[postgis-users] GeomFromWKB (was: Problem with PostGIS 1.0.0 RC1)

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Tue Jan 25 01:17:11 PST 2005


Hi strk/Dave, 

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net 
> [mailto:postgis-users-bounces at postgis.refractions.net] On 
> Behalf Of strk at refractions.net
> Sent: 24 January 2005 09:48
> To: David Blasby
> Cc: PostGIS Users Discussion
> Subject: [postgis-users] GeomFromWKB (was: Problem with 
> PostGIS 1.0.0 RC1)
> 
> 
> On Sun, Jan 23, 2005 at 10:25:52AM -0800, David Blasby wrote:
> > > CREATE OR REPLACE FUNCTION GeomFromWKB(text)
> > > RETURNS geometry as
> > > 'select geomFromWKB($1::geometry::bytea)'
> > > LANGUAGE 'SQL';
> > 
> > Why are you running the conversion twice 
> > (WKB->GEOMETRY->WKB->GEOMETRY)?
> > 
> >  CREATE OR REPLACE FUNCTION GeomFromWKB(text)
> >  RETURNS geometry as
> >  'select ($1::geometry)'
> >  LANGUAGE 'SQL';
> 
> Ok. Let's better define the problem.
> 
> GeomFromWKB is an OGC function, and we worked to make this 
> clear for the user. For example, if you give GeomFromWKB a 
> WKB defining 3D geometry you'll get a Warning. Similarly if 
> you use the M or SRID extension you still get a Warning.
> 
> This is what OGC says about it:
> 
> <<
> The GeomFromWKB function, takes a well-known binary 
> representation of geometry (WKBGeometry as described in 
> section 3.3) and a Spatial Reference System ID
> (SRID) and creates an instance of the appropriate geometry 
> type. This function plays the role of the Geometry Factory in 
> SQL. An implementation shall substitute an SQL type used to 
> represent binary values for the type Binary in the definitions below.
> 
>   GeomFromWKB(WKBGeometry Binary, SRID Integer)
> 
> Construct a Geometry value given its well-known binary representation.
> >>
> 
> For PostgreSQL the implementation shall substitute 'bytea' to 
> 'Binary', and this is what is done within RC1.
> 
> So, for *strictness* we should force users to use bytea 
> (porting to this behaviour also all of GeomTypeFromWKB - 
> currently cheating).
> 
> For *portability* we might want to be broader in what we 
> accept, but should still warn about it.
> 
> My question: is taking HEXWKB really a portability issue ? 
> Where did user take that GeomFromWKB(HEXWKB) call from ?

I think that accepting bytea is the right thing to do, but it can be useful
for testing to use HEXWKB without having to escape everything ;) Perhaps the
best way would be to provide a HexWKBToBytea() function that does the
conversion, so those people who really want to use it can just do something
like SELECT GeomFromWKB(HexWKBToByteA('000102....FF'))? If it's a slightly
non-standard use I think this would be a better solution than loosening the
constraints on the input checking.


Kind regards,

Mark.

------------------------
WebBased Ltd
South West Technology Centre
Tamar Science Park
Plymouth
PL6 8BT 

T: +44 (0)1752 791021
F: +44 (0)1752 791023
W: http://www.webbased.co.uk





More information about the postgis-users mailing list