From f0821d897f66c31755f7012b68191a2ec7a060fb Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 2 Jun 2014 20:25:32 -0700 Subject: [PATCH] improvements to GDAL 2.x handling - refs #2259 amends cbdd112223b42576 --- plugins/input/ogr/ogr_datasource.cpp | 8 ++++++-- plugins/input/ogr/ogr_layer_ptr.hpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index a88c781ee..4700b74de 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -72,7 +72,7 @@ ogr_datasource::~ogr_datasource() { // free layer before destroying the datasource layer_.free_layer(); -#if GDAL_VERSION_NUM >= 2000 +#if GDAL_VERSION_MAJOR >= 2 GDALClose(( GDALDatasetH) dataset_); #else OGRDataSource::DestroyDataSource (dataset_); @@ -117,7 +117,7 @@ void ogr_datasource::init(mapnik::parameters const& params) if (! driver.empty()) { -#if GDAL_VERSION_NUM >= 2000 +#if GDAL_VERSION_MAJOR >= 2 unsigned int nOpenFlags = GDAL_OF_READONLY | GDAL_OF_VECTOR; const char* papszAllowedDrivers[] = { driver.c_str(), NULL }; dataset_ = static_cast(GDALOpenEx(dataset_name_.c_str(),nOpenFlags,papszAllowedDrivers,NULL,NULL)); @@ -132,7 +132,11 @@ void ogr_datasource::init(mapnik::parameters const& params) else { // open ogr driver +#if GDAL_VERSION_MAJOR >= 2 dataset_ = static_cast(OGROpen(dataset_name_.c_str(), FALSE, NULL)); +#else + dataset_ = OGRSFDriverRegistrar::Open(dataset_name_.c_str(), FALSE); +#endif } if (! dataset_) diff --git a/plugins/input/ogr/ogr_layer_ptr.hpp b/plugins/input/ogr/ogr_layer_ptr.hpp index 5d53a7ddc..a0438fb7e 100644 --- a/plugins/input/ogr/ogr_layer_ptr.hpp +++ b/plugins/input/ogr/ogr_layer_ptr.hpp @@ -33,7 +33,7 @@ #include #include -#if GDAL_VERSION_NUM >= 2000 +#if GDAL_VERSION_MAJOR >= 2 typedef GDALDataset* gdal_dataset_type; #else typedef OGRDataSource* gdal_dataset_type;