feat(junction): project sourced islands
This commit is contained in:
1 parent
cd3a9c9613
commit
0e162d1f43
3 files changed
+67
-1
No files matched your search
@@ -536,7 +536,33 @@ function buildComplexJunctionGeometry(model, cluster, helpers) {
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
const allFeatures = [...features, ...islands, ...sidewalkCorners, ...crosswalks, ...stopLines];
|
const knownIslandFeatures = (model.exclusionRegions || [])
|
||||||
|
.filter(
|
||||||
|
(region) =>
|
||||||
|
Array.isArray(region.ring) &&
|
||||||
|
region.ring.length >= 4 &&
|
||||||
|
region.ring.some((point) => helpers.distanceMeters(point, center) <= outerRadius + 12),
|
||||||
|
)
|
||||||
|
.map((region) => ({
|
||||||
|
type: 'Feature',
|
||||||
|
properties: {
|
||||||
|
native_id: `osm-traffic-island:${region.id}`,
|
||||||
|
object_key: `island:osm/${region.id}`,
|
||||||
|
kind: 'island',
|
||||||
|
osm_way_ids: String(region.id),
|
||||||
|
source: region.source,
|
||||||
|
facility_evidence: 'source-osm-region',
|
||||||
|
},
|
||||||
|
geometry: { type: 'Polygon', coordinates: [region.ring] },
|
||||||
|
}));
|
||||||
|
const allFeatures = [
|
||||||
|
...features,
|
||||||
|
...islands,
|
||||||
|
...sidewalkCorners,
|
||||||
|
...crosswalks,
|
||||||
|
...stopLines,
|
||||||
|
...knownIslandFeatures,
|
||||||
|
];
|
||||||
const structure = structureFromTopology(topology, shape, center, allFeatures);
|
const structure = structureFromTopology(topology, shape, center, allFeatures);
|
||||||
for (const feature of allFeatures) {
|
for (const feature of allFeatures) {
|
||||||
feature.properties.junction_key = structure.junctionKey;
|
feature.properties.junction_key = structure.junctionKey;
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ function structureFromTopology(topology, shape, center, features) {
|
|||||||
'complex-corner-crosswalk': 'crossing',
|
'complex-corner-crosswalk': 'crossing',
|
||||||
'complex-stop-line': 'stop-line',
|
'complex-stop-line': 'stop-line',
|
||||||
'complex-corner-island': 'island',
|
'complex-corner-island': 'island',
|
||||||
|
island: 'island',
|
||||||
'complex-sidewalk-corner': 'sidewalk-turn',
|
'complex-sidewalk-corner': 'sidewalk-turn',
|
||||||
}[p.kind];
|
}[p.kind];
|
||||||
if (!kind || !p.object_key) continue;
|
if (!kind || !p.object_key) continue;
|
||||||
|
|||||||
@@ -193,4 +193,43 @@ assert.equal(
|
|||||||
.provenance.facilityEvidence,
|
.provenance.facilityEvidence,
|
||||||
'source-crossing-node',
|
'source-crossing-node',
|
||||||
);
|
);
|
||||||
|
const knownIsland = {
|
||||||
|
id: 'known-structure-island',
|
||||||
|
source: 'osm-traffic-island',
|
||||||
|
ring: [
|
||||||
|
[sourceCenter[0] - 0.00001, sourceCenter[1] - 0.00001],
|
||||||
|
[sourceCenter[0] + 0.00001, sourceCenter[1] - 0.00001],
|
||||||
|
[sourceCenter[0] + 0.00001, sourceCenter[1] + 0.00001],
|
||||||
|
[sourceCenter[0] - 0.00001, sourceCenter[1] + 0.00001],
|
||||||
|
[sourceCenter[0] - 0.00001, sourceCenter[1] - 0.00001],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const islandStructureModel = structuredClone(sourceCrossingModel);
|
||||||
|
islandStructureModel.exclusionRegions = [knownIsland];
|
||||||
|
const islandStructureGeometry = compiler.nativeRoad.compileGeometry(
|
||||||
|
islandStructureModel,
|
||||||
|
{ 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 islandStructure = islandStructureGeometry.roadSurface.features.find(
|
||||||
|
(feature) => feature.properties?.junction_structure,
|
||||||
|
)?.properties.junction_structure;
|
||||||
|
assert.equal(
|
||||||
|
islandStructure.facilities.find((facility) => facility.key === 'island:osm/known-structure-island').provenance
|
||||||
|
.facilityEvidence,
|
||||||
|
'source-osm-region',
|
||||||
|
);
|
||||||
console.log('road compiler package tests passed');
|
console.log('road compiler package tests passed');
|
||||||
Reference in new issue
Block a user