[postgis] JDBC and WKB; shp2postgresql

dougvanauken dougvanauken at worldnet.att.net
Sat Nov 24 14:55:22 PST 2001


I four questions regarding WKB and JDBC:

First question:
Does anyone have some examples on how to insert and retreive geometry 
using WKB and JDBC:
-------------------------------------------------------
Second question:
According to the OpenGIS SQL specicification an insert using WKB 
would use the following format:
INSERT INTO Countries (Name, Location) VALUES ('Kenya', PolygonFromWKB
(:wnb, :srid)).  

Using this format, how do you insert an WKB object using JDBC?

As an example, if I have this:

Polygon polygon = new Polygon(...);
....
PreparedStatement pstmt = cnn.prepareStatement("INSERT INTO Countries 
(Name, Location) VALUES ('Kenya', ?)
pstmt.setOject(1, polygon)

How would I implement PolgyonFromWKB(:wkb, :srid)?
----------------------------------------------------

Second question:
Is the following the correct way to retreive an object using JDBC and 
WKB?

ResultSet rst = cnn.executeQuery("SELECT Name, AsBinary(Location) 
FROM Countries WHERE Name like 'k%');
while(r.next()){
  String name = r.getString(1)
  PGgeometry geometry = (PGgeometry)r.getObject(2);
}    

------------------------------------------------------
Third question:
If I insert an object as text, can I retreive it as binary, and vice-
versa -- If I insert it as binary, can I retreive it as text?


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Universal Inkjet Refill Kit $29.95
Refill any ink cartridge for less!
Includes black and color ink.
http://us.click.yahoo.com/ltH6zA/MkNDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 





More information about the postgis-users mailing list