Skip to content

Commit bea951b

Browse files
mournergithub-actions[bot]
authored andcommitted
Remove whoots-js dependency
GitOrigin-RevId: 88464c9eb6538a1c32e7c2e40df3de89a91424d1
1 parent 241934b commit bea951b

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@mapbox/tiny-sdf": "^2.0.6",
2525
"@mapbox/unitbezier": "^0.0.1",
2626
"@mapbox/vector-tile": "^2.0.4",
27-
"@mapbox/whoots-js": "^3.1.0",
2827
"@types/geojson": "^7946.0.16",
2928
"@types/geojson-vt": "^3.2.5",
3029
"@types/mapbox__point-geometry": "^0.1.4",

src/source/tile_id.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {getTileBBox} from '@mapbox/whoots-js';
21
import assert from 'assert';
32
import {register} from '../util/web_worker_transfer';
43

@@ -35,7 +34,6 @@ export class CanonicalTileID {
3534

3635
// given a list of urls, choose a url template and return a tile URL
3736
url(urls: Array<string>, scheme?: string | null): string {
38-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
3937
const bbox = getTileBBox(this.x, this.y, this.z);
4038
const quadkey = getQuadkey(this.z, this.x, this.y);
4139

@@ -45,7 +43,6 @@ export class CanonicalTileID {
4543
.replace(/{x}/g, String(this.x))
4644
.replace(/{y}/g, String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))
4745
.replace('{quadkey}', quadkey)
48-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4946
.replace('{bbox-epsg-3857}', bbox);
5047
}
5148

@@ -208,6 +205,16 @@ function getQuadkey(z: number, x: number, y: number) {
208205
return quadkey;
209206
}
210207

208+
function getTileBBox(x: number, y: number, z: number) {
209+
const z2 = 2 ** z;
210+
const worldSize = 2 * Math.PI * 6378137;
211+
const minX = worldSize * (x / z2 - 0.5);
212+
const minY = worldSize * (0.5 - (y + 1) / z2);
213+
const maxX = minX + worldSize / z2;
214+
const maxY = minY + worldSize / z2;
215+
return `${minX},${minY},${maxX},${maxY}`;
216+
}
217+
211218
// For all four borders: 0 - left, 1, right, 2 - top, 3 - bottom
212219
export const neighborCoord = [
213220
(coord: OverscaledTileID): OverscaledTileID => {

0 commit comments

Comments
 (0)