22 QString QgsExtendLinesAlgorithm::name()
const 24 return QStringLiteral(
"extendlines" );
27 QString QgsExtendLinesAlgorithm::displayName()
const 29 return QObject::tr(
"Extend lines" );
32 QStringList QgsExtendLinesAlgorithm::tags()
const 34 return QObject::tr(
"linestring,continue,grow,extrapolate" ).split(
',' );
37 QString QgsExtendLinesAlgorithm::group()
const 39 return QObject::tr(
"Vector geometry" );
42 QString QgsExtendLinesAlgorithm::groupId()
const 44 return QStringLiteral(
"vectorgeometry" );
47 QString QgsExtendLinesAlgorithm::outputName()
const 49 return QObject::tr(
"Extended" );
52 QString 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 " 59 QString QgsExtendLinesAlgorithm::shortDescription()
const 61 return QObject::tr(
"Extends LineString geometries by extrapolating the start and end segments." );
64 QList<int> QgsExtendLinesAlgorithm::inputLayerTypes()
const 74 QgsExtendLinesAlgorithm *QgsExtendLinesAlgorithm::createInstance()
const 76 return new QgsExtendLinesAlgorithm();
79 void QgsExtendLinesAlgorithm::initParameters(
const QVariantMap & )
81 std::unique_ptr< QgsProcessingParameterDistance> startDistance = qgis::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 = qgis::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() )
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...
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.
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...
Custom exception class for processing related exceptions.
A store for object properties.
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition for a property.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
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 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...