Compare commits

..

2 commits
v0.3.2 ... main

Author SHA1 Message Date
9962a6932d added export gpx 2026-08-03 20:14:22 +01:00
fff8a8382b extend more info timeout to 30s 2026-08-03 14:47:33 +01:00
3 changed files with 24 additions and 10 deletions

2
Cargo.lock generated
View file

@ -1590,7 +1590,7 @@ dependencies = [
[[package]]
name = "rs_maps"
version = "0.3.2"
version = "0.3.4"
dependencies = [
"anyhow",
"argon2",

View file

@ -1,7 +1,7 @@
# Cargo.toml
[package]
name = "rs_maps"
version = "0.3.2"
version = "0.3.4"
edition = "2021"
[dependencies]

View file

@ -36,9 +36,10 @@ const OVERPASS_ENDPOINTS = [
'https://overpass.private.coffee/api/interpreter',
];
// Past this, move on to the next mirror. A single-object lookup that hasn't
// answered in 8s isn't going to.
const OVERPASS_TIMEOUT_MS = 8000;
// Overpass queues requests when busy — a trivial single-object lookup has been
// observed taking over a minute before returning a perfectly good 200. 30s is
// the most that's reasonable to make someone wait; past that, give up quietly.
const OVERPASS_TIMEOUT_MS = 30000;
const COLOURS = ['#4E9C6B', '#D2467F', '#E2A93C', '#4E8FC9', '#B07BD4', '#D3574B'];
const DEFAULT_COLOUR = COLOURS[0];
@ -705,7 +706,9 @@ async function fetchOsmTags(osmType, osmId) {
const short = OSM_SHORT[osmType];
if (!short) return null;
const query = `[out:json][timeout:10];${short}(${osmId});out tags;`;
// Server-side budget matched to ours, so it sheds the request rather than
// holding it in a queue we've already stopped waiting on.
const query = `[out:json][timeout:30];${short}(${osmId});out tags;`;
let lastError = null;
for (const endpoint of OVERPASS_ENDPOINTS) {
@ -907,12 +910,11 @@ function showSearchHit(hit) {
slot.replaceChildren(node);
more.remove();
} catch {
// Overpass being busy is routine and not worth interrupting anyone
// over. The button simply comes back so it can be pressed again;
// the reason stays in the console.
more.disabled = false;
more.textContent = 'More details';
// Every mirror was busy or unreachable. This is a load problem at
// their end, not missing data — worth saying so, since retrying in a
// minute usually works.
toast('OpenStreetMap details are busy — try again shortly', true);
}
popup.update(); // re-measure after the content grew
});
@ -1108,6 +1110,18 @@ async function loadGpxList() {
edit.addEventListener('click', () => editRoute(f.name));
li.appendChild(edit);
// A plain anchor rather than a fetch-and-blob: same-origin navigation
// carries the session cookie, and the browser handles the save dialog,
// resumability and large files without any of it passing through JS.
const download = document.createElement('a');
download.className = 'link';
download.textContent = 'Download';
download.href = 'api/gpx/file/' + encodeURIComponent(f.name);
// Without an explicit filename the browser would name it after the URL's
// last segment, which is percent-encoded.
download.download = f.name;
li.appendChild(download);
list.appendChild(li);
});
}