<!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>&nbsp;I have created following quick 
and dirty two php scripts(svgmap.php,<BR>wkt2svg.php) for creating SVG instances 
from WKT(Point &amp; Polygon) which<BR>are returned by PostGIS as a result of 
spatial queries.<BR><BR>&nbsp;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>&nbsp;And change your DB info(host, ID 
etc.) and table info for your data.<BR><BR>&nbsp;Sorry, these scripts are 
incomplete for dealing with inner polygons 
and<BR>multi-polygons.<BR><BR>&nbsp;<BR>&nbsp;List1&nbsp; 
svgmap.php<BR><BR>&lt;?php<BR><BR>include("wkt2svg.inc"); # load 
wkt2svg<BR><BR>//////////////////////////////////////////////////<BR>//&nbsp;&nbsp; 
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("&lt;hr&gt;pg_connect &lt;/hr&gt;");}<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>&nbsp;$resultstr = pg_result($execid,0,0);<BR><BR>&nbsp;$extent = 
getExtent($resultstr);<BR><BR>// create extent<BR>&nbsp; 
createExtent($extent);<BR><BR>//<BR>// Polygon Layer<BR>//<BR>&nbsp; 
$layerName="your table name";# Polygon Geometry included<BR>&nbsp; $fillColor = 
"cyan"; # filled Color name or hex<BR>&nbsp; $outlineColot = "blue"; # out line 
# Polygon Geometry included<BR>&nbsp; $where = "geoid &gt;= 0"; # 
condition<BR><BR>&nbsp; getPolygons($dbcon, $layerName, $fillColor, 
$outlineColot,$where);<BR><BR>//<BR>// LineString Layer<BR>//<BR>&nbsp; 
$layerName="eki";# Point Geometry included<BR>&nbsp; getPoints($dbcon, 
$layerName); <BR><BR>&nbsp;// close SVG<BR>&nbsp; 
createFooter();<BR><BR>}<BR>?&gt;<BR>&nbsp; 
<BR>------------------------------------------------------------------------<BR>---------------------------------------<BR><BR>List 
2 wkt2svg<BR><BR>&lt;?<BR>&nbsp; //XML header<BR>function 
showHeader(){<BR>&nbsp; header("Content-type: 
image/svg-xml");<BR><BR>//Header<BR><BR>&nbsp; print('&lt;?xml version="1.0" 
encoding="iso-8859-1"?&gt;' . "\n");<BR><BR>// <BR>/*<BR>print('&lt;!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"&gt;' . "\n");<BR>*/<BR>};<BR><BR>//generate a tag for 
extent<BR>function createExtent($extent){<BR><BR>&nbsp;$xmin = 
$extent[0];<BR>&nbsp;$ymin = $extent[1];<BR><BR>&nbsp;$width= $extent[3] - 
$extent[0];<BR>&nbsp;$height= $extent[4] - $extent[1];<BR><BR>&nbsp;$height2= 
$extent[4] + $extent[1];<BR><BR>&nbsp; //print '&lt;svg width="512" height="512" 
viewBox="'.$xmin.' '.$ymin.'<BR>'.$width.' '.$height.'"&gt;';<BR>&nbsp; print 
'&lt;svg viewBox="'.$xmin.' '.$ymin.' '.$width.' '.$height.'"&gt;';<BR>&nbsp; 
print '&lt;g transform="matrix(1 0 0 -1 0 '.$height2.')" &gt;'; 
#Affine<BR>&nbsp;<BR>};<BR>//close svg<BR>function createFooter(){<BR>&nbsp; 
print '&lt;/g&gt;';<BR>&nbsp; print('&lt;/svg&gt;' . "\n");<BR>};<BR>//get 
extent<BR>function getExtent($result){<BR>&nbsp;$tmpstr = str_replace("BOX3D(", 
"", $result);<BR>&nbsp;$tmpstr = str_replace(")", "", $tmpstr);<BR>&nbsp;$tmpstr 
= str_replace(",", " ", $tmpstr);<BR>&nbsp;return explode(" ", 
$tmpstr);<BR>};<BR>//start a layer or g group<BR>function 
layerHeader(){<BR>&nbsp;&nbsp; print('&lt;g&gt;' . "\n");<BR>}<BR>//close a 
layer<BR>function layerFooter(){<BR>&nbsp;&nbsp; print('&lt;/g&gt;' . 
"\n");<BR>}<BR>//get coordinates of points<BR>function getPoints($dbcon, 
$layerName){<BR>&nbsp; $sql= "SELECT geoid, x(GEO_VALUE), y(GEO_VALUE) FROM 
".$layerName;<BR>&nbsp; $execid = pg_exec ($dbcon, $sql);<BR><BR>&nbsp; 
print('&lt;g id="'.$layerName.'"&gt;' . "\n");<BR><BR>&nbsp; for ($i=0;$i &lt; 
pg_numrows($execid);$i++){<BR>&nbsp;&nbsp;&nbsp; $id = pg_result($execid,$i,0); 
//id<BR>&nbsp;&nbsp;&nbsp; $x= pg_result($execid,$i,1);&nbsp;&nbsp; // X 
<BR>&nbsp;&nbsp;&nbsp; $y = pg_result($execid,$i,2); // 
Y<BR><BR>&nbsp;&nbsp;&nbsp; print '&lt;circle style="fill:red;fill-stroke:blue;" 
id="'.$id.'"<BR>cx="'.$x.'" cy="'.$y.'" r="100px"/&gt;';<BR>&nbsp; 
};<BR><BR>&nbsp; print('&lt;/g&gt;');<BR>};<BR>//<BR>// create a Path for a 
Polygon<BR>//<BR>function getPolygons($dbcon, $layerName, 
$fillColor,$outlineColor,<BR>$where){<BR><BR>&nbsp;if($where == 
"")<BR>&nbsp;&nbsp; $sql= "SELECT exteriorring(GEO_VALUE) FROM 
".$layerName;<BR>&nbsp;else<BR>&nbsp;&nbsp; $sql= "SELECT 
exteriorring(GEO_VALUE) FROM ".$layerName." 
WHERE<BR>".$where;<BR><BR>&nbsp;$execid = pg_exec ($dbcon, 
$sql);<BR><BR>&nbsp;print('&lt;g id="'.$layerName.'"&gt;' . 
"\n");<BR><BR>&nbsp;for ($i=0;$i &lt; pg_numrows($execid);$i++){<BR>&nbsp;&nbsp; 
$exterior = pg_result($execid,$i,0);<BR>&nbsp;&nbsp; //remove 
SRID=-1;<BR>&nbsp;&nbsp; $tempstr = explode(";", $exterior);<BR>&nbsp;&nbsp; 
$exterior = $tempstr[1];<BR><BR>&nbsp;&nbsp; print 
'&lt;path<BR>style="fill:'.$fillColor.';stroke:'.$outlineColor.';stroke-width:22"<BR>d="'.createPolygonPath($exterior).'" 
/&gt;';<BR>&nbsp;};<BR><BR>&nbsp;print('&lt;/g&gt;');<BR>};<BR>//<BR>// generate 
a path<BR>//<BR><BR>function createPolygonPath($result){<BR>&nbsp; $tmpstr = 
str_replace("LINESTRING(", "", $result);<BR>&nbsp; $tmpstr = str_replace(")", 
"", $tmpstr);<BR>&nbsp; $tmpstr = str_replace(",", "L", $tmpstr);<BR>&nbsp; 
$tmpstr = str_replace(" ", ",", $tmpstr);<BR>&nbsp;return 
"M".$tmpstr."z";<BR>};<BR><BR>?&gt;</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&#95;227&#95;105&#95;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&nbsp;&nbsp;&nbsp;&nbsp;
<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>