yy20111011659 / route-me

Automatically exported from code.google.com/p/route-me
0 stars 0 forks source link

RMTile hash function rewrite #95

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The RMTile.c hash function used by the Memory and Database caches collides
somewhat frequently depending on your tile source, and the caches do not
handle this.

Original issue reported on code.google.com by tracy.harton on 26 Mar 2009 at 12:46

GoogleCodeExporter commented 8 years ago
Here is an updated hash funciton that shouldn't collide for most sources:

It allows for 256 zoom levels, and 28 bits for x and y.

uint64_t RMTileHash(RMTile tile)
{
        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;
}

Original comment by tracy.harton on 26 Mar 2009 at 12:47

GoogleCodeExporter commented 8 years ago
Fixed in r398/r404

Original comment by tracy.harton on 26 Mar 2009 at 5:22