Sidereon.Terrain.MmapTerrain (Sidereon v0.14.0)

Copy Markdown View Source

Memory-mappable terrain store conversion and lookup.

A terrain store is a single byte container built from DTED tiles. The reader can be opened from bytes with from_bytes/1 or from a path with from_path/1. Heights returned by this module are typed as orthometric height H in metres above the EGM96 mean sea level geoid. Use the ellipsoidal conversion functions when a WGS84 ellipsoidal height h = H + N is needed.

Terrain lookup axes are always (longitude_deg, latitude_deg).

Summary

Types

Terrain interpolation method.

t()

Parsed terrain store handle.

Terrain datum conversion or geoid-grid loading error.

Terrain store conversion or parse error.

Functions

Return a checksum for a parsed store handle or terrain store bytes.

Convert a DTED tile tree into terrain store bytes.

Return WGS84 ellipsoidal terrain height using the embedded EGM96 1-degree grid.

Return WGS84 ellipsoidal terrain height with an explicit geoid model.

Return WGS84 ellipsoidal terrain height with lookup options.

Parse terrain store bytes into a reader handle.

Read a terrain store file into a reader handle.

Parse owned terrain store bytes into a reader handle.

Evaluate (longitude_deg, latitude_deg) points as orthometric heights.

Return orthometric terrain height at (longitude_deg, latitude_deg).

Return orthometric terrain height at (longitude_deg, latitude_deg) with lookup options.

Evaluate (longitude_deg, latitude_deg) points as typed orthometric heights.

Return typed orthometric terrain height at (longitude_deg, latitude_deg).

Return typed orthometric terrain height with lookup options.

Return the FNV-1a checksum for terrain store bytes.

Return parsed tile index records.

Return canonical terrain store bytes from a parsed handle.

Return the file-level vertical datum.

Convert a DTED tile tree and write terrain store bytes to out_path.

Types

interpolation()

@type interpolation() :: :bilinear | :nearest_posting

Terrain interpolation method.

t()

@type t() :: %Sidereon.Terrain.MmapTerrain{handle: reference()}

Parsed terrain store handle.

terrain_datum_error()

@type terrain_datum_error() :: Sidereon.Terrain.MmapTerrain.TerrainDatumError.t()

Terrain datum conversion or geoid-grid loading error.

terrain_store_error()

@type terrain_store_error() :: Sidereon.Terrain.MmapTerrain.TerrainStoreError.t()

Terrain store conversion or parse error.

Functions

checksum64(bytes)

@spec checksum64(t() | binary()) :: non_neg_integer()

Return a checksum for a parsed store handle or terrain store bytes.

dted_tree_to_mmap_store(root)

@spec dted_tree_to_mmap_store(String.t()) ::
  {:ok, binary()} | {:error, terrain_store_error() | term()}

Convert a DTED tile tree into terrain store bytes.

ellipsoidal_height_m(terrain, longitude_deg, latitude_deg, opts \\ [])

@spec ellipsoidal_height_m(t(), number(), number(), keyword()) ::
  {:ok, Sidereon.Terrain.MmapTerrain.EllipsoidalHeightM.t()}
  | {:error, terrain_datum_error() | term()}

Return WGS84 ellipsoidal terrain height using the embedded EGM96 1-degree grid.

ellipsoidal_height_m_with_model(mmap_terrain, longitude_deg, latitude_deg, model, opts \\ [])

@spec ellipsoidal_height_m_with_model(
  t(),
  number(),
  number(),
  Sidereon.Terrain.MmapTerrain.TerrainGeoidModel.t() | :egm96_one_degree,
  keyword()
) ::
  {:ok, Sidereon.Terrain.MmapTerrain.EllipsoidalHeightM.t()}
  | {:error, terrain_datum_error() | term()}

Return WGS84 ellipsoidal terrain height with an explicit geoid model.

Passing TerrainGeoidModel.egm96_fifteen_minute/1 requires a loaded Egm96FifteenMinuteGeoid; it never falls back to the embedded 1-degree grid.

ellipsoidal_height_m_with_options(mmap_terrain, longitude_deg, latitude_deg, opts)

@spec ellipsoidal_height_m_with_options(t(), number(), number(), keyword()) ::
  {:ok, Sidereon.Terrain.MmapTerrain.EllipsoidalHeightM.t()}
  | {:error, terrain_datum_error() | term()}

Return WGS84 ellipsoidal terrain height with lookup options.

from_bytes(bytes)

@spec from_bytes(binary()) :: {:ok, t()} | {:error, terrain_store_error() | term()}

Parse terrain store bytes into a reader handle.

from_path(path)

@spec from_path(String.t()) :: {:ok, t()} | {:error, terrain_store_error() | term()}

Read a terrain store file into a reader handle.

from_vec(bytes)

@spec from_vec(binary()) :: {:ok, t()} | {:error, terrain_store_error() | term()}

Parse owned terrain store bytes into a reader handle.

height_batch(terrain, points, opts \\ [])

@spec height_batch(t(), [{number(), number()}], keyword()) ::
  [ok: Sidereon.Terrain.MmapTerrain.OrthometricHeightM.t(), error: term()]
  | {:error, term()}

Evaluate (longitude_deg, latitude_deg) points as orthometric heights.

height_m(terrain, longitude_deg, latitude_deg, opts \\ [])

@spec height_m(t(), number(), number(), keyword()) ::
  {:ok, Sidereon.Terrain.MmapTerrain.OrthometricHeightM.t()} | {:error, term()}

Return orthometric terrain height at (longitude_deg, latitude_deg).

height_m_with_options(mmap_terrain, longitude_deg, latitude_deg, opts)

@spec height_m_with_options(t(), number(), number(), keyword()) ::
  {:ok, Sidereon.Terrain.MmapTerrain.OrthometricHeightM.t()} | {:error, term()}

Return orthometric terrain height at (longitude_deg, latitude_deg) with lookup options.

orthometric_height_batch(mmap_terrain, points, opts \\ [])

@spec orthometric_height_batch(t(), [{number(), number()}], keyword()) ::
  [ok: Sidereon.Terrain.MmapTerrain.OrthometricHeightM.t(), error: term()]
  | {:error, term()}

Evaluate (longitude_deg, latitude_deg) points as typed orthometric heights.

orthometric_height_m(terrain, longitude_deg, latitude_deg, opts \\ [])

@spec orthometric_height_m(t(), number(), number(), keyword()) ::
  {:ok, Sidereon.Terrain.MmapTerrain.OrthometricHeightM.t()} | {:error, term()}

Return typed orthometric terrain height at (longitude_deg, latitude_deg).

orthometric_height_m_with_options(mmap_terrain, longitude_deg, latitude_deg, opts)

@spec orthometric_height_m_with_options(t(), number(), number(), keyword()) ::
  {:ok, Sidereon.Terrain.MmapTerrain.OrthometricHeightM.t()} | {:error, term()}

Return typed orthometric terrain height with lookup options.

terrain_store_checksum64(bytes)

@spec terrain_store_checksum64(binary()) :: non_neg_integer()

Return the FNV-1a checksum for terrain store bytes.

tile_index(mmap_terrain)

Return parsed tile index records.

to_bytes(mmap_terrain)

@spec to_bytes(t()) :: binary()

Return canonical terrain store bytes from a parsed handle.

vertical_datum(mmap_terrain)

@spec vertical_datum(t()) :: Sidereon.Terrain.MmapTerrain.VerticalDatum.t()

Return the file-level vertical datum.

write_dted_tree_to_mmap_store(root, out_path)

@spec write_dted_tree_to_mmap_store(String.t(), String.t()) ::
  :ok | {:error, terrain_store_error() | term()}

Convert a DTED tile tree and write terrain store bytes to out_path.