fix: apply complex carriageway edge offsets
This commit is contained in:
1 parent
38dc9d6f52
commit
936354fec8
2 files changed
+18
-7
No files matched your search
@@ -938,7 +938,7 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
const item = clusterItems
|
||||
.get(String(constraint.anchor?.clusterId))
|
||||
?.find((candidate) => candidate.key === constraint.anchor?.carriagewayKey);
|
||||
const value = Number(
|
||||
const rawValue =
|
||||
constraint.kind === 'cluster-carriageway-width'
|
||||
? constraint.value?.widthMeters
|
||||
: constraint.kind === 'cluster-carriageway-transition-length'
|
||||
@@ -949,8 +949,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
? constraint.value?.offsetDegrees
|
||||
: constraint.kind === 'cluster-carriageway-edge-offset'
|
||||
? constraint.value
|
||||
: constraint.value?.cutbackMeters,
|
||||
);
|
||||
: constraint.value?.cutbackMeters;
|
||||
const value = constraint.kind === 'cluster-carriageway-edge-offset' ? rawValue : Number(rawValue);
|
||||
const cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
|
||||
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
|
||||
const transitionMax = item && cluster ? transitionBounds(model, cluster, item, constraints).max : 0;
|
||||
@@ -958,7 +958,14 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
||||
blocking(diagnostics, constraint, 'direct-edit-cluster-carriageway-missing', '复杂路口车行道锚点不存在。');
|
||||
applied = false;
|
||||
} else if (
|
||||
!Number.isFinite(value) ||
|
||||
(constraint.kind !== 'cluster-carriageway-edge-offset' && !Number.isFinite(value)) ||
|
||||
(constraint.kind === 'cluster-carriageway-edge-offset' &&
|
||||
(!Number.isFinite(value.leftOffsetMeters) ||
|
||||
!Number.isFinite(value.rightOffsetMeters) ||
|
||||
value.leftOffsetMeters < -10 ||
|
||||
value.leftOffsetMeters > 10 ||
|
||||
value.rightOffsetMeters < -10 ||
|
||||
value.rightOffsetMeters > 10)) ||
|
||||
(constraint.kind === 'cluster-carriageway-width' &&
|
||||
(value < Math.max(MIN_LANE_WIDTH_METERS, item.laneCount * MIN_LANE_WIDTH_METERS) ||
|
||||
value > item.widthMeters * 2)) ||
|
||||
|
||||
@@ -39,7 +39,7 @@ function offsetCoordinate(point, heading, meters) {
|
||||
];
|
||||
}
|
||||
|
||||
function sectionAt(item, radius, center, widthMeters, helpers, explicitStation) {
|
||||
function sectionAt(item, radius, center, widthMeters, helpers, explicitStation, edgeOffsets = null) {
|
||||
const station = Math.max(
|
||||
0,
|
||||
Math.min(item.length, explicitStation ?? stationAtDistanceFrom(item.approach.line, center, radius, helpers)),
|
||||
@@ -47,12 +47,14 @@ function sectionAt(item, radius, center, widthMeters, helpers, explicitStation)
|
||||
const point = pointAtStation(item.approach.line, station, helpers);
|
||||
const tangent = tangentAtStation(item.approach.line, station, helpers);
|
||||
const halfWidth = Math.max(0, Number(widthMeters) || 0) / 2;
|
||||
const leftOffset = Number(edgeOffsets?.left) || 0;
|
||||
const rightOffset = Number(edgeOffsets?.right) || 0;
|
||||
return {
|
||||
stationMeters: station,
|
||||
point,
|
||||
tangent,
|
||||
left: offsetCoordinate(point, tangent - 90, halfWidth),
|
||||
right: offsetCoordinate(point, tangent + 90, halfWidth),
|
||||
left: offsetCoordinate(point, tangent - 90, halfWidth + leftOffset),
|
||||
right: offsetCoordinate(point, tangent + 90, halfWidth + rightOffset),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -70,6 +72,7 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
||||
const requestedTransition = Number.isFinite(item.approach.transitionLengthMeters)
|
||||
? Math.max(0, item.approach.transitionLengthMeters)
|
||||
: null;
|
||||
const edgeOffsets = { left: item.approach.leftEdgeOffsetMeters, right: item.approach.rightEdgeOffsetMeters };
|
||||
const inner = sectionAt(
|
||||
item,
|
||||
innerRadius,
|
||||
@@ -79,6 +82,7 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
||||
(requestedTransition === null ? undefined : outer.stationMeters - requestedTransition) === undefined
|
||||
? undefined
|
||||
: outer.stationMeters - requestedTransition + positionOffset,
|
||||
edgeOffsets,
|
||||
);
|
||||
const key = `boundary:${item.key}`;
|
||||
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
||||
|
||||
Reference in new issue
Block a user