[postgis-users] where has the wkb type gone?

strk at refractions.net strk at refractions.net
Wed Aug 24 00:11:43 PDT 2005


On Tue, Aug 23, 2005 at 10:29:28PM +0100, Richard Taylor wrote:
...
> In older versions of postgis the returns of AsBinary and AsText on a geometry 
> column was of type 'geometry' and 'wkb'. These types (oids) were unique to 
> the postgis types. So it was straight forward to hook the EWKT and EWKB 
> parsers to those oids and the type conversion happened transparently to the 
> code issuing the select query.
>
> In the new version of postgis the type (oid) of AsEWKT and AsEWKB as 'text' 
> and 'bytea'. If I hook the parser on to these types it will attempt to parse 
> all 'text' and 'bytea' columns on any select query, which is unlikely to be 
> want the user is expecting. 
> 
> I can not see anyway, in the new postgis, to detect whether the column in the 
> result of select query is of EWKT or EWKB type. 

I think AsText had always returned 'text', so the problem should
have been there before too... Canonical output returned 'geometry'
(practically being an EWKT representation).

I suggest you don't hook on function returns, but just on the
geometry type.

In a text cursor a 'geometry' would be EWKT for older postgis and
EHEXWKB for newer one (you can detect the EWKT checking for first
char in [SPLMG]).
In a binary cursor a 'geometry' would be internal representation
for older postgis and EWKB for newer postgis. This would be harder
to detect.

--strk;



More information about the postgis-users mailing list