fix: pave complex junction crossings

This commit is contained in:
que01 committed 2026-09-14 15:54:39 +08:00
1 parent 062f20f34c
commit 914adcc4e6
2 files changed
+95

No files matched your search

+26
View File
@@ -171,4 +171,30 @@ assert.equal(new Set(solvedContacts.greenRing.slice(0, -1).map((p) => p.join(','
assert.deepEqual(points, island.properties.contact_points);
}
assert.equal(geometry.diagnostics.filter((d) => d.rule === 'complex-junction-island-infeasible').length, 0);
const pavementByCrossing = new Map(
geometry.roadSurface.features
.filter((feature) => feature.properties.kind === 'complex-crosswalk-pavement')
.map((feature) => [feature.properties.crossing_key, feature]),
);
const ringArea = (ring) =>
Math.abs(
ring.slice(1).reduce((sum, point, index) => sum + ring[index][0] * point[1] - point[0] * ring[index][1], 0) / 2,
);
const residualArea = (multiPolygon) =>
multiPolygon.reduce(
(sum, polygon) =>
sum + ringArea(polygon[0]) - polygon.slice(1).reduce((holes, hole) => holes + ringArea(hole), 0),
0,
);
for (const stripe of geometry.crosswalks.features.filter(
(feature) => feature.properties.cluster_id === 'four-node-contact-regression',
)) {
const pavement = pavementByCrossing.get(stripe.properties.crossing_key);
assert.ok(pavement, `${stripe.properties.crossing_key} must publish crossing pavement`);
assert.ok(
residualArea(clipping.difference(stripe.geometry.coordinates, pavement.geometry.coordinates)) < 1e-10,
`${stripe.properties.native_id} must remain fully on its matching pavement`,
);
}
}