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

This commit is contained in:
Nyall Dawson 2017-01-03 15:10:28 +10:00
parent f59acade4b
commit b0bc763475
41 changed files with 18 additions and 512 deletions

View File

@ -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}

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -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 );

View File

@ -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
{

View File

@ -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 )

View File

@ -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

View File

@ -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 );

View File

@ -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;

View File

@ -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\", "

View File

@ -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 )

View File

@ -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 )

View File

@ -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;

View File

@ -50,11 +50,7 @@
#include <cpl_conv.h>
#include <gdal.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
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<QString> 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<QString, QgsVectorFileWriter::MetaData> 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,

View File

@ -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;

View File

@ -42,14 +42,12 @@
#include <cpl_error.h>
#include <cpl_string.h>
#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 )

View File

@ -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;

View File

@ -20,11 +20,7 @@
#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
QgsRasterChangeCoords::QgsRasterChangeCoords()
: mHasCrs( false )

View File

@ -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!<br>"
"Only the table name will be used.<br>"
"It can result in wrong input if more tables of the same name<br>"
"are present in the database." ) );
}
}
#endif //GDAL_VERSION_NUM
list.push_back( opt );
}

View File

@ -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<QgsRasterPyramid> & 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<QPair<QString, QString> > *pyramidResamplingMethods()
methods.append( QPair<QString, QString>( QStringLiteral( "AVERAGE" ), QObject::tr( "Average" ) ) );
methods.append( QPair<QString, QString>( QStringLiteral( "GAUSS" ), QObject::tr( "Gauss" ) ) );
methods.append( QPair<QString, QString>( QStringLiteral( "CUBIC" ), QObject::tr( "Cubic" ) ) );
#if GDAL_VERSION_MAJOR >= 2
methods.append( QPair<QString, QString>( "CUBICSPLINE", QObject::tr( "Cubic Spline" ) ) );
methods.append( QPair<QString, QString>( "LANCZOS", QObject::tr( "Lanczos" ) ) );
#endif
methods.append( QPair<QString, QString>( QStringLiteral( "MODE" ), QObject::tr( "Mode" ) ) );
methods.append( QPair<QString, QString>( QStringLiteral( "NONE" ), QObject::tr( "None" ) ) );
}

View File

@ -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;
}

View File

@ -26,13 +26,8 @@
#define CPL_SUPRESS_CPLUSPLUS
#include <gdal.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
/**
\brief Base clasee for GDAL and WCS providers.

View File

@ -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<NativeType> 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<OGRwkbGeometryType, int>::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<const char*> 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<GIntBig>( id ) );
#else
OGR_F_SetFID( feature, static_cast<long>( 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<QgsField> &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<QgsField> &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<int> 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<QVariant> &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<QVariant> &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 );
}

View File

@ -32,15 +32,9 @@ class QgsOgrFeatureIterator;
#include <ogr_api.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 QgsOgrProvider

View File

@ -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")

View File

@ -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;

View File

@ -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() );

View File

@ -49,11 +49,7 @@
#include <QTemporaryFile>
#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<QString, QString>& parameters )
: QgsWmsConfigParser()

View File

@ -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 );

View File

@ -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
{

View File

@ -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 )
{

View File

@ -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)

View File

@ -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')

View File

@ -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')

View File

@ -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 """

View File

@ -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)."""

View File

@ -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'<element type="long" name="id"/>', b'<element type="integer" name="id"/>')
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):

View File

@ -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(