QGIS API Documentation 3.99.0-Master (18a1e75d814)
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
22#include "qgis_analysis.h"
23#include "qgis_sip.h"
24#include "qgsrasterrange.h"
25
26#include <QVector>
27
28#define SIP_NO_FILE
29
33class QgsRectangle;
34
36
42class ANALYSIS_EXPORT QgsReclassifyUtils
43{
44 public:
48 class RasterClass : public QgsRasterRange
49 {
50 public:
52 RasterClass() = default;
53
58 RasterClass( double minValue, double maxValue, QgsRasterRange::BoundsType type, double value )
59 : QgsRasterRange( minValue, maxValue, type )
60 , value( value )
61 {}
62
64 double value = 0;
65 };
66
70 static void reportClasses( const QVector<RasterClass> &classes, QgsProcessingFeedback *feedback );
71
76 static void checkForOverlaps( const QVector<RasterClass> &classes, QgsProcessingFeedback *feedback );
77
99 static void reclassify( const QVector<RasterClass> &classes, QgsRasterInterface *sourceRaster, int band, const QgsRectangle &extent, int sourceWidthPixels, int sourceHeightPixels, std::unique_ptr<QgsRasterDataProvider> destinationRaster, double destNoDataValue, bool useNoDataForMissingValues, QgsProcessingFeedback *feedback = nullptr );
100
110 static double reclassifyValue( const QVector<RasterClass> &classes, double input, bool &reclassified )
111 {
112 reclassified = false;
113 for ( const QgsReclassifyUtils::RasterClass &c : classes )
114 {
115 if ( c.contains( input ) )
116 {
117 reclassified = true;
118 return c.value;
119 }
120 }
121 return input;
122 }
123};
124
125Q_DECLARE_TYPEINFO( QgsReclassifyUtils::RasterClass, Q_MOVABLE_TYPE );
126
127
129
130#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)