From b0bc7634756aa2b5e403056a517db9d2c711542c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 3 Jan 2017 15:10:28 +1000 Subject: [PATCH] Bump minimum GDAL version to 2.0, remove old version #ifdefs --- cmake/FindGDAL.cmake | 22 ++--- src/analysis/raster/qgskde.cpp | 4 - src/analysis/raster/qgsninecellfilter.cpp | 4 - src/analysis/raster/qgsrastercalculator.cpp | 5 - src/analysis/raster/qgsrelief.cpp | 4 - src/analysis/vector/qgszonalstatistics.cpp | 4 - src/app/dwg/qgsdwgimportdialog.cpp | 5 - src/app/dwg/qgsdwgimporter.cpp | 9 -- src/app/ogr/qgsnewogrconnection.cpp | 4 - src/app/qgisapp.cpp | 2 - src/app/qgsalignrasterdialog.cpp | 2 - src/app/qgsoptions.cpp | 4 - src/core/qgis.cpp | 4 - src/core/qgscoordinatereferencesystem.cpp | 4 - src/core/qgsgml.cpp | 4 - src/core/qgsogrutils.cpp | 12 --- src/core/qgsvectorfilewriter.cpp | 62 ------------- src/core/qgsvectorfilewriter.h | 2 - src/gui/qgsnewgeopackagelayerdialog.cpp | 2 - src/plugins/georeferencer/qgsimagewarper.cpp | 4 - .../georeferencer/qgsrasterchangecoords.cpp | 4 - src/plugins/grass/qgsgrassmoduleparam.cpp | 22 ----- src/providers/gdal/qgsgdalprovider.cpp | 81 +--------------- src/providers/gdal/qgsgdalproviderbase.cpp | 46 --------- src/providers/gdal/qgsgdalproviderbase.h | 5 - src/providers/ogr/qgsogrprovider.cpp | 93 +------------------ src/providers/ogr/qgsogrprovider.h | 6 -- src/providers/wcs/qgswcsprovider.cpp | 5 - src/providers/wcs/qgswcsprovider.h | 4 - src/providers/wfs/qgswfsshareddata.cpp | 12 --- src/server/qgssldconfigparser.cpp | 4 - .../core/testqgscoordinatereferencesystem.cpp | 17 +--- tests/src/core/testqgsogrutils.cpp | 6 -- tests/src/core/testziplayer.cpp | 30 ------ tests/src/python/test_db_manager_gpkg.py | 12 +-- tests/src/python/test_provider_ogr.py | 2 - tests/src/python/test_provider_ogr_gpkg.py | 4 - tests/src/python/test_provider_ogr_sqlite.py | 2 - tests/src/python/test_provider_tabfile.py | 3 - tests/src/python/test_qgsserver.py | 8 -- tests/src/python/test_qgsvectorfilewriter.py | 1 - 41 files changed, 18 insertions(+), 512 deletions(-) diff --git a/cmake/FindGDAL.cmake b/cmake/FindGDAL.cmake index 617cdf9f843..b4b90e4e1a9 100644 --- a/cmake/FindGDAL.cmake +++ b/cmake/FindGDAL.cmake @@ -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} diff --git a/src/analysis/raster/qgskde.cpp b/src/analysis/raster/qgskde.cpp index 57543e013bb..57ae3cf1e05 100644 --- a/src/analysis/raster/qgskde.cpp +++ b/src/analysis/raster/qgskde.cpp @@ -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 ) diff --git a/src/analysis/raster/qgsninecellfilter.cpp b/src/analysis/raster/qgsninecellfilter.cpp index 30ccce47020..c1b56eb9733 100644 --- a/src/analysis/raster/qgsninecellfilter.cpp +++ b/src/analysis/raster/qgsninecellfilter.cpp @@ -21,11 +21,7 @@ #include #include -#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 ) diff --git a/src/analysis/raster/qgsrastercalculator.cpp b/src/analysis/raster/qgsrastercalculator.cpp index 1be0718b25e..957a370f641 100644 --- a/src/analysis/raster/qgsrastercalculator.cpp +++ b/src/analysis/raster/qgsrastercalculator.cpp @@ -29,13 +29,8 @@ #include #include -#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& rasterEntries ) diff --git a/src/analysis/raster/qgsrelief.cpp b/src/analysis/raster/qgsrelief.cpp index 01187b5b015..967d39b9d61 100644 --- a/src/analysis/raster/qgsrelief.cpp +++ b/src/analysis/raster/qgsrelief.cpp @@ -28,11 +28,7 @@ #include #include -#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 ) diff --git a/src/analysis/vector/qgszonalstatistics.cpp b/src/analysis/vector/qgszonalstatistics.cpp index 0fd2df0cb28..068a77544e2 100644 --- a/src/analysis/vector/qgszonalstatistics.cpp +++ b/src/analysis/vector/qgszonalstatistics.cpp @@ -28,11 +28,7 @@ #include #include -#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 ) diff --git a/src/app/dwg/qgsdwgimportdialog.cpp b/src/app/dwg/qgsdwgimportdialog.cpp index 18c73bb64db..ae04d080507 100644 --- a/src/app/dwg/qgsdwgimportdialog.cpp +++ b/src/app/dwg/qgsdwgimportdialog.cpp @@ -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 ); diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 81aee4e254d..2e6d3dc1a2f 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -140,7 +140,6 @@ 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 ) { @@ -148,14 +147,12 @@ void QgsDwgImporter::startTransaction() .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" ) @@ -163,7 +160,6 @@ void QgsDwgImporter::commitTransaction() .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 { diff --git a/src/app/ogr/qgsnewogrconnection.cpp b/src/app/ogr/qgsnewogrconnection.cpp index d1713a4c1ac..6cda770c5f0 100644 --- a/src/app/ogr/qgsnewogrconnection.cpp +++ b/src/app/ogr/qgsnewogrconnection.cpp @@ -26,11 +26,7 @@ #include #include -#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 ) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index be787dc3752..3d91bf6827d 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -266,9 +266,7 @@ #include #include -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0) #define SUPPORT_GEOPACKAGE -#endif // // Other includes diff --git a/src/app/qgsalignrasterdialog.cpp b/src/app/qgsalignrasterdialog.cpp index e0edb5b8de0..bbced151694 100644 --- a/src/app/qgsalignrasterdialog.cpp +++ b/src/app/qgsalignrasterdialog.cpp @@ -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 ); diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index d6ae41c8877..e490fc8e015 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -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; diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 3693e257868..4233b2de4e8 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -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\", " diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index dbb6814630b..90f30f92ec6 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -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 ) diff --git a/src/core/qgsgml.cpp b/src/core/qgsgml.cpp index 3b7c27c0b7f..b6d9fa38dcb 100644 --- a/src/core/qgsgml.cpp +++ b/src/core/qgsgml.cpp @@ -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 ) diff --git a/src/core/qgsogrutils.cpp b/src/core/qgsogrutils.cpp index 9e5066044e9..a4202c9bf07 100644 --- a/src/core/qgsogrutils.cpp +++ b/src/core/qgsogrutils.cpp @@ -21,15 +21,9 @@ #include #include -#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; diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index ae47349c372..7646a09a550 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -50,11 +50,7 @@ #include #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 #define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif QgsVectorFileWriter::FieldValueConverter::FieldValueConverter() { @@ -209,23 +205,6 @@ void QgsVectorFileWriter::init( QString vectorFileName, vectorFileName += QLatin1String( ".dbf" ); } -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 - // check for unique fieldnames - QSet fieldNames; - for ( int i = 0; i < fields.count(); ++i ) - { - QString name = fields[i].name().left( 10 ); - if ( fieldNames.contains( name ) ) - { - mErrorMessage = QObject::tr( "trimming attribute name '%1' to ten significant characters produces duplicate column name." ) - .arg( fields[i].name() ); - mError = ErrAttributeCreationFailed; - return; - } - fieldNames << name; - } -#endif - if ( action == CreateOrOverwriteFile || action == CreateOrOverwriteLayer ) deleteShapeFile( vectorFileName ); } @@ -491,13 +470,6 @@ void QgsVectorFileWriter::init( QString vectorFileName, switch ( attrField.type() ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 2000000 - case QVariant::LongLong: - ogrType = OFTString; - ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21; - ogrPrecision = -1; - break; -#else case QVariant::LongLong: { const char* pszDataTypes = GDALGetMetadataItem( poDriver, GDAL_DMD_CREATIONFIELDDATATYPES, NULL ); @@ -509,7 +481,6 @@ void QgsVectorFileWriter::init( QString vectorFileName, ogrPrecision = 0; break; } -#endif case QVariant::String: ogrType = OFTString; if ( ogrWidth <= 0 || ogrWidth > 255 ) @@ -620,25 +591,8 @@ void QgsVectorFileWriter::init( QString vectorFileName, QgsDebugMsg( QString( "returned field index for %1: %2" ).arg( name ).arg( ogrIdx ) ); if ( ogrIdx < 0 || existingIdxs.contains( ogrIdx ) ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 - // if we didn't find our new column, assume it's name was truncated and - // it was the last one added (like for shape files) - int fieldCount = OGR_FD_GetFieldCount( defn ); - - OGRFieldDefnH fdefn = OGR_FD_GetFieldDefn( defn, fieldCount - 1 ); - if ( fdefn ) - { - const char *fieldName = OGR_Fld_GetNameRef( fdefn ); - - if ( attrField.name().left( strlen( fieldName ) ) == fieldName ) - { - ogrIdx = fieldCount - 1; - } - } -#else // GDAL 1.7 not just truncates, but launders more aggressivly. ogrIdx = OGR_FD_GetFieldCount( defn ) - 1; -#endif if ( ogrIdx < 0 ) { @@ -1154,12 +1108,10 @@ QMap QgsVectorFileWriter::initMetaData() QStringLiteral( "geometry" ) // Default value ) ); -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) layerOptions.insert( "SPATIAL_INDEX", new BoolOption( QObject::tr( "If a spatial index must be created." ), true // Default value ) ); -#endif driverMetadata.insert( QStringLiteral( "GPKG" ), MetaData( @@ -1977,7 +1929,6 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature& feature ) switch ( attrValue.type() ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case QVariant::Int: case QVariant::UInt: OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.toInt() ); @@ -1989,17 +1940,6 @@ OGRFeatureH QgsVectorFileWriter::createFeature( const QgsFeature& feature ) case QVariant::String: OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() ); break; -#else - case QVariant::Int: - OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.toInt() ); - break; - case QVariant::String: - case QVariant::LongLong: - case QVariant::UInt: - case QVariant::ULongLong: - OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() ); - break; -#endif case QVariant::Double: OGR_F_SetFieldDouble( poFeature, ogrField, attrValue.toDouble() ); break; @@ -2761,7 +2701,6 @@ void QgsVectorFileWriter::createSymbolLayerTable( QgsVectorLayer* vl, const Qgs mapUnits = ct.destinationCrs().mapUnits(); } -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1700 mSymbolLayerTable.clear(); OGRStyleTableH ogrStyleTable = OGR_STBL_Create(); OGRStyleMgrH styleManager = OGR_SM_Create( ogrStyleTable ); @@ -2785,7 +2724,6 @@ void QgsVectorFileWriter::createSymbolLayerTable( QgsVectorLayer* vl, const Qgs } } OGR_DS_SetStyleTableDirectly( ds, ogrStyleTable ); -#endif } QgsVectorFileWriter::WriterError QgsVectorFileWriter::exportFeaturesSymbolLevels( QgsVectorLayer* layer, QgsFeatureIterator& fit, diff --git a/src/core/qgsvectorfilewriter.h b/src/core/qgsvectorfilewriter.h index 1db1551341d..16823ad986b 100644 --- a/src/core/qgsvectorfilewriter.h +++ b/src/core/qgsvectorfilewriter.h @@ -540,9 +540,7 @@ class CORE_EXPORT QgsVectorFileWriter SymbologyExport mSymbologyExport; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1700 QMap< QgsSymbolLayer*, QString > mSymbolLayerTable; -#endif //! Scale for symbology export (e.g. for symbols units in map units) double mSymbologyScaleDenominator; diff --git a/src/gui/qgsnewgeopackagelayerdialog.cpp b/src/gui/qgsnewgeopackagelayerdialog.cpp index cf363fab1d2..9a9f14b9bcc 100644 --- a/src/gui/qgsnewgeopackagelayerdialog.cpp +++ b/src/gui/qgsnewgeopackagelayerdialog.cpp @@ -42,14 +42,12 @@ #include #include -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) #define SUPPORT_GEOMETRY_LESS #define SUPPORT_CURVE_GEOMETRIES #define SUPPORT_INTEGER64 #define SUPPORT_SPATIAL_INDEX #define SUPPORT_IDENTIFIER_DESCRIPTION #define SUPPORT_FIELD_WIDTH -#endif QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) diff --git a/src/plugins/georeferencer/qgsimagewarper.cpp b/src/plugins/georeferencer/qgsimagewarper.cpp index 54e3616d252..5c955d463b5 100644 --- a/src/plugins/georeferencer/qgsimagewarper.cpp +++ b/src/plugins/georeferencer/qgsimagewarper.cpp @@ -29,11 +29,7 @@ #include "qgsgeoreftransform.h" #include "qgslogger.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 bool QgsImageWarper::mWarpCanceled = false; diff --git a/src/plugins/georeferencer/qgsrasterchangecoords.cpp b/src/plugins/georeferencer/qgsrasterchangecoords.cpp index 276f2e285a7..4febdb281e6 100644 --- a/src/plugins/georeferencer/qgsrasterchangecoords.cpp +++ b/src/plugins/georeferencer/qgsrasterchangecoords.cpp @@ -20,11 +20,7 @@ #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 #define TO8F(x) (x).toUtf8().constData() -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#endif QgsRasterChangeCoords::QgsRasterChangeCoords() : mHasCrs( false ) diff --git a/src/plugins/grass/qgsgrassmoduleparam.cpp b/src/plugins/grass/qgsgrassmoduleparam.cpp index a62e03a3926..7b8ea91a74d 100644 --- a/src/plugins/grass/qgsgrassmoduleparam.cpp +++ b/src/plugins/grass/qgsgrassmoduleparam.cpp @@ -1024,29 +1024,7 @@ QStringList QgsGrassModuleGdalInput::options() if ( !mOgrLayerOption.isEmpty() && mOgrLayers[current].size() > 0 ) { opt = mOgrLayerOption + "="; - // GDAL 1.4.0 supports schemas (r9998) -#if GDAL_VERSION_NUM >= 1400 opt += mOgrLayers[current]; -#else - // Handle older versions of gdal gracefully - // OGR does not support schemas !!! - if ( current >= 0 && current < mUri.size() ) - { - QStringList l = mOgrLayers[current].split( "." ); - opt += l.at( 1 ); - - // Currently only PostGIS is using layer - // -> layer -> PostGIS -> warning - if ( mOgrLayers[current].length() > 0 ) - { - QMessageBox::warning( 0, tr( "Warning" ), - tr( "PostGIS driver in OGR does not support schemas!
" - "Only the table name will be used.
" - "It can result in wrong input if more tables of the same name
" - "are present in the database." ) ); - } - } -#endif //GDAL_VERSION_NUM list.push_back( opt ); } diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index 2b42b7f1771..530a2a5bab7 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -902,8 +902,6 @@ int QgsGdalProvider::ySize() const { return mHeight; } QString QgsGdalProvider::generateBandName( int theBandNumber ) const { -#ifdef GDAL_COMPUTE_VERSION /* only available in GDAL 1.10 or later */ -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,10,0) if ( strcmp( GDALGetDriverShortName( GDALGetDatasetDriver( mGdalDataset ) ), "netCDF" ) == 0 ) { char ** GDALmetadata = GDALGetMetadata( mGdalDataset, nullptr ); @@ -966,8 +964,6 @@ QString QgsGdalProvider::generateBandName( int theBandNumber ) const } } } -#endif -#endif return QgsRasterDataProvider::generateBandName( theBandNumber ); } @@ -1020,27 +1016,6 @@ QgsRasterIdentifyResult QgsGdalProvider::identify( const QgsPoint & thePoint, Qg int width = 1; int height = 1; - // GDAL ECW driver in GDAL < 1.9.2 read whole row if single pixel (nYSize == 1) - // was requested which made identify very slow -> use 2x2 matrix - // but other drivers may be optimised for 1x1 -> conditional -#if !defined(GDAL_VERSION_NUM) || GDAL_VERSION_NUM < 1920 - if ( strcmp( GDALGetDriverShortName( GDALGetDatasetDriver( mGdalDataset ) ), "ECW" ) == 0 ) - { - width = 2; - height = 2; - if ( col == mWidth - 1 && mWidth > 1 ) - { - col--; - c++; - } - if ( row == mHeight - 1 && mHeight > 1 ) - { - row--; - r++; - } - } -#endif - double xMin = myExtent.xMinimum() + col * xres; double xMax = xMin + xres * width; double yMax = myExtent.yMaximum() - row * yres; @@ -1146,7 +1121,6 @@ Qgis::DataType QgsGdalProvider::dataType( int bandNo ) const double QgsGdalProvider::bandScale( int bandNo ) const { -#if GDAL_VERSION_NUM >= 1800 GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, bandNo ); int bGotScale; double myScale = GDALGetRasterScale( myGdalBand, &bGotScale ); @@ -1154,15 +1128,10 @@ double QgsGdalProvider::bandScale( int bandNo ) const return myScale; else return 1.0; -#else - Q_UNUSED( bandNo ); - return 1.0; -#endif } double QgsGdalProvider::bandOffset( int bandNo ) const { -#if GDAL_VERSION_NUM >= 1800 GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, bandNo ); int bGotOffset; double myOffset = GDALGetRasterOffset( myGdalBand, &bGotOffset ); @@ -1170,10 +1139,6 @@ double QgsGdalProvider::bandOffset( int bandNo ) const return myOffset; else return 0.0; -#else - Q_UNUSED( bandNo ); - return 0.0; -#endif } int QgsGdalProvider::bandCount() const @@ -1294,20 +1259,10 @@ bool QgsGdalProvider::hasHistogram( int theBandNo, double myMinVal, myMaxVal; int myBinCount; -#if GDAL_VERSION_MAJOR >= 2 GUIntBig* myHistogramArray = 0; CPLErr myError = GDALGetDefaultHistogramEx( myGdalBand, &myMinVal, &myMaxVal, &myBinCount, &myHistogramArray, false, nullptr, nullptr ); -#else - int* myHistogramArray = nullptr; - - // TODO: GDALGetDefaultHistogram has no bIncludeOutOfRange and bApproxOK, - // consider consequences - CPLErr myError = GDALGetDefaultHistogram( myGdalBand, &myMinVal, &myMaxVal, - &myBinCount, &myHistogramArray, false, - nullptr, nullptr ); -#endif if ( myHistogramArray ) VSIFree( myHistogramArray ); // use VSIFree because allocated by GDAL @@ -1456,19 +1411,11 @@ QgsRasterHistogram QgsGdalProvider::histogram( int theBandNo, } #endif -#if GDAL_VERSION_MAJOR >= 2 GUIntBig* myHistogramArray = new GUIntBig[myHistogram.binCount]; CPLErr myError = GDALGetRasterHistogramEx( myGdalBand, myMinVal, myMaxVal, myHistogram.binCount, myHistogramArray, theIncludeOutOfRange, bApproxOK, progressCallback, &myProg ); //this is the arg for our custom gdal progress callback -#else - int* myHistogramArray = new int[myHistogram.binCount]; - CPLErr myError = GDALGetRasterHistogram( myGdalBand, myMinVal, myMaxVal, - myHistogram.binCount, myHistogramArray, - theIncludeOutOfRange, bApproxOK, progressCallback, - &myProg ); //this is the arg for our custom gdal progress callback -#endif if ( myError != CE_None ) { @@ -1481,19 +1428,9 @@ QgsRasterHistogram QgsGdalProvider::histogram( int theBandNo, for ( int myBin = 0; myBin < myHistogram.binCount; myBin++ ) { -#if GDAL_VERSION_MAJOR < 2 - if ( myHistogramArray[myBin] < 0 ) //can't have less than 0 pixels of any value - { - myHistogram.histogramVector.push_back( 0 ); - // QgsDebugMsg( "Added 0 to histogram vector as freq was negative!" ); - } - else -#endif - { - myHistogram.histogramVector.push_back( myHistogramArray[myBin] ); - myHistogram.nonNullCount += myHistogramArray[myBin]; - // QgsDebugMsg( "Added " + QString::number( myHistogramArray[myBin] ) + " to histogram vector" ); - } + myHistogram.histogramVector.push_back( myHistogramArray[myBin] ); + myHistogram.nonNullCount += myHistogramArray[myBin]; + // QgsDebugMsg( "Added " + QString::number( myHistogramArray[myBin] ) + " to histogram vector" ); } myHistogram.valid = true; @@ -1727,11 +1664,7 @@ QString QgsGdalProvider::buildPyramids( const QList & theRaste // is called next time, it crashes somewhere in GDAL: // https://trac.osgeo.org/gdal/ticket/4831 // Crash can be avoided if dataset is reopened, fixed in GDAL 1.9.2 -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1920 if ( theFormat == QgsRaster::PyramidsInternal ) -#else - if ( true ) // GDAL #4831 fix -#endif { QgsDebugMsg( "Reopening dataset ..." ); //close the gdal dataset and reopen it in read only mode @@ -2034,12 +1967,8 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString // in GDAL 2.0 vector and mixed drivers are returned by GDALGetDriver, so filter out non-raster drivers // TODO also make sure drivers are not loaded unnecessarily (as GDALAllRegister() and OGRRegisterAll load all 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 // now we need to see if the driver is for something currently // supported; if not, we give it a miss for the next driver @@ -2193,14 +2122,12 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString theFileFiltersString = filters.join( QStringLiteral( ";;" ) ) + ";;"; // VSIFileHandler (see qgsogrprovider.cpp) - second -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1600 QSettings settings; if ( settings.value( QStringLiteral( "/qgis/scanZipInBrowser2" ), "basic" ).toString() != QLatin1String( "no" ) ) { theFileFiltersString.prepend( createFileFilter_( QObject::tr( "GDAL/OGR VSIFileHandler" ), QStringLiteral( "*.zip *.gz *.tar *.tar.gz *.tgz" ) ) ); theExtensions << QStringLiteral( "zip" ) << QStringLiteral( "gz" ) << QStringLiteral( "tar" ) << QStringLiteral( "tar.gz" ) << QStringLiteral( "tgz" ); } -#endif // can't forget the default case - first theFileFiltersString.prepend( QObject::tr( "All files" ) + " (*);;" ); @@ -3045,10 +2972,8 @@ QGISEXTERN QList > *pyramidResamplingMethods() methods.append( QPair( QStringLiteral( "AVERAGE" ), QObject::tr( "Average" ) ) ); methods.append( QPair( QStringLiteral( "GAUSS" ), QObject::tr( "Gauss" ) ) ); methods.append( QPair( QStringLiteral( "CUBIC" ), QObject::tr( "Cubic" ) ) ); -#if GDAL_VERSION_MAJOR >= 2 methods.append( QPair( "CUBICSPLINE", QObject::tr( "Cubic Spline" ) ) ); methods.append( QPair( "LANCZOS", QObject::tr( "Lanczos" ) ) ); -#endif methods.append( QPair( QStringLiteral( "MODE" ), QObject::tr( "Mode" ) ) ); methods.append( QPair( QStringLiteral( "NONE" ), QObject::tr( "None" ) ) ); } diff --git a/src/providers/gdal/qgsgdalproviderbase.cpp b/src/providers/gdal/qgsgdalproviderbase.cpp index a1009a64710..b91cc3bf002 100644 --- a/src/providers/gdal/qgsgdalproviderbase.cpp +++ b/src/providers/gdal/qgsgdalproviderbase.cpp @@ -262,21 +262,7 @@ QgsRectangle QgsGdalProviderBase::extent( GDALDatasetH gdalDataset )const GDALDatasetH QgsGdalProviderBase::gdalOpen( const char *pszFilename, GDALAccess eAccess ) { - // See http://hub.qgis.org/issues/8356 and http://trac.osgeo.org/gdal/ticket/5170 -#if GDAL_VERSION_MAJOR == 1 && ( (GDAL_VERSION_MINOR == 9 && GDAL_VERSION_REV <= 2) || (GDAL_VERSION_MINOR == 10 && GDAL_VERSION_REV <= 0) ) - char* pszOldVal = CPLStrdup( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ); - CPLSetThreadLocalConfigOption( "VSI_CACHE", "FALSE" ); - QgsDebugMsg( "Disabled VSI_CACHE" ); -#endif - GDALDatasetH hDS = GDALOpen( pszFilename, eAccess ); - -#if GDAL_VERSION_MAJOR == 1 && ( (GDAL_VERSION_MINOR == 9 && GDAL_VERSION_REV <= 2) || (GDAL_VERSION_MINOR == 10 && GDAL_VERSION_REV <= 0) ) - CPLSetThreadLocalConfigOption( "VSI_CACHE", pszOldVal ); - CPLFree( pszOldVal ); - QgsDebugMsg( "Reset VSI_CACHE" ); -#endif - return hDS; } @@ -292,14 +278,6 @@ int CPL_STDCALL _gdalProgressFnWithFeedback( double dfComplete, const char *pszM CPLErr QgsGdalProviderBase::gdalRasterIO( GDALRasterBandH hBand, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, void * pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, int nPixelSpace, int nLineSpace, QgsRasterBlockFeedback* feedback ) { - // See http://hub.qgis.org/issues/8356 and http://trac.osgeo.org/gdal/ticket/5170 -#if GDAL_VERSION_MAJOR == 1 && ( (GDAL_VERSION_MINOR == 9 && GDAL_VERSION_REV <= 2) || (GDAL_VERSION_MINOR == 10 && GDAL_VERSION_REV <= 0) ) - char* pszOldVal = CPLStrdup( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ); - CPLSetThreadLocalConfigOption( "VSI_CACHE", "FALSE" ); - QgsDebugMsg( "Disabled VSI_CACHE" ); -#endif - -#if GDAL_VERSION_MAJOR >= 2 GDALRasterIOExtraArg extra; INIT_RASTERIO_EXTRA_ARG( extra ); if ( 0 && feedback ) // disabled! @@ -313,36 +291,12 @@ CPLErr QgsGdalProviderBase::gdalRasterIO( GDALRasterBandH hBand, GDALRWFlag eRWF extra.pProgressData = ( void* ) feedback; } CPLErr err = GDALRasterIOEx( hBand, eRWFlag, nXOff, nYOff, nXSize, nYSize, pData, nBufXSize, nBufYSize, eBufType, nPixelSpace, nLineSpace, &extra ); -#else - Q_UNUSED( feedback ); - CPLErr err = GDALRasterIO( hBand, eRWFlag, nXOff, nYOff, nXSize, nYSize, pData, nBufXSize, nBufYSize, eBufType, nPixelSpace, nLineSpace ); -#endif - -#if GDAL_VERSION_MAJOR == 1 && ( (GDAL_VERSION_MINOR == 9 && GDAL_VERSION_REV <= 2) || (GDAL_VERSION_MINOR == 10 && GDAL_VERSION_REV <= 0) ) - CPLSetThreadLocalConfigOption( "VSI_CACHE", pszOldVal ); - CPLFree( pszOldVal ); - QgsDebugMsg( "Reset VSI_CACHE" ); -#endif return err; } int QgsGdalProviderBase::gdalGetOverviewCount( GDALRasterBandH hBand ) { - // See http://hub.qgis.org/issues/8356 and http://trac.osgeo.org/gdal/ticket/5170 -#if GDAL_VERSION_MAJOR == 1 && ( (GDAL_VERSION_MINOR == 9 && GDAL_VERSION_REV <= 2) || (GDAL_VERSION_MINOR == 10 && GDAL_VERSION_REV <= 0) ) - char* pszOldVal = CPLStrdup( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ); - CPLSetThreadLocalConfigOption( "VSI_CACHE", "FALSE" ); - QgsDebugMsg( "Disabled VSI_CACHE" ); -#endif - int count = GDALGetOverviewCount( hBand ); - -#if GDAL_VERSION_MAJOR == 1 && ( (GDAL_VERSION_MINOR == 9 && GDAL_VERSION_REV <= 2) || (GDAL_VERSION_MINOR == 10 && GDAL_VERSION_REV <= 0) ) - CPLSetThreadLocalConfigOption( "VSI_CACHE", pszOldVal ); - CPLFree( pszOldVal ); - QgsDebugMsg( "Reset VSI_CACHE" ); -#endif - return count; } diff --git a/src/providers/gdal/qgsgdalproviderbase.h b/src/providers/gdal/qgsgdalproviderbase.h index 9595112eb96..aba702fa9d7 100644 --- a/src/providers/gdal/qgsgdalproviderbase.h +++ b/src/providers/gdal/qgsgdalproviderbase.h @@ -26,13 +26,8 @@ #define CPL_SUPRESS_CPLUSPLUS #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 #define TO8F(x) (x).toUtf8().constData() #define FROM8(x) QString::fromUtf8(x) -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#define FROM8(x) QString::fromLocal8Bit(x) -#endif /** \brief Base clasee for GDAL and WCS providers. diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index f2881621d82..5103fd6a25d 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -104,13 +104,8 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding ) switch ( field.type() ) { case QVariant::LongLong: -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 ogrType = OFTInteger64; ogrPrecision = 0; -#else - ogrType = OFTString; - ogrPrecision = -1; -#endif ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21; break; @@ -406,9 +401,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri ) QList nativeTypes; nativeTypes << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 11 ) -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 << QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 0, 21 ) -#endif << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), QStringLiteral( "double" ), QVariant::Double, 0, 20, 0, 15 ) << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QVariant::String, 0, 65535 ) << QgsVectorDataProvider::NativeType( tr( "Date" ), QStringLiteral( "date" ), QVariant::Date, 8, 8 ); @@ -571,7 +564,6 @@ QString QgsOgrProvider::ogrWkbGeometryTypeName( OGRwkbGeometryType type ) const case wkbGeometryCollection: geom = QStringLiteral( "GeometryCollection" ); break; -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) case wkbCircularString: geom = QStringLiteral( "CircularString" ); break; @@ -602,7 +594,6 @@ QString QgsOgrProvider::ogrWkbGeometryTypeName( OGRwkbGeometryType type ) const case wkbMultiSurfaceZ: geom = QStringLiteral( "MultiSurfaceZ" ); break; -#endif case wkbNone: geom = QStringLiteral( "None" ); break; @@ -730,7 +721,6 @@ QStringList QgsOgrProvider::subLayers() const fCount[wkbUnknown] = 0; } -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) // When there are CurvePolygons, promote Polygons if ( fCount.contains( wkbPolygon ) && fCount.contains( wkbCurvePolygon ) ) { @@ -748,21 +738,12 @@ QStringList QgsOgrProvider::subLayers() const fCount[wkbCompoundCurve] += fCount.value( wkbCircularString ); fCount.remove( wkbCircularString ); } -#endif -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) bool bIs25D = ( wkbHasZ( layerGeomType ) != 0 ); -#else - bool bIs25D = (( layerGeomType & wkb25DBit ) != 0 ); -#endif QMap::const_iterator countIt = fCount.constBegin(); for ( ; countIt != fCount.constEnd(); ++countIt ) { -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) QString geom = ogrWkbGeometryTypeName(( bIs25D ) ? wkbSetZ( countIt.key() ) : countIt.key() ); -#else - QString geom = ogrWkbGeometryTypeName(( bIs25D ) ? ( OGRwkbGeometryType )( countIt.key() | wkb25DBit ) : countIt.key() ); -#endif QString sl = QStringLiteral( "%1:%2:%3:%4" ).arg( i ).arg( theLayerName ).arg( fCount.value( countIt.key() ) ).arg( geom ); QgsDebugMsg( "sub layer: " + sl ); @@ -881,15 +862,12 @@ void QgsOgrProvider::loadFields() 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; @@ -900,7 +878,6 @@ void QgsOgrProvider::loadFields() varType = QVariant::DateTime; break; case OFTString: -#endif default: varType = QVariant::String; // other unsupported, leave it as a string } @@ -940,7 +917,6 @@ void QgsOgrProvider::loadFields() width, prec ); -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) // check if field is nullable bool nullable = OGR_Fld_IsNullable( fldDef ); if ( !nullable ) @@ -956,7 +932,6 @@ void QgsOgrProvider::loadFields() { mDefaultValues.insert( i + ( mFirstFieldIsFid ? 1 : 0 ), defaultValue ); } -#endif mAttributeFields.append( newField ); } @@ -979,7 +954,6 @@ void QgsOgrProvider::setRelevantFields( OGRLayerH ogrLayer, bool fetchGeometry, void QgsOgrProviderUtils::setRelevantFields( OGRLayerH ogrLayer, int fieldCount, bool fetchGeometry, const QgsAttributeList &fetchAttributes, bool firstAttrIsFid ) { -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 if ( OGR_L_TestCapability( ogrLayer, OLCIgnoreFields ) ) { QVector ignoredFields; @@ -1000,11 +974,6 @@ void QgsOgrProviderUtils::setRelevantFields( OGRLayerH ogrLayer, int fieldCount, OGR_L_SetIgnoredFields( ogrLayer, ignoredFields.data() ); } -#else - Q_UNUSED( ogrLayer ); - Q_UNUSED( fetchGeometry ); - Q_UNUSED( fetchAttributes ); -#endif } QgsFeatureIterator QgsOgrProvider::getFeatures( const QgsFeatureRequest& request ) const @@ -1192,11 +1161,8 @@ OGRGeometryH QgsOgrProvider::ConvertGeometryIfNecessary( OGRGeometryH hGeom ) { return OGR_G_ForceToMultiLineString( hGeom ); } -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) + return OGR_G_ForceTo( hGeom, layerGeomType, nullptr ); -#else - return hGeom; -#endif } bool QgsOgrProvider::addFeature( QgsFeature& f ) @@ -1239,11 +1205,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f ) qlonglong id = attrFid.toLongLong( &ok ); if ( ok ) { -#if GDAL_VERSION_MAJOR >= 2 OGR_F_SetFID( feature, static_cast( id ) ); -#else - OGR_F_SetFID( feature, static_cast( id ) ); -#endif } } } @@ -1275,11 +1237,9 @@ bool QgsOgrProvider::addFeature( QgsFeature& f ) break; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case OFTInteger64: OGR_F_SetFieldInteger64( feature, ogrAttId, attrVal.toLongLong() ); break; -#endif case OFTReal: OGR_F_SetFieldDouble( feature, ogrAttId, attrVal.toDouble() ); @@ -1409,7 +1369,6 @@ bool QgsOgrProvider::addAttributes( const QList &attributes ) case QVariant::Int: type = OFTInteger; break; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case QVariant::LongLong: { const char* pszDataTypes = GDALGetMetadataItem( ogrDriver, GDAL_DMD_CREATIONFIELDDATATYPES, NULL ); @@ -1421,7 +1380,6 @@ bool QgsOgrProvider::addAttributes( const QList &attributes ) } break; } -#endif case QVariant::Double: type = OFTReal; break; @@ -1486,7 +1444,6 @@ bool QgsOgrProvider::deleteAttributes( const QgsAttributeIds &attributes ) if ( !doInitialActionsForEdition() ) return false; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1900 bool res = true; QList attrsLst = attributes.toList(); // sort in descending order @@ -1514,11 +1471,6 @@ bool QgsOgrProvider::deleteAttributes( const QgsAttributeIds &attributes ) } loadFields(); return res; -#else - Q_UNUSED( attributes ); - pushError( tr( "Deleting fields is not supported prior to GDAL 1.9.0" ) ); - return false; -#endif } bool QgsOgrProvider::renameAttributes( const QgsFieldNameMap& renamedAttributes ) @@ -1526,7 +1478,6 @@ bool QgsOgrProvider::renameAttributes( const QgsFieldNameMap& renamedAttributes if ( !doInitialActionsForEdition() ) return false; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1900 QgsFieldNameMap::const_iterator renameIt = renamedAttributes.constBegin(); bool result = true; for ( ; renameIt != renamedAttributes.constEnd(); ++renameIt ) @@ -1568,11 +1519,6 @@ bool QgsOgrProvider::renameAttributes( const QgsFieldNameMap& renamedAttributes } loadFields(); return result; -#else - Q_UNUSED( attributes ); - pushError( tr( "Renaming fields is not supported prior to GDAL 1.9.0" ) ); - return false; -#endif } @@ -1651,11 +1597,9 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_ case OFTInteger: OGR_F_SetFieldInteger( of, f, it2->toInt() ); break; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 case OFTInteger64: OGR_F_SetFieldInteger64( of, f, it2->toLongLong() ); break; -#endif case OFTReal: OGR_F_SetFieldDouble( of, f, it2->toDouble() ); break; @@ -2444,7 +2388,6 @@ QString createFilters( const QString& type ) // see http://trac.osgeo.org/gdal/wiki/UserDocs/ReadInZip // Requires GDAL>=1.6.0 with libz support, let's assume we have it. // This does not work for some file types, see VSIFileHandler doc. -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1600 QSettings settings; if ( settings.value( QStringLiteral( "/qgis/scanZipInBrowser2" ), "basic" ).toString() != QLatin1String( "no" ) ) { @@ -2452,7 +2395,6 @@ QString createFilters( const QString& type ) myExtensions << QStringLiteral( "zip" ) << QStringLiteral( "gz" ) << QStringLiteral( "tar" ) << QStringLiteral( "tar.gz" ) << QStringLiteral( "tgz" ); } -#endif // can't forget the default case - first myFileFilters.prepend( QObject::tr( "All files" ) + " (*);;" ); @@ -2812,12 +2754,10 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, } QgsDebugMsg( QString( "GDAL Version number %1" ).arg( GDAL_VERSION_NUM ) ); -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1310 if ( reference ) { OSRRelease( reference ); } -#endif //GDAL_VERSION_NUM return true; } @@ -2889,10 +2829,6 @@ void QgsOgrProvider::uniqueValues( int index, QList &uniqueValues, int return; //not a provider field } -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1910 - // avoid GDAL #4509 - return QgsVectorDataProvider::uniqueValues( index, uniqueValues, limit ); -#else QByteArray sql = "SELECT DISTINCT " + quotedIdentifier( textEncoding()->fromUnicode( fld.name() ) ); sql += " FROM " + quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrLayer ) ) ); @@ -2922,7 +2858,6 @@ void QgsOgrProvider::uniqueValues( int index, QList &uniqueValues, int } OGR_DS_ReleaseResultSet( ogrDataSource, l ); -#endif } QStringList QgsOgrProvider::uniqueStringsMatching( int index, const QString& substring, int limit, QgsFeedback* feedback ) const @@ -2938,10 +2873,6 @@ QStringList QgsOgrProvider::uniqueStringsMatching( int index, const QString& sub return results; //not a provider field } -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1910 - // avoid GDAL #4509 - return QgsVectorDataProvider::uniqueStringsMatching( index, substring, limit, feedback ); -#else QByteArray sql = "SELECT DISTINCT " + quotedIdentifier( textEncoding()->fromUnicode( fld.name() ) ); sql += " FROM " + quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrLayer ) ) ); @@ -2975,7 +2906,6 @@ QStringList QgsOgrProvider::uniqueStringsMatching( int index, const QString& sub OGR_DS_ReleaseResultSet( ogrDataSource, l ); return results; -#endif } QVariant QgsOgrProvider::minimumValue( int index ) const @@ -3075,20 +3005,7 @@ OGRDataSourceH QgsOgrProviderUtils::OGROpenWrapper( const char* pszPath, bool bU *phDriver = hDriver; if ( !hDS ) return nullptr; - // GDAL < 1.11.5 has a crashing bug with GeoPackage databases with curve geometry - // types (https://trac.osgeo.org/gdal/ticket/6558) -#if GDAL_VERSION_MAJOR == 1 && GDAL_VERSION_MINOR == 11 && GDAL_VERSION_MACRO < 5 - const char* pszLastErrorMsg = CPLGetLastErrorMsg(); - if ( hDriver == OGRGetDriverByName( "GPKG" ) && - strstr( pszLastErrorMsg, "geometry column" ) && - strstr( pszLastErrorMsg, "of type" ) && - strstr( pszLastErrorMsg, "ignored" ) ) - { - QgsDebugMsg( QString( "Ignoring %1 that is a GeoPackage DB with curve geometries" ).arg( pszPath ) ); - OGR_DS_Destroy( hDS ); - hDS = nullptr; - } -#endif + return hDS; } @@ -3371,12 +3288,10 @@ OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type return wkbLineString; case wkbMultiPolygon: return wkbPolygon; -#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0) case wkbMultiCurve: return wkbCompoundCurve; case wkbMultiSurface: return wkbCurvePolygon; -#endif default: return type; } @@ -3824,9 +3739,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS } { OGRFieldDefnH fld = OGR_Fld_Create( "useAsDefault", OFTInteger ); -#if GDAL_VERSION_MAJOR >= 2 OGR_Fld_SetSubType( fld, OFSTBoolean ); -#endif ok &= OGR_L_CreateField( hLayer, fld, true ) == OGRERR_NONE; OGR_Fld_Destroy( fld ); } @@ -3849,9 +3762,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS } { OGRFieldDefnH fld = OGR_Fld_Create( "update_time", OFTDateTime ); -#if GDAL_VERSION_MAJOR >= 2 OGR_Fld_SetDefault( fld, "CURRENT_TIMESTAMP" ); -#endif ok &= OGR_L_CreateField( hLayer, fld, true ) == OGRERR_NONE; OGR_Fld_Destroy( fld ); } diff --git a/src/providers/ogr/qgsogrprovider.h b/src/providers/ogr/qgsogrprovider.h index 2bddecb8f58..6e96836f495 100644 --- a/src/providers/ogr/qgsogrprovider.h +++ b/src/providers/ogr/qgsogrprovider.h @@ -32,15 +32,9 @@ class QgsOgrFeatureIterator; #include -#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 /** \class QgsOgrProvider diff --git a/src/providers/wcs/qgswcsprovider.cpp b/src/providers/wcs/qgswcsprovider.cpp index c241caee1a3..e35bb83d20f 100644 --- a/src/providers/wcs/qgswcsprovider.cpp +++ b/src/providers/wcs/qgswcsprovider.cpp @@ -49,13 +49,8 @@ #include "cpl_conv.h" #include "cpl_string.h" -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 #define TO8F(x) (x).toUtf8().constData() #define FROM8(x) QString::fromUtf8(x) -#else -#define TO8F(x) QFile::encodeName( x ).constData() -#define FROM8(x) QString::fromLocal8Bit(x) -#endif #define ERR(message) QGS_ERROR_MESSAGE(message,"WCS provider") #define SRVERR(message) QGS_ERROR_MESSAGE(message,"WCS server") diff --git a/src/providers/wcs/qgswcsprovider.h b/src/providers/wcs/qgswcsprovider.h index bd95b2c0d2a..e798fbef37b 100644 --- a/src/providers/wcs/qgswcsprovider.h +++ b/src/providers/wcs/qgswcsprovider.h @@ -348,11 +348,7 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase //! Name of memory file for cached data QString mCachedMemFilename; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 mutable VSILFILE * mCachedMemFile; -#else - mutable FILE * mCachedMemFile; -#endif //! Pointer to cached GDAL dataset mutable GDALDatasetH mCachedGdalDataset; diff --git a/src/providers/wfs/qgswfsshareddata.cpp b/src/providers/wfs/qgswfsshareddata.cpp index 4c9f159f9a5..60a4ac91d46 100644 --- a/src/providers/wfs/qgswfsshareddata.cpp +++ b/src/providers/wfs/qgswfsshareddata.cpp @@ -202,9 +202,7 @@ bool QgsWFSSharedData::computeFilter( QString& errorMsg ) // The difference is that in the QGIS way we have to create the template database // on disk, which is a slightly bit slower. But due to later caching, this is // not so a big deal. -#if GDAL_VERSION_MAJOR >= 2 || GDAL_VERSION_MINOR >= 11 #define USE_OGR_FOR_DB_CREATION -#endif static QString quotedIdentifier( QString id ) { @@ -248,16 +246,8 @@ bool QgsWFSSharedData::createCache() // but QgsVectorFileWriter will refuse anyway to create a ogc_fid, so we will // do it manually bool useReservedNames = cacheFields.lookupField( QStringLiteral( "ogc_fid" ) ) >= 0; -#if GDAL_VERSION_MAJOR < 2 - if ( cacheFields.lookupField( QStringLiteral( "geometry" ) ) >= 0 ) - useReservedNames = true; -#endif if ( !useReservedNames ) { -#if GDAL_VERSION_MAJOR < 2 - fidName = QStringLiteral( "ogc_fid" ); - geometryFieldname = QStringLiteral( "GEOMETRY" ); -#endif // Creating a spatialite database can be quite slow on some file systems // so we create a GDAL in-memory file, and then copy it on // the file system. @@ -266,10 +256,8 @@ bool QgsWFSSharedData::createCache() QStringList layerOptions; datasourceOptions.push_back( QStringLiteral( "INIT_WITH_EPSG=NO" ) ); layerOptions.push_back( QStringLiteral( "LAUNDER=NO" ) ); // to get exact matches for field names, especially regarding case -#if GDAL_VERSION_MAJOR >= 2 layerOptions.push_back( "FID=__ogc_fid" ); layerOptions.push_back( "GEOMETRY_NAME=__spatialite_geometry" ); -#endif vsimemFilename.sprintf( "/vsimem/qgis_wfs_cache_template_%p/features.sqlite", this ); mCacheTablename = CPLGetBasename( vsimemFilename.toStdString().c_str() ); VSIUnlink( vsimemFilename.toStdString().c_str() ); diff --git a/src/server/qgssldconfigparser.cpp b/src/server/qgssldconfigparser.cpp index df3d503d631..a9842d5ef6b 100644 --- a/src/server/qgssldconfigparser.cpp +++ b/src/server/qgssldconfigparser.cpp @@ -49,11 +49,7 @@ #include -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 #define TO8(x) (x).toUtf8().constData() -#else -#define TO8(x) (x).toLocal8Bit().constData() -#endif QgsSLDConfigParser::QgsSLDConfigParser( QDomDocument* doc, const QMap& parameters ) : QgsWmsConfigParser() diff --git a/tests/src/core/testqgscoordinatereferencesystem.cpp b/tests/src/core/testqgscoordinatereferencesystem.cpp index e84730552af..109bcd9c1bc 100644 --- a/tests/src/core/testqgscoordinatereferencesystem.cpp +++ b/tests/src/core/testqgscoordinatereferencesystem.cpp @@ -102,13 +102,11 @@ void TestQgsCoordinateReferenceSystem::initTestCase() qDebug() << "PROJ.4 version: " << PJ_VERSION; // if user set GDAL_FIX_ESRI_WKT print a warning -#if GDAL_VERSION_NUM >= 1900 if ( strcmp( CPLGetConfigOption( "GDAL_FIX_ESRI_WKT", "" ), "" ) != 0 ) { qDebug() << "Warning! GDAL_FIX_ESRI_WKT =" << CPLGetConfigOption( "GDAL_FIX_ESRI_WKT", "" ) << "this might generate errors!"; } -#endif } @@ -361,14 +359,10 @@ void TestQgsCoordinateReferenceSystem::createFromESRIWkt() myWktStrings << QStringLiteral( "GEOGCS[\"GCS_South_American_1969\",DATUM[\"D_South_American_1969\",SPHEROID[\"GRS_1967_Truncated\",6378160.0,298.25]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]" ); myFiles << QLatin1String( "" ); myGdalVersionOK << 1900; -#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 + //proj definition for EPSG:4618 was updated in GDAL 2.0 - see https://github.com/OSGeo/proj.4/issues/241 myProj4Strings << "+proj=longlat +ellps=aust_SA +towgs84=-66.87,4.37,-38.52,0,0,0,0 +no_defs"; myTOWGS84Strings << "+towgs84=-66.87,4.37,-38.52,0,0,0,0"; -#else - myProj4Strings << QStringLiteral( "+proj=longlat +ellps=aust_SA +towgs84=-57,1,-41,0,0,0,0 +no_defs" ); - myTOWGS84Strings << QStringLiteral( "+towgs84=-57,1,-41,0,0,0,0" ); -#endif myAuthIdStrings << QStringLiteral( "EPSG:4618" ); // do test with WKT definitions @@ -637,21 +631,12 @@ void TestQgsCoordinateReferenceSystem::toWkt() myCrs.createFromSrid( GEOSRID ); QString myWkt = myCrs.toWkt(); debugPrint( myCrs ); -#if GDAL_VERSION_NUM >= 1800 //Note: this is not the same as GEOWKT as OGR strips off the TOWGS clause... QString myStrippedWkt( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID" "[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," "AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY" "[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY" "[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ); -#else - // for GDAL <1.8 - QString myStrippedWkt( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID" - "[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," - "AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY" - "[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY" - "[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ); -#endif qDebug() << "wkt: " << myWkt; qDebug() << "stripped: " << myStrippedWkt; QVERIFY( myWkt == myStrippedWkt ); diff --git a/tests/src/core/testqgsogrutils.cpp b/tests/src/core/testqgsogrutils.cpp index 7afeaab48df..6e04340b38b 100644 --- a/tests/src/core/testqgsogrutils.cpp +++ b/tests/src/core/testqgsogrutils.cpp @@ -29,15 +29,9 @@ #include "qgsapplication.h" #include "qgspointv2.h" -#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 class TestQgsOgrUtils: public QObject { diff --git a/tests/src/core/testziplayer.cpp b/tests/src/core/testziplayer.cpp index b584e06fac9..4c0fa9ac6d8 100644 --- a/tests/src/core/testziplayer.cpp +++ b/tests/src/core/testziplayer.cpp @@ -314,9 +314,6 @@ void TestZipLayer::testPassthruVectorZip() QSettings settings; QString myFileName = mDataDir + "points2.zip"; QgsDebugMsg( "GDAL: " + QString( GDAL_RELEASE_NAME ) ); -#if GDAL_VERSION_NUM < 1800 - myFileName = "/vsizip/" + myFileName + "/points.shp"; -#endif QgsDebugMsg( "FILE: " + QString( myFileName ) ); Q_FOREACH ( const QString& s, mScanZipSettings ) { @@ -328,9 +325,6 @@ void TestZipLayer::testPassthruVectorZip() void TestZipLayer::testPassthruVectorTar() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QSettings settings; QString myFileName = mDataDir + "points2.tar"; Q_FOREACH ( const QString& s, mScanZipSettings ) @@ -343,9 +337,6 @@ void TestZipLayer::testPassthruVectorTar() void TestZipLayer::testPassthruVectorGzip() { -#if GDAL_VERSION_NUM < 1700 - QSKIP( "This test requires GDAL >= 1.7", SkipSingle ); -#endif QSettings settings; Q_FOREACH ( const QString& s, mScanZipSettings ) { @@ -368,9 +359,6 @@ void TestZipLayer::testPassthruRasterZip() void TestZipLayer::testPassthruRasterTar() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QSettings settings; Q_FOREACH ( const QString& s, mScanZipSettings ) { @@ -404,9 +392,6 @@ void TestZipLayer::testZipItemRaster() void TestZipLayer::testTarItemRaster() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QSettings settings; Q_FOREACH ( const QString& s, mScanZipSettings ) { @@ -429,9 +414,6 @@ void TestZipLayer::testZipItemVector() void TestZipLayer::testTarItemVector() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QSettings settings; Q_FOREACH ( const QString& s, mScanZipSettings ) { @@ -455,9 +437,6 @@ void TestZipLayer::testZipItemAll() void TestZipLayer::testTarItemAll() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QSettings settings; settings.setValue( mSettingsKey, "full" ); QVERIFY( "full" == settings.value( mSettingsKey ).toString() ); @@ -497,9 +476,6 @@ void TestZipLayer::testZipItemRasterTransparency() void TestZipLayer::testTarItemRasterTransparency() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QVERIFY( testZipItemTransparency( mDataDir + "landsat_b1.tar", "gdal", 250 ) ); } @@ -521,9 +497,6 @@ void TestZipLayer::testZipItemSubfolder() void TestZipLayer::testTarItemSubfolder() { -#if GDAL_VERSION_NUM < 1800 - QSKIP( "This test requires GDAL >= 1.8", SkipSingle ); -#endif QSettings settings; Q_FOREACH ( const QString& s, mScanZipSettings ) { @@ -536,9 +509,6 @@ void TestZipLayer::testTarItemSubfolder() void TestZipLayer::testZipItemVRT() { -#if GDAL_VERSION_NUM < 1700 - QSKIP( "This test requires GDAL >= 1.7", SkipSingle ); -#endif QSettings settings; Q_FOREACH ( const QString& s, mScanZipSettings ) { diff --git a/tests/src/python/test_db_manager_gpkg.py b/tests/src/python/test_db_manager_gpkg.py index 5b92ed1d39d..9e9d6216f60 100644 --- a/tests/src/python/test_db_manager_gpkg.py +++ b/tests/src/python/test_db_manager_gpkg.py @@ -404,13 +404,11 @@ class TestPyQgsDBManagerGpkg(unittest.TestCase): ds.CreateLayer('testMultiLineString', geom_type=ogr.wkbMultiLineString) ds.CreateLayer('testMultiPolygon', geom_type=ogr.wkbMultiPolygon) ds.CreateLayer('testGeometryCollection', geom_type=ogr.wkbGeometryCollection) - - if int(gdal.VersionInfo('VERSION_NUM')) >= GDAL_COMPUTE_VERSION(2, 0, 0): - ds.CreateLayer('testCircularString', geom_type=ogr.wkbCircularString) - ds.CreateLayer('testCompoundCurve', geom_type=ogr.wkbCompoundCurve) - ds.CreateLayer('testCurvePolygon', geom_type=ogr.wkbCurvePolygon) - ds.CreateLayer('testMultiCurve', geom_type=ogr.wkbMultiCurve) - ds.CreateLayer('testMultiSurface', geom_type=ogr.wkbMultiSurface) + ds.CreateLayer('testCircularString', geom_type=ogr.wkbCircularString) + ds.CreateLayer('testCompoundCurve', geom_type=ogr.wkbCompoundCurve) + ds.CreateLayer('testCurvePolygon', geom_type=ogr.wkbCurvePolygon) + ds.CreateLayer('testMultiCurve', geom_type=ogr.wkbMultiCurve) + ds.CreateLayer('testMultiSurface', geom_type=ogr.wkbMultiSurface) ds = None uri.setDatabase(test_gpkg) diff --git a/tests/src/python/test_provider_ogr.py b/tests/src/python/test_provider_ogr.py index aebfcbcd994..c37c0dee021 100644 --- a/tests/src/python/test_provider_ogr.py +++ b/tests/src/python/test_provider_ogr.py @@ -99,7 +99,6 @@ class PyQgsOGRProvider(unittest.TestCase): self.assertTrue(vl.isValid()) self.assertEqual(vl.wkbType(), QgsWkbTypes.Point) - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) def testMixOfPolygonCurvePolygon(self): datasource = os.path.join(self.basetestpath, 'testMixOfPolygonCurvePolygon.csv') @@ -115,7 +114,6 @@ class PyQgsOGRProvider(unittest.TestCase): self.assertEqual(len(vl.dataProvider().subLayers()), 1) self.assertEqual(vl.dataProvider().subLayers()[0], '0:testMixOfPolygonCurvePolygon:4:CurvePolygon') - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) def testMixOfLineStringCompoundCurve(self): datasource = os.path.join(self.basetestpath, 'testMixOfLineStringCompoundCurve.csv') diff --git a/tests/src/python/test_provider_ogr_gpkg.py b/tests/src/python/test_provider_ogr_gpkg.py index 64c15f6e3ae..a82e2a008cd 100644 --- a/tests/src/python/test_provider_ogr_gpkg.py +++ b/tests/src/python/test_provider_ogr_gpkg.py @@ -76,7 +76,6 @@ class TestPyQgsOGRProviderGpkg(unittest.TestCase): # The geometries must be binarily identical self.assertEqual(got_geom.exportToWkb(), reference.exportToWkb(), 'Expected {}, got {}'.format(reference.exportToWkt(), got_geom.exportToWkt())) - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) def testCurveGeometryType(self): tmpfile = os.path.join(self.basetestpath, 'testCurveGeometryType.gpkg') @@ -146,18 +145,15 @@ class TestPyQgsOGRProviderGpkg(unittest.TestCase): ds = None self.assertEqual(res, 'delete') - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) # We need GDAL 2.0 to issue PRAGMA journal_mode # Note: for that case, we don't strictly need turning on WAL def testBug15351_closeIter_commit_closeProvider(self): self.internalTestBug15351('closeIter_commit_closeProvider') - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) # We need GDAL 2.0 to issue PRAGMA journal_mode def testBug15351_commit_closeProvider_closeIter(self): self.internalTestBug15351('commit_closeProvider_closeIter') - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) # We need GDAL 2.0 to issue PRAGMA journal_mode def testBug15351_commit_closeIter_closeProvider(self): self.internalTestBug15351('commit_closeIter_closeProvider') diff --git a/tests/src/python/test_provider_ogr_sqlite.py b/tests/src/python/test_provider_ogr_sqlite.py index de54b298332..7b972aa6946 100644 --- a/tests/src/python/test_provider_ogr_sqlite.py +++ b/tests/src/python/test_provider_ogr_sqlite.py @@ -130,7 +130,6 @@ class TestPyQgsOGRProviderSqlite(unittest.TestCase): got = [(f.attribute('fid'), f.attribute('intfield')) for f in vl.dataProvider().getFeatures(QgsFeatureRequest().setFilterExpression("fid = 12"))] self.assertEqual(got, [(12, 123)]) - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) def testNotNullConstraint(self): """ test detection of not null constraint on OGR layer """ @@ -161,7 +160,6 @@ class TestPyQgsOGRProviderSqlite(unittest.TestCase): self.assertTrue(fields.at(2).constraints().constraints() & QgsFieldConstraints.ConstraintNotNull) self.assertEqual(fields.at(2).constraints().constraintOrigin(QgsFieldConstraints.ConstraintNotNull), QgsFieldConstraints.ConstraintOriginProvider) - @unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) def testDefaultValues(self): """ test detection of defaults on OGR layer """ diff --git a/tests/src/python/test_provider_tabfile.py b/tests/src/python/test_provider_tabfile.py index edc51ba9c5c..2308f86c5c3 100644 --- a/tests/src/python/test_provider_tabfile.py +++ b/tests/src/python/test_provider_tabfile.py @@ -68,8 +68,6 @@ class TestPyQgsTabfileProvider(unittest.TestCase): assert isinstance(f.attributes()[datetime_idx], QDateTime) self.assertEqual(f.attributes()[datetime_idx], QDateTime(QDate(2004, 5, 3), QTime(13, 41, 00))) - # This test fails with GDAL version < 2 because tab update is new in GDAL 2.0 - @unittest.expectedFailure(int(osgeo.gdal.VersionInfo()[:1]) < 2) def testUpdateMode(self): """ Test that on-the-fly re-opening in update/read-only mode works """ @@ -90,7 +88,6 @@ class TestPyQgsTabfileProvider(unittest.TestCase): self.assertEqual(vl.dataProvider().property("_debug_open_mode"), "read-only") self.assertTrue(vl.dataProvider().isValid()) - @unittest.expectedFailure(int(osgeo.gdal.VersionInfo()[:1]) < 2) def testInteger64WriteTabfile(self): """Check writing Integer64 fields to an MapInfo tabfile (which does not support that type).""" diff --git a/tests/src/python/test_qgsserver.py b/tests/src/python/test_qgsserver.py index 60e8898a3b4..5b706d6c2f0 100644 --- a/tests/src/python/test_qgsserver.py +++ b/tests/src/python/test_qgsserver.py @@ -225,10 +225,6 @@ class TestQgsServer(unittest.TestCase): response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response) expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected) - # for older GDAL versions (<2.0), id field will be integer type - if int(osgeo.gdal.VersionInfo()[:1]) < 2: - expected = expected.replace(b'typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong"', b'typeName="Integer" precision="0" length="10" editType="TextEdit" type="int"') - self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8'))) def test_project_wms(self): @@ -317,10 +313,6 @@ class TestQgsServer(unittest.TestCase): response = re.sub(RE_STRIP_UNCHECKABLE, b'', response) expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected) - # for older GDAL versions (<2.0), id field will be integer type - if int(osgeo.gdal.VersionInfo()[:1]) < 2: - expected = expected.replace(b'', b'') - self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8'))) def test_project_wfs(self): diff --git a/tests/src/python/test_qgsvectorfilewriter.py b/tests/src/python/test_qgsvectorfilewriter.py index c07260801d8..787b732b087 100644 --- a/tests/src/python/test_qgsvectorfilewriter.py +++ b/tests/src/python/test_qgsvectorfilewriter.py @@ -421,7 +421,6 @@ class TestQgsVectorLayer(unittest.TestCase): self.assertEqual(f['nonconv'], 1) self.assertEqual(f['conv_attr'], 'converted_val') - @unittest.expectedFailure(int(osgeo.gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0)) def testInteger64WriteTabfile(self): """Check writing Integer64 fields to an MapInfo tabfile (which does not support that type).""" ml = QgsVectorLayer(