24 QString QgsLineSubstringAlgorithm::name()
const
26 return QStringLiteral(
"linesubstring" );
29 QString QgsLineSubstringAlgorithm::displayName()
const
31 return QObject::tr(
"Line substring" );
34 QStringList QgsLineSubstringAlgorithm::tags()
const
36 return QObject::tr(
"linestring,curve,split,shorten,shrink,portion,part,reference,referencing,distance,interpolate" ).split(
',' );
39 QString QgsLineSubstringAlgorithm::group()
const
41 return QObject::tr(
"Vector geometry" );
44 QString QgsLineSubstringAlgorithm::groupId()
const
46 return QStringLiteral(
"vectorgeometry" );
49 QString QgsLineSubstringAlgorithm::outputName()
const
51 return QObject::tr(
"Substring" );
54 QString QgsLineSubstringAlgorithm::shortHelpString()
const
56 return QObject::tr(
"This algorithm returns the portion of a line (or curve) which falls "
57 "between the specified start and end distances (measured from the "
58 "beginning of the line).\n\n"
59 "Z and M values are linearly interpolated from existing values.\n\n"
60 "If a multipart geometry is encountered, only the first part is considered when "
61 "calculating the substring." );
64 QString QgsLineSubstringAlgorithm::shortDescription()
const
66 return QObject::tr(
"Returns the substring of lines which fall between start and end distances." );
69 QList<int> QgsLineSubstringAlgorithm::inputLayerTypes()
const
79 QgsLineSubstringAlgorithm *QgsLineSubstringAlgorithm::createInstance()
const
81 return new QgsLineSubstringAlgorithm();
84 void QgsLineSubstringAlgorithm::initParameters(
const QVariantMap & )
86 std::unique_ptr< QgsProcessingParameterDistance> startDistance = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"START_DISTANCE" ),
87 QObject::tr(
"Start distance" ), 0.0, QStringLiteral(
"INPUT" ),
false, 0 );
88 startDistance->setIsDynamic(
true );
90 startDistance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
91 addParameter( startDistance.release() );
93 std::unique_ptr< QgsProcessingParameterDistance> endDistance = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"END_DISTANCE" ),
94 QObject::tr(
"End distance" ), 1.0, QStringLiteral(
"INPUT" ),
false, 0 );
95 endDistance->setIsDynamic(
true );
97 endDistance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
98 addParameter( endDistance.release() );
109 mStartDistance = parameterAsDouble( parameters, QStringLiteral(
"START_DISTANCE" ), context );
111 if ( mDynamicStartDistance )
112 mStartDistanceProperty = parameters.value( QStringLiteral(
"START_DISTANCE" ) ).value<
QgsProperty >();
114 mEndDistance = parameterAsDouble( parameters, QStringLiteral(
"END_DISTANCE" ), context );
116 if ( mDynamicEndDistance )
117 mEndDistanceProperty = parameters.value( QStringLiteral(
"END_DISTANCE" ) ).value<
QgsProperty >();
128 double startDistance = mStartDistance;
129 if ( mDynamicStartDistance )
130 startDistance = mStartDistanceProperty.valueAsDouble( context.
expressionContext(), startDistance );
132 double endDistance = mEndDistance;
133 if ( mDynamicEndDistance )
138 curve = qgsgeometry_cast< const QgsCurve * >( geometry.
constGet() );
143 if ( collection->numGeometries() > 0 )
145 curve = qgsgeometry_cast< const QgsCurve * >( collection->geometryN( 0 ) );
151 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
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 SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool isMultipart() const SIP_HOLDGIL
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.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
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...
SourceType
Data source types enum.
@ TypeVectorLine
Vector line layers.
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.
QList< QgsFeature > QgsFeatureList