QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  {
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
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 // TODO
249 // (WMS) IdentifyFormatFeature is not consistent with QgsRaster::IdentifyFormatValue.
250 // IdentifyFormatHtml: better error reporting
251 QgsRasterIdentifyResult QgsRasterDataProvider::identify( const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox, int width, int height, int /*dpi*/ )
252 {
253  QgsDebugMsgLevel( QStringLiteral( "Entered" ), 4 );
254  QMap<int, QVariant> results;
255 
256  if ( format != QgsRaster::IdentifyFormatValue || !( capabilities() & IdentifyValue ) )
257  {
258  QgsDebugMsg( QStringLiteral( "Format not supported" ) );
259  return QgsRasterIdentifyResult( ERR( tr( "Format not supported" ) ) );
260  }
261 
262  if ( !extent().contains( point ) )
263  {
264  // Outside the raster
265  for ( int bandNo = 1; bandNo <= bandCount(); bandNo++ )
266  {
267  results.insert( bandNo, QVariant() );
268  }
270  }
271 
272  QgsRectangle finalExtent = boundingBox;
273  if ( finalExtent.isEmpty() )
274  finalExtent = extent();
275 
276  if ( width == 0 )
277  {
278  width = capabilities() & Size ? xSize() : 1000;
279  }
280  if ( height == 0 )
281  {
282  height = capabilities() & Size ? ySize() : 1000;
283  }
284 
285  // Calculate the row / column where the point falls
286  double xres = ( finalExtent.width() ) / width;
287  double yres = ( finalExtent.height() ) / height;
288 
289  int col = static_cast< int >( std::floor( ( point.x() - finalExtent.xMinimum() ) / xres ) );
290  int row = static_cast< int >( std::floor( ( finalExtent.yMaximum() - point.y() ) / yres ) );
291 
292  double xMin = finalExtent.xMinimum() + col * xres;
293  double xMax = xMin + xres;
294  double yMax = finalExtent.yMaximum() - row * yres;
295  double yMin = yMax - yres;
296  QgsRectangle pixelExtent( xMin, yMin, xMax, yMax );
297 
298  for ( int i = 1; i <= bandCount(); i++ )
299  {
300  std::unique_ptr< QgsRasterBlock > bandBlock( block( i, pixelExtent, 1, 1 ) );
301 
302  if ( bandBlock )
303  {
304  double value = bandBlock->value( 0 );
305 
306  results.insert( i, value );
307  }
308  else
309  {
310  results.insert( i, QVariant() );
311  }
312  }
314 }
315 
316 double QgsRasterDataProvider::sample( const QgsPointXY &point, int band,
317  bool *ok, const QgsRectangle &boundingBox, int width, int height, int dpi )
318 {
319  if ( ok )
320  *ok = false;
321 
322  const auto res = identify( point, QgsRaster::IdentifyFormatValue, boundingBox, width, height, dpi );
323  const QVariant value = res.results().value( band );
324 
325  if ( !value.isValid() )
326  return std::numeric_limits<double>::quiet_NaN();
327 
328  if ( ok )
329  *ok = true;
330 
331  return value.toDouble( ok );
332 }
333 
335 {
336  return QStringLiteral( "text/plain" );
337 }
338 
339 bool QgsRasterDataProvider::writeBlock( QgsRasterBlock *block, int band, int xOffset, int yOffset )
340 {
341  if ( !block )
342  return false;
343  if ( !isEditable() )
344  {
345  QgsDebugMsg( QStringLiteral( "writeBlock() called on read-only provider." ) );
346  return false;
347  }
348  return write( block->bits(), band, block->width(), block->height(), xOffset, yOffset );
349 }
350 
351 // typedef QList<QPair<QString, QString> > *pyramidResamplingMethods_t();
352 QList<QPair<QString, QString> > QgsRasterDataProvider::pyramidResamplingMethods( const QString &providerKey )
353 {
354  QList<QPair<QString, QString> > methods = QgsProviderRegistry::instance()->pyramidResamplingMethods( providerKey );
355  if ( methods.isEmpty() )
356  {
357  QgsDebugMsg( QStringLiteral( "provider pyramidResamplingMethods returned no methods" ) );
358  }
359  return methods;
360 }
361 
363 {
364  QList<QgsRasterPyramid> myPyramidList = buildPyramidList();
365 
366  if ( myPyramidList.isEmpty() )
367  return false;
368 
369  QList<QgsRasterPyramid>::iterator myRasterPyramidIterator;
370  for ( myRasterPyramidIterator = myPyramidList.begin();
371  myRasterPyramidIterator != myPyramidList.end();
372  ++myRasterPyramidIterator )
373  {
374  if ( myRasterPyramidIterator->exists )
375  {
376  return true;
377  }
378  }
379  return false;
380 }
381 
383 {
384  if ( bandNo >= mUserNoDataValue.size() )
385  {
386  for ( int i = mUserNoDataValue.size(); i < bandNo; i++ )
387  {
389  }
390  }
391  QgsDebugMsgLevel( QStringLiteral( "set %1 band %1 no data ranges" ).arg( noData.size() ), 4 );
392 
393  if ( mUserNoDataValue[bandNo - 1] != noData )
394  {
395  // Clear statistics
396  int i = 0;
397  while ( i < mStatistics.size() )
398  {
399  if ( mStatistics.value( i ).bandNumber == bandNo )
400  {
401  mStatistics.removeAt( i );
402  mHistograms.removeAt( i );
403  }
404  else
405  {
406  i++;
407  }
408  }
409  mUserNoDataValue[bandNo - 1] = noData;
410  }
411 }
412 
414 {
415  return mTemporalCapabilities.get();
416 }
417 
419 {
420  return mTemporalCapabilities.get();
421 }
422 
424  const QString &uri,
425  const QString &format, int nBands,
426  Qgis::DataType type,
427  int width, int height, double *geoTransform,
429  const QStringList &createOptions )
430 {
432  providerKey,
433  uri, format,
434  nBands, type, width,
435  height, geoTransform, crs, createOptions );
436  if ( !ret )
437  {
438  QgsDebugMsg( "Cannot resolve 'createRasterDataProviderFunction' function in " + providerKey + " provider" );
439  }
440 
441  // TODO: it would be good to return invalid QgsRasterDataProvider
442  // with QgsError set, but QgsRasterDataProvider has pure virtual methods
443 
444  return ret;
445 }
446 
448 {
449  switch ( format )
450  {
452  return QStringLiteral( "Value" );
454  return QStringLiteral( "Text" );
456  return QStringLiteral( "Html" );
458  return QStringLiteral( "Feature" );
459  default:
460  return QStringLiteral( "Undefined" );
461  }
462 }
463 
465 {
466  switch ( format )
467  {
469  return tr( "Value" );
471  return tr( "Text" );
473  return tr( "Html" );
475  return tr( "Feature" );
476  default:
477  return QStringLiteral( "Undefined" );
478  }
479 }
480 
482 {
483  if ( formatName == QLatin1String( "Value" ) ) return QgsRaster::IdentifyFormatValue;
484  if ( formatName == QLatin1String( "Text" ) ) return QgsRaster::IdentifyFormatText;
485  if ( formatName == QLatin1String( "Html" ) ) return QgsRaster::IdentifyFormatHtml;
486  if ( formatName == QLatin1String( "Feature" ) ) return QgsRaster::IdentifyFormatFeature;
488 }
489 
491 {
492  switch ( format )
493  {
495  return IdentifyValue;
497  return IdentifyText;
499  return IdentifyHtml;
501  return IdentifyFeature;
502  default:
503  return NoCapabilities;
504  }
505 }
506 
508 {
509  return QList< double >();
510 }
511 
513 {
514  return false;
515 }
516 
518 {
519  Q_UNUSED( point )
520  Q_UNUSED( type )
521  return QgsPoint();
522 }
523 
524 bool QgsRasterDataProvider::userNoDataValuesContains( int bandNo, double value ) const
525 {
526  QgsRasterRangeList rangeList = mUserNoDataValue.value( bandNo - 1 );
527  return QgsRasterRange::contains( value, rangeList );
528 }
529 
531 {
532  mDpi = other.mDpi;
537  mExtent = other.mExtent;
538 
539  // copy temporal properties
540  if ( mTemporalCapabilities && other.mTemporalCapabilities )
541  {
542  *mTemporalCapabilities = *other.mTemporalCapabilities;
543  }
544 }
545 
546 // ENDS
QgsRasterDataProvider::setUserNoDataValue
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
Definition: qgsrasterdataprovider.cpp:382
qgsrasterprojector.h
ERR
#define ERR(message)
Definition: qgsrasterdataprovider.cpp:31
QgsPointXY::y
double y
Definition: qgspointxy.h:48
Qgis::DataType
DataType
Raster data types.
Definition: qgis.h:114
QgsRasterDataProvider::mSrcNoDataValue
QList< double > mSrcNoDataValue
Source no data value is available and is set to be used or internal no data is available.
Definition: qgsrasterdataprovider.h:628
QgsRasterDataProvider::dataType
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
QgsRasterInterface::IdentifyHtml
@ IdentifyHtml
Definition: qgsrasterinterface.h:193
QgsRasterInterface::mStatistics
QList< QgsRasterBandStats > mStatistics
List of cached statistics, all bands mixed.
Definition: qgsrasterinterface.h:470
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:104
QgsDataProvider
Definition: qgsdataprovider.h:41
QgsRasterInterface::Size
@ Size
Definition: qgsrasterinterface.h:186
QgsRasterBlock::applyNoDataValues
void applyNoDataValues(const QgsRasterRangeList &rangeList)
Definition: qgsrasterblock.cpp:583
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
QgsRasterDataProvider::dpi
int dpi() const
Returns the dpi of the output device.
Definition: qgsrasterdataprovider.h:419
QgsRectangle::setXMinimum
void setXMinimum(double x)
Set the minimum x value.
Definition: qgsrectangle.h:130
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsRasterDataProvider::useSourceNoDataValue
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
Definition: qgsrasterdataprovider.h:246
qgsrasteridentifyresult.h
QgsRasterDataProvider::transformCoordinates
virtual QgsPoint transformCoordinates(const QgsPoint &point, TransformType type)
Transforms coordinates between source image coordinate space [0..width]x[0..height] and layer coordin...
Definition: qgsrasterdataprovider.cpp:517
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsRaster::IdentifyFormatText
@ IdentifyFormatText
Definition: qgsraster.h:74
QgsRectangle::xMaximum
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
QgsRasterDataProvider::write
virtual bool write(void *data, int band, int width, int height, int xOffset, int yOffset)
Writes into the provider datasource.
Definition: qgsrasterdataprovider.h:452
QgsRasterDataProvider::copyBaseSettings
void copyBaseSettings(const QgsRasterDataProvider &other)
Copy member variables from other raster data provider. Useful for implementation of clone() method in...
Definition: qgsrasterdataprovider.cpp:530
QgsRasterDataProvider::mSrcHasNoDataValue
QList< bool > mSrcHasNoDataValue
Source no data value exists.
Definition: qgsrasterdataprovider.h:631
QgsRasterDataProvider::extent
QgsRectangle extent() const override=0
Returns the extent of the layer.
QgsRaster::IdentifyFormatHtml
@ IdentifyFormatHtml
Definition: qgsraster.h:75
QgsRasterDataProvider::lastErrorFormat
virtual QString lastErrorFormat()
Returns the format of the error text for the last error in this provider.
Definition: qgsrasterdataprovider.cpp:334
QgsRasterInterface::IdentifyFeature
@ IdentifyFeature
Definition: qgsrasterinterface.h:194
QgsRasterBlock::bits
char * bits(int row, int column)
Returns a pointer to block data.
Definition: qgsrasterblock.cpp:516
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsRasterDataProvider::bandOffset
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
Definition: qgsrasterdataprovider.h:235
QgsRectangle
Definition: qgsrectangle.h:41
QgsRasterDataProvider::mUserNoDataValue
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0.
Definition: qgsrasterdataprovider.h:644
QgsRasterDataProvider::identifyFormatFromName
static QgsRaster::IdentifyFormat identifyFormatFromName(const QString &formatName)
Definition: qgsrasterdataprovider.cpp:481
QgsRasterDataProvider::nativeResolutions
virtual QList< double > nativeResolutions() const
Returns a list of native resolutions if available, i.e.
Definition: qgsrasterdataprovider.cpp:507
QgsRasterDataProvider::sourceHasNoDataValue
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
Definition: qgsrasterdataprovider.h:243
qgsapplication.h
QgsProviderRegistry::pyramidResamplingMethods
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
Definition: qgsproviderregistry.cpp:484
QgsRasterBlock::subRect
static QRect subRect(const QgsRectangle &extent, int width, int height, const QgsRectangle &subExtent)
For extent and width, height find rectangle covered by subextent.
Definition: qgsrasterblock.cpp:770
QgsRasterInterface::NoCapabilities
@ NoCapabilities
Definition: qgsrasterinterface.h:185
QgsRasterDataProvider::block
QgsRasterBlock * block(int bandNo, const QgsRectangle &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
Definition: qgsrasterdataprovider.cpp:45
QgsRasterBlock::setIsNoData
bool setIsNoData(int row, int column)
Set no data on pixel.
Definition: qgsrasterblock.h:428
qgsprovidermetadata.h
QgsRaster::IdentifyFormatValue
@ IdentifyFormatValue
Definition: qgsraster.h:73
QgsRasterInterface::IdentifyValue
@ IdentifyValue
Definition: qgsrasterinterface.h:191
qgsproviderregistry.h
QgsRasterInterface::xSize
virtual int xSize() const
Gets raster size.
Definition: qgsrasterinterface.h:241
QgsRasterIdentifyResult
Definition: qgsrasteridentifyresult.h:30
QgsProviderRegistry::createRasterDataProvider
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.
Definition: qgsproviderregistry.cpp:472
QgsRasterDataProvider::writeBlock
bool writeBlock(QgsRasterBlock *block, int band, int xOffset=0, int yOffset=0)
Writes pixel data from a raster block into the provider data source.
Definition: qgsrasterdataprovider.cpp:339
QgsRasterDataProvider::providerCapabilities
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
Definition: qgsrasterdataprovider.cpp:231
qgsDoubleNear
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
QgsRasterDataProvider::sample
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.
Definition: qgsrasterdataprovider.cpp:316
QgsRasterBlock::setNoDataValue
void setNoDataValue(double noDataValue)
Sets cell value that will be considered as "no data".
Definition: qgsrasterblock.cpp:222
QgsRasterBlock::setIsNoDataExcept
bool setIsNoDataExcept(QRect exceptRect)
Set the whole block to no data except specified rectangle.
Definition: qgsrasterblock.cpp:296
QgsRasterDataProvider::NoProviderCapabilities
@ NoProviderCapabilities
Provider has no capabilities.
Definition: qgsrasterdataprovider.h:100
QgsRasterDataProvider::pyramidResamplingMethods
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
Definition: qgsrasterdataprovider.cpp:352
QgsRasterDataProvider::identify
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.
Definition: qgsrasterdataprovider.cpp:251
QgsRectangle::setXMaximum
void setXMaximum(double x)
Set the maximum x value.
Definition: qgsrectangle.h:135
QgsRasterDataProvider::bandScale
virtual double bandScale(int bandNo) const
Read band scale for raster value.
Definition: qgsrasterdataprovider.h:229
QgsRasterRangeList
QList< QgsRasterRange > QgsRasterRangeList
Definition: qgsrasterrange.h:26
QgsRasterDataProvider::sourceNoDataValue
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
Definition: qgsrasterdataprovider.h:252
QgsRasterRange::contains
bool contains(double value) const
Returns true if this range contains the specified value.
Definition: qgsrasterrange.h:114
QgsRasterBlock::isEmpty
bool isEmpty() const
Returns true if block is empty, i.e.
Definition: qgsrasterblock.cpp:130
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsRasterDataProvider::ignoreExtents
virtual bool ignoreExtents() const
Returns true if the extents reported by the data provider are not reliable and it's possible that the...
Definition: qgsrasterdataprovider.cpp:512
QgsRaster::IdentifyFormatFeature
@ IdentifyFormatFeature
Definition: qgsraster.h:76
QgsRectangle::yMaximum
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
QgsRasterInterface::ySize
virtual int ySize() const
Definition: qgsrasterinterface.h:242
QgsRasterDataProvider::TransformType
TransformType
Types of transformation in transformCoordinates() function.
Definition: qgsrasterdataprovider.h:563
QgsRectangle::toString
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Definition: qgsrectangle.cpp:127
QgsPointXY
Definition: qgspointxy.h:43
QgsRasterDataProvider::identifyFormatLabel
static QString identifyFormatLabel(QgsRaster::IdentifyFormat format)
Definition: qgsrasterdataprovider.cpp:464
QgsRasterDataProvider::identifyFormatToCapability
static Capability identifyFormatToCapability(QgsRaster::IdentifyFormat format)
Definition: qgsrasterdataprovider.cpp:490
QgsRasterBlock::width
int width() const
Returns the width (number of columns) of the raster block.
Definition: qgsrasterblock.h:638
QgsRasterInterface::mHistograms
QList< QgsRasterHistogram > mHistograms
List of cached histograms, all bands mixed.
Definition: qgsrasterinterface.h:473
QgsRasterDataProvider::buildPyramidList
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns the raster layers pyramid list.
Definition: qgsrasterdataprovider.h:338
QgsRasterInterface
Definition: qgsrasterinterface.h:116
QgsRasterDataProvider::userNoDataValues
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
Definition: qgsrasterdataprovider.h:257
QgsRasterInterface::Capability
Capability
If you add to this, please also add to capabilitiesString()
Definition: qgsrasterinterface.h:183
QgsRasterDataProvider::mUseSrcNoDataValue
QList< bool > mUseSrcNoDataValue
Use source nodata value.
Definition: qgsrasterdataprovider.h:638
QgsRasterInterface::IdentifyText
@ IdentifyText
Definition: qgsrasterinterface.h:192
QgsRasterDataProvider::readBlock
virtual bool readBlock(int bandNo, int xBlock, int yBlock, void *data)
Reads a block of raster data into data.
Definition: qgsrasterdataprovider.h:598
QgsRasterDataProvider::setUseSourceNoDataValue
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
Definition: qgsrasterdataprovider.cpp:33
QgsPointXY::x
double x
Definition: qgspointxy.h:47
QgsRasterBlockFeedback
Definition: qgsrasterinterface.h:40
QgsRectangle::height
double height() const
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
QgsRasterBlock::applyScaleOffset
void applyScaleOffset(double scale, double offset)
Apply band scale and offset to raster block values.
Definition: qgsrasterblock.cpp:570
QgsRectangle::yMinimum
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
QgsRasterDataProvider::QgsRasterDataProvider
QgsRasterDataProvider()
Provider capabilities.
Definition: qgsrasterdataprovider.cpp:216
QgsRasterBlock::height
int height() const
Returns the height (number of rows) of the raster block.
Definition: qgsrasterblock.h:645
QgsDataProvider::uri
QgsDataSourceUri uri() const
Gets the data source specification.
Definition: qgsdataprovider.h:180
QgsRasterDataProvider::isEditable
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
Definition: qgsrasterdataprovider.h:436
QgsRasterDataProvider::userNoDataValuesContains
bool userNoDataValuesContains(int bandNo, double value) const
Returns true if user no data contains value.
Definition: qgsrasterdataprovider.cpp:524
QgsRasterInterface::bandCount
virtual int bandCount() const =0
Gets number of bands.
QgsRasterDataProvider::create
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.
Definition: qgsrasterdataprovider.cpp:423
qgslogger.h
QgsRasterDataProvider::identifyFormatName
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
Definition: qgsrasterdataprovider.cpp:447
QgsRasterDataProvider::mExtent
QgsRectangle mExtent
Definition: qgsrasterdataprovider.h:646
QgsRasterDataProvider::hasPyramids
bool hasPyramids()
Returns true if raster has at least one populated histogram.
Definition: qgsrasterdataprovider.cpp:362
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
QgsRectangle::isEmpty
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:437
QgsRaster::IdentifyFormat
IdentifyFormat
Definition: qgsraster.h:70
QgsRasterDataProvider::htmlMetadata
virtual QString htmlMetadata()=0
Returns metadata in a format suitable for feeding directly into a subset of the GUI raster properties...
Definition: qgsrasterdataprovider.cpp:242
QgsRasterInterface::capabilities
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
Definition: qgsrasterinterface.h:206
QgsRasterDataProvider::temporalCapabilities
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Definition: qgsrasterdataprovider.cpp:413
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88
QgsRectangle::width
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
QgsRectangle::setYMinimum
void setYMinimum(double y)
Set the minimum y value.
Definition: qgsrectangle.h:140
QgsRectangle::setYMaximum
void setYMaximum(double y)
Set the maximum y value.
Definition: qgsrectangle.h:145
QgsRasterInterface::dataTypeSize
int dataTypeSize(int bandNo)
Definition: qgsrasterinterface.h:231
QgsRasterBlock
Definition: qgsrasterblock.h:36
QgsRectangle::xMinimum
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
QgsRasterDataProviderTemporalCapabilities
Definition: qgsrasterdataprovidertemporalcapabilities.h:37
qgsrasterdataprovider.h
QgsDataProvider::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
QgsRaster::IdentifyFormatUndefined
@ IdentifyFormatUndefined
Definition: qgsraster.h:72
qgssize
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:723
QgsRasterDataProvider::mDpi
int mDpi
Dots per inch.
Definition: qgsrasterdataprovider.h:619