From 919aad8b5d6e346797bacfc8abbeea9e60f7ebf4 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 14:51:27 -0700 Subject: [PATCH] polygon_to_cells alias (#399) --- src/h3/api/basic_int/__init__.py | 7 +++++++ tests/polyfill/test_h3.py | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/h3/api/basic_int/__init__.py b/src/h3/api/basic_int/__init__.py index 818618974..d292ed698 100644 --- a/src/h3/api/basic_int/__init__.py +++ b/src/h3/api/basic_int/__init__.py @@ -446,6 +446,13 @@ def h3shape_to_cells(h3shape, res): return _out_collection(mv) +def polygon_to_cells(h3shape, res): + """ + Alias for ``h3shape_to_cells``. + """ + return h3shape_to_cells(h3shape, res) + + def cells_to_h3shape(cells, *, tight=True): """ Return an ``H3Shape`` describing the area covered by a collection of H3 cells. diff --git a/tests/polyfill/test_h3.py b/tests/polyfill/test_h3.py index b6de1019d..8d9d9480e 100644 --- a/tests/polyfill/test_h3.py +++ b/tests/polyfill/test_h3.py @@ -107,6 +107,16 @@ def test_polyfill(): assert '89283095edbffff' in out +def test_polygon_to_cells(): + poly = h3.LatLngPoly(sf_7x7) + # Note that `polygon_to_cells` is an alias for `h3shape_to_cells` + out = h3.polygon_to_cells(poly, res=9) + + assert len(out) == 1253 + assert '89283080527ffff' in out + assert '89283095edbffff' in out + + def test_polyfill_with_hole(): poly = h3.LatLngPoly(sf_7x7, sf_hole1)