diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index 8c25b20..6c0fdcc 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -528,7 +528,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { closure_count: coreClosure.closureCount, provenance: 'native-road-complex-junction/v7-shared-entry-core', }, - geometry: { type: 'Polygon', coordinates: [coreRing] }, + geometry: { type: 'Polygon', coordinates: [coreRing, ...(coreClosure.holes || [])] }, }); else { cornerDiagnostics.push( diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index a9037b5..53909a7 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -239,7 +239,15 @@ function buildCoreClosure(topology, graph, center) { }); if (ring.length < 7 || hasZeroLengthEdge || !paired || Math.abs(signedArea(ring)) < 1e-14 || ringSelfIntersects(ring)) return { status: 'unsupported', reason: 'core-closure-invalid' }; - if (graph.exclusionRegions.some((region) => ringsOverlap(region.ring, ring))) + const holes = graph.exclusionRegions + .filter((region) => { + const boundaryIntersects = ringSelfIntersects([...region.ring]); + const contained = region.ring.slice(0, -1).every((point) => pointInRing(point, ring)); + const clearOfEntries = graph.sections.every((section) => !ringsOverlap(region.ring, section.ring)); + return region.isHole === true && !boundaryIntersects && contained && clearOfEntries; + }) + .map((region) => region.ring); + if (graph.exclusionRegions.some((region) => ringsOverlap(region.ring, ring) && !holes.includes(region.ring))) return { status: 'unsupported', reason: 'known-exclusion-region' }; const seamErrors = graph.sections.map((section) => { const leftIndex = ring.findIndex( @@ -270,6 +278,7 @@ function buildCoreClosure(topology, graph, center) { return { status: 'supported', ring, + holes, sharedEdgeRefs: [...pairedEdges.keys()].sort(), closureCount: graph.sections.length, maxSharedSeamErrorMeters: seamErrorMeters,