<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;}
span.emailstyle19
{font-family:Arial;
color:navy;}
span.EmailStyle20
{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'>I don’t know the center() function,
but you can try the centroid() one</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>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This query was working for me (my spatial
column is geom)</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>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>select AsBinary(centroid(geom)) as
mycenter from "fr_lamb_mg_1_region"</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:48 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'>AsBinary() and AsText() require a "geometry object as input. My
object is of type "Point" and will non execute the query.I tried
executing the query alone.Am I doing something wrong? Do you know how I can
convert Point or types "circle" into binary?</span></font></p>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I am also using postgis_1.1.0.jar.</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'>"Gilbert,
Antoine" <AGilbert@korem.com></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'>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Yes</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=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I’m not a postgis expert, but I
think in your case it should be </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 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>ResultSet rs =
s.executeQuery("select (AsBinary(center(geometry)))) as mycenter from
land");</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 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>You have to convert
the geometry in the binary format</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 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>You can use AsText
too and use new PGgeometry(rs.getString(1)) or something like that I think</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 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>I’m using
postgis_1_0_0.jar</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>
<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>
<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 3:19 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>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Hi</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> I tried what you did but the program wouln't even compile. I have
a table named "land" which has an attribute"geometry" of
type "circle". I want to retrieve the center of the circle which is
of type "point" as defined by postGIS.Here is my Program</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>import java.sql.*;<br>
import org.postgis.*;</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'>public class JavaGIS3
{ <br>
public static void main(String[] args) <br>
{ <br>
java.sql.Connection conn; <br>
try <br>
{ <br>
Class.forName("org.postgresql.Driver"); <br>
String url =
"jdbc:postgresql://localhost:5432/dcmms"; <br>
conn = DriverManager.getConnection(url, "postgres",
"abcde"); <br>
Statement s = conn.createStatement(); <br>
ResultSet rs = s.executeQuery("select
(center(geometry))as mycenter from land"); <br>
ResultSetMetaData rsmd = rs.getMetaData();<br>
for(int i=0;rs.next();i++){<br>
Geometry geometry = new
BinaryParser().parse(rs.getBytes(1));<br>
if(geometry.getType()==geometry.POINT){<br>
System.out.println("Finally retrieved geometry object!")<br>
}<br>
}<br>
s.close(); <br>
conn.close(); <br>
} <br>
catch( Exception e ) <br>
{ <br>
e.printStackTrace(); <br>
}<br>
}<br>
}</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I did what you had said in your email but it would give an
error:</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=red face="Times New Roman"><span
style='font-size:10.0pt;color:red'>BinaryParser cannot be resolved to a type</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:black'>What should I do? Did you compile your
program?</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 color="#0000bf" face=Courier><span
style='font-size:12.0pt;font-family:Courier;color:#0000BF'><br>
</span></font><b><i><span style='font-weight:bold;font-style:italic'>"Gilbert,
Antoine" <AGilbert@korem.com></span></i></b> wrote:</p>
</div>
</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'>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Here is my example using postgis_1_0_0.jar</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Connection connection =
TestUtils.getTestConnection();</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
Statement stmt = connection.createStatement();</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
ResultSet rs = stmt.executeQuery("select AsBinary(geom) as geom from
\"rue_test_polyline\"");</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
ResultSetMetaData rsmd = rs.getMetaData();</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
for(int i=0;rs.next();i++){</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
Geometry geometry = new BinaryParser().parse(rs.getBytes(1));</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
if(geometry.getType()==geometry.MULTILINESTRING){</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
MultiLineString multiline = ((MultiLineString)geometry);</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
System.out.println(multiline.toString());</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
System.out.println("ligne "+i+" contient
"+multiline.numLines()+" segment(s)");</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
for(int j=0;j<multiline.numLines();j++)</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
System.out.println(" segment
"+j+":"+multiline.getLine(j).numPoints()+" points");</span></font></p>
</div>
</div>
<div>
<div>
<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>
<div>
<div>
<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>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
stmt.close();</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>
connection.close();</span></font></p>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<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>
<div>
<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 3:43 AM<br>
<b><span style='font-weight:bold'>To:</span></b>
postgis-users@postgis.refractions.net<br>
<b><span style='font-weight:bold'>Subject:</span></b> [postgis-users] JAVA and
post GIS</span></font></p>
</div>
</div>
</div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</div>
<div id=RTEContent>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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. </span></font></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>-fatemeh</span></font></p>
</div>
</div>
</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>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Bring words and photos together (easily) with<br>
<a
href="http://us.rd.yahoo.com/mail_us/taglines/PMHM3/*http:/photomail.mail.yahoo.com">PhotoMail
</a>- it's free and works with Yahoo! Mail.</span></font></p>
</div>
</div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>_______________________________________________<br>
postgis-users mailing list<br>
postgis-users@postgis.refractions.net<br>
http://postgis.refractions.net/mailman/listinfo/postgis-users</span></font></p>
</div>
</blockquote>
<div>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> </span></font></p>
</div>
</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>
<div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><a
href="http://us.rd.yahoo.com/evt=38381/%20ylc=X3oDMTEzcGlrdGY5BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMWF1dG9z/*http:/autos.yahoo.com/index.html%20">Yahoo!
Autos</a>. Looking for a sweet ride? Get pricing, reviews, & more on new
and used cars.</span></font></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>_______________________________________________<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'><a
href="http://us.rd.yahoo.com/evt=38381/%20ylc=X3oDMTEzcGlrdGY5BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMWF1dG9z/*http:/autos.yahoo.com/index.html%20">Yahoo!
Autos</a>. Looking for a sweet ride? Get pricing, reviews, & more on new
and used cars.</span></font></p>
</div>
</body>
</html>