"""Two reference pages: the Glossary (/glossary/) and the Method (/method/). The glossary is read from glossary.toml. The method page is generated from the definitions in docs/schema.md and from the records: how many have each figure, and how the measured lengths of the tracks compare with the published ones. """ import collections import os import re import statistics from . import common, datafiles, elevation, facets, hike, pagekit, words from .markup import Markup, esc GLOSSARY = "/glossary/" METHOD = "/method/" # Glossary --------------------------------------------------------------------------- def terms(repo_root): return datafiles.glossary(repo_root) def terms_for(path, repo_root): """The glossary terms that point at a page: [(term id, term)].""" return [(t["id"], t["term"]) for t in terms(repo_root) if path in t.get("see", [])] def terms_nav(path, repo_root): """A line of links to the glossary entries for a page, or "".""" found = terms_for(path, repo_root) if not found: return "" links = " · ".join(f'{esc(t)}' for i, t in found) return f'' def glossary_page(repo_root, labels, site): """(title, description, body, terms) for /glossary/. labels: {path: link text} for every page built, so that a term links only to a page that exists.""" ts = terms(repo_root) if not ts: return None entries = "" for t in ts: see = [(p, labels[p]) for p in t.get("see", []) if p in labels] see_html = (" See: " + ", ".join(f'{esc(label)}' for p, label in see) + ".") if see else "" src = (f' Source: {esc(t["source_url"])}.') if t.get("source_url") else "" entries += (f'
A trail’s length here is the published figure for walking it from one end to the other, taking one branch at a split and leaving out side trails. For a loop reached by a stem that includes the stem both ways, and the record’s note gives the length with the stem counted once. Only the dataset’s test for the 50 mile floor counts distinct miles, so an out-and-back is judged one way. It is the figure the trail’s holder or author gives for that walk, and each record says where it comes from. A trail that cannot be walked from end to end today is not listed, but a ferry, shuttle or bus link that the holder or the route’s author names as the way through does not rule one out, and the track has a gap there. Every trail or route needs a published length; one with no stated length is not listed. The floor is 50 miles, or, for an author’s route that is short on miles, at least five days as its author gives the trip. The five days count only for an author’s route that is mostly cross-country or on hard terrain: a trail trip that a guidebook paces over five or more days does not qualify. The five days never replace a published length. A trail with its own name and its own published length is listed even where it lies on a longer listed trail, as the John Muir Trail lies on the Pacific Crest Trail; a guidebook’s cut of a longer trail is not. Nothing harder than Class 3 may be required, apart from a few short Class 4 scrambles. A route that needs a rope, a belay or rock-climbing skill is not listed, unless that section is optional and the record says so. The lists and pages show the length in miles with kilometres after.
Some holders also publish a larger figure for a whole system, or a planned total. A record keeps it apart as the whole system, with what it counts, and no list, length band or time estimate uses it. {n_system} of the {n} records have one. A trail that can be walked through but is partly unbuilt keeps the holder’s end-to-end route as its length and gives the built length beside it. {n_built} of the {n} records give one.
Where a track is included, its length is measured along the track as a geodesic length and compared with the published figure. The difference is the measured length minus the published length, as a percent of the published length. Track ends within 100 metres are joined, and the number of parts left is shown.
Across the {len(ver)} measured tracks, the middle difference is {mid:.1f} percent.
{pagekit.table(["Measured against published", "Tracks", "Share"], rows, caption="How the measured tracks compare", numeric=(1, 2))}A track that differs by more than {limit:.0f} percent needs a reason in its record, such as a trail that is partly unbuilt, a published length that is a planned one, or side trails counted in the figure. {gaps} of the {len(ver)} measured tracks give one. A track that covers only part of a trail is marked as partial, and its measured length is not its trail’s length.
{no_track} records have no track included. Their length is the published figure alone, and nothing has been measured.
{esc(_sentence(meaning.get("days", "").replace(" [fewest, most],", "")))} {stated} of the {n} records have a time a source states. For the others the page estimates it from the length, at {round(words.km_to_mi(a))} to {round(words.km_to_mi(b))} miles ({a} to {b} km) a day, or {round(words.km_to_mi(c))} to {round(words.km_to_mi(d_))} miles ({c} to {d_} km) a day where much of the trail is cross-country. An estimate is labelled as one wherever it is shown.
Climb is the total ascent along the track.{(" It uses " + esc(model) + ", sampled every " + words.fmt_int(spacing) + " metres, with " + esc(smoothing[:1].lower() + smoothing[1:]) + ".") if model and spacing else ""} {esc(limits_text)}
A climb is ranked or shown in a list only where its track covers the whole trail: a track that covers part of the trail, or more than the trail, would mislead.
{esc(_sentence(meaning.get("season", "")))} {esc(_sentence(meaning.get("high_point_m", "").split(" May be given")[0]))} Not every record has them, so a page built from them says how many records it covers.
Every fact is read on a page that the record names. See the sources, the record schema and the glossary.