pub struct MercatorDem { /* private fields */ }Expand description
A contiguous rectangular block of decoded web-mercator (XYZ) DEM tiles, stitched into a single elevation grid and sampleable by longitude / latitude.
The stitched grid is row-major north → south, tiles_x * tile_size
columns by tiles_y * tile_size rows. Sampling outside the block clamps
to the nearest edge sample, so a halo that slightly overshoots the
fetched coverage degrades gracefully rather than panicking — but for
correct results the block should cover the target bounds (plus any halo).
Implementations§
Source§impl MercatorDem
impl MercatorDem
Sourcepub fn new(
zoom: u8,
x0: u32,
y0: u32,
tiles_x: u32,
tiles_y: u32,
tile_size: u32,
elev: Vec<f32>,
) -> Self
pub fn new( zoom: u8, x0: u32, y0: u32, tiles_x: u32, tiles_y: u32, tile_size: u32, elev: Vec<f32>, ) -> Self
Wrap an already-stitched elevation block.
elev must be row-major north → south with
(tiles_x*tile_size) * (tiles_y*tile_size) entries.
§Panics
Panics on a length mismatch, or if any tile dimension is zero.
Sourcepub fn from_tiles<F>(
zoom: u8,
x0: u32,
y0: u32,
tiles_x: u32,
tiles_y: u32,
tile_size: u32,
get_tile: F,
) -> Self
pub fn from_tiles<F>( zoom: u8, x0: u32, y0: u32, tiles_x: u32, tiles_y: u32, tile_size: u32, get_tile: F, ) -> Self
Build a block by pulling each XYZ tile through get_tile, which
returns that tile’s decoded elevations (tile_size², row-major
north → south). The closure is where you do your fetch + heightmap
decode; for async callers, pre-fetch into a map and look it up here.
Tiles are requested in row-major order (x0, y0) … (x0+tiles_x-1, y0+tiles_y-1).
§Panics
Panics if any returned tile does not have exactly tile_size² samples.
Sourcepub fn tiles_covering(
zoom: u8,
west: f64,
south: f64,
east: f64,
north: f64,
) -> (u32, u32, u32, u32)
pub fn tiles_covering( zoom: u8, west: f64, south: f64, east: f64, north: f64, ) -> (u32, u32, u32, u32)
Range of XYZ tiles at zoom covering a longitude/latitude box,
returning (x0, y0, tiles_x, tiles_y).
Widen the box by your halo before calling if you intend to sample a
buffer beyond the tile (e.g. for buffered_geodetic).
Sourcepub fn sample(&self, lon: f64, lat: f64) -> f32
pub fn sample(&self, lon: f64, lat: f64) -> f32
Bilinearly sample the elevation at (lon, lat) in degrees.
Latitude is clamped to the web-mercator limit. Positions outside the
fetched block clamp to the nearest edge sample. NaN samples (e.g.
missing data filled by the caller) are tolerated: the interpolation
falls back to any defined neighbour, returning NaN only if all four
corners are NaN.
Sourcepub fn geodetic_grid(&self, bounds: &TileBounds, grid_size: u32) -> Vec<f32>
pub fn geodetic_grid(&self, bounds: &TileBounds, grid_size: u32) -> Vec<f32>
Resample onto a geodetic grid_size × grid_size grid covering
bounds, row-major north → south — ready for
crate::terrain::encode_terrain.
§Panics
Panics if grid_size < 2.
Sourcepub fn buffered_geodetic(
&self,
bounds: &TileBounds,
tile_grid_size: u32,
buffer: u32,
) -> BufferedElevations
pub fn buffered_geodetic( &self, bounds: &TileBounds, tile_grid_size: u32, buffer: u32, ) -> BufferedElevations
Resample onto a halo-extended geodetic grid — a
BufferedElevations for
crate::terrain::NormalMode::BufferedGradient.
The inner tile_grid_size × tile_grid_size block matches
geodetic_grid; the surrounding buffer-cell
strip is sampled from the neighbour area (so make sure this
MercatorDem was built to cover bounds widened by the halo).
§Panics
Panics if tile_grid_size < 2.
Trait Implementations§
Source§impl Clone for MercatorDem
impl Clone for MercatorDem
Source§fn clone(&self) -> MercatorDem
fn clone(&self) -> MercatorDem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MercatorDem
impl RefUnwindSafe for MercatorDem
impl Send for MercatorDem
impl Sync for MercatorDem
impl Unpin for MercatorDem
impl UnsafeUnpin for MercatorDem
impl UnwindSafe for MercatorDem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more