QGIS API Documentation 4.3.0-Master (9dce731a7a1)
Loading...
Searching...
No Matches
qgsrastervectorfieldvaluesource.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrastervectorfieldvaluesource.h
3 ---------------------------------
4 begin : September 2026
5 copyright : (C) 2026 by Stefanos Natsis
6 email : uclaros 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 QGSRASTERVECTORFIELDVALUESOURCE_H
19#define QGSRASTERVECTORFIELDVALUESOURCE_H
20
21#include <memory>
22
23#include "qgis.h"
24#include "qgsrasterinterface.h"
25#include "qgsrectangle.h"
27
28#define SIP_NO_FILE
29
30class QgsRasterBlock;
31
33
45class QgsRasterVectorFieldValueSourceBase : public QgsVectorFieldValueSource
46{
47 public:
53 QgsRasterVectorFieldValueSourceBase( const QgsRectangle &blockExtent, const QgsRectangle &dataExtent, int columns, int rows );
54
55 QgsRectangle extent() const override;
56 QVector<QgsPointXY> seedPoints( const QgsRectangle &extent ) const override;
57
59 bool nativeLayout( QgsPointXY &origin, double &spacingX, double &spacingY ) const override;
60
62 static constexpr int MAXIMUM_SEED_POINTS = 100'000;
63
64 protected:
66 bool isValid() const;
67
69 virtual bool cellHasValue( int row, int column ) const = 0;
70
71 QgsRectangle mBlockExtent;
72 QgsRectangle mDataExtent;
73
74 int mColumns = 0;
75 int mRows = 0;
76 double mXResolution = 0;
77 double mYResolution = 0;
78};
79
91class QgsRasterVectorFieldValueSource : public QgsRasterVectorFieldValueSourceBase
92{
93 public:
101 QgsRasterVectorFieldValueSource(
102 std::shared_ptr<const QgsRasterBlock> xValues, std::shared_ptr<const QgsRasterBlock> yValues, const QgsRectangle &blockExtent, const QgsRectangle &dataExtent, double maximumMagnitude
103 );
104
105 QgsRasterVectorFieldValueSource *clone() const override;
106 QgsVector vectorValue( const QgsPointXY &point ) const override;
107 double maximumMagnitude() const override;
108 std::unique_ptr<QgsRasterInterface> magnitudeSource( const QgsRenderContext &context, QSize size ) const override;
109
110 private:
115 double sampledValue( const QgsRasterBlock *block, const QgsPointXY &point ) const;
116
117 bool cellHasValue( int row, int column ) const override;
118
119 std::shared_ptr<const QgsRasterBlock> mXValues;
120 std::shared_ptr<const QgsRasterBlock> mYValues;
121 double mMaximumMagnitude = 0;
122};
123
138class CORE_EXPORT QgsRasterVectorFieldEncodedDirectionValueSource : public QgsRasterVectorFieldValueSourceBase
139{
140 public:
147 QgsRasterVectorFieldEncodedDirectionValueSource( std::shared_ptr<const QgsRasterBlock> values, Qgis::RasterDirectionEncoding encoding, const QgsRectangle &blockExtent, const QgsRectangle &dataExtent );
148
149 QgsRasterVectorFieldEncodedDirectionValueSource *clone() const override;
150 QgsVector vectorValue( const QgsPointXY &point ) const override;
151
153 double maximumMagnitude() const override;
154
163 void setSamplingWindow( double width, double height ) override;
164
170 static int directionOrdinal( Qgis::RasterDirectionEncoding encoding, double value );
171
173 static QgsVector ordinalVector( int ordinal );
174
175 private:
177 int nearestOrdinal( const QgsPointXY &point ) const;
178
180 int majorityOrdinal( const QgsPointXY &point ) const;
181
182 bool cellHasValue( int row, int column ) const override;
183
184 std::shared_ptr<const QgsRasterBlock> mValues;
186 double mWindowWidth = 0;
187 double mWindowHeight = 0;
188};
189
201class QgsRasterVectorFieldMagnitudeInterface : public QgsRasterInterface
202{
203 public:
205 QgsRasterVectorFieldMagnitudeInterface( std::shared_ptr<const QgsRasterBlock> xValues, std::shared_ptr<const QgsRasterBlock> yValues, const QgsRectangle &blockExtent );
206
207 QgsRasterInterface *clone() const override;
208 Qgis::DataType dataType( int bandNo ) const override;
209 int bandCount() const override;
210 QgsRectangle extent() const override;
211 QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override;
212
213 private:
214 std::shared_ptr<const QgsRasterBlock> mXValues;
215 std::shared_ptr<const QgsRasterBlock> mYValues;
216 QgsRectangle mBlockExtent;
217};
218
220
221#endif // QGSRASTERVECTORFIELDVALUESOURCE_H
DataType
Raster data types.
Definition qgis.h:413
RasterDirectionEncoding
Schemes used to encode a compass direction as an integer raster value.
Definition qgis.h:7288
@ Esri
Esri: 1=E, 2=SE, 4=S, 8=SW, 16=W, 32=NW, 64=N, 128=NE.
Definition qgis.h:7289
Represents a 2D point.
Definition qgspointxy.h:62
Raster data container.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)=0
Read block of data using given extent and size.
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
virtual int bandCount() const =0
Gets number of bands.
virtual QgsRectangle extent() const
Gets the extent of the interface.
A rectangle specified with double values.
Abstract source of vector (u/v) values sampled at arbitrary map positions.
virtual QgsRectangle extent() const =0
Returns the extent of the data, in map coordinates.
virtual QVector< QgsPointXY > seedPoints(const QgsRectangle &extent) const
Returns the natural seeding positions of the data within extent, in map coordinates.
virtual bool nativeLayout(QgsPointXY &origin, double &spacingX, double &spacingY) const
Returns the grid on which the data itself is sampled through origin, spacingX and spacingY,...