23 QString QgsSingleSidedBufferAlgorithm::name()
const
25 return QStringLiteral(
"singlesidedbuffer" );
28 QString QgsSingleSidedBufferAlgorithm::displayName()
const
30 return QObject::tr(
"Single sided buffer" );
33 QStringList QgsSingleSidedBufferAlgorithm::tags()
const
35 return QObject::tr(
"rectangle,perpendicular,right,angles,square,quadrilateralise" ).split(
',' );
38 QString QgsSingleSidedBufferAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43 QString QgsSingleSidedBufferAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48 QString QgsSingleSidedBufferAlgorithm::shortHelpString()
const
50 return QObject::tr(
"This algorithm buffers lines by a specified distance on one "
51 "side of the line only.\n\nThe segments parameter controls "
52 "the number of line segments to use to approximate a quarter "
53 "circle when creating rounded buffers. The join style parameter "
54 "specifies whether round, miter or beveled joins should be used "
55 "when buffering corners in a line. The miter limit parameter is "
56 "only applicable for miter join styles, and controls the maximum "
57 "distance from the buffer to use when creating a mitered join." );
60 QString QgsSingleSidedBufferAlgorithm::outputName()
const
62 return QObject::tr(
"Buffered" );
65 QList<int> QgsSingleSidedBufferAlgorithm::inputLayerTypes()
const
81 QgsSingleSidedBufferAlgorithm *QgsSingleSidedBufferAlgorithm::createInstance()
const
83 return new QgsSingleSidedBufferAlgorithm();
86 void QgsSingleSidedBufferAlgorithm::initParameters(
const QVariantMap & )
88 auto bufferParam = std::make_unique < QgsProcessingParameterDistance >( QStringLiteral(
"DISTANCE" ), QObject::tr(
"Distance" ), 10, QStringLiteral(
"INPUT" ) );
89 bufferParam->setIsDynamic(
true );
91 bufferParam->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
92 addParameter( bufferParam.release() );
94 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"SIDE" ), QObject::tr(
"Side" ), QStringList() << QObject::tr(
"Left" ) << QObject::tr(
"Right" ),
false, 0 ) );
96 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"JOIN_STYLE" ), QObject::tr(
"Join style" ), QStringList() << QObject::tr(
"Round" ) << QObject::tr(
"Miter" ) << QObject::tr(
"Bevel" ),
false, 0 ) );
102 mDistance = parameterAsDouble( parameters, QStringLiteral(
"DISTANCE" ), context );
104 if ( mDynamicDistance )
105 mDistanceProperty = parameters.value( QStringLiteral(
"DISTANCE" ) ).value<
QgsProperty >();
107 mSide =
static_cast< Qgis::BufferSide>( parameterAsInt( parameters, QStringLiteral(
"SIDE" ), context ) );
108 mSegments = parameterAsInt( parameters, QStringLiteral(
"SEGMENTS" ), context );
109 mJoinStyle =
static_cast< Qgis::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
110 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
121 double distance = mDistance;
122 if ( mDynamicDistance )
123 distance = mDistanceProperty.valueAsDouble( context.
expressionContext(), distance );
126 if ( outputGeometry.
isNull() )
BufferSide
Side of line to buffer.
JoinStyle
Join styles for buffers.
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.
QgsGeometry singleSidedBuffer(double distance, int segments, Qgis::BufferSide side, Qgis::JoinStyle joinStyle=Qgis::JoinStyle::Round, double miterLimit=2.0) const
Returns a single sided buffer for a (multi)line geometry.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
A numeric parameter for processing algorithms.
@ Double
Double/float values.
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...
SourceType
Data source types enum.
@ TypeVectorLine
Vector line layers.
@ TypeVectorPolygon
Vector polygon layers.
Definition for a property.
@ Double
Double value (including negative values)
A store for object properties.
Type
The WKB type describes the number of dimensions a geometry has.
QList< QgsFeature > QgsFeatureList