Expand description
Web Mercator projection — port of projection.ts.
Converts between geographic coordinates (longitude/latitude in degrees) and world/pixel coordinates used by slippy-map tile systems.
Constants§
- EARTH_
RADIUS - Earth radius used by Web Mercator in meters.
- MAX_LAT
- Maximum latitude representable in Web Mercator (≈85.05112878°).
- TILE_
SIZE - Tile size in pixels.
Functions§
- clamp_
lat - Clamp latitude to the Web Mercator valid range.
- from_
pixels - Convert pixel coordinates at a zoom level back to lon/lat.
- meters_
per_ pixel - Meters per pixel at a given latitude and zoom.
- project
- Project longitude/latitude (degrees) to normalized world coordinates in
[0, 1). - to_
pixels - Project lon/lat to pixel coordinates at a given zoom level.
- unproject
- Inverse-project normalized world coordinates in
[0, 1)back to lon/lat degrees.