feat(junction): expose stage1 structure and standards panel
This commit is contained in:
1 parent
0f804b71d1
commit
fc7fe81eff
15 files changed
+434
-17
No files matched your search
@@ -12,6 +12,7 @@ assert.equal(typeof compiler.complexJunction.buildComplexJunctionGeometry, 'func
|
||||
assert.equal(typeof compiler.complexJunction.classifyJunctionShape, 'function');
|
||||
assert.equal(typeof compiler.junctionStructure.buildJunctionStructure, 'function');
|
||||
assert.equal(typeof compiler.junctionStandards.validateStandardsProfile, 'function');
|
||||
assert.equal(typeof compiler.junctionProjection.projectJunctionStructure, 'function');
|
||||
const shapeHelpers = { distanceMeters: (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]) };
|
||||
const arm = (heading, distance = 20) => ({
|
||||
heading,
|
||||
|
||||
@@ -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');
|
||||
Reference in new issue
Block a user