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

1.0 Release with latest GDAL3 bindings #73

Merged
merged 5 commits into from
Aug 22, 2019
Merged

1.0 Release with latest GDAL3 bindings #73

merged 5 commits into from
Aug 22, 2019

Conversation

visr
Copy link
Member

@visr visr commented Aug 11, 2019

  1. stop removing prefixes from GDAL function names, thereby overloading them
  2. removes the C submodule, everything is now together in the main module

Fixes #70.

I realize the function renaming is quite breaking. In the README.md I wrote
a bit about the changes and how to update code with the renamer.

Before we had many methods of (for instance) destroy. We used multiple dispatch to select the right C function if you called GDAL.destroy(x),
depending on the type of x:

"destroy": [
        "gdaldestroy",
        "gdal_cg_destroy",
        "ogr_fld_destroy",
        "ogr_gfld_destroy",
        "ogr_fd_destroy",
        "ogr_f_destroy",
        "ogr_ds_destroy",
        "ogr_sm_destroy",
        "ogr_st_destroy",
        "ogr_stbl_destroy"
    ]

This only worked because we rewrote the wrapping code, to pretend that Ptr{Cvoid} was actually Ptr{OGRFeatureH}, where OGRFeatureH was an abstract type we put in types.jl. While it was nice to use dispatch here, it did not match well with the C API. Firstly, it meant that wrapping became a complicated puzzle which did not neccesarily work. In types.jl we used subtyping to simulate that some functions could take different types of inputs. Now it is up to the user to select the right function. The functions will accept everything that can be converted to the types that C expects. This is in line with the new default Clang.jl behavior. This more straightforward wrapping of the GDAL C API is a better fit for this package, allowing others such as ArchGDAL.jl to try to make it more Julian. As you can see the wrapping code is now much simpler as a result, which should make it easier to maintain this package.

Regarding the C submodule, since we now do less rewriting, there is no strong reason anymore to keep them separate, folding them together.

1. stop removing prefixes from GDAL function names, thereby overloading them
2. removes the C submodule, everything is not together in the main module

I realize the function renaming is quite breaking. In the README.md I wrote
a bit about the changes and how to update code with the [renamer](https://gist.github.com/visr/0a2ad3fe92073345c93c2ca42f5f58a0#file-renamer-jl).

Before we had many methods of (for instance) destroy. We used multiple dispatch to select the right C function if you called GDAL.destroy(x),
depending on the type of x:

```json
"destroy": [
        "gdaldestroy",
        "gdal_cg_destroy",
        "ogr_fld_destroy",
        "ogr_gfld_destroy",
        "ogr_fd_destroy",
        "ogr_f_destroy",
        "ogr_ds_destroy",
        "ogr_sm_destroy",
        "ogr_st_destroy",
        "ogr_stbl_destroy"
    ]
```

This only worked because we rewrote the wrapping code, to pretend that `Ptr{Cvoid}` was actually `Ptr{OGRFeatureH}`, where `OGRFeatureH` was an abstract type
we put in https://github.com/JuliaGeo/GDAL.jl/blob/b75ac1c3a351ac934e35827289a0d522a1fa7005/src/types.jl. While it was nice to use dispatch here,
it did not match well with the C API. Firstly, it meant that wrapping became a complicated puzzle which did not neccesarily work. In `types.jl` we used
subtyping to simulate that some functions could take different types of inputs. Now it is up to the user to select the right function. The functions
will accept everything that can be converted to the types that C expects. This is in line with the new default Clang.jl behavior. This more straightforward
wrapping of the GDAL C API is a better fit for this package, allowing others such as ArchGDAL.jl to try to make it more Julian.

Regarding the C submodule, since we now do less rewriting, there is no strong reason anymore to keep them separate, folding them together.
@visr visr requested review from evetion and yeesian August 11, 2019 00:14
@evetion
Copy link
Member

evetion commented Aug 11, 2019

I already like the title 👍

visr added a commit to JuliaGeo/Proj.jl that referenced this pull request Aug 11, 2019
This code is mostly copy pasted from JuliaGeo/GDAL.jl#73.

Three transformations are applied:

- docstrings are added, created from PROJ Doxygen XML output
- functions that return a Cstring are wrapped in unsafe_string to return a String
- functions that return a Ptr{Cstring} are wrapped in unsafe_loadstringlist to return a Vector{String}
Copy link
Member

@yeesian yeesian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context to potential readers:

This PR grew out of conversations we had in private about how the rewriting of GDAL function names into names that were more Julian took a lot of effort (to resolve name clashes under the new default Clang behavior).

Given that

  • the benefit is a shorter function name without any added features, and
  • this package wasn't designed to be end-user facing as the API follows that of GDAL's C API,

we have decided that the benefits did not justify the effort to continue the rewriting of GDAL function names in GDAL.jl.

gen/doc.jl Outdated Show resolved Hide resolved
gen/wrap.jl Show resolved Hide resolved
gen/wrap.jl Outdated Show resolved Hide resolved
gen/wrap.jl Outdated Show resolved Hide resolved
gen/wrap.jl Outdated Show resolved Hide resolved
@yeesian
Copy link
Member

yeesian commented Aug 13, 2019

OGRDatumType seems to be missing now.

@evetion
Copy link
Member

evetion commented Aug 13, 2019

Do we have an overview of all (registered?) packages that have GDAL as a dependency? This release will break all those packages.

I'm actually not in favor of deprecating all individual functions, but we should have a general deprecation warning at package load.

@visr
Copy link
Member Author

visr commented Aug 13, 2019

OGRDatumType seems to be missing now.

I cannot seem to find a trace of it in the GDAL 3 repository, so I think it really dissappeared.

@visr
Copy link
Member Author

visr commented Aug 13, 2019

ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Nothing}}, ::GDAL.GDALPaletteInterp)

Good catch thanks. I don't quite understand it yet. Has ccall behavior changed? Maybe this method should be defined by the @cenum macro. I can ask over there.

@yeesian
Copy link
Member

yeesian commented Aug 13, 2019

ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Nothing}}, ::GDAL.GDALPaletteInterp)

Good catch thanks. I don't quite understand it yet. Has ccall behavior changed? Maybe this method should be defined by the @cenum macro. I can ask over there.

That was a mistake on my end which led to a false alarm: I was calling the wrong GDAL method.

@visr
Copy link
Member Author

visr commented Aug 13, 2019

Do we have an overview of all (registered?) packages that have GDAL as a dependency? This release will break all those packages.

If https://discourse.julialang.org/t/reverse-dependencies-of-a-package/9774/5 is correct, it's just GeoArrays and ArchGDAL. Though of course there are plenty scripts out there that use this package directly.

I'm actually not in favor of deprecating all individual functions, but we should have a general deprecation warning at package load.

I thought about deprecations for functions. But doing it properly (e.g. redirecting automatically to a working alternative) will be a difficult and large task. If anybody would be up for doing that it would be great, but I don't want to spend my time on it frankly. The general deprecation warning at package load, I'm not sure how we can do that such that it won't be annoying to users that have updated their code. The new version indicates breaking changes, and what they are and how to update can be found on the README.

@yeesian
Copy link
Member

yeesian commented Aug 13, 2019

I agree that (i) we should start having a better habit of maintaining a CHANGELOG as well as a smoother deprecation process, but also agree that (ii) it would have been too much work for us to provide that kind of user support in pre-1.0 versions.

We should have a version that provides deprecation warnings to get some practice before 1.0, but I agree that it is too big of a job for this PR (after having gone through yeesian/ArchGDAL.jl#85 to get a sense for the complexity of the task).

@yeesian
Copy link
Member

yeesian commented Aug 13, 2019

I want to add that I like that the docstrings still refer to the original GDAL function names. It makes it easier for people who are doing a search based on the original names.

README.md Outdated Show resolved Hide resolved
@visr
Copy link
Member Author

visr commented Aug 13, 2019

after having gone through yeesian/ArchGDAL.jl#85 to get a sense for the complexity of the task

Yeah that was quite the effort, nicely done! Probably that was the single largest updating effort haha.

@visr
Copy link
Member Author

visr commented Aug 17, 2019

Any objections to me merging this? How shall we do it with tagging releases? Do a simultaneous release of GDAL, ArchGDAL and GeoArrays?

@evetion
Copy link
Member

evetion commented Aug 18, 2019

Let's do a simultaneous release. I've added a compat GDAL = ">=1.0" to my Project.toml.

@evetion evetion changed the title break everything 1.0 Release with latest GDAL3 bindings Aug 18, 2019
@meggart
Copy link
Member

meggart commented Aug 19, 2019

No objection from my side. I have a few projects depending on GDAL, with test the new version soon and will freeze GDAL version until then.

@yeesian
Copy link
Member

yeesian commented Aug 21, 2019

Any objections to me merging this? How shall we do it with tagging releases? Do a simultaneous release of GDAL, ArchGDAL and GeoArrays?

Yeah, I think this package is ready for v1.0 :)

I think a new release of GDAL.jl should be made first -- modulo tests from downstream packages working locally. And we'll wait for green from Travis and AppVeyor before updating downstream packages (ArchGDAL then GeoArrays; in the order of their dependencies).

What do you all think?

@visr visr merged commit 9beaa4e into master Aug 22, 2019
@visr visr deleted the simplewrap branch August 22, 2019 19:18
visr added a commit to JuliaGeo/Proj.jl that referenced this pull request Nov 15, 2019
This code is mostly copy pasted from JuliaGeo/GDAL.jl#73.

Three transformations are applied:

- docstrings are added, created from PROJ Doxygen XML output
- functions that return a Cstring are wrapped in unsafe_string to return a String
- functions that return a Ptr{Cstring} are wrapped in unsafe_loadstringlist to return a Vector{String}
visr added a commit to JuliaGeo/Proj.jl that referenced this pull request Nov 19, 2019
This code is mostly copy pasted from JuliaGeo/GDAL.jl#73.

Three transformations are applied:

- docstrings are added, created from PROJ Doxygen XML output
- functions that return a Cstring are wrapped in unsafe_string to return a String
- functions that return a Ptr{Cstring} are wrapped in unsafe_loadstringlist to return a Vector{String}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrap GDAL 3.0
4 participants