fix: resolve multi-carriageway complex cores

This commit is contained in:
que01 committed 2026-09-11 13:11:08 +08:00
1 parent eaafcd85da
commit 14930c5dd6
1 file changed
+14 -5
+14 -5
View File
@@ -220,11 +220,20 @@ function coordinateDistanceMeters(first, second) {
function buildCoreClosure(topology, graph, center) {
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 (topology.arms.length < 4 || topology.arms.length > 6)
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) => {
const distance = (section) => {
const x = (section.inner.left[0] + section.inner.right[0]) / 2 - center[0];
const y = (section.inner.left[1] + section.inner.right[1]) / 2 - center[1];
return x * x + y * y;
};
return distance(a) - distance(b) || a.carriagewayKey.localeCompare(b.carriagewayKey);
})[0],
);
if (coreSections.some((section) => !section))
return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };