QGIS API Documentation 3.99.0-Master (26c88405ac0)
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 "qgis_sip.h"
20#include "qgsrectangle.h"
21
22#include <QMap>
23
24class QgsMapToPixel;
25class QgsRasterBlock;
30
35class CORE_EXPORT QgsRasterIterator
36{
37 public:
38
44 QgsRasterIterator( QgsRasterInterface *input, int tileOverlapPixels = 0 );
45
61 void setSnapToPixelFactor( int factor ) { mSnapToPixelFactor = factor > 0 ? factor : 1; }
62
73 int snapToPixelFactor() const { return mSnapToPixelFactor; }
74
93 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 );
94
103 void startRasterRead( int bandNumber, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback = nullptr );
104
124 bool next( int bandNumber, int &columns SIP_OUT, int &rows SIP_OUT, int &topLeftColumn SIP_OUT, int &topLeftRow SIP_OUT, QgsRectangle &blockExtent SIP_OUT );
125
137 bool readNextRasterPart( int bandNumber,
138 int &nCols, int &nRows,
140 int &topLeftCol, int &topLeftRow );
141
159 bool readNextRasterPart( int bandNumber,
160 int &nCols, int &nRows,
161 std::unique_ptr< QgsRasterBlock > &block,
162 int &topLeftCol, int &topLeftRow,
163 QgsRectangle *blockExtent = nullptr,
164 int *tileColumns = nullptr, int *tileRows = nullptr, int *tileTopLeftColumn = nullptr, int *tileTopLeftRow = nullptr ) SIP_SKIP;
165
169 void stopRasterRead( int bandNumber );
170
174 const QgsRasterInterface *input() const { return mInput; }
175
181 void setMaximumTileWidth( int w ) { mMaximumTileWidth = w; }
182
188 int maximumTileWidth() const { return mMaximumTileWidth; }
189
195 void setMaximumTileHeight( int h ) { mMaximumTileHeight = h; }
196
202 int maximumTileHeight() const { return mMaximumTileHeight; }
203
211 int blockCountWidth() const { return mNumberBlocksWidth; }
212
220 int blockCountHeight() const { return mNumberBlocksHeight; }
221
229 qgssize blockCount() const { return static_cast< qgssize >( mNumberBlocksHeight ) * mNumberBlocksWidth; }
230
236 double progress( int bandNumber ) const;
237
239 static const int DEFAULT_MAXIMUM_TILE_WIDTH = 2000;
240
242 static const int DEFAULT_MAXIMUM_TILE_HEIGHT = 2000;
243
244 private:
245 //Stores information about reading of a raster band. Columns and rows are in unsampled coordinates
246 struct RasterPartInfo
247 {
248 qgssize currentCol;
249 qgssize currentRow;
250 qgssize nCols;
251 qgssize nRows;
252 };
253
254 QgsRasterInterface *mInput = nullptr;
255 QMap<int, RasterPartInfo> mRasterPartInfos;
256 QgsRectangle mExtent;
257 QgsRasterBlockFeedback *mFeedback = nullptr;
258
259 int mTileOverlapPixels = 0;
260 int mMaximumTileWidth;
261 int mMaximumTileHeight;
262 int mSnapToPixelFactor = 1;
263
264 int mNumberBlocksWidth = 0;
265 int mNumberBlocksHeight = 0;
266
268 void removePartInfo( int bandNumber );
269 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 );
270
271};
272
273#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.
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.
QgsRasterIterator(QgsRasterInterface *input, int tileOverlapPixels=0)
Constructor for QgsRasterIterator, iterating over the specified input raster source.
int maximumTileWidth() const
Returns the maximum tile width returned during iteration.
const QgsRasterInterface * input() const
Returns the input raster interface which is being iterated over.
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
int blockCountWidth() const
Returns the total number of blocks which cover the width of the input raster.
static const int DEFAULT_MAXIMUM_TILE_HEIGHT
Default maximum tile height.
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:7142
#define SIP_SKIP
Definition qgis_sip.h:134
#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.