25QString QgsExtractVerticesAlgorithm::name()
const
27 return QStringLiteral(
"extractvertices" );
30QString QgsExtractVerticesAlgorithm::displayName()
const
32 return QObject::tr(
"Extract vertices" );
35QStringList QgsExtractVerticesAlgorithm::tags()
const
37 return QObject::tr(
"points,vertex,nodes" ).split(
',' );
40QString QgsExtractVerticesAlgorithm::group()
const
42 return QObject::tr(
"Vector geometry" );
45QString QgsExtractVerticesAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeometry" );
50QString QgsExtractVerticesAlgorithm::shortHelpString()
const
52 return QObject::tr(
"This algorithm takes a vector layer and generates a point layer with points representing the vertices in the input geometries. The attributes associated to each point are the same ones associated to the feature that the point belongs to." ) + QStringLiteral(
"\n\n" ) + QObject::tr(
"Additional fields are added to the point indicating the vertex index (beginning at 0), the vertex’s part and its index within the part (as well as its ring for polygons), distance along original geometry and bisector angle of vertex for original geometry." );
60QString QgsExtractVerticesAlgorithm::outputName()
const
62 return QObject::tr(
"Vertices" );
65QgsExtractVerticesAlgorithm *QgsExtractVerticesAlgorithm::createInstance()
const
67 return new QgsExtractVerticesAlgorithm();
75QgsFields QgsExtractVerticesAlgorithm::outputFields(
const QgsFields &inputFields )
const
78 outputFields.
append(
QgsField( QStringLiteral(
"vertex_index" ), QMetaType::Type::Int, QString(), 10, 0 ) );
79 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part" ), QMetaType::Type::Int, QString(), 10, 0 ) );
82 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part_ring" ), QMetaType::Type::Int, QString(), 10, 0 ) );
84 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part_index" ), QMetaType::Type::Int, QString(), 10, 0 ) );
85 outputFields.
append(
QgsField( QStringLiteral(
"distance" ), QMetaType::Type::Double, QString(), 20, 14 ) );
86 outputFields.
append(
QgsField( QStringLiteral(
"angle" ), QMetaType::Type::Double, QString(), 20, 14 ) );
103 return outputWkbType;
118 std::unique_ptr<QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
152 double cumulativeDistance = 0.0;
163 attrs << vertexId.
ring;
166 << cumulativeDistance
172 outputFeatures << outputFeature;
178 cumulativeDistance += distanceToNext;
182 return outputFeatures;
ProcessingSourceType
Processing data source types.
@ VectorPoint
Vector point layers.
@ RegeneratesPrimaryKey
Algorithm always drops any existing primary keys or FID values and regenerates them in outputs.
QFlags< ProcessingAlgorithmDocumentationFlag > ProcessingAlgorithmDocumentationFlags
Flags describing algorithm behavior for documentation purposes.
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
WkbType
The WKB type describes the number of dimensions a geometry has.
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
The vertex_iterator class provides STL-style iterator for vertices.
QgsVertexId vertexId() const
Returns vertex ID of the current item.
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
QFlags< SinkFlag > SinkFlags
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void clearGeometry()
Removes any geometry associated with the feature.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static Qgis::WkbType addM(Qgis::WkbType type)
Adds the m dimension to a WKB type and returns the new type.
static Qgis::WkbType addZ(Qgis::WkbType type)
Adds the z dimension to a WKB type and returns the new type.
static bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QList< QgsFeature > QgsFeatureList
Utility class for identifying a unique vertex within a geometry.