QGIS API Documentation  3.2.0-Bonn (bc43194)
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 <QMap>
21 
22 class QgsMapToPixel;
23 class QgsRasterBlock;
25 class QgsRasterInterface;
26 class QgsRasterProjector;
27 struct QgsRasterViewPort;
28 
33 class CORE_EXPORT QgsRasterIterator
34 {
35  public:
36 
41 
50  void startRasterRead( int bandNumber, int nCols, int nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback = nullptr );
51 
63  bool readNextRasterPart( int bandNumber,
64  int &nCols, int &nRows,
65  QgsRasterBlock **block,
66  int &topLeftCol, int &topLeftRow );
67 
81  bool readNextRasterPart( int bandNumber,
82  int &nCols, int &nRows,
83  std::unique_ptr< QgsRasterBlock > &block,
84  int &topLeftCol, int &topLeftRow,
85  QgsRectangle *blockExtent = nullptr ) SIP_SKIP;
86 
90  void stopRasterRead( int bandNumber );
91 
95  const QgsRasterInterface *input() const { return mInput; }
96 
102  void setMaximumTileWidth( int w ) { mMaximumTileWidth = w; }
103 
109  int maximumTileWidth() const { return mMaximumTileWidth; }
110 
116  void setMaximumTileHeight( int h ) { mMaximumTileHeight = h; }
117 
123  int maximumTileHeight() const { return mMaximumTileHeight; }
124 
126  static const int DEFAULT_MAXIMUM_TILE_WIDTH = 2000;
127 
129  static const int DEFAULT_MAXIMUM_TILE_HEIGHT = 2000;
130 
131  private:
132  //Stores information about reading of a raster band. Columns and rows are in unsampled coordinates
133  struct RasterPartInfo
134  {
135  int currentCol;
136  int currentRow;
137  int nCols;
138  int nRows;
139  };
140 
141  QgsRasterInterface *mInput = nullptr;
142  QMap<int, RasterPartInfo> mRasterPartInfos;
143  QgsRectangle mExtent;
144  QgsRasterBlockFeedback *mFeedback = nullptr;
145 
146  int mMaximumTileWidth;
147  int mMaximumTileHeight;
148 
150  void removePartInfo( int bandNumber );
151 };
152 
153 #endif // QGSRASTERITERATOR_H
A rectangle specified with double values.
Definition: qgsrectangle.h:40
Iterator for sequentially processing raster cells.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:36
Raster data container.
#define SIP_SKIP
Definition: qgis_sip.h:119
Base class for processing filters like renderers, reprojector, resampler etc.
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.
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.