From a22319a1495f9f7e83e92b7eb907659706aa6d13 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 9 Sep 2026 12:01:16 +0800 Subject: [PATCH] fix(junction): protect entry surfaces from exclusion regions --- src/compile/complex-junction.js | 13 +++++++++++++ src/compile/junction-boundary-graph.js | 4 ++++ test/junction-build-plan-counterexamples.js | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index 28a5063..1c24b30 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -123,6 +123,19 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { // carriageway's outer transition, leaving neighboring arms untouched. A // collapsed handoff is reported and omitted rather than publishing a // zero-area trapezoid that downstream layers could mistake for pavement. + if (section.exclusionStatus !== 'clear') { + transitionDiagnostics.push( + helpers.diagnostic( + 'warning', + `carriageway:${item.key}`, + item.approach.roadIds.map(String), + 'complex-junction-entry-overlaps-known-region', + '该进口过渡区域侵入已知排除区域,已省略该进口面以保留来源区域。', + section.inner.point, + ), + ); + continue; + } if (section.transitionStatus !== 'supported') { transitionDiagnostics.push( helpers.diagnostic( diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index f230406..78a1658 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -65,9 +65,13 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR const outer = sectionAt(item, outerRadius, center, outerWidthMeters, helpers); const inner = sectionAt(item, innerRadius, center, innerWidthMeters, helpers); const key = `boundary:${item.key}`; + const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right]; + const exclusion = exclusionRegions.find((region) => ringsOverlap(region.ring, sectionRing)); return { key, carriagewayKey: item.key, + exclusionStatus: exclusion ? 'overlaps-known-region' : 'clear', + ...(exclusion ? { exclusionRegionId: String(exclusion.id ?? '') } : {}), armKey: item.armKey, outerWidthMeters, innerWidthMeters, diff --git a/test/junction-build-plan-counterexamples.js b/test/junction-build-plan-counterexamples.js index 9e0a845..5303020 100644 --- a/test/junction-build-plan-counterexamples.js +++ b/test/junction-build-plan-counterexamples.js @@ -345,3 +345,17 @@ assert.equal(taperedSection.outerWidthMeters, 10); assert.equal(taperedSection.innerWidthMeters, 6); assert.ok(taperedSection.transitionMeters > 0); assert.equal(taperedSection.transitionStatus, 'supported'); + +const approachExclusion = [point(-6, 8), point(6, 8), point(6, 24), point(-6, 24), point(-6, 8)]; +const graphWithApproachExclusion = buildJunctionBoundaryGraph( + tee.topology, + point(0, 0), + { outerRadiusFor: () => 30, innerRadiusFor: () => 10 }, + tee.helpers, + [{ id: 'island:approach', ring: approachExclusion }], +); +const excludedSection = graphWithApproachExclusion.sections.find( + (section) => section.outer.point[1] > section.outer.point[1] - 1, +); +assert.equal(excludedSection.exclusionStatus, 'overlaps-known-region'); +assert.equal(excludedSection.exclusionRegionId, 'island:approach');