diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index 1aa8193..0331147 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -218,11 +218,20 @@ function coordinateDistanceMeters(first, second) { // source carriageway. Its shared entry seams are the sections' `inner` edges; // every remaining edge is an explicit closure between adjacent arms. function buildCoreClosure(topology, graph, center) { - if (topology.arms.some((arm) => arm.members.length !== 1)) - return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' }; - if (graph.sections.length < 3 || graph.sections.length > 6) + let coreSections = graph.sections; + if (topology.arms.some((arm) => arm.members.length !== 1)) { + if (topology.arms.length !== 4) return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' }; + coreSections = topology.arms.map((arm) => + graph.sections + .filter((section) => section.armKey === arm.key && section.ringStatus === 'supported') + .sort((a, b) => a.carriagewayKey.localeCompare(b.carriagewayKey))[0], + ); + if (coreSections.some((section) => !section)) + return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' }; + } + if (coreSections.length < 3 || coreSections.length > 6) return { status: 'unsupported', reason: 'unsupported-arm-count' }; - const points = graph.sections + const points = coreSections .flatMap((section) => [ { point: section.inner.left, edgeRef: section.edgeRefs.inner }, { point: section.inner.right, edgeRef: section.edgeRefs.inner },