[Qgis-developer] Perfs: a lot of WKB conversions

Even Rouault even.rouault at spatialys.com
Tue Jul 19 02:38:01 PDT 2016


> I was a bit sceptical, so I did a quick computation. A 32 bit float allows
> an accuracy of 3mm with WGS84 for coordinates around 180°:
> 180 takes 8 bits out of the 23 bits of fraction.  The remaining 15 bits can
> split the earth circumference into chunks of 3mm (40000/(2^15)). I'm maybe
> off by +1 bit of precision (the fraction has an implicit 1 at MSB), so that
> would be 1.5mm.

I'm not sure to have followed your computation, but it is wrong somewhere 
(must be a km vs m confusion). For example, OpenStreetMap .pbf format uses 
int32 to store longitudes (in a scaled way), and that enables a ~1cm accuracy.

Proof : 40e6 / 2^32 ~= 0.0093 m = 9.3 mm

In practice, they multiply longitudes in deegrees by 10 000 000, which offers 
40e6 / (2 * 180 * 10 000 000) = 1.1 cm accuracy

So for float32 given that you have only 23 bit for the mantissa, the precision 
should be much less than that in average and would not be uniform anyway.

But your conclusion that float32 cannot be used to store coordinates is right 
:-)

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


More information about the Qgis-developer mailing list