QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
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( qgsgeometry_cast< const QgsCurve * >( mc->
geometryN( i ) ) );
281 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( g.
constGet() ) );
285 for (
const QgsCurve *curve : curves )
290 QVector< QgsPoint > linePoints;
310 linePoints.append(
QgsPoint( p.
x(), p.
y(), z ) );
312 mTriangulation->
addLine( linePoints, type );
328 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.
virtual void addLine(const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
@ SourceStructureLines
Structure lines.
@ ValueAttribute
Take value from feature's attribute.
bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const override
Saves the triangulation features to a feature sink.
Point geometry type, with support for z-dimension and m-values.
~QgsTinInterpolator() override
int numGeometries() const
Returns the number of geometries within the collection.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
@ SourcePoints
Point source.
const QgsCoordinateReferenceSystem & crs
Curve polygon geometry type.
@ ValueZ
Use feature's geometry Z values for interpolation.
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
Multi surface geometry collection.
virtual void addTriangulation(Triangulation *t)
Adds an association to a triangulation.
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
QList< int > QgsAttributeList
static QgsFields triangulationFields()
Returns the fields output by features when calling saveTriangulation().
ValueSource
Source for interpolated values from features.
void setTriangulationSink(QgsFeatureSink *sink)
Sets the optional sink for saving the triangulation features.
Multi curve geometry collection.
TinInterpolation
Indicates the type of interpolation to be performed.
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 ...
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
QgsTinInterpolator(const QList< QgsInterpolator::LayerData > &inputData, TinInterpolation interpolation=Linear, QgsFeedback *feedback=nullptr)
Constructor for QgsTinInterpolator.
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)
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.
bool isMeasure() const
Returns true if the geometry contains m values.
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
@ ValueM
Use feature's geometry M values for interpolation.
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.