feat(junction): classify complex junction shapes
This commit is contained in:
1 parent
38ea779d9b
commit
a359f88edc
13 files changed
+440
-14
No files matched your search
@@ -9,6 +9,41 @@ assert.equal(typeof compiler.laneGeometry.laneCenterline, 'function');
|
||||
assert.equal(typeof compiler.gaodeReference.convertGeoJson, 'function');
|
||||
assert.equal(typeof compiler.turnLaneArrows.buildCustomTurnLaneArrows, 'function');
|
||||
assert.equal(typeof compiler.complexJunction.buildComplexJunctionGeometry, 'function');
|
||||
assert.equal(typeof compiler.complexJunction.classifyJunctionShape, 'function');
|
||||
const shapeHelpers = { distanceMeters: (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]) };
|
||||
const arm = (heading, distance = 20) => ({
|
||||
heading,
|
||||
members: [
|
||||
{
|
||||
approach: {
|
||||
line: [
|
||||
[0, 0],
|
||||
[0, distance],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
assert.equal(
|
||||
compiler.complexJunction.classifyJunctionShape([arm(0), arm(90), arm(180), arm(270)], [0, 0], shapeHelpers).kind,
|
||||
'cross',
|
||||
);
|
||||
assert.equal(
|
||||
compiler.complexJunction.classifyJunctionShape([arm(0), arm(120), arm(180)], [0, 0], shapeHelpers).kind,
|
||||
't-junction',
|
||||
);
|
||||
assert.equal(
|
||||
compiler.complexJunction.classifyJunctionShape([arm(0), arm(80), arm(140)], [0, 0], shapeHelpers).kind,
|
||||
'multi-arm',
|
||||
);
|
||||
assert.equal(
|
||||
compiler.complexJunction.classifyJunctionShape([arm(0), arm(90), arm(180), arm(270)], [0, 0], shapeHelpers).label,
|
||||
'4 臂十字路口',
|
||||
);
|
||||
assert.equal(
|
||||
compiler.complexJunction.classifyJunctionShape([arm(0), arm(90)], [0, 0], shapeHelpers).kind,
|
||||
'unsupported',
|
||||
);
|
||||
assert.equal(typeof compiler.nativeRoad.compileRoadModel, 'function');
|
||||
assert.equal(typeof compiler.check.checkOutput, 'function');
|
||||
assert.equal(typeof compiler.layerManifest.manifestForArea, 'function');
|
||||
@@ -28,4 +63,32 @@ const model = compiler.nativeRoad.compileRoadModel(fs.readFileSync(fixture, 'utf
|
||||
overrides: [],
|
||||
});
|
||||
assert.equal(model.roads.length, 24);
|
||||
const complexModel = compiler.nativeRoad.compileRoadModel(fs.readFileSync(fixture, 'utf8'), {
|
||||
schema: 'native-road-overrides/v1',
|
||||
overrides: [],
|
||||
});
|
||||
const complexGeometry = compiler.nativeRoad.compileGeometry(
|
||||
complexModel,
|
||||
{ schema: 'native-road-overrides/v1', overrides: [] },
|
||||
{
|
||||
edgeLines: false,
|
||||
junctionTemplates: {
|
||||
enabled: true,
|
||||
clusters: [
|
||||
{
|
||||
id: 'fixture-five-arm',
|
||||
template: 'complex-junction-v1',
|
||||
nodeIds: ['8005332807', '8024512135', '8024512145', '8024512147', '8613058676'],
|
||||
coreRadiusMeters: 24,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
const complexCore = complexGeometry.roadSurface.features.find(
|
||||
(feature) => feature.properties?.kind === 'complex-core' && feature.properties?.cluster_id === 'fixture-five-arm',
|
||||
);
|
||||
assert.equal(complexCore?.properties?.shape_kind, 'multi-arm');
|
||||
assert.equal(complexCore?.properties?.arm_count, 5);
|
||||
assert.ok(complexGeometry.roadSurface.features.some((feature) => feature.properties?.kind === 'complex-approach'));
|
||||
console.log('road compiler package tests passed');
|
||||
Reference in new issue
Block a user