FW: [postgis-users] FW: [Psycopg] RELEASE: GeoTypes-0.2.0a1

David Blasby dblasby at refractions.net
Thu Sep 25 09:13:51 PDT 2003


>>I will have to look into WKB before I go any further. I don't know what the 
>>issues are here. I guess I need to use a binary cursor in Psycopg (I have not 
>>used these before) and then work out how to parse the result in python. I 
>>will also have to read the WKB docs to understand it better.

You can either make a binary cursor, or you can cheat and just use a 
normal query.  If you use the normal query, you'll get your WKB in hex 
form.  Ie. "FF00FF"  - you'll have to translate this to a byte array and 
then treat it as normal WKB.  "FF00FF" would be 255,0,255.

>>Would using the GetGeometryType()  function require two trips to the database 
>>for each return? e.g. 
>>
>>	<list of geometry objects> = select geo_obj from geo_table;
>>	for each geometry_object
>>		geometry_sub_type = select GetGeometryType(geometry_object)
>>
>>I was trying to avoid this. It is possible to avoid it with the WKT format 
>>because the real sub type of the object is encoded in the format is this true 
>>of the WKB format? (I will read it anyway).

Actually, the GetGeometryType() is easy to determine by either looking 
at the WKT or WKB.

For WKT - just look at the first word in the text.  ie. "POLYGON"
FOR WKB - the same code is given in the first few bytes of the WKT.

dave
ps. The OGC SF SQL spec has definitions of WKT and WKB:
http://www.opengis.org/techno/specs/99-049.pdf






More information about the postgis-users mailing list