import { EpsgCode , QuadKey , TileMatrixSet , Tile , TileMatrixSets , NamedBounds } from '@basemaps/geo' ; export function qkToName ( qk ) { return TileMatrixSet . tileToName ( QuadKey . toTile ( qk ) ) ; } export function qkToNamedBounds ( quadKeys ) { const tms = TileMatrixSets . get ( EpsgCode . Google ) ; return quadKeys . map ( ( qk ) => ( { name : qkToName ( qk ) , ... tms . tileToSourceBounds ( QuadKey . toTile ( qk ) ) } ) ) ; } export function tileNamesToNamedBounds ( tileNames , tms = TileMatrixSets . get ( EpsgCode . Google ) ) { return tileNames . map ( ( name ) => ( { name , ... tms . tileToSourceBounds ( TileMatrixSet . nameToTile ( name ) ) } ) ) ; } export function genTileNames ( topLeftTile , xTotal , yTotal = 1 , tms = TileMatrixSets . get ( EpsgCode . Google ) ) { const bounds = [ ] ; yTotal += topLeftTile . y ; xTotal += topLeftTile . x ; const tile = { ... topLeftTile } ; for ( let y = topLeftTile . y ; y < yTotal ; ++ y ) { tile . y = y ; for ( let x = topLeftTile . x ; x < xTotal ; ++ x ) { tile . x = x ; bounds . push ( { name : TileMatrixSet . tileToName ( tile ) , ... tms . tileToSourceBounds ( tile ) } ) ; } } return bounds ; }