diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index f229188..09628ba 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -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); for (const feature of allFeatures) { feature.properties.junction_key = structure.junctionKey; diff --git a/src/compile/junction-topology.js b/src/compile/junction-topology.js index 6120b2c..83126c0 100644 --- a/src/compile/junction-topology.js +++ b/src/compile/junction-topology.js @@ -77,6 +77,7 @@ function structureFromTopology(topology, shape, center, features) { 'complex-corner-crosswalk': 'crossing', 'complex-stop-line': 'stop-line', 'complex-corner-island': 'island', + island: 'island', 'complex-sidewalk-corner': 'sidewalk-turn', }[p.kind]; if (!kind || !p.object_key) continue; diff --git a/test/index.js b/test/index.js index 02ef4af..17dd34c 100644 --- a/test/index.js +++ b/test/index.js @@ -193,4 +193,43 @@ assert.equal( .provenance.facilityEvidence, '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');