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 = qgis::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< QgsGeometry::BufferSide>( parameterAsInt( parameters, QStringLiteral(
"SIDE" ), context ) );
108 mSegments = parameterAsInt( parameters, QStringLiteral(
"SEGMENTS" ), context );
109 mJoinStyle =
static_cast< QgsGeometry::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() )