QGIS API Documentation 3.41.0-Master (af5edcb665c)
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"
25
26class QgsRasterBlock;
27
36class CORE_EXPORT QgsGdalOption
37{
38 public:
39
43 enum class Type
44 {
45 Invalid,
46 Select,
47 Boolean,
48 Text,
49 Int,
50 Double,
51 };
52
54 QString name;
55
57 Type type = Type::Invalid;
58
60 QString description;
61
63 QStringList options;
64
66 QVariant defaultValue;
67
69 QVariant minimum;
70
72 QVariant maximum;
73
75 QString scope;
76
83 static QgsGdalOption fromXmlNode( const CPLXMLNode *node );
84
88 static QList< QgsGdalOption > optionsFromXml( const CPLXMLNode *node );
89};
90
91
100class CORE_EXPORT QgsGdalUtils
101{
102 public:
103
109 static bool supportsRasterCreate( GDALDriverH driver );
110
115 static gdal::dataset_unique_ptr createSingleBandMemoryDataset( GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
116
121 static gdal::dataset_unique_ptr createMultiBandMemoryDataset( GDALDataType dataType, int bands, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
122
127 static gdal::dataset_unique_ptr createSingleBandTiffDataset( const QString &filename, GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
128
139 static bool resampleSingleBandRaster( GDALDatasetH hSrcDS, GDALDatasetH hDstDS, GDALResampleAlg resampleAlg, const char *pszCoordinateOperation );
140
152 static bool resampleSingleBandRaster( GDALDatasetH hSrcDS,
153 GDALDatasetH hDstDS,
154 GDALResampleAlg resampleAlg,
155 const QgsCoordinateReferenceSystem &sourceCrs,
156 const QgsCoordinateReferenceSystem &destinationCrs );
157
162 static QImage resampleImage( const QImage &image, QSize outputSize, GDALRIOResampleAlg resampleAlg );
163
168 static QString helpCreationOptionsFormat( const QString &format );
169
174 static QString validateCreationOptionsFormat( const QStringList &createOptions, const QString &format );
175
180 static char **papszFromStringList( const QStringList &list );
181
189 static gdal::dataset_unique_ptr imageToMemoryDataset( const QImage &image );
190
198 static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset( int pixelWidth, int pixelHeight, const QgsRectangle &extent, void *block, GDALDataType dataType );
199
207 static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset( const QgsRectangle &extent, QgsRasterBlock *block );
208
217 static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset( double rotation, const QgsPointXY &origin, double gridXSize, double gridYSize, QgsRasterBlock *block );
218
227 static GDALDatasetH rpcAwareAutoCreateWarpedVrt(
228 GDALDatasetH hSrcDS,
229 const char *pszSrcWKT,
230 const char *pszDstWKT,
231 GDALResampleAlg eResampleAlg,
232 double dfMaxError,
233 const GDALWarpOptions *psOptionsIn );
234
243 static void *rpcAwareCreateTransformer( GDALDatasetH hSrcDS, GDALDatasetH hDstDS = nullptr, char **papszOptions = nullptr );
244
250 static GDALDataType gdalDataTypeFromQgisDataType( Qgis::DataType dataType );
251
257 static GDALResampleAlg gdalResamplingAlgorithm( Qgis::RasterResamplingMethod method );
258
259#ifndef QT_NO_NETWORKPROXY
261 static void setupProxy();
262#endif
263
278 static bool pathIsCheapToOpen( const QString &path, int smallFileSizeLimit = 50000 );
279
286 static QStringList multiLayerFileExtensions();
287
294 static QString vsiPrefixForPath( const QString &path );
295
301 static QStringList vsiArchivePrefixes();
302
309 {
311 QString identifier;
312
314 QString name;
315 };
316
322 static QList< VsiNetworkFileSystemDetails > vsiNetworkFileSystems();
323
329 static bool isVsiArchivePrefix( const QString &prefix );
330
336 static QStringList vsiArchiveFileExtensions();
337
343 static bool isVsiArchiveFileExtension( const QString &extension );
344
350 static Qgis::VsiHandlerType vsiHandlerType( const QString &prefix );
351
362 static bool applyVsiCredentialOptions( const QString &prefix, const QString &path, const QVariantMap &options );
363
370 static bool vrtMatchesLayerType( const QString &vrtPath, Qgis::LayerType type );
371
377 static QString gdalDocumentationUrlForDriver( GDALDriverH hDriver );
378
379 friend class TestQgsGdalUtils;
380};
381
382#endif // QGSGDALUTILS_H
VsiHandlerType
GDAL VSI handler types.
Definition qgis.h:5405
RasterResamplingMethod
Resampling method for raster provider-level resampling.
Definition qgis.h:1394
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.
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".