22QString QgsExtendLinesAlgorithm::name()
const
24 return QStringLiteral(
"extendlines" );
27QString QgsExtendLinesAlgorithm::displayName()
const
29 return QObject::tr(
"Extend lines" );
32QStringList QgsExtendLinesAlgorithm::tags()
const
34 return QObject::tr(
"linestring,continue,grow,extrapolate" ).split(
',' );
37QString QgsExtendLinesAlgorithm::group()
const
39 return QObject::tr(
"Vector geometry" );
42QString QgsExtendLinesAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47QString QgsExtendLinesAlgorithm::outputName()
const
49 return QObject::tr(
"Extended" );
52QString QgsExtendLinesAlgorithm::shortHelpString()
const
54 return QObject::tr(
"This algorithm extends line geometries by a specified amount at the start and end "
55 "of the line. Lines are extended using the bearing of the first and last segment "
59QString QgsExtendLinesAlgorithm::shortDescription()
const
61 return QObject::tr(
"Extends LineString geometries by extrapolating the start and end segments." );
64QList<int> QgsExtendLinesAlgorithm::inputLayerTypes()
const
74QgsExtendLinesAlgorithm *QgsExtendLinesAlgorithm::createInstance()
const
76 return new QgsExtendLinesAlgorithm();
79void QgsExtendLinesAlgorithm::initParameters(
const QVariantMap & )
81 std::unique_ptr< QgsProcessingParameterDistance> startDistance = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"START_DISTANCE" ),
82 QObject::tr(
"Start distance" ), 0.0, QStringLiteral(
"INPUT" ),
false, 0 );
83 startDistance->setIsDynamic(
true );
85 startDistance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
86 addParameter( startDistance.release() );
88 std::unique_ptr< QgsProcessingParameterDistance> endDistance = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"END_DISTANCE" ),
89 QObject::tr(
"End distance" ), 0.0, QStringLiteral(
"INPUT" ),
false, 0 );
90 endDistance->setIsDynamic(
true );
92 endDistance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
93 addParameter( endDistance.release() );
104 mStartDistance = parameterAsDouble( parameters, QStringLiteral(
"START_DISTANCE" ), context );
106 if ( mDynamicStartDistance )
107 mStartDistanceProperty = parameters.value( QStringLiteral(
"START_DISTANCE" ) ).value<
QgsProperty >();
109 mEndDistance = parameterAsDouble( parameters, QStringLiteral(
"END_DISTANCE" ), context );
111 if ( mDynamicEndDistance )
112 mEndDistanceProperty = parameters.value( QStringLiteral(
"END_DISTANCE" ) ).value<
QgsProperty >();
123 double startDistance = mStartDistance;
124 if ( mDynamicStartDistance )
125 startDistance = mStartDistanceProperty.valueAsDouble( context.
expressionContext(), startDistance );
127 double endDistance = mEndDistance;
128 if ( mDynamicEndDistance )
132 if ( outGeometry.
isNull() )
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.
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