QGIS API Documentation 3.41.0-Master (181b2f43d8e)
Loading...
Searching...
No Matches
qgsgdalutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgdalutils.h
3 --------------
4 begin : September 2018
5 copyright : (C) 2018 Even Rouault
6 email : even.rouault at spatialys.com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSGDALUTILS_H
17#define QGSGDALUTILS_H
18
19#define SIP_NO_FILE
20
21#include "qgis_core.h"
22#include <gdal.h>
23
24#include "qgsogrutils.h"
26
35class CORE_EXPORT QgsGdalOption
36{
37 public:
38
42 enum class Type
43 {
44 Invalid,
45 Select,
46 Boolean,
47 Text,
48 Int,
49 Double,
50 };
51
53 QString name;
54
56 Type type = Type::Invalid;
57
59 QString description;
60
62 QStringList options;
63
65 QVariant defaultValue;
66
68 QVariant minimum;
69
71 QVariant maximum;
72
74 QString scope;
75
82 static QgsGdalOption fromXmlNode( const CPLXMLNode *node );
83
87 static QList< QgsGdalOption > optionsFromXml( const CPLXMLNode *node );
88};
89
90
99class CORE_EXPORT QgsGdalUtils
100{
101 public:
102
108 static bool supportsRasterCreate( GDALDriverH driver );
109
114 static gdal::dataset_unique_ptr createSingleBandMemoryDataset( GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
115
120 static gdal::dataset_unique_ptr createMultiBandMemoryDataset( GDALDataType dataType, int bands, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
121
126 static gdal::dataset_unique_ptr createSingleBandTiffDataset( const QString &filename, GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
127
138 static bool resampleSingleBandRaster( GDALDatasetH hSrcDS, GDALDatasetH hDstDS, GDALResampleAlg resampleAlg, const char *pszCoordinateOperation );
139
151 static bool resampleSingleBandRaster( GDALDatasetH hSrcDS,
152 GDALDatasetH hDstDS,
153 GDALResampleAlg resampleAlg,
154 const QgsCoordinateReferenceSystem &sourceCrs,
155 const QgsCoordinateReferenceSystem &destinationCrs );
156
161 static QImage resampleImage( const QImage &image, QSize outputSize, GDALRIOResampleAlg resampleAlg );
162
167 static QString helpCreationOptionsFormat( const QString &format );
168
173 static QString validateCreationOptionsFormat( const QStringList &createOptions, const QString &format );
174
179 static char **papszFromStringList( const QStringList &list );
180
188 static gdal::dataset_unique_ptr imageToMemoryDataset( const QImage &image );
189
197 static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset( int pixelWidth, int pixelHeight, const QgsRectangle &extent, void *block, GDALDataType dataType );
198
206 static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset( const QgsRectangle &extent, QgsRasterBlock *block );
207
216 static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset( double rotation, const QgsPointXY &origin, double gridXSize, double gridYSize, QgsRasterBlock *block );
217
226 static GDALDatasetH rpcAwareAutoCreateWarpedVrt(
227 GDALDatasetH hSrcDS,
228 const char *pszSrcWKT,
229 const char *pszDstWKT,
230 GDALResampleAlg eResampleAlg,
231 double dfMaxError,
232 const GDALWarpOptions *psOptionsIn );
233
242 static void *rpcAwareCreateTransformer( GDALDatasetH hSrcDS, GDALDatasetH hDstDS = nullptr, char **papszOptions = nullptr );
243
249 static GDALDataType gdalDataTypeFromQgisDataType( Qgis::DataType dataType );
250
256 static GDALResampleAlg gdalResamplingAlgorithm( QgsRasterDataProvider::ResamplingMethod method );
257
258#ifndef QT_NO_NETWORKPROXY
260 static void setupProxy();
261#endif
262
277 static bool pathIsCheapToOpen( const QString &path, int smallFileSizeLimit = 50000 );
278
285 static QStringList multiLayerFileExtensions();
286
293 static QString vsiPrefixForPath( const QString &path );
294
300 static QStringList vsiArchivePrefixes();
301
308 {
310 QString identifier;
311
313 QString name;
314 };
315
321 static QList< VsiNetworkFileSystemDetails > vsiNetworkFileSystems();
322
328 static bool isVsiArchivePrefix( const QString &prefix );
329
335 static QStringList vsiArchiveFileExtensions();
336
342 static bool isVsiArchiveFileExtension( const QString &extension );
343
349 static Qgis::VsiHandlerType vsiHandlerType( const QString &prefix );
350
361 static bool applyVsiCredentialOptions( const QString &prefix, const QString &path, const QVariantMap &options );
362
369 static bool vrtMatchesLayerType( const QString &vrtPath, Qgis::LayerType type );
370
376 static QString gdalDocumentationUrlForDriver( GDALDriverH hDriver );
377
378 friend class TestQgsGdalUtils;
379};
380
381#endif // QGSGDALUTILS_H
VsiHandlerType
GDAL VSI handler types.
Definition qgis.h:5387
DataType
Raster data types.
Definition qgis.h:351
LayerType
Types of layers that can be added to a map.
Definition qgis.h:169
This class represents a coordinate reference system (CRS).
Encapsulates the definition of a GDAL configuration option.
QVariant defaultValue
Default value.
QVariant maximum
Maximum acceptable value.
QString name
Option name.
QStringList options
Available choices, for Select options.
QVariant minimum
Minimum acceptable value.
Type
Option types.
QString scope
Option scope.
QString description
Option description.
Utilities for working with GDAL.
A class to represent a 2D point.
Definition qgspointxy.h:60
Raster data container.
ResamplingMethod
Resampling method for provider-level resampling.
A rectangle specified with double values.
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
void * GDALDatasetH
const QgsCoordinateReferenceSystem & crs
Encapsulates details for a GDAL VSI network file system.
QString name
Translated, user-friendly name.
QString identifier
VSI handler identifier, eg "vsis3".