Keep Gateway Arch National Park out of the places, with a deny-list for such cases

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 10:40:44 -07:00
1 parent c704139e5b
commit e42398589a
2 files changed
+23 -1

No files matched your search

+16 -1
View File
@@ -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 = {}
+7
View File
@@ -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"])