Skip to content

Commit

Permalink
Allow duplicated coordinates in tile request URLs (#11441)
Browse files Browse the repository at this point in the history
  • Loading branch information
ozero authored and ansis committed Apr 11, 2022
1 parent 3c752ce commit 36c1749
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/source/tile_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class CanonicalTileID {

return urls[(this.x + this.y) % urls.length]
.replace('{prefix}', (this.x % 16).toString(16) + (this.y % 16).toString(16))
.replace('{z}', String(this.z))
.replace('{x}', String(this.x))
.replace('{y}', String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))
.replace(/{z}/g, String(this.z))
.replace(/{x}/g, String(this.x))
.replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))
.replace('{quadkey}', quadkey)
.replace('{bbox-epsg-3857}', bbox);
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/source/tile_id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test('CanonicalTileID', (t) => {
t.test('.url', (t) => {
t.test('replaces {z}/{x}/{y}', (t) => {
t.equal(new CanonicalTileID(1, 0, 0).url(['{z}/{x}/{y}.json']), '1/0/0.json');
t.equal(new CanonicalTileID(15, 9876, 4321).url(['{z}/{x}/{z}_{x}_{y}.json']), '15/9876/15_9876_4321.json');
t.end();
});

Expand Down

0 comments on commit 36c1749

Please sign in to comment.