QGIS API Documentation  3.23.0-Master (eb871beae0)
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 
28 class QgsRasterInterface;
31 class QgsRectangle;
32 
34 
40 class ANALYSIS_EXPORT QgsReclassifyUtils
41 {
42 
43  public:
44 
48  class RasterClass : public QgsRasterRange
49  {
50  public:
51 
53  RasterClass() = default;
54 
59  RasterClass( double minValue, double maxValue, QgsRasterRange::BoundsType type, double value )
60  : QgsRasterRange( minValue, maxValue, type )
61  , value( value )
62  {}
63 
65  double value = 0;
66  };
67 
71  static void reportClasses( const QVector< RasterClass > &classes, QgsProcessingFeedback *feedback );
72 
77  static void checkForOverlaps( const QVector< RasterClass > &classes, QgsProcessingFeedback *feedback );
78 
100  static void reclassify( const QVector< RasterClass > &classes,
101  QgsRasterInterface *sourceRaster,
102  int band,
103  const QgsRectangle &extent,
104  int sourceWidthPixels,
105  int sourceHeightPixels,
106  QgsRasterDataProvider *destinationRaster,
107  double destNoDataValue, bool useNoDataForMissingValues,
108  QgsProcessingFeedback *feedback = nullptr );
109 
119  static double reclassifyValue( const QVector< RasterClass > &classes, double input, bool &reclassified )
120  {
121  reclassified = false;
122  for ( const QgsReclassifyUtils::RasterClass &c : classes )
123  {
124  if ( c.contains( input ) )
125  {
126  reclassified = true;
127  return c.value;
128  }
129  }
130  return input;
131  }
132 
133 };
134 
135 Q_DECLARE_TYPEINFO( QgsReclassifyUtils::RasterClass, Q_MOVABLE_TYPE );
136 
137 
139 
140 #endif // QGSRECLASSIFYUTILS
141 
142 
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.
Definition: qgsrectangle.h:42
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)