Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
conda*
.conda*
.spyproject/
.vscode/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Currently this tool supports the following DGGSs:
- [H3](https://h3geo.org/)
- [rHEALPix](https://datastore.landcareresearch.co.nz/dataset/rhealpix-discrete-global-grid-system)
- [S2](https://s2geometry.io/)
- [A5](https://a5geo.org/)

... and the following geocode systems:

Expand Down Expand Up @@ -164,6 +165,12 @@ Or without activating the shell:
poetry run python tests/test_vector2dggs.py
```

To test a specific DGGS:

```bash
python -m pytest tests/test_runthrough.py -k "a5" -v
```

Test data are included at `tests/data/`.

## Example commands
Expand Down
23 changes: 20 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ rhealpixdggs = { version = "^0.5.12", optional = true}
s2geometry = { version = "^0.9.0", optional = true}
rusty-polygon-geohasher = { version = "^0.2.3", optional = true}
python-geohash = { version = "^0.8.5", optional = true}
pya5 = { version = "^0.8.0", optional = true }
urllib3 = "^2.6.3"
cryptography = "^46.0.5"

Expand All @@ -58,6 +59,7 @@ line-length = 88
h3 = ["h3"]
rhp = ["rhppandas", "rhealpixdggs"]
s2 = ["s2geometry"]
a5 = ["pya5"]
geohash = ["rusty-polygon-geohasher", "python-geohash"]
# Convenience extras
all = ["h3", "rhppandas", "rhealpixdggs", "s2geometry", "rusty-polygon-geohasher", "python-geohash"]
all = ["h3", "rhppandas", "rhealpixdggs", "s2geometry", "rusty-polygon-geohasher", "python-geohash", "pya5"]
215 changes: 215 additions & 0 deletions tests/classes/a5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
from .base import TestRunthrough
from ..data.datapaths import *

from vector2dggs.a5 import a5


class TestA5(TestRunthrough):
"""
Sends the test data file through A5 indexing using default parameters.
"""

def test_a5_run(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
],
standalone_mode=False,
)

except Exception:
self.fail(f"A5 runthrough failed.")

def test_a5_run_overwrite(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
],
standalone_mode=False,
)
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"-o",
],
standalone_mode=False,
)

except Exception:
self.fail(f"A5 runthrough with overwrite failed.")

def test_a5_cut_crs(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"-crs",
"3793",
"-c",
"4000",
],
standalone_mode=False,
)

except Exception:
self.fail("A5 run through using actual CRS failed")

def test_a5_cut_crs_reproject(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"-crs",
"4326",
"-c",
"0.005",
],
standalone_mode=False,
)
except Exception:
self.fail("A5 run through with reprojected CRS failed")

def test_a5_no_bisection(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"-c",
"0",
],
standalone_mode=False,
)
except Exception:
self.fail("A5 run through without bisection failed")

def test_a5_compaction(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"-co",
"-id",
"LCDB_UID",
],
standalone_mode=False,
)

except Exception:
self.fail(f"A5 runthrough with compaction failed.")

def test_a5_geo_point(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"--geo",
"point",
],
standalone_mode=False,
)
except Exception:
self.fail("A5 run through with --geo point failed")

def test_a5_geo_point_compact(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"--geo",
"point",
"-co",
"-id",
"LCDB_UID",
"-o",
],
standalone_mode=False,
)
except Exception:
self.fail("A5 run through with --geo point -co failed")

def test_a5_geo_polygon(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"--geo",
"polygon",
],
standalone_mode=False,
)
except Exception:
self.fail("A5 run through with --geo polygon failed")

def test_a5_geo_polygon_compact(self):
try:
a5(
[
TEST_FILE_PATH,
str(TEST_OUTPUT_PATH),
"--layer",
TEST_LAYER_NAME,
"-r",
"17",
"--geo",
"polygon",
"-co",
"-id",
"LCDB_UID",
"-o",
],
standalone_mode=False,
)
except Exception:
self.fail("A5 run through with --geo polygon -co failed")
Loading
Loading