fix: require source evidence for complex crosswalks
This commit is contained in:
1 parent
858db529ae
commit
3a8af43140
9 files changed
+320
-53
No files matched your search
@@ -85,7 +85,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const inferredEnvelope = armEnvelopeAtRadius(arm, inferredRadius, center, helpers);
|
||||
const evidence = inferredEnvelope
|
||||
? crossingEvidenceForArm(model, arm, inferredEnvelope.center, helpers)
|
||||
: { kind: 'inferred-road-envelope', crossingNodeIds: [], crossing: null };
|
||||
: { kind: 'unknown-no-crossing-source', crossingNodeIds: [], crossing: null };
|
||||
return [
|
||||
arm.key,
|
||||
{
|
||||
@@ -164,7 +164,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
const stopOffset = crossingControls.get(crossingKey)?.stopLineOffsetMeters || 3;
|
||||
const stopCenter = pointOnCarriagewayRadius(item, center, crossingRadius + stopOffset, helpers);
|
||||
const crossingEvidence = crossingPlans.get(arm.key)?.evidence || {
|
||||
kind: 'inferred-road-envelope',
|
||||
kind: 'unknown-no-crossing-source',
|
||||
crossingNodeIds: [],
|
||||
};
|
||||
const ring = [
|
||||
@@ -239,16 +239,30 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
arm.crosswalkRadius = armCrosswalkRadius;
|
||||
const envelope = armEnvelopeAtRadius(arm, armCrosswalkRadius, center, helpers);
|
||||
if (!envelope) continue;
|
||||
const evidence = crossingPlans.get(arm.key)?.evidence || {
|
||||
kind: 'unknown-no-crossing-source',
|
||||
crossingNodeIds: [],
|
||||
};
|
||||
if (evidence.kind !== 'source-crossing-node') {
|
||||
transitionDiagnostics.push(
|
||||
helpers.diagnostic(
|
||||
'info',
|
||||
`crossing:${arm.key}`,
|
||||
arm.members.flatMap((item) => item.approach.roadIds.map(String)),
|
||||
'complex-junction-crossing-source-missing',
|
||||
'该进口未找到匹配的 OSM 过街节点,过街状态未知,未生成斑马线。',
|
||||
envelope.center,
|
||||
),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
arm.crosswalkFrame = {
|
||||
center: envelope.center,
|
||||
groupDepth: 3.4,
|
||||
supportHeading: normalizeHeading(arm.heading + 90),
|
||||
envelopeWidthMeters: envelope.widthMeters,
|
||||
};
|
||||
arm.crosswalkEvidence = crossingPlans.get(arm.key)?.evidence || {
|
||||
kind: 'inferred-road-envelope',
|
||||
crossingNodeIds: [],
|
||||
};
|
||||
arm.crosswalkEvidence = evidence;
|
||||
}
|
||||
for (let index = 0; index < arms.length; index += 1) {
|
||||
const arm = arms[index];
|
||||
@@ -354,19 +368,6 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
);
|
||||
return true;
|
||||
};
|
||||
for (const arm of arms) {
|
||||
if (!arm.crosswalkFrame || arm.crosswalkEvidence.kind !== 'inferred-road-envelope') continue;
|
||||
cornerDiagnostics.push(
|
||||
helpers.diagnostic(
|
||||
'info',
|
||||
`crossing:${arm.key}`,
|
||||
arm.members.flatMap((member) => member.approach.roadIds.map(String)),
|
||||
'complex-junction-crossing-inferred',
|
||||
'该进口未找到与道路及当前位置匹配的 OSM 过街节点;已按最终车行道范围推断斑马线和停止线。',
|
||||
arm.crosswalkFrame.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
const omittedCornerFacilityCount = arms.filter((arm, index) => {
|
||||
const next = arms[(index + 1) % arms.length];
|
||||
const delta = positiveHeadingDelta(arm.heading, next.heading);
|
||||
@@ -663,8 +664,8 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
||||
[...nodeIds],
|
||||
calibration ? 'complex-junction-reference-calibrated' : 'complex-junction-generated',
|
||||
calibration
|
||||
? `已识别为${shape.label},使用参考几何校准参数后重新生成 ${approaches.length} 个进口、道路面、斑马线和停止线。`
|
||||
: `已识别为${shape.label},独立生成 ${approaches.length} 个进口、道路面、斑马线和停止线。`,
|
||||
? `已识别为${shape.label},使用参考几何校准参数后重新生成 ${approaches.length} 个进口、道路面、${crosswalks.length} 组斑马线和停止线。`
|
||||
: `已识别为${shape.label},独立生成 ${approaches.length} 个进口、道路面、${crosswalks.length} 组斑马线和停止线。`,
|
||||
center,
|
||||
),
|
||||
],
|
||||
@@ -900,7 +901,7 @@ function crossingEvidenceForArm(model, arm, center, helpers) {
|
||||
);
|
||||
const crossingNodeIds = crossings.map((crossing) => String(crossing.id));
|
||||
return {
|
||||
kind: crossingNodeIds.length ? 'source-crossing-node' : 'inferred-road-envelope',
|
||||
kind: crossingNodeIds.length ? 'source-crossing-node' : 'unknown-no-crossing-source',
|
||||
crossingNodeIds,
|
||||
crossing: crossings[0] || null,
|
||||
};
|
||||
|
||||
@@ -317,7 +317,7 @@ function clusterArmRadiusPoint(arm, center, radius) {
|
||||
|
||||
function clusterCrossingBaseRadius(model, arm, center, inferredRadius) {
|
||||
const inferredCenter = clusterArmRadiusPoint(arm, center, inferredRadius);
|
||||
if (!inferredCenter) return inferredRadius;
|
||||
if (!inferredCenter) return null;
|
||||
const osmWayIds = new Set(
|
||||
arm.members.flatMap((member) => member.roads.flatMap((road) => (road.osmWayIds || []).map(String))),
|
||||
);
|
||||
@@ -336,7 +336,7 @@ function clusterCrossingBaseRadius(model, arm, center, inferredRadius) {
|
||||
haversineMeters(first.coordinate, inferredCenter) - haversineMeters(second.coordinate, inferredCenter) ||
|
||||
String(first.id).localeCompare(String(second.id)),
|
||||
)[0];
|
||||
return crossing ? haversineMeters(center, crossing.coordinate) : inferredRadius;
|
||||
return crossing ? haversineMeters(center, crossing.coordinate) : null;
|
||||
}
|
||||
|
||||
function clusterArms(clusterId, items) {
|
||||
@@ -1055,9 +1055,29 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
(candidate) => `crossing:${candidate.key}` === constraint.anchor?.crossingKey,
|
||||
);
|
||||
const value = Number(constraint.value?.insetMeters ?? constraint.value?.offsetMeters);
|
||||
const crossingSourceRadius = arm
|
||||
? clusterCrossingBaseRadius(
|
||||
model,
|
||||
arm,
|
||||
clusterCenter(
|
||||
model,
|
||||
clusters.find((item) => String(item.id) === clusterId),
|
||||
),
|
||||
Math.max(
|
||||
2,
|
||||
complexJunctionMetrics(clusters.find((item) => String(item.id) === clusterId)).coreRadius * 0.68,
|
||||
),
|
||||
)
|
||||
: null;
|
||||
const min = constraint.kind === 'cluster-crossing-inset' ? 0 : MIN_STOP_LINE_OFFSET_METERS;
|
||||
const max = constraint.kind === 'cluster-crossing-inset' ? MAX_CROSSWALK_INSET_METERS : 12;
|
||||
if (!arm || !Number.isFinite(value) || value < min || value > max) {
|
||||
if (
|
||||
!arm ||
|
||||
(constraint.kind === 'cluster-crossing-inset' && !Number.isFinite(crossingSourceRadius)) ||
|
||||
!Number.isFinite(value) ||
|
||||
value < min ||
|
||||
value > max
|
||||
) {
|
||||
blocking(
|
||||
diagnostics,
|
||||
constraint,
|
||||
@@ -1796,32 +1816,35 @@ function makeClusterCrossingHandles(model, junctionData, constraints, clusters)
|
||||
const pointAt = (distance) =>
|
||||
clusterArmRadiusPoint(arm, center, distance) ||
|
||||
coordinateAt(line, Math.min(0.9, Math.max(0.05, distance / length)));
|
||||
const baseCrosswalkDistance = clusterCrossingBaseRadius(
|
||||
const sourceCrossingDistance = clusterCrossingBaseRadius(
|
||||
model,
|
||||
arm,
|
||||
center,
|
||||
Math.max(2, complexJunctionMetrics(cluster).coreRadius * 0.68),
|
||||
);
|
||||
const baseCrosswalkDistance =
|
||||
sourceCrossingDistance ?? Math.max(2, complexJunctionMetrics(cluster).coreRadius * 0.68);
|
||||
const insetConstraint = constraintFor(constraints, 'cluster-crossing-inset', anchor);
|
||||
const inset = numericValue(insetConstraint, 'insetMeters', 0);
|
||||
handles.push({
|
||||
handleId: `handle:cluster-crossing-inset:${crossingKey}`,
|
||||
kind: 'cluster-crossing-inset',
|
||||
anchor,
|
||||
position: pointAt(baseCrosswalkDistance + inset),
|
||||
axisAzimuth: arm.heading,
|
||||
value: { current: inset, min: 0, max: MAX_CROSSWALK_INSET_METERS, unit: 'meter' },
|
||||
...(insetConstraint ? { constraintId: insetConstraint.id } : {}),
|
||||
affects: [`complex-crosswalk:${clusterId}`],
|
||||
editable: true,
|
||||
});
|
||||
if (Number.isFinite(sourceCrossingDistance))
|
||||
handles.push({
|
||||
handleId: `handle:cluster-crossing-inset:${crossingKey}`,
|
||||
kind: 'cluster-crossing-inset',
|
||||
anchor,
|
||||
position: pointAt(baseCrosswalkDistance + inset),
|
||||
axisAzimuth: arm.heading,
|
||||
value: { current: inset, min: 0, max: MAX_CROSSWALK_INSET_METERS, unit: 'meter' },
|
||||
...(insetConstraint ? { constraintId: insetConstraint.id } : {}),
|
||||
affects: [`complex-crosswalk:${clusterId}`],
|
||||
editable: true,
|
||||
});
|
||||
const stopConstraint = constraintFor(constraints, 'cluster-stop-line-offset', anchor);
|
||||
const offset = numericValue(stopConstraint, 'offsetMeters', 3);
|
||||
handles.push({
|
||||
handleId: `handle:cluster-stop-line-offset:${crossingKey}`,
|
||||
kind: 'cluster-stop-line-offset',
|
||||
anchor,
|
||||
position: pointAt(baseCrosswalkDistance + inset + offset),
|
||||
position: pointAt(baseCrosswalkDistance + (Number.isFinite(sourceCrossingDistance) ? inset : 0) + offset),
|
||||
axisAzimuth: arm.heading,
|
||||
value: { current: offset, min: MIN_STOP_LINE_OFFSET_METERS, max: 12, unit: 'meter' },
|
||||
...(stopConstraint ? { constraintId: stopConstraint.id } : {}),
|
||||
|
||||
Reference in new issue
Block a user