Authored by Tracy Harton

*** This checkin requires you to reset any persistant caches as the key changes ***

rewrite RMTileHash to avoid collisions since the Caches don't check or handle them.

Should handle any map up to:
256 zoom levels
(2^28)-1 x values
(2^28)-1 y values

If you have a map outside those bounds, I want to see it as it must be pretty cool.
... ... @@ -27,18 +27,17 @@
#include "RMTile.h"
#import <math.h>
#import <stdio.h>
uint64_t RMTileHash(RMTile tile)
{
uint64_t accumulator = 0;
for (int i = 0; i < tile.zoom; i++) {
accumulator |= ((uint64_t)tile.x & (1LL<<i)) << i;
accumulator |= ((uint64_t)tile.y & (1LL<<i)) << (i+1);
}
accumulator |= 1LL<<(tile.zoom * 2);
return accumulator;
uint64_t zoom = (uint64_t) tile.zoom & 0xFFLL; // 8bits, 256 levels
uint64_t x = (uint64_t) tile.x & 0xFFFFFFFLL; // 28 bits
uint64_t y = (uint64_t) tile.y & 0xFFFFFFFLL; // 28 bits
uint64_t hash = (zoom << 56) | (x << 28) | (y << 0);
return hash;
}
RMTile RMTileDummy()
... ... @@ -86,4 +85,4 @@ TileRect TileRectIntersection(TileRect one, TileRect two)
}
// Calculate and return the union of two rectangles
TileRect TileRectUnion(TileRect one, TileRect two);*/
\ No newline at end of file
TileRect TileRectUnion(TileRect one, TileRect two);*/
... ...