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 = qgis::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 = qgis::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 )
151 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
Base class for providing feedback from a processing algorithm.
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QList< QgsFeature > QgsFeatureList
A geometry is the spatial representation of a feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Positive double value (including 0)
bool hasGeometry() const
Returns true if the feature has an associated geometry.
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
Abstract base class for curved geometry type.
A store for object properties.
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition for a property.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
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.
void clearGeometry()
Removes any geometry associated with the feature.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
SourceType
Data source types enum.
Contains information about the context in which a processing algorithm is executed.
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...