From 77d746fbf636df83dd7a6598db0beed1e94dc075 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Tue, 5 Nov 2024 11:24:50 -0800 Subject: [PATCH 1/5] codecov4 --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 5167a386..2c9141c1 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -79,7 +79,7 @@ --cov-report xml - name: codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml From 4eba45f413a3b01582c42695169a7f9e0b408275 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Thu, 23 Jan 2025 10:16:14 -0800 Subject: [PATCH 2/5] get edge length by version; --- tobler/util/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tobler/util/util.py b/tobler/util/util.py index 3f88b02d..1735b9da 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -35,8 +35,10 @@ def circumradius(resolution): "You can install it with `conda install h3-py` or " "`pip install h3`" ) - - return h3.edge_length(resolution, "m") + h3ver = h3.__version__ + if h3ver < 4: + return h3.edge_length(resolution, "m") + return h3.average_edge_length(resolution, "m") def _check_crs(source_df, target_df): From b31632b22e20bd0599f177a42f93323fd158bec4 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Thu, 23 Jan 2025 10:25:50 -0800 Subject: [PATCH 3/5] convert to number --- tobler/util/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tobler/util/util.py b/tobler/util/util.py index 1735b9da..a0f681e7 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -35,7 +35,7 @@ def circumradius(resolution): "You can install it with `conda install h3-py` or " "`pip install h3`" ) - h3ver = h3.__version__ + h3ver = int(h3.__version__[0]) if h3ver < 4: return h3.edge_length(resolution, "m") return h3.average_edge_length(resolution, "m") From d6092e2fdedb0b06b0bc235021221c2d6cbb7db1 Mon Sep 17 00:00:00 2001 From: knaaptime Date: Thu, 23 Jan 2025 10:30:39 -0800 Subject: [PATCH 4/5] add test --- tobler/tests/test_utils.py | 8 ++++++++ tobler/util/util.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tobler/tests/test_utils.py b/tobler/tests/test_utils.py index b5dca26e..6b724196 100644 --- a/tobler/tests/test_utils.py +++ b/tobler/tests/test_utils.py @@ -52,6 +52,14 @@ def test_h3fy_clip(): sac_hex.area.sum(), 13131736346.537422, decimal=0 ) +def test_h3fy_clip_buffer(): + sac1 = load_example("Sacramento1") + sac1 = geopandas.read_file(sac1.get_path("sacramentot2.shp")) + sac_hex = h3fy(sac1, clip=True, buffer=True) + sac_hex = sac_hex.to_crs(sac_hex.estimate_utm_crs()) + assert_almost_equal( + sac_hex.area.sum(), 13749446323.1722, decimal=0 + ) @pytest.mark.skipif(platform.system() == "Windows", reason='Unknown precision error on Windows. See #174 for details') def test_h3_multipoly(): diff --git a/tobler/util/util.py b/tobler/util/util.py index a0f681e7..0c4474f3 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -38,7 +38,7 @@ def circumradius(resolution): h3ver = int(h3.__version__[0]) if h3ver < 4: return h3.edge_length(resolution, "m") - return h3.average_edge_length(resolution, "m") + return h3.average_hexagon_edge_length(resolution, "m") def _check_crs(source_df, target_df): From b58302964ea1f04a961fd1b7980bed7487a3e099 Mon Sep 17 00:00:00 2001 From: eli knaap Date: Thu, 23 Jan 2025 11:28:35 -0800 Subject: [PATCH 5/5] Update tobler/util/util.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💪 Co-authored-by: Martin Fleischmann --- tobler/util/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tobler/util/util.py b/tobler/util/util.py index 0c4474f3..88c8add8 100644 --- a/tobler/util/util.py +++ b/tobler/util/util.py @@ -35,8 +35,7 @@ def circumradius(resolution): "You can install it with `conda install h3-py` or " "`pip install h3`" ) - h3ver = int(h3.__version__[0]) - if h3ver < 4: + if Version(h3.__version__) < Version("4.0"): return h3.edge_length(resolution, "m") return h3.average_hexagon_edge_length(resolution, "m")