Package-level declarations
Types
Marching-squares contour generation, ported from the sibling iOS app's ContourGenerator.swift.
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.
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.
One contour line at elevationMeters, already chained into a single connected polyline.
A point in a tile's own [0,1]×[0,1] unit square — same convention as the base offline layer's tile-local math.
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.
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).
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.
A point in geographic space, degrees — what TerrainTileMath.lonLatAt converts a tile-local position into.
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.
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.
Mapterhorn's two-tier archive split: a global low-res layer always present, a regional high-res layer sometimes.
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.
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.
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.
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.
Raw Terrarium WebP tiles as a plain file hierarchy under baseDir: <baseDir>/<source>/<zoom>/<x>/<y>.webp.
Functions
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.