QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsreclassifyutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsreclassifyutils.h
3 ---------------------
4 begin : June, 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSRECLASSIFYUTILS
19#define QGSRECLASSIFYUTILS
20
21#define SIP_NO_FILE
22
23#include "qgis_analysis.h"
24#include "qgis_sip.h"
25#include "qgsrasterrange.h"
26
27#include <QVector>
28
32class QgsRectangle;
33
35
41class ANALYSIS_EXPORT QgsReclassifyUtils
42{
43 public:
47 class RasterClass : public QgsRasterRange
48 {
49 public:
51 RasterClass() = default;
52
57 RasterClass( double minValue, double maxValue, QgsRasterRange::BoundsType type, double value )
58 : QgsRasterRange( minValue, maxValue, type )
59 , value( value )
60 {}
61
63 double value = 0;
64 };
65
69 static void reportClasses( const QVector<RasterClass> &classes, QgsProcessingFeedback *feedback );
70
75 static void checkForOverlaps( const QVector<RasterClass> &classes, QgsProcessingFeedback *feedback );
76
98 static void reclassify( const QVector<RasterClass> &classes, QgsRasterInterface *sourceRaster, int band, const QgsRectangle &extent, int sourceWidthPixels, int sourceHeightPixels, QgsRasterDataProvider *destinationRaster, double destNoDataValue, bool useNoDataForMissingValues, QgsProcessingFeedback *feedback = nullptr );
99
109 static double reclassifyValue( const QVector<RasterClass> &classes, double input, bool &reclassified )
110 {
111 reclassified = false;
112 for ( const QgsReclassifyUtils::RasterClass &c : classes )
113 {
114 if ( c.contains( input ) )
115 {
116 reclassified = true;
117 return c.value;
118 }
119 }
120 return input;
121 }
122};
123
124Q_DECLARE_TYPEINFO( QgsReclassifyUtils::RasterClass, Q_MOVABLE_TYPE );
125
126
128
129#endif // QGSRECLASSIFYUTILS
Base class for providing feedback from a processing algorithm.
Base class for raster data providers.
Base class for processing filters like renderers, reprojector, resampler etc.
Represents a range of raster values between min and max, optionally including the min and max value.
BoundsType
Handling for min and max bounds.
A rectangle specified with double values.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Q_DECLARE_TYPEINFO(QgsMargins, Q_MOVABLE_TYPE)