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
|
const item = clusterItems
|
||||||
.get(String(constraint.anchor?.clusterId))
|
.get(String(constraint.anchor?.clusterId))
|
||||||
?.find((candidate) => candidate.key === constraint.anchor?.carriagewayKey);
|
?.find((candidate) => candidate.key === constraint.anchor?.carriagewayKey);
|
||||||
const value = Number(
|
const rawValue =
|
||||||
constraint.kind === 'cluster-carriageway-width'
|
constraint.kind === 'cluster-carriageway-width'
|
||||||
? constraint.value?.widthMeters
|
? constraint.value?.widthMeters
|
||||||
: constraint.kind === 'cluster-carriageway-transition-length'
|
: constraint.kind === 'cluster-carriageway-transition-length'
|
||||||
@@ -949,8 +949,8 @@ function solveConstraints(model, constraints, junctionData, diagnostics, cluster
|
|||||||
? constraint.value?.offsetDegrees
|
? constraint.value?.offsetDegrees
|
||||||
: constraint.kind === 'cluster-carriageway-edge-offset'
|
: constraint.kind === 'cluster-carriageway-edge-offset'
|
||||||
? constraint.value
|
? 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 cluster = clusters.find((candidate) => String(candidate.id) === String(item?.clusterId));
|
||||||
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
|
const cutbackMax = cluster ? clusterCutbackMaximum(cluster, item?.approach.length || 0) : 0;
|
||||||
const transitionMax = item && cluster ? transitionBounds(model, cluster, item, constraints).max : 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', '复杂路口车行道锚点不存在。');
|
blocking(diagnostics, constraint, 'direct-edit-cluster-carriageway-missing', '复杂路口车行道锚点不存在。');
|
||||||
applied = false;
|
applied = false;
|
||||||
} else if (
|
} 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' &&
|
(constraint.kind === 'cluster-carriageway-width' &&
|
||||||
(value < Math.max(MIN_LANE_WIDTH_METERS, item.laneCount * MIN_LANE_WIDTH_METERS) ||
|
(value < Math.max(MIN_LANE_WIDTH_METERS, item.laneCount * MIN_LANE_WIDTH_METERS) ||
|
||||||
value > item.widthMeters * 2)) ||
|
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(
|
const station = Math.max(
|
||||||
0,
|
0,
|
||||||
Math.min(item.length, explicitStation ?? stationAtDistanceFrom(item.approach.line, center, radius, helpers)),
|
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 point = pointAtStation(item.approach.line, station, helpers);
|
||||||
const tangent = tangentAtStation(item.approach.line, station, helpers);
|
const tangent = tangentAtStation(item.approach.line, station, helpers);
|
||||||
const halfWidth = Math.max(0, Number(widthMeters) || 0) / 2;
|
const halfWidth = Math.max(0, Number(widthMeters) || 0) / 2;
|
||||||
|
const leftOffset = Number(edgeOffsets?.left) || 0;
|
||||||
|
const rightOffset = Number(edgeOffsets?.right) || 0;
|
||||||
return {
|
return {
|
||||||
stationMeters: station,
|
stationMeters: station,
|
||||||
point,
|
point,
|
||||||
tangent,
|
tangent,
|
||||||
left: offsetCoordinate(point, tangent - 90, halfWidth),
|
left: offsetCoordinate(point, tangent - 90, halfWidth + leftOffset),
|
||||||
right: offsetCoordinate(point, tangent + 90, halfWidth),
|
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)
|
const requestedTransition = Number.isFinite(item.approach.transitionLengthMeters)
|
||||||
? Math.max(0, item.approach.transitionLengthMeters)
|
? Math.max(0, item.approach.transitionLengthMeters)
|
||||||
: null;
|
: null;
|
||||||
|
const edgeOffsets = { left: item.approach.leftEdgeOffsetMeters, right: item.approach.rightEdgeOffsetMeters };
|
||||||
const inner = sectionAt(
|
const inner = sectionAt(
|
||||||
item,
|
item,
|
||||||
innerRadius,
|
innerRadius,
|
||||||
@@ -79,6 +82,7 @@ function buildJunctionBoundaryGraph(topology, center, radii, helpers, exclusionR
|
|||||||
(requestedTransition === null ? undefined : outer.stationMeters - requestedTransition) === undefined
|
(requestedTransition === null ? undefined : outer.stationMeters - requestedTransition) === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: outer.stationMeters - requestedTransition + positionOffset,
|
: outer.stationMeters - requestedTransition + positionOffset,
|
||||||
|
edgeOffsets,
|
||||||
);
|
);
|
||||||
const key = `boundary:${item.key}`;
|
const key = `boundary:${item.key}`;
|
||||||
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
const sectionRing = [outer.right, inner.right, inner.left, outer.left, outer.right];
|
||||||
|
|||||||
Reference in new issue
Block a user