Skip to content

tile_math.hpp

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

Web Mercator (EPSG:3857) tile arithmetic for slippy maps, the scheme OpenStreetMap uses.

Source src/app/map/tile_math.hpp

Tile coordinates at zoom z run from 0 to 2^z along both axes, with (0, 0) at the north-west corner of the world (latitude kMaxLatitudeDeg, longitude -180) and y growing southwards; the integer part names a tile and the fraction is the place inside it. Pixel coordinates are tile coordinates times kTileSize, so a widget only needs to know where its centre lies in pixels at the current zoom. All functions here work on whole zoom levels; MapWidget scales their results for fractional zoom.

See also

Namespaces

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

Types

Type Description
TileKey Address of one tile: its zoom level and its column and row at that level.

Namespace members

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

Member Description
nmeasim::app::map::kTileSize Edge length of a square raster tile in pixels, as served by OpenStreetMap-style servers.
nmeasim::app::map::kMinZoom Lowest zoom level the map widget allows; at level 1 the world is 2 by 2 tiles.
nmeasim::app::map::kMaxZoom Highest zoom level the map widget allows, the deepest level the OpenStreetMap standard tile layer serves.
nmeasim::app::map::kMaxLatitudeDeg Northern and southern limit of Web Mercator in degrees, atan(sinh(pi)).
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.