test(junction): cover known island exclusions

This commit is contained in:
que01 committed 2026-09-09 09:57:14 +08:00
1 parent 4b8f37a219
commit 75bdfbe607
2 files changed
+21

No files matched your search

+12
View File
@@ -66,6 +66,18 @@ const model = compiler.nativeRoad.compileRoadModel(fs.readFileSync(fixture, 'utf
overrides: [], overrides: [],
}); });
assert.equal(model.roads.length, 24); assert.equal(model.roads.length, 24);
const islandModel = compiler.nativeRoad.compileRoadModel(
`<osm>
<node id="1" lon="120" lat="30"/><node id="2" lon="120.0001" lat="30"/>
<node id="3" lon="120.0001" lat="30.0001"/><node id="4" lon="120" lat="30.0001"/>
<way id="island"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="1"/><tag k="highway" v="traffic_island"/></way>
</osm>`,
{ schema: 'native-road-overrides/v1', overrides: [] },
);
assert.deepEqual(
islandModel.exclusionRegions.map((region) => [region.id, region.source]),
[['island', 'osm-traffic-island']],
);
const complexModel = compiler.nativeRoad.compileRoadModel(fs.readFileSync(fixture, 'utf8'), { const complexModel = compiler.nativeRoad.compileRoadModel(fs.readFileSync(fixture, 'utf8'), {
schema: 'native-road-overrides/v1', schema: 'native-road-overrides/v1',
overrides: [], overrides: [],
@@ -126,6 +126,15 @@ const teeCore = buildCoreClosure(tee.topology, teeBoundaryGraph, point(0, 0));
assert.equal(teeCore.status, 'supported'); assert.equal(teeCore.status, 'supported');
assert.equal(teeCore.sharedEdgeRefs.length, teeBoundaryGraph.sections.length); assert.equal(teeCore.sharedEdgeRefs.length, teeBoundaryGraph.sections.length);
assert.ok(teeCore.ring.every((coordinate) => coordinate.every(Number.isFinite))); assert.ok(teeCore.ring.every((coordinate) => coordinate.every(Number.isFinite)));
const exclusionRing = [point(-1, -1), point(1, -1), point(1, 1), point(-1, 1), point(-1, -1)];
const teeWithIsland = buildJunctionBoundaryGraph(
tee.topology,
point(0, 0),
{ outerRadiusFor: () => 30, innerRadiusFor: () => 10 },
tee.helpers,
[{ id: 'island:known', ring: exclusionRing }],
);
assert.equal(buildCoreClosure(tee.topology, teeWithIsland, point(0, 0)).reason, 'known-exclusion-region');
// Offset and unequal-width approaches preserve individual source sections and // Offset and unequal-width approaches preserve individual source sections and
// local section tangents rather than a single arm envelope. // local section tangents rather than a single arm envelope.