fix: resolve multi-carriageway complex cores
This commit is contained in:
1 parent
eaafcd85da
commit
14930c5dd6
1 file changed
+12
-3
@@ -220,11 +220,20 @@ function coordinateDistanceMeters(first, second) {
|
|||||||
function buildCoreClosure(topology, graph, center) {
|
function buildCoreClosure(topology, graph, center) {
|
||||||
let coreSections = graph.sections;
|
let coreSections = graph.sections;
|
||||||
if (topology.arms.some((arm) => arm.members.length !== 1)) {
|
if (topology.arms.some((arm) => arm.members.length !== 1)) {
|
||||||
if (topology.arms.length !== 4) return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };
|
if (topology.arms.length < 4 || topology.arms.length > 6)
|
||||||
coreSections = topology.arms.map((arm) =>
|
return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };
|
||||||
|
coreSections = topology.arms.map(
|
||||||
|
(arm) =>
|
||||||
graph.sections
|
graph.sections
|
||||||
.filter((section) => section.armKey === arm.key && section.ringStatus === 'supported')
|
.filter((section) => section.armKey === arm.key && section.ringStatus === 'supported')
|
||||||
.sort((a, b) => a.carriagewayKey.localeCompare(b.carriagewayKey))[0],
|
.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))
|
if (coreSections.some((section) => !section))
|
||||||
return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };
|
return { status: 'unsupported', reason: 'parallel-carriageway-closure-unresolved' };
|
||||||
|
|||||||
Reference in new issue
Block a user