[gdal-dev] GDAL precision for Geometry object

Even Rouault even.rouault at spatialys.com
Fri Oct 16 11:21:28 PDT 2015


Le vendredi 16 octobre 2015 20:14:44, Hermann Peifer a écrit :
> On 2015-10-16 18:20, Even Rouault wrote:
> > Le vendredi 16 octobre 2015 17:57:10, Hermann Peifer a écrit :
> >> On 2015-10-12 11:28, Even Rouault wrote:
> >>> I've changed to '%.15g' formatting for WKT in
> >>> https://trac.osgeo.org/gdal/ticket/6145
> >> 
> >> Hi Even,
> >> 
> >> Why did you choose '%.15g', rather than '%.17g'? The latter format
> >> should guarantee a lossless binary->decimal->binary round-trip, whereas
> >> the former one might also do -- or not. I don't think that any precision
> >> loss between '%.15g', and '%.17g' would result into "a real life
> >> problem", I am asking just out of curiosity.
> > 
> > Hi Hermann,
> > 
> > re'adding the list in CC.
> > 
> > Your point is valid. My idea was to avoid making WKT returned by the
> > modified version potentially longer than it is currently
> 
> I am pretty sure you know: '%.17g' could also result into shorter string
> values, compared to the earlier '%.15f', as in the below (admittedly
> unfair) example.

Yes, that's intended that the output is potentially now shorter than before. 
Previous formatting outputed too many figures, especially for projected 
coordinates.

> 
> Hermann
> 
> $ printf "%.15f\n" 50.375
> 50.375000000000000
> $
> $ printf "%.17g\n" 50.375
> 50.375

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list