feat(junction): validate entry ring geometry
This commit is contained in:
1 parent
a90826efed
commit
a37c707188
3 files changed
+32
-1
No files matched your search
@@ -123,6 +123,19 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
// carriageway's outer transition, leaving neighboring arms untouched. A
|
// carriageway's outer transition, leaving neighboring arms untouched. A
|
||||||
// collapsed handoff is reported and omitted rather than publishing a
|
// collapsed handoff is reported and omitted rather than publishing a
|
||||||
// zero-area trapezoid that downstream layers could mistake for pavement.
|
// zero-area trapezoid that downstream layers could mistake for pavement.
|
||||||
|
if (section.ringStatus !== 'supported') {
|
||||||
|
transitionDiagnostics.push(
|
||||||
|
helpers.diagnostic(
|
||||||
|
'warning',
|
||||||
|
`carriageway:${item.key}`,
|
||||||
|
item.approach.roadIds.map(String),
|
||||||
|
'complex-junction-entry-ring-invalid',
|
||||||
|
'该进口边界无法形成有效道路面,已省略退化或自交几何。',
|
||||||
|
section.inner.point,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (section.exclusionStatus !== 'clear') {
|
if (section.exclusionStatus !== 'clear') {
|
||||||
transitionDiagnostics.push(
|
transitionDiagnostics.push(
|
||||||
helpers.diagnostic(
|
helpers.diagnostic(
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
|||||||
const key = `boundary:${item.key}`;
|
const key = `boundary:${item.key}`;
|
||||||
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
||||||
const exclusion = exclusionRegions.find((region) => ringsOverlap(region.ring, sectionRing));
|
const exclusion = exclusionRegions.find((region) => ringsOverlap(region.ring, sectionRing));
|
||||||
|
const ringFinite = sectionRing.every((coordinate) => coordinate?.every(Number.isFinite));
|
||||||
|
const ringArea = ringFinite ? Math.abs(signedArea(sectionRing)) : 0;
|
||||||
|
const ringStatus = !ringFinite || ringArea < 1e-14 || ringSelfIntersects(sectionRing) ? 'invalid' : 'supported';
|
||||||
return {
|
return {
|
||||||
key,
|
key,
|
||||||
carriagewayKey: item.key,
|
carriagewayKey: item.key,
|
||||||
@@ -79,7 +82,8 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
|||||||
transitionStatus: outer.stationMeters - inner.stationMeters > 1e-6 ? 'supported' : 'insufficient-source-length',
|
transitionStatus: outer.stationMeters - inner.stationMeters > 1e-6 ? 'supported' : 'insufficient-source-length',
|
||||||
outer,
|
outer,
|
||||||
inner,
|
inner,
|
||||||
ring: [outer.right, inner.right, inner.left, outer.left, outer.right],
|
ring: sectionRing,
|
||||||
|
ringStatus,
|
||||||
edgeRefs: {
|
edgeRefs: {
|
||||||
left: `${key}:left`,
|
left: `${key}:left`,
|
||||||
right: `${key}:right`,
|
right: `${key}:right`,
|
||||||
|
|||||||
@@ -559,3 +559,17 @@ assert.deepEqual(
|
|||||||
],
|
],
|
||||||
'BoundaryGraph must expose the canonical entry ring consumed by compilation',
|
'BoundaryGraph must expose the canonical entry ring consumed by compilation',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.ok(teeBoundaryGraph.sections.every((section) => section.ringStatus === 'supported'));
|
||||||
|
const zeroWidth = topology('zero-width-entry', [
|
||||||
|
{ widthMeters: 0, line: [point(0, 0), point(0, 40)] },
|
||||||
|
{ widthMeters: 5, line: [point(0, 0), point(40, 0)] },
|
||||||
|
{ widthMeters: 5, line: [point(0, 0), point(-40, 0)] },
|
||||||
|
]);
|
||||||
|
const zeroWidthGraph = buildJunctionBoundaryGraph(
|
||||||
|
zeroWidth.topology,
|
||||||
|
point(0, 0),
|
||||||
|
{ outerRadiusFor: () => 24, innerRadiusFor: () => 10 },
|
||||||
|
zeroWidth.helpers,
|
||||||
|
);
|
||||||
|
assert.equal(zeroWidthGraph.sections[0].ringStatus, 'invalid');
|
||||||
Reference in new issue
Block a user