<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-2022-jp">
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2><FONT size=3>Hi,<BR><BR> I have created following quick 
and dirty two php scripts(svgmap.php,<BR>wkt2svg.php) for creating SVG instances 
from WKT(Point & Polygon) which<BR>are returned by PostGIS as a result of 
spatial queries.<BR><BR> You must install SVG Adobe Viewer Plug-In 
(</FONT><A href="http://www.adobe.com/svg"><FONT 
size=3>http://www.adobe.com/svg</FONT></A><FONT size=3>)<BR>Ver 2.0 or later 
into your PC if it not installed..<BR><BR> And change your DB info(host, ID 
etc.) and table info for your data.<BR><BR> Sorry, these scripts are 
incomplete for dealing with inner polygons 
and<BR>multi-polygons.<BR><BR> <BR> List1  
svgmap.php<BR><BR><?php<BR><BR>include("wkt2svg.inc"); # load 
wkt2svg<BR><BR>//////////////////////////////////////////////////<BR>//   
Main<BR>//////////////////////////////////////////////////<BR><BR>showHeader();<BR><BR>//<BR>// 
Set DB Connection Info<BR>//<BR>$hostName = "your host name";<BR>$USR = 
"your-id";<BR>$PASSWRD = "your password";<BR>$TABLE="your database 
name";<BR><BR>$dbcon = pg_connect("host=".$hostName." user=".$USR 
."<BR>password=".$PASSWRD." dbname=".$TABLE); # connect to DB<BR>;<BR><BR>if 
(!$dbcon) { die("<hr>pg_connect </hr>");}<BR><BR>$sql= "SET 
ENABLE_SEQSCAN = OFF";<BR><BR>$execid = pg_exec ($dbcon, 
$sql);<BR><BR>$layerName = "your table name"; # Polygon Geometry 
included<BR><BR>$sql= "SELECT extent(GEO_VALUE) FROM ".$layerName; # get Map 
Extent<BR><BR>$execid = pg_exec ($dbcon, $sql);<BR><BR>if (!$execid){<BR>} else 
{<BR><BR> $resultstr = pg_result($execid,0,0);<BR><BR> $extent = 
getExtent($resultstr);<BR><BR>// create extent<BR>  
createExtent($extent);<BR><BR>//<BR>// Polygon Layer<BR>//<BR>  
$layerName="your table name";# Polygon Geometry included<BR>  $fillColor = 
"cyan"; # filled Color name or hex<BR>  $outlineColot = "blue"; # out line 
# Polygon Geometry included<BR>  $where = "geoid >= 0"; # 
condition<BR><BR>  getPolygons($dbcon, $layerName, $fillColor, 
$outlineColot,$where);<BR><BR>//<BR>// LineString Layer<BR>//<BR>  
$layerName="eki";# Point Geometry included<BR>  getPoints($dbcon, 
$layerName); <BR><BR> // close SVG<BR>  
createFooter();<BR><BR>}<BR>?><BR>  
<BR>------------------------------------------------------------------------<BR>---------------------------------------<BR><BR>List 
2 wkt2svg<BR><BR><?<BR>  //XML header<BR>function 
showHeader(){<BR>  header("Content-type: 
image/svg-xml");<BR><BR>//Header<BR><BR>  print('<?xml version="1.0" 
encoding="iso-8859-1"?>' . "\n");<BR><BR>// <BR>/*<BR>print('<!DOCTYPE svg 
PUBLIC "-//W3C//DTD SVG //EN" ');<BR><BR>print('"</FONT><A 
href="http://www.w3.org/TR/2001/"><FONT 
size=3>http://www.w3.org/TR/2001/</FONT></A><FONT size=3> PR-SVG-20010719/DTD/' 
.<BR><BR>'svg10.dtd">' . "\n");<BR>*/<BR>};<BR><BR>//generate a tag for 
extent<BR>function createExtent($extent){<BR><BR> $xmin = 
$extent[0];<BR> $ymin = $extent[1];<BR><BR> $width= $extent[3] - 
$extent[0];<BR> $height= $extent[4] - $extent[1];<BR><BR> $height2= 
$extent[4] + $extent[1];<BR><BR>  //print '<svg width="512" height="512" 
viewBox="'.$xmin.' '.$ymin.'<BR>'.$width.' '.$height.'">';<BR>  print 
'<svg viewBox="'.$xmin.' '.$ymin.' '.$width.' '.$height.'">';<BR>  
print '<g transform="matrix(1 0 0 -1 0 '.$height2.')" >'; 
#Affine<BR> <BR>};<BR>//close svg<BR>function createFooter(){<BR>  
print '</g>';<BR>  print('</svg>' . "\n");<BR>};<BR>//get 
extent<BR>function getExtent($result){<BR> $tmpstr = str_replace("BOX3D(", 
"", $result);<BR> $tmpstr = str_replace(")", "", $tmpstr);<BR> $tmpstr 
= str_replace(",", " ", $tmpstr);<BR> return explode(" ", 
$tmpstr);<BR>};<BR>//start a layer or g group<BR>function 
layerHeader(){<BR>   print('<g>' . "\n");<BR>}<BR>//close a 
layer<BR>function layerFooter(){<BR>   print('</g>' . 
"\n");<BR>}<BR>//get coordinates of points<BR>function getPoints($dbcon, 
$layerName){<BR>  $sql= "SELECT geoid, x(GEO_VALUE), y(GEO_VALUE) FROM 
".$layerName;<BR>  $execid = pg_exec ($dbcon, $sql);<BR><BR>  
print('<g id="'.$layerName.'">' . "\n");<BR><BR>  for ($i=0;$i < 
pg_numrows($execid);$i++){<BR>    $id = pg_result($execid,$i,0); 
//id<BR>    $x= pg_result($execid,$i,1);   // X 
<BR>    $y = pg_result($execid,$i,2); // 
Y<BR><BR>    print '<circle style="fill:red;fill-stroke:blue;" 
id="'.$id.'"<BR>cx="'.$x.'" cy="'.$y.'" r="100px"/>';<BR>  
};<BR><BR>  print('</g>');<BR>};<BR>//<BR>// create a Path for a 
Polygon<BR>//<BR>function getPolygons($dbcon, $layerName, 
$fillColor,$outlineColor,<BR>$where){<BR><BR> if($where == 
"")<BR>   $sql= "SELECT exteriorring(GEO_VALUE) FROM 
".$layerName;<BR> else<BR>   $sql= "SELECT 
exteriorring(GEO_VALUE) FROM ".$layerName." 
WHERE<BR>".$where;<BR><BR> $execid = pg_exec ($dbcon, 
$sql);<BR><BR> print('<g id="'.$layerName.'">' . 
"\n");<BR><BR> for ($i=0;$i < pg_numrows($execid);$i++){<BR>   
$exterior = pg_result($execid,$i,0);<BR>   //remove 
SRID=-1;<BR>   $tempstr = explode(";", $exterior);<BR>   
$exterior = $tempstr[1];<BR><BR>   print 
'<path<BR>style="fill:'.$fillColor.';stroke:'.$outlineColor.';stroke-width:22"<BR>d="'.createPolygonPath($exterior).'" 
/>';<BR> };<BR><BR> print('</g>');<BR>};<BR>//<BR>// generate 
a path<BR>//<BR><BR>function createPolygonPath($result){<BR>  $tmpstr = 
str_replace("LINESTRING(", "", $result);<BR>  $tmpstr = str_replace(")", 
"", $tmpstr);<BR>  $tmpstr = str_replace(",", "L", $tmpstr);<BR>  
$tmpstr = str_replace(" ", ",", $tmpstr);<BR> return 
"M".$tmpstr."z";<BR>};<BR><BR>?></FONT><BR><BR><BR></FONT></DIV>
<br>

<!-- |**|begin egp html banner|**| -->

<table border=0 cellspacing=0 cellpadding=2>
<tr bgcolor=#FFFFCC>
<td align=center><font size="-1" color=#003399><b>Yahoo! Groups Sponsor</b></font></td>
</tr>
<tr bgcolor=#FFFFFF>
<td align=center width=470><table width="300" border="0" cellspacing="0" cellpadding="0"><tr><td width="300">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="184" colspan="2"><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/itapeorng4_11_12.gif" width="154" height="70" alt="" border="0"></td>
<td width="116" rowspan="2"><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/1111.jpg" width="146" height="221" alt="" border="0"></td>
</tr><form method="get" action="http://rd.yahoo.com/M=210544.1579876.3135161.1261774/D=egroupweb/S=1705007183:HM/A=776687/R=0/*http://ads.track-star.com/adspace.ts">
<tr valign="bottom"><td width="1" bgcolor="#FF6600"><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/orgline.gif" width="1" height="151" alt="" border="0"></td>
<td width="183" bgcolor="#FFCC00" align="center"><input type="hidden" name="ts" value="1;2;217;107_227_105_264"><input type="hidden" name="startApplication" value="%20">
<font style="font-size: 12px;font-family:Times New Roman,Times,serif;font-weight:bold;">Start here...<br><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/clear.gif" width="5" height="5" alt="" border="0"><br>Height:<br><select name="feet" size="1" maxlength="1" > <option value="3">3
<option value="4">4
<option value="5" selected>5
<option value="6">6
<option value="7">7
<option value="8">8
</select>
ft    
<select name="inches" size="1" maxlength="2">
<option value="00">0
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4" selected>4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8">8
<option value="9">9
<option value="10">10
<option value="11">11
</select>in<br><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/clear.gif" width="5" height="5" alt="" border="0"><br>
Weight:<br>
<input name="weightUnit" type="radio" value="pounds" checked style="background:#FFCC00;color:#000001;">lbs.
<input name="weightUnit" type="radio" value="kilograms" style="background:#FFCC00;color:#000001;">kg.<br>
<input type="text" name="weight" size="5" value=""></font><br><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/clear.gif" width="5" height="8" alt="" border="0"><br><img src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/3333.gif" width="153" height="19" alt="" border="0"></td></tr>
<tr><td colspan="3" width="300"><input type="image" src="http://us.a1.yimg.com/us.yimg.com/a/di/dietsmart/2222.gif" width="300" height="29" alt="" border="0"></td></tr></form>
</table></td></tr></table></td>
</tr>
<tr><td><img alt="" width=1 height=1 src="http://us.adserver.yahoo.com/l?M=210544.1579876.3135161.1261774/D=egroupmail/S=1705007183:HM/A=776687/rand=376490136"></td></tr>
</table>

<!-- |**|end egp html banner|**| -->


<br>
<tt>
To unsubscribe from this group, send an email to:<BR>
postgis-unsubscribe@yahoogroups.com<BR>
<BR>
</tt>
<br>

<br>
<tt>Your use of Yahoo! Groups is subject to the <a href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</a>.</tt>
</br>

</BODY></HTML>