One Source Schema
Built-in terrain sources, library entries and your own sources are one record type, looked up by id in one place and resolved by one function.
A terrain source is the same record wherever it is listed: a Worldwide Default shipped with the app, a Library entry, or a source you added. Only where it surfaces differs. Imagery basemaps with a fixed tile address follow the same schema.
The record
lib/source-schema.ts defines it:
| Type | What it adds |
|---|---|
SourceEntryBase | What every source has: id, name, url, zoom range, tileSize, bounds, documentation, licence, and apiKey when the tiles need one |
TerrainSourceEntry | An elevation transport (type: terrarium, terrainrgb, cog, vrt, wms-raw, lerc, quantized-mesh, dem-diff, ...) and its decoding settings (nodata, RGB packing, difference operands) |
RasterSourceEntry | An imagery transport (type: tms, wms, wmts, cog, iiif, ...) and its display settings (role, opacity, scheme) |
section says where an entry surfaces: defaults (Worldwide Defaults, the built-in basemaps), library (the Library dialogs) or custom (your own list). The saved lists in your browser and the library file predate the field, so an entry without it is read from the list it sits in.
Ids never change: a shared link names a source by id (?terrainSourceA=mapterhorn, ?terrainSourceA=custom-global-gem15-dtm).
A Library entry can carry a libraryGroup, a key of LIBRARY_GROUPS (lib/library-groups.ts): the Library dialog then lists it in that thematic section, after the scope sections (Nation-wide, Global, Sub-national, City), folded unless the group says otherwise, and the search reads the group's title and keywords with each of its rows. The one group so far is relief, the pre-rendered relief products (hillshades, sky view factor, local dominance, red relief maps) published as imagery; adding a group is one record in that file, and a key it does not know still gets a section named after the key.
Two raster fields fix a tile service's own shortcomings, through the tiletx:// protocol (lib/tile-transform-protocol.ts): alphaMode says what the tiles' alpha becomes, always leaving no-data (alpha 0) transparent: "served", "opaque" (any alpha to 255, for ArcGIS Online's 8-bit layers whose PNG tiles carry an alpha of about 127 on every pixel; the older forceOpaque: true is read as this), "multiply" (black, alpha 255 minus the luminance: a multiply blend over the imagery) or "screen" (white, alpha the luminance: a screen blend). On a Library entry it is the default; the edit dialog's Transparency field writes the user's choice on their stored copy, which wins (resolveAlphaMode: the user's alphaMode, then the Library's, then forceOpaque, then served); underzoom (1 to 3) assembles a tile from its 4, 16 or 64 children at the source's minzoom for that many zoom levels below it, fetching only the children inside bounds, so a service with no overview tiles does not vanish when the view zooms out. A source added before the Library gave it either field still gets it: the map reads them from the Library entry with the same id.
The credit has two forms. attribution is the full credit, shown in Source Info; shortAttribution, set where the full one is long, is the map line: publisher short name and licence code ("MARI-GISLAB (Tulane), CC BY-NC-SA"). sourceCredit (lib/source-credit.ts) builds the string a MapLibre source carries: the short credit linked to licenseUrl (else infoUrl), so entries of one publisher give the same string and the attribution control shows it once; else the full credit, else the name, linked to infoUrl. A source added before its Library entry had a short credit takes the Library's, unless its attribution was edited.
An apiKey names the setting whose value fills the {API_KEY} placeholder of url (entryUrl). A keyed source is hidden from the pickers until its key is set (hasEntryKey).
Where the entries are
| File | Entries |
|---|---|
lib/terrain-sources.ts | The built-in Worldwide Defaults: Mapterhorn, Esri, Mapbox, MapTiler, AWS, Cesium World Terrain |
lib/custom-sources.json | The Library. An entry with "section": "defaults" is also a Worldwide Default: GEM-15 DTM, last in the list |
lib/basemap-sources.ts | The built-in basemaps with a fixed address: Google Hybrid and Satellite, Bing, Esri, Mapbox, MapTiler, HERE |
Your browser (customTerrainSources, customBasemapSources) | Your own sources and the Library entries you added |
The dated imagery has an address per date rather than one address: it has its own schema, below. The OpenStreetMap vector style is not a tile source and stays outside both.
One lookup, one resolver
lib/terrain-catalog.ts holds the lookup: findTerrainSource(id, yourSources) returns your entry of that id, else the Worldwide Default. WORLDWIDE_DEFAULTS is the picker's list and visibleWorldwideDefaults(keys) the part of it your keys open.
Everything that reads a terrain source goes through that lookup, with no branch for built-ins:
| Reader | Resolver |
|---|---|
The map's terrain and hillshade source (TerrainSources) | buildRasterTileSource on the entry |
| The derived modes, the difference source, the elevation picker, the client export | terrainTileSpec (lib/terrain-tile-spec.ts) |
| Contours | buildTileUrl in ContoursLayer.tsx, then terrainTileSpec for the app's own schemes |
| GDAL commands (the info dialogs) and the titiler export | gdalTileSource |
| The tile service and the MCP server | terrainTileSpec, on the same entries written to tile-server/generated/library.json |
What GDAL can read
gdalTileSource gives GDAL a plain {z}/{x}/{y} pyramid when one exists. A Terrarium or Terrain-RGB pyramid is read as is, with its own tile size. A COG, a VRT or a raw WMS is read through titiler as Terrain-RGB tiles. LERC, quantized mesh, a difference, a cell-routed mosaic (GEM-15), STAC, MosaicJSON, TileJSON and local files are decoded by the app alone, so they have no GDAL command; the Download section exports them.
Dated imagery
A dated source maps a date and a place to tiles. DatedImagerySource (in lib/source-schema.ts) shares the source record's id, name, shortName, description, infoUrl and apiKey, and adds:
| Field | What it is |
|---|---|
section | defaults for the timeline's own sources, library for the national and regional series, catalog for the STAC catalogs |
granularity | What a date is: a capture dated per tile (capture), a monthly, quarterly or yearly mosaic, a flight year or period (year), or the one current mosaic (current) |
realDates | false when the dates are a placeholder cadence (HLS: a tick a month, the mosaic of a 30-day window; Planetary Computer's monthly and quarterly mosaics) |
bounds, licence | Where a series has any date, and its licence (the national series) |
historicalEntry | Offered inside the sidebar's single Historical Imagery entry (Bing is a plain basemap there, with a pill on the timeline) |
tileSize, maxzoom | The tiles' size and the deepest zoom with real tiles: the map overzooms past it, the camera's ceiling follows it |
attribution | The constant string the map shows; the real per-place credit is in the sidebar's Source Info section, since a mounted source's attribution cannot change |
fixedDates(keys) | The dates known without a request (HLS's months, Planet's months with a key, EOX's years), for the timeline to show at once |
listDates(place, start, end, keys) | The catalog: every date at a place in a range |
tiles(tick, { keys, hd }) | The tiles of a date: the map's template, and for an export a plain https template, a tile fetcher or Bing's quadkey builder. null until the date can name them (a Wayback date before it is resolved to a release, a missing key) |
lib/dated-imagery.ts holds the six sources: Esri Wayback, NASA HLS, Google Earth historical, Planet monthly mosaics, EOX Sentinel-2 cloudless and Bing (its one current mosaic, dated by its capture date at the place). Their ids are the URL's (?historicalActiveSourceA=wayback).
The national and regional series of lib/national-historical.ts are dated sources too, in the library section: lib/national-dated.ts turns each one (an agency's flights such as Spain's PNOA or the Netherlands' PDOK, about seventy in all, Google Earth Timelapse, Landsat WELD, Planetary Computer's Landsat and Sentinel-2 mosaics) into a source whose dates are its layers' years, periods or months and whose tiles for a date are that layer (an XYZ template, a WMS GetMap with {bbox-epsg-3857}, or one of the app's schemes). Their listDates keeps the layers whose extent holds the place. ALL_DATED_IMAGERY_SOURCES lists them with the STAC catalogs below, and findDatedImagery finds any by id (cat-nat-pnoa, cat-nat-gtimelapse, stac-oam). A layer's basemap id (custom-basemap-cat-cat-nat-pnoa--PNOA2004) is the one the timeline gives it and a shared link rebuilds.
STAC catalogs
A STAC catalog is a dated source through one adapter, lib/stac-dated.ts, configured per catalog (StacCatalogConfig) rather than one class per catalog:
| Field | What it is |
|---|---|
endpoint, kind | A STAC API root (one /search per place) or a static catalog.json (crawled, lib/stac-crawl.ts) |
collections | The collections searched (an API), or the child catalog to crawl from (static) |
assetKeys | The asset to drape, before the defaults (visual, cog, image, the visual role, the first GeoTIFF) |
signing | planetary-computer: Azure Blob hrefs get a SAS token from Planetary Computer's token endpoint, per collection, refreshed when it has under five minutes left; tiles is null until one is held |
query | The STAC query extension (cloud cover), sent as a POST |
maxzoom, maxItems | The ceiling when items state no GSD; the items read per place (300 by default) |
presetId, timelineCatalog | The STAC search panel's catalog and the timeline catalog that read the same items |
- Dates at a place: an item search over a box about two tiles of the zoom across, around the point;
nextpages are followed (a POSTnextwith its body) up tomaxItems. The items are grouped by UTC day of acquisition (datetime, else the start ofstart_datetime/end_datetime): one tick a day, itsrefthe day's items with their footprints and GSD. - Tiles of a date: one COG through titiler; several (a satellite pass cut into 5 km COGs, two drone flights the same day) mosaicked by
lib/capture-mosaic.ts(capture://, with afetchTileBlobfor exports). Theboundsare the union of the footprints: unlike a global source, a date covers only part of the area. The COGs go through titiler rather than the in-browsercog://protocol because most are in UTM. - Ceiling: the first zoom whose pixel is no larger than the day's finest item GSD at its latitude, capped at 22.
The presets: OpenAerialMap (stac-oam), Maxar Open Data (stac-maxar), Vantor (stac-vantor) and NOAA emergency response (stac-noaa), all from HOT's STAC API, and Sentinel-2 L2A scenes under 20 % cloud from Planetary Computer (stac-pc-s2, signed). The timeline's HOT catalogs (cat-oam, cat-maxar...) take their endpoint and collection from these presets and search through the adapter's searchStacItems; they still list one tick per acquisition, with a card, rather than one per day. The STAC search panel stays the manual search, a page at a time.
node scripts/test-lib.mjs lib/stac-dated.test.ts checks the adapter offline against a recorded HOT search over Antakya (lib/fixtures/hot-stac-antakya.json).
Readers
| Reader | What it takes from the schema |
|---|---|
The map's basemap (RasterBasemapSource) | tiles and maxzoom, for the view's date |
The multi-date export (lib/historical-export-sources.ts) | listDates, then tiles for each date; the current basemaps come from the built-in basemap entries |
| The timeline | fixedDates for HLS, Planet and EOX |
The MCP server's imagery_dates | listDates of every source with real dates and no key, the national series included (each date with its layer's basemap id, which open_view takes as imageryUrl), and the STAC catalogs (each day with its items' count, GSD, footprint and the COG under the place as imageryUrl) |
| The timeline's national catalogs | A layer's tiles (nationalLayerTiles); the catalog walk itself also asks the agency's flight index or probes a tile, to drop years flown elsewhere in the extent |
| The tile service | The registry, bundled in generated/app-lib.mjs |
Still outside it: the live per-place walks the timeline runs as React hooks for Wayback, Google Earth and Bing (debounced, cached, filled in progressively; listDates is their one-shot equivalent), and the per-place attribution hooks. The timeline's other catalogs (old maps, ArcGIS Online, Map Warper, the STAC catalogs you attach...) are search results, each item with its own footprint and address rather than one source with a date, and stay with the catalogs.
Before the schema
Until 2026-11-23 the built-ins were a different shape ({ name, link, encoding, sourceConfig: { tiles, tileSize, maxzoom } }), and every reader branched on which shape it got. GEM-15 was shown among the defaults by a pinned row that copied the library entry into your own list before selecting it. That copy stays in the lists of those who picked it then; it is the same record, and your copy wins over the default.
Tile service (Scalar)
What the app draws, served as XYZ tiles and as pictures of a viewport over HTTP, from a Docker image; its addresses and parameters browsed with Scalar
QGIS Plugins
Two released QGIS plugins - Terrain Viewer 0.6.0, the app's sidebar as a QGIS panel whose modes are tile service layers (Colour and Values per mode), with an Install button for a local tile service and an experimental local compute of 16 modes in numpy - and Send2MapApp 0.5.1, the app's "Open in" list in QGIS.