feat(junction): validate transition length constraints
This commit is contained in:
1 parent
95c49722d4
commit
413b3d9b89
3 files changed
+25
-4
No files matched your search
@@ -26,6 +26,7 @@ const SOLVED_KINDS = new Set([
|
||||
'junction-approach-width',
|
||||
'cluster-carriageway-width',
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-carriageway-transition-length',
|
||||
'cluster-corner-radius',
|
||||
'cluster-crossing-inset',
|
||||
'cluster-stop-line-offset',
|
||||
@@ -43,6 +44,7 @@ const KINDS = [
|
||||
'junction-approach-width',
|
||||
'cluster-carriageway-width',
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-carriageway-transition-length',
|
||||
'cluster-corner-radius',
|
||||
'cluster-crossing-inset',
|
||||
'cluster-stop-line-offset',
|
||||
@@ -884,17 +886,25 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
]),
|
||||
);
|
||||
let applied;
|
||||
if (constraint.kind === 'cluster-carriageway-width' || constraint.kind === 'cluster-carriageway-cutback') {
|
||||
if (
|
||||
constraint.kind === 'cluster-carriageway-width' ||
|
||||
constraint.kind === 'cluster-carriageway-cutback' ||
|
||||
constraint.kind === 'cluster-carriageway-transition-length'
|
||||
) {
|
||||
const item = clusterItems
|
||||
.get(String(constraint.anchor?.clusterId))
|
||||
?.find((candidate) => candidate.key === constraint.anchor?.carriagewayKey);
|
||||
const value = Number(
|
||||
constraint.kind === 'cluster-carriageway-width'
|
||||
? constraint.value?.widthMeters
|
||||
: constraint.value?.cutbackMeters,
|
||||
: constraint.kind === 'cluster-carriageway-transition-length'
|
||||
? constraint.value?.transitionLengthMeters
|
||||
: constraint.value?.cutbackMeters,
|
||||
);
|
||||
const cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
|
||||
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
|
||||
const metrics = cluster ? complexJunctionMetrics(cluster) : null;
|
||||
const transitionMax = metrics ? metrics.approachOuterRadius - metrics.approachInnerRadius : 0;
|
||||
if (!item) {
|
||||
blocking(diagnostics, constraint, 'direct-edit-cluster-carriageway-missing', '复杂路口车行道锚点不存在。');
|
||||
applied = false;
|
||||
@@ -903,7 +913,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
(constraint.kind === 'cluster-carriageway-width' &&
|
||||
(value < Math.max(MIN_LANE_WIDTH_METERS, item.laneCount * MIN_LANE_WIDTH_METERS) ||
|
||||
value > item.widthMeters * 2)) ||
|
||||
(constraint.kind === 'cluster-carriageway-cutback' && (value < 1 || value > cutbackMax))
|
||||
(constraint.kind === 'cluster-carriageway-cutback' && (value < 1 || value > cutbackMax)) ||
|
||||
(constraint.kind === 'cluster-carriageway-transition-length' &&
|
||||
(value < (metrics?.minimumTransitionMeters || 0) || value > transitionMax))
|
||||
) {
|
||||
blocking(
|
||||
diagnostics,
|
||||
@@ -915,7 +927,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
} else {
|
||||
const target = constraint.kind === 'cluster-carriageway-width' ? clusterPlans : clusterCutbacks;
|
||||
if (!target.has(item.clusterId)) target.set(item.clusterId, new Map());
|
||||
target.get(item.clusterId).set(item.key, value);
|
||||
const derivedCutback =
|
||||
constraint.kind === 'cluster-carriageway-transition-length' ? Math.max(0, transitionMax - value) : value;
|
||||
target.get(item.clusterId).set(item.key, derivedCutback);
|
||||
applied = true;
|
||||
}
|
||||
} else if (constraint.kind === 'cluster-corner-radius') {
|
||||
|
||||
Reference in new issue
Block a user