#!/usr/bin/perl
use DBI;
use CGI::Carp qw(fatalsToBrowser);
#Set content type
print "Content-Type: image/svg-xml\n\n";
#Establish connection to database
$dbh = DBI->connect ('dbi:Oracle:geosgen','USER','PASS')
|| die "Man down! Man down!: $DBI::errstr";
#Send SQL query for mountains
$sth1 = $dbh->prepare("select table_alias.mot.sdo_point.X, table_alias.mot.sdo_point.Y, table_alias.name
from X.mounts table_alias");
$sth1->execute;
#Send SQL query for tourist attraction
$sth2 = $dbh->prepare("select table_alias.mot.sdo_point.X, table_alias.mot.sdo_point.Y
from s1227289.tours table_alias");
$sth2->execute;
#Set content type
print qq(<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
"http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">);
print qq(<svg width="20cm" height="20cm" viewBox="-5.8 56 0.8 2">);
#print mountains
while (@data = $sth1->fetchrow_array()) {
print qq(
<circle cx="$data[1]" cy="$data[0]" r="0.002" fill="green">
</circle>
<text x="$data[1]"
y="$data[0]"
fill="black"
style='font-size:0.01px;font-family:Arial'>$data[2]</text>
);
}
#print tourist attractions
while (@data = $sth2->fetchrow_array()) {
print qq(
<circle cx="$data[1]" cy="$data[0]" r="0.002" fill="red">
</circle>
);
}
print qq(</svg>);
我一直在努力解决这个问题,但是我无法理解它!问题在于转型。绘制的点是颠倒的,需要翻转。我之前已经解决了类似的问题,但这次y值都是负数(即-5.8)
我该如何解决这个问题?总结一下,我基本上想要进行转换,但是如何用-ve数字来解决这个问题。我搜索过类似的问题,但没有人处理过-ve数字。
答案 0 :(得分:0)
添加transform =“scale(1,-1)”属性将翻转事物。或者也可能更简单,在你的php输出中,y值为-1 * $ data [0]