feat(junction): derive complex approach boundary sections

This commit is contained in:
que01 committed 2026-09-08 18:02:24 +08:00
1 parent 4de971ce68
commit b4abfdb870
4 files changed
+138 -12

No files matched your search

@@ -4,6 +4,7 @@
const assert = require('assert/strict');
const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('../src/compile/junction-build-plan');
const { buildJunctionBoundaryGraph } = require('../src/compile/junction-boundary-graph');
const { classifyJunctionShape } = require('../src/compile/complex-junction');
const metersPerDegree = 111320;
@@ -90,6 +91,16 @@ assert.ok(
(item) => item.entrySection.boundaryEndpoints.near.left[0] !== item.entrySection.boundaryEndpoints.near.right[0],
),
);
const dividedBoundaryGraph = buildJunctionBoundaryGraph(
divided.topology,
point(0, 0),
{ outerRadiusFor: () => 25, innerRadiusFor: () => 10 },
divided.helpers,
);
assert.equal(dividedBoundaryGraph.status, 'entry-sections-only');
assert.equal(dividedBoundaryGraph.sections.length, divided.topology.carriageways.length);
assert.equal(new Set(dividedBoundaryGraph.sections.map((section) => section.carriagewayKey)).size, 4);
assert.equal(dividedBoundaryGraph.edges.length, dividedBoundaryGraph.sections.length * 4);
// A T junction has explicit, source-stable entry sections. Closure edges are a
// later BoundaryGraph concern and must not be fabricated by topology parsing.
@@ -135,6 +146,16 @@ assert.notEqual(
curvedShort.topology.carriageways[0].entrySection.nearTangent,
curvedShort.topology.carriageways[0].entrySection.farTangent,
);
const curvedBoundaryGraph = buildJunctionBoundaryGraph(
curvedShort.topology,
point(0, 0),
{ outerRadiusFor: () => 8, innerRadiusFor: () => 2 },
curvedShort.helpers,
);
const curvedSection = curvedBoundaryGraph.sections.find(
(section) => section.carriagewayKey === curvedShort.topology.carriageways[0].key,
);
assert.notEqual(curvedSection.outer.tangent, curvedSection.inner.tangent);
const curvedBoundaryLine = [point(0, 0), point(0, 5), point(10, 10)];
const curvedBoundaryStation = stationAtDistanceFrom(curvedBoundaryLine, point(0, 0), 9, {