Dashboard: altitude (gnss.alt, the terrain's while simulating), the car tilted by the terrain's slope while simulating; free look while following (the map moved by hand pauses the follow, "Back to the position" or 15 s resumes it); overlays and shown library files remembered per device (localStorage), back after a reload once the offline checks are in
CI / check (push) Successful in 24s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-01 00:15:08 +01:00
1 parent 8c999919b8
commit 12b4ac6725
9 files changed
+199 -19

No files matched your search

+18 -6
View File
@@ -63,12 +63,24 @@ function fetchTile(z, x, y, offlineAvailable) {
// -> Promise<number|null> — null on a fetch/decode failure, or a point
// falling outside a partial offline extract's zoom range.
export async function elevationAt(lng, lat, offlineAvailable) {
const { tileX, tileY, fracX, fracY } = lngLatToTile(lng, lat, DEM_ZOOM);
const tile = await fetchTile(DEM_ZOOM, tileX, tileY, offlineAvailable);
// smooth: bilinear between the four pixels around the point (within the
// tile) instead of the nearest one — for slopes over a few meters, where
// nearest-pixel steps would read as 0° then a jump.
export async function elevationAt(lng, lat, offlineAvailable, { zoom = DEM_ZOOM, smooth = false } = {}) {
const { tileX, tileY, fracX, fracY } = lngLatToTile(lng, lat, zoom);
const tile = await fetchTile(zoom, tileX, tileY, offlineAvailable);
if (!tile) return null;
const px = Math.min(tile.size - 1, Math.floor(fracX * tile.size));
const py = Math.min(tile.size - 1, Math.floor(fracY * tile.size));
return tile.elevations[py * tile.size + px];
const { elevations: e, size } = tile;
if (!smooth) {
const px = Math.min(size - 1, Math.floor(fracX * size));
const py = Math.min(size - 1, Math.floor(fracY * size));
return e[py * size + px];
}
const x = Math.min(size - 1.001, Math.max(0, fracX * size - 0.5));
const y = Math.min(size - 1.001, Math.max(0, fracY * size - 0.5));
const [x0, y0] = [Math.floor(x), Math.floor(y)];
const [tx, ty] = [x - x0, y - y0];
const at = (i, j) => e[(y0 + j) * size + x0 + i];
return (at(0, 0) * (1 - tx) + at(1, 0) * tx) * (1 - ty) + (at(0, 1) * (1 - tx) + at(1, 1) * tx) * ty;
}