<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:NimbusMonL-Regu-Extend_850;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:blue;
text-decoration:underline;}
p
{mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman";}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white lang=EN-US link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi, I don’t know if it is the best
way, but I implement this class:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>import</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> java.sql.*;</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>import</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> org.postgis.PGgeometry;</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>import</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> com.vividsolutions.jts.geom.*;</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>import</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> com.vividsolutions.jts.io.*;</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>public class</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> GeometryReader </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>{</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>static</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>int</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font><i><font
size=2 color="#0000c0" face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:#0000C0;font-style:italic'>SRID</span></font></i><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>= 0;</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>static</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> GeometryFactory </span></font><i><font size=2 color="#0000c0"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000C0;font-style:italic'>fact</span></font></i><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>= </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>new</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
GeometryFactory(</span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>new</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
PrecisionModel(1E10), </span></font><i><font size=2 color="#0000c0"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#0000C0;font-style:italic'>SRID</span></font></i><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>);</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>static</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>public</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> Geometry
getGeometry(Object obj) </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>throws</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> SQLException, ParseException </span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> {</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>return</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> <i><span style='font-style:italic'>getGeometry</span></i>(((PGgeometry)obj).toString());</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> }</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>static</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>public</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> Geometry
getGeometry(String geometryStr) </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>throws</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> SQLException, ParseException </span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> {</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> WKTReader r= </span></font><b><font size=2
color="#7f0055" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#7F0055;font-weight:bold'>new</span></font></b><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'> WKTReader( </span></font><i><font size=2
color="#0000c0" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#0000C0;font-style:italic'>fact</span></font></i><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'> );</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> Geometry geom;</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 color="#3f7f5f"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#3F7F5F'>// ADD SRID</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>if</span></font></b><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> (geometryStr.indexOf(</span></font><font size=2 color="#2a00ff"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#2A00FF'>';'</span></font><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>) != -1)</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> {</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> String []temp= PGgeometry.<i><span
style='font-style:italic'>splitSRID</span></i>(geometryStr);</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>int</span></font></b><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> srid= Integer.<i><span style='font-style:italic'>parseInt</span></i>(temp[0].substring(5));</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> geom= (Geometry) r.read(temp[1]);</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> geom.setSRID(</span></font><i><font size=2
color="#0000c0" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#0000C0;font-style:italic'>SRID</span></font></i><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>);</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> }</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>else</span></font></b><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> geom= (Geometry) r.read(geometryStr);</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>return</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> geom;</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> }</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>}</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>And in every place where I need to recover
a geometry (Polygon, Linestring, etc) I invoke GeometryReader.getGeometry( );.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>i.e:<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>public</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>class</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> Rta </span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>{</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>public</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055;font-weight:
bold'>static</span></font></b><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font><b><font
size=2 color="#7f0055" face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:#7F0055;font-weight:bold'>void</span></font></b><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'> main(String[] args) </span></font><b><font size=2
color="#7f0055" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#7F0055;font-weight:bold'>throws</span></font></b><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'> ClassNotFoundException, SQLException,
ParseException </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> {</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> Class.<i><span style='font-style:italic'>forName</span></i>(</span></font><font
size=2 color="#2a00ff" face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:#2A00FF'>"org.postgresql.Driver"</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>);</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> Connection conn= DriverManager.<i><span
style='font-style:italic'>getConnection</span></i>( </span></font><font size=2
color="#2a00ff" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#2A00FF'>"jdbc:postgresql://localhost:5432/proof"</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>, </span></font><font size=2 color="#2a00ff"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#2A00FF'>"postgres"</span></font><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>, </span></font><font size=2 color="#2a00ff" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"postgres"</span></font><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'> );</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> String queryDML= </span></font><font size=2
color="#2a00ff" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#2A00FF'>"SELECT geometryColumn FROM region LIMIT
10"</span></font><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> Statement stmt= conn.createStatement();</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> ResultSet rs= stmt.executeQuery(queryDML);</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><b><font size=2 color="#7f0055"
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055;font-weight:bold'>while</span></font></b><font size=2
color=black face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> ( rs.next() )</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> {</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> Geometry geometryRead= GeometryReader.<i><span
style='font-style:italic'>getGeometry</span></i>(rs.getObject(1));</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> System.</span></font><i><font size=2
color="#0000c0" face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:#0000C0;font-style:italic'>out</span></font></i><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>.println(geometryRead.getArea());</span></font><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> }</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> ….</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> }</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>}</span></font><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Then I obtain a Geometry reference.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Leticia<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=3 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> <st1:PersonName
w:st="on">postgis-users-bounces@postgis.refractions.net</st1:PersonName>
[mailto:<st1:PersonName w:st="on">postgis-users-bounces@postgis.refractions.net</st1:PersonName>]
<b><span style='font-weight:bold'>On Behalf Of </span></b>shojka@web.de<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, May 11, 2007 11:45
AM<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">postgis-users@postgis.refractions.net</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> [postgis-users] Buffering
with JDBC</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span style='font-size:10.0pt;
font-family:Verdana'> </span></font><font size=1 face=Verdana><span
style='font-size:9.0pt;font-family:Verdana'><o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>import
java.sql.*; import java.util.*; import java.lang.*; import org.postgis.*; <o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>public
class JavaGIS { public static void main(String[] args)<o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>{<o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>java.sql.Connection
conn;<o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>try<o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>{<o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'>
Class.forName("org.postgresql.Driver");<o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'> String
url = "jdbc:postgresql://localhost:5432/database"; conn =
DriverManager.getConnection(url, "postgres", ""); <o:p></o:p></span></font></p>
<p><font size=1 face=Verdana><span style='font-size:9.0pt;font-family:Verdana'> ((org.postgresql.jdbc2.Jdbc2Connection)conn).addDataType("Geometry","org.postgis.PGgeometry");<br>
((org.postgresql.jdbc2.Jdbc2Connection)conn).addDataTy
pe("box3d","org.postgis.PGbox3d");<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> Statement s =
conn.createStatement();<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> ResultSet r =
s.executeQuery("SELECT Buffer(GeometryFromText('POINT(10000
20000)',-1),20)");<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> while( r.next() )<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> {<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
PGgeometry geom= (PGgeometry)r.getObject(1);<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> if( geom.getType() =
Geometry.POLYGON )<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> {<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
Polygon pl = (Polygon)geom.getGeometry();<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
for( int r = 0; r < pl.numRings(); r++ )<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> {<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
LinearRing rng = pl.ge tRing(r);<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
System.out.println("Ring: " + r);<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
for( int p = 0; p < rng.numPoints(); p++ )<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> {<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
Point pt = rng.getPoint(p);<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
System.out.println("Point: " + p);<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>
System.out.println(pt.toString());<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> }<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> }<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> }<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>}<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>s.close();<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>conn.close();<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>}<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>catch( Exception e )<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>{<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>e.printStackTrace();<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>}<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>}<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>}<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>Dear PostGis users,<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>I want to use buf fer function from
POSTGIS but I simply cannot convert the result of query in a PGgeometry
object. The line:<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'> PGgeometry geom=
(PGgeometry)r.getObject(1);<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>results always in:<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>java.lang.ClassCastException:
org.postgresql.util.PGobject<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>I got result as a strine when i insert
in qery function Astext(), but when I want to work with geometry I am helpless.
Has anyone an idea how this problem could be solved?<o:p></o:p></span></font></p>
<p><font size=2 face="NimbusMonL-Regu-Extend_850"><span style='font-size:10.0pt;
font-family:NimbusMonL-Regu-Extend_850'>Thanking in advance<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=1 face=Verdana><span
style='font-size:9.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0>
<tr>
<td bgcolor=black style='background:black;padding:0in 0in 0in 0in'>
<p class=MsoNormal><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><img width=1 height=1 id="_x0000_i1025"
src="https://img.web.de/p.gif" border=0><o:p></o:p></span></font></p>
</td>
</tr>
<tr>
<td style='padding:0in 0in 0in 0in'>
<p class=MsoNormal style='line-height:10.2pt'><font size=1 face=Verdana><span
style='font-size:7.0pt;font-family:Verdana'>Erweitern Sie FreeMail zu einem
noch leistungsstärkeren E-Mail-Postfach! <br>
Mehr Infos unter <a href="http://produkte.web.de/club/?mc=021131"><b><span
style='font-weight:bold'>http://produkte.web.de/club/?mc=021131</span></b></a>&
nbsp; <o:p></o:p></span></font></p>
</td>
</tr>
</table>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>