[gdal-dev] OGRFormatDouble

Even Rouault even.rouault at spatialys.com
Tue Jan 15 09:15:35 PST 2019


On mardi 15 janvier 2019 11:31:14 CET Andrew Bell wrote:
> Hi,
> 
> I'm looking at OGRFormatDouble and trying to understand why it exists, as
> such.  It seems to impose its own formatting for double-precision values
> that is different from what is standardized in the C/C++ languages.  Other
> than imposing consistency where there is variability in the standards
> (string representation of infinity, for example), I'm wondering if there is
> any specific issue that the code is trying to address.

Probably users complaining about non-significant decimals that uselessly 
increase the size of the WKT (1.23999999999 instead of 1.24). I agree the 
current implementation is a set of heuristics, not necessarily working in 
every situation.

Digging into history, I see the first implementation of such ad-hoc rounding 
was per bcb5d113ff0d856d0859ef4b9b992a0d8cab08b5 in 2005 without more detail 
about the use case in the commit mssage.
I then enhanced this per b756ec600bc5474d0a99912069e6eab2ba35752a in 2010. 
Unfortunately I didn't provide more context either.

> 
> I don't like changing existing behavior, but in this case, conforming to
> existing standards seems to provide more clarity to users, provided that
> the OGR-specific formatting doesn't serve a purpose other than satisfying
> the desires of a previous developer or working around non-standard
> implementations that no longer exist.

Probably that in the case where the user defines explicitly the desired 
precision, you could disable this. Or, have an option to control if this is 
ad-hoc extra rounding should be done. I see I introduced per 
fae7de26911594333001b62669e50ef4088caeb2 a configuration option for that 
purpose to fix https://trac.osgeo.org/gdal/ticket/7188

Even

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


More information about the gdal-dev mailing list