Skip to main content

GeoidGrid

Struct GeoidGrid 

Source
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

Source

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.

Source

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_lon

followed 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.

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn orthometric_height_deg( &self, ellipsoidal_height_m: f64, lat_deg: f64, lon_deg: f64, ) -> f64

Orthometric height H = h - N (metres above mean sea level) from an ellipsoidal height and a geodetic position in degrees, using this grid’s undulation.

Source

pub fn ellipsoidal_height_deg( &self, orthometric_height_m: f64, lat_deg: f64, lon_deg: f64, ) -> f64

Ellipsoidal height h = H + N (metres above the WGS84 ellipsoid) from an orthometric height and a geodetic position in degrees, using this grid’s undulation.

Trait Implementations§

Source§

impl Clone for GeoidGrid

Source§

fn clone(&self) -> GeoidGrid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GeoidGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for GeoidGrid

Source§

fn eq(&self, other: &GeoidGrid) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for GeoidGrid

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.