fix: pave complex junction crossings
This commit is contained in:
1 parent
062f20f34c
commit
914adcc4e6
2 files changed
+95
No files matched your search
@@ -84,6 +84,10 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
const boundaryParts = [];
|
const boundaryParts = [];
|
||||||
const transitionDiagnostics = [];
|
const transitionDiagnostics = [];
|
||||||
const crosswalks = [];
|
const crosswalks = [];
|
||||||
|
// A crossing is a connection across a paved carriageway, never decoration
|
||||||
|
// over empty ground. Keep its complete rectangle as an explicit road-surface
|
||||||
|
// component so core closure gaps cannot show through the white stripes.
|
||||||
|
const crosswalkPavements = [];
|
||||||
const stopLines = [];
|
const stopLines = [];
|
||||||
const islands = [];
|
const islands = [];
|
||||||
const crossingControls = helpers.clusterCrossingControls || new Map();
|
const crossingControls = helpers.clusterCrossingControls || new Map();
|
||||||
@@ -340,6 +344,28 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
arm.crosswalkFrame.endpoints = endpoints;
|
arm.crosswalkFrame.endpoints = endpoints;
|
||||||
arm.crosswalkFrame.spanMeters = usableSpan;
|
arm.crosswalkFrame.spanMeters = usableSpan;
|
||||||
arm.crosswalkFrame.roadEdgeInsetMeters = roadEdgeInset;
|
arm.crosswalkFrame.roadEdgeInsetMeters = roadEdgeInset;
|
||||||
|
const pavementRing = [
|
||||||
|
helpers.offsetCoordinate(endpoints[0], crossingHeading, -groupDepth / 2),
|
||||||
|
helpers.offsetCoordinate(endpoints[1], crossingHeading, -groupDepth / 2),
|
||||||
|
helpers.offsetCoordinate(endpoints[1], crossingHeading, groupDepth / 2),
|
||||||
|
helpers.offsetCoordinate(endpoints[0], crossingHeading, groupDepth / 2),
|
||||||
|
helpers.offsetCoordinate(endpoints[0], crossingHeading, -groupDepth / 2),
|
||||||
|
];
|
||||||
|
crosswalkPavements.push({
|
||||||
|
type: 'Feature',
|
||||||
|
properties: {
|
||||||
|
native_id: `complex-crosswalk-pavement:${cluster.id}:${item.approach.segmentId}`,
|
||||||
|
object_key: `crossing:${arm.key}`,
|
||||||
|
crossing_key: `crossing:${arm.key}`,
|
||||||
|
arm_key: arm.key,
|
||||||
|
cluster_id: cluster.id,
|
||||||
|
kind: 'complex-crosswalk-pavement',
|
||||||
|
complex_part: 'crosswalk-pavement',
|
||||||
|
road_id: item.approach.roadIds[0],
|
||||||
|
provenance: 'native-road-complex-junction-crosswalk-pavement/v1',
|
||||||
|
},
|
||||||
|
geometry: { type: 'Polygon', coordinates: [pavementRing] },
|
||||||
|
});
|
||||||
for (let stripe = 0; stripe < stripeCount; stripe += 1) {
|
for (let stripe = 0; stripe < stripeCount; stripe += 1) {
|
||||||
const along = layout.centers[stripe];
|
const along = layout.centers[stripe];
|
||||||
const centerPoint = helpers.offsetCoordinate(endpoints[0], bearing(...endpoints), along);
|
const centerPoint = helpers.offsetCoordinate(endpoints[0], bearing(...endpoints), along);
|
||||||
@@ -606,6 +632,48 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
const diagonalHeading = outwardHeading;
|
const diagonalHeading = outwardHeading;
|
||||||
const diagonalCenter = helpers.offsetCoordinate(outerMidpoint, outwardHeading, diagonalDepth / 2);
|
const diagonalCenter = helpers.offsetCoordinate(outerMidpoint, outwardHeading, diagonalDepth / 2);
|
||||||
const diagonalSpan = COMPLEX_CROSSWALK_DEPTH_METERS;
|
const diagonalSpan = COMPLEX_CROSSWALK_DEPTH_METERS;
|
||||||
|
const diagonalPavementRing = [
|
||||||
|
helpers.offsetCoordinate(
|
||||||
|
helpers.offsetCoordinate(diagonalCenter, diagonalHeading + 90, -diagonalSpan / 2),
|
||||||
|
diagonalHeading,
|
||||||
|
-diagonalDepth / 2,
|
||||||
|
),
|
||||||
|
helpers.offsetCoordinate(
|
||||||
|
helpers.offsetCoordinate(diagonalCenter, diagonalHeading + 90, diagonalSpan / 2),
|
||||||
|
diagonalHeading,
|
||||||
|
-diagonalDepth / 2,
|
||||||
|
),
|
||||||
|
helpers.offsetCoordinate(
|
||||||
|
helpers.offsetCoordinate(diagonalCenter, diagonalHeading + 90, diagonalSpan / 2),
|
||||||
|
diagonalHeading,
|
||||||
|
diagonalDepth / 2,
|
||||||
|
),
|
||||||
|
helpers.offsetCoordinate(
|
||||||
|
helpers.offsetCoordinate(diagonalCenter, diagonalHeading + 90, -diagonalSpan / 2),
|
||||||
|
diagonalHeading,
|
||||||
|
diagonalDepth / 2,
|
||||||
|
),
|
||||||
|
helpers.offsetCoordinate(
|
||||||
|
helpers.offsetCoordinate(diagonalCenter, diagonalHeading + 90, -diagonalSpan / 2),
|
||||||
|
diagonalHeading,
|
||||||
|
-diagonalDepth / 2,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
crosswalkPavements.push({
|
||||||
|
type: 'Feature',
|
||||||
|
properties: {
|
||||||
|
native_id: `complex-corner-crosswalk-pavement:${cluster.id}:${index + 1}`,
|
||||||
|
object_key: `crossing:corner:${first.cornerKey}`,
|
||||||
|
crossing_key: `crossing:corner:${first.cornerKey}`,
|
||||||
|
island_key: `island:inferred/${first.cornerKey}`,
|
||||||
|
cluster_id: cluster.id,
|
||||||
|
kind: 'complex-crosswalk-pavement',
|
||||||
|
complex_part: 'crosswalk-pavement',
|
||||||
|
corner_key: first.cornerKey,
|
||||||
|
provenance: 'native-road-complex-junction-crosswalk-pavement/v1',
|
||||||
|
},
|
||||||
|
geometry: { type: 'Polygon', coordinates: [diagonalPavementRing] },
|
||||||
|
});
|
||||||
const layout = stripeLayout(diagonalDepth);
|
const layout = stripeLayout(diagonalDepth);
|
||||||
const stripeCount = layout.centers.length;
|
const stripeCount = layout.centers.length;
|
||||||
const stripeSpacing = layout.pitch;
|
const stripeSpacing = layout.pitch;
|
||||||
@@ -810,6 +878,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
// Corner fills come last so they overlay the rectangular carriageway ends
|
// Corner fills come last so they overlay the rectangular carriageway ends
|
||||||
// they are smoothing; they never replace an OSM-derived road surface.
|
// they are smoothing; they never replace an OSM-derived road surface.
|
||||||
features.push(...cornerFills);
|
features.push(...cornerFills);
|
||||||
|
features.push(...crosswalkPavements);
|
||||||
if (coreFeature) features.push(coreFeature);
|
if (coreFeature) features.push(coreFeature);
|
||||||
// `coreRadiusMeters` is only consulted when there is no reference geometry.
|
// `coreRadiusMeters` is only consulted when there is no reference geometry.
|
||||||
// Under calibration the radius comes from the reference span, so a configured
|
// Under calibration the radius comes from the reference span, so a configured
|
||||||
|
|||||||
@@ -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.deepEqual(points, island.properties.contact_points);
|
||||||
}
|
}
|
||||||
assert.equal(geometry.diagnostics.filter((d) => d.rule === 'complex-junction-island-infeasible').length, 0);
|
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`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user