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 = std::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 = std::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 = std::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 = std::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() ) );