Skip to content
Permalink
Browse files

Bump minimum GDAL version to 2.0, remove old version #ifdefs

  • Loading branch information
nyalldawson committed Jan 3, 2017
1 parent f59acad commit b0bc7634756aa2b5e403056a517db9d2c711542c
Showing with 18 additions and 512 deletions.
  1. +7 −15 cmake/FindGDAL.cmake
  2. +0 −4 src/analysis/raster/qgskde.cpp
  3. +0 −4 src/analysis/raster/qgsninecellfilter.cpp
  4. +0 −5 src/analysis/raster/qgsrastercalculator.cpp
  5. +0 −4 src/analysis/raster/qgsrelief.cpp
  6. +0 −4 src/analysis/vector/qgszonalstatistics.cpp
  7. +0 −5 src/app/dwg/qgsdwgimportdialog.cpp
  8. +0 −9 src/app/dwg/qgsdwgimporter.cpp
  9. +0 −4 src/app/ogr/qgsnewogrconnection.cpp
  10. +0 −2 src/app/qgisapp.cpp
  11. +0 −2 src/app/qgsalignrasterdialog.cpp
  12. +0 −4 src/app/qgsoptions.cpp
  13. +0 −4 src/core/qgis.cpp
  14. +0 −4 src/core/qgscoordinatereferencesystem.cpp
  15. +0 −4 src/core/qgsgml.cpp
  16. +0 −12 src/core/qgsogrutils.cpp
  17. +0 −62 src/core/qgsvectorfilewriter.cpp
  18. +0 −2 src/core/qgsvectorfilewriter.h
  19. +0 −2 src/gui/qgsnewgeopackagelayerdialog.cpp
  20. +0 −4 src/plugins/georeferencer/qgsimagewarper.cpp
  21. +0 −4 src/plugins/georeferencer/qgsrasterchangecoords.cpp
  22. +0 −22 src/plugins/grass/qgsgrassmoduleparam.cpp
  23. +3 −78 src/providers/gdal/qgsgdalprovider.cpp
  24. +0 −46 src/providers/gdal/qgsgdalproviderbase.cpp
  25. +0 −5 src/providers/gdal/qgsgdalproviderbase.h
  26. +2 −91 src/providers/ogr/qgsogrprovider.cpp
  27. +0 −6 src/providers/ogr/qgsogrprovider.h
  28. +0 −5 src/providers/wcs/qgswcsprovider.cpp
  29. +0 −4 src/providers/wcs/qgswcsprovider.h
  30. +0 −12 src/providers/wfs/qgswfsshareddata.cpp
  31. +0 −4 src/server/qgssldconfigparser.cpp
  32. +1 −16 tests/src/core/testqgscoordinatereferencesystem.cpp
  33. +0 −6 tests/src/core/testqgsogrutils.cpp
  34. +0 −30 tests/src/core/testziplayer.cpp
  35. +5 −7 tests/src/python/test_db_manager_gpkg.py
  36. +0 −2 tests/src/python/test_provider_ogr.py
  37. +0 −4 tests/src/python/test_provider_ogr_gpkg.py
  38. +0 −2 tests/src/python/test_provider_ogr_sqlite.py
  39. +0 −3 tests/src/python/test_provider_tabfile.py
  40. +0 −8 tests/src/python/test_qgsserver.py
  41. +0 −1 tests/src/python/test_qgsvectorfilewriter.py
@@ -61,13 +61,9 @@ ELSE(WIN32)
ENDIF (NOT GDAL_VERSION)
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GDAL_VERSION_MAJOR "${GDAL_VERSION}")
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GDAL_VERSION_MINOR "${GDAL_VERSION}")
IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION EQUAL 1 AND GDAL_VERSION_MINOR LESS 4))
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 1.4.0 or higher.")
ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION EQUAL 1 AND GDAL_VERSION_MINOR LESS 4))

IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11))
MESSAGE (WARNING "GDAL version is too old (${GDAL_VERSION}) to support GeoPackage. 1.11.0 or higher is recommended.")
ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11))
IF (GDAL_VERSION_MAJOR LESS 2)
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 2.0 or higher.")
ENDIF (GDAL_VERSION_MAJOR LESS 2)

ENDIF (GDAL_LIBRARY)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
@@ -105,14 +101,10 @@ ELSE(WIN32)

# check for gdal version
# version 1.2.5 is known NOT to be supported (missing CPL_STDCALL macro)
# According to INSTALL, 1.4.0+ is required
IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 4))
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 1.4.0 or higher.")
ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 4))

IF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11))
MESSAGE (WARNING "GDAL version is too old (${GDAL_VERSION}) to support GeoPackage. 1.11.0 or higher is recommended.")
ENDIF (GDAL_VERSION_MAJOR LESS 1 OR (GDAL_VERSION_MAJOR EQUAL 1 AND GDAL_VERSION_MINOR LESS 11))
# According to INSTALL, 2.0+ is required
IF (GDAL_VERSION_MAJOR LESS 2)
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 2.0 or higher.")
ENDIF (GDAL_VERSION_MAJOR LESS 2)

# set INCLUDE_DIR to prefix+include
EXEC_PROGRAM(${GDAL_CONFIG}
@@ -23,11 +23,7 @@
#define M_PI 3.14159265358979323846
#endif

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#endif

QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEstimation::Parameters& parameters, const QString& outputFile, const QString& outputFormat )
: mInputLayer( parameters.vectorLayer )
@@ -21,11 +21,7 @@
#include <QProgressDialog>
#include <QFile>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#endif

QgsNineCellFilter::QgsNineCellFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
: mInputFile( inputFile )
@@ -29,13 +29,8 @@
#include <cpl_string.h>
#include <gdalwarper.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8(x) (x).toUtf8().constData()
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8(x) (x).toLocal8Bit().constData()
#define TO8F(x) QFile::encodeName( x ).constData()
#endif

QgsRasterCalculator::QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries )
@@ -28,11 +28,7 @@
#include <QFile>
#include <QTextStream>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#endif

QgsRelief::QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat )
: mInputFile( inputFile )
@@ -28,11 +28,7 @@
#include <QProgressDialog>
#include <QFile>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#endif

QgsZonalStatistics::QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix, int rasterBand, Statistics stats )
: mRasterFilePath( rasterFile )
@@ -69,11 +69,6 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f )
cbMergeLayers->setChecked( s.value( "/DwgImport/lastMergeLayers", false ).toBool() );
cbUseCurves->setChecked( s.value( "/DwgImport/lastUseCurves", true ).toBool() );

#if !defined(GDAL_COMPUTE_VERSION) || GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,0,0)
cbUseCurves->setChecked( false );
cbUseCurves->setHidden( true );
#endif

leDrawing->setReadOnly( true );
pbImportDrawing->setHidden( true );
lblMessage->setHidden( true );
@@ -140,30 +140,26 @@ void QgsDwgImporter::startTransaction()
{
Q_ASSERT( mDs );

#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
mInTransaction = GDALDatasetStartTransaction( mDs, 0 ) == OGRERR_NONE;
if ( !mInTransaction )
{
LOG( QObject::tr( "Could not start transaction\nDatabase:%1\nError:%2" )
.arg( mDatabase )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
#endif
}

void QgsDwgImporter::commitTransaction()
{
Q_ASSERT( mDs != nullptr );

#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
if ( mInTransaction && GDALDatasetCommitTransaction( mDs ) != OGRERR_NONE )
{
LOG( QObject::tr( "Could not commit transaction\nDatabase:%1\nError:%2" )
.arg( mDatabase )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
mInTransaction = false;
#endif
}

QgsDwgImporter::~QgsDwgImporter()
@@ -186,13 +182,8 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
OGRwkbGeometryType lineGeomType, hatchGeomType;
if ( useCurves )
{
#if !defined(GDAL_COMPUTE_VERSION) || GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,0,0)
error = QObject::tr( "Curves only supported with GDAL2" );
return false;
#else
lineGeomType = wkbCompoundCurveZ;
hatchGeomType = wkbCurvePolygonZ;
#endif
}
else
{
@@ -26,11 +26,7 @@
#include <ogr_api.h>
#include <cpl_error.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#endif

QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connType, const QString& connName, Qt::WindowFlags fl )
: QDialog( parent, fl )
@@ -266,9 +266,7 @@
#include <gdal_version.h>
#include <proj_api.h>

#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0)
#define SUPPORT_GEOPACKAGE
#endif

//
// Other includes
@@ -393,13 +393,11 @@ QgsAlignRasterLayerConfigDialog::QgsAlignRasterLayerConfigDialog()
cboResample->addItem( tr( "Lanczos (6x6 kernel)" ), QgsAlignRaster::RA_Lanczos );
cboResample->addItem( tr( "Average" ), QgsAlignRaster::RA_Average );
cboResample->addItem( tr( "Mode" ), QgsAlignRaster::RA_Mode );
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
cboResample->addItem( tr( "Maximum" ), QgsAlignRaster::RA_Max );
cboResample->addItem( tr( "Minimum" ), QgsAlignRaster::RA_Min );
cboResample->addItem( tr( "Median" ), QgsAlignRaster::RA_Median );
cboResample->addItem( tr( "First Quartile (Q1)" ), QgsAlignRaster::RA_Q1 );
cboResample->addItem( tr( "Third Quartile (Q3)" ), QgsAlignRaster::RA_Q3 );
#endif

editOutput = new QLineEdit( this );
btnBrowse = new QPushButton( tr( "Browse..." ), this );
@@ -1852,12 +1852,8 @@ void QgsOptions::loadGdalDriverList()

// in GDAL 2.0 vector and mixed drivers are returned by GDALGetDriver, so filter out non-raster drivers
// TODO add same UI for vector drivers
#ifdef GDAL_COMPUTE_VERSION
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) != "YES" )
continue;
#endif
#endif

myGdalDriverDescription = GDALGetDescription( myGdalDriver );
myDrivers << myGdalDriverDescription;
@@ -47,11 +47,7 @@ const int Qgis::QGIS_VERSION_INT = VERSION_INT;
// Release name
QString Qgis::QGIS_RELEASE_NAME( QStringLiteral( RELEASE_NAME ) );

#if GDAL_VERSION_NUM >= 1800
const QString GEOPROJ4 = QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" );
#else
const QString GEOPROJ4 = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
#endif

const QString GEOWKT =
"GEOGCS[\"WGS 84\", "
@@ -214,12 +214,10 @@ bool QgsCoordinateReferenceSystem::createFromUserInput( const QString &theDefini
OGRSpatialReferenceH crs = OSRNewSpatialReference( nullptr );

// make sure towgs84 parameter is loaded if using an ESRI definition and gdal >= 1.9
#if GDAL_VERSION_NUM >= 1900
if ( theDefinition.startsWith( QLatin1String( "ESRI::" ) ) )
{
setupESRIWktFix();
}
#endif

if ( OSRSetFromUserInput( crs, theDefinition.toLocal8Bit().constData() ) == OGRERR_NONE )
{
@@ -238,7 +236,6 @@ void QgsCoordinateReferenceSystem::setupESRIWktFix()
{
// make sure towgs84 parameter is loaded if gdal >= 1.9
// this requires setting GDAL_FIX_ESRI_WKT=GEOGCS (see qgis bug #5598 and gdal bug #4673)
#if GDAL_VERSION_NUM >= 1900
const char* configOld = CPLGetConfigOption( "GDAL_FIX_ESRI_WKT", "" );
const char* configNew = "GEOGCS";
// only set if it was not set, to let user change the value if needed
@@ -254,7 +251,6 @@ void QgsCoordinateReferenceSystem::setupESRIWktFix()
{
QgsDebugMsg( QString( "GDAL_FIX_ESRI_WKT was already set : %1" ).arg( configNew ) );
}
#endif
}

bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( const QString& theCrs )
@@ -868,11 +868,7 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
{
const int wkbSize = OGR_G_WkbSize( hGeom );
unsigned char* pabyBuffer = new unsigned char[ wkbSize ];
#if GDAL_VERSION_MAJOR >= 2
OGR_G_ExportToIsoWkb( hGeom, wkbNDR, pabyBuffer );
#else
OGR_G_ExportToWkb( hGeom, wkbNDR, pabyBuffer );
#endif
QgsGeometry g;
g.fromWkb( pabyBuffer, wkbSize );
if ( mInvertAxisOrientation )
@@ -21,15 +21,9 @@
#include <QTextCodec>
#include <QUuid>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8(x) (x).toUtf8().constData()
#define TO8F(x) (x).toUtf8().constData()
#define FROM8(x) QString::fromUtf8(x)
#else
#define TO8(x) (x).toLocal8Bit().constData()
#define TO8F(x) QFile::encodeName( x ).constData()
#define FROM8(x) QString::fromLocal8Bit(x)
#endif

QgsFeature QgsOgrUtils::readOgrFeature( OGRFeatureH ogrFet, const QgsFields& fields, QTextCodec* encoding )
{
@@ -80,15 +74,12 @@ QgsFields QgsOgrUtils::readOgrFields( OGRFeatureH ogrFet, QTextCodec* encoding )
case OFTInteger:
varType = QVariant::Int;
break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
case OFTInteger64:
varType = QVariant::LongLong;
break;
#endif
case OFTReal:
varType = QVariant::Double;
break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400
case OFTDate:
varType = QVariant::Date;
break;
@@ -99,7 +90,6 @@ QgsFields QgsOgrUtils::readOgrFields( OGRFeatureH ogrFet, QTextCodec* encoding )
varType = QVariant::DateTime;
break;
case OFTString:
#endif
default:
varType = QVariant::String; // other unsupported, leave it as a string
}
@@ -148,11 +138,9 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField
case QVariant::Int:
value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attIndex ) );
break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
case QVariant::LongLong:
value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attIndex ) );
break;
#endif
case QVariant::Double:
value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attIndex ) );
break;

0 comments on commit b0bc763

Please sign in to comment.
You can’t perform that action at this time.