From e041cbe8a78c6ec1bb3b9d129f11b6922b1e2648 Mon Sep 17 00:00:00 2001 From: Nick Rabinowitz Date: Tue, 3 Oct 2023 11:27:39 -0700 Subject: [PATCH] Implement polygonToCellsCompact --- src/h3lib/include/polyfill.h | 2 +- src/h3lib/lib/polyfill.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/h3lib/include/polyfill.h b/src/h3lib/include/polyfill.h index a9110ebf2..3dbb11dd4 100644 --- a/src/h3lib/include/polyfill.h +++ b/src/h3lib/include/polyfill.h @@ -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); diff --git a/src/h3lib/lib/polyfill.c b/src/h3lib/lib/polyfill.c index 93085b4f7..1745fdfd3 100644 --- a/src/h3lib/lib/polyfill.c +++ b/src/h3lib/lib/polyfill.c @@ -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; } \ No newline at end of file