22using namespace Qt::StringLiterals;
26QString QgsExtendLinesAlgorithm::name()
const
28 return u
"extendlines"_s;
31QString QgsExtendLinesAlgorithm::displayName()
const
33 return QObject::tr(
"Extend lines" );
36QStringList QgsExtendLinesAlgorithm::tags()
const
38 return QObject::tr(
"linestring,continue,grow,extrapolate" ).split(
',' );
41QString QgsExtendLinesAlgorithm::group()
const
43 return QObject::tr(
"Vector geometry" );
46QString QgsExtendLinesAlgorithm::groupId()
const
48 return u
"vectorgeometry"_s;
51QString QgsExtendLinesAlgorithm::outputName()
const
53 return QObject::tr(
"Extended" );
56QString QgsExtendLinesAlgorithm::shortHelpString()
const
58 return QObject::tr(
"This algorithm extends line geometries by a specified amount at the start and end "
59 "of the line. Lines are extended using the bearing of the first and last segment "
63QString QgsExtendLinesAlgorithm::shortDescription()
const
65 return QObject::tr(
"Extends LineString geometries by extrapolating the start and end segments." );
68QList<int> QgsExtendLinesAlgorithm::inputLayerTypes()
const
78QgsExtendLinesAlgorithm *QgsExtendLinesAlgorithm::createInstance()
const
80 return new QgsExtendLinesAlgorithm();
83void QgsExtendLinesAlgorithm::initParameters(
const QVariantMap & )
85 auto startDistance = std::make_unique<QgsProcessingParameterDistance>( u
"START_DISTANCE"_s, QObject::tr(
"Start distance" ), 0.0, u
"INPUT"_s,
false, 0 );
86 startDistance->setIsDynamic(
true );
88 startDistance->setDynamicLayerParameterName( u
"INPUT"_s );
89 addParameter( startDistance.release() );
91 auto endDistance = std::make_unique<QgsProcessingParameterDistance>( u
"END_DISTANCE"_s, QObject::tr(
"End distance" ), 0.0, u
"INPUT"_s,
false, 0 );
92 endDistance->setIsDynamic(
true );
94 endDistance->setDynamicLayerParameterName( u
"INPUT"_s );
95 addParameter( endDistance.release() );
106 mStartDistance = parameterAsDouble( parameters, u
"START_DISTANCE"_s, context );
108 if ( mDynamicStartDistance )
109 mStartDistanceProperty = parameters.value( u
"START_DISTANCE"_s ).value<
QgsProperty>();
111 mEndDistance = parameterAsDouble( parameters, u
"END_DISTANCE"_s, context );
113 if ( mDynamicEndDistance )
114 mEndDistanceProperty = parameters.value( u
"END_DISTANCE"_s ).value<
QgsProperty>();
125 double startDistance = mStartDistance;
126 if ( mDynamicStartDistance )
127 startDistance = mStartDistanceProperty.valueAsDouble( context.
expressionContext(), startDistance );
129 double endDistance = mEndDistance;
130 if ( mDynamicEndDistance )
134 if ( outGeometry.
isNull() )
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.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
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.
QgsGeometry extendLine(double startDistance, double endDistance) const
Extends a (multi)line geometry by extrapolating out the start or end of the line by a specified dista...
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Custom exception class for processing related exceptions.
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.
QList< QgsFeature > QgsFeatureList