Add the Eastern Sierra High Route and three OpenStreetMap tracks
Mirror to forge / mirror (push) Canceled after 0s
Validate / validate (push) Canceled after 0s
Validate / site (push) Canceled after 0s
Validate / deploy (push) Canceled after 0s

The Eastern Sierra High Route (Dan Stenziano, ESHR) is a sold route, so
the record has no track.

Thames Valley, Grand Valley and Nepisiguit Mi'gmaq now have tracks from
OpenStreetMap, with elevation. The Boreal Trail does not: OpenStreetMap
holds only three short pieces of it, and its record now says so.

osm_track.py tries a third Overpass server, and tries every server once
before it waits, so a dead one no longer costs minutes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-15 09:38:21 -07:00
1 parent 1f7edb91ab
commit 540a3220be
25 files changed
+235 -105

No files matched your search

+11 -8
View File
@@ -45,11 +45,12 @@ import urllib.request
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ENDPOINTS = ["https://overpass-api.de/api/interpreter",
"https://overpass.openstreetmap.fr/api/interpreter",
"https://overpass.kumi.systems/api/interpreter"]
USER_AGENT = "osm-track-fetch/1.0 (python-urllib)"
TIMEOUT_S = 300
RETRY_STATUS = (429, 502, 503, 504)
RETRY_WAITS_S = (10, 30, 60) # per endpoint, between tries
RETRY_WAITS_S = (10, 30, 60) # between rounds of all endpoints
JOIN_GAP_M = 100.0 # same distance as tools/elevation.py
EARTH_R = 6371008.8 # metres; same as tools/elevation.py
@@ -152,8 +153,10 @@ def fetch(relation_id, opener=urllib.request.urlopen, sleep=time.sleep,
"""Overpass JSON for the relation and everything below it. One request at a time."""
body = urllib.parse.urlencode({"data": query_for(relation_id)}).encode()
last = None
for url in endpoints:
for attempt in range(len(RETRY_WAITS_S) + 1):
# Each round tries every endpoint once, so a dead server costs one failed
# request, not a run of waits, before the next one is tried.
for rnd in range(len(RETRY_WAITS_S) + 1):
for url in endpoints:
req = urllib.request.Request(url, data=body, headers={
"User-Agent": USER_AGENT, "Accept": "application/json"})
try:
@@ -165,11 +168,11 @@ def fetch(relation_id, opener=urllib.request.urlopen, sleep=time.sleep,
raise TrackError(f"Overpass refused the request ({last})") from e
except (urllib.error.URLError, TimeoutError, OSError, ValueError) as e:
last = f"{url}: {e}"
if attempt < len(RETRY_WAITS_S):
wait = RETRY_WAITS_S[attempt]
print(f" {last}; trying again in {wait} s", file=sys.stderr)
sleep(wait)
print(f" giving up on {url}", file=sys.stderr)
print(f" {last}", file=sys.stderr)
if rnd < len(RETRY_WAITS_S):
wait = RETRY_WAITS_S[rnd]
print(f" trying all again in {wait} s", file=sys.stderr)
sleep(wait)
raise TrackError(f"Overpass did not answer ({last})")
+15 -4
View File
@@ -243,23 +243,34 @@ class RunTests(unittest.TestCase):
class FetchTests(unittest.TestCase):
def test_retry_then_mirror(self):
def test_next_endpoint_before_any_wait(self):
calls, sleeps = [], []
def opener(req, timeout):
calls.append((req.full_url, req.get_header("User-agent"), timeout))
if len(calls) <= 5:
if len(calls) <= 4:
code = 429 if len(calls) % 2 else 504
raise urllib.error.HTTPError(req.full_url, code, "busy", {}, None)
return io.BytesIO(b'{"elements": []}')
out = T.fetch(1, opener=opener, sleep=sleeps.append)
self.assertEqual(out, {"elements": []})
self.assertEqual(calls[0][0], T.ENDPOINTS[0])
n = len(T.ENDPOINTS)
self.assertEqual([c[0] for c in calls[:n]], T.ENDPOINTS)
self.assertEqual(calls[4][0], T.ENDPOINTS[1])
self.assertEqual(sleeps, [10, 30, 60, 10])
self.assertEqual(sleeps, [10]) # only one wait: after a full round
self.assertEqual(calls[0][1], T.USER_AGENT)
self.assertTrue(calls[0][2])
self.assertIn("overpass.openstreetmap.fr", " ".join(T.ENDPOINTS))
def test_gives_up_after_all_rounds(self):
sleeps = []
def opener(req, timeout):
raise urllib.error.HTTPError(req.full_url, 502, "bad", {}, None)
with self.assertRaises(T.TrackError):
T.fetch(1, opener=opener, sleep=sleeps.append)
self.assertEqual(sleeps, list(T.RETRY_WAITS_S))
def test_other_error_stops(self):
def opener(req, timeout):