From e42398589a85fdc3ee8c2503d9822e55a3c3cded Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Fri, 20 Nov 2026 10:40:44 -0700 Subject: [PATCH] Keep Gateway Arch National Park out of the places, with a deny-list for such cases Co-Authored-By: Claude Sonnet 5.5 --- tools/place_trails.py | 17 ++++++++++++++++- tools/tests/test_place_trails.py | 7 +++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/place_trails.py b/tools/place_trails.py index 754c3f5..562c47d 100644 --- a/tools/place_trails.py +++ b/tools/place_trails.py @@ -471,6 +471,21 @@ def assign_slugs(outlines): return outlines +# Places the source offers that are never listed, with the reason beside each. Keyed by +# (kind, source, source id). A trail that merely passes through one is not "in" it in the +# way a place page means. +DENY = { + ("park", "nps", "JEFF"): "Gateway Arch National Park is the memorial grounds in " + "downtown St. Louis; a trail crossing it is an urban pass-through", +} + + +def apply_denylist(outlines, deny=None): + deny = DENY if deny is None else deny + return [o for o in outlines + if (o.kind, o.source, str(o.source_id)) not in {(k, s, str(i)) for (k, s, i) in deny}] + + def merge_same_name(outlines): """One name within a kind and source is one place: the outlines are unioned and the place carries every id. The source lists some ranges twice under different ids.""" @@ -546,7 +561,7 @@ def catalogue(cache, allowlist=None): slug=spec.get("slug") or "", within=tuple(spec.get("within") or ()), path=g["path"], where_hand=tuple(spec.get("where") or ()))) - return assign_slugs(merge_same_name(out)) + return assign_slugs(merge_same_name(apply_denylist(out))) _GMBA_CACHE = {} diff --git a/tools/tests/test_place_trails.py b/tools/tests/test_place_trails.py index 99644c5..d072b2e 100644 --- a/tools/tests/test_place_trails.py +++ b/tools/tests/test_place_trails.py @@ -238,6 +238,13 @@ class ProposalTest(unittest.TestCase): stated = {("park", "alpha"): {"a", "b", "z"}, ("wilderness", "alpha-wilderness"): {"a", "b"}} self.assertEqual(P.doubled_places(stated, names), set()) + def test_a_denied_place_is_not_in_the_catalogue(self): + arch = outline("park", "JEFF", "Gateway Arch National Park", self.park.geometry) + keep = outline("park", "YOSE", "Yosemite National Park", self.range.geometry) + self.assertEqual([o.source_id for o in P.apply_denylist([arch, keep])], ["YOSE"]) + self.assertTrue(all(reason.strip() for reason in P.DENY.values())) + self.assertIn(("park", "nps", "JEFF"), P.DENY) + def test_a_slug_collision_inside_a_kind_gets_the_state_code(self): a = outline("park", "P1", "Glacier", self.park.geometry, slug=None, hint=["MT"]) b = outline("park", "P2", "Glacier", self.range.geometry, slug=None, hint=["BC"])