Skip to content

Commit c517d80

Browse files
committedAug 30, 2022
Bump minimum GDAL version to 3.2
1 parent 01905bf commit c517d80

File tree

8 files changed

+6
-377
lines changed

8 files changed

+6
-377
lines changed
 

‎INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Required build dependencies:
105105
* Sqlite3 >= 3.0.0
106106
* SpatiaLite >= 4.2.0
107107
* libspatialindex
108-
* GDAL/OGR >= 3.0.0
108+
* GDAL/OGR >= 3.2.0
109109
* Qwt >= 5.0 & (< 6.1 with internal QwtPolar)
110110
* expat >= 1.95
111111
* QScintilla2

‎cmake/FindGDAL.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ ELSE(WIN32)
6464
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GDAL_VERSION_MAJOR "${GDAL_VERSION}")
6565
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GDAL_VERSION_MINOR "${GDAL_VERSION}")
6666
IF (GDAL_VERSION_MAJOR LESS 3)
67-
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 3.0 or higher.")
67+
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 3.2 or higher.")
6868
ENDIF (GDAL_VERSION_MAJOR LESS 3)
69-
#IF ( (GDAL_VERSION_MAJOR EQUAL 2) AND (GDAL_VERSION_MINOR LESS 1) )
70-
# MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 2.1 or higher.")
71-
#ENDIF( (GDAL_VERSION_MAJOR EQUAL 2) AND (GDAL_VERSION_MINOR LESS 1) )
69+
IF ( (GDAL_VERSION_MAJOR EQUAL 3) AND (GDAL_VERSION_MINOR LESS 2) )
70+
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 3.2 or higher.")
71+
ENDIF( (GDAL_VERSION_MAJOR EQUAL 3) AND (GDAL_VERSION_MINOR LESS 2) )
7272

7373
ENDIF (GDAL_LIBRARY)
7474
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)

‎src/core/providers/ogr/qgsogrprovider.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,11 @@ void QgsOgrProvider::loadFields()
773773
width, prec, QString(), varSubType
774774
);
775775

776-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,2,0)
777776
const QString alias = textEncoding()->toUnicode( OGR_Fld_GetAlternativeNameRef( fldDef ) );
778777
if ( !alias.isEmpty() )
779778
{
780779
newField.setAlias( alias );
781780
}
782-
#endif
783781

784782
// check if field is nullable
785783
bool nullable = OGR_Fld_IsNullable( fldDef );
@@ -3563,14 +3561,12 @@ void QgsOgrProvider::open( OpenMode mode )
35633561
}
35643562

35653563
QStringList options( mOpenOptions );
3566-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0)
35673564
// assume trusted data to get more speed
35683565
if ( mGDALDriverName == QLatin1String( "FlatGeobuf" ) &&
35693566
!options.contains( QStringLiteral( "VERIFY_BUFFERS=YES" ) ) )
35703567
{
35713568
options << QStringLiteral( "VERIFY_BUFFERS=NO" );
35723569
}
3573-
#endif
35743570

35753571
// try to open read-only
35763572
if ( !mLayerName.isNull() )
@@ -3598,13 +3594,9 @@ void QgsOgrProvider::open( OpenMode mode )
35983594
{
35993595
// determine encoding from shapefile cpg or LDID information, if possible
36003596
QString shpEncoding;
3601-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0)
36023597
shpEncoding = mOgrLayer->GetMetadataItem( QStringLiteral( "ENCODING_FROM_CPG" ), QStringLiteral( "SHAPEFILE" ) );
36033598
if ( shpEncoding.isEmpty() )
36043599
shpEncoding = mOgrLayer->GetMetadataItem( QStringLiteral( "ENCODING_FROM_LDID" ), QStringLiteral( "SHAPEFILE" ) );
3605-
#else
3606-
shpEncoding = QgsOgrUtils::readShapefileEncoding( mFilePath );
3607-
#endif
36083600

36093601
if ( !shpEncoding.isEmpty() )
36103602
setEncoding( shpEncoding );

‎src/core/providers/ogr/qgsogrproviderutils.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,12 @@ QString createFilters( const QString &type )
269269
if ( !sDirectoryExtensions.contains( QStringLiteral( "gdb" ) ) )
270270
sDirectoryExtensions << QStringLiteral( "gdb" );
271271
}
272-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0)
273272
else if ( driverName.startsWith( QLatin1String( "FlatGeobuf" ) ) )
274273
{
275274
sProtocolDrivers += QLatin1String( "FlatGeobuf;" );
276275
sFileFilters += createFileFilter_( QObject::tr( "FlatGeobuf" ), QStringLiteral( "*.fgb" ) );
277276
sExtensions << QStringLiteral( "fgb" );
278277
}
279-
#endif
280278
else if ( driverName.startsWith( QLatin1String( "PGeo" ) ) )
281279
{
282280
sDatabaseDrivers += QObject::tr( "ESRI Personal GeoDatabase" ) + ",PGeo;";
@@ -1286,18 +1284,6 @@ void QgsOgrProviderUtils::GDALCloseWrapper( GDALDatasetH hDS )
12861284
GDALClose( hDS );
12871285
}
12881286
}
1289-
1290-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0) && GDAL_VERSION_NUM <= GDAL_COMPUTE_VERSION(3,1,3)
1291-
else if ( mGDALDriverName == QLatin1String( "XLSX" ) ||
1292-
mGDALDriverName == QLatin1String( "ODS" ) )
1293-
{
1294-
// Workaround bug in GDAL 3.1.0 to 3.1.3 that creates XLSX and ODS files incompatible with LibreOffice due to use of ZIP64
1295-
CPLSetThreadLocalConfigOption( "CPL_CREATE_ZIP64", "NO" );
1296-
GDALClose( hDS );
1297-
CPLSetThreadLocalConfigOption( "CPL_CREATE_ZIP64", nullptr );
1298-
}
1299-
#endif
1300-
13011287
else
13021288
{
13031289
GDALClose( hDS );
@@ -3088,24 +3074,7 @@ OGRErr QgsOgrLayer::SyncToDisk()
30883074
{
30893075
QMutexLocker locker( &ds->mutex );
30903076

3091-
OGRErr eErr;
3092-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0) && GDAL_VERSION_NUM <= GDAL_COMPUTE_VERSION(3,1,3)
3093-
// Workaround bug in GDAL 3.1.0 to 3.1.3 that creates XLSX and ODS files incompatible with LibreOffice due to use of ZIP64
3094-
QString drvName = GDALGetDriverShortName( GDALGetDatasetDriver( ds->hDS ) );
3095-
if ( drvName == QLatin1String( "XLSX" ) ||
3096-
drvName == QLatin1String( "ODS" ) )
3097-
{
3098-
CPLSetThreadLocalConfigOption( "CPL_CREATE_ZIP64", "NO" );
3099-
eErr = OGR_L_SyncToDisk( hLayer );
3100-
CPLSetThreadLocalConfigOption( "CPL_CREATE_ZIP64", nullptr );
3101-
}
3102-
else
3103-
#endif
3104-
{
3105-
eErr = OGR_L_SyncToDisk( hLayer );
3106-
}
3107-
3108-
return eErr;
3077+
return OGR_L_SyncToDisk( hLayer );
31093078
}
31103079

31113080
void QgsOgrLayer::ExecuteSQLNoReturn( const QByteArray &sql )

‎src/core/qgscplhttpfetchoverrider.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,6 @@
2020
#include "cpl_http.h"
2121
#include "gdal.h"
2222

23-
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,2,0)
24-
25-
QgsCPLHTTPFetchOverrider::QgsCPLHTTPFetchOverrider( const QString &authCfg, QgsFeedback *feedback )
26-
{
27-
Q_UNUSED( authCfg );
28-
Q_UNUSED( feedback );
29-
Q_UNUSED( mAuthCfg );
30-
Q_UNUSED( mFeedback );
31-
}
32-
33-
QgsCPLHTTPFetchOverrider::~QgsCPLHTTPFetchOverrider()
34-
{
35-
}
36-
37-
#else
38-
3923
QgsCPLHTTPFetchOverrider::QgsCPLHTTPFetchOverrider( const QString &authCfg, QgsFeedback *feedback ):
4024
mAuthCfg( authCfg ),
4125
mFeedback( feedback )
@@ -200,8 +184,6 @@ CPLHTTPResult *QgsCPLHTTPFetchOverrider::callback( const char *pszURL,
200184
return psResult;
201185
}
202186

203-
#endif
204-
205187
void QgsCPLHTTPFetchOverrider::setAttribute( QNetworkRequest::Attribute code, const QVariant &value )
206188
{
207189
mAttributes[code] = value;

‎src/core/qgsgdalutils.cpp

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -328,148 +328,6 @@ QString QgsGdalUtils::validateCreationOptionsFormat( const QStringList &createOp
328328
return QString();
329329
}
330330

331-
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(3,2,0)
332-
333-
GDALDatasetH GDALAutoCreateWarpedVRTEx( GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstWKT, GDALResampleAlg eResampleAlg,
334-
double dfMaxError, const GDALWarpOptions *psOptionsIn, char **papszTransformerOptions )
335-
{
336-
VALIDATE_POINTER1( hSrcDS, "GDALAutoCreateWarpedVRT", nullptr );
337-
338-
/* -------------------------------------------------------------------- */
339-
/* Populate the warp options. */
340-
/* -------------------------------------------------------------------- */
341-
GDALWarpOptions *psWO = nullptr;
342-
if ( psOptionsIn != nullptr )
343-
psWO = GDALCloneWarpOptions( psOptionsIn );
344-
else
345-
psWO = GDALCreateWarpOptions();
346-
347-
psWO->eResampleAlg = eResampleAlg;
348-
349-
psWO->hSrcDS = hSrcDS;
350-
351-
GDALWarpInitDefaultBandMapping( psWO, GDALGetRasterCount( hSrcDS ) );
352-
353-
/* -------------------------------------------------------------------- */
354-
/* Setup no data values */
355-
/* -------------------------------------------------------------------- */
356-
for ( int i = 0; i < psWO->nBandCount; i++ )
357-
{
358-
GDALRasterBandH rasterBand = GDALGetRasterBand( psWO->hSrcDS, psWO->panSrcBands[i] );
359-
360-
int hasNoDataValue;
361-
double noDataValue = GDALGetRasterNoDataValue( rasterBand, &hasNoDataValue );
362-
363-
if ( hasNoDataValue )
364-
{
365-
// Check if the nodata value is out of range
366-
int bClamped = FALSE;
367-
int bRounded = FALSE;
368-
CPL_IGNORE_RET_VAL(
369-
GDALAdjustValueToDataType( GDALGetRasterDataType( rasterBand ),
370-
noDataValue, &bClamped, &bRounded ) );
371-
if ( !bClamped )
372-
{
373-
GDALWarpInitNoDataReal( psWO, -1e10 );
374-
375-
psWO->padfSrcNoDataReal[i] = noDataValue;
376-
psWO->padfDstNoDataReal[i] = noDataValue;
377-
}
378-
}
379-
}
380-
381-
if ( psWO->padfDstNoDataReal != nullptr )
382-
{
383-
if ( CSLFetchNameValue( psWO->papszWarpOptions, "INIT_DEST" ) == nullptr )
384-
{
385-
psWO->papszWarpOptions =
386-
CSLSetNameValue( psWO->papszWarpOptions, "INIT_DEST", "NO_DATA" );
387-
}
388-
}
389-
390-
/* -------------------------------------------------------------------- */
391-
/* Create the transformer. */
392-
/* -------------------------------------------------------------------- */
393-
psWO->pfnTransformer = GDALGenImgProjTransform;
394-
395-
char **papszOptions = nullptr;
396-
if ( pszSrcWKT != nullptr )
397-
papszOptions = CSLSetNameValue( papszOptions, "SRC_SRS", pszSrcWKT );
398-
if ( pszDstWKT != nullptr )
399-
papszOptions = CSLSetNameValue( papszOptions, "DST_SRS", pszDstWKT );
400-
papszOptions = CSLMerge( papszOptions, papszTransformerOptions );
401-
psWO->pTransformerArg =
402-
GDALCreateGenImgProjTransformer2( psWO->hSrcDS, nullptr,
403-
papszOptions );
404-
CSLDestroy( papszOptions );
405-
406-
if ( psWO->pTransformerArg == nullptr )
407-
{
408-
GDALDestroyWarpOptions( psWO );
409-
return nullptr;
410-
}
411-
412-
/* -------------------------------------------------------------------- */
413-
/* Figure out the desired output bounds and resolution. */
414-
/* -------------------------------------------------------------------- */
415-
double adfDstGeoTransform[6] = { 0.0 };
416-
int nDstPixels = 0;
417-
int nDstLines = 0;
418-
CPLErr eErr =
419-
GDALSuggestedWarpOutput( hSrcDS, psWO->pfnTransformer,
420-
psWO->pTransformerArg,
421-
adfDstGeoTransform, &nDstPixels, &nDstLines );
422-
if ( eErr != CE_None )
423-
{
424-
GDALDestroyTransformer( psWO->pTransformerArg );
425-
GDALDestroyWarpOptions( psWO );
426-
return nullptr;
427-
}
428-
429-
/* -------------------------------------------------------------------- */
430-
/* Update the transformer to include an output geotransform */
431-
/* back to pixel/line coordinates. */
432-
/* */
433-
/* -------------------------------------------------------------------- */
434-
GDALSetGenImgProjTransformerDstGeoTransform(
435-
psWO->pTransformerArg, adfDstGeoTransform );
436-
437-
/* -------------------------------------------------------------------- */
438-
/* Do we want to apply an approximating transformation? */
439-
/* -------------------------------------------------------------------- */
440-
if ( dfMaxError > 0.0 )
441-
{
442-
psWO->pTransformerArg =
443-
GDALCreateApproxTransformer( psWO->pfnTransformer,
444-
psWO->pTransformerArg,
445-
dfMaxError );
446-
psWO->pfnTransformer = GDALApproxTransform;
447-
GDALApproxTransformerOwnsSubtransformer( psWO->pTransformerArg, TRUE );
448-
}
449-
450-
/* -------------------------------------------------------------------- */
451-
/* Create the VRT file. */
452-
/* -------------------------------------------------------------------- */
453-
GDALDatasetH hDstDS
454-
= GDALCreateWarpedVRT( hSrcDS, nDstPixels, nDstLines,
455-
adfDstGeoTransform, psWO );
456-
457-
GDALDestroyWarpOptions( psWO );
458-
459-
if ( pszDstWKT != nullptr )
460-
GDALSetProjection( hDstDS, pszDstWKT );
461-
else if ( pszSrcWKT != nullptr )
462-
GDALSetProjection( hDstDS, pszSrcWKT );
463-
else if ( GDALGetGCPCount( hSrcDS ) > 0 )
464-
GDALSetProjection( hDstDS, GDALGetGCPProjection( hSrcDS ) );
465-
else
466-
GDALSetProjection( hDstDS, GDALGetProjectionRef( hSrcDS ) );
467-
468-
return hDstDS;
469-
}
470-
#endif
471-
472-
473331
GDALDatasetH QgsGdalUtils::rpcAwareAutoCreateWarpedVrt(
474332
GDALDatasetH hSrcDS,
475333
const char *pszSrcWKT,

0 commit comments

Comments
 (0)
Please sign in to comment.