pub struct GeoidGrid { /* private fields */ }Expand description
A regular latitude/longitude grid of geoid undulation samples (metres) with bilinear interpolation.
Samples are stored row-major with latitude ascending (outer) and longitude
ascending (inner): values_m[i * n_lon + j] is the undulation at latitude
lat_min_deg + i * dlat_deg and longitude lon_min_deg + j * dlon_deg.
Latitude inputs are clamped to the grid’s latitude span. Longitude inputs are
normalized to [-180, 180) and then, when the grid spans a full 360 degrees
of longitude, wrapped across the antimeridian; otherwise they are clamped to
the grid’s longitude span (so a regional grid does not wrap).
Implementations§
Source§impl GeoidGrid
impl GeoidGrid
Sourcepub fn new(
lat_min_deg: f64,
lon_min_deg: f64,
dlat_deg: f64,
dlon_deg: f64,
n_lat: usize,
n_lon: usize,
values_m: Vec<f64>,
) -> Result<Self, GeoidError>
pub fn new( lat_min_deg: f64, lon_min_deg: f64, dlat_deg: f64, dlon_deg: f64, n_lat: usize, n_lon: usize, values_m: Vec<f64>, ) -> Result<Self, GeoidError>
Build a geoid grid from its origin, spacing, dimensions, and row-major samples (metres).
Returns GeoidError when a dimension is zero, the sample count does not
equal n_lat * n_lon, a spacing/origin is non-finite or a spacing is
non-positive, or a sample is non-finite.
Sourcepub fn from_text(text: &str) -> Result<Self, GeoidError>
pub fn from_text(text: &str) -> Result<Self, GeoidError>
Parse a geoid grid from a simple, documented text format (the data-loading hook for full EGM grids).
The format is whitespace-delimited with # line comments. The first
non-comment token sequence is a six-field header:
lat_min lon_min dlat dlon n_lat n_lonfollowed by exactly n_lat * n_lon undulation samples in metres, in
row-major order (latitude ascending outer, longitude ascending inner).
All angles are in degrees. This is deliberately a minimal, line-oriented
format; a caller converting a vendor grid (EGM .gri/.ndp, a GeoTIFF,
etc.) lowers it to this shape or builds a GeoidGrid via new.
Sourcepub fn from_egm96_dac(bytes: &[u8]) -> Result<Self, GeoidError>
pub fn from_egm96_dac(bytes: &[u8]) -> Result<Self, GeoidError>
Parse the authoritative NGA EGM96 15-arcminute binary geoid grid
(WW15MGH.DAC) for decimetre-class datum work.
This is the highest-resolution path in the module. Its bilinear lookup tracks the geoid to roughly decimetre RMS, but the worst-case bilinear interpolation error can still exceed 1 m over the steepest geoid gradients, so it does not guarantee sub-metre accuracy everywhere.
The file is a headerless block of 721 * 1440 big-endian INTEGER*2
samples in centimetres, arranged north-to-south by record (record 1 at
latitude +90, last record at -90, in 0.25-degree steps) and, within
each record, west-to-east by longitude from 0 to 359.75 degrees in
0.25-degree steps. Each sample is divided by 100 to get metres. The rows
are flipped to the latitude-ascending storage order of GeoidGrid, so
the resulting grid is global in longitude and wraps across the
antimeridian like any other full-span grid.
The file is not vendored in this crate (it is a ~2 MB public-domain NGA
download); fetch WW15MGH.DAC from the NGA EGM96 distribution and pass its
bytes here. For a zero-setup metre-class default without the download, use
egm96_undulation instead.
Returns GeoidError::Parse if the byte length is not exactly
721 * 1440 * 2 bytes.
Sourcepub fn undulation_rad(&self, lat_rad: f64, lon_rad: f64) -> f64
pub fn undulation_rad(&self, lat_rad: f64, lon_rad: f64) -> f64
Bilinearly interpolated undulation N (metres) at a geodetic position in
radians (latitude positive north, longitude positive east).
Sourcepub fn undulations_rad(&self, points_rad: &[(f64, f64)]) -> Vec<f64>
pub fn undulations_rad(&self, points_rad: &[(f64, f64)]) -> Vec<f64>
Batch bilinear undulation lookup for geodetic positions in radians.
Each input tuple is (lat_rad, lon_rad), with latitude positive north and
longitude positive east. Output element i is exactly the scalar
undulation_rad result for input element i.
Sourcepub fn undulation_deg(&self, lat_deg: f64, lon_deg: f64) -> f64
pub fn undulation_deg(&self, lat_deg: f64, lon_deg: f64) -> f64
Bilinearly interpolated undulation N (metres) at a geodetic position in
degrees (latitude positive north, longitude positive east).
Sourcepub fn undulations_deg(&self, points_deg: &[(f64, f64)]) -> Vec<f64>
pub fn undulations_deg(&self, points_deg: &[(f64, f64)]) -> Vec<f64>
Batch bilinear undulation lookup for geodetic positions in degrees.
Each input tuple is (lat_deg, lon_deg), with latitude positive north and
longitude positive east. Output element i is exactly the scalar
undulation_deg result for input element i.
Sourcepub fn orthometric_height_rad(
&self,
ellipsoidal_height_m: f64,
lat_rad: f64,
lon_rad: f64,
) -> f64
pub fn orthometric_height_rad( &self, ellipsoidal_height_m: f64, lat_rad: f64, lon_rad: f64, ) -> f64
Orthometric height H = h - N (metres above mean sea level) from an
ellipsoidal height and a geodetic position in radians, using this grid’s
undulation.
Sourcepub fn ellipsoidal_height_rad(
&self,
orthometric_height_m: f64,
lat_rad: f64,
lon_rad: f64,
) -> f64
pub fn ellipsoidal_height_rad( &self, orthometric_height_m: f64, lat_rad: f64, lon_rad: f64, ) -> f64
Ellipsoidal height h = H + N (metres above the WGS84 ellipsoid) from an
orthometric height and a geodetic position in radians, using this grid’s
undulation.
Trait Implementations§
impl StructuralPartialEq for GeoidGrid
Auto Trait Implementations§
impl Freeze for GeoidGrid
impl RefUnwindSafe for GeoidGrid
impl Send for GeoidGrid
impl Sync for GeoidGrid
impl Unpin for GeoidGrid
impl UnsafeUnpin for GeoidGrid
impl UnwindSafe for GeoidGrid
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
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.