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
Add shim module and support for GDAL 3 #804
Conversation
Regarding the "TypeError: attrib() got an unexpected keyword argument 'convert'" on travis this might be the reason: https://stackoverflow.com/questions/58189683/typeerror-attrib-got-an-unexpected-keyword-argument-convert |
fiona/_shim3.pyx
Outdated
@@ -0,0 +1,149 @@ | |||
"""Shims on top of ogrext for GDAL versions >= 2.2""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>= 3.0
- pip install -e .[test] | ||
- "python -m pip wheel -r requirements-dev.txt" | ||
- "python -m pip install -r requirements-dev.txt" | ||
- "GDAL_CONFIG=$GDALINST/gdal-$GDALVERSION/bin/gdal-config python -m pip install --upgrade --force-reinstall --no-use-pep517 -e .[test]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you didn't want to include the --upgrade again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave it for now. This is copied from rasterio and we haven't had a problem there yet.
@@ -19,6 +19,8 @@ cdef OGRFieldSubType get_field_subtype(void *fielddefn) | |||
cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype) | |||
cdef bint check_capability_create_layer(void *cogr_ds) | |||
cdef void *get_linear_geometry(void *geom) | |||
cdef const char* osr_get_name(OGRSpatialReferenceH hSrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is copied from rasterio. It isn't called in fiona yet, but it will be in a future version as we change our modules to be more like those in rasterio. Therefore, I'm going to leave it in.
else: | ||
raise ValueError("Invalid CRS") | ||
|
||
# Fixup, export to WKT, and set the GDAL dataset's projection. | ||
OSRFixup(cogr_srs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this OSRFixup call should be still used in GDAL < 3.0. Supporting both version scenarios is probably complicated, however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see any harm in having osr_set_traditional_axis_mapping_strategy call OSRFixup for GDAL versions 1 and 2 @hobu ? That's one way to bring it back in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No harm, but that's not quite where you want it. You want it right after any ImportFromWkt-type calls happen where the input might be ESRI content.
Some test failures in path finding stuff using @conda-forge:
|
Small cast nit 1b5081a |
Bumping up the requirements got me over the attrib issue on windows. The important one is
|
@hobu skip those tests with |
ok, with that and the requirements bump, my windows tests are clean. |
I would recommend against this approach as it will change the CRS and it will be different on export. I would recommend only doing so when doing a transformation operation where it is needed. |
@snowman2 I believe the code here is consistent with GDAL and OGR. See in https://gdal.org/development/rfc/rfc73_proj6_wkt2_srsbarn.html:
|
On the conda-forge builds that use GDAL 3, it is complaining about "undefined symbol: OSRFixup" (conda-forge/fiona-feedstock#143), but that symbol should only be used when built against GDAL 1/2 ? |
@jorisvandenbossche it is important that setup.py needs to know about the correct gdal version. I don't fully understand your build system. Maybe the problem is that you pin gdal to 2.4 in https://github.com/conda-forge/fiona-feedstock/blob/8a8798d39c129ebfc1817808ef7298aaf0f4e0ef/recipe/bld.bat#L2 ? |
That's for windows, which does not yet have GDAL 3 builds I think (and the windows builds are also passing). For linux (https://github.com/conda-forge/fiona-feedstock/blob/master/recipe/build.sh) it does not seem to be pinned like that. |
@jorisvandenbossche Maybe I found the issue: setup.py chooses _shim2.c instead of _shim3.c for gdal3. I created a PR to fix this: #807 @sgillies As a side note, we log information in setup.py. Do you know how to display these logs? |
@rbuffat thank you, that PR does the trick. I've made this mistake before and it comes from not building the wheels from a source distribution, but from a repo checkout. I need to change that. Fiona 1.8.9.post1 is being built now. |
@rbuffat thanks a lot for fixing that! |
See https://stackoverflow.com/a/8710759 for a pointer on setup.py logging. |
The builds for GDAL 3 are passing, but now the builds for GDAL 2.4 are failing. Importing the build package gives:
|
A typo in the merged PR (minor -> major) is the reason for that, I assume, see https://github.com/Toblerity/Fiona/pull/807/files#r337729479 |
With fiona 1.8.9.post2, all builds are passing now for conda-forge: conda-forge/fiona-feedstock#145 |
I propose to merge this and make a 1.8.9 release without fixing the Appveyor build so that we can ease the PROJ 4/6 pain of users. Let's tackle the Appveyor updates in the master branch.
Summary of the PR:
towgs84
andwktext
don't surface in GDAL's WKT output anymore.@hobu you're interested in this, I know. Want to give it a quick scan? I realize that some of the Cython files are archaic and a bit opaque.
@snorfalorpagus any objections?