fix: align separators at complex crosswalks
This commit is contained in:
1 parent
c03a90709e
commit
0f1850f740
2 files changed
+32
-4
No files matched your search
@@ -1185,9 +1185,27 @@ function compileComplexLaneSeparators(features, controls = [], clusterCenters =
|
||||
),
|
||||
)
|
||||
: null;
|
||||
for (const { index, left, right, line } of prepared) {
|
||||
const publishedLine =
|
||||
center && Number.isFinite(sharedRadius) ? trimLineOutsideRadius(line, center, sharedRadius) : line;
|
||||
const radiusClipped = prepared.map(({ line }) =>
|
||||
center && Number.isFinite(sharedRadius) ? trimLineOutsideRadius(line, center, sharedRadius) : line,
|
||||
);
|
||||
// A diagonal zebra intersects adjacent lane separators at different
|
||||
// longitudinal stations. Use the shortest post-control line as the
|
||||
// shared inward cutoff so parallel separators terminate at one crossing
|
||||
// boundary instead of leaving one visibly longer than its neighbour.
|
||||
const sharedVisibleLength = Math.min(
|
||||
...radiusClipped.filter(Boolean).map((line) => lineLengthMeters(line)),
|
||||
);
|
||||
for (let preparedIndex = 0; preparedIndex < prepared.length; preparedIndex += 1) {
|
||||
const { index, left, right } = prepared[preparedIndex];
|
||||
const line = radiusClipped[preparedIndex];
|
||||
if (!line) continue;
|
||||
const outwardFirst = distanceMeters(line[0], center) >= distanceMeters(line.at(-1), center);
|
||||
const oriented = outwardFirst ? line : [...line].reverse();
|
||||
const publishedOriented =
|
||||
Number.isFinite(sharedVisibleLength) && lineLengthMeters(oriented) > sharedVisibleLength + 0.01
|
||||
? trimLineRange(oriented, 0, lineLengthMeters(oriented) - sharedVisibleLength)
|
||||
: oriented;
|
||||
const publishedLine = outwardFirst ? publishedOriented : [...publishedOriented].reverse();
|
||||
const ring = roadRing(publishedLine, 0.12);
|
||||
if (!ring) continue;
|
||||
result.push({
|
||||
|
||||
@@ -57,12 +57,22 @@ for (const ordered of [clusters, [...clusters].reverse()]) {
|
||||
.filter((separator) => separator.properties.cluster_id === 'west')
|
||||
.map((separator) => {
|
||||
const ring = separator.geometry.coordinates[0];
|
||||
return Math.min(...ring.map((point) => meters(point, clusterCenter)));
|
||||
const start = [(ring[0][0] + ring[1][0]) / 2, (ring[0][1] + ring[1][1]) / 2];
|
||||
const end = [(ring[2][0] + ring[3][0]) / 2, (ring[2][1] + ring[3][1]) / 2];
|
||||
return meters(start, end);
|
||||
});
|
||||
assert.ok(
|
||||
Math.max(...endpointDistances) - Math.min(...endpointDistances) < 0.2,
|
||||
'adjacent complex separators must share a stable core-side endpoint',
|
||||
);
|
||||
const separatorLengths = complexSeparators.map((separator) => {
|
||||
const ring = separator.geometry.coordinates[0];
|
||||
return ring.slice(1, -1).reduce((sum, point, index) => sum + meters(ring[index], point), 0);
|
||||
});
|
||||
assert.ok(
|
||||
Math.max(...separatorLengths) - Math.min(...separatorLengths) < 0.2,
|
||||
'adjacent complex separators must share the same zebra-side cutoff',
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const separator of complexSeparators) {
|
||||
|
||||
Reference in new issue
Block a user