feat: support complex carriageway edge offsets

This commit is contained in:
que01 committed 2026-09-10 11:01:11 +08:00
1 parent 3e74732190
commit 38dc9d6f52
3 files changed
+27 -2

No files matched your search

+16 -2
View File
@@ -29,6 +29,7 @@ const SOLVED_KINDS = new Set([
'cluster-carriageway-transition-length',
'cluster-carriageway-position',
'cluster-carriageway-direction',
'cluster-carriageway-edge-offset',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
@@ -49,6 +50,7 @@ const KINDS = [
'cluster-carriageway-transition-length',
'cluster-carriageway-position',
'cluster-carriageway-direction',
'cluster-carriageway-edge-offset',
'cluster-corner-radius',
'cluster-crossing-inset',
'cluster-stop-line-offset',
@@ -873,6 +875,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
const clusterTransitions = new Map();
const clusterPositions = new Map();
const clusterDirections = new Map();
const clusterEdgeOffsets = new Map();
const clusterCorners = new Map();
const clusterCrossings = new Map();
const clusterItems = clusterCarriageways(model, junctionData, clusters);
@@ -910,6 +913,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
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 edgeSnapshot = new Map([...clusterEdgeOffsets].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(
@@ -928,7 +932,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
constraint.kind === 'cluster-carriageway-cutback' ||
constraint.kind === 'cluster-carriageway-transition-length' ||
constraint.kind === 'cluster-carriageway-position' ||
constraint.kind === 'cluster-carriageway-direction'
constraint.kind === 'cluster-carriageway-direction' ||
constraint.kind === 'cluster-carriageway-edge-offset'
) {
const item = clusterItems
.get(String(constraint.anchor?.clusterId))
@@ -942,7 +947,9 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
? constraint.value?.offsetMeters
: constraint.kind === 'cluster-carriageway-direction'
? constraint.value?.offsetDegrees
: constraint.value?.cutbackMeters,
: constraint.kind === 'cluster-carriageway-edge-offset'
? constraint.value
: constraint.value?.cutbackMeters,
);
const cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
@@ -981,6 +988,10 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
: clusterCutbacks;
if (!target.has(item.clusterId)) target.set(item.clusterId, new Map());
target.get(item.clusterId).set(item.key, value);
if (constraint.kind === 'cluster-carriageway-edge-offset') {
if (!clusterEdgeOffsets.has(item.clusterId)) clusterEdgeOffsets.set(item.clusterId, new Map());
clusterEdgeOffsets.get(item.clusterId).set(item.key, value);
}
applied = true;
}
} else if (constraint.kind === 'cluster-corner-radius') {
@@ -1064,6 +1075,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
for (const [key, value] of positionSnapshot) clusterPositions.set(key, value);
clusterDirections.clear();
for (const [key, value] of directionSnapshot) clusterDirections.set(key, value);
clusterEdgeOffsets.clear();
for (const [key, value] of edgeSnapshot) clusterEdgeOffsets.set(key, value);
clusterCorners.clear();
for (const [key, value] of cornerSnapshot) clusterCorners.set(key, value);
clusterCrossings.clear();
@@ -1081,6 +1094,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
clusterTransitions,
clusterPositions,
clusterDirections,
clusterEdgeOffsets,
clusterCorners,
clusterCrossings,
states,