0
#!/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 数字。

4

1 回答 1

0

添加一个 transform="scale(1, -1)" 属性会翻转。或者可能更简单,在您的 php 输出中将 y 值作为 -1 * $data[0]

于 2013-02-15T08:43:38.503 回答