/
qgsgdalutils.h
137 lines (117 loc) · 5.06 KB
/
qgsgdalutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************************
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>
#include "qgsogrutils.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 );
/**
* Creates a new single band memory dataset with given parameters
* \since QGIS 3.8
*/
static gdal::dataset_unique_ptr createSingleBandMemoryDataset( GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
/**
* Creates a new multi band memory dataset with given parameters
* \since QGIS 3.12
*/
static gdal::dataset_unique_ptr createMultiBandMemoryDataset( GDALDataType dataType, int bands, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
/**
* Creates a new single band TIFF dataset with given parameters
* \since QGIS 3.8
*/
static gdal::dataset_unique_ptr createSingleBandTiffDataset( const QString &filename, GDALDataType dataType, const QgsRectangle &extent, int width, int height, const QgsCoordinateReferenceSystem &crs );
/**
* Resamples a single band raster to the destination dataset with different resolution (and possibly with different CRS).
* Ideally the source dataset should cover the whole area or the destination dataset.
* \since QGIS 3.8
*/
static void resampleSingleBandRaster( GDALDatasetH hSrcDS, GDALDatasetH hDstDS, GDALResampleAlg resampleAlg );
/**
* Resamples a QImage \a image using GDAL resampler.
* \since QGIS 3.12
*/
static QImage resampleImage( const QImage &image, QSize outputSize, GDALRIOResampleAlg resampleAlg );
/**
* Gets creation options metadata for a given format
* \since QGIS 3.10
*/
static QString helpCreationOptionsFormat( const QString &format );
/**
* Validates creation options for a given format, regardless of layer.
* \since QGIS 3.10
*/
static QString validateCreationOptionsFormat( const QStringList &createOptions, const QString &format );
/**
* Helper function
* \since QGIS 3.10
*/
static char **papszFromStringList( const QStringList &list );
/**
* Converts an \a image to a GDAL memory dataset by borrowing image data.
*
* \warning The \a image must exist unchanged for the lifetime of the returned gdal dataset!
*
* \since QGIS 3.12
*/
static gdal::dataset_unique_ptr imageToMemoryDataset( const QImage &image );
/**
* This is a copy of GDALAutoCreateWarpedVRT optimized for imagery using RPC georeferencing
* that also sets RPC_HEIGHT in GDALCreateGenImgProjTransformer2 based on HEIGHT_OFF.
* By default GDAL would assume that the imagery has zero elevation - if that is not the case,
* the image would not be shown in the correct location.
*
* \since QGIS 3.14
*/
static GDALDatasetH rpcAwareAutoCreateWarpedVrt(
GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstWKT,
GDALResampleAlg eResampleAlg,
double dfMaxError,
const GDALWarpOptions *psOptionsIn );
/**
* This is a wrapper around GDALCreateGenImgProjTransformer2() that takes into account RPC
* georeferencing (it sets RPC_HEIGHT in GDALCreateGenImgProjTransformer2 based on HEIGHT_OFF).
* By default GDAL would assume that the imagery has zero elevation - if that is not the case,
* the image would not be shown in the correct location.
*
* \since QGIS 3.16
*/
static void *rpcAwareCreateTransformer( GDALDatasetH hSrcDS, GDALDatasetH hDstDS = nullptr, char **papszOptions = nullptr );
#ifndef QT_NO_NETWORKPROXY
//! Sets the gdal proxy variables
static void setupProxy();
#endif
friend class TestQgsGdalUtils;
};
#endif // QGSGDALUTILS_H