22 QString QgsTaperedBufferAlgorithm::name()
const 24 return QStringLiteral(
"taperedbuffer" );
27 QString QgsTaperedBufferAlgorithm::displayName()
const 29 return QObject::tr(
"Tapered buffers" );
32 QStringList QgsTaperedBufferAlgorithm::tags()
const 34 return QObject::tr(
"variable,distance,length,line,buffer" ).split(
',' );
37 QString QgsTaperedBufferAlgorithm::group()
const 39 return QObject::tr(
"Vector geometry" );
42 QString QgsTaperedBufferAlgorithm::groupId()
const 44 return QStringLiteral(
"vectorgeometry" );
47 QString 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 >();
82 QString 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." );
88 QList<int> QgsTaperedBufferAlgorithm::inputLayerTypes()
const 93 QgsTaperedBufferAlgorithm *QgsTaperedBufferAlgorithm::createInstance()
const 95 return new QgsTaperedBufferAlgorithm();
98 void QgsTaperedBufferAlgorithm::initParameters(
const QVariantMap & )
100 std::unique_ptr< QgsProcessingParameterNumber > startWidth = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"START_WIDTH" ),
103 startWidth->setIsDynamic(
true );
105 startWidth->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
106 addParameter( startWidth.release() );
108 std::unique_ptr< QgsProcessingParameterNumber > endWidth = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"END_WIDTH" ),
111 endWidth->setIsDynamic(
true );
113 endWidth->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
114 addParameter( endWidth.release() );
116 std::unique_ptr< QgsProcessingParameterNumber > segments = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"SEGMENTS" ),
119 segments->setIsDynamic(
true );
121 segments->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
122 addParameter( segments.release() );
131 int segments = mSegments;
132 if ( mDynamicSegments )
135 double startWidth = mStartWidth;
136 if ( mDynamicStartWidth )
137 startWidth = mStartWidthProperty.valueAsDouble( context.
expressionContext(), startWidth );
139 double endWidth = mEndWidth;
140 if ( mDynamicEndWidth )
144 if ( outputGeometry.
isNull() )
146 feedback->
reportError( QObject::tr(
"Error buffering geometry %1: %2" ).arg( feature.
id() ).arg( outputGeometry.
lastError() ) );
156 QString QgsVariableWidthBufferByMAlgorithm::name()
const 158 return QStringLiteral(
"bufferbym" );
161 QString QgsVariableWidthBufferByMAlgorithm::displayName()
const 163 return QObject::tr(
"Variable width buffer (by m-value)" );
166 QStringList QgsVariableWidthBufferByMAlgorithm::tags()
const 168 return QObject::tr(
"variable,distance,length,line,buffer" ).split(
',' );
171 QString QgsVariableWidthBufferByMAlgorithm::group()
const 173 return QObject::tr(
"Vector geometry" );
176 QString QgsVariableWidthBufferByMAlgorithm::groupId()
const 178 return QStringLiteral(
"vectorgeometry" );
181 QString QgsVariableWidthBufferByMAlgorithm::outputName()
const 183 return QObject::tr(
"Buffered" );
198 mSegments = parameterAsInt( parameters, QStringLiteral(
"Segments" ), context );
200 if ( mDynamicSegments )
201 mSegmentsProperty = parameters.value( QStringLiteral(
"Segments" ) ).value<
QgsProperty >();
206 QString QgsVariableWidthBufferByMAlgorithm::shortHelpString()
const 208 return QObject::tr(
"This algorithm creates variable width buffers along lines, using the m-value of the line geometries " 209 "as the diameter of the buffer at each vertex." );
212 QList<int> QgsVariableWidthBufferByMAlgorithm::inputLayerTypes()
const 217 QgsVariableWidthBufferByMAlgorithm *QgsVariableWidthBufferByMAlgorithm::createInstance()
const 219 return new QgsVariableWidthBufferByMAlgorithm();
222 void QgsVariableWidthBufferByMAlgorithm::initParameters(
const QVariantMap & )
224 std::unique_ptr< QgsProcessingParameterNumber > segments = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"SEGMENTS" ),
227 segments->setIsDynamic(
true );
229 segments->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
230 addParameter( segments.release() );
239 int segments = mSegments;
240 if ( mDynamicSegments )
244 if ( outputGeometry.
isNull() )
246 feedback->
reportError( QObject::tr(
"Error buffering geometry %1: %2" ).arg( feature.
id() ).arg( outputGeometry.
lastError() ) );
Base class for providing feedback from a processing algorithm.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
QList< QgsFeature > QgsFeatureList
Non-zero positive integer values.
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)
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
Type
The WKB type describes the number of dimensions a geometry has.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
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.
A store for object properties.
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition for a property.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
SourceType
Data source types enum.
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.
Contains information about the context in which a processing algorithm is executed.
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...