improvements to GDAL 2.x handling - refs #2259 amends cbdd112223

This commit is contained in:
Dane Springmeyer 2014-06-02 20:25:32 -07:00
parent f68291c5b4
commit f0821d897f
2 changed files with 7 additions and 3 deletions

View file

@ -72,7 +72,7 @@ ogr_datasource::~ogr_datasource()
{ {
// free layer before destroying the datasource // free layer before destroying the datasource
layer_.free_layer(); layer_.free_layer();
#if GDAL_VERSION_NUM >= 2000 #if GDAL_VERSION_MAJOR >= 2
GDALClose(( GDALDatasetH) dataset_); GDALClose(( GDALDatasetH) dataset_);
#else #else
OGRDataSource::DestroyDataSource (dataset_); OGRDataSource::DestroyDataSource (dataset_);
@ -117,7 +117,7 @@ void ogr_datasource::init(mapnik::parameters const& params)
if (! driver.empty()) if (! driver.empty())
{ {
#if GDAL_VERSION_NUM >= 2000 #if GDAL_VERSION_MAJOR >= 2
unsigned int nOpenFlags = GDAL_OF_READONLY | GDAL_OF_VECTOR; unsigned int nOpenFlags = GDAL_OF_READONLY | GDAL_OF_VECTOR;
const char* papszAllowedDrivers[] = { driver.c_str(), NULL }; const char* papszAllowedDrivers[] = { driver.c_str(), NULL };
dataset_ = static_cast<gdal_dataset_type>(GDALOpenEx(dataset_name_.c_str(),nOpenFlags,papszAllowedDrivers,NULL,NULL)); dataset_ = static_cast<gdal_dataset_type>(GDALOpenEx(dataset_name_.c_str(),nOpenFlags,papszAllowedDrivers,NULL,NULL));
@ -132,7 +132,11 @@ void ogr_datasource::init(mapnik::parameters const& params)
else else
{ {
// open ogr driver // open ogr driver
#if GDAL_VERSION_MAJOR >= 2
dataset_ = static_cast<gdal_dataset_type>(OGROpen(dataset_name_.c_str(), FALSE, NULL)); dataset_ = static_cast<gdal_dataset_type>(OGROpen(dataset_name_.c_str(), FALSE, NULL));
#else
dataset_ = OGRSFDriverRegistrar::Open(dataset_name_.c_str(), FALSE);
#endif
} }
if (! dataset_) if (! dataset_)

View file

@ -33,7 +33,7 @@
#include <gdal_version.h> #include <gdal_version.h>
#include <ogrsf_frmts.h> #include <ogrsf_frmts.h>
#if GDAL_VERSION_NUM >= 2000 #if GDAL_VERSION_MAJOR >= 2
typedef GDALDataset* gdal_dataset_type; typedef GDALDataset* gdal_dataset_type;
#else #else
typedef OGRDataSource* gdal_dataset_type; typedef OGRDataSource* gdal_dataset_type;