Skip to content

Commit

Permalink
Implement polygonToCellsCompact
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Rabinowitz committed Oct 3, 2023
1 parent e3102ce commit e041cbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/h3lib/include/polyfill.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ H3Error H3_EXPORT(polygonToCells2)(const GeoPolygon *polygon,
int res, uint32_t flags,
H3Index *out);

H3Error H3_EXPORT(polygonToCells3)(const GeoPolygon *polygon,
H3Error H3_EXPORT(polygonToCellsCompact)(const GeoPolygon *polygon,
int res, uint32_t flags,
H3Index *out);

Expand Down
13 changes: 13 additions & 0 deletions src/h3lib/lib/polyfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,17 @@ H3Error H3_EXPORT(polygonToCells2)(const GeoPolygon *polygon, int res,
out[i++] = iter.cell;
}
return iter.error;
}

/**
* Compact implementation for polygonToCells
*/
H3Error H3_EXPORT(polygonToCellsCompact)(const GeoPolygon *polygon, int res,
uint32_t flags, H3Index *out) {
IterCellsPolygonCompact iter = iterInitPolygonCompact(polygon, res, flags);
int64_t i = 0;
for (; iter.cell; iterStepPolygonCompact(&iter)) {
out[i++] = iter.cell;
}
return iter.error;
}

0 comments on commit e041cbe

Please sign in to comment.