Request for Changes-11: Gdal 2.0 support
- 1 [Request for Changes - 11] Gdal 2.0 support
[Request for Changes - 11] Gdal 2.0 support
- Author: Julien Michel
- Submitted on 15.10.2015
- Proposed target release: 5.2
- Adopted : +4 votes
This Request for Changes makes Orfeo ToolBox support both gdal 1.x (x >=10) and gdal 2.x.
Until now, Gdal 2.0 and higher was not supported in OTB . The main reason is an API change that unifies OGRDatasource and GDALDataset .
While in the initial bug report, it was suggested that moving to the C API should resolve the issue, I found no evidence of that (some C API function are also marked as deprecated), and it implies a lot of changes in the code. I therefore did not got this way and tried to keep with the C++ API. Note that there might be other reason to move to the C API in the future, but that is a great deal of work.
Of course, the tricky part of this RFChanges is to get both gdal 1.x and gdal 2.x supported without #ifdef everywhere in the code. I resolved this by hiding all interface changes in functions of an ogr::version_proxy namespace, that is in charge of switching implementation at the back while proposing the same public interface for both versions. I then updated all classes using the deprecated OGR methods to use the ogr::version_proxy functions instead.
Classes and files
- There was an error in gdalVersionTest.cxx that prevented 2.0 to be detected as a correct version:
- otb-module-init.cmake has been updated to store the gdal major version in a cmake cache variable :
- otbConfigure.h.in has been updated with the content of the OTB_USE_GDAL_20 cmake variable
- The ogr::version_proxy namespace was created and contains functions fir the stable interface to use both gdal version
- Two different implementations of those functions are built depending on the gdal version:
- The cmake switch is here:
- OGRDatasetWrapper and OGRLayerWrapper classes have been changed to use the ogr::version_proxy namespace instead of direct calls to gdal API for all calls affected by the API change.
- OGRVectorDataIO and OGRIOHelper classes have been changed to use the ogr::version_proxy functions instead of direct calls to gdal API for all calls affected by the API change.
- otbTestKernel.cxx has been changed to use the ogr::version_proxy namespace instead of direct calls to gdal API for all calls affected by the API change.
No code changes in applications.
No changes in tests, but changes in TestDriver and OGR use might have some impact on the dashboard.
- Dashboard submission for this branch and using gdal 1.10 is on and no has no failing test related to the changes
- A new configuration has to be set to test the same branch with gdal 2.0 as well.
- New functions in ogr::version_proxy namespace has been heavily documented.
This bring yet another GDAL/OGR/Proxy/helper class in our code. From an outside perspective, it might be hard to understand what all these classes are for (this is more clear with ogr::version_proxy namespace instead of static class as suggested by Luc).