Skip to main content

Module elevation

Module elevation 

Source
Expand description

A launch site’s elevation (height above sea level) from Open-Meteo’s elevation API.

Open-Meteo’s elevation API (api.open-meteo.com/v1/elevation) answers the height at up to MAX_PLACES places in one request, as {"elevation":[1400.0]}, one number per place in the order asked. Its data is the Copernicus DEM GLO-90 (2021 release), a digital elevation model on a grid 3 arc-seconds apart in latitude, about 93 m; in longitude its spacing narrows from 93 m at the equator to 60 m at 50°, then widens in steps (the product handbook, issue 5.0, Table 3, p. 15). It is a surface model: its heights include buildings and vegetation, so over a tree line or buildings they sit above the bare ground. Its heights are above the EGM2008 geoid (mean sea level), not the WGS 84 ellipsoid (§1.2.1, p. 13): a site’s ellipsoidal height is h = H + N, with N the geoid undulation there, which hpr has no model for (geodesy notes). The ocean has no tiles and reads 0 m.

An ElevationRequest names the places; parse reads the answer, refusing one with the wrong number of heights, a height that is not a number, or a height outside HEIGHT_RANGE_M. fetch asks a Client for the URL, so the answer comes from the cache when it can, and offline from the cache only; an answer that doesn’t parse is never cached. The cache key is the whole request: the same places, in the same order. The URL writes each coordinate to 5 decimals (about 1 m), so a place given to 8 decimals or fewer and rebuilt from radians finds its cached answer. The ground doesn’t move, so a copy stays fresh for TTL_S, a year. Show ATTRIBUTION (it is on every Fetched) wherever the height is shown.

How far to trust it: a height is the answer’s number, unchanged (tests/elevation.rs). The recorded heights are whole meters; Open-Meteo doesn’t document its rounding. The handbook states the DEM’s absolute vertical accuracy as under 4 m (90% linear error), a global mean outside Antarctica and Greenland (Table 1, p. 10); in 184 of the 16,363 geotiles there, each about a degree across (1.1%; the table’s 0.9% is of all tiles), it is over 10 m (Table 12, p. 31). Nothing here measures it. The guide page says more.

use hpr_net::elevation::{self, Place};

// An answer recorded for Spaceport America's launch area, 32.99° N, 106.97° W.
let body = include_bytes!("../tests/fixtures/replay/open-meteo-elevation.json");
let spaceport = Place::new(32.99, -106.97);
let heights = elevation::parse(body, &[spaceport])?;
assert_eq!((heights[0].place, heights[0].height_msl_m), (spaceport, 1400.0));

Structs§

Elevation
A place’s height, as the elevation API answers it.
ElevationRequest
What to ask Open-Meteo’s elevation API for: one place or up to MAX_PLACES.
Place
A place on the ground.

Enums§

ElevationError
Why an elevation request or answer was refused.

Constants§

ATTRIBUTION
The credit Open-Meteo’s license (CC BY 4.0) asks for: itself, and the Copernicus programme whose DEM it serves, in the DEM license’s words.
ENDPOINT
Open-Meteo’s elevation endpoint.
HEIGHT_RANGE_M
The heights parse accepts, m above mean sea level. The lowest land, by the Dead Sea, lies a little over 400 m below sea level, and the highest, Everest’s summit, 8,849 m above it; the margins leave room for the DEM’s own errors. A height outside them is a broken answer, such as a 16-bit no-data value.
MAX_PLACES
The most places Open-Meteo answers in one request.
TTL_S
How long a cached answer counts as fresh, s: a year. The model behind it changes with a new DEM release, years apart.

Functions§

fetch
Fetches request through client and reads each place’s height above mean sea level.
parse
Reads an answer of the elevation API for places: each place’s height, m above mean sea level (the EGM2008 geoid), in the order asked.