Skip to content

Commit 40ff1d9

Browse files
committed
Update notes on adding a route
1 parent 1e3cf4e commit 40ff1d9

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ Both plans and individual legs can include a `cancelled` key:
7474

7575
### Adding a Route
7676

77-
To add a new route, add a GPX file to the `routes/_gpx/` directory. Route files follow strict formatting rules, which get checked by `_bin/make_routes_table.py`. The build will fail with a descriptive error if any route doesn't meet the minimum formatting requirements.
77+
Add a GPX file to the `routes/_gpx/` directory. The build will fail with a descriptive error if any route doesn't meet the minimum formatting requirements which get checked by `_bin/make_routes_table.py`.
78+
79+
* The file's `<gpx>` tag must include the RCR extension: `<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Race Condition Running" xmlns:rcr="http://raceconditionrunning.com/extensions">`
80+
* `<name>` - lowercase, hyphenated name of the route. Ends with `loop` if the route is a loop or `ob` if the route is an out-and-back.
81+
* `<desc>` - The presentation name of the route, e.g. "Lake Union Loop".
82+
* You must include an `<extensions>` tag in the `<metadata>` section, with
83+
`<rcr:last_updated>YYYY-MM-DD</rcr:last_updated>`.
7884

7985
Before you commit changes to a route, run `make normalize-routes-in-place` to ensure the route is formatted correctly.
8086

_bin/rcr.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def load_route(path):
6767
with open(path, 'r') as f:
6868
reader = gpxpy.parse(f)
6969
except Exception as e:
70-
raise GPXParseError(f"Could not parse '{path}'\n{e}")
70+
raise GPXParseError(f"Could not parse '{path}'\n{e}. Make sure rcr extension is specified.")
7171

7272
# Recursively strip `{<extension_url}:` prefix from metadata keys. Nesting only used for changelog right now
7373
def strip_rcr_prefix(item_list):
@@ -98,6 +98,14 @@ def strip_rcr_prefix(item_list):
9898
if not track:
9999
raise GPXFormatError(f"Bogus number of tracks in:\n{path}")
100100

101+
if not track.description:
102+
raise GPXFormatError(f"Track description (<desc>) is empty in:\n{path}")
103+
extracted_distance = None
104+
try:
105+
extracted_distance = float(track.description.split("(")[1].split("mi)")[0].strip())
106+
except (ValueError, IndexError):
107+
raise GPXFormatError(f"Could not extract distance from track description in:\n{path}. Should be in format 'Description (X mi)'")
108+
101109
ascent = metadata.get('ascent', None)
102110
if ascent:
103111
ascent = float(ascent)
@@ -115,7 +123,7 @@ def strip_rcr_prefix(item_list):
115123
'id': path.stem,
116124
'name': metadata.get('name', track.description.split("(")[0].strip()),
117125
'last_updated': metadata.get('last_updated', None),
118-
'distance_mi': metadata.get('distance', float(track.description.split("(")[1].split("mi)")[0].strip())),
126+
'distance_mi': metadata.get('distance', extracted_distance),
119127
'ascent_m': ascent,
120128
'descent_m': descent,
121129
'map': metadata.get('map', None),

0 commit comments

Comments
 (0)