simple tile utilities
npm install @mapbox/tilebelt
simple tile utilities
``bash`
npm install @mapbox/tilebelt
`js
import * as tilebelt from '@mapbox/tilebelt';
const tile = [10, 15, 8] // x,y,z
tilebelt.tileToGeoJSON(tile);
// {
// "type": "Polygon",
// "coordinates": [
// [
// [ -165.9375, 82.8533822917608 ],
// [ -165.9375, 82.67628497834903 ],
// [ -164.53125, 82.67628497834903 ],
// [ -164.53125, 82.8533822917608 ],
// [ -165.9375, 82.8533822917608 ]
// ]
// ]
// }
tilebelt.getParent(tile);
// [ 5, 7, 7 ]
`
function | description
---|---
tileToGeoJSON(tile) | get a geojson representation of a tiletileToBBOX(tile) | get the bbox of a tilebboxToTile(bbox) | get the smallest tile to cover a bboxgetChildren(tile) | get the 4 tiles one zoom level highergetParent(tile) | get the tile one zoom level lowergetSiblings(tile) | get the 4 sibling tiles for a tilehasSiblings(tiles, tile) | check to see if an array of tiles contains a tiles siblingshasTile(tiles, tile) | check to see if an array of tiles contains a particular tiletilesEqual(tile1, tile2) | check to see if two tiles are the sametileToQuadkey(tile) | get the quadkey for a tilequadkeyToTile(quadkey) | get the tile for a quadkeypointToTile(lon, lat, zoom) | get the tile for a point at a specified zoom levelpointToTileFraction(lon, lat, zoom) | get the precise fractional tile location for a point at a zoom level
`sh``
npm ci # install deps
npm test # tests
npm run bench # run benchmarks
npm run format # format using prettier