[postgis-users] JAVA and post GIS
Gilbert, Antoine
AGilbert at korem.com
Mon Jan 30 13:39:09 PST 2006
All these examples not working with the current versions
_____
From: Fatemeh Abbasinejad [mailto:fabbasinejad at yahoo.com]
Sent: January 30, 2006 4:09 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] JAVA and post GIS
Hi.
I sae the code and tried to execute it on my own tables.Ther were some
problems:
First when trying to add data types it would give me a warning that the
method addDataType has been deprecated.
Also when I tried to cast to PGeometry it would throw
"ClassCastException".Here is my code:
((PGConnection)conn).addDataType("geometry","org.postgis.PGgeometry");
Statement s = conn.createStatement();
ResultSet r = s.executeQuery("select center(geometry)as mycenter from
land");
while( r.next() )
{
PGgeometry mycenter = (PGgeometry)r.getObject(1);
System.out.println(mycenter.toString());
}
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".
Have I casted wrong? I also tried casting to "Point" but it would give
the same exception. What should I do?
Emily Gouge <egouge at refractions.net> wrote:
Hi,
There is some documentation and an example on connecting to
PostGIS using Java. See:
http://postgis.refractions.net/docs/ch04.html#id2789526
You can add a datatype to the postgres connection and then the
getObject() call will return a
PGGeometry object:
((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PG
geometry");
Additionally you can also check out the postgis_jts jar, which
provides the ability to return a
JtsGeometry object (and subsequently to convert this object to a
JTS Geometry object).
Emily
Fatemeh Abbasinejad wrote:
> I am new to PostGIS. Does anyone know how we can retrieve our
defined data types
> (like point,circle,...) from a ResultSet in java. I used
getObject but it didn't work.
> -fatemeh
>
>
> ---------------------------------
> Bring words and photos together (easily) with
> PhotoMail - it's free and works with Yahoo! Mail.
>
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
_____
What are the most popular cars? Find out at Yahoo! Autos
<http://us.rd.yahoo.com/evt=38382/_ylc=X3oDMTEzNWFva2Y2BF9TAzk3MTA3MDc2B
HNlYwNtYWlsdGFncwRzbGsDMmF1dG9z/*http:/autos.yahoo.com/newcars/popular/t
hisweek.html%20%0d%0a>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060130/a65f0ed0/attachment.html>
More information about the postgis-users
mailing list