fix: preserve approach lane separators near junction controls

This commit is contained in:
que01 committed 2026-09-14 15:24:50 +08:00
1 parent ad0f55e79d
commit 062f20f34c
3 files changed
+57 -4

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
'use strict';
const assert = require('assert/strict');
const fs = require('fs');
const { compileRoadModel, compileGeometry } = require('../src/compile/native-road');
const clusterNodeIds = new Set(['8005332807', '8024512135', '8024512145', '8024512147']);
const model = compileRoadModel(fs.readFileSync('./inputs/osm/枫树二路.osm', 'utf8'), { overrides: [] });
const geometry = compileGeometry(
model,
{ overrides: [] },
{
edgeLines: false,
junctionTemplates: {
enabled: true,
clusters: [
{
id: 'marking-containment',
template: 'complex-junction-v1',
coreRadiusMeters: 21,
nodeIds: [...clusterNodeIds],
},
],
},
},
);
const previewRoads = new Set(
geometry.laneCenterlines.features
.filter((feature) => feature.properties.cluster_preview)
.map((feature) => feature.properties.road_id),
);
const separatorsByRoad = new Map();
for (const feature of geometry.laneSeparators.features) {
const roadId = feature.properties.road_id;
separatorsByRoad.set(roadId, (separatorsByRoad.get(roadId) || 0) + 1);
}
for (const road of model.roads.filter((candidate) => previewRoads.has(candidate.id))) {
const internal = road.sourceNodeIds.every((nodeId) => clusterNodeIds.has(String(nodeId)));
const count = separatorsByRoad.get(road.id) || 0;
if (internal) assert.equal(count, 0, `${road.id} is internal and should not publish separators`);
else assert.ok(count > 0, `${road.id} lost all approach separators after control trimming`);
}
console.log('junction marking containment tests passed');