feat: establish junction region geometry baseline
This commit is contained in:
1 parent
de97600fe8
commit
76f81d024a
14 files changed
+287
-11
No files matched your search
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
function buildPedestrianIsland({ key, ring, crossingKeys, provenance = 'inferred' }) {
|
||||
if (!key || !Array.isArray(ring) || ring.length < 4) return null;
|
||||
const adjacentCrossings = [...new Set(crossingKeys || [])];
|
||||
if (adjacentCrossings.length !== 3) return null;
|
||||
return { key, ring, adjacentCrossings, provenance };
|
||||
}
|
||||
|
||||
function validateFacilityComposition(island, crossings) {
|
||||
if (!island || island.adjacentCrossings.length !== 3) return { valid: false, reason: 'island-needs-three-crossings' };
|
||||
const crossingMap = new Map((crossings || []).map((crossing) => [crossing.key, crossing]));
|
||||
const linked = island.adjacentCrossings.map((key) => crossingMap.get(key));
|
||||
if (linked.some((crossing) => !crossing)) return { valid: false, reason: 'crossing-reference-missing' };
|
||||
if (linked.some((crossing) => !crossing.fromBoundary || !crossing.toBoundary))
|
||||
return { valid: false, reason: 'crossing-boundary-missing' };
|
||||
return { valid: true, reason: null };
|
||||
}
|
||||
|
||||
module.exports = { buildPedestrianIsland, validateFacilityComposition };
|
||||
Reference in new issue
Block a user