Skip to main content

MmapTerrain

Struct MmapTerrain 

Source
pub struct MmapTerrain<'a> { /* private fields */ }
Expand description

Memory-mappable terrain reader backed by a terrain store byte span.

Scalar and batch terrain lookups return orthometric metres, H, above the EGM96 mean sea level geoid. Use Self::ellipsoidal_height_m or OrthometricHeightM::to_ellipsoidal_height_deg for the explicit h = H + N conversion to WGS84 ellipsoidal height.

Implementations§

Source§

impl MmapTerrain<'static>

Source

pub fn from_vec(bytes: Vec<u8>) -> Result<Self, TerrainStoreError>

Parse an owned terrain store byte vector.

Source

pub fn from_path(path: impl AsRef<Path>) -> Result<Self, TerrainStoreError>

Read and parse a terrain store file.

This reads the file into memory. Applications that already manage an mmap should pass the mmap slice to MmapTerrain::from_bytes to avoid the file read copy.

Source§

impl<'a> MmapTerrain<'a>

Source

pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, TerrainStoreError>

Parse a borrowed terrain store byte span.

The reader keeps the byte span in place and indexes posting payloads by offset. Passing an mmap-backed slice gives a zero-copy reader.

Source

pub fn as_bytes(&self) -> &[u8]

Borrow the original terrain store bytes.

Source

pub const fn vertical_datum(&self) -> VerticalDatum

Return the store’s file-level vertical datum.

Source

pub fn tile_index(&self) -> &[TerrainStoreTileIndex]

Borrow the parsed tile index records.

Source

pub fn checksum64(&self) -> u64

Return an FNV-1a checksum of the full terrain store byte span.

Source

pub fn to_bytes(&self) -> Vec<u8>

Re-serialize this parsed terrain store into canonical bytes.

A store accepted by Self::from_bytes is already canonical, so this returns bytes identical to Self::as_bytes.

Source

pub fn height_m(&mut self, longitude_deg: f64, latitude_deg: f64) -> Result<f64>

Return the bilinearly interpolated orthometric height H in metres at a longitude-first geodetic position in degrees.

Source

pub fn height_m_with_options( &mut self, longitude_deg: f64, latitude_deg: f64, options: DtedLookupOptions, ) -> Result<f64>

Return the orthometric height H in metres at a longitude-first geodetic position in degrees using explicit lookup options.

Source

pub fn orthometric_height_m( &self, longitude_deg: f64, latitude_deg: f64, ) -> Result<OrthometricHeightM>

Return the bilinearly interpolated orthometric height H in metres as a typed value at a longitude-first geodetic position in degrees.

Source

pub fn orthometric_height_m_with_options( &self, longitude_deg: f64, latitude_deg: f64, options: DtedLookupOptions, ) -> Result<OrthometricHeightM>

Return the orthometric height H in metres as a typed value at a longitude-first geodetic position in degrees using explicit lookup options.

Source

pub fn height_batch( &mut self, points: &[(f64, f64)], options: DtedLookupOptions, ) -> Vec<Result<f64>>

Evaluate (longitude_deg, latitude_deg) points in order as orthometric heights H in metres.

The tuple order is longitude-first, matching Self::height_m. Each output element is independent, so an invalid point or parse failure is returned only for that element.

Source

pub fn orthometric_height_batch( &self, points: &[(f64, f64)], options: DtedLookupOptions, ) -> Vec<Result<OrthometricHeightM>>

Evaluate (longitude_deg, latitude_deg) points in order as typed orthometric heights H in metres.

The tuple order is longitude-first. Each output element is independent, so an invalid point or parse failure is returned only for that element.

Source

pub fn ellipsoidal_height_m( &self, longitude_deg: f64, latitude_deg: f64, ) -> Result<EllipsoidalHeightM, TerrainDatumError>

Return ellipsoidal height h in metres using the embedded EGM96 1-degree grid for h = H + N.

The input position is terrain order (longitude_deg, latitude_deg). Internally, the geoid call is made with (latitude_deg, longitude_deg). The embedded EGM96 1-degree grid agrees with the full EGM96 15-arcminute grid to about 0.4 m RMS.

Source

pub fn ellipsoidal_height_m_with_options( &self, longitude_deg: f64, latitude_deg: f64, options: DtedLookupOptions, ) -> Result<EllipsoidalHeightM, TerrainDatumError>

Return ellipsoidal height h in metres using the embedded EGM96 1-degree grid for h = H + N and explicit terrain lookup options.

The input position is terrain order (longitude_deg, latitude_deg). Internally, the geoid call is made with (latitude_deg, longitude_deg).

Source

pub fn ellipsoidal_height_m_with_model( &self, longitude_deg: f64, latitude_deg: f64, options: DtedLookupOptions, geoid: TerrainGeoidModel<'_>, ) -> Result<EllipsoidalHeightM, TerrainDatumError>

Return ellipsoidal height h in metres using an explicit geoid tier for h = H + N.

The input position is terrain order (longitude_deg, latitude_deg). Internally, the geoid call is made with (latitude_deg, longitude_deg). Choosing TerrainGeoidModel::Egm96FifteenMinute requires a loaded WW15MGH.DAC grid and never falls back to the embedded EGM96 1-degree grid.

Trait Implementations§

Source§

impl<'a> Clone for MmapTerrain<'a>

Source§

fn clone(&self) -> MmapTerrain<'a>

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<'a> Debug for MmapTerrain<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MmapTerrain<'a>

§

impl<'a> RefUnwindSafe for MmapTerrain<'a>

§

impl<'a> Send for MmapTerrain<'a>

§

impl<'a> Sync for MmapTerrain<'a>

§

impl<'a> Unpin for MmapTerrain<'a>

§

impl<'a> UnsafeUnpin for MmapTerrain<'a>

§

impl<'a> UnwindSafe for MmapTerrain<'a>

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