-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
osr_util.py
- bugfix and add default_axis_order
flag; arrays.py
- add types to remove dependency on numpy
#3778
Conversation
aa0faf9
to
81d4f06
Compare
f78efc0
to
862b97b
Compare
default_gis_order
flag to allow the user to change the defaultdefault_gis_order
flag to allow the user to change the default
default_gis_order
flag to allow the user to change the defaultdefault_axis_order
flag to allow the user to change the default
862b97b
to
2ded3cb
Compare
default_axis_order
flag to allow the user to change the defaultosr_util.py
- bugfix and add default_axis_order
flag; arrays.py
- add types to remove dependency on numpy
2ded3cb
to
259bde0
Compare
259bde0
to
3d8e845
Compare
@rouault I can't figure out why the following 3 tests fail. |
3d8e845
to
686a287
Compare
Hum, this is quite subtle, so let's see at:
Why IsSame() returns 1 whereas the axis order in the proj4 case is long/lat and in the importFromEPSG() is lat/long ? The reason is that the IsSame() behaviour by default is CRITERION=EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS, that is it ignores axis order difference for GeographicCRS. The reason for that was probably to diminish the level of backward incompatibility when we switched to PROJ 6 during the GDAL 2 --> GDAL 3 transition. But if now I do
they are no longer consider equivalent for IsSame(). The reason is that the first test in IsSame() checks that the GetDataAxisToSRSAxisMapping() of the 2 CRS is the same. Admitedly, this is quite confusing. Perhaps in the CRITERION=EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS case when we compare 2 Geographic CRS, we should also ignore the GetDataAxisToSRSAxisMapping() setting, but there might be some unforeseen impacts in doing that |
Thanks for looking into it! |
686a287
to
1b86ca3
Compare
Just thinking about how to solve this issue (outside of this PR)... So if I got it strait you mean that I think that we could take the following approach to make this right, but is this an issue of Anyway, if it's a GDAL issue then maybe we can solve it as follows: |
in GDAL, in the implementation of OGRSpatialReference::IsSame()
That sounds like a good plan. |
Any other comments about this PR? |
I'd go for that. I see it is currently used in the 3.3 branch but we didn't make any clear statements about what is considered to be in the API or implementation details |
Right, I was thinking how far should I go to keep backwards compatibility inside the auxiliary submodule, as it does adds clutter... |
It might be useful to have a clear statement about what is in the API and what is not at some point. And what is in the API should ideally come with some not-only-contained-in-py-files documentation. |
1b86ca3
to
9bb1bdb
Compare
Right, I'll try to formalize something like that. |
Ok, done, I think this PR is ready now. |
… ArrayLike, ScalarLike, ArrayOrScalarLike types (to be used instead of NumpyCompatibleArray, NumpyCompatibleArrayOrReal), removes numpy dependency osr_util.py, gdallocationinfo.py, numpy_util.py - use new types autotest/pyscripts/test_gdal_utils.py - test new types
…rs() - add `default_axis_order` flag (with get and set) to allow the user to change the default; add get_srs_pj(), are_srs_equivalent() support functions autotest/pyscripts/test_osr_util.py.py - add test get_srs() and get_transform() with different axis orders
9bb1bdb
to
d07f99b
Compare
Thanks @rouault! |
the backport bot is a regular github action, and it follows the queuing logic of github actions jobs. So a bit of patience: it is queued at https://github.com/OSGeo/gdal/actions/workflows/backport.yml |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release/3.3 release/3.3
# Navigate to the new working tree
cd .worktrees/backport-release/3.3
# Create a new branch
git switch --create backport-3778-to-release/3.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 7746b3c4af0007509af58f25c9404109e4351c87
# Push it to GitHub
git push --set-upstream origin backport-3778-to-release/3.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release/3.3 Then, create a pull request where the |
ok, so the automatic backport failed. @idanmiara I let you create a backport PR that cherry-picks the relevant commits |
Thanks. |
Backport 3.3 (#3778): osr_util.py - bugfix and add default_axis_order flag; arrays.py - add types to remove dependency on numpy
What does this PR do?
This PR solves two issues, I wanted to separate them but apparently for writing proper tests that don't depend on
numpy
I needed to merge them.I've added many tests for to make it right this time...
osr_util.py
depends on numpy. this PR remove this dependency.osgeo_utils/auxiliary/array_util.py
- addArrayLike
,ScalarLike
,ArrayOrScalarLike
types (replacesNumpyCompatibleArray
,NumpyCompatibleArrayOrReal
)osr_util.py, gdallocationinfo.py, numpy_util.py - use new types
autotest/pyscripts/test_gdal_utils.py - test new types
osr_util.py - add
default_axis_order
flag to allow the user to change the defaultsome applications use
gis_order
, this PR will allow them to override the default if they wish by adding the following code to their package/module__init__.py
Because
get_srs
is used in many inner functions, it would be very hard to propagate thegis_order
default without this PR.this PR also fixes a bug in get_srs() for the following case:
Also fixing the issue that calling
get_srs()
with anosr.SpatialReference
object modified the input object.With this PR it creates a copy and returns it.
Related PR
python/typing#593
#3780