Skip to content

Commit

Permalink
Fix calculateKey
Browse files Browse the repository at this point in the history
  • Loading branch information
mpulkki-mapbox committed Nov 15, 2019
1 parent 43b5875 commit f8f040f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/source/tile_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class CanonicalTileID {
this.z = z;
this.x = x;
this.y = y;
this.key = calculateKey(0, z, x, y);
this.key = calculateKey(0, 0, z, x, y);
}

equals(id: CanonicalTileID) {
Expand Down Expand Up @@ -62,7 +62,7 @@ export class UnwrappedTileID {
constructor(wrap: number, canonical: CanonicalTileID) {
this.wrap = wrap;
this.canonical = canonical;
this.key = calculateKey(wrap, canonical.z, canonical.x, canonical.y);
this.key = calculateKey(wrap, 0, canonical.z, canonical.x, canonical.y);
}
}

Expand All @@ -78,7 +78,7 @@ export class OverscaledTileID {
this.overscaledZ = overscaledZ;
this.wrap = wrap;
this.canonical = new CanonicalTileID(z, +x, +y);
this.key = calculateKey(wrap, overscaledZ, x, y);
this.key = calculateKey(wrap, overscaledZ, z, x, y);
}

equals(id: OverscaledTileID) {
Expand Down Expand Up @@ -164,11 +164,11 @@ export class OverscaledTileID {
}
}

function calculateKey(wrap: number, z: number, x: number, y: number) {
function calculateKey(wrap: number, overscaledZ: number, z: number, x: number, y: number) {
wrap *= 2;
if (wrap < 0) wrap = wrap * -1 - 1;
const dim = 1 << z;
return ((dim * dim * wrap + dim * y + x) * 32) + z;
return (((dim * dim * wrap + dim * y + x) * 32) + z) * 64 + overscaledZ;
}

function getQuadkey(z, x, y) {
Expand Down

0 comments on commit f8f040f

Please sign in to comment.