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;
Base class for providing feedback from a processing algorithm.
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QList< QgsFeature > QgsFeatureList
QgsVertexId vertexId() const
Returns vertex ID of the current item.
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
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)
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
Type
The WKB type describes the number of dimensions a geometry has.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
Utility class for identifying a unique vertex within a geometry.
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry...
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
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) ...
Encapsulate a field in an attribute table or data source.
The vertex_iterator class provides STL-style iterator for vertices.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
SourceType
Data source types enum.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
Contains information about the context in which a processing algorithm is executed.