25using namespace Qt::StringLiterals;
29QString QgsLineSubstringAlgorithm::name()
const
31 return u
"linesubstring"_s;
34QString QgsLineSubstringAlgorithm::displayName()
const
36 return QObject::tr(
"Line substring" );
39QStringList QgsLineSubstringAlgorithm::tags()
const
41 return QObject::tr(
"linestring,curve,split,shorten,shrink,portion,part,reference,referencing,distance,interpolate" ).split(
',' );
44QString QgsLineSubstringAlgorithm::group()
const
46 return QObject::tr(
"Vector geometry" );
49QString QgsLineSubstringAlgorithm::groupId()
const
51 return u
"vectorgeometry"_s;
54QString QgsLineSubstringAlgorithm::outputName()
const
56 return QObject::tr(
"Substring" );
59QString QgsLineSubstringAlgorithm::shortHelpString()
const
61 return QObject::tr(
"This algorithm returns the portion of a line (or curve) which falls "
62 "between the specified start and end distances (measured from the "
63 "beginning of the line).\n\n"
64 "Z and M values are linearly interpolated from existing values.\n\n"
65 "If a multipart geometry is encountered, only the first part is considered when "
66 "calculating the substring." );
69QString QgsLineSubstringAlgorithm::shortDescription()
const
71 return QObject::tr(
"Returns the substring of lines which fall between start and end distances." );
74QList<int> QgsLineSubstringAlgorithm::inputLayerTypes()
const
84QgsLineSubstringAlgorithm *QgsLineSubstringAlgorithm::createInstance()
const
86 return new QgsLineSubstringAlgorithm();
89void QgsLineSubstringAlgorithm::initParameters(
const QVariantMap & )
91 auto startDistance = std::make_unique<QgsProcessingParameterDistance>( u
"START_DISTANCE"_s, QObject::tr(
"Start distance" ), 0.0, u
"INPUT"_s,
false, 0 );
92 startDistance->setIsDynamic(
true );
94 startDistance->setDynamicLayerParameterName( u
"INPUT"_s );
95 addParameter( startDistance.release() );
97 auto endDistance = std::make_unique<QgsProcessingParameterDistance>( u
"END_DISTANCE"_s, QObject::tr(
"End distance" ), 1.0, u
"INPUT"_s,
false, 0 );
98 endDistance->setIsDynamic(
true );
100 endDistance->setDynamicLayerParameterName( u
"INPUT"_s );
101 addParameter( endDistance.release() );
112 mStartDistance = parameterAsDouble( parameters, u
"START_DISTANCE"_s, context );
114 if ( mDynamicStartDistance )
115 mStartDistanceProperty = parameters.value( u
"START_DISTANCE"_s ).value<
QgsProperty>();
117 mEndDistance = parameterAsDouble( parameters, u
"END_DISTANCE"_s, context );
119 if ( mDynamicEndDistance )
120 mEndDistanceProperty = parameters.value( u
"END_DISTANCE"_s ).value<
QgsProperty>();
131 double startDistance = mStartDistance;
132 if ( mDynamicStartDistance )
133 startDistance = mStartDistanceProperty.valueAsDouble( context.
expressionContext(), startDistance );
135 double endDistance = mEndDistance;
136 if ( mDynamicEndDistance )
146 if ( collection->numGeometries() > 0 )
154 std::unique_ptr<QgsCurve> substring( curve->
curveSubstring( startDistance, endDistance ) );
155 const QgsGeometry result( std::move( substring ) );
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...
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
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.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void clearGeometry()
Removes any geometry associated with the feature.
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.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
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.
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QList< QgsFeature > QgsFeatureList