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;