[OSM-talk] Re: Data types; indexes etc.

Nick Hill nick at nickhill.co.uk
Thu Apr 27 11:34:47 BST 2006

dblasby at openplans.org wrote:
> Nick wrote:
> Do you know if experiments been carried out using integers instead of
> floats in the internal bbox representation? These may have two positive
> effects;
> 1) Speed the mathematical comparisons used to determine intersections.
> 2) All calculations will be exact, without any rounding errors. This
> opens the possibility of only representing offsets within the index, in
> tiny data types. The index might then be even smaller than the data
> being indexed.
> I must admit, I was quite suprised when I saw that you got 2-3* the
> performance with integers vs doubles.  I would expect the fact that the
> index data is 1/2 the size makes up most of this difference (64bit
> doubles vs 32bit ints).  Have you tried double vs float?  I cannot
> image that a<b for int32 and float32s is going to make that much of a
> difference, but who knows?

I have just performed tests on a 1M point field for the three data 
types. The averaged results for 25,600 point tiles as follows:

Double float 64 0.51s
Single float 32 0.33s
Integer32 0.237s

This is more or less as I expected; the size difference between the data
sizes makes a substantial difference. The integer type is also
substantially faster than a float.

I wouldn't recommend using single floats for geographic representations; 
the rounding errors would be intolerable. Literally miles out.

More information about the talk mailing list