QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
25 QString QgsExtractSpecificVerticesAlgorithm::name()
const
27 return QStringLiteral(
"extractspecificvertices" );
30 QString QgsExtractSpecificVerticesAlgorithm::displayName()
const
32 return QObject::tr(
"Extract specific vertices" );
35 QStringList QgsExtractSpecificVerticesAlgorithm::tags()
const
37 return QObject::tr(
"points,vertex,nodes" ).split(
',' );
40 QString QgsExtractSpecificVerticesAlgorithm::group()
const
42 return QObject::tr(
"Vector geometry" );
45 QString QgsExtractSpecificVerticesAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeometry" );
50 QString QgsExtractSpecificVerticesAlgorithm::shortHelpString()
const
52 return QObject::tr(
"This algorithm takes a line or polygon layer and generates a point layer with points "
53 "representing specific vertices in the input lines or polygons. For instance, this algorithm "
54 "can be used to extract the first or last vertices in the geometry. The attributes associated "
55 "to each point are the same ones associated to the line or polygon that the point belongs to." ) +
56 QStringLiteral(
"\n\n" ) +
57 QObject::tr(
"The vertex indices parameter accepts a comma separated string specifying the indices of the "
58 "vertices to extract. The first vertex corresponds to an index of 0, the second vertex has an "
59 "index of 1, etc. Negative indices can be used to find vertices at the end of the geometry, "
60 "e.g., an index of -1 corresponds to the last vertex, -2 corresponds to the second last vertex, etc." ) +
61 QStringLiteral(
"\n\n" ) +
62 QObject::tr(
"Additional fields are added to the points indicating the specific vertex position (e.g., 0, -1, etc), "
63 "the original vertex index, the vertex’s part and its index within the part (as well as its ring for "
64 "polygons), distance along the original geometry and bisector angle of vertex for the original geometry." );
67 QString QgsExtractSpecificVerticesAlgorithm::outputName()
const
69 return QObject::tr(
"Vertices" );
72 QgsExtractSpecificVerticesAlgorithm *QgsExtractSpecificVerticesAlgorithm::createInstance()
const
74 return new QgsExtractSpecificVerticesAlgorithm();
82 QgsFields QgsExtractSpecificVerticesAlgorithm::outputFields(
const QgsFields &inputFields )
const
85 outputFields.
append(
QgsField( QStringLiteral(
"vertex_pos" ), QVariant::Int ) );
86 outputFields.
append(
QgsField( QStringLiteral(
"vertex_index" ), QVariant::Int ) );
87 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part" ), QVariant::Int ) );
90 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part_ring" ), QVariant::Int ) );
92 outputFields.
append(
QgsField( QStringLiteral(
"vertex_part_index" ), QVariant::Int ) );
93 outputFields.
append(
QgsField( QStringLiteral(
"distance" ), QVariant::Double ) );
94 outputFields.
append(
QgsField( QStringLiteral(
"angle" ), QVariant::Double ) );
111 return outputWkbType;
119 QgsFeatureSink::SinkFlags QgsExtractSpecificVerticesAlgorithm::sinkFlags()
const
124 void QgsExtractSpecificVerticesAlgorithm::initParameters(
const QVariantMap & )
126 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"VERTICES" ), QObject::tr(
"Vertex indices" ), QStringLiteral(
"0" ) ) );
131 std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
134 QString verticesString = parameterAsString( parameters, QStringLiteral(
"VERTICES" ), context );
135 const QStringList verticesList = verticesString.split(
',', QString::SkipEmptyParts );
136 for (
const QString &vertex : verticesList )
139 int i = vertex.toInt( &ok );
180 for (
int vertex : mIndices )
184 vertexIndex = totalVertices + vertex;
188 vertexIndex = vertex;
191 if ( vertexIndex < 0 || vertexIndex >= totalVertices )
207 attrs << vertexId.
ring;
216 outputFeatures << outFeature;
220 return outputFeatures;
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
Point geometry type, with support for z-dimension and m-values.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Type
The WKB type describes the number of dimensions a geometry has.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
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)
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
@ TypeVectorPoint
Vector point layers.
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QList< QgsFeature > QgsFeatureList
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
Utility class for identifying a unique vertex within a geometry.
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
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)
SourceType
Data source types enum.