Expand description
ndslive-math — coordinate math, packed tile IDs, and Morton (Z-order)
codes for NDS.Live geographic tiling.
This crate is a faithful Rust port of the Python reference implementation
(ndslive.math). It provides:
Wgs84— a WGS84 lon/lat/alt point with NDS coordinate conversion, distance and bearing helpers.MortonCode— a standalone Z-order encoder/decoder.PackedTileId— an NDS.Live Packed Tile ID with geometry accessors and neighbour traversal.NdsBoundingBox— a rectangle in NDS coordinate space.get_tile_ids_for_bounding_box/bounding_box_from_tile_ids— bulk tile enumeration helpers.
§Example
use ndslive_math::{Wgs84, MortonCode, PackedTileId};
// WGS84 -> NDS coordinates (uses floor, per the NDS recommendation).
let point = Wgs84::new(11.585, 48.137); // Munich
let (nds_x, nds_y) = point.to_nds_coordinates();
// Find the level-13 tile containing the point.
let morton = MortonCode::from_nds_coordinates(nds_x, nds_y);
let tile = PackedTileId::from_morton_and_level(morton, 13).unwrap();
let sw = tile.south_west_corner();
let east = tile.east_neighbour();Re-exports§
pub use bounding_box::NdsBoundingBox;pub use morton::MortonCode;pub use polygon::Orientation;pub use polygon::Polygon;pub use polygon::PolygonType;pub use polygon_triangulation::PolygonTriangulation;pub use tileid::bounding_box_from_tile_ids;pub use tileid::get_tile_ids_for_bounding_box;pub use tileid::PackedTileId;pub use tileid::TileIdError;pub use vec2::Vec2;pub use wgs84::Wgs84;pub use wgs84::EARTH_RADIUS_IN_METERS;pub use wgs84::LAT_MAX;pub use wgs84::LAT_MIN;pub use wgs84::LAT_NDS_DELTA;pub use wgs84::LAT_NDS_DELTA_POW2;pub use wgs84::LON_MAX;pub use wgs84::LON_MIN;pub use wgs84::LON_NDS_DELTA;pub use wgs84::LON_NDS_DELTA_POW2;pub use wgs84::METERS_PER_DEGREE;pub use wgs84_aabb::Wgs84Aabb;pub use wgs84_polygon::Wgs84Polygon;
Modules§
- bounding_
box - Axis-aligned bounding boxes in NDS coordinate space.
- morton
- Morton (Z-order) encoding for 2D NDS coordinates.
- polygon
- Generic polygon container with orientation, mirroring the C++
Polygon. - polygon_
triangulation - Ear-clipping polygon triangulation.
- tileid
- NDS.Live Packed Tile IDs and bounding-box tile enumeration.
- vec2
- A plain 2D vector that is not WGS84-normalized.
- wgs84
- WGS84 coordinate point with NDS coordinate conversion and geodesic helpers.
- wgs84_
aabb - WGS84 axis-aligned bounding box.
- wgs84_
polygon - WGS84 polygon with bounding box, median, and SAT collision.