[postgis-users] Problem with PostGIS 1.0.0 RC1

strk at refractions.net strk at refractions.net
Sun Jan 23 01:10:48 PST 2005


On Sat, Jan 22, 2005 at 03:26:43PM +0100, Markus Schaber wrote:
> Hi, Mark,
> 
> Mark Cave-Ayland schrieb:
> >Could we do this using the type system? For example, could we create a new
> >type called postgis_binary and then change GeomFromWKB to accept
> >postgis_binary instead of bytea? We then write two implicit casts: a bytea
> >to postgis_binary cast and a text to postgis_binary cast. In the case of 
> >the
> >bytea to postgis_binary cast, we simply return the binary data unaltered.
> >For the text to postgis_binary cast, we parse the hex string into binary 
> >and
> >return that. Hopefully this would allow GeometryFromWKB() to work with both
> >bytea and hex string data.... What do you think?
> 
> I don't think the work of introducing and maintaining a new PostgreSQL 
> type is worth the effort (but strk may correct me, as he's the one who 
> has to do the work :-).

That would bring the WKB type back, which I obsoleted in LWGEOM
to reduce maintanence costs.

> 
> My solution would be to have two GeometryFromWKB() methods, one accepts 
> bytea and the other text.
> 
> Both are implemented as small stubs that both call the same WKB parsing 
> function, but with a different "byte getting" method. In C, the easiest 
> way to do this should be a struct that includes context information and 
> a function pointer to the actual byte reading function.
> 
> This is somehow similar to the approach I took in my Java code, but I 
> had the advantage that Java provides classes and objects.

Well.. we have an ODBMS here... this seems to do the trick:

CREATE OR REPLACE FUNCTION GeomFromWKB(text)
RETURNS geometry as
'select geomFromWKB($1::geometry::bytea)'
LANGUAGE 'SQL';

Note that in this case you will need an explicit ::bytea cast when willing
to use the bytea version.

The only *transparent* way would be having geometry_in recognize all of
HEXWKB,bytea,WKT (currently only bytea missing).

--strk;


> 
> HTH,
> Markus

-- 

For standing up against patentability of software,

  Thank You, Poland!

Read the intervention:    http://kwiki.ffii.org/ConsPolon041221En
Send your thanks:         thankyoupoland.info
Read/do more:		  http://www.noepatents.org/



More information about the postgis-users mailing list