27QString QgsSplitLinesByLengthAlgorithm::name()
const
29 return QStringLiteral(
"splitlinesbylength" );
32QString QgsSplitLinesByLengthAlgorithm::displayName()
const
34 return QObject::tr(
"Split lines by maximum length" );
37QStringList QgsSplitLinesByLengthAlgorithm::tags()
const
39 return QObject::tr(
"segments,parts,distance,cut,chop" ).split(
',' );
42QString QgsSplitLinesByLengthAlgorithm::group()
const
44 return QObject::tr(
"Vector geometry" );
47QString QgsSplitLinesByLengthAlgorithm::groupId()
const
49 return QStringLiteral(
"vectorgeometry" );
52QString QgsSplitLinesByLengthAlgorithm::shortHelpString()
const
54 return QObject::tr(
"This algorithm takes a line (or curve) layer and splits each feature into multiple parts, "
55 "where each part is of a specified maximum length.\n\n"
56 "Z and M values at the start and end of the new line substrings are linearly interpolated from existing values." );
59QString QgsSplitLinesByLengthAlgorithm::shortDescription()
const
61 return QObject::tr(
"Splits lines into parts which are no longer than a specified length." );
64QList<int> QgsSplitLinesByLengthAlgorithm::inputLayerTypes()
const
74QgsSplitLinesByLengthAlgorithm *QgsSplitLinesByLengthAlgorithm::createInstance()
const
76 return new QgsSplitLinesByLengthAlgorithm();
79void QgsSplitLinesByLengthAlgorithm::initParameters(
const QVariantMap & )
81 std::unique_ptr< QgsProcessingParameterDistance > length = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"LENGTH" ),
82 QObject::tr(
"Maximum line length" ), 10, QStringLiteral(
"INPUT" ),
false, 0 );
83 length->setIsDynamic(
true );
85 length->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
86 addParameter( length.release() );
91 mLength = parameterAsDouble( parameters, QStringLiteral(
"LENGTH" ), context );
94 mLengthProperty = parameters.value( QStringLiteral(
"LENGTH" ) ).value<
QgsProperty >();
99QString QgsSplitLinesByLengthAlgorithm::outputName()
const
101 return QObject::tr(
"Split" );
117 double distance = mLength;
118 if ( mDynamicLength )
119 distance = mLengthProperty.valueAsDouble( context.
expressionContext(), distance );
127 const QgsCurve *part = qgsgeometry_cast< const QgsCurve * >( *it );
132 double end = distance;
133 const double length = part->
length();
134 while ( start < length )
139 features << outputFeature;
ProcessingSourceType
Processing data source types.
@ VectorLine
Vector line layers.
@ 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 double length() const
Returns the planar, 2-dimensional length of the geometry.
Abstract base class for curved geometry type.
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
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.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Base class for providing feedback from a processing algorithm.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
Definition for a property.
@ DoublePositive
Positive double value (including 0)
A store for object properties.
static Qgis::WkbType singleType(Qgis::WkbType type)
Returns the single type for a WKB type.
QList< QgsFeature > QgsFeatureList