fix: align complex junction separator cutoffs

This commit is contained in:
que01 committed 2026-09-29 09:59:06 +08:00
1 parent 1842eb7d8c
commit c03a90709e
2 files changed
+37 -5

No files matched your search

+23 -4
View File
@@ -1149,6 +1149,10 @@ function compileComplexLaneSeparators(features, controls = [], clusterCenters =
for (const lanes of groups.values()) {
const roadId = lanes[0].properties.road_id;
lanes.sort((first, second) => first.properties.lane_index - second.properties.lane_index);
const clusterId = lanes[0].properties.cluster_id;
const center = clusterCenters.get(clusterId);
const coreRadius = clusterCoreRadii.get(clusterId);
const prepared = [];
for (let index = 1; index < lanes.length; index += 1) {
const left = lanes[index - 1].geometry.coordinates;
const right = lanes[index].geometry.coordinates;
@@ -1162,14 +1166,29 @@ function compileComplexLaneSeparators(features, controls = [], clusterCenters =
// near the core and make the separator disappear entirely.
const roadControls = controls.filter((control) => String(control.properties?.road_id || '') === String(roadId));
const visibleLine = trimLineBeforeFirstControl(line, roadControls, 0.12);
const clusterId = lanes[0].properties.cluster_id;
const center = clusterCenters.get(clusterId);
const coreRadius = clusterCoreRadii.get(clusterId);
const coreClippedLine =
visibleLine && center && Number.isFinite(coreRadius)
? trimLineOutsideRadius(visibleLine, center, coreRadius)
: visibleLine;
const ring = coreClippedLine ? roadRing(coreClippedLine, 0.12) : null;
if (!coreClippedLine) continue;
prepared.push({ index, left, right, line: coreClippedLine });
}
// Adjacent separators share the same zebra/stop-line cutoff. Their lane
// offsets can otherwise make the polygon-overlap probe stop a few
// centimetres apart, leaving visibly uneven endpoints. Use the shortest
// outward-to-inward station as the shared, geometry-derived cutoff.
if (!prepared.length) continue;
const sharedRadius = center
? Math.min(
...prepared.map(({ line }) =>
Math.min(...line.map((point) => distanceMeters(point, center))),
),
)
: null;
for (const { index, left, right, line } of prepared) {
const publishedLine =
center && Number.isFinite(sharedRadius) ? trimLineOutsideRadius(line, center, sharedRadius) : line;
const ring = roadRing(publishedLine, 0.12);
if (!ring) continue;
result.push({
type: 'Feature',
+14 -1
View File
@@ -36,7 +36,10 @@ for (const ordered of [clusters, [...clusters].reverse()]) {
const road = model.roads.find((r) => r.id === roadId);
const midpoint = road.centerline[0].map((v, i) => (v + road.centerline.at(-1)[i]) / 2);
const complexSeparators = geometry.laneSeparators.features.filter(
(f) => f.properties.road_id === roadId && f.properties.provenance === 'native-road-complex-lane-separator/v1',
(f) =>
f.properties.road_id === roadId &&
f.properties.cluster_id === 'west' &&
f.properties.provenance === 'native-road-complex-lane-separator/v1',
);
if (roadId === 'road:way/858770823:segment/2:forward') {
const core = geometry.roadSurface.features.find(
@@ -50,6 +53,16 @@ for (const ordered of [clusters, [...clusters].reverse()]) {
separator.geometry.coordinates[0].every((point) => meters(point, clusterCenter) >= coreRadius - 0.05),
'complex separator must stop outside the calibrated west-cluster core',
);
const endpointDistances = complexSeparators
.filter((separator) => separator.properties.cluster_id === 'west')
.map((separator) => {
const ring = separator.geometry.coordinates[0];
return Math.min(...ring.map((point) => meters(point, clusterCenter)));
});
assert.ok(
Math.max(...endpointDistances) - Math.min(...endpointDistances) < 0.2,
'adjacent complex separators must share a stable core-side endpoint',
);
}
}
for (const separator of complexSeparators) {