feat(junction): close verified complex cores

This commit is contained in:
que01 committed 2026-09-09 09:15:58 +08:00
1 parent b4abfdb870
commit 88d8b841e5
5 files changed
+97 -25

No files matched your search

+11 -2
View File
@@ -91,7 +91,16 @@ const complexGeometry = compiler.nativeRoad.compileGeometry(
const complexCore = complexGeometry.roadSurface.features.find(
(feature) => feature.properties?.kind === 'complex-core' && feature.properties?.cluster_id === 'fixture-five-arm',
);
assert.equal(complexCore?.properties?.shape_kind, 'multi-arm');
assert.equal(complexCore?.properties?.arm_count, 5);
// This fixture contains multiple source carriageways within several arms. The
// compiler must retain those independent sections rather than filling their
// unknown interstitial areas with a synthetic core.
assert.equal(complexCore, undefined);
assert.ok(
complexGeometry.diagnostics.some(
(item) =>
item.rule === 'complex-junction-core-closure-unsupported' &&
item.subjectId === 'junction-cluster:fixture-five-arm',
),
);
assert.ok(complexGeometry.roadSurface.features.some((feature) => feature.properties?.kind === 'complex-approach'));
console.log('road compiler package tests passed');
+15 -1
View File
@@ -4,7 +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 { buildJunctionBoundaryGraph, buildCoreClosure } = require('../src/compile/junction-boundary-graph');
const { classifyJunctionShape } = require('../src/compile/complex-junction');
const metersPerDegree = 111320;
@@ -101,6 +101,10 @@ 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);
assert.equal(
buildCoreClosure(divided.topology, dividedBoundaryGraph, point(0, 0)).reason,
'parallel-carriageway-closure-unresolved',
);
// A T junction has explicit, source-stable entry sections. Closure edges are a
// later BoundaryGraph concern and must not be fabricated by topology parsing.
@@ -112,6 +116,16 @@ const tee = topology('tee', [
assert.equal(tee.topology.arms.length, 3);
assert.equal(classifyJunctionShape(tee.topology.arms, point(0, 0), tee.helpers).kind, 't-junction');
assert.ok(tee.topology.carriageways.every((item) => item.entrySection.feasibility === 'supported'));
const teeBoundaryGraph = buildJunctionBoundaryGraph(
tee.topology,
point(0, 0),
{ outerRadiusFor: () => 30, innerRadiusFor: () => 10 },
tee.helpers,
);
const teeCore = buildCoreClosure(tee.topology, teeBoundaryGraph, point(0, 0));
assert.equal(teeCore.status, 'supported');
assert.equal(teeCore.sharedEdgeRefs.length, teeBoundaryGraph.sections.length);
assert.ok(teeCore.ring.every((coordinate) => coordinate.every(Number.isFinite)));
// Offset and unequal-width approaches preserve individual source sections and
// local section tangents rather than a single arm envelope.