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>
impl MmapTerrain<'static>
Sourcepub fn from_vec(bytes: Vec<u8>) -> Result<Self, TerrainStoreError>
pub fn from_vec(bytes: Vec<u8>) -> Result<Self, TerrainStoreError>
Parse an owned terrain store byte vector.
Sourcepub fn from_vec_attested(
bytes: Vec<u8>,
claimed_checksum64: u64,
) -> Result<Self, TerrainStoreError>
pub fn from_vec_attested( bytes: Vec<u8>, claimed_checksum64: u64, ) -> Result<Self, TerrainStoreError>
Parse owned terrain store bytes using a caller-attested checksum.
The byte-based counterpart of Self::from_path_attested, for callers
that already hold the store bytes (an interface layer, an object-store
read) alongside a trustworthy content measurement. Same contract:
structural checks run unconditionally, the per-tile payload hashing is
replaced by the claim, and the handle reports
DigestProvenance::Attested until Self::verify succeeds.
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self, TerrainStoreError>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, TerrainStoreError>
Open and parse a terrain store file.
With the mmap feature the file is memory-mapped read-only and this
reader owns the mapping; without it the file is read into memory. The
entry point is the same either way, so enabling the feature speeds up
every existing caller rather than asking anyone to migrate.
Mapping is what makes a very large store usable at all: construction parses only the header, datum tag, and tile index, and lookups are demand-paged, so a reader querying a geographically local region never faults in the rest of the file.
Sourcepub fn from_path_attested(
path: impl AsRef<Path>,
claimed_checksum64: u64,
) -> Result<Self, TerrainStoreError>
pub fn from_path_attested( path: impl AsRef<Path>, claimed_checksum64: u64, ) -> Result<Self, TerrainStoreError>
Open a terrain store using a caller-attested full-store checksum.
This performs the same header, index, dimension, length, and tile-bound
validation as Self::from_path without hashing tile payloads. Terrain
headers do not carry a full-store checksum, so the claim is recorded as
supplied and can be checked later with Self::verify. With the mmap
feature the file is memory-mapped read-only; without it the file is read
into memory.
Source§impl<'a> MmapTerrain<'a>
impl<'a> MmapTerrain<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, TerrainStoreError>
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.
Sourcepub fn is_memory_mapped(&self) -> bool
pub fn is_memory_mapped(&self) -> bool
Whether this reader is backed by a memory map rather than a copy in process memory.
Sourcepub const fn vertical_datum(&self) -> VerticalDatum
pub const fn vertical_datum(&self) -> VerticalDatum
Return the store’s file-level vertical datum.
Sourcepub fn tile_index(&self) -> &[TerrainStoreTileIndex]
pub fn tile_index(&self) -> &[TerrainStoreTileIndex]
Borrow the parsed tile index records.
Sourcepub fn tile_count(&self) -> usize
pub fn tile_count(&self) -> usize
Return the number of tiles present in this terrain store.
Sourcepub fn tile_ids(&self) -> &[TerrainTileId]
pub fn tile_ids(&self) -> &[TerrainTileId]
Borrow the sorted integer tile ids present in this terrain store.
Sourcepub const fn digest_provenance(&self) -> DigestProvenance
pub const fn digest_provenance(&self) -> DigestProvenance
Return who computed the checksum carried by this reader.
Sourcepub fn checksum64(&self) -> u64
pub fn checksum64(&self) -> u64
Return the full-store checksum carried by this reader.
Verified readers compute the FNV-1a checksum on demand. Attested readers return the caller’s claim without hashing the byte span.
Sourcepub fn verify(&mut self) -> Result<(), TerrainStoreError>
pub fn verify(&mut self) -> Result<(), TerrainStoreError>
Re-verify tile payloads and any caller-attested full-store checksum.
Successful verification changes the digest provenance to
DigestProvenance::Verified.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
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.
Sourcepub fn height_m(&mut self, longitude_deg: f64, latitude_deg: f64) -> Result<f64>
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.
Sourcepub fn height_m_with_options(
&mut self,
longitude_deg: f64,
latitude_deg: f64,
options: DtedLookupOptions,
) -> Result<f64>
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.
Sourcepub fn orthometric_height_m(
&self,
longitude_deg: f64,
latitude_deg: f64,
) -> Result<OrthometricHeightM>
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.
Sourcepub fn orthometric_height_m_with_options(
&self,
longitude_deg: f64,
latitude_deg: f64,
options: DtedLookupOptions,
) -> Result<OrthometricHeightM>
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.
Sourcepub fn height_batch(
&mut self,
points: &[(f64, f64)],
options: DtedLookupOptions,
) -> Vec<Result<f64>> ⓘ
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.
Sourcepub fn orthometric_height_batch(
&self,
points: &[(f64, f64)],
options: DtedLookupOptions,
) -> Vec<Result<OrthometricHeightM>> ⓘ
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.
Sourcepub fn ellipsoidal_height_m(
&self,
longitude_deg: f64,
latitude_deg: f64,
) -> Result<EllipsoidalHeightM, TerrainDatumError>
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.
Sourcepub fn ellipsoidal_height_m_with_options(
&self,
longitude_deg: f64,
latitude_deg: f64,
options: DtedLookupOptions,
) -> Result<EllipsoidalHeightM, TerrainDatumError>
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).
Sourcepub fn ellipsoidal_height_m_with_model(
&self,
longitude_deg: f64,
latitude_deg: f64,
options: DtedLookupOptions,
geoid: TerrainGeoidModel<'_>,
) -> Result<EllipsoidalHeightM, TerrainDatumError>
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>
impl<'a> Clone for MmapTerrain<'a>
Source§fn clone(&self) -> MmapTerrain<'a>
fn clone(&self) -> MmapTerrain<'a>
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<'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> 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
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.