From 227cdeab42aad98b703e8c93156e6e524cf8e818 Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Thu, 16 Jul 2015 21:05:37 +0200 Subject: [PATCH] Bump minimum GDAL version to 2.0.0. Adapt code to API changes for now. Porting of OGR to GDAL classes can happen later. --- CMakeLists.txt | 2 +- src/Lib/terragear/tg_shapefile.cxx | 5 +++-- src/Prep/OGRDecode/ogr-decode.cxx | 9 +++++---- src/Utils/poly2ogr/poly2ogr.cxx | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0ea1240..7d7e410f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ find_package(Boost COMPONENTS system thread REQUIRED) find_package(ZLIB REQUIRED) find_package(Threads REQUIRED) find_package(SimGear 3.1.0 REQUIRED) -find_package(GDAL 1.6.0 REQUIRED) +find_package(GDAL 2.0.0 REQUIRED) find_package(TIFF REQUIRED) # needed for SRTM set (CGAL_MINIMUM 4.0) diff --git a/src/Lib/terragear/tg_shapefile.cxx b/src/Lib/terragear/tg_shapefile.cxx index 54001719..2025ed1d 100644 --- a/src/Lib/terragear/tg_shapefile.cxx +++ b/src/Lib/terragear/tg_shapefile.cxx @@ -18,7 +18,8 @@ void* tgShapefile::OpenDatasource( const char* datasource_name ) tgShapefile::initialized = true; } - ogrdriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName( format_name ); + ogrdriver = (OGRSFDriver*) OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName( format_name ); + if ( !ogrdriver ) { SG_LOG( SG_GENERAL, SG_ALERT, "Unknown datasource format driver: " << format_name ); exit(1); @@ -322,4 +323,4 @@ tgPolygon tgShapefile::ToPolygon( const void* subject ) result.SetTexMethod( TG_TEX_BY_GEODE ); return result; -} \ No newline at end of file +} diff --git a/src/Prep/OGRDecode/ogr-decode.cxx b/src/Prep/OGRDecode/ogr-decode.cxx index 15bcd052..ccb824f0 100644 --- a/src/Prep/OGRDecode/ogr-decode.cxx +++ b/src/Prep/OGRDecode/ogr-decode.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -648,10 +649,10 @@ int main( int argc, char **argv ) { SG_LOG( SG_GENERAL, SG_DEBUG, "Opening datasource " << datasource << " for reading." ); - OGRRegisterAll(); - OGRDataSource *poDS; + GDALAllRegister(); + GDALDataset *poDS; - poDS = OGRSFDriverRegistrar::Open( datasource.c_str(), FALSE ); + poDS = (GDALDataset*) GDALOpen( datasource.c_str(), GA_ReadOnly ); if( poDS == NULL ) { SG_LOG( SG_GENERAL, SG_ALERT, "Failed opening datasource " << datasource ); @@ -682,7 +683,7 @@ int main( int argc, char **argv ) { } } - OGRDataSource::DestroyDataSource( poDS ); + GDALClose(poDS); SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets"); results.Save( save_shapefiles ); diff --git a/src/Utils/poly2ogr/poly2ogr.cxx b/src/Utils/poly2ogr/poly2ogr.cxx index 73d1c4b8..a5f99b04 100644 --- a/src/Utils/poly2ogr/poly2ogr.cxx +++ b/src/Utils/poly2ogr/poly2ogr.cxx @@ -459,7 +459,7 @@ void usage(const char* progname, const std::string& msg) { SG_LOG(SG_GENERAL, SG_INFO, "\t\tAvailable formats:"); OGRSFDriverRegistrar* registrar=OGRSFDriverRegistrar::GetRegistrar(); for (int i=0;iGetDriverCount();i++) { - SG_LOG(SG_GENERAL, SG_INFO, "\t\t\t-f \"" << registrar->GetDriver(i)->GetName() << "\""); + SG_LOG(SG_GENERAL, SG_INFO, "\t\t\t-f \"" << registrar->GetDriver(i)->GetDescription() << "\""); } SG_LOG(SG_GENERAL, SG_INFO, "\t\tDefault: ESRI Shapefile"); SG_LOG(SG_GENERAL, SG_INFO, ""); @@ -519,7 +519,7 @@ int main(int argc, char** argv) { const char* dst_datasource=argv[optind++]; OGRSFDriver *ogrdriver; - ogrdriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(format_name); + ogrdriver = (OGRSFDriver*) OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(format_name); if (!ogrdriver) { usage(argv[0],std::string("Unknown datasource format driver:")+format_name); exit(1);