feat(junction): expose stage1 structure and standards panel

This commit is contained in:
que01 committed 2026-09-07 14:52:06 +08:00
1 parent 0f804b71d1
commit fc7fe81eff
15 files changed
+434 -17

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
'use strict';
const assert = require('assert/strict');
const { projectJunctionStructure, standardsDiagnostics } = require('../src/compile/junction-projection');
const model = {
roads: [
{
id: 'road:north',
sourceNodeIds: ['junction'],
tags: { name: '北环路' },
direction: 'two-way',
laneCount: 2,
widthMeters: 7,
},
{
id: 'road:east',
sourceNodeIds: ['junction'],
tags: { name: '东环路' },
direction: 'oneway',
laneCount: 1,
widthMeters: 3.5,
},
{
id: 'road:remote',
sourceNodeIds: ['elsewhere'],
tags: { name: '不属于当前路口' },
direction: 'two-way',
laneCount: 2,
widthMeters: 7,
},
],
endpoints: [
{ nodeId: 'junction', coordinate: [120, 30] },
{ nodeId: 'elsewhere', coordinate: [120.01, 30.01] },
],
};
const structure = projectJunctionStructure({
model,
layers: {
crosswalks: {
type: 'FeatureCollection',
features: [{ type: 'Feature', properties: { native_id: 'crossing:north' }, geometry: null }],
},
vehicleStopLines: {
type: 'FeatureCollection',
features: [{ type: 'Feature', properties: { native_id: 'stop-line:north' }, geometry: null }],
},
intersectionSurface: { type: 'FeatureCollection', features: [] },
},
trafficSignals: {
assemblies: {
type: 'FeatureCollection',
features: [{ type: 'Feature', properties: { signal_uid: 'signal:north' }, geometry: null }],
},
},
});
assert.equal(structure.junctionKey, 'junction');
assert.equal(structure.shape.kind, 'unsupported');
assert.deepEqual(
structure.arms.map((arm) => arm.label),
['北环路', '东环路'],
);
assert.equal(structure.arms[1].directionality, 'one-way');
assert.equal(structure.corners.length, 2);
assert.deepEqual(
structure.facilities.map((facility) => facility.kind),
['crossing', 'stop-line', 'signal'],
);
const diagnostics = standardsDiagnostics(structure);
assert.equal(diagnostics.length, 2);
assert.equal(diagnostics[0].severity, 'pass');
assert.equal(diagnostics[1].severity, 'warning');
assert.equal(diagnostics[1].objectKey, 'road-arm:road:east');
console.log('junction projection tests passed');