QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsalgorithmvectorize.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmvectorize.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 QGSALGORITHMVECTORIZE_H
19 #define QGSALGORITHMVECTORIZE_H
20 
21 #define SIP_NO_FILE
22 
23 #include "qgis_sip.h"
24 #include "qgsprocessingalgorithm.h"
25 #include "qgsreclassifyutils.h"
26 
28 
32 class QgsVectorizeAlgorithmBase : public QgsProcessingAlgorithm
33 {
34  public:
35 
36  QString group() const final;
37  QString groupId() const final;
38  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) final;
39 
40  protected:
41 
42  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
43 
44  QVariantMap processAlgorithm( const QVariantMap &parameters,
45  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
46 
47  std::unique_ptr< QgsRasterInterface > mInterface;
48 
50  double mNoDataValue = -9999;
51  int mBand = 1;
52  QgsRectangle mExtent;
54  double mRasterUnitsPerPixelX = 0;
55  double mRasterUnitsPerPixelY = 0;
56  int mNbCellsXProvider = 0;
57  int mNbCellsYProvider = 0;
58  QgsReclassifyUtils::RasterClass::BoundsType mBoundsType = QgsReclassifyUtils::RasterClass::IncludeMax;
59  bool mUseNoDataForMissingValues = false;
60 
61  private:
62 
63  virtual QString outputName() const = 0;
64  virtual QgsProcessing::SourceType outputType() const = 0;
65  virtual QgsWkbTypes::Type sinkType() const = 0;
66  virtual QgsGeometry createGeometryForPixel( double centerX, double centerY, double pixelWidthX, double pixelWidthY ) const = 0;
67 };
68 
72 class QgsRasterPixelsToPolygonsAlgorithm : public QgsVectorizeAlgorithmBase
73 {
74  public:
75 
76  QgsRasterPixelsToPolygonsAlgorithm() = default;
77  QString name() const override;
78  QString displayName() const override;
79  QStringList tags() const override;
80  QString shortHelpString() const override;
81  QString shortDescription() const override;
82  QgsRasterPixelsToPolygonsAlgorithm *createInstance() const override SIP_FACTORY;
83 
84  private:
85 
86  QString outputName() const override;
87  QgsProcessing::SourceType outputType() const override;
88  QgsWkbTypes::Type sinkType() const override;
89  QgsGeometry createGeometryForPixel( double centerX, double centerY, double pixelWidthX, double pixelWidthY ) const override;
90 
91 };
92 
96 class QgsRasterPixelsToPointsAlgorithm : public QgsVectorizeAlgorithmBase
97 {
98  public:
99 
100  QgsRasterPixelsToPointsAlgorithm() = default;
101  QString name() const override;
102  QString displayName() const override;
103  QStringList tags() const override;
104  QString shortHelpString() const override;
105  QString shortDescription() const override;
106  QgsRasterPixelsToPointsAlgorithm *createInstance() const override SIP_FACTORY;
107 
108  private:
109 
110  QString outputName() const override;
111  QgsProcessing::SourceType outputType() const override;
112  QgsWkbTypes::Type sinkType() const override;
113  QgsGeometry createGeometryForPixel( double centerX, double centerY, double pixelWidthX, double pixelWidthY ) const override;
114 
115 };
116 
118 
119 #endif // QGSALGORITHMVECTORIZE_H
120 
121 
QgsProcessingFeedback
Base class for providing feedback from a processing algorithm.
Definition: qgsprocessingfeedback.h:37
Qgis::DataType
DataType
Raster data types.
Definition: qgis.h:128
qgsreclassifyutils.h
QgsProcessingAlgorithm::groupId
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
Definition: qgsprocessingalgorithm.h:234
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:69
QgsProcessingAlgorithm::prepareAlgorithm
virtual bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Prepares the algorithm to run using the specified parameters.
Definition: qgsprocessingalgorithm.cpp:451
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsProcessingAlgorithm::processAlgorithm
virtual QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Runs the algorithm using the specified parameters.
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:46
qgsprocessingalgorithm.h
qgis_sip.h
QgsProcessing
Contains enumerations and other constants for use in processing algorithms and parameters.
Definition: qgsprocessing.h:39
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
Qgis::DataType::Float32
@ Float32
Thirty two bit floating point (float)
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsProcessingAlgorithm::group
virtual QString group() const
Returns the name of the group this algorithm belongs to.
Definition: qgsprocessingalgorithm.h:225
QgsWkbTypes
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:41
QgsProcessing::SourceType
SourceType
Data source types enum.
Definition: qgsprocessing.h:45
QgsProcessingAlgorithm::initAlgorithm
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.