Say "track" on the site for a trail's geometry

The pages called the thing a hiker downloads and sees on the map a
"line". They now call it a track, name the format on download links
("Download GPX and GeoJSON"), and speak of the map where the text is
about what is drawn. Field and file names shown on purpose keep
"line" (line.geojson, line_policy).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-13 12:43:49 -07:00
1 parent abfbeb00bd
commit eb444ff0e6
12 files changed
+163 -152

No files matched your search

+3 -3
View File
@@ -330,10 +330,10 @@
function fail(reason) {
if (entry.ready) return;
host.dataset.state = 'fallback';
status.textContent = 'Base map unavailable (' + reason + '). The line is drawn on a plain graticule.';
status.textContent = 'Base map unavailable (' + reason + '). The track is drawn on a plain graticule.';
}
status.textContent = 'Loading the line…';
status.textContent = 'Loading the track…';
var dataReady = fetch(fig.dataset.src, { credentials: 'same-origin' })
.then(function (r) {
if (!r.ok) throw new Error(r.status);
@@ -357,7 +357,7 @@
})
.catch(function () {
host.dataset.state = 'error';
status.textContent = 'The line data did not load. Downloads on this page are unaffected.';
status.textContent = 'The track data did not load. Downloads on this page are unaffected.';
return null;
});
+12 -12
View File
@@ -249,12 +249,12 @@ def build_trail(rec, out_dir, code_mtime, force, stats):
"Simplified to 5 m, 6 decimals", "GPX"))
if "alternates" in files:
downloads.append(download(tdir, f"{tid}-alternates.geojson", "alternates",
"Alternate and connector lines, full resolution", "GeoJSON"))
"Alternate and connector tracks, full resolution", "GeoJSON"))
downloads.append(download(tdir, f"{tid}-alternates.gpx", "alternates",
"Alternate and connector lines, simplified to 5 m", "GPX"))
"Alternate and connector tracks, simplified to 5 m", "GPX"))
for source in files.get("extracts", {}):
downloads.append(download(tdir, f"{tid}-{source}.geojson", "extract",
f"Line as served by source '{source}', full resolution", "GeoJSON"))
f"Track as served by source '{source}', full resolution", "GeoJSON"))
return downloads, cache or {}
@@ -336,28 +336,28 @@ def archive_readme(name):
if ext == ".gpx":
what = "simplified to 5 m"
resolution = ("The GPX files are simplified to 5 m, with coordinates to 6 decimal places.\n"
"The full-resolution lines are in all-geojson.zip.\n")
"The full-resolution tracks are in all-geojson.zip.\n")
else:
what = "full resolution"
resolution = ("The GeoJSON files are the full-resolution lines, as published in this dataset.\n"
resolution = ("The GeoJSON files are the full-resolution tracks, as published in this dataset.\n"
"The simplified GPX files (5 m) are in all-gpx.zip.\n")
rows = [(f"<id>/<id>{ext}", f"the main line, {what}"),
(f"<id>/<id>-alternates{ext}", f"alternate and connector lines, {what}, where the\n"
rows = [(f"<id>/<id>{ext}", f"the main track, {what}"),
(f"<id>/<id>-alternates{ext}", f"alternate and connector tracks, {what}, where the\n"
"source serves them separately"),
("<id>/release.txt", "the source, licence and date the line files came from")]
("<id>/release.txt", "the source, licence and date the track files came from")]
width = max(len(p) for p, _ in rows) + 3
files = ""
for path, what_it_is in rows:
files += " " + path.ljust(width) + what_it_is.replace("\n", "\n" + " " * (width + 2)) + "\n"
return (f"{site_name() or 'Long trails'}: every {kind} line\n\n"
"For each trail or route whose record includes a line:\n\n"
return (f"{site_name() or 'Long trails'}: every track, as {kind}\n\n"
"For each trail or route whose record includes a track:\n\n"
f"{files}\n"
"and at the top:\n\n"
" trails.csv one row per record, with its licence\n"
" SOURCES.md each source, its terms, and the trails that use it\n\n"
"Terms. Each line keeps its source's terms and needs its source's credit, as\n"
"Terms. Each track keeps its source's terms and needs its source's credit, as\n"
"given in its <id>/release.txt (the Licence and Attribution lines) and in\n"
"trails.csv (the licence column). Lines from OpenStreetMap are\n"
"trails.csv (the licence column). Tracks from OpenStreetMap are\n"
"© OpenStreetMap contributors, under the ODbL. The records themselves are\n"
"public domain (CC0-1.0).\n\n"
f"{resolution}")
+11 -11
View File
@@ -27,9 +27,9 @@ LENGTH_LIMIT = 15.0
def line_differs(rec):
"""True when the record has a line, the line was measured, and the measured
"""True when the record has a track, the track was measured, and the measured
length differs from the published length by more than 15%. The one test of
a partial line used by every page."""
a partial track used by every page."""
v = rec.get("verification", {})
diff = v.get("difference_percent")
return bool(has_line(rec) and v.get("verified") and diff is not None
@@ -37,15 +37,15 @@ def line_differs(rec):
def line_short(rec):
"""line_differs, and the measured line is the shorter: the line is partial."""
"""line_differs, and the measured track is the shorter: the track is partial."""
return line_differs(rec) and rec["verification"]["difference_percent"] < 0
def partial_short_text(rec):
"""The short form for lists: "Line measures 2.0 km of 1,100 km published"."""
"""The short form for lists: "Track measures 2.0 km of 1,100 km published"."""
v = rec["verification"]
word = "of" if v["difference_percent"] < 0 else "against"
return (f"Line measures {words.fmt_km1(v['measured_km'])} km {word} "
return (f"Track measures {words.fmt_km1(v['measured_km'])} km {word} "
f"{words.fmt_km(rec['length_km'])} km published")
@@ -96,7 +96,7 @@ def designated_year(rec):
def short_source(rec):
"""A short name for where the included line came from, for lists."""
"""A short name for where the included track came from, for lists."""
src = rec.get("source", {})
if src.get("osm_only"):
name = "OpenStreetMap"
@@ -124,9 +124,9 @@ def rich(text):
def absent_reason_short(rec):
"""line_absent_reason without the opening "No line is included." (the status already says so)."""
"""line_absent_reason without the opening "No line is included." or "No track is included." (the status already says so)."""
reason = rec.get("source", {}).get("line_absent_reason", "")
return re.sub(r"^No line is included\.\s*", "", reason) or reason
return re.sub(r"^No (?:line|track) is included\.\s*", "", reason) or reason
def regions_html(rec, linked=False):
@@ -147,7 +147,7 @@ def regions_html(rec, linked=False):
def tags(rec, with_policy=True):
"""Kind, tier and listing tags, and (with_policy) the line policy of a route."""
"""Kind, tier and listing tags, and (with_policy) the track policy of a route."""
out = []
if is_route(rec):
out.append('<span class="tag tag--route">Person-defined route</span>')
@@ -167,8 +167,8 @@ def tags(rec, with_policy=True):
def policy_chip(value):
lab, short = words.label(words.POLICIES, value), words.meaning(words.POLICIES, value)
return Markup(f'<span class="policy policy--{esc(value)}" title="Line policy: {esc(short)}">'
f'<span class="vh">Line policy: </span>{esc(lab)}</span>')
return Markup(f'<span class="policy policy--{esc(value)}" title="Track policy: {esc(short)}">'
f'<span class="vh">Track policy: </span>{esc(lab)}</span>')
def logo_img(rec, alt, eager=False):
+31 -25
View File
@@ -148,7 +148,7 @@ def sources_page(records, site, repo_root):
return sum(1 for r in recs if r.get("verification", {}).get("verified"))
n_measured = measured(records)
status_cells = (f'<div><dt>Line measured</dt><dd>{n_measured}<small>Records whose line was '
status_cells = (f'<div><dt>Track measured</dt><dd>{n_measured}<small>Records whose track was '
f'downloaded and measured (verification), whatever its source</small></dd></div>')
for key in ("verified", "osm-only", "found", "none"):
recs = by_status.get(key, [])
@@ -168,31 +168,37 @@ def sources_page(records, site, repo_root):
f'<td class="num">{lines}</td><td>{_record_links(recs)}</td></tr>')
return rows
def source_label(k):
# A record with no track holds a value such as "none (no line included)"; say it in words.
if str(k).strip().lower().startswith(("none (no line", "none (no track")):
return "None (no track included)"
return esc(k)
def lic_label(k):
return Markup(f'{esc(words.label(words.LICENCES, k))} <code class="raw">{esc(k)}</code>')
head = ('<thead><tr><th scope="col">{0}</th><th scope="col">Records</th>'
'<th scope="col">With a line</th><th scope="col">Trails and routes</th></tr></thead>')
'<th scope="col">With a track</th><th scope="col">Trails and routes</th></tr></thead>')
computed = f"""<div class="container section">
<div class="section-head"><h2 id="sources-at-a-glance">At a glance</h2>
<p>Counted from the {len(records)} records. Each trail page names its own source, licence and credit.
The source status says where a line was looked for; whether it was measured is counted separately.</p></div>
The source status says where a track was looked for; whether it was measured is counted separately.</p></div>
<dl class="tally">{status_cells}</dl>
{f'<p class="note">Other source status values: {esc(", ".join(map(str, other)))}.</p>' if other else ""}
<div class="doc-block"><h3>By licence</h3><div class="table-wrap"><table>
{head.format("Licence")}
<tbody>{group_rows(by_licence, lic_label)}</tbody></table></div></div>
<div class="doc-block"><h3>By line source</h3><div class="table-wrap"><table>
{head.format("Line source")}
<tbody>{group_rows(by_source, esc)}</tbody></table></div></div>
<div class="doc-block"><h3>By track source</h3><div class="table-wrap"><table>
{head.format("Track source")}
<tbody>{group_rows(by_source, source_label)}</tbody></table></div></div>
</div>"""
doc_html = render_doc(read_doc(repo_root, "SOURCES.md"), site, drop_h1=True)
body = (f'<div class="page-head"><div class="container"><header class="titleblock">'
f'<div class="titleblock__text"><p class="kicker">Provenance</p><h1>Sources</h1>'
f'<p class="page-head__lede">Where the lines come from, and the terms each source states.</p>'
f'<p class="page-head__lede">Where the tracks come from, and the terms each source states.</p>'
f'</div></header></div></div>{computed}'
f'<div class="container section"><div class="prose doc">{doc_html}</div></div>')
return "Sources", "Where each trail line comes from: licences, line sources and source terms.", Markup(body)
return "Sources", "Where each trail track comes from: licences, track sources and source terms.", Markup(body)
def logos_page(records, site, repo_root):
@@ -259,14 +265,14 @@ def _size(out_dir, relpath):
# The bulk files on /data/: (name, what it holds, offered as a download).
# trails.json and overview.geojson are what the pages fetch; a browser shows them.
BULK_FILES = (
("trails.csv", "One row per trail: id, name, country, regions, length, kind, line policy and status.", True),
("trails.csv", "One row per trail: id, name, country, regions, length, kind, track policy and status.", True),
("trails.json", "Every record in full, as JSON, with the derived fields the site builds.", False),
("index.geojson", "Every included line, simplified to about 100 m, with id and name.", True),
("overview.geojson", "Every included line simplified to about 750 m for the overview map, "
("index.geojson", "Every included track, simplified to about 100 m, with id and name.", True),
("overview.geojson", "Every included track simplified to about 750 m for the overview map, "
"with id, name, kind, country and length.", False),
("all-gpx.zip", "Every GPX file (main lines and alternates, simplified to 5 m), as <id>/<file>, "
("all-gpx.zip", "Every GPX file (main tracks and alternates, simplified to 5 m), as <id>/<file>, "
"with each trail's release.txt, trails.csv, SOURCES.md and a README.", True),
("all-geojson.zip", "Every full-resolution GeoJSON main line and alternates file, as <id>/<file>, "
("all-geojson.zip", "Every full-resolution GeoJSON main track and alternates file, as <id>/<file>, "
"with each trail's release.txt, trails.csv, SOURCES.md and a README.", True),
)
@@ -280,7 +286,7 @@ def _licence_text_url(licence, repo_root):
def line_licence_rows(records, repo_root):
"""(what, terms, text URL) for each licence the included lines carry, from the records."""
"""(what, terms, text URL) for each licence the included tracks carry, from the records."""
by_licence = _group_by([r for r in records if common.has_line(r)],
lambda r: r.get("source", {}).get("licence", "") or "unknown")
rows = []
@@ -288,7 +294,7 @@ def line_licence_rows(records, repo_root):
recs = by_licence[lic]
label = words.label(words.LICENCES, lic)
n = len(recs)
what = f"Lines licensed {esc(label)}: {n} record{'s' if n != 1 else ''}"
what = f"Tracks licensed {esc(label)}: {n} record{'s' if n != 1 else ''}"
if n <= 3:
links = ", ".join(f'<a href="{esc(common.trail_path(r))}">{common.name(r)}</a>' for r in recs)
what += f" ({links})"
@@ -306,13 +312,13 @@ def data_page(records, site, repo_root, out_dir):
rows += (f'<tr><td><a href="/data/{esc(name)}"{dl}>/data/{esc(name)}</a></td>'
f'<td>{esc(what)}</td><td class="num">{esc(_size(out_dir, "data/" + name))}</td></tr>')
per_trail = [
("<id>.geojson", "The main line at full resolution, as published in the dataset."),
("<id>.gpx", "The main line simplified to 5 m, for GPS devices. No elevation."),
("<id>-alternates.geojson / .gpx", "Alternate and connector lines, where the source serves them separately."),
("<id>-<source>.geojson", "One source's own extract, where a line combines sources."),
("map.json", "The line simplified to 30 m for the trail page map (GeoJSON)."),
("<id>.geojson", "The main track at full resolution, as published in the dataset."),
("<id>.gpx", "The main track simplified to 5 m, for GPS devices. No elevation."),
("<id>-alternates.geojson / .gpx", "Alternate and connector tracks, where the source serves them separately."),
("<id>-<source>.geojson", "One source's own extract, where a track combines sources."),
("map.json", "The track simplified to 30 m for the trail page map (GeoJSON)."),
("trail.toml", "The record itself: source, licence, verification, logo and route details."),
("release.txt", "The source, licence and date the line files came from, where a line is included."),
("release.txt", "The source, licence and date the track files came from, where a track is included."),
("shield.svg / shield.png", "The trail logo, where one is included. Not licensed; see Logos."),
("shield-thumb.png", "A copy of a PNG logo no larger than 256 px, for the lists."),
]
@@ -320,8 +326,8 @@ def data_page(records, site, repo_root, out_dir):
lic_rows = [
("Records, documents and compiled index", "CC0-1.0 (public domain)", '/licences/LICENSE'),
("Tools in tools/", "MIT", '/licences/MIT.txt'),
("Each trail line", "Keeps its source's terms, stated in its record; see Sources", '/sources/'),
("Lines from OpenStreetMap", "ODbL-1.0; credit © OpenStreetMap contributors", '/licences/ODbL-1.0.txt'),
("Each trail track", "Keeps its source's terms, stated in its record; see Sources", '/sources/'),
("Tracks from OpenStreetMap", "ODbL-1.0; credit © OpenStreetMap contributors", '/licences/ODbL-1.0.txt'),
*line_licence_rows(records, repo_root),
("Trail logos", "Not licensed; belong to their holders, shown only to identify each trail", '/logos/'),
]
@@ -334,7 +340,7 @@ def data_page(records, site, repo_root, out_dir):
<div class="section-head"><h2>Bulk downloads</h2><p>{len(records)} records. Sizes are this build's.</p></div>
<div class="table-wrap"><table><thead><tr><th scope="col">File</th><th scope="col">What it holds</th><th scope="col">Size</th></tr></thead>
<tbody>{rows}</tbody></table></div>
<p class="prose">Each line in the archives keeps its source&rsquo;s terms and needs its source&rsquo;s
<p class="prose">Each track in the archives keeps its source&rsquo;s terms and needs its source&rsquo;s
credit, as given in the trail&rsquo;s release.txt; trails.csv gives each record&rsquo;s licence too.</p>
<div class="doc-block"><h2>Per-trail files</h2>
<p class="prose">Every record has a stable directory. Replace <code>&lt;id&gt;</code> with a record id
@@ -342,7 +348,7 @@ def data_page(records, site, repo_root, out_dir):
<code>/trails/&lt;id&gt;/&lt;id&gt;.gpx</code>, <code>/trails/&lt;id&gt;/&lt;id&gt;-alternates.geojson</code> (and <code>.gpx</code>),
<code>/trails/&lt;id&gt;/map.json</code>, <code>/trails/&lt;id&gt;/trail.toml</code> and
<code>/trails/&lt;id&gt;/release.txt</code>. The trail page is <code>/trails/&lt;id&gt;/</code>.
Line files exist only where the record includes a line; the record says why when it does not.</p>
Track files exist only where the record includes a track; the record says why when it does not.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">File under /trails/&lt;id&gt;/</th><th scope="col">What it holds</th></tr></thead>
<tbody>{prow}</tbody></table></div></div>
<div class="doc-block"><h2>Licences</h2>
+17 -17
View File
@@ -78,14 +78,14 @@ def entry(rec, *, level=3, extra=""):
if common.has_line(rec):
partial_note = (f'<p class="entry__partial">{esc(common.partial_short_text(rec))}</p>'
if partial else "")
line = (f'<span class="line__status">{common.SWATCH_ROUTE if route else common.SWATCH_LINE}Line{policy}</span>'
line = (f'<span class="line__status">{common.SWATCH_ROUTE if route else common.SWATCH_LINE}Track{policy}</span>'
f'{partial_note}'
f'<span class="line__detail">GeoJSON, GPX</span>'
f'<span class="line__detail">{esc(common.short_source(rec))} &middot; {esc(common.licence_label(rec))}</span>')
note = ""
else:
line = f'<span class="line__status">{common.SWATCH_NONE}Record only{policy}</span>'
note = (f'\n <p class="entry__note"><span class="vh">Why there is no line: </span>'
note = (f'\n <p class="entry__note"><span class="vh">Why there is no track: </span>'
f'{esc(common.absent_reason_short(rec))}</p>')
regions = " ".join(words.region_key(c, rec["country"]) for c in rec.get("regions", []))
search = " ".join([rec["name"], rec.get("short_name", ""), rec["id"]]
@@ -108,7 +108,7 @@ def entry(rec, *, level=3, extra=""):
</div>
<dl class="entry__facts">
<div class="entry__length"><dt>Length</dt><dd>{words.length(rec["length_km"], "stack", rec["derived"]["length_mi"])}<span class="loglen" style="--km: {rec["length_km"]}" aria-hidden="true"></span></dd></div>
<div class="entry__line"><dt>Line</dt><dd class="line line--{"yes" if common.has_line(rec) else "no"}">{line}</dd></div>
<div class="entry__line"><dt>Track</dt><dd class="line line--{"yes" if common.has_line(rec) else "no"}">{line}</dd></div>
</dl>{note}{extra}
</li>"""
@@ -154,7 +154,7 @@ def finder_form(c, steps=LENGTH_STEPS):
<div class="field">
<label class="check">
<input type="checkbox" name="line">
<span class="check__text">Has a downloadable line <span class="check__count">{c["line"]}</span></span>
<span class="check__text">Has a downloadable track <span class="check__count">{c["line"]}</span></span>
<span class="check__hint">GeoJSON and GPX. The other {c["record_only"]} are records only.</span>
</label>
</div>
@@ -197,7 +197,7 @@ def finder_form(c, steps=LENGTH_STEPS):
<span class="check__text">Person-defined routes <span class="check__count">{c["route"]}</span></span>
<span class="check__hint">Worked out and published by a person or a small group</span>
</label>
<label class="field__label field__label--sub" for="policy">Route line policy</label>
<label class="field__label field__label--sub" for="policy">Route track policy</label>
<select class="select" id="policy" name="policy"><option value="">Any</option>{policy_opts}</select>
</fieldset>
<div class="field">
@@ -228,7 +228,7 @@ def list_head():
return f"""<div class="list-head" aria-hidden="true">
<span>Trail</span>
<span>Length<span class="list-head__scale">{"".join(ticks)}</span></span>
<span>Line</span>
<span>Track</span>
</div>"""
@@ -251,9 +251,9 @@ SORT_SELECT = """<label class="results-sort">Sort
def key():
return f"""<ul class="key" aria-label="Key to the list">
<li>{common.SWATCH_LINE}Line in the dataset</li>
<li>{common.SWATCH_LINE}Track in the dataset</li>
<li>{common.SWATCH_NONE}Record only; the note says why</li>
<li>Route line policy:
<li>Route track policy:
{common.policy_chip("open")} {common.policy_chip("sold")} {common.policy_chip("withheld")} {common.policy_chip("unclear")}
</li>
</ul>"""
@@ -309,21 +309,21 @@ def render(records, site):
recs = sorted(records, key=sort_name)
total = c["total"]
lede = (f"A record for each of {total} long trails and routes, as a rule 50 miles (80&nbsp;km) or more: "
"what it is, how long it is, who publishes it, and on what terms its line may be passed on. "
"Where the terms allow, download the line as GeoJSON or GPX.")
"what it is, how long it is, who publishes it, and on what terms its track may be passed on. "
"Where the terms allow, download the track as GPX or GeoJSON.")
return f"""<section class="hero" aria-labelledby="hero-title">
<div class="container hero__inner">
<p class="kicker">A public dataset &middot; United States and Canada</p>
<h1 id="hero-title">{esc(site.tagline)}</h1>
<p class="hero__lede">{lede}</p>
<p class="hero__caveat">This is a dataset, not a navigation product. Lines vary in quality, some trails are unfinished, and some records have no line at all; each of those says why.</p>
<p class="hero__caveat">This is a dataset, not a navigation product. Tracks vary in quality, some trails are unfinished, and some records have no track at all; each of those says why.</p>
<p><a class="button button--primary hero__cta" href="#q">Find a trail</a></p>
<div class="hero__counts">
<dl class="tally">
<div><dt>Records</dt><dd>{total}</dd></div>
<div><dt><a href="/?kind=designated">Designated trails</a></dt><dd>{c["designated"]}</dd></div>
<div><dt><a href="/?kind=route">Person-defined routes</a></dt><dd>{c["route"]}</dd></div>
<div><dt>{common.SWATCH_LINE}<a href="/?line=1">With a line</a></dt><dd>{c["line"]}</dd></div>
<div><dt>{common.SWATCH_LINE}<a href="/?line=1">With a track</a></dt><dd>{c["line"]}</dd></div>
<div><dt>{common.SWATCH_NONE}Records only</dt><dd>{c["record_only"]}</dd></div>
</dl>
<div class="ratio" aria-hidden="true"><span class="ratio__line" style="--n: {c["line"]}"></span><span class="ratio__none" style="--n: {c["record_only"]}"></span></div>
@@ -334,13 +334,13 @@ def render(records, site):
<section class="section" aria-labelledby="map-title">
<div class="container">
<div class="section-head">
<h2 id="map-title">Every line in the dataset</h2>
<p>{c["line"]} lines, simplified for display. Select a line for its name.</p>
<h2 id="map-title">Every track in the dataset</h2>
<p>{c["line"]} tracks, simplified for display. Select a trail on the map for its name.</p>
</div>
<figure class="mapfig" data-map="overview" data-src="/data/overview.geojson"{overview_bbox(records)}>
<div class="mapfig__frame">
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
<div class="map" role="region" aria-label="Map of every line in the dataset">
<div class="map" role="region" aria-label="Map of every track in the dataset">
<div class="map__fallback"></div>
<div class="map__canvas"></div>
<p class="map__status" role="status">The map needs JavaScript. The list below has every record.</p>
@@ -352,7 +352,7 @@ def render(records, site):
<li>{common.SWATCH_LINE}Designated trail</li>
<li>{common.SWATCH_ROUTE}Person-defined route</li>
</ul>
<p>Lines are simplified to about 750&nbsp;m here; each keeps the credit and licence named on its page. Base map: OpenFreeMap, &copy;&nbsp;OpenMapTiles, data &copy;&nbsp;OpenStreetMap contributors.</p>
<p>Tracks are simplified to about 750&nbsp;m here; each keeps the credit and licence named on its page. Base map: OpenFreeMap, &copy;&nbsp;OpenMapTiles, data &copy;&nbsp;OpenStreetMap contributors.</p>
</figcaption>
</figure>
</div>
@@ -362,7 +362,7 @@ def render(records, site):
<div class="container finder__grid">
<div class="finder__head section-head">
<h2 id="finder-title">Find a trail</h2>
<p>Search, then narrow by country, region, length, kind and line</p>
<p>Search, then narrow by country, region, length, kind and track</p>
</div>
{finder_form(c, length_steps(records))}
{results(recs, finder=True)}
+3 -3
View File
@@ -66,15 +66,15 @@ def footer(site):
<div class="container site-footer__grid">
<div class="site-footer__about">
<a class="wordmark" href="/"><span class="wordmark__blaze" aria-hidden="true"></span>{esc(site.name)}</a>
<p>A dataset, not a navigation product: lines vary in quality, some trails are unfinished, and some records have no line at all. Check a trail&rsquo;s own record before using its line.</p>
<p>The records are public domain (CC0-1.0). Each line keeps the terms of its source, named on its page. Lines from OpenStreetMap are &copy;&nbsp;OpenStreetMap contributors, under the ODbL. Logos belong to their holders and are shown only to identify each trail.</p>
<p>A dataset, not a navigation product: tracks vary in quality, some trails are unfinished, and some records have no track at all. Check a trail&rsquo;s own record before using its track.</p>
<p>The records are public domain (CC0-1.0). Each track keeps the terms of its source, named on its page. Tracks from OpenStreetMap are &copy;&nbsp;OpenStreetMap contributors, under the ODbL. Logos belong to their holders and are shown only to identify each trail.</p>
</div>
<nav aria-labelledby="footer-data">
<h2 id="footer-data">Data</h2>
<ul>
<li><a href="/data/">About the data and downloads</a></li>
<li><a href="/data/trails.csv">trails.csv</a>: one row per trail</li>
<li><a href="/data/index.geojson">index.geojson</a>: every line, simplified</li>
<li><a href="/data/index.geojson">index.geojson</a>: every track, simplified</li>
<li><a href="/sources/">Sources and their terms</a></li>
</ul>
</nav>
+11 -11
View File
@@ -62,12 +62,12 @@ def _bbox_attr(recs):
def _region_map(recs, title):
ids = [r["id"] for r in recs if "line" in r["derived"]["files"]]
if not ids:
return ('<p class="note">No downloadable line in this region yet, so there is '
return ('<p class="note">No downloadable track in this region yet, so there is '
'nothing to draw. The records below say why.</p>')
return f"""<figure class="mapfig" data-map="overview" data-src="/data/overview.geojson" data-ids="{esc(" ".join(ids))}"{_bbox_attr(recs)}>
<div class="mapfig__frame">
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
<div class="map" role="region" aria-label="Map of lines in {esc(title)}">
<div class="map" role="region" aria-label="Map of tracks in {esc(title)}">
<div class="map__fallback"></div><div class="map__canvas"></div>
<p class="map__status" role="status">The map needs JavaScript. The list below has every record.</p>
</div>
@@ -76,7 +76,7 @@ def _region_map(recs, title):
<figcaption class="mapfig__caption">
<ul class="legend" aria-label="Legend"><li>{common.SWATCH_LINE}Designated trail</li>
<li>{common.SWATCH_ROUTE}Person-defined route</li></ul>
<p>{len(ids)} line{"s" if len(ids) != 1 else ""} in this region, simplified for display. Select a line for its name.</p>
<p>{len(ids)} track{"s" if len(ids) != 1 else ""} in this region, simplified for display. Select a trail on the map for its name.</p>
</figcaption>
</figure>"""
@@ -108,7 +108,7 @@ def regions_index_page(records, site):
blocks += f"""<div class="doc-block"><h2 id="{esc(country.lower())}">{esc(words.COUNTRIES[country])}</h2>
<p class="prose">{n_country} records name at least one {unit}. Each is counted once, whichever
country it is filed under.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">State, province or territory</th><th scope="col">Records</th><th scope="col">With a downloadable line</th></tr></thead>
<div class="table-wrap"><table><thead><tr><th scope="col">State, province or territory</th><th scope="col">Records</th><th scope="col">With a downloadable track</th></tr></thead>
<tbody>{rows}</tbody></table></div>{extra}</div>"""
body = f"""<div class="page-head"><div class="container"><header class="titleblock">
<div class="titleblock__text"><p class="kicker">Browse</p><h1>Regions</h1>
@@ -117,7 +117,7 @@ def regions_index_page(records, site):
</div></header>
<dl class="tally">{tally}</dl></div></div>
<div class="container section">{blocks}</div>"""
return "Regions", "Long trails by state, province and territory, with counts of records and lines.", Markup(body)
return "Regions", "Long trails by state, province and territory, with counts of records and tracks.", Markup(body)
def region_page(slug, records, site):
@@ -137,7 +137,7 @@ def region_page(slug, records, site):
n = by_slug[same[idx + 1]]
neighbours.append(f'<a href="{esc(region_path(n["code"], n["country"]))}">{esc(n["name"])} →</a>')
nav = " · ".join(neighbours)
with_line = (f'<a href="/?region={esc(key)}&amp;line=1">With a line</a>' if lines else "With a line")
with_line = (f'<a href="/?region={esc(key)}&amp;line=1">With a track</a>' if lines else "With a track")
body = f"""<div class="page-head"><div class="container">
<nav class="breadcrumb" aria-label="Breadcrumb"><ol><li><a href="/regions/">Regions</a></li>
<li><a href="/regions/#{esc(info["country"].lower())}">{esc(words.COUNTRIES[info["country"]])}</a></li>
@@ -145,14 +145,14 @@ def region_page(slug, records, site):
<header class="titleblock"><div class="titleblock__text">
<p class="kicker">{esc(words.COUNTRIES[info["country"]])} · {esc(info["code"])}</p>
<h1>{esc(info["name"])}</h1>
<p class="page-head__lede">{len(recs)} record{"s" if len(recs) != 1 else ""}, {lines} with a downloadable line.</p>
<p class="page-head__lede">{len(recs)} record{"s" if len(recs) != 1 else ""}, {lines} with a downloadable track.</p>
</div></header>
<dl class="tally"><div><dt>Records</dt><dd>{len(recs)}</dd></div>
<div><dt>{common.SWATCH_LINE}{with_line}</dt><dd>{lines}</dd></div>
<div><dt>{common.SWATCH_NONE}Records only</dt><dd>{len(recs) - lines}</dd></div></dl>
</div></div>
<div class="container section">
<div class="section-head"><h2>Lines in {esc(info["name"])}</h2><p>Only lines in this region are drawn.</p></div>
<div class="section-head"><h2>Tracks in {esc(info["name"])}</h2><p>Only tracks in this region are drawn.</p></div>
{_region_map(recs, info["name"])}
</div>
<div class="container section">
@@ -198,7 +198,7 @@ def routes_page(records, site, repo_root):
for key in ("open", "sold", "withheld", "unclear"):
lab, short, rule = words.POLICIES[key]
policy_items += f'<li>{common.policy_chip(key)}<span>{esc(short)}. {esc(rule)}</span></li>'
policies = Markup(f'<ol class="policy-scale" aria-label="The four line policies">{policy_items}</ol>')
policies = Markup(f'<ol class="policy-scale" aria-label="The four track policies">{policy_items}</ol>')
routes = [r for r in records if common.is_route(r)]
by_creator = collections.defaultdict(list)
@@ -212,9 +212,9 @@ def routes_page(records, site, repo_root):
<p class="page-head__lede">{len(routes)} routes worked out and published by a person or a small group.</p>
</div></header></div></div>
<div class="container section"><div class="prose doc">{intro}</div>
<h2 class="doc-block">The four line policies</h2>{policies}
<h2 class="doc-block">The four track policies</h2>{policies}
<p class="prose"><a href="/?kind=route">See the routes in the trail finder</a>, or read a route below.</p></div>
<div class="container section"><div class="section-head"><h2>Routes by creator</h2>
<p>Each route links to its record; its guides link out to the creator's or publisher's page.</p></div>
{home.results(groups=groups)}</div>"""
return "Routes", f"{len(routes)} person-defined routes by creator, with line policies and guides.", Markup(body)
return "Routes", f"{len(routes)} person-defined routes by creator, with track policies and guides.", Markup(body)
+51 -50
View File
@@ -63,9 +63,10 @@ def record_text(text, cls=""):
def restates_no_line(value):
"""True for record values that only say there is no line ("none (no line included)")."""
"""True for record values that only say there is no track ("none (no line included)")."""
text = str(value or "").strip().lower()
return text.startswith(("none (no line", "no line included", "no line to measure"))
return text.startswith(("none (no line", "no line included", "no line to measure",
"none (no track", "no track included", "no track to measure"))
def region_names(rec):
@@ -135,20 +136,20 @@ def tally(rec):
items = [("Published length", words.length(rec["length_km"], "stack", rec["derived"]["length_mi"]), note)]
if v.get("verified") and "measured_km" in v:
diff = v.get("difference_percent", 0)
items.append(("Measured line", words.length(v["measured_km"], "stack", measured=True),
items.append(("Measured track", words.length(v["measured_km"], "stack", measured=True),
f"{words.fmt_percent(diff)} against published"))
else:
items.append(("Measured line", Markup('<span class="tally__none">Not measured</span>'),
"No line was downloaded and measured"))
items.append(("Measured track", Markup('<span class="tally__none">Not measured</span>'),
"No track was downloaded and measured"))
if common.has_line(rec):
text = "In the dataset, partial" if common.line_short(rec) else "In the dataset"
link = Markup(f'<a href="#download">{esc(text)}</a>') if rec["derived"].get("downloads") else text
items.append(("Line", link, "Licence: " + common.licence_label(rec)))
items.append(("Track", link, "Licence: " + common.licence_label(rec)))
else:
items.append(("Line", "Record only", "The reason is given below"))
items.append(("Track", "Record only", "The reason is given below"))
if common.is_route(rec):
p = common.policy(rec)
items.append(("Line policy", words.label(words.POLICIES, p), words.meaning(words.POLICIES, p)))
items.append(("Track policy", words.label(words.POLICIES, p), words.meaning(words.POLICIES, p)))
else:
t = rec.get("tier", "")
items.append(("Tier", words.label(words.TIERS, t), words.meaning(words.TIERS, t)))
@@ -163,7 +164,7 @@ def map_figure(rec):
src = rec["source"]
has_alt = "alternates" in rec["derived"]["files"]
route = common.is_route(rec)
legend = f'<li>{common.SWATCH_ROUTE if route else common.SWATCH_LINE}Main line</li>'
legend = f'<li>{common.SWATCH_ROUTE if route else common.SWATCH_LINE}Main track</li>'
if has_alt:
legend += f"<li>{common.SWATCH_ALT}Alternates and connectors</li>"
bbox = rec["derived"].get("map_bbox") or rec["derived"].get("bbox")
@@ -175,13 +176,13 @@ def map_figure(rec):
<div class="map" role="region" aria-label="Map of the {esc(rec["name"])}">
<div class="map__fallback"></div>
<div class="map__canvas"></div>
<p class="map__status" role="status">The map needs JavaScript. Download the line from this page.</p>
<p class="map__status" role="status">The map needs JavaScript. Download the GPX or GeoJSON file from this page.</p>
</div>
<span class="mapfig__corner mapfig__corner--se" aria-hidden="true"></span>
</div>
<figcaption class="mapfig__caption">
<ul class="legend" aria-label="Legend">{legend}</ul>
<p>Line: {esc(src.get("line_source", ""))}, read {esc(src.get("source_checked", ""))}, drawn simplified to 30&nbsp;m. Credit: {esc(credit)} Base map: OpenFreeMap, &copy;&nbsp;OpenMapTiles, data &copy;&nbsp;OpenStreetMap contributors.</p>
<p>Track: {esc(src.get("line_source", ""))}, read {esc(src.get("source_checked", ""))}, drawn simplified to 30&nbsp;m. Credit: {esc(credit)} Base map: OpenFreeMap, &copy;&nbsp;OpenMapTiles, data &copy;&nbsp;OpenStreetMap contributors.</p>
</figcaption>
</figure>"""
@@ -197,12 +198,12 @@ def empty_frame(rec):
if common.is_route(rec):
p = common.policy(rec)
titles = {
"open": "Get the line from the creator",
"sold": "The line is sold as a guide",
"withheld": "The creator does not publish a line",
"unclear": "Whether the line may be shared is not settled",
"open": "Get the track from the creator",
"sold": "The track is sold as a guide",
"withheld": "The creator does not publish a track",
"unclear": "Whether the track may be shared is not settled",
}
title = titles.get(p, "No line in this dataset")
title = titles.get(p, "No track in this dataset")
rule = words.POLICIES.get(p, ("", "", ""))[2]
if p == "open" and free_guides(rec):
g = free_guides(rec)[0]
@@ -213,9 +214,9 @@ def empty_frame(rec):
elif len(rec.get("guide", [])) > 1:
actions.append('<a class="button button--link" href="#guides-title">All guides</a>')
else:
title = "No line in this dataset"
title = "No track in this dataset"
reason = common.absent_reason_short(rec)
rule = "A trail may be listed as a record only, with no line, when no line for it may be shared. The record says why."
rule = "A trail may be listed as a record only, with no track, when no track for it may be shared. The record says why."
if src.get("publisher_url"):
actions.append(f'<a class="button button--link" href="{esc(src["publisher_url"])}">'
f'Publisher&rsquo;s page {common.ICON_EXTERNAL}</a>')
@@ -225,7 +226,7 @@ def empty_frame(rec):
actions_html = f'<p class="cluster">{"".join(actions)}</p>' if actions else ""
return f"""<figure class="mapfig mapfig--empty detail__map" aria-labelledby="noline-title">
<div class="mapfig__frame">
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true">No line in this dataset</span>
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true">No track in this dataset</span>
<div class="map map--empty">
<div class="map__message">
<p class="kicker">Record only</p>
@@ -237,7 +238,7 @@ def empty_frame(rec):
</div>
<span class="mapfig__corner mapfig__corner--se" aria-hidden="true">Nothing drawn</span>
</div>
<figcaption class="mapfig__caption"><p>No map is drawn: the dataset holds no line for this {"route" if common.is_route(rec) else "trail"}, and does not guess one.</p></figcaption>
<figcaption class="mapfig__caption"><p>No map is drawn: the dataset holds no track for this {"route" if common.is_route(rec) else "trail"}, and does not guess one.</p></figcaption>
</figure>"""
@@ -251,7 +252,7 @@ def ordered_downloads(items):
def download_group(rec, label, swatch, note, items, gid):
"""One group of download buttons. GPX comes first and is the primary button. Each
link's accessible name starts with the group: "Main line: GPX, 1.1 MB"."""
link's accessible name starts with the group: "Main track: GPX, 1.1 MB"."""
buttons = "".join(
f'<a class="button{" button--primary" if d["format"] == "GPX" else ""}" '
f'href="/trails/{esc(rec["id"])}/{esc(d["file"])}" download="{esc(d["file"])}">'
@@ -265,17 +266,17 @@ def download_group(rec, label, swatch, note, items, gid):
def partial_notice(rec):
"""The notice above the buttons when the line differs from the published length
"""The notice above the buttons when the track differs from the published length
by more than 15%: the record's own numbers, then its length_gap_note."""
if not common.line_differs(rec):
return ""
v = rec["verification"]
diff = v["difference_percent"]
head = "Partial line" if diff < 0 else "Longer than the published length"
head = "Partial track" if diff < 0 else "Longer than the published length"
gap = rec["source"].get("length_gap_note", "")
return f"""<div class="notice notice--partial">
<h3>{head}</h3>
<p>The line in the dataset measures {esc(words.fmt_km1(v["measured_km"]))}&nbsp;km against a published {esc(words.fmt_km(rec["length_km"]))}&nbsp;km ({esc(words.fmt_percent(diff))}).</p>
<p>The track in the dataset measures {esc(words.fmt_km1(v["measured_km"]))}&nbsp;km against a published {esc(words.fmt_km(rec["length_km"]))}&nbsp;km ({esc(words.fmt_percent(diff))}).</p>
{f"<p>{common.rich(gap)}</p>" if gap else ""}
</div>"""
@@ -294,7 +295,7 @@ def downloads_panel(rec):
parts = v.get("parts")
note = (f"{words.fmt_km1(v['measured_km'])} km measured"
+ (f" in {parts} part{'s' if parts != 1 else ''}" if parts else "") + f" · {note}")
groups.append(download_group(rec, "Main line", common.SWATCH_ROUTE if common.is_route(rec) else common.SWATCH_LINE,
groups.append(download_group(rec, "Main track", common.SWATCH_ROUTE if common.is_route(rec) else common.SWATCH_LINE,
note, main, "dl-main"))
alts = [d for d in downloads if d["role"] == "alternates"]
if alts:
@@ -305,7 +306,7 @@ def downloads_panel(rec):
name = EXTRACT_SOURCES.get(key, key)
# No swatch: extracts are not drawn on the map.
groups.append(download_group(rec, f"Extract: {name}", "",
"The line as this source serves it, before the sources were combined",
"The track as this source serves it, before the sources were combined",
[d], f"dl-x{i}"))
licence = src.get("licence", "")
licence_html = esc(words.label(words.LICENCES, licence))
@@ -313,16 +314,16 @@ def downloads_panel(rec):
licence_html = ext_link(words.LICENCE_URLS[licence], words.label(words.LICENCES, licence))
if "ODbL" in src.get("attribution", "") and licence != "ODbL-1.0":
licence_html = Markup(f'{licence_html}; OpenStreetMap parts {ext_link(words.LICENCE_URLS["ODbL-1.0"], "ODbL 1.0")}')
osm_note = ("<p class=\"note\">Lines from OpenStreetMap need the credit &ldquo;&copy;&nbsp;OpenStreetMap contributors&rdquo; "
osm_note = ("<p class=\"note\">Tracks from OpenStreetMap need the credit &ldquo;&copy;&nbsp;OpenStreetMap contributors&rdquo; "
"and stay under the ODbL (share-alike).</p>") if "ODbL" in src.get("attribution", "") + licence else ""
release = (f'<p class="note"><a href="/trails/{esc(rec["id"])}/release.txt">release.txt</a>: '
f"the source, licence and date the line files came from.</p>"
f"the source, licence and date the track files came from.</p>"
if rec["derived"].get("release") else "")
return f"""<section class="panel" id="download" aria-labelledby="download-title">
<h2 class="panel__head" id="download-title">Download the line</h2>
<h2 class="panel__head" id="download-title">Download GPX and GeoJSON</h2>
<div class="panel__body">
{partial_notice(rec)}
<p class="note">GPX is simplified to 5&nbsp;m for devices. GeoJSON is the full-resolution line as published in this dataset. Neither carries elevation.</p>
<p class="note">GPX is simplified to 5&nbsp;m for devices. GeoJSON is the full-resolution track as published in this dataset. Neither carries elevation.</p>
<ul class="downloads">{"".join(groups)}</ul>
<div class="credit">
<p class="credit__label" id="credit-label">Credit the source</p>
@@ -398,7 +399,7 @@ def links_panel(rec):
add(f"https://www.openstreetmap.org/relation/{osm['relation']}",
f"OpenStreetMap relation {osm['relation']}", f"The {kind} as mapped in OpenStreetMap")
if src.get("url"):
what = "Where the included line came from" if common.has_line(rec) else "Where to ask for the line"
what = "Where the included track came from" if common.has_line(rec) else "Where to ask for the track"
title = "OpenStreetMap" if host(src["url"]).endswith("openstreetmap.org") else (publisher or host(src["url"]))
add(src["url"], title, what)
for g in rec.get("guide", []):
@@ -413,7 +414,7 @@ def links_panel(rec):
add(sh["logo_source"], owner, "The page the logo was taken from")
add(f"/trails/{rec['id']}/trail.toml", "trail.toml", "The record itself, as data")
if rec["derived"].get("release"):
add(f"/trails/{rec['id']}/release.txt", "release.txt", "Source, licence and date of the line files")
add(f"/trails/{rec['id']}/release.txt", "release.txt", "Source, licence and date of the track files")
def describe(url, whats):
text = "; ".join([whats[0]] + [w[:1].lower() + w[1:] for w in whats[1:]])
@@ -435,7 +436,7 @@ def policy_scale(current):
here = ' aria-current="true"' if p == current else ""
mark = '<span class="policy-scale__here">This route</span>' if p == current else ""
items.append(f'<li{here}>{common.policy_chip(p)}<span>{esc(short)}. {esc(rule)}</span>{mark}</li>')
return Markup(f'<ol class="policy-scale" aria-label="Line policies for person-defined routes">{"".join(items)}</ol>')
return Markup(f'<ol class="policy-scale" aria-label="Track policies for person-defined routes">{"".join(items)}</ol>')
def route_block(rec):
@@ -445,7 +446,7 @@ def route_block(rec):
fact("Creator", r.get("creator", "")),
fact("First published", str(r["year"])) if r.get("year") else
fact("First published", "Not recorded", "No page read states a year"),
fact("Line policy", words.label(words.POLICIES, p), words.meaning(words.POLICIES, p)),
fact("Track policy", words.label(words.POLICIES, p), words.meaning(words.POLICIES, p)),
]
quote = ""
if r.get("creator_words"):
@@ -497,7 +498,7 @@ def record_block(rec):
rows += [
Markup(f'<div><dt>Where</dt><dd>{where}</dd></div>'),
Markup(f'<div><dt>Published length</dt><dd>{words.length(rec["length_km"], "inline", rec["derived"]["length_mi"])}'
f'<small>{esc(rec.get("length_note", ""))}. A check value, not measured from the line.</small></dd></div>'),
f'<small>{esc(rec.get("length_note", ""))}. A check value, not measured from the track.</small></dd></div>'),
fact("Short name", rec.get("short_name", "")),
fact("Record ID", Markup(code(rec["id"])), "Stable: the directory name, never changed"),
]
@@ -510,7 +511,7 @@ def gauge(diff):
off = "low" if diff < GAUGE_MIN else "high" if diff > GAUGE_MAX else ""
inside = abs(diff) <= GAUGE_LIMIT
side = "shorter than" if diff < 0 else "longer than" if diff > 0 else "the same as"
label = (f"Measured line is {abs(diff):.1f} percent {side} the published length, "
label = (f"Measured track is {abs(diff):.1f} percent {side} the published length, "
f"{'inside' if inside else 'outside'} the 15 percent limit.")
mark_text = words.fmt_percent(diff) + (" (off the scale)" if off else "")
ticks = (GAUGE_MIN, -GAUGE_LIMIT, 0, GAUGE_LIMIT, GAUGE_MAX) # placed by .gauge__tick--N in style.css
@@ -536,7 +537,7 @@ def verification_block(rec):
gap = src.get("length_gap_note", "")
if gap and common.line_differs(rec) and rec["derived"].get("downloads"):
# The download panel's notice carries the note, beside the files it is about.
gap_html = '<p class="note">Why the lengths differ: see the notice in <a href="#download">Download the line</a>.</p>'
gap_html = '<p class="note">Why the lengths differ: see the notice in <a href="#download">Download GPX and GeoJSON</a>.</p>'
elif gap:
gap_html = f'<div class="notice"><h3>Why the lengths differ</h3><p>{common.rich(gap)}</p></div>'
else:
@@ -546,17 +547,17 @@ def verification_block(rec):
parts = v.get("parts")
compare = f"""<dl class="compare">
<div><dt>Published</dt><dd>{words.length(rec["length_km"], "stack", rec["derived"]["length_mi"])}</dd></div>
<div><dt>Measured</dt><dd>{words.length(v["measured_km"], "stack", measured=True)}<small>geodesic, from the line</small></dd></div>
<div><dt>Measured</dt><dd>{words.length(v["measured_km"], "stack", measured=True)}<small>geodesic, from the track</small></dd></div>
<div><dt>Difference</dt><dd>{esc(words.fmt_percent(diff))}<small>measured minus published</small></dd></div>
<div><dt>Parts</dt><dd>{esc(parts if parts is not None else "Not recorded")}<small>pieces left after joining ends within 100 m</small></dd></div>
</dl>"""
content = Markup(compare) + gauge(diff) + record_text(v.get("note", "")) + Markup(gap_html)
extra = Markup(f' <span class="tag">Checked {esc(v.get("date", ""))}</span>') if v.get("date") else ""
verified_row = facts(fact("Measured", "Yes", "The line was downloaded and measured"))
verified_row = facts(fact("Measured", "Yes", "The track was downloaded and measured"))
return block("verify-title", "Verification", verified_row + content, extra)
if not common.has_line(rec) and restates_no_line(v.get("note", "")) and not gap:
return "" # "No line to measure": the record only restates that there is no line
rows = facts(fact("Measured", "No", "No line was downloaded and measured"))
return "" # "No line to measure": the record only restates that there is no track
rows = facts(fact("Measured", "No", "No track was downloaded and measured"))
return block("verify-title", "Verification", rows + record_text(v.get("note", "")) + Markup(gap_html))
@@ -568,30 +569,30 @@ def source_block(rec):
licence_value = words.label(words.LICENCES, licence)
licence_html = (ext_link(words.LICENCE_URLS[licence], licence_value) if licence in words.LICENCE_URLS
else esc(licence_value))
source_help = '<small>Where to ask for the line: a layer or relation page</small>' if line else ""
source_help = '<small>Where to ask for the track: a layer or relation page</small>' if line else ""
def keep(value):
"""Rows of a record with no line are left out when they only restate that."""
"""Rows of a record with no track are left out when they only restate that."""
return line or not restates_no_line(value)
rows = [
fact("Line in this dataset", src.get("line_file"), "The main line file of the record") if line else "",
fact("Track in this dataset", src.get("line_file"), "The main track file of the record") if line else "",
fact("Source status", words.label(words.SOURCE_STATUS, status), words.meaning(words.SOURCE_STATUS, status)),
fact("Publisher", src.get("publisher", "")),
Markup(f'<div><dt>Publisher&rsquo;s page</dt><dd>{ext_link(src["publisher_url"])}</dd></div>') if src.get("publisher_url") else "",
Markup(f'<div><dt>Source</dt><dd>{ext_link(src["url"])}{source_help}</dd></div>') if src.get("url") else "",
fact("Line source", src.get("line_source", "")) if keep(src.get("line_source")) else "",
fact("Track source", src.get("line_source", "")) if keep(src.get("line_source")) else "",
fact("Format", src.get("format", "")) if keep(src.get("format")) else "",
fact("Main line", src.get("mainline", ""), "How the main line is told apart from alternates, connectors and side trails"),
fact("Main track", src.get("mainline", ""), "How the main track is told apart from alternates, connectors and side trails"),
fact("Coordinates", src.get("crs", ""), "What the source stores; published files are longitude/latitude (EPSG:4326)") if line else "",
Markup(f'<div><dt>Licence</dt><dd>{licence_html}</dd></div>'),
fact("Credit", common.credit_text(src.get("attribution", "")), "The credit line to show, as the source asks")
if keep(src.get("attribution")) else "",
fact("May be passed on", yes_no(src.get("redistributable")),
"The source's terms allow its line to be passed on" if src.get("redistributable") else
"The source's terms do not allow its line to be passed on") if line else "",
"The source's terms allow its track to be passed on" if src.get("redistributable") else
"The source's terms do not allow its track to be passed on") if line else "",
fact("OpenStreetMap only", yes_no(src.get("osm_only")),
"OpenStreetMap is the only source of the included line" if src.get("osm_only") else "") if line else "",
"OpenStreetMap is the only source of the included track" if src.get("osm_only") else "") if line else "",
fact("Source checked", src.get("source_checked", "")),
fact("Newer release?", src["discovery"], "How to tell whether the source has a newer release") if src.get("discovery") else "",
]
@@ -707,7 +708,7 @@ def description(rec):
kind = "person-defined route" if common.is_route(rec) else "long trail"
text = f"{rec['name']}: a {km} km ({mi} mi) {kind} in {where}. "
if common.has_line(rec):
text += "Download its line as GeoJSON or GPX, with the source, licence and credit."
text += "Download its track as GPX or GeoJSON, with the source, licence and credit."
else:
text += "Record only: " + common.absent_reason_short(rec)
return text if len(text) <= 300 else text[:297].rsplit(" ", 1)[0] + "…"
+9 -9
View File
@@ -53,10 +53,10 @@ KINDS = {
"Worked out and published by a person or a small group: a high route, a traverse or a loop of linked trails"),
}
SOURCE_STATUS = {
"verified": ("Verified", "The line was downloaded from the source and measured"),
"verified": ("Verified", "The track was downloaded from the source and measured"),
"found": ("Found", "The source was located but not downloaded"),
"osm-only": ("OpenStreetMap only", "The only source is an OpenStreetMap route relation"),
"none": ("None", "No source of a line"),
"none": ("None", "No source of a track"),
}
LICENCES = {
"us-gov-public-domain": "US public domain",
@@ -75,15 +75,15 @@ LICENCE_URLS = {
"CC-BY-NC-ND-4.0": "https://creativecommons.org/licenses/by-nc-nd/4.0/",
}
POLICIES = {
"open": ("Open", "The creator publishes the line freely",
"A line is included only where the creator's terms allow passing it on, or where "
"open": ("Open", "The creator publishes the track freely",
"A track is included only where the creator's terms allow passing it on, or where "
"OpenStreetMap carries the route as a route relation. Otherwise get it from the creator."),
"sold": ("Sold", "The route is got by buying a guide or map set",
"No line is included from any source, OpenStreetMap included."),
"withheld": ("Withheld", "The creator chooses not to publish a line",
"No line is included from any source, OpenStreetMap included."),
"unclear": ("Unclear", "Whether the creator shares the line is not settled",
"No line is included until it is settled."),
"No track is included from any source, OpenStreetMap included."),
"withheld": ("Withheld", "The creator chooses not to publish a track",
"No track is included from any source, OpenStreetMap included."),
"unclear": ("Unclear", "Whether the creator shares the track is not settled",
"No track is included until it is settled."),
}
SHIELD_STATUS = {
"use-real-logo": ("Logo in use", "The trail has a logo"),
+1 -1
View File
@@ -6,7 +6,7 @@
name = "Long Hikes"
# One line under the name: the home page <title> and the default meta description.
tagline = "Long-distance hiking trails of the United States and Canada, with their lines where they may be shared"
tagline = "Long-distance hiking trails of the United States and Canada, with their tracks where they may be shared"
# Absolute origin of the deployed site, without a trailing slash, for example
# "https://example.org". When set, every page gets a canonical link. Empty: none.
+6 -3
View File
@@ -150,7 +150,7 @@ class ExtraPagesTest(unittest.TestCase):
self.assertEqual(scale.count('class="len__mi"'), 3, rel)
self.assertNotIn('class="route-item"', read_out("routes/index.html"))
co = read_out("regions/us-co/index.html")
self.assertIn('<a href="/?region=US-CO&amp;line=1">With a line</a>', co)
self.assertIn('<a href="/?region=US-CO&amp;line=1">With a track</a>', co)
def test_routes_page_rows_carry_their_guides(self):
doc = read_out("routes/index.html")
@@ -188,8 +188,11 @@ class ExtraPagesTest(unittest.TestCase):
def test_sources_page_counts_measured_lines(self):
page = read_out("sources/index.html")
measured = sum(1 for r in self.records if r.get("verification", {}).get("verified"))
self.assertIn(f"<dt>Line measured</dt><dd>{measured}<", page)
self.assertIn(f"<dt>Track measured</dt><dd>{measured}<", page)
self.assertIn("<dt>Source status: OpenStreetMap only</dt>", page)
# a record's "none (no line included)" is shown in words, not as the raw value
self.assertIn("<td>None (no track included)</td>", page)
self.assertNotIn("none (no line included)", page)
self.assertEqual(page.count('<th scope="col">Trails and routes</th>'), 2)
self.assertNotRegex(page, r'<td><a href="/trails/[^"]+/">[^<]*</a>, <a')
@@ -200,7 +203,7 @@ class ExtraPagesTest(unittest.TestCase):
for lic in {r["source"]["licence"] for r in lines}:
n = sum(1 for r in lines if r["source"]["licence"] == lic)
label = html.escape(words.label(words.LICENCES, lic), quote=True)
self.assertIn(f"Lines licensed {label}: {n} record", page, lic)
self.assertIn(f"Tracks licensed {label}: {n} record", page, lic)
for name in ("trails.json", "overview.geojson"):
self.assertRegex(page, rf'<a href="/data/{re.escape(name)}">')
for name in ("all-gpx.zip", "all-geojson.zip"):
+8 -7
View File
@@ -167,7 +167,7 @@ class BuiltSiteTest(unittest.TestCase):
self.fail(f"{rec['id']}: {field} = {value!r} not on the page")
def test_partial_line_notice_and_row_note_for_exactly_the_partial_records(self):
"""Decided from the TOML alone: a line, measured, more than 15% from the published length."""
"""Decided from the TOML alone: a track, measured, more than 15% from the published length."""
expected = set()
for rec in self.records:
with open(os.path.join(ROOT, rec["id"], "trail.toml"), "rb") as f:
@@ -192,7 +192,7 @@ class BuiltSiteTest(unittest.TestCase):
short = rec["id"] in expected and rec["verification"]["difference_percent"] < 0
self.assertEqual("In the dataset, partial" in page, short, rec["id"])
if rec["derived"]["has_line"]:
self.assertRegex(page, r'<dt>Line</dt><dd><a href="#download">In the dataset', rec["id"])
self.assertRegex(page, r'<dt>Track</dt><dd><a href="#download">In the dataset', rec["id"])
rows_seen = set()
for path in html_files(OUT):
with open(path, encoding="utf-8") as f:
@@ -204,7 +204,7 @@ class BuiltSiteTest(unittest.TestCase):
self.assertEqual(row.count('class="entry__partial"'), 1 if tid in expected else 0, f"{rel}: {tid}")
if tid in expected:
rows_seen.add(tid)
self.assertRegex(page_text(row), r"Line measures [\d,.]+ km (of|against) [\d,]+ km published")
self.assertRegex(page_text(row), r"Track measures [\d,.]+ km (of|against) [\d,]+ km published")
entries = len(re.findall(r'<li class="entry" ', doc))
partial_rows = len(re.findall(r'<li class="entry" [^>]*data-partial="yes"', doc))
self.assertEqual(doc.count('class="entry__partial"'), partial_rows, rel)
@@ -268,15 +268,16 @@ class BuiltSiteTest(unittest.TestCase):
for rec in self.records:
page = self.pages[rec["id"]]
main = page_text(page[page.index('<div class="detail__main">'):page.index('<details class="rawrecord">')])
helper = "Where to ask for the line: a layer or relation page"
helper = "Where to ask for the track: a layer or relation page"
if rec["derived"]["has_line"]:
self.assertEqual(helper in main, bool(rec["source"].get("url")), rec["id"])
continue
self.assertNotIn(helper, main, rec["id"])
for gone in ("none (no line included)", "None (no line included)", "No line to measure", "None recorded"):
for gone in ("none (no line included)", "None (no line included)", "No line to measure", "None recorded",
"none (no track included)", "None (no track included)", "No track to measure"):
self.assertNotIn(gone, main, rec["id"])
for row in ("Coordinates", "May be passed on", "OpenStreetMap only", "Line source",
"Line in this dataset", "Why there is no line"):
for row in ("Coordinates", "May be passed on", "OpenStreetMap only", "Line source", "Track source",
"Line in this dataset", "Track in this dataset", "Why there is no line", "Why there is no track"):
self.assertNotIn(f"<dt>{row}</dt>", page, rec["id"])
if not rec["derived"]["files"].get("shield"):
logo = re.search(r'<h2 id="logo-title">Logo</h2>(.*?)</section>', page, re.S).group(1)