Module fns

Source
Expand description

Core util(e)ity functions for working with web mercator tiles, bounding boxes, et al

Functions§

_xy
Convert lng lat to web mercator x and y
as_zooms
Return zooms-vec from a ZoomOrZooms enum
bbox2zoom
Calculate the zoom level for the bounding-tile of a bbox
bbox_truncate
Truncate a bounding box to the valid range of longitude and latitude.
bounding_tile
Return the bounding tile for a bounding box.
bounds
Return the bbox tuple given x, y, z.
children
Return the children of a tile given x, y, z, and zoom; returns children in stupid a, b, d, c orderl; but this is the mercantile way… and I am not gonna fix it right now
children1_zorder
Return the 4 direct children of a tile
children_zorder
Return the children of a tile given x, y, z, and zoom in z-order.
flipy
Return the inverted/y-flipped y coordinate for a given y and z
from_id
Convert tile u64 id to tile xyz
int_2_offset_zoom
Return cumulative base-tile-id for a tile and the zoom level of the tile
ll
Return lower left lnglat as LngLat from x,y,z
lnglat
Convert web mercator x and y to longitude and latitude with optional truncation.
lnglat2tile_frac
Converts longitude, latitude, and zoom level to fractional tile coordinates.
lnglat2webmercator
Convert lng lat to web mercator x and y
lr
Return lower right lnglat as LngLat from x,y,z
minmax
Return tuple (min, max) x/y for a zoom-level
neighbors
Return neighbors of a tile (non-wrapping).
parent
Return the parent tile of a tile given x, y, z, and n (number of ancestors).
rmid2xyz
Calculate the xyz of the tile from a row-major-id
siblings
Return the siblings of a tile given x, y, z
tile
Return Tile struct from longitude, latitude, and zoom.
tile_ranges
Return TileRanges from a bounding box and zoom(s).
tiles
Return an iterator of tiles for a bounding box and zoom(s).
tiles_count
Return the number of tiles for a bounding box and zoom(s).
to_id
Convert tile xyz to u64 tile id (based on mapbox coverage implementation)
truncate_lat
Truncate a latitude to the valid range of -90 to 90.
truncate_lng
Truncate a longitude to the valid range of -180 to 180.
truncate_lnglat
Truncate a LngLat to valid range of longitude and latitude.
ul
Return upper left lnglat as LngLat from x,y,z
ult
Return upper left lnglat as tuple (f64, f64) from x,y,z
ur
Return upper right lnglat as LngLat from x,y,z
valid
Return true if x, y, z is a valid tile coordinate
webmercator2lnglat
Convert web mercator x and y to longitude and latitude.
xy
Convert longitude and latitude to web mercator x and y with optional truncation.
xyz2bbox
Return web-mercator bbox from x, y, z.
xyz2rmid
Calculate the row-major-id for a tile which is the index of the tile for the zoom level PLUS the total number of tiles in all zoom levels below it for the zoom level.
yflip
Return the y-flipped y coordinate for a given y and z