pub struct HeightGrid {
pub origin_x: f64,
pub origin_y: f64,
pub dx: f64,
pub dy: f64,
pub ncols: usize,
pub nrows: usize,
pub heights: Vec<f64>,
}Expand description
Terrain heights on an axis-aligned, uniform grid in metres. Row-major,
south-to-north: heights[i * ncols + j] is column j (east) of row
i, where row 0 is the southernmost row and i increases northward,
matching the frame’s +z = north convention shared by monitors and
local_en_m. origin_y is the south edge; sampling height_at moves
north as z increases. Position y is up; the grid lies in the x–z
plane.
Fields§
§origin_x: f64Frame-x of the western (first) column.
origin_y: f64Frame-z of the southern (first) row.
dx: f64Column spacing, metres.
dy: f64Row spacing, metres.
ncols: usizeNumber of columns (east).
nrows: usizeNumber of rows (south→north).
heights: Vec<f64>Row-major height samples, ncols * nrows, south→north.
Implementations§
Source§impl HeightGrid
impl HeightGrid
Sourcepub fn new(
origin_x: f64,
origin_y: f64,
dx: f64,
dy: f64,
ncols: usize,
nrows: usize,
heights: Vec<f64>,
) -> Result<Self>
pub fn new( origin_x: f64, origin_y: f64, dx: f64, dy: f64, ncols: usize, nrows: usize, heights: Vec<f64>, ) -> Result<Self>
Build and validate a grid.
Sourcepub fn height_at(&self, x: f64, z: f64) -> f64
pub fn height_at(&self, x: f64, z: f64) -> f64
Terrain height at a horizontal position, bilinear between samples; clamps at the grid edges.
Sourcepub fn from_ascii(text: &str) -> Result<Self>
pub fn from_ascii(text: &str) -> Result<Self>
A grid from an ASCII ESRI .asc raster (projected, metres): header
ncols/nrows/xllcorner/yllcorner/cellsize, then row-major heights
(north-to-south, west-to-east, i.e. “English reading order”: the first
row is the north edge). Rows are reversed into the grid’s
south-to-north storage so +z points north.
Sourcepub fn from_south_up(
origin_x: f64,
origin_south_y: f64,
dx: f64,
dy: f64,
ncols: usize,
nrows: usize,
heights: Vec<f64>,
) -> Result<Self>
pub fn from_south_up( origin_x: f64, origin_south_y: f64, dx: f64, dy: f64, ncols: usize, nrows: usize, heights: Vec<f64>, ) -> Result<Self>
A grid from raw metres data already in the grid’s south-to-north row-major order (row 0 = south), with the origin at the south-west sample corner.
Sourcepub fn downsample(&self, target_dx: f64) -> Result<HeightGrid>
pub fn downsample(&self, target_dx: f64) -> Result<HeightGrid>
Coarsen the grid to roughly target_dx metre spacing, averaging each
covered cell (a cheap supersampling → mean). The origin and extents
are preserved; dx/dy become the downsampled spacing. Terrain wind
needs no more than ~30 m cells, so a 1 m LiDAR DEM should almost
always be downsized before adjustment.
Trait Implementations§
Source§impl Clone for HeightGrid
impl Clone for HeightGrid
Auto Trait Implementations§
impl Freeze for HeightGrid
impl RefUnwindSafe for HeightGrid
impl Send for HeightGrid
impl Sync for HeightGrid
impl Unpin for HeightGrid
impl UnsafeUnpin for HeightGrid
impl UnwindSafe for HeightGrid
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.