<DIV>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?</DIV> <DIV>I am also using postgis_1.1.0.jar.</DIV> <DIV> </DIV> <DIV><BR><BR><B><I>"Gilbert, Antoine" <AGilbert@korem.com></I></B> wrote:</DIV> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"> <META content="Microsoft Word 11 (filtered)" name=Generator> <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;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt;} div.Section1 {page:Section1;} --> </STYLE> <DIV class=Section1> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Yes</SPAN></FONT></div> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT> </div> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">I’m not a postgis expert, but I think in your case it should be </SPAN></FONT></div> <div class=MsoNormal><FONT face=Arial color=navy
size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT> </div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier">ResultSet rs = s.executeQuery("select (AsBinary(center(geometry)))) as mycenter from land");</SPAN></FONT></div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier"></SPAN></FONT> </div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier">You have to convert the geometry in the binary format</SPAN></FONT></div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier"></SPAN></FONT> </div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier">You can
use AsText too and use new PGgeometry(rs.getString(1)) or something like that I think</SPAN></FONT></div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier"></SPAN></FONT> </div> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier">I’m using postgis_1_0_0.jar</SPAN></FONT></div> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT> </div> <DIV> <DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"> <HR tabIndex=-1 align=center width="100%" SIZE=2> </SPAN></FONT></DIV> <div class=MsoNormal><B><FONT face=Tahoma size=2><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt;
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></div></DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">Hi</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"> 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></div></DIV> <DIV> <div
class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier">import java.sql.*;<BR>import org.postgis.*;</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier">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></div></DIV> <DIV> <div
class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I did what you had said in your email but it would give an error:</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" color=red size=2><SPAN style="FONT-SIZE: 10pt; COLOR: red">BinaryParser cannot be resolved to a type</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial">What should I do? Did you compile your program?</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT
face=Courier color=#0000bf size=3><SPAN style="FONT-SIZE: 12pt; COLOR: #0000bf; FONT-FAMILY: Courier"><BR></SPAN></FONT><B><I><SPAN style="FONT-WEIGHT: bold; FONT-STYLE: italic">"Gilbert, Antoine" <AGilbert@korem.com></SPAN></I></B> wrote:</div></DIV> <BLOCKQUOTE style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; MARGIN-TOP: 5pt; PADDING-LEFT: 4pt; MARGIN-BOTTOM: 5pt; PADDING-BOTTOM: 0cm; MARGIN-LEFT: 3.75pt; BORDER-LEFT: #1010ff 1.5pt solid; PADDING-TOP: 0cm; BORDER-BOTTOM: medium none"> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Hi</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Here is my example using
postgis_1_0_0.jar</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Connection connection = TestUtils.getTestConnection();</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> Statement stmt = connection.createStatement();</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> ResultSet rs = stmt.executeQuery("select AsBinary(geom) as geom from \"rue_test_polyline\"");</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> ResultSetMetaData rsmd = rs.getMetaData();</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> for(int i=0;rs.next();i++){</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> Geometry geometry = new BinaryParser().parse(rs.getBytes(1));</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> if(geometry.getType()==geometry.MULTILINESTRING){</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial
color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> MultiLineString multiline = ((MultiLineString)geometry);</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> System.out.println(multiline.toString());</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> System.out.println("ligne "+i+" contient "+multiline.numLines()+" segment(s)");</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY:
Arial"> for(int j=0;j<multiline.numLines();j++)</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> System.out.println(" segment "+j+":"+multiline.getLine(j).numPoints()+" points");</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> }</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> }</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT
face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> stmt.close();</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"> connection.close();</SPAN></FONT></div></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV> <DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"> <HR tabIndex=-1 align=center width="100%" SIZE=2> </SPAN></FONT></DIV> <DIV> <div class=MsoNormal><B><FONT face=Tahoma size=2><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; 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></div></DIV></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV id=RTEContent> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">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></div></DIV></DIV> <DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">-fatemeh</SPAN></FONT></div></DIV></DIV> <DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"> <HR align=center width="100%" SIZE=1> </SPAN></FONT></DIV> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">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></div></DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">_______________________________________________<BR>postgis-users mailing list<BR>postgis-users@postgis.refractions.net<BR>http://postgis.refractions.net/mailman/listinfo/postgis-users</SPAN></FONT></div></BLOCKQUOTE> <DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"></SPAN></FONT> </div></DIV> <DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR align=center width="100%" SIZE=1> </SPAN></FONT></DIV> <div class=MsoNormal><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"><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></div></DIV>_______________________________________________<BR>postgis-users mailing list<BR>postgis-users@postgis.refractions.net<BR>http://postgis.refractions.net/mailman/listinfo/postgis-users<BR></BLOCKQUOTE> <DIV><BR></DIV><p>
<hr size=1> <a href="http://us.rd.yahoo.com/evt=38381/ ylc=X3oDMTEzcGlrdGY5BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMWF1dG9z/*http://autos.yahoo.com/index.html ">Yahoo! Autos</a>. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.