QGIS API Documentation  3.13.0-Master (b73bd58cfb)
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 
51  void startRasterRead( int bandNumber, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback = nullptr );
52 
72  bool next( int bandNumber, int &columns SIP_OUT, int &rows SIP_OUT, int &topLeftColumn SIP_OUT, int &topLeftRow SIP_OUT, QgsRectangle &blockExtent SIP_OUT );
73 
85  bool readNextRasterPart( int bandNumber,
86  int &nCols, int &nRows,
87  QgsRasterBlock **block,
88  int &topLeftCol, int &topLeftRow );
89 
103  bool readNextRasterPart( int bandNumber,
104  int &nCols, int &nRows,
105  std::unique_ptr< QgsRasterBlock > &block,
106  int &topLeftCol, int &topLeftRow,
107  QgsRectangle *blockExtent = nullptr ) SIP_SKIP;
108 
112  void stopRasterRead( int bandNumber );
113 
117  const QgsRasterInterface *input() const { return mInput; }
118 
124  void setMaximumTileWidth( int w ) { mMaximumTileWidth = w; }
125 
131  int maximumTileWidth() const { return mMaximumTileWidth; }
132 
138  void setMaximumTileHeight( int h ) { mMaximumTileHeight = h; }
139 
145  int maximumTileHeight() const { return mMaximumTileHeight; }
146 
148  static const int DEFAULT_MAXIMUM_TILE_WIDTH = 2000;
149 
151  static const int DEFAULT_MAXIMUM_TILE_HEIGHT = 2000;
152 
153  private:
154  //Stores information about reading of a raster band. Columns and rows are in unsampled coordinates
155  struct RasterPartInfo
156  {
157  qgssize currentCol;
158  qgssize currentRow;
159  qgssize nCols;
160  qgssize nRows;
161  };
162 
163  QgsRasterInterface *mInput = nullptr;
164  QMap<int, RasterPartInfo> mRasterPartInfos;
165  QgsRectangle mExtent;
166  QgsRasterBlockFeedback *mFeedback = nullptr;
167 
168  int mMaximumTileWidth;
169  int mMaximumTileHeight;
170 
172  void removePartInfo( int bandNumber );
173  bool readNextRasterPartInternal( int bandNumber, int &nCols, int &nRows, std::unique_ptr<QgsRasterBlock> *block, int &topLeftCol, int &topLeftRow, QgsRectangle *blockExtent );
174 };
175 
176 #endif // QGSRASTERITERATOR_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Iterator for sequentially processing raster cells.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:37
Raster data container.
#define SIP_SKIP
Definition: qgis_sip.h:126
Base class for processing filters like renderers, reprojector, resampler etc.
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
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
void setMaximumTileHeight(int h)
Sets the minimum tile height returned during iteration.
const QgsRasterInterface * input() const
Returns the input raster interface which is being iterated over.
int maximumTileHeight() const
Returns the minimum tile width returned during iteration.
#define SIP_OUT
Definition: qgis_sip.h:58
This class provides details of the viewable area that a raster will be rendered into.
Feedback object tailored for raster block reading.
int maximumTileWidth() const
Returns the maximum tile width returned during iteration.