QGIS API Documentation 3.41.0-Master (af5edcb665c)
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_sip.h"
24#include "qgis_analysis.h"
25#include "qgsrasterrange.h"
26#include <QVector>
27
31class QgsRectangle;
32
34
40class ANALYSIS_EXPORT QgsReclassifyUtils
41{
42 public:
46 class RasterClass : public QgsRasterRange
47 {
48 public:
50 RasterClass() = default;
51
56 RasterClass( double minValue, double maxValue, QgsRasterRange::BoundsType type, double value )
57 : QgsRasterRange( minValue, maxValue, type )
58 , value( value )
59 {}
60
62 double value = 0;
63 };
64
68 static void reportClasses( const QVector<RasterClass> &classes, QgsProcessingFeedback *feedback );
69
74 static void checkForOverlaps( const QVector<RasterClass> &classes, QgsProcessingFeedback *feedback );
75
97 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 );
98
108 static double reclassifyValue( const QVector<RasterClass> &classes, double input, bool &reclassified )
109 {
110 reclassified = false;
111 for ( const QgsReclassifyUtils::RasterClass &c : classes )
112 {
113 if ( c.contains( input ) )
114 {
115 reclassified = true;
116 return c.value;
117 }
118 }
119 return input;
120 }
121};
122
123Q_DECLARE_TYPEINFO( QgsReclassifyUtils::RasterClass, Q_MOVABLE_TYPE );
124
125
127
128#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.
Raster values range container.
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)