feat: measure junction shared seam errors

This commit is contained in:
que01 committed 2026-09-09 17:09:41 +08:00
1 parent 79f83412e6
commit 49212b3f34
4 files changed
+73 -9

No files matched your search

@@ -345,6 +345,18 @@ assert.equal(taperedSection.outerWidthMeters, 10);
assert.equal(taperedSection.innerWidthMeters, 6);
assert.ok(taperedSection.transitionMeters > 0);
assert.equal(taperedSection.transitionStatus, 'supported');
tapered.topology.carriageways[0].approach.transitionLengthMeters = 100;
const clippedTransitionGraph = buildJunctionBoundaryGraph(
tapered.topology,
point(0, 0),
{ outerRadiusFor: () => 30, innerRadiusFor: () => 10 },
tapered.helpers,
);
const clippedTransition = clippedTransitionGraph.sections.find(
(section) => section.carriagewayKey === tapered.topology.carriageways[0].key,
);
assert.equal(clippedTransition.inner.stationMeters, 0, 'overlong transitions must clamp to the source start');
assert.equal(clippedTransition.transitionStatus, 'insufficient-source-length');
const approachExclusion = [point(-6, 8), point(6, 8), point(6, 24), point(-6, 24), point(-6, 8)];
const graphWithApproachExclusion = buildJunctionBoundaryGraph(
@@ -578,6 +590,15 @@ assert.ok(
buildCoreClosure(tee.topology, teeBoundaryGraph, point(0, 0)).maxSharedSeamErrorMeters <= 0.01,
'shared core seams must remain within the 1 cm tolerance',
);
const offsetSeamGraph = JSON.parse(JSON.stringify(teeBoundaryGraph));
offsetSeamGraph.edges.find((edge) => edge.key === teeBoundaryGraph.sections[0].edgeRefs.inner).to[0] +=
2 / metersPerDegree;
const offsetSeam = buildCoreClosure(tee.topology, offsetSeamGraph, point(0, 0));
assert.ok(offsetSeam.maxSharedSeamErrorMeters > 1.9, 'shared seam metric must measure endpoint displacement in meters');
assert.ok(
offsetSeam.sharedSeamErrors.find((item) => item.carriagewayKey === teeBoundaryGraph.sections[0].carriagewayKey)
.errorMeters > 1.9,
);
const { complexJunctionMetrics, transitionLengthForCutback } = require('../src/compile/junction-metrics');
const transitionMetrics = complexJunctionMetrics({ coreRadiusMeters: 20, outerRadiusExtraMeters: 18 });