1- import { getTileBBox } from '@mapbox/whoots-js' ;
21import assert from 'assert' ;
32import { 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
212219export const neighborCoord = [
213220 ( coord : OverscaledTileID ) : OverscaledTileID => {
0 commit comments