<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
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
{margin-right:0cm;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman";}
span.EmailStyle18
{font-family:Arial;
color:navy;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body 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'>All these examples not working with the
current versions</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </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=2 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'> Fatemeh
Abbasinejad [mailto:fabbasinejad@yahoo.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> January 30, 2006 4:09 PM<br>
<b><span style='font-weight:bold'>To:</span></b> PostGIS Users Discussion<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [postgis-users] JAVA
and post GIS</span></font></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Hi.</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I sae the code and tried to execute it on my own tables.Ther were some
problems:</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>First when trying to add data types it would give me a warning that the
method addDataType has been deprecated.</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Also when I tried to cast to PGeometry it would throw
"ClassCastException".Here is my code:</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
<div>
<p class=MsoNormal><font size=1 color="#0000bf" face=Courier><span
style='font-size:7.5pt;font-family:Courier;color:#0000BF'>((PGConnection)conn).addDataType("geometry","org.postgis.PGgeometry");</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>Statement s =
conn.createStatement(); <br>
ResultSet r = s.executeQuery("select center(geometry)as mycenter from
land"); </span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>while( r.next() ) <br>
{ <br>
PGgeometry mycenter =
(PGgeometry)r.getObject(1); <br>
System.out.println(mycenter.toString());
<br>
}</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I have a table called "land" which has an attribute
"geometry" of type Circle.I want to retreive the center of the circle
which is of type "Point".</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Have I casted wrong? I also tried casting to "Point" but it
would give the same exception. What should I do?</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br>
<b><i><span style='font-weight:bold;font-style:italic'>Emily Gouge
<egouge@refractions.net></span></i></b> wrote:</span></font></p>
</div>
<blockquote style='border:none;border-left:solid #1010FF 1.5pt;padding:0cm 0cm 0cm 4.0pt;
margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt'>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Hi,<br>
<br>
There is some documentation and an example on connecting to PostGIS using Java.
See:<br>
http://postgis.refractions.net/docs/ch04.html#id2789526<br>
<br>
You can add a datatype to the postgres connection and then the getObject() call
will return a <br>
PGGeometry object:<br>
((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");<br>
<br>
Additionally you can also check out the postgis_jts jar, which provides the
ability to return a <br>
JtsGeometry object (and subsequently to convert this object to a JTS Geometry
object).<br>
<br>
Emily<br>
<br>
<br>
<br>
Fatemeh Abbasinejad wrote:<br>
> I am new to PostGIS. Does anyone know how we can retrieve our defined data
types <br>
> (like point,circle,...) from a ResultSet in java. I used getObject but it
didn't work. <br>
> -fatemeh<br>
> <br>
> <br>
> ---------------------------------<br>
> Bring words and photos together (easily) with<br>
> PhotoMail - it's free and works with Yahoo! Mail.<br>
> <br>
> <br>
> ------------------------------------------------------------------------<br>
> <br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> postgis-users@postgis.refractions.net<br>
> http://postgis.refractions.net/mailman/listinfo/postgis-users<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
postgis-users@postgis.refractions.net<br>
http://postgis.refractions.net/mailman/listinfo/postgis-users</span></font></p>
</blockquote>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </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=1 width="100%" align=center>
</span></font></div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
What are the most popular cars? Find out at <a
href="http://us.rd.yahoo.com/evt=38382/_ylc=X3oDMTEzNWFva2Y2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMmF1dG9z/*http:/autos.yahoo.com/newcars/popular/thisweek.html%20%0d%0a">Yahoo!
Autos</a> </span></font></p>
</div>
</body>
</html>