Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Use pyproj to check CRS equality if GDAL not available #160

Merged
merged 2 commits into from
Nov 22, 2024
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 .github/python_test_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: testenv
channels:
- conda-forge
dependencies:
- libgdal-netcdf
- python-build
- gdal
- geopandas
Expand Down
17 changes: 15 additions & 2 deletions python/src/exactextract/exact_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,23 @@
except AttributeError:
pass

return srs_a.IsSame(srs_b)
return bool(srs_a.IsSame(srs_b))

except ImportError:
return False
pass

Check warning on line 323 in python/src/exactextract/exact_extract.py

View check run for this annotation

Codecov / codecov/patch

python/src/exactextract/exact_extract.py#L323

Added line #L323 was not covered by tests

try:
from pyproj import CRS

Check warning on line 326 in python/src/exactextract/exact_extract.py

View check run for this annotation

Codecov / codecov/patch

python/src/exactextract/exact_extract.py#L325-L326

Added lines #L325 - L326 were not covered by tests

crs_a = CRS.from_string(a.srs_wkt())
crs_b = CRS.from_string(b.srs_wkt())

Check warning on line 329 in python/src/exactextract/exact_extract.py

View check run for this annotation

Codecov / codecov/patch

python/src/exactextract/exact_extract.py#L328-L329

Added lines #L328 - L329 were not covered by tests

return crs_a == crs_b

Check warning on line 331 in python/src/exactextract/exact_extract.py

View check run for this annotation

Codecov / codecov/patch

python/src/exactextract/exact_extract.py#L331

Added line #L331 was not covered by tests

except ImportError:
pass

Check warning on line 334 in python/src/exactextract/exact_extract.py

View check run for this annotation

Codecov / codecov/patch

python/src/exactextract/exact_extract.py#L333-L334

Added lines #L333 - L334 were not covered by tests

return False

Check warning on line 336 in python/src/exactextract/exact_extract.py

View check run for this annotation

Codecov / codecov/patch

python/src/exactextract/exact_extract.py#L336

Added line #L336 was not covered by tests


def warn_on_crs_mismatch(vec, ops):
Expand Down
Loading