feat: support complex carriageway direction edits
This commit is contained in:
1 parent
88b7e17f4d
commit
3e74732190
3 files changed
+26
-5
No files matched your search
@@ -28,6 +28,7 @@ const SOLVED_KINDS = new Set([
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-carriageway-transition-length',
|
||||
'cluster-carriageway-position',
|
||||
'cluster-carriageway-direction',
|
||||
'cluster-corner-radius',
|
||||
'cluster-crossing-inset',
|
||||
'cluster-stop-line-offset',
|
||||
@@ -47,6 +48,7 @@ const KINDS = [
|
||||
'cluster-carriageway-cutback',
|
||||
'cluster-carriageway-transition-length',
|
||||
'cluster-carriageway-position',
|
||||
'cluster-carriageway-direction',
|
||||
'cluster-corner-radius',
|
||||
'cluster-crossing-inset',
|
||||
'cluster-stop-line-offset',
|
||||
@@ -870,6 +872,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
const clusterCutbacks = new Map();
|
||||
const clusterTransitions = new Map();
|
||||
const clusterPositions = new Map();
|
||||
const clusterDirections = new Map();
|
||||
const clusterCorners = new Map();
|
||||
const clusterCrossings = new Map();
|
||||
const clusterItems = clusterCarriageways(model, junctionData, clusters);
|
||||
@@ -906,6 +909,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
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 directionSnapshot = new Map([...clusterDirections].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(
|
||||
@@ -923,7 +927,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
constraint.kind === 'cluster-carriageway-width' ||
|
||||
constraint.kind === 'cluster-carriageway-cutback' ||
|
||||
constraint.kind === 'cluster-carriageway-transition-length' ||
|
||||
constraint.kind === 'cluster-carriageway-position'
|
||||
constraint.kind === 'cluster-carriageway-position' ||
|
||||
constraint.kind === 'cluster-carriageway-direction'
|
||||
) {
|
||||
const item = clusterItems
|
||||
.get(String(constraint.anchor?.clusterId))
|
||||
@@ -935,7 +940,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
? constraint.value?.transitionLengthMeters
|
||||
: constraint.kind === 'cluster-carriageway-position'
|
||||
? constraint.value?.offsetMeters
|
||||
: constraint.value?.cutbackMeters,
|
||||
: constraint.kind === 'cluster-carriageway-direction'
|
||||
? constraint.value?.offsetDegrees
|
||||
: constraint.value?.cutbackMeters,
|
||||
);
|
||||
const cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
|
||||
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
|
||||
@@ -951,7 +958,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
(constraint.kind === 'cluster-carriageway-cutback' && (value < 1 || value > cutbackMax)) ||
|
||||
(constraint.kind === 'cluster-carriageway-transition-length' &&
|
||||
(value < transitionBounds(model, cluster, item, constraints).min || value > transitionMax)) ||
|
||||
(constraint.kind === 'cluster-carriageway-position' && (value < -20 || value > 20))
|
||||
(constraint.kind === 'cluster-carriageway-position' && (value < -20 || value > 20)) ||
|
||||
(constraint.kind === 'cluster-carriageway-direction' && (value < -15 || value > 15))
|
||||
) {
|
||||
blocking(
|
||||
diagnostics,
|
||||
@@ -968,7 +976,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
? clusterTransitions
|
||||
: constraint.kind === 'cluster-carriageway-position'
|
||||
? clusterPositions
|
||||
: clusterCutbacks;
|
||||
: constraint.kind === 'cluster-carriageway-direction'
|
||||
? clusterDirections
|
||||
: clusterCutbacks;
|
||||
if (!target.has(item.clusterId)) target.set(item.clusterId, new Map());
|
||||
target.get(item.clusterId).set(item.key, value);
|
||||
applied = true;
|
||||
@@ -1052,6 +1062,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
for (const [key, value] of transitionSnapshot) clusterTransitions.set(key, value);
|
||||
clusterPositions.clear();
|
||||
for (const [key, value] of positionSnapshot) clusterPositions.set(key, value);
|
||||
clusterDirections.clear();
|
||||
for (const [key, value] of directionSnapshot) clusterDirections.set(key, value);
|
||||
clusterCorners.clear();
|
||||
for (const [key, value] of cornerSnapshot) clusterCorners.set(key, value);
|
||||
clusterCrossings.clear();
|
||||
@@ -1068,6 +1080,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
clusterCutbacks,
|
||||
clusterTransitions,
|
||||
clusterPositions,
|
||||
clusterDirections,
|
||||
clusterCorners,
|
||||
clusterCrossings,
|
||||
states,
|
||||
|
||||
@@ -17,6 +17,7 @@ const CONSTRAINT_ANCHORS = {
|
||||
'cluster-carriageway-cutback': 'cluster-carriageway',
|
||||
'cluster-carriageway-transition-length': 'cluster-carriageway',
|
||||
'cluster-carriageway-position': 'cluster-carriageway',
|
||||
'cluster-carriageway-direction': 'cluster-carriageway',
|
||||
'cluster-corner-radius': 'cluster-corner',
|
||||
'cluster-crossing-inset': 'cluster-crossing',
|
||||
'cluster-stop-line-offset': 'cluster-crossing',
|
||||
@@ -185,6 +186,9 @@ function validateValue(scope, kind, value) {
|
||||
fail(scope, 'value.transitionLengthMeters', 'must be a non-negative number of meters');
|
||||
} else if (kind === 'cluster-carriageway-position') {
|
||||
if (!isFiniteNumber(value.offsetMeters)) fail(scope, 'value.offsetMeters', 'must be a finite number of meters');
|
||||
} else if (kind === 'cluster-carriageway-direction') {
|
||||
if (!isFiniteNumber(value.offsetDegrees) || value.offsetDegrees < -15 || value.offsetDegrees > 15)
|
||||
fail(scope, 'value.offsetDegrees', 'must be between -15 and 15 degrees');
|
||||
} else if (kind === 'junction-corner-radius' || kind === 'cluster-corner-radius') {
|
||||
if (!isFiniteNumber(value.radiusMeters) || value.radiusMeters < 0)
|
||||
fail(scope, 'value.radiusMeters', 'must be a non-negative number of meters');
|
||||
|
||||
@@ -1016,7 +1016,8 @@ function applyDirectClusterPlans(model, junctionPlans, directEdit, clusters) {
|
||||
!directEdit?.clusterPlans?.size &&
|
||||
!directEdit?.clusterCutbacks?.size &&
|
||||
!directEdit?.clusterTransitions?.size &&
|
||||
!directEdit?.clusterPositions?.size
|
||||
!directEdit?.clusterPositions?.size &&
|
||||
!directEdit?.clusterDirections?.size
|
||||
)
|
||||
return;
|
||||
const clusterIds = new Set([
|
||||
@@ -1024,6 +1025,7 @@ function applyDirectClusterPlans(model, junctionPlans, directEdit, clusters) {
|
||||
...(directEdit.clusterCutbacks || new Map()).keys(),
|
||||
...(directEdit.clusterTransitions || new Map()).keys(),
|
||||
...(directEdit.clusterPositions || new Map()).keys(),
|
||||
...(directEdit.clusterDirections || new Map()).keys(),
|
||||
]);
|
||||
for (const clusterId of clusterIds) {
|
||||
const widths = directEdit.clusterPlans?.get(clusterId) || new Map();
|
||||
@@ -1051,6 +1053,8 @@ function applyDirectClusterPlans(model, junctionPlans, directEdit, clusters) {
|
||||
if (Number.isFinite(transition)) item.approach.transitionLengthMeters = transition;
|
||||
const position = directEdit.clusterPositions?.get(clusterId)?.get(item.key);
|
||||
if (Number.isFinite(position)) item.approach.positionOffsetMeters = position;
|
||||
const direction = directEdit.clusterDirections?.get(clusterId)?.get(item.key);
|
||||
if (Number.isFinite(direction)) item.heading += direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user