[postgis-devel] Review of AsGML() patch - change of AsGML() parameters

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Thu Sep 6 03:55:26 PDT 2007

Hi folks,

I've finally got around to looking at the GML patches that have been
lying around in the PostGIS queue and propose the following patch to be
applied to SVN HEAD.

The main issue with the AsGML() is that according to the documentation,
there is no parameter to specify the version of GML being output.
However on looking at the source code, it becomes apparent that while
the documentation states:

	AsGML(geometry, [precision])
	ST_AsGML(geometry, [precision])

there also exists another prototype like this:

	AsGML(geometry, [precision], [version])
	ST_AsGML(geometry, [precision], [version])

This strikes me as not being particularly good by forcing use of
precision when you wish to specify a version number. It stuck me that a
far better idea would be to use a similar system system to the new
operators, and define an alias called _ST_AsGML() which accepts all 3
parameters: version, geometry and precision. All other functions then
use SQL aliases to map their parameters onto this function.

Since the extra version parameter is not documented, I'd like to change
the parameter order now before it becomes widely used; the irony being
that if anyone did try and specify a version other than 2, the function
would exit with an error saying that only GML2 was supported!

Incidentally the main patch I used for this was posted here:
http://postgis.refractions.net/pipermail/postgis-devel/2007-July/002690.html. However I did find that the patch had an error in the asgml3_inspected_size() function - when calculating sizes, it was using the asgml_*_size functions instead of the asgml3_*_size functions. So if anyone is using the original posted patch, they may experience memory corruption problems.

The final function prototype looks like this:

	ST_AsGML([version], geom, [precision])

Does that look like it could work for everyone? If nobody complains,
I'll apply the patch later this evening. 

Finally, I'm tempted to add an option version parameter to the ST_AsKML
and ST_AsSVG prototypes similar to the above so that if new versions
come along then the modifications can be made without changing the
existing prototypes. Again, I'll commit this unless anyone loudly



ILande - Open Source Consultancy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: postgis_gml.patch
Type: text/x-patch
Size: 24236 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20070906/079597b5/attachment.bin>

More information about the postgis-devel mailing list