QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
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
23class QgsMapToPixel;
24class QgsRasterBlock;
29
34class CORE_EXPORT QgsRasterIterator
35{
36 public:
37
43 QgsRasterIterator( QgsRasterInterface *input, int tileOverlapPixels = 0 );
44
60 void setSnapToPixelFactor( int factor ) { mSnapToPixelFactor = factor > 0 ? factor : 1; }
61
72 int snapToPixelFactor() const { return mSnapToPixelFactor; }
73
92 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, int resamplingFactor = 1 );
93
102 void startRasterRead( int bandNumber, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback = nullptr );
103
123 bool next( int bandNumber, int &columns SIP_OUT, int &rows SIP_OUT, int &topLeftColumn SIP_OUT, int &topLeftRow SIP_OUT, QgsRectangle &blockExtent SIP_OUT );
124
136 bool readNextRasterPart( int bandNumber,
137 int &nCols, int &nRows,
139 int &topLeftCol, int &topLeftRow );
140
158 bool readNextRasterPart( int bandNumber,
159 int &nCols, int &nRows,
160 std::unique_ptr< QgsRasterBlock > &block,
161 int &topLeftCol, int &topLeftRow,
162 QgsRectangle *blockExtent = nullptr,
163 int *tileColumns = nullptr, int *tileRows = nullptr, int *tileTopLeftColumn = nullptr, int *tileTopLeftRow = nullptr ) SIP_SKIP;
164
168 void stopRasterRead( int bandNumber );
169
173 const QgsRasterInterface *input() const { return mInput; }
174
180 void setMaximumTileWidth( int w ) { mMaximumTileWidth = w; }
181
187 int maximumTileWidth() const { return mMaximumTileWidth; }
188
194 void setMaximumTileHeight( int h ) { mMaximumTileHeight = h; }
195
201 int maximumTileHeight() const { return mMaximumTileHeight; }
202
210 int blockCountWidth() const { return mNumberBlocksWidth; }
211
219 int blockCountHeight() const { return mNumberBlocksHeight; }
220
228 qgssize blockCount() const { return static_cast< qgssize >( mNumberBlocksHeight ) * mNumberBlocksWidth; }
229
235 double progress( int bandNumber ) const;
236
238 static const int DEFAULT_MAXIMUM_TILE_WIDTH = 2000;
239
241 static const int DEFAULT_MAXIMUM_TILE_HEIGHT = 2000;
242
243 private:
244 //Stores information about reading of a raster band. Columns and rows are in unsampled coordinates
245 struct RasterPartInfo
246 {
247 qgssize currentCol;
248 qgssize currentRow;
249 qgssize nCols;
250 qgssize nRows;
251 };
252
253 QgsRasterInterface *mInput = nullptr;
254 QMap<int, RasterPartInfo> mRasterPartInfos;
255 QgsRectangle mExtent;
256 QgsRasterBlockFeedback *mFeedback = nullptr;
257
258 int mTileOverlapPixels = 0;
259 int mMaximumTileWidth;
260 int mMaximumTileHeight;
261 int mSnapToPixelFactor = 1;
262
263 int mNumberBlocksWidth = 0;
264 int mNumberBlocksHeight = 0;
265
267 void removePartInfo( int bandNumber );
268 bool readNextRasterPartInternal( int bandNumber, int &nCols, int &nRows, std::unique_ptr<QgsRasterBlock> *block, int &topLeftCol, int &topLeftRow, QgsRectangle *blockExtent, int &tileColumns, int &tileRows, int &tileTopLeftColumn, int &tileTopLeftRow );
269
270};
271
272#endif // QGSRASTERITERATOR_H
Perform transforms between map coordinates and device coordinates.
Feedback object tailored for raster block reading.
Raster data container.
Base class for processing filters like renderers, reprojector, resampler etc.
Iterator for sequentially processing raster cells.
int snapToPixelFactor() const
Returns the current "snap to pixel" factor in pixels.
void setSnapToPixelFactor(int factor)
Sets the "snap to pixel" factor in pixels.
qgssize blockCount() const
Returns the total number of blocks required to iterate over the input raster.
int maximumTileWidth() const
Returns the maximum tile width returned during iteration.
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
int blockCountWidth() const
Returns the total number of blocks which cover the width of the input raster.
int blockCountHeight() const
Returns the total number of blocks which cover the height of the input raster.
int maximumTileHeight() const
Returns the minimum tile width returned during iteration.
void setMaximumTileHeight(int h)
Sets the minimum tile height returned during iteration.
Implements approximate projection support for optimised raster transformation.
A rectangle specified with double values.
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:6614
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_TRANSFERBACK
Definition qgis_sip.h:48
This class provides details of the viewable area that a raster will be rendered into.