QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsrasteriterator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasteriterator.h
3  ---------------------
4  begin : July 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 #ifndef QGSRASTERITERATOR_H
16 #define QGSRASTERITERATOR_H
17 
18 #include "qgis_core.h"
19 #include "qgsrectangle.h"
20 #include "qgis_sip.h"
21 #include <QMap>
22 
23 class QgsMapToPixel;
24 class QgsRasterBlock;
26 class QgsRasterInterface;
27 class QgsRasterProjector;
28 struct QgsRasterViewPort;
29 
34 class CORE_EXPORT QgsRasterIterator
35 {
36  public:
37 
42 
60  static QgsRectangle subRegion( const QgsRectangle &rasterExtent, int rasterWidth, int rasterHeight, const QgsRectangle &subRegion, int &subRegionWidth SIP_OUT, int &subRegionHeight SIP_OUT, int &subRegionLeft SIP_OUT, int &subRegionTop SIP_OUT );
61 
70  void startRasterRead( int bandNumber, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback = nullptr );
71 
91  bool next( int bandNumber, int &columns SIP_OUT, int &rows SIP_OUT, int &topLeftColumn SIP_OUT, int &topLeftRow SIP_OUT, QgsRectangle &blockExtent SIP_OUT );
92 
104  bool readNextRasterPart( int bandNumber,
105  int &nCols, int &nRows,
106  QgsRasterBlock **block,
107  int &topLeftCol, int &topLeftRow );
108 
122  bool readNextRasterPart( int bandNumber,
123  int &nCols, int &nRows,
124  std::unique_ptr< QgsRasterBlock > &block,
125  int &topLeftCol, int &topLeftRow,
126  QgsRectangle *blockExtent = nullptr ) SIP_SKIP;
127 
131  void stopRasterRead( int bandNumber );
132 
136  const QgsRasterInterface *input() const { return mInput; }
137 
143  void setMaximumTileWidth( int w ) { mMaximumTileWidth = w; }
144 
150  int maximumTileWidth() const { return mMaximumTileWidth; }
151 
157  void setMaximumTileHeight( int h ) { mMaximumTileHeight = h; }
158 
164  int maximumTileHeight() const { return mMaximumTileHeight; }
165 
167  static const int DEFAULT_MAXIMUM_TILE_WIDTH = 2000;
168 
170  static const int DEFAULT_MAXIMUM_TILE_HEIGHT = 2000;
171 
172  private:
173  //Stores information about reading of a raster band. Columns and rows are in unsampled coordinates
174  struct RasterPartInfo
175  {
176  qgssize currentCol;
177  qgssize currentRow;
178  qgssize nCols;
179  qgssize nRows;
180  };
181 
182  QgsRasterInterface *mInput = nullptr;
183  QMap<int, RasterPartInfo> mRasterPartInfos;
184  QgsRectangle mExtent;
185  QgsRasterBlockFeedback *mFeedback = nullptr;
186 
187  int mMaximumTileWidth;
188  int mMaximumTileHeight;
189 
191  void removePartInfo( int bandNumber );
192  bool readNextRasterPartInternal( int bandNumber, int &nCols, int &nRows, std::unique_ptr<QgsRasterBlock> *block, int &topLeftCol, int &topLeftRow, QgsRectangle *blockExtent );
193 };
194 
195 #endif // QGSRASTERITERATOR_H
qgsrectangle.h
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsRasterViewPort
Definition: qgsrasterviewport.h:34
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsRasterProjector
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Definition: qgsrasterprojector.h:47
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgis_sip.h
QgsRasterIterator::input
const QgsRasterInterface * input() const
Returns the input raster interface which is being iterated over.
Definition: qgsrasteriterator.h:136
QgsRasterIterator
Iterator for sequentially processing raster cells.
Definition: qgsrasteriterator.h:34
QgsRasterIterator::setMaximumTileHeight
void setMaximumTileHeight(int h)
Sets the minimum tile height returned during iteration.
Definition: qgsrasteriterator.h:157
QgsRasterIterator::maximumTileHeight
int maximumTileHeight() const
Returns the minimum tile width returned during iteration.
Definition: qgsrasteriterator.h:164
QgsRasterInterface
Base class for processing filters like renderers, reprojector, resampler etc.
Definition: qgsrasterinterface.h:135
QgsRasterIterator::setMaximumTileWidth
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
Definition: qgsrasteriterator.h:143
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsRasterBlockFeedback
Feedback object tailored for raster block reading.
Definition: qgsrasterinterface.h:41
QgsRasterIterator::maximumTileWidth
int maximumTileWidth() const
Returns the maximum tile width returned during iteration.
Definition: qgsrasteriterator.h:150
QgsRasterBlock
Raster data container.
Definition: qgsrasterblock.h:36
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:2791