feat(junction): place sourced complex crossings
This commit is contained in:
1 parent
d49cdab40a
commit
48fd432266
2 files changed
+46
-7
No files matched your search
@@ -83,8 +83,28 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const stopLines = [];
|
||||
const islands = [];
|
||||
const crossingControls = helpers.clusterCrossingControls || new Map();
|
||||
const crossingPlans = new Map(
|
||||
arms.map((arm) => {
|
||||
const inferredRadius = Math.max(1, coreRadius * 0.68);
|
||||
const inferredEnvelope = armEnvelopeAtRadius(arm, inferredRadius, center, helpers);
|
||||
const evidence = inferredEnvelope
|
||||
? crossingEvidenceForArm(model, arm, inferredEnvelope.center, helpers)
|
||||
: { kind: 'inferred-road-envelope', crossingNodeIds: [], crossing: null };
|
||||
return [
|
||||
arm.key,
|
||||
{
|
||||
evidence,
|
||||
baseRadius: evidence.crossing ? helpers.distanceMeters(center, evidence.crossing.coordinate) : inferredRadius,
|
||||
},
|
||||
];
|
||||
}),
|
||||
);
|
||||
const armCrosswalkRadiusFor = (arm) =>
|
||||
Math.max(1, coreRadius * 0.68 + (crossingControls.get(`crossing:${arm.key}`)?.crosswalkInsetMeters || 0));
|
||||
Math.max(
|
||||
1,
|
||||
(crossingPlans.get(arm.key)?.baseRadius || coreRadius * 0.68) +
|
||||
(crossingControls.get(`crossing:${arm.key}`)?.crosswalkInsetMeters || 0),
|
||||
);
|
||||
const boundaryGraph = buildJunctionBoundaryGraph(
|
||||
topology,
|
||||
center,
|
||||
@@ -113,8 +133,10 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const crossingRadius = armCrosswalkRadiusFor(arm);
|
||||
const stopOffset = crossingControls.get(crossingKey)?.stopLineOffsetMeters || 3;
|
||||
const stopCenter = pointOnCarriagewayRadius(item, center, crossingRadius + stopOffset, helpers);
|
||||
const crossingCenter = pointOnCarriagewayRadius(item, center, crossingRadius, helpers);
|
||||
const crossingEvidence = crossingEvidenceForArm(model, arm, crossingCenter, helpers);
|
||||
const crossingEvidence = crossingPlans.get(arm.key)?.evidence || {
|
||||
kind: 'inferred-road-envelope',
|
||||
crossingNodeIds: [],
|
||||
};
|
||||
const ring = [
|
||||
helpers.offsetCoordinate(
|
||||
helpers.offsetCoordinate(stopCenter, item.heading + 90, -outerHalf),
|
||||
@@ -179,7 +201,10 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
supportHeading: normalizeHeading(arm.heading + 90),
|
||||
envelopeWidthMeters: envelope.widthMeters,
|
||||
};
|
||||
arm.crosswalkEvidence = crossingEvidenceForArm(model, arm, envelope.center, helpers);
|
||||
arm.crosswalkEvidence = crossingPlans.get(arm.key)?.evidence || {
|
||||
kind: 'inferred-road-envelope',
|
||||
crossingNodeIds: [],
|
||||
};
|
||||
}
|
||||
for (let index = 0; index < arms.length; index += 1) {
|
||||
const arm = arms[index];
|
||||
@@ -730,17 +755,22 @@ function crossingEvidenceForArm(model, arm, center, helpers) {
|
||||
8,
|
||||
arm.members.reduce((width, member) => width + member.approach.widthMeters, 0) / 2 + 3,
|
||||
);
|
||||
const crossingNodeIds = (model.crossings || [])
|
||||
const crossings = (model.crossings || [])
|
||||
.filter(
|
||||
(crossing) =>
|
||||
(crossing.osmWayIds || []).some((wayId) => osmWayIds.has(String(wayId))) &&
|
||||
helpers.distanceMeters(crossing.coordinate, center) <= maximumDistance,
|
||||
)
|
||||
.map((crossing) => String(crossing.id))
|
||||
.sort();
|
||||
.sort(
|
||||
(first, second) =>
|
||||
helpers.distanceMeters(first.coordinate, center) - helpers.distanceMeters(second.coordinate, center) ||
|
||||
String(first.id).localeCompare(String(second.id)),
|
||||
);
|
||||
const crossingNodeIds = crossings.map((crossing) => String(crossing.id));
|
||||
return {
|
||||
kind: crossingNodeIds.length ? 'source-crossing-node' : 'inferred-road-envelope',
|
||||
crossingNodeIds,
|
||||
crossing: crossings[0] || null,
|
||||
};
|
||||
}
|
||||
function cornerEdgeAt(arm, radius, bisector, center, helpers) {
|
||||
|
||||
@@ -172,6 +172,15 @@ const sourcedComplexCrosswalk = sourceCrossingGeometry.crosswalks.features.find(
|
||||
);
|
||||
assert.equal(sourcedComplexCrosswalk.properties.facility_evidence, 'source-crossing-node');
|
||||
assert.deepEqual(sourcedComplexCrosswalk.properties.source_crossing_node_ids, ['known-complex-crossing']);
|
||||
const sourceCenter = sourceCrossingGeometry.roadSurface.features.find(
|
||||
(feature) => feature.properties?.junction_structure,
|
||||
)?.properties.junction_structure.center;
|
||||
const sourceLatitudeScale = 111320 * Math.cos((sourceCenter[1] * Math.PI) / 180);
|
||||
const sourceCrossingRadius = Math.hypot(
|
||||
(sourceCrossingModel.crossings[0].coordinate[0] - sourceCenter[0]) * sourceLatitudeScale,
|
||||
(sourceCrossingModel.crossings[0].coordinate[1] - sourceCenter[1]) * 111320,
|
||||
);
|
||||
assert.ok(Math.abs(sourcedComplexCrosswalk.properties.radial_distance_m - sourceCrossingRadius) < 0.1);
|
||||
const sourcedStopLine = sourceCrossingGeometry.vehicleStopLines.features.find(
|
||||
(feature) => feature.properties?.crossing_key === inferredComplexCrosswalk.properties.crossing_key,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user