22QString QgsTaperedBufferAlgorithm::name()
const
24 return QStringLiteral(
"taperedbuffer" );
27QString QgsTaperedBufferAlgorithm::displayName()
const
29 return QObject::tr(
"Tapered buffers" );
32QStringList QgsTaperedBufferAlgorithm::tags()
const
34 return QObject::tr(
"variable,distance,length,line,buffer" ).split(
',' );
37QString QgsTaperedBufferAlgorithm::group()
const
39 return QObject::tr(
"Vector geometry" );
42QString QgsTaperedBufferAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47QString QgsTaperedBufferAlgorithm::outputName()
const
49 return QObject::tr(
"Buffered" );
64 mStartWidth = parameterAsDouble( parameters, QStringLiteral(
"START_WIDTH" ), context );
66 if ( mDynamicStartWidth )
67 mStartWidthProperty = parameters.value( QStringLiteral(
"START_WIDTH" ) ).value<
QgsProperty>();
69 mEndWidth = parameterAsDouble( parameters, QStringLiteral(
"END_WIDTH" ), context );
71 if ( mDynamicEndWidth )
72 mEndWidthProperty = parameters.value( QStringLiteral(
"END_WIDTH" ) ).value<
QgsProperty>();
74 mSegments = parameterAsInt( parameters, QStringLiteral(
"Segments" ), context );
76 if ( mDynamicSegments )
77 mSegmentsProperty = parameters.value( QStringLiteral(
"Segments" ) ).value<
QgsProperty>();
82QString QgsTaperedBufferAlgorithm::shortHelpString()
const
84 return QObject::tr(
"This algorithm creates tapered buffers along line geometries, using a specified start and "
85 "end buffer diameter corresponding to the buffer diameter at the start and end of the linestrings." );
88QList<int> QgsTaperedBufferAlgorithm::inputLayerTypes()
const
93QgsTaperedBufferAlgorithm *QgsTaperedBufferAlgorithm::createInstance()
const
95 return new QgsTaperedBufferAlgorithm();
98void QgsTaperedBufferAlgorithm::initParameters(
const QVariantMap & )
100 std::unique_ptr<QgsProcessingParameterNumber> startWidth = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"START_WIDTH" ), QObject::tr(
"Start width" ),
Qgis::ProcessingNumberParameterType::Double, 0.0,
false, 0.0 );
101 startWidth->setIsDynamic(
true );
103 startWidth->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
104 addParameter( startWidth.release() );
106 std::unique_ptr<QgsProcessingParameterNumber> endWidth = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"END_WIDTH" ), QObject::tr(
"End width" ),
Qgis::ProcessingNumberParameterType::Double, 1,
false, 0.0 );
107 endWidth->setIsDynamic(
true );
109 endWidth->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
110 addParameter( endWidth.release() );
112 std::unique_ptr<QgsProcessingParameterNumber> segments = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"SEGMENTS" ), QObject::tr(
"Segments" ),
Qgis::ProcessingNumberParameterType::Integer, 16,
false, 1 );
113 segments->setIsDynamic(
true );
115 segments->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
116 addParameter( segments.release() );
125 int segments = mSegments;
126 if ( mDynamicSegments )
129 double startWidth = mStartWidth;
130 if ( mDynamicStartWidth )
131 startWidth = mStartWidthProperty.valueAsDouble( context.
expressionContext(), startWidth );
133 double endWidth = mEndWidth;
134 if ( mDynamicEndWidth )
138 if ( outputGeometry.
isNull() )
140 feedback->
reportError( QObject::tr(
"Error buffering geometry %1: %2" ).arg( feature.
id() ).arg( outputGeometry.
lastError() ) );
148QString QgsVariableWidthBufferByMAlgorithm::name()
const
150 return QStringLiteral(
"bufferbym" );
153QString QgsVariableWidthBufferByMAlgorithm::displayName()
const
155 return QObject::tr(
"Variable width buffer (by M value)" );
158QStringList QgsVariableWidthBufferByMAlgorithm::tags()
const
160 return QObject::tr(
"variable,distance,length,line,buffer" ).split(
',' );
163QString QgsVariableWidthBufferByMAlgorithm::group()
const
165 return QObject::tr(
"Vector geometry" );
168QString QgsVariableWidthBufferByMAlgorithm::groupId()
const
170 return QStringLiteral(
"vectorgeometry" );
173QString QgsVariableWidthBufferByMAlgorithm::outputName()
const
175 return QObject::tr(
"Buffered" );
190 mSegments = parameterAsInt( parameters, QStringLiteral(
"Segments" ), context );
192 if ( mDynamicSegments )
193 mSegmentsProperty = parameters.value( QStringLiteral(
"Segments" ) ).value<
QgsProperty>();
198QString QgsVariableWidthBufferByMAlgorithm::shortHelpString()
const
200 return QObject::tr(
"This algorithm creates variable width buffers along lines, using the M value of the line geometries "
201 "as the diameter of the buffer at each vertex." );
204QList<int> QgsVariableWidthBufferByMAlgorithm::inputLayerTypes()
const
209QgsVariableWidthBufferByMAlgorithm *QgsVariableWidthBufferByMAlgorithm::createInstance()
const
211 return new QgsVariableWidthBufferByMAlgorithm();
214void QgsVariableWidthBufferByMAlgorithm::initParameters(
const QVariantMap & )
216 std::unique_ptr<QgsProcessingParameterNumber> segments = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"SEGMENTS" ), QObject::tr(
"Segments" ),
Qgis::ProcessingNumberParameterType::Integer, 16,
false, 1 );
217 segments->setIsDynamic(
true );
219 segments->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
220 addParameter( segments.release() );
229 int segments = mSegments;
230 if ( mDynamicSegments )
234 if ( outputGeometry.
isNull() )
236 feedback->
reportError( QObject::tr(
"Error buffering geometry %1: %2" ).arg( feature.
id() ).arg( outputGeometry.
lastError() ) );
ProcessingSourceType
Processing data source types.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
WkbType
The WKB type describes the number of dimensions a geometry has.
@ MultiPolygon
MultiPolygon.
@ Double
Double/float values.
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.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
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.
@ IntegerPositiveGreaterZero
Non-zero positive integer values.
@ 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.
int valueAsInt(const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an integer.
QList< QgsFeature > QgsFeatureList