From b1fd54f0f88fb308b629658515b33c2e96945789 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 9 Sep 2026 11:47:05 +0800 Subject: [PATCH] feat(junction): expose entry transition feasibility --- src/compile/junction-boundary-graph.js | 2 ++ test/junction-build-plan-counterexamples.js | 24 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index baabbf6..f230406 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -71,6 +71,8 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR armKey: item.armKey, outerWidthMeters, innerWidthMeters, + transitionMeters: Math.max(0, outer.stationMeters - inner.stationMeters), + transitionStatus: outer.stationMeters - inner.stationMeters > 1e-6 ? 'supported' : 'insufficient-source-length', outer, inner, edgeRefs: { diff --git a/test/junction-build-plan-counterexamples.js b/test/junction-build-plan-counterexamples.js index 8cdd38d..9e0a845 100644 --- a/test/junction-build-plan-counterexamples.js +++ b/test/junction-build-plan-counterexamples.js @@ -321,3 +321,27 @@ const collapsedGraph = JSON.parse(JSON.stringify(teeBoundaryGraph)); const collapsedSection = collapsedGraph.sections[0]; collapsedSection.inner.right = collapsedSection.inner.left; assert.equal(buildCoreClosure(tee.topology, collapsedGraph, point(0, 0)).reason, 'core-closure-invalid'); + +// Width corrections are represented by one shared trapezoid: the outer seam +// remains source width, the inner seam carries the edited width, and the +// transition distance is explicit for downstream validators and editors. +const tapered = topology('tapered', [ + { widthMeters: 10, line: [point(0, 0), point(0, 50)] }, + { widthMeters: 4, line: [point(0, 0), point(50, 0)] }, + { widthMeters: 4, line: [point(0, 0), point(-50, 0)] }, +]); +tapered.topology.carriageways[0].approach.sourceWidthMeters = 10; +tapered.topology.carriageways[0].approach.widthMeters = 6; +const taperedGraph = buildJunctionBoundaryGraph( + tapered.topology, + point(0, 0), + { outerRadiusFor: () => 30, innerRadiusFor: () => 10 }, + tapered.helpers, +); +const taperedSection = taperedGraph.sections.find( + (section) => section.carriagewayKey === tapered.topology.carriageways[0].key, +); +assert.equal(taperedSection.outerWidthMeters, 10); +assert.equal(taperedSection.innerWidthMeters, 6); +assert.ok(taperedSection.transitionMeters > 0); +assert.equal(taperedSection.transitionStatus, 'supported');