[postgis-devel] 1.3.4rc1

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Mon Oct 27 04:45:58 PDT 2008


Courtin Olivier wrote:

> Ok thanks to this,
> i've still a lot to learn in portable C programming...

Don't we all ;)

> Some thoughts about that:
> - On the whole export functions in PostGIS 1.3 situation is now as this:
>   ST_assvg -> %.*f
>   ST_asgeojson -> %.*f
>   ST_askml -> %.*g
>   ST_asgml -> %.*g
> 
> %.*g is not really usefull, as the scientific notation is not widely 
> supported by client applications,
> and as you experiment and report %.*f is not portable !
> 
> Commons Uses Case (at least for me) are the following:
> 
> Round planar geometic data to avoid sub meters precision:
> SELECT st_asgeojson(geometryfromtext('POINT(11342340.345678912  
> 2139658548.3248234832)', -1), 0);
> {"type":"Point","coordinates":[11342340,2139658548]}
> 
> Handle precision on Decimal Degree data between 3 and 6 digits upon 
> precision needed:
> SELECT st_asgeojson(geometryfromtext('POINT(40.345678912  
> 48.3248234832)', 4326), 5);
>  {"type":"Point","coordinates":[40.34568,48.32482]}
> 
> So my question is: Is there a way to:
> -> keep the previous use cases
> -> have the same behaviour with all the exports functions

Well, according to the documentation at 
http://postgis.refractions.net/documentation/manual-1.3.4rc2/ch06.html#id2710404, 
the precision arguments for ST_AsGML, ST_AsKML and ST_AsGeoJSON 
represent the number of significant digits rather than the number of 
decimal places which is correct in my opinion. Of course, whether the 
code actually does that or not will require a bit more digging.

The issue is that by using decimal places rather than significant digits 
then you have no guarantee of the accuracy of your results. If you need 
to round to decimal places then you should be doing this on the client 
IMO. I do agree that it would be nice to unify the behaviour across all 
of the functions though.


ATB,

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063



More information about the postgis-devel mailing list