Documentation / @interstellar-tools/maps / tileGeoTransform
Function: tileGeoTransform()
ts
function tileGeoTransform(
tile: TileInterface,
width: number,
height: number,
R: number
): GeoTransformInterface;Defined in: tiles/tile-geotransform.ts:57
Find where a web map tile's pixels lie on the mercator map: the GeoTransformInterface of a grid made from the tile, such as by decodeElevationTile.
and
Where:
, and are the tile's column, row and zoom, and its size in pixels is the sphere's radius (m) the tiles were cut for
Units
- Inputs:
Rin m; the size in pixels. - Output: the transform onto the Mercator map with
lambda00, in m.
Notes
- It is exact: cellToMap then inverseMercator gives each pixel's latitude and longitude, and the pixels' outer edges are tileBounds's.
- The map's cells are
larger than the ground's: the grid's own cellSize, from decodeElevationTile, is the ground's at the tile's middle. - Use it with mercator and inverseMercator with the same
R, and their defaultlambda0of 0.
Parameters
| Parameter | Type | Description |
|---|---|---|
tile | TileInterface | The tile, { x, y, z }, as tileAt gives it. |
width | number | Width of the tile in pixels (an integer, > 0). |
height | number | Height of the tile in pixels (an integer, > 0). |
R | number | Radius of the sphere the tiles were cut for, in m (finite, > 0). |
Returns
The transform from the tile's rows and columns to the Mercator map.
Throws
- If
Ris not finite. - If the tile doesn't exist,
widthorheightis not a positive integer, orRis<= 0.
Example
ts
// Latitude and longitude of the north-west pixel of a 256 × 256 tile
const transform = tileGeoTransform(tile, 256, 256, 6378137);
const { x, y } = cellToMap(transform, { row: 0, column: 0 });
inverseMercator(x, y, 6378137); // { phi, lambda } in radians