Skip to content

Commit

Permalink
polygon_to_cells alias (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfriend authored Sep 26, 2024
1 parent 6c4ae92 commit 919aad8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/h3/api/basic_int/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions tests/polyfill/test_h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 919aad8

Please sign in to comment.