Skip to content

Commit d2756ff

Browse files
committed
Fix hole logic in geodesic polyfill
1 parent 90915a2 commit d2756ff

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/h3lib/lib/geodesicIterator.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,25 @@ void geodesicIteratorStep(IterCellsPolygonCompact *iter, H3Index cell) {
148148
}
149149

150150
// Center is outside and no edge intersection. The polygon may
151-
// be inside the cell. Check by testing if polygon vertex is
152-
// inside the cell.
151+
// be inside the cell. Check if any loop vertex (outer shell or hole)
152+
// falls inside the cell. An outer vertex here means the polygon is
153+
// smaller than the cell; a hole vertex here means the hole is inside
154+
// the cell, so the filled region (outer minus holes) still overlaps it.
153155
H3Index polygonCell;
154156
Vec3d *firstVert = &poly->geoloop.edges[0].vert;
155157
H3_CHECK(vec3ToCell(firstVert, cellRes, &polygonCell), iter);
156158
if (polygonCell == cell) {
157159
iter->cell = cell;
158160
return;
159161
}
162+
for (int hi = 0; hi < poly->numHoles; hi++) {
163+
Vec3d *holeVert = &poly->holes[hi].edges[0].vert;
164+
H3_CHECK(vec3ToCell(holeVert, cellRes, &polygonCell), iter);
165+
if (polygonCell == cell) {
166+
iter->cell = cell;
167+
return;
168+
}
169+
}
160170

161171
cell = nextCell(cell);
162172
}

0 commit comments

Comments
 (0)