Package-level declarations

Types

Link copied to clipboard

Marching-squares contour generation, ported from the sibling iOS app's ContourGenerator.swift.

Link copied to clipboard
data class ContourIntervalBand(val minorMeters: Float, val indexMeters: Float)

A zoom band's minor/index spacing, always in meters — ContourIntervals.forZoom's metric flag only picks which round-number family (meters vs. feet-converted-to-meters) generated the values.

Link copied to clipboard

The zoom-banded contour interval table, ported verbatim from the sibling iOS app's ContourGenerator.swift:38-58 (ContourIntervals.intervals(forZoom:metric:)). indexMeters is always 5 × minorMeters in every band; every 5th minor line is an index line.

Link copied to clipboard
data class ContourLine(val elevationMeters: Float, val points: List<ContourPoint>)

One contour line at elevationMeters, already chained into a single connected polyline.

Link copied to clipboard
data class ContourPoint(val x: Float, val y: Float)

A point in a tile's own [0,1]×[0,1] unit square — same convention as the base offline layer's tile-local math.

Link copied to clipboard
data class ContourStyle(val strokeHexColor: String, val strokeWidth: Float, val strokeOpacity: Float)

A contour line's style, expressed as simplestyle-spec property values (stroke, stroke-width, stroke-opacity) rather than a platform color type — both renderers already consume simplestyle properties for imported layers (MapLibre's CustomLayers.kt style expressions; Google's applySimpleStyleSpec()), so a contour feature carrying these properties styles itself identically on both flavors with no per-flavor color logic to keep in sync.

Link copied to clipboard
Link copied to clipboard
class ElevationTile(val width: Int, val height: Int, val elevations: FloatArray)

A decoded elevation grid in meters, row-major with (0,0) at the image's top-left — the same orientation as the source tile's own pixels, and as org.meshtastic.app.map.offline.pmtiles.WebMercatorTileMath's tile-local Y (top-to-bottom, matching XYZ tile convention).

Link copied to clipboard
data class GeoBounds(val south: Double, val west: Double, val north: Double, val east: Double)

A geographic bounding box, degrees.

Link copied to clipboard
object Hillshade

Horn's-method hillshade, ported from the sibling iOS app's HillshadeTileOverlay.swift: shadow-only output (black RGB, alpha = shadow depth) so it composites correctly over both light and dark basemaps without a separate light-mode palette, plus the three cleanup passes iOS added against real artifacts in Puget Sound data — despiked water, sea-surface noise, and flattened-valley noise all showing up as fake terrain.

Link copied to clipboard
data class LonLat(val longitude: Double, val latitude: Double)

A point in geographic space, degrees — what TerrainTileMath.lonLatAt converts a tile-local position into.

Link copied to clipboard

Mapterhorn's two-tier PMTiles layout, ported from the sibling iOS app's mapterhorn-data-contract.md: a single global archive always available at low zoom, plus per-region high-res archives keyed by their own z6 tile coordinate, present only where source data coverage allows.

Link copied to clipboard
sealed interface TerrainDownloadState
Link copied to clipboard
class TerrainRegionExtractor(store: TerrainTileStore, openArchive: (pmtilesUrl: String) -> TerrainRegionExtractor.TileArchive = ::remoteArchive)

Extracts a region's offline terrain: a global low-res layer (always, up to MapterhornEndpoints.GLOBAL_MAX_ZOOM) plus, where bounds fits inside a single z6 tile, a regional high-res layer on top — ported from the sibling iOS app's two-tier TerrainStore download behavior. One tile per HTTP request, like the base offline layer's own extractor; see its README for why that bounds MAX_TILES well below iOS's own per-region cap.

Link copied to clipboard

Mapterhorn's two-tier archive split: a global low-res layer always present, a regional high-res layer sometimes.

Link copied to clipboard
actual class TerrainTileFetcher(pmtilesUrl: String) : AutoCloseable

Fetches individual tiles from a remote PMTiles archive by range request — never the whole archive, just the bytes of the tile asked for. Backed by ch.poole.geo.pmtiles:Reader (MIT-licensed), the same library the base offline layer uses for Protomaps; here it's pointed at Mapterhorn's Terrarium elevation archives instead.

expect class TerrainTileFetcher(pmtilesUrl: String) : AutoCloseable

Fetches individual tiles from a remote PMTiles archive by range request — never the whole archive, just the bytes of the tile asked for. Backed by ch.poole.geo.pmtiles:Reader (MIT-licensed), the same library the base offline layer uses for Protomaps; here it's pointed at Mapterhorn's Terrarium elevation archives instead.

actual class TerrainTileFetcher(pmtilesUrl: String) : AutoCloseable

Fetches individual tiles from a remote PMTiles archive by range request — never the whole archive, just the bytes of the tile asked for. Backed by ch.poole.geo.pmtiles:Reader (MIT-licensed), the same library the base offline layer uses for Protomaps; here it's pointed at Mapterhorn's Terrarium elevation archives instead.

Link copied to clipboard

Standard XYZ/slippy-map Web Mercator tile math, self-contained here (rather than reused from either flavor's own copy — feature/map-maplibre's TileEstimate.kt and the Google flavor's WebMercatorTileMath in the sibling feat/map-google-pmtiles-offline branch) so this module has no dependency in either direction on flavor-specific code — this module is a shared math library, not a consumer of one flavor's app code.

Link copied to clipboard
class TerrainTileStore(fileSystem: FileSystem, baseDir: Path)

Raw Terrarium WebP tiles as a plain file hierarchy under baseDir: <baseDir>/<source>/<zoom>/<x>/<y>.webp.

Link copied to clipboard
data class TileIndex(val zoom: Int, val x: Int, val y: Int)

A single XYZ (google/osm-convention, not TMS) slippy-map tile index.

Functions

Link copied to clipboard

Decodes a Terrarium-encoded WebP tile (Mapterhorn's format) into meters-above-sea-level.

Decodes a Terrarium-encoded WebP tile (Mapterhorn's format) into meters-above-sea-level.

Decodes a Terrarium-encoded WebP tile (Mapterhorn's format) into meters-above-sea-level.

Link copied to clipboard
fun terrariumElevationMeters(red: Int, green: Int, blue: Int): Float