25 QString QgsExtractVerticesAlgorithm::name()
const
27 return QStringLiteral(
"extractvertices" );
30 QString QgsExtractVerticesAlgorithm::displayName()
const
32 return QObject::tr(
"Extract vertices" );
35 QStringList QgsExtractVerticesAlgorithm::tags()
const
37 return QObject::tr(
"points,vertex,nodes" ).split(
',' );
40 QString QgsExtractVerticesAlgorithm::group()
const
42 return QObject::tr(
"Vector geometry" );
45 QString QgsExtractVerticesAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeometry" );
50 QString QgsExtractVerticesAlgorithm::shortHelpString()
const
52 return QObject::tr(
"This algorithm takes a line or polygon layer and generates a point layer with points representing the vertices in the input lines or polygons. The attributes associated to each point are the same ones associated to the line or polygon that the point belongs to." ) +
53 QStringLiteral(
"\n\n" ) +
54 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." );
57 QString QgsExtractVerticesAlgorithm::outputName()
const
59 return QObject::tr(
"Vertices" );
62 QgsExtractVerticesAlgorithm *QgsExtractVerticesAlgorithm::createInstance()
const
64 return new QgsExtractVerticesAlgorithm();
72 QgsFields QgsExtractVerticesAlgorithm::outputFields(
const QgsFields &inputFields )
const
75 outputFields.
append(
QgsField( QStringLiteral(
"vertex_index" ), QVariant::Int, QString(), 10, 0 ) );
76 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part" ), QVariant::Int, QString(), 10, 0 ) );
79 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part_ring" ), QVariant::Int, QString(), 10, 0 ) );
81 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part_index" ), QVariant::Int, QString(), 10, 0 ) );
82 outputFields.
append(
QgsField( QStringLiteral(
"distance" ), QVariant::Double, QString(), 20, 14 ) );
83 outputFields.
append(
QgsField( QStringLiteral(
"angle" ), QVariant::Double, QString(), 20, 14 ) );
100 return outputWkbType;
108 QgsFeatureSink::SinkFlags QgsExtractVerticesAlgorithm::sinkFlags()
const
115 std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
145 double cumulativeDistance = 0.0;
156 attrs << vertexId.
ring;
159 << cumulativeDistance
165 outputFeatures << outputFeature;
171 cumulativeDistance += distanceToNext;
175 return outputFeatures;
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.
@ 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 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, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Contains information about the context in which a processing algorithm is executed.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Base class for providing feedback from a processing algorithm.
SourceType
Data source types enum.
@ TypeVectorPoint
Vector point layers.
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...
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Type
The WKB type describes the number of dimensions a geometry has.
static Type addZ(Type type) SIP_HOLDGIL
Adds the z dimension to a WKB type and returns the new type.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
static Type addM(Type type) SIP_HOLDGIL
Adds the m dimension to a WKB type and returns the new type.
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.