From 25ed63ff3b69e5b8ae781b7bf0e23c1377b7a7e3 Mon Sep 17 00:00:00 2001 From: pepperstm Date: Thu, 12 Nov 2026 09:26:59 +0000 Subject: [PATCH 1/2] Add Herne Hill Velodrome as a shared route, both ways round herne-hill-450: the 450 m outdoor track at Herne Hill, London, flat and closed, ridden anticlockwise as in track racing. herne-hill-450-clockwise is the same track and start/finish line the other way round, as a route of its own so riders going opposite ways are never on the same route. The GPX tracks are an oval at the real location, with its centre, direction and bend radius fitted to the track's outline in OpenStreetMap, so apps that build their world from a GPS track can draw the real surroundings. --- routes/herne-hill-450-clockwise.gpx | 133 +++++++++++++++++++++++++++ routes/herne-hill-450-clockwise.json | 7 ++ routes/herne-hill-450.gpx | 133 +++++++++++++++++++++++++++ routes/herne-hill-450.json | 7 ++ tools/herne_hill_gpx.py | 131 ++++++++++++++++++++++++++ 5 files changed, 411 insertions(+) create mode 100644 routes/herne-hill-450-clockwise.gpx create mode 100644 routes/herne-hill-450-clockwise.json create mode 100644 routes/herne-hill-450.gpx create mode 100644 routes/herne-hill-450.json create mode 100644 tools/herne_hill_gpx.py diff --git a/routes/herne-hill-450-clockwise.gpx b/routes/herne-hill-450-clockwise.gpx new file mode 100644 index 0000000..ddc077e --- /dev/null +++ b/routes/herne-hill-450-clockwise.gpx @@ -0,0 +1,133 @@ + + + + Herne Hill Velodrome (clockwise) + OpenBikeNet shared route herne-hill-450-clockwise: the 450 m outdoor track at Herne Hill, London, ridden clockwise. Centre, direction and bend radius fitted to OpenStreetMap (© OpenStreetMap contributors). + + herne-hill-450-clockwise + + + + Herne Hill Velodrome (clockwise) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/routes/herne-hill-450-clockwise.json b/routes/herne-hill-450-clockwise.json new file mode 100644 index 0000000..765696a --- /dev/null +++ b/routes/herne-hill-450-clockwise.json @@ -0,0 +1,7 @@ +{ + "id": "herne-hill-450-clockwise", + "name": "Herne Hill Velodrome (clockwise)", + "length": 450, + "loop": true, + "profile": [[0, 0], [450, 0]] +} diff --git a/routes/herne-hill-450.gpx b/routes/herne-hill-450.gpx new file mode 100644 index 0000000..4490387 --- /dev/null +++ b/routes/herne-hill-450.gpx @@ -0,0 +1,133 @@ + + + + Herne Hill Velodrome + OpenBikeNet shared route herne-hill-450: the 450 m outdoor track at Herne Hill, London. Centre, direction and bend radius fitted to OpenStreetMap (© OpenStreetMap contributors). + + herne-hill-450 + + + + Herne Hill Velodrome + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/routes/herne-hill-450.json b/routes/herne-hill-450.json new file mode 100644 index 0000000..ea3fb53 --- /dev/null +++ b/routes/herne-hill-450.json @@ -0,0 +1,7 @@ +{ + "id": "herne-hill-450", + "name": "Herne Hill Velodrome", + "length": 450, + "loop": true, + "profile": [[0, 0], [450, 0]] +} diff --git a/tools/herne_hill_gpx.py b/tools/herne_hill_gpx.py new file mode 100644 index 0000000..898435e --- /dev/null +++ b/tools/herne_hill_gpx.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 +"""Write the GPS tracks of Herne Hill Velodrome in London, one for each way round: + + python3 tools/herne_hill_gpx.py > routes/herne-hill-450.gpx + python3 tools/herne_hill_gpx.py clockwise > routes/herne-hill-450-clockwise.gpx + +Track racing goes anticlockwise, so that is herne-hill-450. herne-hill-450-clockwise is the +same track and the same start/finish line ridden the other way. It is a route of its own +because riders are placed by their distance from the line: on one route ID, riders going +opposite ways would be in the wrong places and coming head-on. + +Herne Hill is an outdoor track, opened in 1891 and used for the 1948 Olympics, 450 m round on +the measuring line. Unlike velodrome-250, this is a real place, so apps that build their world +from a GPS track (their own map data and terrain) can draw the real surroundings. + +The track is an oval of two straights and two semicircles, ridden anticlockwise. Its centre, +direction and bend radius were fitted to the track's outline in OpenStreetMap +(https://www.openstreetmap.org/relation/2524096); the inside edge fits the oval to within 0.7 m +on average. Only those few numbers come from the map, not the outline itself. The start/finish +line is on the home straight, just north of the pavilion at the south end of the stands, where +aerial imagery shows the white line across the track. + +As in velodrome_gpx.py, the closed track, measured with the haversine formula on a sphere of +radius 6378.1 km, is the route's length to within a millimetre, and the last point is the first +point again. The points have no elevation: the track is flat, and apps with terrain data can +use their own heights for the ground there. The route files (.json) stay the authority. +The output is deterministic, so running this again gives the same file byte for byte. +""" +import math +import sys + +LENGTH = 450.0 +# Bend radius from the fit, in metres; the straights take up the rest of the length. +RADIUS = 45.3 +STRAIGHT = (LENGTH - 2 * math.pi * RADIUS) / 2 +BEND_STEP = 2.5 +EARTH_RADIUS = 6378100.0 +# The centre of the oval and the direction of its long axis, in degrees anticlockwise from east. +CENTRE = (51.45105, -0.09142) +AXIS = -76.8 +# The start/finish line: this far from the middle of the home straight, against the direction +# of riding (north), just past the north end of the pavilion. +START_OFFSET = 13.0 +DIGITS = 8 + + +def oval(): + """The unscaled oval as (a, b) metres from its centre, a along the long axis, starting at the + start/finish line on the home straight (b = +RADIUS) and riding anticlockwise.""" + half = STRAIGHT / 2 + start = -START_OFFSET + steps = round(math.pi * RADIUS / BEND_STEP) + points = [(start, RADIUS), (-half, RADIUS)] + for i in range(1, steps): + t = math.pi / 2 + math.pi * i / steps + points.append((-half + RADIUS * math.cos(t), RADIUS * math.sin(t))) + points += [(-half, -RADIUS), (half, -RADIUS)] + for i in range(1, steps): + t = -math.pi / 2 + math.pi * i / steps + points.append((half + RADIUS * math.cos(t), RADIUS * math.sin(t))) + points.append((half, RADIUS)) + return points + + +def to_lat_lng(points, scale): + lat0, lng0 = CENTRE + metres_per_degree = EARTH_RADIUS * math.pi / 180 + lng_factor = metres_per_degree * math.cos(math.radians(lat0)) + c, s = math.cos(math.radians(AXIS)), math.sin(math.radians(AXIS)) + out = [] + for a, b in points: + x, y = (a * c - b * s) * scale, (a * s + b * c) * scale + out.append((round(lat0 + y / metres_per_degree, DIGITS), round(lng0 + x / lng_factor, DIGITS))) + return out + + +def haversine(p, q): + lat1, lng1, lat2, lng2 = map(math.radians, (*p, *q)) + a = (math.sin((lat2 - lat1) / 2) ** 2 + + math.cos(lat1) * math.cos(lat2) * math.sin((lng2 - lng1) / 2) ** 2) + return 2 * EARTH_RADIUS * math.asin(math.sqrt(a)) + + +def track_length(track): + return sum(haversine(p, q) for p, q in zip(track, track[1:])) + + +def herne_hill_track(clockwise=False): + """The closed track as (lat, lng) points, the first point repeated at the end.""" + points = oval() + points.append(points[0]) + scale = 1.0 + for _ in range(3): + scale *= LENGTH / track_length(to_lat_lng(points, scale)) + track = to_lat_lng(points, scale) + # The same points the other way round still start and end on the line. + return track[::-1] if clockwise else track + + +def gpx(track, clockwise=False): + route_id = 'herne-hill-450-clockwise' if clockwise else 'herne-hill-450' + name = 'Herne Hill Velodrome (clockwise)' if clockwise else 'Herne Hill Velodrome' + way = ', ridden clockwise' if clockwise else '' + lines = [ + '', + '', + ' ', + f' {name}', + f' OpenBikeNet shared route {route_id}: the 450 m outdoor track at Herne Hill,' + f' London{way}. Centre, direction and bend radius fitted to OpenStreetMap' + ' (© OpenStreetMap contributors).', + f' ', + f' {route_id}', + ' ', + ' ', + ' ', + f' {name}', + ' ', + ] + lines += [f' ' for lat, lng in track] + lines += [' ', ' ', ''] + return '\n'.join(lines) + '\n' + + +if __name__ == '__main__': + args = sys.argv[1:] + if args not in ([], ['clockwise']): + sys.exit('usage: herne_hill_gpx.py [clockwise]') + clockwise = args == ['clockwise'] + sys.stdout.write(gpx(herne_hill_track(clockwise), clockwise)) From 4ce47ff00f751aa18e06e689ddb90c8221116a78 Mon Sep 17 00:00:00 2001 From: Lethonium Dev Server <38733902+RalfLeonFasler@users.noreply.github.com> Date: Sun, 15 Nov 2026 10:24:18 +0000 Subject: [PATCH 2/2] Name the Herne Hill tool in the README and match the fit in its docstring Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- tools/herne_hill_gpx.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 65d159b..63dc5aa 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ for the overall goal. - [`routes/`](routes/): shared route files with stable IDs, so that a position on a route means the same spot in every app. A route may also come as a GPX track (`routes/.gpx`) for apps that only ride GPS routes; the JSON file stays the authority. `tools/velodrome_gpx.py` writes - the velodrome's track. + the velodrome's track, `tools/herne_hill_gpx.py` the tracks of Herne Hill Velodrome. - [`schemas/`](schemas/): JSON Schemas for routes and messages. - [`examples/`](examples/): example messages, used as shared test data. - [`apps.md`](apps.md): optional list of apps that speak the protocol. diff --git a/tools/herne_hill_gpx.py b/tools/herne_hill_gpx.py index 898435e..fa5557a 100644 --- a/tools/herne_hill_gpx.py +++ b/tools/herne_hill_gpx.py @@ -15,7 +15,7 @@ The track is an oval of two straights and two semicircles, ridden anticlockwise. Its centre, direction and bend radius were fitted to the track's outline in OpenStreetMap -(https://www.openstreetmap.org/relation/2524096); the inside edge fits the oval to within 0.7 m +(https://www.openstreetmap.org/relation/2524096); the inside edge fits the oval to within 0.6 m on average. Only those few numbers come from the map, not the outline itself. The start/finish line is on the home straight, just north of the pavilion at the south end of the stands, where aerial imagery shows the white line across the track.