feat: support complex carriageway position edits

This commit is contained in:
que01 committed 2026-09-10 10:37:46 +08:00
1 parent 92894c7e4f
commit 88b7e17f4d
4 files changed
+34 -7

No files matched your search

+17 -4
View File
@@ -27,6 +27,7 @@ const SOLVED_KINDS = new Set([
'cluster-carriageway-width',
'cluster-carriageway-cutback',
'cluster-carriageway-transition-length',
'cluster-carriageway-position',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
@@ -45,6 +46,7 @@ const KINDS = [
'cluster-carriageway-width',
'cluster-carriageway-cutback',
'cluster-carriageway-transition-length',
'cluster-carriageway-position',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
@@ -867,6 +869,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
const clusterPlans = new Map();
const clusterCutbacks = new Map();
const clusterTransitions = new Map();
const clusterPositions = new Map();
const clusterCorners = new Map();
const clusterCrossings = new Map();
const clusterItems = clusterCarriageways(model, junctionData, clusters);
@@ -902,6 +905,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
const clusterSnapshot = new Map([...clusterPlans].map(([key, value]) => [key, new Map(value)]));
const cutbackSnapshot = new Map([...clusterCutbacks].map(([key, value]) => [key, new Map(value)]));
const transitionSnapshot = new Map([...clusterTransitions].map(([key, value]) => [key, new Map(value)]));
const positionSnapshot = new Map([...clusterPositions].map(([key, value]) => [key, new Map(value)]));
const cornerSnapshot = new Map([...clusterCorners].map(([key, value]) => [key, new Map(value)]));
const crossingClusterSnapshot = new Map([...clusterCrossings].map(([key, value]) => [key, new Map(value)]));
const junctionSnapshot = new Map(
@@ -918,7 +922,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
if (
constraint.kind === 'cluster-carriageway-width' ||
constraint.kind === 'cluster-carriageway-cutback' ||
constraint.kind === 'cluster-carriageway-transition-length'
constraint.kind === 'cluster-carriageway-transition-length' ||
constraint.kind === 'cluster-carriageway-position'
) {
const item = clusterItems
.get(String(constraint.anchor?.clusterId))
@@ -928,7 +933,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
? constraint.value?.widthMeters
: constraint.kind === 'cluster-carriageway-transition-length'
? constraint.value?.transitionLengthMeters
: constraint.value?.cutbackMeters,
: constraint.kind === 'cluster-carriageway-position'
? constraint.value?.offsetMeters
: constraint.value?.cutbackMeters,
);
const cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
@@ -943,7 +950,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
value > item.widthMeters * 2)) ||
(constraint.kind === 'cluster-carriageway-cutback' && (value < 1 || value > cutbackMax)) ||
(constraint.kind === 'cluster-carriageway-transition-length' &&
(value < transitionBounds(model, cluster, item, constraints).min || value > transitionMax))
(value < transitionBounds(model, cluster, item, constraints).min || value > transitionMax)) ||
(constraint.kind === 'cluster-carriageway-position' && (value < -20 || value > 20))
) {
blocking(
diagnostics,
@@ -958,7 +966,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
? clusterPlans
: constraint.kind === 'cluster-carriageway-transition-length'
? clusterTransitions
: clusterCutbacks;
: constraint.kind === 'cluster-carriageway-position'
? clusterPositions
: clusterCutbacks;
if (!target.has(item.clusterId)) target.set(item.clusterId, new Map());
target.get(item.clusterId).set(item.key, value);
applied = true;
@@ -1040,6 +1050,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
for (const [key, value] of cutbackSnapshot) clusterCutbacks.set(key, value);
clusterTransitions.clear();
for (const [key, value] of transitionSnapshot) clusterTransitions.set(key, value);
clusterPositions.clear();
for (const [key, value] of positionSnapshot) clusterPositions.set(key, value);
clusterCorners.clear();
for (const [key, value] of cornerSnapshot) clusterCorners.set(key, value);
clusterCrossings.clear();
@@ -1055,6 +1067,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
clusterPlans,
clusterCutbacks,
clusterTransitions,
clusterPositions,
clusterCorners,
clusterCrossings,
states,