Skip to main content

Module projection

Module projection 

Source
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.