25QString QgsExtractSpecificVerticesAlgorithm::name()
 const 
   27  return QStringLiteral( 
"extractspecificvertices" );
 
   30QString QgsExtractSpecificVerticesAlgorithm::displayName()
 const 
   32  return QObject::tr( 
"Extract specific vertices" );
 
   35QStringList QgsExtractSpecificVerticesAlgorithm::tags()
 const 
   37  return QObject::tr( 
"points,vertex,nodes" ).split( 
',' );
 
   40QString QgsExtractSpecificVerticesAlgorithm::group()
 const 
   42  return QObject::tr( 
"Vector geometry" );
 
   45QString QgsExtractSpecificVerticesAlgorithm::groupId()
 const 
   47  return QStringLiteral( 
"vectorgeometry" );
 
   50QString QgsExtractSpecificVerticesAlgorithm::shortHelpString()
 const 
   52  return QObject::tr( 
"This algorithm takes a vector layer and generates a point layer with points " 
   53                      "representing specific vertices in the input geometries. 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 feature that the point belongs to." )
 
   56         + QStringLiteral( 
"\n\n" ) + QObject::tr( 
"The vertex indices parameter accepts a comma separated string specifying the indices of the " 
   57                                                   "vertices to extract. The first vertex corresponds to an index of 0, the second vertex has an " 
   58                                                   "index of 1, etc. Negative indices can be used to find vertices at the end of the geometry, " 
   59                                                   "e.g., an index of -1 corresponds to the last vertex, -2 corresponds to the second last vertex, etc." )
 
   60         + QStringLiteral( 
"\n\n" ) + QObject::tr( 
"Additional fields are added to the points indicating the specific vertex position (e.g., 0, -1, etc), " 
   61                                                   "the original vertex index, the vertex’s part and its index within the part (as well as its ring for " 
   62                                                   "polygons), distance along the original geometry and bisector angle of vertex for the original geometry." );
 
   65QString QgsExtractSpecificVerticesAlgorithm::shortDescription()
 const 
   67  return QObject::tr( 
"Generates a point layer with points representing specific vertices in the input geometries." );
 
   75QString QgsExtractSpecificVerticesAlgorithm::outputName()
 const 
   77  return QObject::tr( 
"Vertices" );
 
   80QgsExtractSpecificVerticesAlgorithm *QgsExtractSpecificVerticesAlgorithm::createInstance()
 const 
   82  return new QgsExtractSpecificVerticesAlgorithm();
 
   90QgsFields QgsExtractSpecificVerticesAlgorithm::outputFields( 
const QgsFields &inputFields )
 const 
   93  newFields.
append( 
QgsField( QStringLiteral( 
"vertex_pos" ), QMetaType::Type::Int ) );
 
   94  newFields.
append( 
QgsField( QStringLiteral( 
"vertex_index" ), QMetaType::Type::Int ) );
 
   95  newFields.
append( 
QgsField( QStringLiteral( 
"vertex_part" ), QMetaType::Type::Int ) );
 
   98    newFields.
append( 
QgsField( QStringLiteral( 
"vertex_part_ring" ), QMetaType::Type::Int ) );
 
  100  newFields.
append( 
QgsField( QStringLiteral( 
"vertex_part_index" ), QMetaType::Type::Int ) );
 
  101  newFields.
append( 
QgsField( QStringLiteral( 
"distance" ), QMetaType::Type::Double ) );
 
  102  newFields.
append( 
QgsField( QStringLiteral( 
"angle" ), QMetaType::Type::Double ) );
 
  119  return outputWkbType;
 
  132void QgsExtractSpecificVerticesAlgorithm::initParameters( 
const QVariantMap & )
 
  134  addParameter( 
new QgsProcessingParameterString( QStringLiteral( 
"VERTICES" ), QObject::tr( 
"Vertex indices" ), QStringLiteral( 
"0" ) ) );
 
  139  std::unique_ptr<QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
  145  const QString verticesString = parameterAsString( parameters, QStringLiteral( 
"VERTICES" ), context );
 
  146  const QStringList verticesList = verticesString.split( 
',', Qt::SkipEmptyParts );
 
  147  for ( 
const QString &vertex : verticesList )
 
  150    const int i = vertex.toInt( &ok );
 
  192    for ( 
const int vertex : mIndices )
 
  196        vertexIndex = totalVertices + vertex;
 
  200        vertexIndex = vertex;
 
  203      if ( vertexIndex < 0 || vertexIndex >= totalVertices )
 
  219        attrs << vertexId.
ring;
 
  228      outputFeatures << outFeature;
 
  232  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.
 
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
 
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.
 
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
 
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
 
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...
 
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
 
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.
 
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
 
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.
 
A string parameter for processing algorithms.
 
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
 
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 Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
 
static Q_INVOKABLE 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.