Open a place page's map on the place, not on the extent of its trails

Utah's map opened on the whole country because the American Discovery Trail
crosses it. Every state, province and group page now opens on its own box
(web/place-bounds.toml, Natural Earth, public domain); tracks that run past it
are still drawn in full and leave the opening view.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-18 17:26:45 -07:00
1 parent 9703848d95
commit cfa8026300
6 files changed
+252 -11

No files matched your search

+10 -3
View File
@@ -6,7 +6,7 @@ The section is called Places; its pages keep their /regions/ URLs.
"""
import collections
from . import browse, common, facets, home, summary, words
from . import bounds, browse, common, facets, home, summary, words
from .markup import Markup, esc
@@ -33,6 +33,13 @@ def collect_regions(records):
return by_slug, across
def group_box(g, by_slug):
"""The ground a group page opens on: the union of the boxes of its members that have trails,
or None when one of them has no box (the map then opens on its trails)."""
keys = next(k for x, _, k in facets.PLACE_GROUPS if x == g)
return bounds.union([k for k in keys if k.lower() in by_slug])
def group_records(records, group):
return [r for r in records if group in facets.place_groups(r)]
@@ -153,7 +160,7 @@ def group_page(g, records, site):
</div></header>
</div></div>
<div class="container section place">
{home.browse_view(home.listing(recs, top=2, where="g:" + g), home.overview_map(recs, f"Map of the trails in {name}"),
{home.browse_view(home.listing(recs, top=2, where="g:" + g), home.overview_map(recs, f"Map of the trails in {name}", place=group_box(g, by_slug)),
about=f"{summary.facts(recs, records)}{summary.details(recs)}", about_title=f"About the trails in {name}")}
{nav}
</div>"""
@@ -206,7 +213,7 @@ def region_page(slug, records, site, facet_pages=()):
</div></header>
</div></div>
<div class="container section place">
{home.browse_view(home.listing(recs, top=2, where=""), home.overview_map(recs, f"Map of the trails in {info['name']}"),
{home.browse_view(home.listing(recs, top=2, where=""), home.overview_map(recs, f"Map of the trails in {info['name']}", place=bounds.place_box(key)),
about=f"{summary.facts(recs, records)}{summary.details(recs)}",
about_title=f"About the trails in {info['name']}")}
{nav}