[OSM-dev] Proposal: Database accelerator and dirty tile marker based on simple algorithm.
Nick Hill
nick at nickhill.co.uk
Wed Sep 20 21:52:05 BST 2006
Hello Nigel
You are correct in representing two approaches to the same problem.
Yours being to recursively sub-divide the planet, mine being to convert
the lat/lon values through binary manipulation to the same conclusion.
The code you have written will not work as expected (I have tested it).
It ignores the significant degrees and only considers the floating point
value. If I have time, I will re-write the code for the two approaches
to hopefully provide identical results, or results according to my
worked example further up the thread.
Nigel Magnay wrote:
> Iterative or recursive, you still have to traverse the bits. So, if I
> understand correctly, I'm proposing (for, say, a 64-bit output format)
>
> // Use appropriate values rather than 0.5 if world is not scaled
> long convert(double x, double y)
> {
> long result = 0;
> for(int i=0;i<32;i++)
> {
> result *= 4; // shift
> x -= Math.floor(x);
> y -= Math.floor(y);
> result += (x > 0.5?1:0) + (y > 0.5 ? 2 : 0);
> x *=2;
> y *= 2;
> }
> return result;
> }
>
> And you are proposing something like
> long convert(double x, double y)
> {
> long result = 0;
> long longX = (long)(x * 10000000); // FCONV
> long longY = (long)(y * 10000000);
> for(int i=0;i<32;i++)
> {
> result *= 2; // shift up
> // add to bottom
> result += (longX & 0x80000000 ?1:0) + (longY & 0x80000000 ? 2 : 0);
> longX = longX * 2; // Shift so top bits most sig.
> longY = longY * 2;
> }
> return result;
> }
More information about the dev
mailing list