-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7984 from rouault/fix_19483
Raster: do not list RasterLite2 as a supported output format, and use a helper for every call site (fixes #19483)
- Loading branch information
Showing
12 changed files
with
175 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*************************************************************************** | ||
qgsgdalutils.cpp | ||
---------------- | ||
begin : September 2018 | ||
copyright : (C) 2018 Even Rouault | ||
email : even.rouault at spatialys.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsgdalutils.h" | ||
|
||
#define CPL_SUPRESS_CPLUSPLUS //#spellok | ||
#include "gdal.h" | ||
#include "cpl_string.h" | ||
|
||
#include <QString> | ||
|
||
bool QgsGdalUtils::supportsRasterCreate( GDALDriverH driver ) | ||
{ | ||
QString driverShortName = GDALGetDriverShortName( driver ); | ||
if ( driverShortName == QLatin1String( "SQLite" ) ) | ||
{ | ||
// it supports Create() but only for vector side | ||
return false; | ||
} | ||
char **driverMetadata = GDALGetMetadata( driver, nullptr ); | ||
return CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) && | ||
CSLFetchBoolean( driverMetadata, GDAL_DCAP_RASTER, false ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
qgsgdalutils.h | ||
-------------- | ||
begin : September 2018 | ||
copyright : (C) 2018 Even Rouault | ||
email : even.rouault at spatialys.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSGDALUTILS_H | ||
#define QGSGDALUTILS_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis_core.h" | ||
#include <gdal.h> | ||
|
||
/** | ||
* \ingroup core | ||
* \class QgsGdalUtils | ||
* \brief Utilities for working with GDAL | ||
* | ||
* \note not available in Python bindings | ||
* \since QGIS 3.4 | ||
*/ | ||
class CORE_EXPORT QgsGdalUtils | ||
{ | ||
public: | ||
|
||
/** | ||
* Reads whether a driver supports GDALCreate() for raster purposes. | ||
* \param driver GDAL driver | ||
* \returns true if a driver supports GDALCreate() for raster purposes. | ||
*/ | ||
static bool supportsRasterCreate( GDALDriverH driver ); | ||
}; | ||
|
||
#endif // QGSGDALUTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/*************************************************************************** | ||
testqgsgdalutils.cpp | ||
-------------------- | ||
begin : September 2018 | ||
copyright : (C) 2018 Even Rouault | ||
email : even.rouault at spatialys.com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgstest.h" | ||
#include <QObject> | ||
#include <QString> | ||
#include <QStringList> | ||
#include <QSettings> | ||
|
||
#include <gdal.h> | ||
|
||
#include "qgsgdalutils.h" | ||
#include "qgsapplication.h" | ||
|
||
class TestQgsGdalUtils: public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
void initTestCase();// will be called before the first testfunction is executed. | ||
void cleanupTestCase();// will be called after the last testfunction was executed. | ||
void init();// will be called before each testfunction is executed. | ||
void cleanup();// will be called after every testfunction. | ||
void supportsRasterCreate(); | ||
|
||
private: | ||
}; | ||
|
||
void TestQgsGdalUtils::initTestCase() | ||
{ | ||
QgsApplication::init(); | ||
QgsApplication::initQgis(); | ||
GDALAllRegister(); | ||
} | ||
|
||
void TestQgsGdalUtils::cleanupTestCase() | ||
{ | ||
QgsApplication::exitQgis(); | ||
} | ||
|
||
void TestQgsGdalUtils::init() | ||
{ | ||
|
||
} | ||
|
||
void TestQgsGdalUtils::cleanup() | ||
{ | ||
|
||
} | ||
|
||
void TestQgsGdalUtils::supportsRasterCreate() | ||
{ | ||
QVERIFY( QgsGdalUtils::supportsRasterCreate( GDALGetDriverByName( "GTiff" ) ) ); | ||
QVERIFY( QgsGdalUtils::supportsRasterCreate( GDALGetDriverByName( "GPKG" ) ) ); | ||
|
||
// special case | ||
QVERIFY( !QgsGdalUtils::supportsRasterCreate( GDALGetDriverByName( "SQLite" ) ) ); | ||
|
||
// create-only | ||
QVERIFY( !QgsGdalUtils::supportsRasterCreate( GDALGetDriverByName( "DTED" ) ) ); | ||
|
||
// vector-only | ||
QVERIFY( !QgsGdalUtils::supportsRasterCreate( GDALGetDriverByName( "ESRI Shapefile" ) ) ); | ||
} | ||
|
||
QGSTEST_MAIN( TestQgsGdalUtils ) | ||
#include "testqgsgdalutils.moc" |