47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
'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');
|