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
The app runs in the browser and has no server. The tile service is a small server that hands out what the app draws, so a map library, QGIS or a script can use a Terrain Viewer view without running the app. Two engines draw:
| Engine | Draws | Time per tile |
|---|---|---|
| Direct | Every 2D terrain mode and overlay (contours with labels, iso-line, mound detector, plane slicer, graticule, dark theme), computed in the server by the app's own code from any source the app reads, read with the app's own readers | 0.05 to 2.5 s |
| Browser | Everything: the app itself in a headless browser, so every source, every mode, imagery, 3D, split views and combined layouts | 3 to 10 s for a new block, then milliseconds |
Tiles and viewports take the direct engine whenever they can. 3D, tilted, rotated and split views always take the browser, and so do imagery and the few layers listed in What goes to the browser.
docker run -p 3400:3400 --shm-size=1g -v tv-tiles:/data/tiles ghcr.io/iconem/terrain-viewer-tilesOr from a clone, without Docker: cd tile-server && pnpm install && pnpm start (after pnpm install at the root). The service is its own package, tile-server/, with its own image (tile-server/Dockerfile).
Then http://localhost:3400/docs is the API reference with a working Test request button, and http://localhost:3400/openapi.json its OpenAPI document. http://localhost:3400/ opens that page too: its first section is the quick start below, with the service's own address in each line.
Quick start
Copy an address into QGIS (XYZ Tiles), MapLibre, CesiumJS or Blender. Leave {z}/{x}/{y} as they are: the client fills them in. On another server, replace http://localhost:3400 with its address.
Slope from Mapterhorn, as XYZ tiles (any mode of /processes, or several comma-separated):
http://localhost:3400/terrain-tiles/mapterhorn/{z}/{x}/{y}.png?modes=slopeSky-view factor from IGN RGE ALTI (France), as XYZ tiles (zoom 12 and finer; the first tiles of an area take a second or two):
http://localhost:3400/terrain-tiles/custom-fr-ign-rgealti-highres/{z}/{x}/{y}.png?modes=svfA source given by its address rather than an id (Terrarium tiles here; a COG, a VRT or a JSON configuration the same way), in the query:
http://localhost:3400/terrain-tiles/{z}/{x}/{y}.png?modes=hillshade&terrainSource=https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.pngCesium terrain (quantized mesh) from Mapterhorn: the layer.json, for CesiumJS or Blender (see Quantized mesh; martini mesher, heights above the ellipsoid):
http://localhost:3400/quantized-mesh/mapterhorn/layer.jsonThe same terrain meshed by delatin instead of martini (half the triangles, three times slower to make):
http://localhost:3400/quantized-mesh/mapterhorn/layer.json?mesher=delatinImagery: Esri Wayback of 2020 as XYZ tiles (the dated imagery and the built-in basemaps by id: /basemaps):
http://localhost:3400/basemap-tiles/wayback/{z}/{x}/{y}.jpg?imageryDate=2020-01-01A picture of a box (west, south, east, north in degrees; .tif with one mode gives its values):
http://localhost:3400/bbox/7.6,45.95,7.7,46/800x600.png?terrainSource=mapterhorn&modes=hillshade,contoursA colour ramp as a picture, for a legend (orientation=vertical; the ids: /colorramps):
http://localhost:3400/colorramps/slope-plantopo.png?width=256&height=16The STAC Item of a tile (any raster export's address plus .stac.json):
http://localhost:3400/terrain-tiles/mapterhorn/12/2133/1449.png.stac.json?modes=slopeThe modes, as OGC API - Processes (each mode's settings: /processes/{id}):
http://localhost:3400/processesThe answers
| Address | Answers | Like |
|---|---|---|
/terrain-tiles/{source}/{z}/{x}/{y}.png or .jpg (or /terrain-tiles/{z}/{x}/{y}…?terrainSource=) | One Web Mercator tile of the modes computed from the elevation, by its index. 256 px; {y}@2x or tilesize=512 for 512 px | An XYZ tile layer, titiler's /tiles |
/basemap-tiles/{source}/{z}/{x}/{y}.jpg or .png (or /basemap-tiles/{z}/{x}/{y}…?imageryUrl=) | One tile of the imagery under the terrain, see Addresses for which | An XYZ basemap |
/render.png or .jpg | A picture of a viewport: lat, lng, zoom, or bbox=west,south,east,north, with width and height. Can be tilted (viewMode=3d, pitch, bearing) or split, and can mix imagery and terrain modes | A WMS GetMap |
/bbox/{w},{s},{e},{n}/{width}x{height}.png, .jpg or .tif | The same answer as /render with bbox, width and height, the box and the size in the address (titiler's form); its .stac.json Item and Link header like /render | titiler's /bbox |
/quantized-mesh/{source}/layer.json and /{z}/{x}/{y}.terrain | The elevation as Cesium terrain, see Quantized mesh | Cesium ion terrain |
Addresses: a source in the path or in the query
The source can be named in the path, as /quantized-mesh/{source}/… always did, or given in the query. Both forms answer the same tile, and the query forms stay:
| In the path: a library id | In the query: anything else |
|---|---|
/terrain-tiles/mapterhorn/{z}/{x}/{y}.png?modes=slope | /terrain-tiles/{z}/{x}/{y}.png?modes=slope&terrainSource=<address, COG, VRT or JSON> |
/basemap-tiles/wayback/{z}/{x}/{y}.jpg?imageryDate=2020-01-01 | /basemap-tiles/{z}/{x}/{y}.jpg?imageryUrl=<XYZ or COG address> |
/quantized-mesh/mapterhorn/layer.json | /quantized-mesh/custom/layer.json?terrainSource=<…> |
An id goes in the path because it is short and cannot be lost from a copied template; an address cannot (it holds slashes and its own {z}/{x}/{y}). custom in the path means "the source is in the query" on all three. An unknown id answers 404 naming the list to look in (/sources, /basemaps). The same holds for .tif, .pbf, .mvt and .stac.json.
/basemap-tiles is not only the historical imagery: it draws the basemap as the app does, so it serves the dated sources (wayback, ge-historical, bing, hls, eox-s2, each with imageryDate), the app's built-in basemaps with a fixed address (google, googlesat, bing, esri, mapbox, maptiler, here), any XYZ or COG address (imageryUrl), and the app's basemap parameters (basemapSource, overlayBasemapIds). bing is in both lists: dated with an imageryDate, Bing Aerial without. It keeps its name for that reason. /basemaps lists the ids.
A tile is the map alone. A viewport keeps the scale bar and the credits. The terrain tiles refuse basemap and the basemap tiles refuse terrain modes: ask both and stack them in the client.
Both take the view as query parameters, the same words the MCP server uses:
| Parameter | Meaning |
|---|---|
terrainSource | An id from /sources (the built-in sources and the library), the address of Terrarium tiles, of a COG (.tif) or of a VRT (.vrt), or a configuration as JSON with the fields of a library entry: {"url": "…/{z}/{x}/{y}.png", "type": "terrainrgb", "maxzoom": 15} (types terrarium, terrainrgb, cog, vrt, wms-raw, lerc, quantized-mesh, tilejson) |
modes | Comma-separated: hillshade, colorRelief, contours, slope, aspect, curvature, tpi, roughness, lrm, svf, openness, localDominance, phong, matcap, shadows, moundDetector, isoline, graticules, planeSlicer, basemap (also tri, shapeIndex, blobness, eigenRatio, orientation) |
imageryUrl, imagerySource, imageryDate | The imagery of /basemap-tiles (and of a viewport, under the terrain, with the mode basemap) |
engine | auto (the default: direct when it can), direct (an error when it cannot), browser |
background | none: no white (or black) map background, a transparent PNG, to stack layers in a GIS. Direct engine only |
mapboxKey, maptilerKey, cesiumIonKey | Your own API key, for the Mapbox, MapTiler and Cesium ion sources. The direct engine's readers use it, and the browser engine gives it to the app as a setting, never in the app's address. A tile made with a key is cached apart from one made without |
| anything else | Passed to the app as a URL parameter: ramps, opacities, light direction, contour interval |
Every answer says which engine drew it in its x-tv-engine header, and x-tv-engine-why says why not the direct one.
How several modes stack
modes=a,b,c draws them in one tile in the map's order, never in the order written. Bottom to top: colorRelief, the terrain analysis and relief visualization modes (slope, aspect, tri, curvature, tpi, lrm, roughness, shapeIndex, blobness, eigenRatio, orientation, svf, openness, localDominance), hillshade, matcap, phong, shadows, buildingShadows, then the overlays isoline, graticules, moundDetector, planeSlicer and contours on top. /processes/{id} gives each mode's place as x-tv-stack-rank.
A mode's opacity is its own parameter (slopeOpacity) times its panel group's (terrainAnalysisOpacity, reliefVisualizationOpacity, lightingEffectsOpacity): slopeOpacity=0.5&terrainAnalysisOpacity=0.4 draws the slope at 0.2. Each layer is drawn source-over with that opacity, over the map's background (white, black with theme=dark, none with background=none). The shading layers differ: the hillshade is a half-transparent dark and light layer, Phong and matcap multiply the colours under them and add their highlight, the shadows darken. In a GIS, give them a multiply blend, as the QGIS project does.
Refused together: basemap with /terrain-tiles, a terrain mode with /basemap-tiles, a mode that is only a picture with .pbf, more than one mode or a mode without values with .tif, and engine=direct with what only the browser draws. Any other set stacks.
Removed addresses
/tiles/{z}/{x}/{y} (every extension) and /modes were removed on 2026-11-24 and answer 404 with the address to use: /terrain-tiles/... for the elevation modes, /basemap-tiles/... for the imagery, /processes and /view for /modes. titiler's tile addresses were removed on 2026-11-25 and answer 404 the same way: /tiles/WebMercatorQuad/{z}/{x}/{y} (ask /terrain-tiles/{z}/{x}/{y}) and /WebMercatorQuad/tilejson.json (ask /tilejson.json). /bbox/{w},{s},{e},{n}/{width}x{height}.{format}, removed the same day, came back on 2026-11-25 as a documented address: it answers what /render.{format}?bbox=…&width=…&height=… answers, and /render stays for centred viewports.
Names, not addresses
Like titiler's list of tile matrix sets, three lists give the ids the parameters take:
| Address | Lists |
|---|---|
/sources, /sources/{id} | The 141 terrain sources: built-in and library, with type, tile address, zoom range, extent, and the engine that can draw each |
/colorramps, /colorramps/{id} | The app's 268 colour ramps, to name as colorRamp (colour relief) or slopeColorRamp (slope); one ramp gives its stops |
/colorramps/{id}.png or .jpg | A ramp as a picture, coloured as the map colours it (MapLibre's colour relief: linear between the stops): width and height (256 × 16 by default, 16 × 256 vertical), orientation=vertical (the lowest value at the bottom; horizontal: on the left), reverse=true. PNG keeps the ramp's transparency, JPEG is on white. For a legend or a ramp picker |
/basemaps | What /basemap-tiles/{source}/… takes: the dated imagery and the built-in basemaps, each with the parameter it stands for and its API key |
/algorithms | The modes with the engine that draws each |
/processes, /processes/{id} | Each mode as an OGC API - Processes description: its settings as inputs with their JSON Schema (type, range, values, default), its outputs, its panel group, form, opacity parameters, and the unit and typical range of its values. The QGIS plugin builds its panel from it |
/view?url=<a share link> or /view?<its query> | Reads a link of the app: which modes it switches on (active), each mode's opacity, the parameters its layers keep, the camera, and tiles.terrain, the XYZ template that draws it here. Paste https://terrain-viewer.iconem.com/?showTerrainAnalysis=true&slopeOpacity=0.5&terrainSourceA=mapterhorn (URL-encoded) as url and the answer has "active": ["slope", "hillshade"] and "tiles": {"terrain": "…/terrain-tiles/mapterhorn/{z}/{x}/{y}.png?modes=slope,hillshade"}. The QGIS plugin's Open link reads it |
A source that is not listed can still be given whole, as its address or as a JSON configuration.
Vector tiles
The tile address with .pbf (or .mvt), /terrain-tiles/{z}/{x}/{y}.pbf, answers the line, area and point overlays as a Mapbox Vector Tile, the features the app's own layers draw, one layer each. modes picks them, the app's parameters set them as for the raster tiles, and /tilejson.json?tile_format=pbf&modes=… gives a TileJSON for a MapLibre vector source. The extension chooses raster or vector; a mode drawn only as an image is refused as .pbf. Tiles are 512 px, as the map loads them; past a layer's last zoom (15 for the mound detector, the source's for the others) a tile is cut from its deepest one, scaled up.
| Mode | Layer | Features |
|---|---|---|
contours | contours | Lines, ele (metres) and level (1 for a major line), the app's own contour tiles; on the local relief model with contourReferenceMode=lrm |
isoline | isoband, isoline, isoline-cliff | At a value: the band above it as polygons, its edge as lines, and on slope the simplified cliff edge the teeth hang from. Every interval: isoline lines with ele |
moundDetector | tells | A point per candidate with its measures (a, blobness, plan, detHessian, pit, scaleM, ...) |
planeSlicer | plane-slicer | The area at or above planeSlicerValue (or planeSlicerValueLrm on the local relief model) as polygons, with value and side: the map floods the side planeSlicerSide names (below by default) |
graticules | graticule | Meridians and parallels at the app's spacing for the zoom, kind and deg |
Every mode, raster or vector:
| Mode | Raster tile (.png, .jpg) | Vector tile (.pbf, .mvt) |
|---|---|---|
| Hillshade, colour relief, the 14 computed modes, matcap, Phong, cast shadows | Yes | No: they are images |
| Plane slicer | Yes | No: the app draws it as a colour layer. The same edge as polygons: isoline on elevation at the slice's height |
| Contours, iso-line, mound detector, graticule | Yes, drawn from the same vector tiles | Yes |
The raster tile of these four is made from the vector tiles: their features are read, then drawn with the app's widths, colours and opacities, the contour labels and the cliff teeth placed as MapLibre places line symbols.
map.addSource("tv-overlays", { type: "vector", url: "http://localhost:3400/tilejson.json?tile_format=pbf&modes=contours,moundDetector" })
map.addLayer({ id: "contour-lines", type: "line", source: "tv-overlays", "source-layer": "contours", paint: { "line-width": ["match", ["get", "level"], 1, 1, 0.5] } })
map.addLayer({ id: "contour-labels", type: "symbol", source: "tv-overlays", "source-layer": "contours", filter: ["==", ["get", "level"], 1], layout: { "symbol-placement": "line", "text-field": ["concat", ["get", "ele"], " m"], "text-size": 10 } })
map.addLayer({ id: "mounds", type: "circle", source: "tv-overlays", "source-layer": "tells", paint: { "circle-radius": 8, "circle-color": "rgba(0,0,0,0)", "circle-stroke-color": "#ef4444", "circle-stroke-width": 2 } })Values, not colours
A colour is for the eye; an analysis wants the number under it. One mode's values, before its ramp, in natural units:
| Address | Answers |
|---|---|
/terrain-tiles/{z}/{x}/{y}.tif?modes=slope | A Float32 GeoTIFF tile: one band, EPSG:3857, georeferenced, NaN where there is no data, deflate-compressed with the floating-point predictor (lossless; compression=none for a plain file). 256 px, @2x or tilesize=512 for 512 |
/render.tif?modes=slope&bbox=w,s,e,n&width=1024 | The values over a box, like a WCS GetCoverage: exactly the box, width pixels across, the height that keeps the pixels square in Web Mercator (at most 4096 a side); or lat, lng, zoom, width, height. /bbox/{w},{s},{e},{n}/{width}x{height}.tif is the same |
/terrain-tiles/{z}/{x}/{y}.png?modes=slope&encoding=terrarium | The same values packed in a PNG as an elevation would be (terrarium or terrainrgb), for MapLibre's raster-dem or a few lines of numpy; valueScale multiplies them first, so small values (curvature) stay above the packing's step (1/256 for Terrarium, 0.1 for Terrain-RGB) |
/gdal.xml?modes=slope | The GeoTIFF tiles described for GDAL's WMS driver: one Float32 raster of the whole world down to the source's deepest zoom, with overviews. GDAL opens its address as is: gdalinfo, gdal_translate -projwin, rasterio.open, QGIS's Add Raster Layer |
The compression costs 2 to 6 ms a 256 px tile, small beside its computation (10 to 20 ms for slope, about 0.15 s for the sky view factor at radius 8 when its source tile is not cached yet), and divides the size by about 4 for elevation, 2 for slope, 1.4 for curvature or the sky view factor (their low bits are noise). Browsers do not display TIFF: the API reference's test request answers "Preview unavailable" for these and offers the file to download.
One mode at a time; its own parameters count (curvatureMode, lrmRadius, svfRadius, opennessMode...), its ramp, range and opacity do not. The direct engine computes them, so a source it cannot read, or a mode that is a picture (hillshade, matcap, Phong, shadows, the overlays), is refused with a 400. Each answer gives its unit in x-tv-value-unit, and /processes/{id} gives it with each mode (x-tv-values).
| Mode | Unit | Value |
|---|---|---|
elevation, colorRelief | m | The source's elevation, as it decodes it |
slope | degree | 0 flat to 90 vertical (Horn's kernel, as gdaldem) |
aspect | degree | The direction the slope faces, clockwise from north, 0 to 360 |
tri | m | Mean absolute difference to the 8 neighbours |
tpi | m | Elevation minus the mean of the 8 neighbours |
roughness | m | Largest difference in the 3x3 window |
curvature | 1/m | By curvatureMode: combined (Laplacian), profile, plan, casorati in 1/m; det-hessian in 1/m²; shape-index without unit |
shapeIndex | none | -1 bowl, -0.5 valley, 0 saddle, 0.5 ridge, 1 dome |
blobness | none | det/trace of the gradient's structure tensor (a squared slope) |
eigenRatio | none | λmin/λmax of that tensor, 0 linear (slope, ridge, valley) to 1 isotropic (peak, pit, saddle) |
orientation | degree | The axis of the dominant gradient, clockwise from north, 0 to 180 |
lrm | m | Elevation minus its low-pass trend |
svf | none | The visible share of the sky, 0 to 1 (1 on open flat ground) |
openness | degree | Mean zenith angle to the horizon, 90 on flat ground |
localDominance | degree | Mean angle down to the surrounding terrain, high on mounds |
Some of the app's sliders read these in other units, where its protocols scale a value to fit their RGB packing or their ramp: the sky view factor and the eigenvalue ratio as percentages (×100), openness re-centred on flat ground (minus 90), blobness ×100, curvature ×100 (det-hessian ×10 000). The values here undo those factors. The values are read before that packing, so they are neither clamped (the app's curvature stops at ±0.33 1/m, which steep ground at high zoom exceeds on most pixels) nor rounded to its step.
Quantized mesh
Any source the direct engine reads also comes as Cesium terrain, quantized-mesh-1.0, the format of Cesium ion's terrain. A 3D client is given one address, the layer.json, and asks for the tiles itself:
| Address | Answers |
|---|---|
/quantized-mesh/{source}/layer.json | The layer.json a Cesium client reads first: TileJSON 2.1.0, format: quantized-mesh-1.0, scheme: tms, projection: EPSG:4326, available level by level (level 0 whole, the source's bounds below), maxzoom the level as fine as the source (its deepest 256 px Web Mercator zoom less one: 17 for Mapterhorn), extensions: [octvertexnormals], the source's attribution. The tile template keeps the query given, so ?mesher=delatin, ?heights=orthometric or a key on the layer.json's address reaches every tile |
/quantized-mesh/{source}/{z}/{x}/{y}.terrain | One tile, application/vnd.quantized-mesh, gzipped when the client accepts it, cached a week |
{source} is an id from /sources, or custom with the source in terrainSource (an address or a JSON configuration, as for /terrain-tiles). The API keys are the same as for the other tiles (mapboxKey, maptilerKey, cesiumIonKey, or the operator's). Parameters:
| Parameter | Default | What it does |
|---|---|---|
error | 0.5 | The mesh's vertical error, as a share of Cesium's geometric error of the level (77 km at level 0, halved each level: 4.7 m at level 14, so 2.35 m by default). Smaller for a finer mesh, larger for a lighter one |
mesher | martini | martini or delatin, see Martini or delatin |
heights | ellipsoidal | ellipsoidal (above the WGS84 ellipsoid, the geoid added) or orthometric (above sea level, as the source gives them), see Heights: ellipsoid or sea level |
maxTriangles | 32768 | delatin only: the most triangles a tile gets. The mesh stops refining there, worst points first. The default only bounds noisy or very fine sources; lower it to keep a Blender scene light |
extensions | octvertexnormals, for a client that does not send Cesium's Accept: application/vnd.quantized-mesh;extensions=octvertexnormals |
Heights: ellipsoid or sea level

Quantized mesh is ellipsoidal: Cesium places a vertex at its height above the WGS84 ellipsoid (h), as Cesium World Terrain, 3D Tiles and Google Photorealistic 3D Tiles do. The elevation sources count from sea level instead (H, orthometric: Mapterhorn, AWS Terrain Tiles, Copernicus, IGN, AHN…). Served as they are, the meshes sat too low by the geoid's height N, about 45 m in Paris and 51 m in the Alps, and a photogrammetry mesh or a 3D Tiles city placed with GNSS floated above the ground.
Since 2026-11-25 the service adds it: h = H + N, with N from EGM96 (NGA's 15′ grid, bilinear; the grid is a work of the US government, public domain, read through the MIT package egm96-universal, shipped with the service, nothing fetched). EGM2008 differs from EGM96 by less than a metre in most places and a few metres in high mountains, inside a tile's error at the levels where the shift is visible; the national sea-level datums of the sources differ from the geoid by a metre or two anyway. The source's own datum is read from its entry: cesium (Cesium World Terrain, already ellipsoidal) is not shifted again.
heights | The mesh's heights | For |
|---|---|---|
ellipsoidal (default) | Above the WGS84 ellipsoid: the source's heights plus N | CesiumJS, Cesium for Unreal and Unity, Blender's OGC 3D Tiles add-on: anything that mixes the terrain with 3D Tiles, GNSS or Cesium's globe |
orthometric | Above sea level, as the source gives them (an ellipsoidal source has N taken off) | A client that places everything above sea level, a local scene in metres |
One parameter rather than two endpoints (as Re:Earth Terrain's ellipsoid and elevation): the source stays the only path segment, the other choices (mesher, error) are parameters too, and the layer.json's tile template carries it to every tile. The layer.json's description says which heights it serves. A tile with no data is flat at sea level, the geoid's height at its centre (0 m with orthometric). Looking N up costs under a millisecond a tile (65 × 65 samples, interpolated). The module is tile-server/geoid.mjs.
Blender
The OGC 3D Tiles add-on (blender_ogc3dtiles, with its cesium-native backend installed) streams the terrain around the camera:
- Start the tile service: the desktop app runs it on port 3400, or
docker run -p 3400:3400 ghcr.io/iconem/terrain-viewer-tiles. - In Blender, open the 3D viewport's sidebar (N), tab 3D Tiles, and add an entry (+) of type Quantized-mesh terrain.
- Paste the layer.json address as its URL:
http://localhost:3400/quantized-mesh/mapterhorn/layer.json. Another source: its id in place ofmapterhorn(custom-global-gem15-dtm,custom-nl-ahn-dtm…); a keyed one: add?maptilerKey=…; lighter tiles: add?error=1(or?mesher=delatin, half the triangles). The heights are ellipsoidal, as the add-on reads them. - Drape imagery on top under Raster overlays, as a URL template: this service's imagery,
http://localhost:3400/basemap-tiles/wayback/{z}/{x}/{y}.jpg, or a terrain mode as a picture,http://localhost:3400/terrain-tiles/mapterhorn/{z}/{x}/{y}.png?modes=hillshade,slope. - Press Start. Tiles load as the camera moves. A photogrammetry mesh or a point cloud on top can blend into the terrain (the add-on's Terrain blending, beta).
The add-on asks for the normals itself; for a client that does not, ?extensions=octvertexnormals adds them (smooth shading). Checked with the desktop app's service on port 3400.
CesiumJS
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: await Cesium.CesiumTerrainProvider.fromUrl(
"http://localhost:3400/quantized-mesh/mapterhorn/",
{ requestVertexNormals: true },
),
})
// Any XYZ layer of the service draped over it:
viewer.imageryLayers.addImageryProvider(new Cesium.UrlTemplateImageryProvider({
url: "http://localhost:3400/terrain-tiles/mapterhorn/{z}/{x}/{y}.png?modes=slope&background=none",
}))fromUrl takes the folder of the layer.json. Cesium for Unreal and Unity take the layer.json's address as a quantized-mesh terrain source.
Which sources
Every /sources entry whose engine is direct, by type:
| Type | Checked |
|---|---|
| Terrarium and Terrain-RGB pyramids | Mapterhorn, AWS Terrain Tiles; Mapbox and MapTiler with a key |
| LERC (ArcGIS tiled elevation) | Esri World Elevation |
| COG | NRCan MRDEM 30 m (Canada), swissALTIRegio (Switzerland) |
| VRT of COGs | Google GEM-15 DTM and DSM |
WMS and WCS (wms-raw) | AHN 0.5 m (Netherlands), IGN RGE ALTI (France) |
| PMTiles | SmartMaps GEL |
| Difference (nDSM, change) | Read through their two operands, each as above |
A new tile of a tile pyramid (Mapterhorn, AWS, Esri) takes 0.2 to 0.6 s the first time, of a COG, VRT, WMS or PMTiles source 1 to 3.5 s (several reads per tile); then it comes from the cache.
How a tile is made
The grid is geographic TMS (EPSG:4326, two tiles at level 0, y from the south). The source's Web Mercator pixels of the zoom as wide as the tile (level z reads 256 px zoom z + 1, capped at the source's deepest) are read with a two-pixel border and resampled once, bilinear, to a 257 × 257 grid over the tile; holes are grown from the data around them. The geoid's height is added (unless heights=orthometric), then the grid is meshed within the error, then encoded with the header (centre, minimum and maximum height, bounding sphere, horizon occlusion point), zigzag-delta vertices, high-water-mark indices, the west, south, east and north edge lists and, when asked, the oct-encoded vertex normals. Skirts are the client's, as the spec says. A tile with no data is flat at sea level (and not cached). The meshing is tile-server/quantized-mesh.mjs, a module with no server in it: it takes a height grid and gives the tile, so another app can use it with its own reader.
What keeps it fast: the workers start with the service (the first tile no longer waits about 3 s for them); a source tile fetched by one worker is shared with the others, and decoded tiles are shared with /terrain-tiles; each tile is gzipped once, off the main thread, and kept gzipped, so a cached tile goes out as it is read (about 1,000 tiles a second, 16 requests at a time on a 20-thread machine, against 200 when every answer was compressed again).
Martini or delatin
| delatin | martini (default) | |
|---|---|---|
| Method | Delaunay refinement: adds the worst point, one at a time, until the error is met | RTIN: right triangles split in halves over a 2^k + 1 grid (257 × 257) |
| Triangles for the same error | About 45 % fewer, so 45 % fewer bytes to stream and less memory in Blender | About twice as many |
| Time to make a tile | 25 to 45 ms at levels 10 to 14 (about 7 µs a point), growing with the triangles | 8 to 11 ms, about three to four times faster |
| Structure | Irregular triangles that follow ridges and valleys | A regular, nested pattern of right triangles |
| Cap | maxTriangles | None |
Measured on Mapterhorn around the Matterhorn, one 257 × 257 tile per level, error × 0.5, vertex normals on, the source already read (1.5 to 3 ms), in Node on one core:
| Level (error) | delatin | martini |
|---|---|---|
| 10 (37.6 m) | 7,536 triangles, 75 KB, 31 ms | 14,387 triangles, 142 KB, 10 ms |
| 11 (18.8 m) | 7,233 triangles, 72 KB, 25 ms | 13,662 triangles, 135 KB, 8 ms |
| 12 (9.4 m) | 7,304 triangles, 72 KB, 25 ms | 14,064 triangles, 139 KB, 8 ms |
| 13 (4.7 m) | 13,632 triangles, 134 KB, 39 ms | 24,904 triangles, 245 KB, 10 ms |
| 14 (2.4 m) | 15,179 triangles, 149 KB, 43 ms | 25,178 triangles, 248 KB, 10 ms |
| 14, error × 0.25 (1.2 m) | 27,703 triangles, 272 KB, 85 ms | 42,208 triangles, 415 KB, 18 ms |
| 14, error × 1 (4.7 m) | 7,476 triangles, 74 KB, 26 ms | 14,112 triangles, 139 KB, 9 ms |
14, maxTriangles=4000 | 4,000 triangles, 40 KB, 17 ms |
gzip takes off about 60 %. Through the service, a tile not yet cached takes 25 to 50 ms with delatin and 17 to 30 ms with martini once its source tiles are read; the first tiles of a new area also wait for the source (60 to 170 ms for Mapterhorn).
martini is the default since 2026-11-25: a tile is made three times faster, which is what a viewer waits for while it streams a new area, and twice the triangles is nothing to a GPU (25,000 triangles a tile). delatin (?mesher=delatin) when bytes count more than time: a slow network, a scene kept in memory (half the triangles is half the download and half the memory), a cache served many times. With either, error is the first setting to change: doubling it roughly halves the triangles.
A QGIS project
/qgis.qgz?<a view> is a QGIS project of that view. Every layer of the app is an XYZ layer, stacked as the map stacks them, top of the tree drawn on top, and grouped as the app's panel where that order allows:
| Tree, top to bottom | Layers |
|---|---|
| Overlays | Contours, Plane slicer, Mound candidates, Graticule, Iso-line, each as the app draws it and, unchecked under it, as vector tiles |
| Lighting Effects | Building shadows, Terrain shadows, Phong, Matcap |
| Hillshade | |
| Relief Visualization | Local Dominance, Openness, Sky View Factor, Local Relief Model |
| Terrain Analysis | Principal Components, Neighborhood statistics, Surface derivatives |
| Elevation Hypso | |
| Values (Float32, for analysis) | Unchecked and closed: one raster per mode with values (elevation, slope, aspect, curvature, TRI, TPI, roughness, shape index, blobness, eigenvalue ratio, orientation, LRM, sky view factor, openness, local dominance), read by GDAL from /gdal.xml, in natural units, with a grey ramp over a typical range. For the raster calculator, zonal statistics, profiles, identify |
| Basemap | The view's basemap and overlays as the app draws them (browser engine), the basemap itself when it is a plain XYZ address, Google hybrid |
The layers the view switches on start checked; every layer's address carries the view's settings (terrain source, ramps, opacities, radii) and asks for its own mode only, so checking another one later draws it as the view would have. Raster layers ask for background=none, so checked layers stack as in the map. lat, lng and zoom set the project's extent.
The view is a query in the service's names (terrainSource, modes, imageryUrl) or in the app's own: the query of a share link works as is (terrainSourceA, the show* switches, basemapSourceA, overlayBasemapIds, and a source given by URL with terrainType). That is what the app's Share dialog does when a tile service is set in Settings > Tile Service: Export QGIS project downloads <service>/qgis.qgz?<the link's query>. Without a query the project has every layer unchecked but Google hybrid. node tile-server/qgis-project.mjs http://localhost:3400 out.qgz writes that one without the service. Checked in QGIS 4.2.
A layer's settings are in its address: QGIS edits an XYZ address in the layer's source settings, and has no controls bound to its parameters. Opacity is the exception: each layer's tiles are asked at full opacity and the view's opacity is set on the QGIS layer (Layer Properties > Transparency), where it can be changed. QGIS draws neighbouring XYZ tiles a pixel over each other, so a half-transparent tile showed a line along every tile edge; the shading layers (hillshade, Phong, terrain and building shadows), transparent by design, are therefore asked on the map's background and multiplied over the layers under them (Layer Properties > Symbology > Blending mode). Its vector tile layers take QGIS's default style.
Raster tiles in a map
/terrain-tiles/custom-nl-ahn-dtm/{z}/{x}/{y}.png?modes=slope
/basemap-tiles/wayback/{z}/{x}/{y}.jpg?imageryDate=2020-01-01
/render.jpg?bbox=6.7,45.75,7.0,45.95&width=800&height=600&modes=hillshade,contoursmap.addSource("tv-slope", { type: "raster", tileSize: 256, tiles: ["http://localhost:3400/terrain-tiles/mapterhorn/{z}/{x}/{y}.png?modes=slope"] })Visualization modes (OGC API - Processes)
Each mode is described as a process of OGC API - Processes, Part 1: Core (OGC 18-062r2), with the landing page and conformance of OGC API Common:
| Address | Answers |
|---|---|
/ (with Accept: application/json, or ?f=json) | The landing page: links to the API definition, the docs, /conformance, /processes. A browser is sent to /docs |
/conformance | OGC API Common core, landing page and JSON; Processes' process description and JSON classes |
/processes | Every mode, top of the map first, then basemap; x-tv-groups is the app's panel tree by id; ?expand=true gives every description in full |
/processes/{id} | One mode: inputs (each setting with a JSON Schema and its URL parameter), outputs (image as PNG or JPEG, values as Float32 GeoTIFF for a mode with values, vectorTile for an overlay), links |
An excerpt of /processes/slope:
{
"id": "slope", "version": "1.0.0", "title": "Slope",
"inputs": {
"slopeOpacity": { "minOccurs": 0, "maxOccurs": 1, "schema": { "type": "number", "minimum": 0, "maximum": 1, "default": 1 }, "x-tv-url-param": "slopeOpacity", "x-tv-role": "opacity" },
"slopeSourceMode": { "minOccurs": 0, "maxOccurs": 1, "schema": { "type": "string", "enum": ["plantopo", "client"], "default": "client" }, "x-tv-role": "setting" }
},
"outputs": {
"image": { "schema": { "oneOf": [{ "type": "string", "contentEncoding": "binary", "contentMediaType": "image/png" }, { "contentMediaType": "image/jpeg" }] } },
"values": { "schema": { "oneOf": [{ "contentMediaType": "image/tiff; application=geotiff" }, { "contentMediaType": "image/png" }] }, "x-tv-unit": "degree" }
},
"x-tv-group": ["Terrain Analysis", "Surface derivatives"],
"x-tv-opacity-key": "slopeOpacity", "x-tv-group-opacity-keys": ["terrainAnalysisOpacity"],
"x-tv-stack-rank": 1, "x-tv-values": { "unit": "degree", "range": [0, 60] },
"links": [{ "rel": "http://www.opengis.net/def/rel/ogc/1.0/execute", "href": "…/terrain-tiles/{z}/{x}/{y}.png?modes=slope", "type": "image/png", "templated": true }]
}What the standard has no slot for is an x-tv- property: the panel group (x-tv-group), the form and shading, the stacking rank, the opacity and group opacity parameters, the app's switches, whether the mode has values, their unit and the typical range the QGIS plugin's grey ramp starts with.
Execution. A mode is run by asking for its tiles, not by the standard's POST /processes/{id}/execution and its jobs: a tile is a few milliseconds of work that a map asks hundreds of times, which a job queue would only slow down, and every GIS already reads XYZ tiles. So each description links its tile endpoints with rel http://www.opengis.net/def/rel/ogc/1.0/execute, templated, the inputs going into the query; the execution path answers 501 with the same links; and /conformance claims the process description class, not the Processes core class.
titiler's parameters
A client written for titiler keeps a few of its parameter names, for Web Mercator only. Its tile addresses are not answered (removed on 2026-11-25, see Removed addresses): ask /terrain-tiles/{z}/{x}/{y} for /tiles/WebMercatorQuad/{z}/{x}/{y} and /tilejson.json for /WebMercatorQuad/tilejson.json. Its /bbox/{w},{s},{e},{n}/{width}x{height}.{format} is answered, as /render with that box and size.
| titiler | Here |
|---|---|
url | Read as terrainSource |
algorithm | Read as one name of modes |
tilesize | 256 or 512 |
rescale, colormap_name, bidx, expression, nodata, other tile matrix sets | Not read. The app's own parameters set the ramps |
The API reference (/docs) names these in the description of /terrain-tiles.
Provenance: a STAC Item for each export
Each raster the service answers has a STAC Item: the export's address plus .stac.json, with the same query. The answer names it in a Link header, Link: <…/terrain-tiles/13/4270/2911.tif.stac.json?modes=slope>; rel="describedby"; type="application/geo+json". That covers the value TIFFs and PNGs (/terrain-tiles/{z}/{x}/{y}.tif, /render.tif, /bbox/…/{w}x{h}.tif) and the rendered pictures (/terrain-tiles/….png|jpg, /basemap-tiles/…, /render.png|jpg, /bbox/….png). Vector tiles have none. The item is worked out from the address alone, so asking for it draws nothing, and the caller's API keys are left out of it.
The item is STAC 1.1.0 with the Processing extension v1.2.0:
| Field | Value |
|---|---|
bbox, geometry | The export's footprint: the tile; the box asked for values; for a picture of a box, the whole picture (the box, plus more on two sides when the shapes differ); for a centred viewport, its box without pitch or bearing |
datetime, processing:datetime | When the item was answered (UTC) |
processing:lineage | One sentence: the mode or modes, the terrain source (or the imagery), the parameters |
processing:software | {"terrain-viewer tile-server": "<version of tile-server/package.json>"} |
processing:level | L3 for a map derived from the elevation; left out for the imagery |
processing:expression | {"format": "x-tv-process", "expression": {"process", "processes", "endpoint", "inputs"}}: the process ids (as in /processes) and their inputs as executed |
links | derived_from the source (its /sources/{id} entry and its tile template, or its address; for the imagery, its address or /processes/basemap), related to each /processes/{id} |
assets.data | The export itself, role data (values) or visual (a picture) |
{
"type": "Feature", "stac_version": "1.1.0",
"stac_extensions": ["https://stac-extensions.github.io/processing/v1.2.0/schema.json"],
"id": "tv-terrain-tiles-slope-13-4270-2911",
"bbox": [7.6464844, 46.0732306, 7.6904297, 46.1037088],
"properties": {
"datetime": "2026-11-25T09:00:00Z",
"processing:lineage": "The values of mode slope (before its colour ramp) computed from terrain source mapterhorn by the Terrain Viewer tile service (terrain-tiles, tif), in EPSG:3857, with slopeMaxDegrees=45.",
"processing:software": { "terrain-viewer tile-server": "0.3.0" },
"processing:level": "L3",
"processing:datetime": "2026-11-25T09:00:00Z",
"processing:expression": { "format": "x-tv-process", "expression": { "process": "slope", "processes": ["slope"], "endpoint": "terrain-tiles", "inputs": { "terrainSource": "mapterhorn", "slopeMaxDegrees": "45" } } }
},
"links": [{ "rel": "derived_from", "href": "http://localhost:3400/sources/mapterhorn" }, { "rel": "related", "href": "http://localhost:3400/processes/slope" }],
"assets": { "data": { "href": "http://localhost:3400/terrain-tiles/13/4270/2911.tif?modes=slope&slopeMaxDegrees=45", "type": "image/tiff; application=geotiff", "roles": ["data"] } }
}(The geometry and the self link are left out above.) The tests check every item against the extension's schema, a copy of which is kept in tile-server/schemas/. This is a proof of concept: there is no STAC catalog or collection over the items, and none is written to disk.
What the direct engine draws
The direct engine computes the tile in the server, with no browser. It opens nothing: it rebuilds the map's layer stack from the same URL parameters the app would read, and computes every layer with the app's own code, bundled for Node.
| Layers | How |
|---|---|
| Colour relief, and the 14 computed modes: slope, aspect, TRI, curvature, TPI, LRM, roughness, shape index, blobness, eigen ratio, orientation, sky-view factor, openness, local dominance | The app's tile protocols (lib/*-protocol.ts), coloured with the paint the map computes (lib/layer-paints.ts, lib/mode-relief.ts) and interpolated between the ramp's stops as MapLibre does |
| Hillshade | MapLibre's two shader passes, rewritten in JavaScript line by line, fed with the paint the map computes: the five methods and the app's three multi-light presets |
| Matcap, Phong | The app's live GL layers, its default renderer: their fragment shaders rewritten in JavaScript (the normal of each pixel from the bilinear elevation, Phong's multiply and add passes over the layers below, the camera-relative matcap lookup). With matcapRenderer=raster or phongRenderer=raster, the app's tile protocols, as the app then draws them |
| Cast shadows | The app's tile protocol |
| Contours | maplibre-contour, the app's contour library, with its intervals, widths and colours; on the terrain, or on its local relief model with contourReferenceMode=lrm. The labels are drawn on the picture (elevation and "m" on major lines, Noto Sans bold 10 px with a halo, upright), where MapLibre puts line symbols: per vector tile, every 250 px from where the line enters it, not where it turns more than 45°, and not over an earlier label. Straight, where MapLibre bends the letters along the line. The vector tiles carry ele for a client that places its own |
| Iso-line | At a value: the app's isoband:// vector tiles over the chosen measure (elevation, slope, any computed mode or lighting), the fill and the line, and on slope the cliff teeth, every 28 px from where MapLibre starts them on each tile. Every interval: the contour engine over the measure's tiles |
| Mound detector | The app's tells:// vector tiles, a circle per candidate with the map's radius (fixed, or the measured diameter times tellsScaleMultiplier) and colours (outline, or coloured by blobness, plan curvature, Hessian or LRM) |
| Plane slicer | The colour relief the map draws for it, on the elevation or on the local relief model |
| Graticule | The lines at the app's spacing for the zoom, or graticuleDensity. Its labels sit on the edges of the screen in the app, so a tile has none |
| Dark theme | The black background, and the contour, label and graticule colours that follow the theme |
The layers stack in the map's order (the relief and lighting layers, then iso-line and graticule, mound markers, plane slicer, and the contours on top) over its white or black background, each composited with the app's opacity for it, so any combination of modes is drawn as the map draws it. A colour ramp is read as MapLibre reads it: the stops rounded to the elevation encoding's step and the colours taken from an 8-bit texture. Every URL parameter the app reads for these layers applies: ramps, ranges, inversion, custom ramp stops, radii, light direction, exaggeration, opacities.
Sources
The direct engine reads every source type the app reads, with the app's own readers. What a source's elevation tiles are (template, RGB packing, tile size, zoom range) comes from the function the map uses for its own decoders, terrainTileSpec in lib/terrain-tile-spec.ts, with the app's default settings (the in-browser COG reader on, Terrarium tiles, titiler at titiler.xyz). The readers are the app's protocols, registered in Node through the app's registry (lib/protocol-registry.ts) by tile-server/app-sources.ts:
| Type | Read by |
|---|---|
| Terrarium, Terrain-RGB, custom RGB packing | The tiles fetched and decoded in the server |
| PMTiles | pmtiles://, Range reads of the archive |
| COG | cog:// (geotiff.js), with the elevation colour function the map registers. A COG the in-browser reader refuses, or one pinned to titiler (cogViaTitiler, most of the library's), is read through titiler as in the app |
| VRT | vrt://: the VRT's own index, its files Range-read by geotiff.js and warped by proj4. Also GEM-15, Open Buildings and Meta's canopy height, whose indexes come from the deployed app. A VRT pinned to titiler goes through titiler |
WMS, WCS, ArcGIS exportImage (wms-raw) | float32dem://, one Float32 GeoTIFF request per tile |
| LERC (ArcGIS tiled elevation, Esri World Elevation) | lerc://, Esri's wasm decoder |
| Quantized mesh | quantized-mesh://, the meshes rasterised |
| Difference (nDSM, change) | demdiff:// over its two operands, each read as above |
| TileJSON | The manifest's tile template |
Mapbox, MapTiler and Cesium ion are read with your API key (mapboxKey, maptilerKey, cesiumIonKey); without one neither engine can draw them, and a key the provider refuses gives an error that says so. Not read in the server, so drawn by the browser: a local file, a source whose address is not https (one demo entry of the library), STAC and MosaicJSON entries (none among the terrain sources), and a COG or VRT that does not answer. /sources gives each source its engine, and the reason when it is the browser.
What goes to the browser
3D, tilted, rotated and split views (the camera is the app's); imagery and basemaps; the sky and fog background; the historical mode; a source the server does not read (see Sources). The answer's x-tv-engine-why header names the reason.
Compared with the app
Run on 2026-11-21, the rows with contours, the iso-line teeth and the mound detector again on 2026-11-22: every case below drawn by both engines at the same index, at Matterhorn (z12, 4,000 m of relief) and in Paris (z14, almost flat), as 256 px tiles and as @2x, 196 pairs. The table keeps the worst of the four tiles for each case; times are the median of the four, with the elevation tiles already in memory for the direct engine and a new 2048 px block for each browser tile.
| Case | Largest mean difference (0-255) | Largest share of pixels off by more than 24 | Direct, median | Browser, median |
|---|---|---|---|---|
| hillshade (combined, default) | 0.9 | 0 % | 451 ms | 6290 ms |
| hillshade standard | 2.27 | 0.97 % | 141 ms | 5811 ms |
| hillshade igor | 1.6 | 0 % | 125 ms | 5885 ms |
| hillshade basic, light 200/30 | 0.21 | 0.09 % | 82 ms | 4002 ms |
| hillshade combined, exaggeration 0.6, coloured | 0.65 | 0 % | 122 ms | 5057 ms |
| hillshade multidir-colors | 0.82 | 0 % | 124 ms | 4205 ms |
| hillshade duotone-nw-ne | 0.51 | 0 % | 110 ms | 5075 ms |
| hillshade aspect-multidir | 1.08 | 0 % | 112 ms | 4524 ms |
| colour relief (default) | 0.22 | 0 % | 53 ms | 3931 ms |
| colour relief dem_screen 300-4500, opaque | 0.07 | 0 % | 54 ms | 4555 ms |
| slope | 0.02 | 0 % | 864 ms | 4607 ms |
| slope 0-45 inverted | 0.04 | 0 % | 121 ms | 5509 ms |
| aspect | 0.15 | 0 % | 174 ms | 5589 ms |
| TRI | 0.1 | 0 % | 122 ms | 5216 ms |
| curvature | 0.17 | 0 % | 121 ms | 5423 ms |
| TPI | 0.22 | 0 % | 141 ms | 4948 ms |
| roughness | 0.21 | 0 % | 190 ms | 5446 ms |
| shape index | 5.61 | 3.24 % | 188 ms | 5579 ms |
| blobness | 0.13 | 0 % | 168 ms | 4610 ms |
| eigen ratio | 0.18 | 0 % | 206 ms | 5635 ms |
| orientation | 0.07 | 0 % | 263 ms | 5047 ms |
| LRM | 0.17 | 0 % | 343 ms | 4234 ms |
| LRM radius 32 | 0.2 | 0 % | 366 ms | 4578 ms |
| sky-view factor | 0.06 | 0 % | 855 ms | 5691 ms |
| openness | 0.07 | 0 % | 765 ms | 5597 ms |
| local dominance | 0.09 | 0 % | 1112 ms | 5703 ms |
| contours | 2.13 | 0.97 % | 431 ms | 10951 ms |
| contours 20/100 | 4.5 | 1.87 % | 462 ms | 8984 ms |
| matcap (live renderer in the app) | 1.82 | 0.26 % | 222 ms | 5165 ms |
| matcap, raster renderer | 0.64 | 0 % | 286 ms | 5431 ms |
| phong (live renderer in the app) | 1.72 | 0.15 % | 211 ms | 4952 ms |
| phong, raster renderer | 0.26 | 0 % | 225 ms | 4848 ms |
| cast shadows | 0 | 0 % | 228 ms | 4094 ms |
| cast shadows, sun at 15 degrees | 0 | 0 % | 217 ms | 4140 ms |
| phong, rim light 0.6, two lights | 1.36 | 0.14 % | 239 ms | 5138 ms |
| hillshade + colour relief + contours | 1.19 | 0.14 % | 534 ms | 7096 ms |
| slope + hillshade | 0.9 | 0 % | 199 ms | 5607 ms |
| LRM + sky-view factor + hillshade | 1 | 0 % | 977 ms | 5699 ms |
| contours of the local relief model | 6.4 | 1.84 % | 1421 ms | 9722 ms |
| iso-line, slope 30 degrees | 1.88 | 2.36 % | 408 ms | 5824 ms |
| iso-line, slope 30 with fill and cliff teeth | 5.21 | 7.6 % | 1802 ms | 7714 ms |
| iso-line, slope every 10 degrees | 1.91 | 2.13 % | 355 ms | 4419 ms |
| iso-line, elevation every 50 m | 1.54 | 1.6 % | 136 ms | 4070 ms |
| graticules | 0.93 | 0 % | 127 ms | 5543 ms |
| plane slicer at 2800 m | 0.53 | 0 % | 135 ms | 5128 ms |
| plane slicer, local relief above 0 | 0.78 | 0 % | 184 ms | 5512 ms |
| mound detector | 2.04 | 1.02 % | 917 ms | 5964 ms |
| dark theme, hillshade + contours | 1.91 | 0.48 % | 264 ms | 9286 ms |
What the remaining differences are:
- Contour labels are not measured: every case with contours is compared with
showContourLabels=false. The labels are placed every 250 px from where a line enters each tile, as MapLibre does, but without its collision over the whole block or its letters bent along the line. What is left is the anti-aliasing of thin lines where they crowd, most at the local relief model. - Shape index: in Paris, every difference is a pixel at exactly +1 (a dome), drawn transparent by the app and dark red by the direct engine. That is an app bug, fixed in this release (see the changelog): MapLibre rounds a ramp's stops to the elevation's encoding, so the last pair of a discrete ramp became one value and the shader divided 0 by 0. Once the fix is deployed both engines draw it dark red.
- Iso-line cliff teeth: placed as MapLibre places them; a few teeth are kept on one side only near the ends of short lines.
- Mound markers: the same circles; MapLibre's circle shader smooths a ring's edges inside it, which the server's rings now follow (half a pixel inward), from 11 to 2.
- Hillshade on flat ground: the gradient is kept in 8 bits, as in MapLibre's own texture, and a tiny slope rounds one way or the other.
- Matcap and Phong: compared with the app's default live renderer, and with its raster renderer when
matcapRenderer=rasterorphongRenderer=raster.
Sources other than Mapterhorn compare the same way: a COG within 0.4 to 2.5, a VRT 0.2 to 0.8, a WMS 0.02 to 1.3, LERC 0.02 to 1.7, quantized mesh 0.01 to 0.5 (hillshade, colour relief and slope). Where a source has holes, the direct engine leaves them transparent while the map draws them at the fill height titiler gives them (0 m), so a GEM-15 hole or the ground under a building in a nDSM differs. Both read their sources from the same entries (lib/source-schema.ts).
node tile-server/compare-engines.mjs <service> runs the comparison again and writes the table and, for each case, the two tiles side by side with their difference.
How the browser draws a tile, and how fast
The browser engine does not compute a tile: the app draws it. For a tile, the app is opened on the 2048 px block that holds it (8 by 8 tiles of 256 px), the picture is cut into tiles, and all of them are kept a week on disk (/data/tiles in the image).
Measured on a laptop on 2026-11-21:
| Time | |
|---|---|
| Direct tile, one mode | 0.03 to 0.4 s once the elevation tiles are in memory; up to 2.5 s for local dominance or a first tile |
| Direct viewport, 900 by 600, three modes (MCP picture) | 1.8 s |
| Browser, first tile of a block, Chrome with a graphics card | 3 to 9 s |
| Browser, first tile of a block, in the container (no graphics card) | 10 s |
| Browser, its 63 neighbours, and any tile asked again within a week | under 0.1 s |
| Browser viewport, 600 by 400, 3D slope | 3 s |
An imagery tile from the browser engine equals the provider's own tile of the same index (mean difference 1.7 on 255, the JPEG compression), and joins its neighbour without a seam.
The browser engine suits a few views, a cache filled in advance, or pictures of 3D views for a report or an assistant; not a busy map. The direct engine can serve a live map.
Settings
| Variable | Meaning | Default |
|---|---|---|
PORT | The port | 3400 |
TV_HOST | The interface to listen on; 127.0.0.1 keeps the service to this machine (the QGIS plugin's bundled one) | every interface |
CHROME_PATH | A Chromium for the browser engine | the installed Chrome, else Edge; with neither, the views needing the browser answer 501 |
TV_NO_BROWSER | 1: no browser engine, never look for Chrome or Edge; the views needing it answer 501 (the copies in the QGIS plugin and the desktop app, which ship without playwright-core; without playwright-core installed it is the same) | off |
TV_EXIT_WITH_STDIN | 1: stop when the standard input closes, i.e. when the process that started the service is gone (the QGIS plugin, the desktop app) | off |
TV_BASE_URL | The app to render | https://terrain-viewer.iconem.com/ |
TILE_CACHE_DIR | Where tiles and pictures are kept a week | /data/tiles in the image |
TV_RENDER_CONCURRENCY | Pages rendered at the same time; each is a whole app | 2 |
TV_DIRECT_WORKERS | Worker threads of the direct engine, one tile each; 0 draws in the server's thread, TV_DIRECT_CONCURRENCY (4) tiles at a time | the cores minus one, at most 8 |
TV_PROTOCOL_CACHE_MB | Memory each worker keeps for the relief modes' computed source tiles (slope, sky view factor, shadows…), so the 256 px tiles within one 512 px source tile and the neighbours cost one computation | 48 |
TV_QUEUE_TIMEOUT | Seconds a request may wait for its turn before a 503 with Retry-After | 30 |
TV_RENDER_TIMEOUT | Seconds before a request not yet answered gets a 504 | 90 |
TV_ALLOWED_HOSTS | Host names accepted in the Host header, comma-separated | any |
TV_MAPBOX_KEY, TV_MAPTILER_KEY, TV_CESIUM_ION_KEY | The operator's keys, used when a request gives none: anyone who can reach the service then uses them | none |
EARTHDATA_TOKEN | An Earthdata user token, for /proxy/earthdata. Read from the environment, else from the repository's .env (that key only) | none |
TV_PROXY_MAX_RANGE, TV_PROXY_MAX_FULL | Largest byte range, and largest whole file, the proxy passes | 16 MiB, 64 MiB |
TV_PROXY_CONCURRENCY, TV_PROXY_TIMEOUT | Upstream reads at a time (eight times as many wait, then 503), and milliseconds before a 504 | 16, 60000 |
A request whose client has gone (QGIS cancels the tiles it no longer shows while you pan) is dropped before its work starts, so several QGIS windows no longer pile up work nobody waits for. The direct engine draws in worker threads (tile-server/direct-pool.mjs): a sky view factor or openness tile keeps a thread busy for seconds, and on the server's own thread it held up every other request, /health included. A tile whose request is cancelled or reaches TV_RENDER_TIMEOUT has its worker ended, which stops the computation, and a fresh worker takes its place. Each worker keeps its own elevation cache and its own cache of computed relief tiles (TV_PROTOCOL_CACHE_MB), so memory grows with their number. /health reports each engine's running, waiting and limit, and for the direct engine workers, busy and replaced (workers ended since the start). The root address / redirects to the Scalar page /docs; with Accept: application/json it answers the index of addresses.
What a relief tile costs. The relief modes (slope, curvature, sky view factor, openness, shadows…) are computed by the app's tile protocols on the source's own tiles, often 512 px, then resampled to the 256 px tile asked for. Only the source tiles whose pixels the tile reads are computed (until 2026-11-25 the resampling margin reached into the neighbours, four 512 px computations for every 256 px tile), and each worker keeps the computed tiles, so the other three 256 px tiles of a source tile, and the same mode's values (.tif), come from memory. Measured on a laptop (16 z12 tiles around Mont Blanc on Mapterhorn, elevation cached, one thread, node tile-server/bench-direct.mjs), ms per tile:
| Mode | Before | A tile whose source tile is new | Tiles of a 4 × 4 block |
|---|---|---|---|
| Hillshade | 37 | 25 to 35 | 25 to 35 |
| Slope | 61 to 76 | 21 | 11 to 13 |
| Shadows (r = 256 px, sun 15°) | 82 to 100 | 23 to 32 | 7 to 9 |
| Sky view factor, r = 8 | 537 to 546 | 150 to 165 | 15 to 20 |
| Sky view factor, r = 32 | 1281 to 1352 | 325 to 360 | 15 to 16 |
Over HTTP with 8 workers, the same 16 tiles 8 at a time take 11 ms a tile for the hillshade, 14 for shadows, 29 for the sky view factor at r = 8 and 51 at r = 32 (214 and 466 before). The outputs are the same pixels as before (bench-direct.mjs --compare on the 112 tiles of its cases).
The browser in the container reads any address given as a source: keep the service away from a private network, or behind a proxy that restricts who can call it. It has no sign-in.
The code is tile-server/server.mjs. The direct engine is tile-server/direct.mjs, on the elevation reader tile-server/dem.mjs, which the MCP server's elevation and export_geotiff tools use too. The browser engine is tile-server/render.mjs, shared with the MCP server's pictures. The tile service does not know the MCP server; the MCP server (mcp/) imports the link builder, the engines and the elevation reader from tile-server/. With TV_RENDER_URL set to the tile service's address, the MCP server asks it for its pictures in place of rendering them, which is how mcp/docker-compose.yml wires the two. The MCP server's elevation tools need no browser any more, and its pictures of flat views are drawn by the direct engine in the server itself; only 3D, imagery and the other browser layers need a browser, its own or the tile service's.
Not yet run on a server.
CORS proxy for NASA G-LiHT
Two NASA hosts hold G-LiHT and neither lets a web page read it: glihtdata.gsfc.nasa.gov sends no CORS header, and LP DAAC's Earthdata Cloud copy wants an Earthdata login and refuses the preflight. The service passes a short list of their files through (tile-server/proxy.mjs, tested by proxy-test.mjs), see NASA G-LiHT for what they hold:
| Address | Upstream | Allowed |
|---|---|---|
/proxy/gliht/files/G-LiHT/<campaign>/lidar/kml/… | https://glihtdata.gsfc.nasa.gov/files/G-LiHT/… | .kmz under lidar/kml/ (and lidar/geotiff/ archives, for scripts): no index, no listing, nothing else of the host |
/proxy/earthdata/lp-prod-protected/GL….001/<granule>/<file> | https://data.lpdaac.earthdatacloud.nasa.gov/… with Authorization: Bearer $EARTHDATA_TOKEN | the G-LiHT DTM, DSM and CHM collections (GLDTMT, GLDSMT, GLCHMT, GLDTMK, GLCHMK): .tif, .kmz, browse .png, .cmr.xml |
/proxy/earthdata/vrt/<same path>.tif | a VRT the service writes over that GeoTIFF | as above |
- Range passes through: one range per request, at most
TV_PROXY_MAX_RANGE; a whole file only underTV_PROXY_MAX_FULL(a 286 MB tar.gz answers413). Answers carryAccess-Control-Allow-Origin: *and exposeContent-Range,Accept-Ranges,ETag;OPTIONSanswers the preflight aRangeheader triggers. GLiHT answers arecache-control: public, max-age=604800(the files have not changed since 2017), Earthdata onesprivate, max-age=3600. - The token stays on the server: the browser never sees it. Earthdata answers a token holder with a redirect to a signed S3 address; the service follows it without the token (S3 never receives it), keeps the signed address 30 minutes so the next Range reads skip the login hop, and turns a redirect to the login page into a
401that says what to fix. - The VRT: LP DAAC's GeoTIFFs are the files NASA ships gzipped, uncompressed: Float32, one strip per row, no overviews, UTM. The VRT names the file 512 px at a time, so the app's in-browser
vrt://reader derives a minimum zoom at which a tile reads a few windows (about z16), instead of the whole file at z12. Add it as a custom terrain source, type VRT. - In the app: Settings > G-LiHT address =
<service>/proxy/gliht(a link fills it from the Tile Service field).
Getting the Earthdata token
- Sign in at urs.earthdata.nasa.gov (create the free account if needed).
- Generate Token (top menu), then Generate Token again: a token valid 60 days. Copy it.
- Once per account, approve LP DAAC's data: download any G-LiHT file once from Earthdata Search while signed in, and accept the prompt if there is one.
- Add one line to the main checkout's
.env(C:/Dev/Iconem/terrain-viewer/.env, gitignored), then copy it to a worktree as usual:EARTHDATA_TOKEN=<the token>. In Docker, pass it as an environment variable (-e EARTHDATA_TOKEN=…), never in the image. - Check:
curl -r 0-7 http://localhost:3400/proxy/earthdata/lp-prod-protected/GLDTMT.001/GLDTMT_Kuiic1_Apr2013_DTM/GLDTMT_Kuiic1_Apr2013_DTM.tif | xxdshowsII*(a TIFF). A401says the token is missing, expired (60 days) or refused.
On a public server
The service has no sign-in, and one sky view factor tile keeps a worker busy for seconds: open to the internet, a few clients can saturate it, and anyone can make the container fetch any address (the operator's keys too, if set). Its own protections are per process: the work limits (TV_RENDER_CONCURRENCY, TV_DIRECT_WORKERS), TV_QUEUE_TIMEOUT, TV_RENDER_TIMEOUT, cancelled requests dropped, TV_ALLOWED_HOSTS. What it needs in front, as a reverse proxy (Traefik middlewares here; nginx or Caddy have the same):
| Need | Traefik middleware |
|---|---|
| Requests per client over time | rateLimit (average, burst, period; sourceCriterion.ipStrategy behind another proxy or a CDN) |
| Requests running at once per client | inFlightReq (amount) |
| Who may call it at all | ipAllowList (an office, a VPN), or basicAuth / forwardAuth (an identity provider, an API key check) |
| Sizes and slow clients | buffering (maxRequestBodyBytes), and the entry point's respondingTimeouts |
| Repeats | a cache in front (the tiles are cache-control: public, max-age=86400): Traefik has none built in, so a CDN or nginx proxy_cache |
The /proxy/ routes need the same and one more rule: /proxy/earthdata hands out data that Earthdata serves only to a signed-in account, with the operator's token, to anyone who reaches it. Give it a router of its own with basicAuth or ipAllowList, and a rateLimit on /proxy/gliht so the service is not a free mirror of NASA's host; inFlightReq with amount: 8 per client is plenty for the app's Range reads. With Docker labels:
- traefik.http.routers.tv-earthdata.rule=Host(`tiles.example.org`) && PathPrefix(`/proxy/earthdata`)
- traefik.http.routers.tv-earthdata.middlewares=tv-auth,tv-inflight
- traefik.http.routers.tv-gliht.rule=Host(`tiles.example.org`) && PathPrefix(`/proxy/gliht`)
- traefik.http.routers.tv-gliht.middlewares=tv-ratelimit,tv-inflight
- traefik.http.middlewares.tv-auth.basicauth.users=me:$$apr1$$... # htpasswd -nb me <password>
- traefik.http.middlewares.tv-ratelimit.ratelimit.average=50
- traefik.http.middlewares.tv-ratelimit.ratelimit.burst=200
- traefik.http.middlewares.tv-inflight.inflightreq.amount=8A browser cannot send basic-auth credentials with the app's Range reads unless they are in the address (https://me:pw@tiles.example.org/proxy/…, which Chrome refuses for subresources): for the Earthdata route an ipAllowList (your office, a VPN) is the practical choice, or keep the route on localhost.
QGIS's XYZ layers can send a header (Authentication > API header) or a key in the address, so a forwardAuth that checks either one keeps QGIS working. Keep the container off a private network: the sources it reads are any address a request gives.
Related work and references
Specifications the service follows, and other services and libraries that serve terrain the same way, with how each relates to this one (links checked 2026-11-25):
- OGC API - Processes, Part 1: Core (OGC 18-062r2):
/processesand/processes/{id}describe each mode as a process, with its inputs as JSON Schema. A process is run by asking for its tiles, not by a POST to/execution, so the service declares the process description classes but not the core class. - OGC API - Tiles, Part 1: Core (OGC 20-057) and OGC Two Dimensional Tile Matrix Set (OGC 17-083r4): the service's tiles are on the grid the tile matrix set standard calls
WebMercatorQuad, at plain{z}/{x}/{y}addresses. It does not answer OGC API - Tiles'/tiles/{tileMatrixSetId}paths, and titiler's addresses of that form were removed (see Removed addresses). - quantized-mesh-1.0 (CesiumGS): the format of
/quantized-mesh/{source}/…, with itslayer.json, the edge lists and theoctvertexnormalsextension; skirts are left to the client, as the specification says. - Cesium World Terrain (Cesium ion): global terrain in the same format, behind an ion token. The service makes that format from any source the app reads instead; the app also reads Cesium World Terrain itself, measured on Quantized mesh protocol.
- mapbox/martini (with an Observable notebook on how it works) and mapbox/delatin (a port of hmm): the two meshers of
tile-server/quantized-mesh.mjs, chosen withmesher=, compared in Martini or delatin. - quantized-mesh-encoder (Python): encodes a mesh made by pydelatin or pymartini as quantized-mesh, served on demand by dem-tiler. The same chain as the service's, in Python rather than Node.
- Re:Earth Terrain (terrain.reearth.land): Mapterhorn with the EGM2008 geoid added per request, served from a Cloudflare Worker as quantized-mesh, Terrain-RGB and Terrarium. Its heights are on the WGS84 ellipsoid, as Cesium's globe expects; the service writes a source's heights unchanged, so its Mapterhorn mesh stays above mean sea level. Its Terrarium tiles are a terrain source of the app's library (Global - Re:Earth Terrain - Terrarium (ellipsoid)).
- Terrarium (Tilezen's format description, the AWS Terrain Tiles) and Mapbox Terrain-RGB: the two RGB packings of heights the service reads, and writes for computed values with
encoding=terrariumorterrainrgb. - TiTiler (Development Seed): dynamic tiles from COGs and STAC, with algorithms such as hillshade, slope and contours. The service keeps a few of its parameter names and its
/bboxaddress (see titiler's parameters), and the direct engine reads COGs pinned to titiler through it, as the app does. - TileJSON and STAC:
/tilejson.jsonand the quantized-meshlayer.json(TileJSON 2.1.0) describe the tile sets; each export's.stac.jsonis a STAC Item (see Provenance).
Papers:
- W. Evans, D. Kirkpatrick, G. Townsend, Right-triangulated irregular networks, Algorithmica 30(2), 2001. The RTIN hierarchy of right triangles split in halves over a 2^k + 1 grid that martini builds, hence its 257 × 257 grid per tile.
- M. Garland, P. S. Heckbert, Fast Polygonal Approximation of Terrains and Height Fields, Carnegie Mellon University technical report CMU-CS-95-181, 1995. Greedy insertion of the worst-fitting point into a Delaunay triangulation until the error is met, the method delatin implements. Adding points worst first is what lets
maxTrianglesstop a tile early with its largest errors already fixed, and martini's fixed right-triangle splits need about twice the triangles for the same error.
Reference
Every address, parameter and answer: the API reference, a page of its own over the full width, as the service's own /docs shows it. Its Test request calls http://localhost:3400, so it answers when the service runs on your computer.
The document is written by tile-server/openapi.mjs; node tile-server/openapi.mjs rewrites the docs' copy, docs/public/tile-service-openapi.json. The docs build runs it before next build, and tile-server's tests fail when the tracked copy is stale.
URL as an API (Scalar)
The viewer's URL described as an OpenAPI document, browsed with Scalar — every parameter with the right control for its type
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.