feat(junction): expose entry transition feasibility

This commit is contained in:
que01 committed 2026-09-09 11:47:05 +08:00
1 parent e5d805a369
commit b1fd54f0f8
2 files changed
+26

No files matched your search

+2
View File
@@ -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: {
@@ -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');