[postgis-devel] Re: [postgis-users] Change default "canonical form"of spatial objects

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Wed Mar 23 00:46:27 PST 2005


> -----Original Message-----
> From: postgis-devel-bounces at postgis.refractions.net 
> [mailto:postgis-devel-bounces at postgis.refractions.net] On 
> Behalf Of strk at refractions.net
> Sent: 23 March 2005 06:17
> To: postgis-users at postgis.refractions.net
> Cc: postgis-devel at postgis.refractions.net
> Subject: [postgis-devel] Re: [postgis-users] Change default 
> "canonical form"of spatial objects
> 
> 
> On Tue, Mar 22, 2005 at 07:53:23PM -0300, Gustavo Henrique 
> Sberze Ribas wrote:
> > Hello,
> > 
> >   Is it possible to change the "canonical form" of spatial 
> objects in 
> > an uncomplicated way? :)
> >   The current form is HEXEWKB for ascii and I'd like it to
> > be EWKT. I mean, I'd like the following statements to
> > produce the same output: 
> >   
> >   - SELECT geom FROM table;
> >   - SELECT AsEWKT(geom) FROM table;
> > 
> >   I'm currently running PG 7.4.6 with PostGIS RC2.
> 
> The only way to change canonical output form is modifying
> the C code. Canonical form is complicated for the sake
> of precision.
> 
> If using asewkt() is a pain for many people we might
> consider adding a function like: 
> 	SELECT postgis_set("ascii_canonical_form", "ewkt");
> 	SELECT postgis_set("ascii_canonical_form", "wkt");
> 	SELECT postgis_set("ascii_canonical_form", "hexwkb");
> 
> --strk;


Hi Gustavo,

Is there any particular reason why your application cannot use AsEWKT()
around a column? If you look back in the archives, there is a lot of
discussion as to why the internal representation (HEXEWKB) is different from
the OGC compliant versions - using an explicit AsEWKT() will guarantee that
the output will be correct regardless of how the internal representation may
change in future versions of PostGIS.

It may be possible to add a postgis_set() function, but I can see there
being subtle issues with using pg_dump/pg_restore - I believe at the moment
these accept HEXEWKB but also (E)WKT to allow dumps from previous versions
of PostGIS to be restored, and I think if we start relaxing this check we
are only going to make things too complicated for ourselves in the long run.

If your application really can't select the column, have you considered
using a view instead? For example, something like this:

	-- Rename table to real_table
	ALTER TABLE table RENAME TO real_table;

	-- Create the view
	CREAVE VIEW table AS SELECT AsEWKT(geom) FROM real_table;

Now you can simply do:

	SELECT geom FROM table;

And this will give your EWKT output as required for your application.


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-devel mailing list