From 1767bf4789894bb9baa3a9856500a7eceb843265 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Fri, 20 Nov 2026 10:48:46 -0700 Subject: [PATCH] Reach a trail just outside a source outline that is drawn tighter than the range GMBA draws the Adirondacks by relief and its outline stops about 21 km east of Cranberry Lake, so the 80 km Cranberry Lake 50 loop, inside the Adirondack Park, was in no range. The cause is the source's outline, not the trail: an allow-list entry can now push a range's outline out (grow_km, with grow_clip to keep it off ground it should not reach), and the Adirondack Mountains use it so the loop is placed without a rule for one trail. Co-Authored-By: Claude Sonnet 5.5 --- tools/place_allowlist.toml | 8 +++++++- tools/place_trails.py | 21 ++++++++++++++++++++- tools/tests/test_place_trails.py | 12 ++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/tools/place_allowlist.toml b/tools/place_allowlist.toml index d7ce647..dd28190 100644 --- a/tools/place_allowlist.toml +++ b/tools/place_allowlist.toml @@ -15,7 +15,8 @@ # great system, where it has one: at most two kept levels apply to any one trail, a named # range and its system, so a range's within never names another named range), where # (optional state or province codes that replace the tool's own reading, which comes from -# web/place-bounds.toml and overlaps along borders). +# web/place-bounds.toml and overlaps along borders), grow_km and grow_clip (optional, see +# the Adirondack Mountains). # # The `where` lines are set by hand where the boxes overlap a neighbour along a border. # @@ -92,6 +93,11 @@ gmba_id = "12552" slug = "adirondack-mountains" name = "Adirondack Mountains" where = ["NY"] +# GMBA draws the Adirondacks by relief, and its outline stops about 21 km east of Cranberry +# Lake, which is inside the Adirondack Park. The outline is pushed out 25 km, clipped so it +# does not run east of Lake Champlain into Vermont. +grow_km = 25 +grow_clip = [-75.4, 43.0, -73.4, 45.0] [[range]] gmba_id = "12104" diff --git a/tools/place_trails.py b/tools/place_trails.py index 3bbf844..db8b93a 100644 --- a/tools/place_trails.py +++ b/tools/place_trails.py @@ -498,6 +498,22 @@ def apply_denylist(outlines, deny=None): if (o.kind, o.source, str(o.source_id)) not in {(k, s, str(i)) for (k, s, i) in deny}] +def grow_outline(geom, km, clip=None): + """The outline pushed out by `km` on every side (and clipped to the box [w, s, e, n] + where one is given); the original is always kept whole. For a range whose published + outline is tighter than the range as hikers know it. Each use is a reviewed entry in + the allow-list (grow_km, grow_clip) with its reason.""" + import math + shapely = _need_shapely() + k = math.cos(math.radians(geom.centroid.y)) + fwd = lambda c: c * [k, 1.0] + back = lambda c: c / [k, 1.0] + grown = shapely.transform(shapely.transform(geom, fwd).buffer(km / 111.32), back) + if clip: + grown = grown.intersection(shapely.geometry.box(*clip)) + return _union_geoms([geom, grown]) + + 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.""" @@ -568,8 +584,11 @@ def catalogue(cache, allowlist=None): for g in gmba_ranges(cache): spec = wanted.get(g["gmba_id"]) if spec: + geom = g["geometry"] + if spec.get("grow_km"): + geom = grow_outline(geom, float(spec["grow_km"]), spec.get("grow_clip")) out.append(Outline("range", "gmba-v2", g["gmba_id"], - spec.get("name") or g["name"], [], g["geometry"], + spec.get("name") or g["name"], [], geom, slug=spec.get("slug") or "", within=tuple(spec.get("within") or ()), path=g["path"], where_hand=tuple(spec.get("where") or ()))) diff --git a/tools/tests/test_place_trails.py b/tools/tests/test_place_trails.py index ab3ce08..cbeaca5 100644 --- a/tools/tests/test_place_trails.py +++ b/tools/tests/test_place_trails.py @@ -260,6 +260,18 @@ class ProposalTest(unittest.TestCase): self.assertEqual(P._clean_cpcad_name("Killarney Lakelands And Headwaters Provincial Park"), "Killarney Lakelands and Headwaters Provincial Park") + def test_a_grown_outline_reaches_a_track_just_outside_it_but_only_inside_its_clip(self): + # about 20 km east of the park's edge (-109.0): a track the source's outline missed + east = LineString([(-108.75, 43.2), (-108.75, 43.29)]) + self.assertEqual(P.propose([rec("a", ["WY"], east)], [self.park]).per_trail["a"], []) + grown = P.grow_outline(self.park.geometry, 25) + self.assertGreater(grown.area, self.park.geometry.area) + self.assertTrue(grown.contains(east)) + # a clip keeps the growth off ground the owner did not mean: nothing east of -108.9 + clipped = P.grow_outline(self.park.geometry, 25, clip=[-111.0, 42.0, -108.9, 45.0]) + self.assertFalse(clipped.intersects(east)) + self.assertTrue(clipped.contains(self.park.geometry)) + 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"])