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() )