QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
37 , mIsInitialized( false )
38 , mFeedback( feedback )
39 , mInterpolation( interpolation )
45 delete mTriangulation;
46 delete mTriangleInterpolator;
51 if ( !mIsInitialized )
56 if ( !mTriangleInterpolator )
62 if ( !mTriangleInterpolator->
calcPoint( x, y, r ) )
77 mTriangulationSink = sink;
80 void QgsTinInterpolator::initialize()
91 mTriangulation = dualEdgeTriangulation;
96 int nProcessedFeatures = 0;
99 for (
const LayerData &layer : qgis::as_const(
mLayerData ) )
103 nFeatures += layer.source->featureCount();
111 for (
const LayerData &layer : qgis::as_const(
mLayerData ) )
116 switch ( layer.valueSource )
119 attList.push_back( layer.interpolationAttribute );
138 mFeedback->
setProgress( 100.0 *
static_cast< double >( nProcessedFeatures ) / nFeatures );
140 insertData( f, layer.valueSource, layer.interpolationAttribute, layer.sourceType );
141 ++nProcessedFeatures;
155 mTriangleInterpolator = ctInterpolator;
162 mIsInitialized =
true;
165 if ( mTriangulationSink )
180 double attributeValue = 0;
181 bool attributeConversionOk =
false;
186 QVariant attributeVariant = f.
attribute( attr );
187 if ( !attributeVariant.isValid() )
191 attributeValue = attributeVariant.toDouble( &attributeConversionOk );
192 if ( !attributeConversionOk || std::isnan( attributeValue ) )
217 if ( addPointsFromGeometry( g, source, attributeValue ) != 0 )
229 if ( addPointsFromGeometry( g, source, attributeValue ) != 0 )
238 std::vector<const QgsCurve *> curves;
241 std::vector< const QgsCurvePolygon * > polygons;
247 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( ms->
geometryN( i ) ) );
252 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( g.
constGet() ) );
260 if ( polygon->exteriorRing() )
261 curves.emplace_back( polygon->exteriorRing() );
263 for (
int i = 0; i < polygon->numInteriorRings(); ++i )
265 curves.emplace_back( polygon->interiorRing( i ) );
276 curves.emplace_back( mc->
curveN( i ) );
281 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( g.
constGet() ) );
285 for (
const QgsCurve *curve : curves )
291 curve->points( linePoints );
292 for (
QgsPoint &point : linePoints )
297 point.setZ( attributeValue );
304 point.setZ( point.m() );
308 mTriangulation->
addLine( linePoints, type );
324 int QgsTinInterpolator::addPointsFromGeometry(
const QgsGeometry &g, ValueSource source,
double attributeValue )
Abstract base class for curved geometry type.
static QgsFields triangulationFields()
Returns the fields output by features when saving the triangulation.
void setProgress(double progress)
Sets the current progress for the feedback object.
@ CloughTocher
Clough-Tocher interpolation.
@ SourceStructureLines
Structure lines.
@ ValueAttribute
Take value from feature's attribute.
Point geometry type, with support for z-dimension and m-values.
~QgsTinInterpolator() override
@ SourcePoints
Point source.
const QgsCoordinateReferenceSystem & crs
Curve polygon geometry type.
Container of fields for a vector layer.
@ ValueZ
Use feature's geometry Z values for interpolation.
Interface class for interpolations.
Multi surface geometry collection.
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
QList< int > QgsAttributeList
int numGeometries() const SIP_HOLDGIL
Returns the number of geometries within the collection.
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
ValueSource
Source for interpolated values from features.
This class wraps a request for features to a vector layer (or directly its vector data provider).
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
void setTriangulationSink(QgsFeatureSink *sink)
Sets the optional sink for saving the triangulation features.
LinTriangleInterpolator is a class which interpolates linearly on a triangulation.
Multi curve geometry collection.
static QgsFields triangulationFields()
Returns the fields output by features when calling saveTriangulation().
TinInterpolation
Indicates the type of interpolation to be performed.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
virtual void setTriangulation(NormVecDecorator *tin)
bool estimateFirstDerivatives(QgsFeedback *feedback=nullptr)
This method adds the functionality of estimating normals at the data points. Return true in the case ...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const override
Saves the triangulation features to a feature sink.
This is an implementation of a Clough-Tocher interpolator based on a triangular tessellation.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsTinInterpolator(const QList< QgsInterpolator::LayerData > &inputData, TinInterpolation interpolation=Linear, QgsFeedback *feedback=nullptr)
Constructor for QgsTinInterpolator.
This class represents a coordinate reference system (CRS).
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
bool isCanceled() const
Tells whether the operation has been canceled already.
@ SourceBreakLines
Break lines.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
bool nextFeature(QgsFeature &f)
QVector< QgsPoint > QgsPointSequence
A geometry is the spatial representation of a feature.
virtual bool calcPoint(double x, double y, QgsPoint &result)=0
Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
virtual void addLine(const QgsPointSequence &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
virtual void addTriangulation(QgsTriangulation *t)
Adds an association to a triangulation.
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
@ ValueM
Use feature's geometry M values for interpolation.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback) override
Calculates interpolation value for map coordinates x, y.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
QgsCurve * curveN(int index)
Returns the curve with the specified index.
Wrapper for iterator of features from vector data provider or vector layer.
An interface for objects which accept features via addFeature(s) methods.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data struc...
Decorator class which adds the functionality of estimating normals at the data points.