Skip to content

tile_math.cpp

file src/app/map/tile_math.cpp ยท Applications

Web Mercator (EPSG:3857) projection formulas behind the slippy-map tile arithmetic.

Source src/app/map/tile_math.cpp

Implements the spherical forward and inverse projection of the OpenStreetMap slippy map scheme and the ground resolution per pixel.

See also

Namespaces

Namespace Description
nmeasim::app::map The slippy-map view of the desktop application, part of nmeasim::app.

Namespace members

Declared or defined in this file and documented on the page of their namespace.

Member Description
nmeasim::app::map::tiles_at Returns the number of tiles along one axis at a zoom level, 2^zoom.
nmeasim::app::map::tile_coordinates Returns the fractional tile coordinates of a position at a zoom level.
nmeasim::app::map::pixel_coordinates Returns the pixel coordinates of a position at a zoom level.
nmeasim::app::map::position_of_tile Returns the position at fractional tile coordinates at a zoom level, the inverse of tile_coordinates.
nmeasim::app::map::position_of_pixel Returns the position at pixel coordinates at a zoom level, the inverse of pixel_coordinates.
nmeasim::app::map::tile_at Returns the tile containing fractional tile coordinates, with x wrapped around the antimeridian.
nmeasim::app::map::parent_of Returns the tile one zoom level up (one level less detailed) that contains a tile.
nmeasim::app::map::wrap_longitude Wraps a longitude into [-180, 180), as the world repeats east and west.
nmeasim::app::map::metres_per_pixel Returns the ground distance one pixel covers at a latitude and zoom level.

Summary

File-local functions

Name Description
to_radians() Converts an angle from degrees to radians.
to_degrees() Converts an angle from radians to degrees.

File-local variables

Name Description
kEarthCircumferenceM Equatorial circumference of the Earth in metres: 2 pi times the WGS 84 semi-major axis of 6378137 m, the sphere Web Mercator projects from.

File-local functions

to_radians()

double to_radians(double degrees) noexcept

Converts an angle from degrees to radians.

Parameters

Name Type Description
degrees double Angle in degrees, any value.

Returns double: The angle in radians.

Declared in src/app/map/tile_math.cpp:28

to_degrees()

double to_degrees(double radians) noexcept

Converts an angle from radians to degrees.

Parameters

Name Type Description
radians double Angle in radians, any value.

Returns double: The angle in degrees.

Declared in src/app/map/tile_math.cpp:36

File-local variables

kEarthCircumferenceM

double kEarthCircumferenceM{40075016.686}

Equatorial circumference of the Earth in metres: 2 pi times the WGS 84 semi-major axis of 6378137 m, the sphere Web Mercator projects from.

Declared in src/app/map/tile_math.cpp:22