fix: apply complex carriageway edge offsets

This commit is contained in:
que01 committed 2026-09-10 11:17:15 +08:00
1 parent 38dc9d6f52
commit 936354fec8
2 files changed
+18 -7

No files matched your search

+7 -3
View File
@@ -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];