QGIS API Documentation  3.13.0-Master (b73bd58cfb)
qgsrasterdataprovider.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterdataprovider.cpp - DataProvider Interface for raster layers
3  --------------------------------------
4  Date : Mar 11, 2005
5  Copyright : (C) 2005 by Brendan Morley
6  email : morb at ozemail dot com dot au
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsproviderregistry.h"
19 #include "qgsrasterdataprovider.h"
21 #include "qgsprovidermetadata.h"
22 #include "qgsrasterprojector.h"
23 #include "qgslogger.h"
24 #include "qgsapplication.h"
25 
26 #include <QTime>
27 #include <QMap>
28 #include <QByteArray>
29 #include <QVariant>
30 
31 #define ERR(message) QgsError(message, "Raster provider")
32 
34 {
35  if ( mUseSrcNoDataValue.size() < bandNo )
36  {
37  for ( int i = mUseSrcNoDataValue.size(); i < bandNo; i++ )
38  {
39  mUseSrcNoDataValue.append( false );
40  }
41  }
42  mUseSrcNoDataValue[bandNo - 1] = use;
43 }
44 
45 QgsRasterBlock *QgsRasterDataProvider::block( int bandNo, QgsRectangle const &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback )
46 {
47  QgsDebugMsgLevel( QStringLiteral( "bandNo = %1 width = %2 height = %3" ).arg( bandNo ).arg( width ).arg( height ), 4 );
48  QgsDebugMsgLevel( QStringLiteral( "boundingBox = %1" ).arg( boundingBox.toString() ), 4 );
49 
50  std::unique_ptr< QgsRasterBlock > block = qgis::make_unique< QgsRasterBlock >( dataType( bandNo ), width, height );
51  if ( sourceHasNoDataValue( bandNo ) && useSourceNoDataValue( bandNo ) )
52  {
53  block->setNoDataValue( sourceNoDataValue( bandNo ) );
54  }
55 
56  if ( block->isEmpty() )
57  {
58  QgsDebugMsg( QStringLiteral( "Couldn't create raster block" ) );
59  return block.release();
60  }
61 
62  // Read necessary extent only
63  QgsRectangle tmpExtent = boundingBox;
64 
65  if ( tmpExtent.isEmpty() )
66  {
67  QgsDebugMsg( QStringLiteral( "Extent outside provider extent" ) );
68  block->setIsNoData();
69  return block.release();
70  }
71 
72  double xRes = boundingBox.width() / width;
73  double yRes = boundingBox.height() / height;
74  double tmpXRes, tmpYRes;
75  double providerXRes = 0;
76  double providerYRes = 0;
77  if ( capabilities() & Size )
78  {
79  providerXRes = extent().width() / xSize();
80  providerYRes = extent().height() / ySize();
81  tmpXRes = std::max( providerXRes, xRes );
82  tmpYRes = std::max( providerYRes, yRes );
83  if ( qgsDoubleNear( tmpXRes, xRes ) ) tmpXRes = xRes;
84  if ( qgsDoubleNear( tmpYRes, yRes ) ) tmpYRes = yRes;
85  }
86  else
87  {
88  tmpXRes = xRes;
89  tmpYRes = yRes;
90  }
91 
92  if ( tmpExtent != boundingBox ||
93  tmpXRes > xRes || tmpYRes > yRes )
94  {
95  // Read smaller extent or lower resolution
96 
97  if ( !extent().contains( boundingBox ) )
98  {
99  QRect subRect = QgsRasterBlock::subRect( boundingBox, width, height, extent() );
100  block->setIsNoDataExcept( subRect );
101  }
102 
103  // Calculate row/col limits (before tmpExtent is aligned)
104  int fromRow = std::round( ( boundingBox.yMaximum() - tmpExtent.yMaximum() ) / yRes );
105  int toRow = std::round( ( boundingBox.yMaximum() - tmpExtent.yMinimum() ) / yRes ) - 1;
106  int fromCol = std::round( ( tmpExtent.xMinimum() - boundingBox.xMinimum() ) / xRes );
107  int toCol = std::round( ( tmpExtent.xMaximum() - boundingBox.xMinimum() ) / xRes ) - 1;
108 
109  QgsDebugMsgLevel( QStringLiteral( "fromRow = %1 toRow = %2 fromCol = %3 toCol = %4" ).arg( fromRow ).arg( toRow ).arg( fromCol ).arg( toCol ), 4 );
110 
111  if ( fromRow < 0 || fromRow >= height || toRow < 0 || toRow >= height ||
112  fromCol < 0 || fromCol >= width || toCol < 0 || toCol >= width )
113  {
114  // Should not happen
115  QgsDebugMsg( QStringLiteral( "Row or column limits out of range" ) );
116  return block.release();
117  }
118 
119  // If lower source resolution is used, the extent must be aligned to original
120  // resolution to avoid possible shift due to resampling
121  if ( tmpXRes > xRes )
122  {
123  int col = std::floor( ( tmpExtent.xMinimum() - extent().xMinimum() ) / providerXRes );
124  tmpExtent.setXMinimum( extent().xMinimum() + col * providerXRes );
125  col = std::ceil( ( tmpExtent.xMaximum() - extent().xMinimum() ) / providerXRes );
126  tmpExtent.setXMaximum( extent().xMinimum() + col * providerXRes );
127  }
128  if ( tmpYRes > yRes )
129  {
130  int row = std::floor( ( extent().yMaximum() - tmpExtent.yMaximum() ) / providerYRes );
131  tmpExtent.setYMaximum( extent().yMaximum() - row * providerYRes );
132  row = std::ceil( ( extent().yMaximum() - tmpExtent.yMinimum() ) / providerYRes );
133  tmpExtent.setYMinimum( extent().yMaximum() - row * providerYRes );
134  }
135  int tmpWidth = std::round( tmpExtent.width() / tmpXRes );
136  int tmpHeight = std::round( tmpExtent.height() / tmpYRes );
137  tmpXRes = tmpExtent.width() / tmpWidth;
138  tmpYRes = tmpExtent.height() / tmpHeight;
139 
140  QgsDebugMsgLevel( QStringLiteral( "Reading smaller block tmpWidth = %1 height = %2" ).arg( tmpWidth ).arg( tmpHeight ), 4 );
141  QgsDebugMsgLevel( QStringLiteral( "tmpExtent = %1" ).arg( tmpExtent.toString() ), 4 );
142 
143  std::unique_ptr< QgsRasterBlock > tmpBlock = qgis::make_unique< QgsRasterBlock >( dataType( bandNo ), tmpWidth, tmpHeight );
144  if ( sourceHasNoDataValue( bandNo ) && useSourceNoDataValue( bandNo ) )
145  {
146  tmpBlock->setNoDataValue( sourceNoDataValue( bandNo ) );
147  }
148 
149  if ( !readBlock( bandNo, tmpExtent, tmpWidth, tmpHeight, tmpBlock->bits(), feedback ) )
150  {
151  QgsDebugMsg( QStringLiteral( "Error occurred while reading block" ) );
152  block->setIsNoData();
153  return block.release();
154  }
155 
156  int pixelSize = dataTypeSize( bandNo );
157 
158  double xMin = boundingBox.xMinimum();
159  double yMax = boundingBox.yMaximum();
160  double tmpXMin = tmpExtent.xMinimum();
161  double tmpYMax = tmpExtent.yMaximum();
162 
163  for ( int row = fromRow; row <= toRow; row++ )
164  {
165  double y = yMax - ( row + 0.5 ) * yRes;
166  int tmpRow = std::floor( ( tmpYMax - y ) / tmpYRes );
167 
168  for ( int col = fromCol; col <= toCol; col++ )
169  {
170  double x = xMin + ( col + 0.5 ) * xRes;
171  int tmpCol = std::floor( ( x - tmpXMin ) / tmpXRes );
172 
173  if ( tmpRow < 0 || tmpRow >= tmpHeight || tmpCol < 0 || tmpCol >= tmpWidth )
174  {
175  QgsDebugMsg( QStringLiteral( "Source row or column limits out of range" ) );
176  block->setIsNoData(); // so that the problem becomes obvious and fixed
177  return block.release();
178  }
179 
180  qgssize tmpIndex = static_cast< qgssize >( tmpRow ) * static_cast< qgssize >( tmpWidth ) + tmpCol;
181  qgssize index = row * static_cast< qgssize >( width ) + col;
182 
183  char *tmpBits = tmpBlock->bits( tmpIndex );
184  char *bits = block->bits( index );
185  if ( !tmpBits )
186  {
187  QgsDebugMsg( QStringLiteral( "Cannot get input block data tmpRow = %1 tmpCol = %2 tmpIndex = %3." ).arg( tmpRow ).arg( tmpCol ).arg( tmpIndex ) );
188  continue;
189  }
190  if ( !bits )
191  {
192  QgsDebugMsg( QStringLiteral( "Cannot set output block data." ) );
193  continue;
194  }
195  memcpy( bits, tmpBits, pixelSize );
196  }
197  }
198  }
199  else
200  {
201  if ( !readBlock( bandNo, boundingBox, width, height, block->bits(), feedback ) )
202  {
203  QgsDebugMsg( QStringLiteral( "Error occurred while reading block" ) );
204  block->setIsNoData();
205  return block.release();
206  }
207  }
208 
209  // apply scale and offset
210  block->applyScaleOffset( bandScale( bandNo ), bandOffset( bandNo ) );
211  // apply user no data values
212  block->applyNoDataValues( userNoDataValues( bandNo ) );
213  return block.release();
214 }
215 
218  , QgsRasterInterface( nullptr )
219  , mTemporalCapabilities( qgis::make_unique< QgsRasterDataProviderTemporalCapabilities >() )
220 {
221 
222 }
223 
225  : QgsDataProvider( uri, options )
226  , QgsRasterInterface( nullptr )
227  , mTemporalCapabilities( qgis::make_unique< QgsRasterDataProviderTemporalCapabilities >() )
228 {
229 }
230 
231 QgsRasterDataProvider::ProviderCapabilities QgsRasterDataProvider::providerCapabilities() const
232 {
234 }
235 
236 //
237 //Random Static convenience function
238 //
240 // convenience function for building metadata() HTML table cells
241 
243 {
244  QString s;
245  return s;
246 }
247 
248 // Default implementation for values
249 QgsRasterIdentifyResult QgsRasterDataProvider::identify( const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox, int width, int height, int /*dpi*/ )
250 {
251  QgsDebugMsgLevel( QStringLiteral( "Entered" ), 4 );
252  QMap<int, QVariant> results;
253 
254  if ( format != QgsRaster::IdentifyFormatValue || !( capabilities() & IdentifyValue ) )
255  {
256  QgsDebugMsg( QStringLiteral( "Format not supported" ) );
257  return QgsRasterIdentifyResult( ERR( tr( "Format not supported" ) ) );
258  }
259 
260  if ( !extent().contains( point ) )
261  {
262  // Outside the raster
263  for ( int bandNo = 1; bandNo <= bandCount(); bandNo++ )
264  {
265  results.insert( bandNo, QVariant() );
266  }
268  }
269 
270  QgsRectangle finalExtent = boundingBox;
271  if ( finalExtent.isEmpty() )
272  finalExtent = extent();
273 
274  if ( width == 0 )
275  {
276  width = capabilities() & Size ? xSize() : 1000;
277  }
278  if ( height == 0 )
279  {
280  height = capabilities() & Size ? ySize() : 1000;
281  }
282 
283  // Calculate the row / column where the point falls
284  double xres = ( finalExtent.width() ) / width;
285  double yres = ( finalExtent.height() ) / height;
286 
287  int col = static_cast< int >( std::floor( ( point.x() - finalExtent.xMinimum() ) / xres ) );
288  int row = static_cast< int >( std::floor( ( finalExtent.yMaximum() - point.y() ) / yres ) );
289 
290  double xMin = finalExtent.xMinimum() + col * xres;
291  double xMax = xMin + xres;
292  double yMax = finalExtent.yMaximum() - row * yres;
293  double yMin = yMax - yres;
294  QgsRectangle pixelExtent( xMin, yMin, xMax, yMax );
295 
296  for ( int i = 1; i <= bandCount(); i++ )
297  {
298  std::unique_ptr< QgsRasterBlock > bandBlock( block( i, pixelExtent, 1, 1 ) );
299 
300  if ( bandBlock )
301  {
302  double value = bandBlock->value( 0 );
303 
304  results.insert( i, value );
305  }
306  else
307  {
308  results.insert( i, QVariant() );
309  }
310  }
312 }
313 
314 double QgsRasterDataProvider::sample( const QgsPointXY &point, int band,
315  bool *ok, const QgsRectangle &boundingBox, int width, int height, int dpi )
316 {
317  if ( ok )
318  *ok = false;
319 
320  const auto res = identify( point, QgsRaster::IdentifyFormatValue, boundingBox, width, height, dpi );
321  const QVariant value = res.results().value( band );
322 
323  if ( !value.isValid() )
324  return std::numeric_limits<double>::quiet_NaN();
325 
326  if ( ok )
327  *ok = true;
328 
329  return value.toDouble( ok );
330 }
331 
333 {
334  return QStringLiteral( "text/plain" );
335 }
336 
337 bool QgsRasterDataProvider::writeBlock( QgsRasterBlock *block, int band, int xOffset, int yOffset )
338 {
339  if ( !block )
340  return false;
341  if ( !isEditable() )
342  {
343  QgsDebugMsg( QStringLiteral( "writeBlock() called on read-only provider." ) );
344  return false;
345  }
346  return write( block->bits(), band, block->width(), block->height(), xOffset, yOffset );
347 }
348 
349 // typedef QList<QPair<QString, QString> > *pyramidResamplingMethods_t();
350 QList<QPair<QString, QString> > QgsRasterDataProvider::pyramidResamplingMethods( const QString &providerKey )
351 {
352  QList<QPair<QString, QString> > methods = QgsProviderRegistry::instance()->pyramidResamplingMethods( providerKey );
353  if ( methods.isEmpty() )
354  {
355  QgsDebugMsg( QStringLiteral( "provider pyramidResamplingMethods returned no methods" ) );
356  }
357  return methods;
358 }
359 
361 {
362  QList<QgsRasterPyramid> myPyramidList = buildPyramidList();
363 
364  if ( myPyramidList.isEmpty() )
365  return false;
366 
367  QList<QgsRasterPyramid>::iterator myRasterPyramidIterator;
368  for ( myRasterPyramidIterator = myPyramidList.begin();
369  myRasterPyramidIterator != myPyramidList.end();
370  ++myRasterPyramidIterator )
371  {
372  if ( myRasterPyramidIterator->exists )
373  {
374  return true;
375  }
376  }
377  return false;
378 }
379 
381 {
382  if ( bandNo >= mUserNoDataValue.size() )
383  {
384  for ( int i = mUserNoDataValue.size(); i < bandNo; i++ )
385  {
387  }
388  }
389  QgsDebugMsgLevel( QStringLiteral( "set %1 band %1 no data ranges" ).arg( noData.size() ), 4 );
390 
391  if ( mUserNoDataValue[bandNo - 1] != noData )
392  {
393  // Clear statistics
394  int i = 0;
395  while ( i < mStatistics.size() )
396  {
397  if ( mStatistics.value( i ).bandNumber == bandNo )
398  {
399  mStatistics.removeAt( i );
400  mHistograms.removeAt( i );
401  }
402  else
403  {
404  i++;
405  }
406  }
407  mUserNoDataValue[bandNo - 1] = noData;
408  }
409 }
410 
412 {
413  return mTemporalCapabilities.get();
414 }
415 
417 {
418  return mTemporalCapabilities.get();
419 }
420 
422  const QString &uri,
423  const QString &format, int nBands,
424  Qgis::DataType type,
425  int width, int height, double *geoTransform,
427  const QStringList &createOptions )
428 {
430  providerKey,
431  uri, format,
432  nBands, type, width,
433  height, geoTransform, crs, createOptions );
434  if ( !ret )
435  {
436  QgsDebugMsg( "Cannot resolve 'createRasterDataProviderFunction' function in " + providerKey + " provider" );
437  }
438 
439  // TODO: it would be good to return invalid QgsRasterDataProvider
440  // with QgsError set, but QgsRasterDataProvider has pure virtual methods
441 
442  return ret;
443 }
444 
446 {
447  switch ( format )
448  {
450  return QStringLiteral( "Value" );
452  return QStringLiteral( "Text" );
454  return QStringLiteral( "Html" );
456  return QStringLiteral( "Feature" );
457  default:
458  return QStringLiteral( "Undefined" );
459  }
460 }
461 
463 {
464  switch ( format )
465  {
467  return tr( "Value" );
469  return tr( "Text" );
471  return tr( "Html" );
473  return tr( "Feature" );
474  default:
475  return QStringLiteral( "Undefined" );
476  }
477 }
478 
480 {
481  if ( formatName == QLatin1String( "Value" ) ) return QgsRaster::IdentifyFormatValue;
482  if ( formatName == QLatin1String( "Text" ) ) return QgsRaster::IdentifyFormatText;
483  if ( formatName == QLatin1String( "Html" ) ) return QgsRaster::IdentifyFormatHtml;
484  if ( formatName == QLatin1String( "Feature" ) ) return QgsRaster::IdentifyFormatFeature;
486 }
487 
489 {
490  switch ( format )
491  {
493  return IdentifyValue;
495  return IdentifyText;
497  return IdentifyHtml;
499  return IdentifyFeature;
500  default:
501  return NoCapabilities;
502  }
503 }
504 
506 {
507  return QList< double >();
508 }
509 
511 {
512  return false;
513 }
514 
515 bool QgsRasterDataProvider::userNoDataValuesContains( int bandNo, double value ) const
516 {
517  QgsRasterRangeList rangeList = mUserNoDataValue.value( bandNo - 1 );
518  return QgsRasterRange::contains( value, rangeList );
519 }
520 
522 {
523  mDpi = other.mDpi;
528  mExtent = other.mExtent;
529 
530  // copy temporal properties
531  if ( mTemporalCapabilities && other.mTemporalCapabilities )
532  {
533  *mTemporalCapabilities = *other.mTemporalCapabilities;
534  }
535 }
536 
537 // ENDS
bool hasPyramids()
Returns true if raster has at least one populated histogram.
virtual int bandCount() const =0
Gets number of bands.
virtual double sample(const QgsPointXY &point, int band, bool *ok=nullptr, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Samples a raster value from the specified band found at the point position.
void setNoDataValue(double noDataValue)
Sets cell value that will be considered as "no data".
IdentifyFormat
Definition: qgsraster.h:57
A rectangle specified with double values.
Definition: qgsrectangle.h:41
void copyBaseSettings(const QgsRasterDataProvider &other)
Copy member variables from other raster data provider. Useful for implementation of clone() method in...
bool contains(double value) const
Returns true if this range contains the specified value.
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
void setXMaximum(double x)
Set the maximum x value.
Definition: qgsrectangle.h:135
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
bool userNoDataValuesContains(int bandNo, double value) const
Returns true if user no data contains value.
double y
Definition: qgspointxy.h:48
A class to represent a 2D point.
Definition: qgspointxy.h:43
virtual bool ignoreExtents() const
Returns true if the extents reported by the data provider are not reliable and it&#39;s possible that the...
int height() const
Returns the height (number of rows) of the raster block.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:315
DataType
Raster data types.
Definition: qgis.h:101
virtual int ySize() const
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider&#39;s temporal capabilities.
Capability
If you add to this, please also add to capabilitiesString()
static Capability identifyFormatToCapability(QgsRaster::IdentifyFormat format)
Abstract base class for spatial data provider implementations.
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
static QRect subRect(const QgsRectangle &extent, int width, int height, const QgsRectangle &subExtent)
For extent and width, height find rectangle covered by subextent.
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
virtual QString lastErrorFormat()
Returns the format of the error text for the last error in this provider.
Raster identify results container.
int dpi() const
Returns the dpi of the output device.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Raster data container.
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:437
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns the raster layers pyramid list.
static QgsRaster::IdentifyFormat identifyFormatFromName(const QString &formatName)
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual QList< double > nativeResolutions() const
Returns a list of native resolutions if available, i.e.
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
void setYMinimum(double y)
Set the minimum y value.
Definition: qgsrectangle.h:140
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
QList< QgsRasterHistogram > mHistograms
List of cached histograms, all bands mixed.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QgsDataSourceUri uri() const
Gets the data source specification.
QList< bool > mSrcHasNoDataValue
Source no data value exists.
QgsRasterDataProvider()
Provider capabilities.
virtual QgsRasterDataProvider * createRasterDataProvider(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates new instance of raster data provider.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
Definition: qgis.h:703
double x
Definition: qgspointxy.h:47
virtual QString htmlMetadata()=0
Returns metadata in a format suitable for feeding directly into a subset of the GUI raster properties...
QList< double > mSrcNoDataValue
Source no data value is available and is set to be used or internal no data is available.
int width() const
Returns the width (number of columns) of the raster block.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
virtual bool readBlock(int bandNo, int xBlock, int yBlock, void *data)
Reads a block of raster data into data.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
Implementation of data provider temporal properties for QgsRasterDataProviders.
QgsRasterBlock * block(int bandNo, const QgsRectangle &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
Setting options for creating vector data providers.
char * bits(int row, int column)
Returns a pointer to block data.
QList< QgsRasterRange > QgsRasterRangeList
void setYMaximum(double y)
Set the maximum y value.
Definition: qgsrectangle.h:145
This class represents a coordinate reference system (CRS).
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
int dataTypeSize(int bandNo)
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
virtual bool write(void *data, int band, int width, int height, int xOffset, int yOffset)
Writes into the provider datasource.
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
QList< QgsRasterBandStats > mStatistics
List of cached statistics, all bands mixed.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
bool writeBlock(QgsRasterBlock *block, int band, int xOffset=0, int yOffset=0)
Writes pixel data from a raster block into the provider data source.
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
Feedback object tailored for raster block reading.
static QString identifyFormatLabel(QgsRaster::IdentifyFormat format)
virtual int xSize() const
Gets raster size.
#define ERR(message)
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
void setXMinimum(double x)
Set the minimum x value.
Definition: qgsrectangle.h:130
double height() const
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
Base class for raster data providers.
static QgsRasterDataProvider * create(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates a new dataset with mDataSourceURI.
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0...
QList< bool > mUseSrcNoDataValue
Use source nodata value.
virtual double bandScale(int bandNo) const
Read band scale for raster value.