22QString QgsOffsetLinesAlgorithm::name()
const
24 return QStringLiteral(
"offsetline" );
27QString QgsOffsetLinesAlgorithm::displayName()
const
29 return QObject::tr(
"Offset lines" );
32QStringList QgsOffsetLinesAlgorithm::tags()
const
34 return QObject::tr(
"offset,linestring" ).split(
',' );
37QString QgsOffsetLinesAlgorithm::group()
const
39 return QObject::tr(
"Vector geometry" );
42QString QgsOffsetLinesAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47QString QgsOffsetLinesAlgorithm::outputName()
const
49 return QObject::tr(
"Offset" );
52QString QgsOffsetLinesAlgorithm::shortHelpString()
const
54 return QObject::tr(
"This algorithm offsets lines by a specified distance. Positive distances will offset lines to the left, and negative distances "
55 "will offset to the right of lines.\n\n"
56 "The segments parameter controls the number of line segments to use to approximate a quarter circle when creating rounded offsets.\n\n"
57 "The join style parameter specifies whether round, miter or beveled joins should be used when offsetting corners in a line.\n\n"
58 "The miter limit parameter is only applicable for miter join styles, and controls the maximum distance from the offset curve to "
59 "use when creating a mitered join." );
62QString QgsOffsetLinesAlgorithm::shortDescription()
const
64 return QObject::tr(
"Offsets lines by a specified distance." );
67QgsOffsetLinesAlgorithm *QgsOffsetLinesAlgorithm::createInstance()
const
69 return new QgsOffsetLinesAlgorithm();
72void QgsOffsetLinesAlgorithm::initParameters(
const QVariantMap & )
74 std::unique_ptr< QgsProcessingParameterDistance > offset = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"DISTANCE" ),
75 QObject::tr(
"Distance" ),
76 10.0, QStringLiteral(
"INPUT" ) );
77 offset->setIsDynamic(
true );
79 offset->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
80 addParameter( offset.release() );
83 addParameter( segmentParam.release() );
85 auto joinStyleParam = std::make_unique< QgsProcessingParameterEnum>( QStringLiteral(
"JOIN_STYLE" ), QObject::tr(
"Join style" ), QStringList() << QObject::tr(
"Round" ) << QObject::tr(
"Miter" ) << QObject::tr(
"Bevel" ),
false, 0 );
86 addParameter( joinStyleParam.release() );
88 auto miterLimitParam = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MITER_LIMIT" ), QObject::tr(
"Miter limit" ),
QgsProcessingParameterNumber::Double, 2,
false, 1 );
89 addParameter( miterLimitParam.release() );
92QList<int> QgsOffsetLinesAlgorithm::inputLayerTypes()
const
104 mOffset = parameterAsDouble( parameters, QStringLiteral(
"DISTANCE" ), context );
106 if ( mDynamicOffset )
107 mOffsetProperty = parameters.value( QStringLiteral(
"DISTANCE" ) ).value<
QgsProperty >();
109 mSegments = parameterAsInt( parameters, QStringLiteral(
"SEGMENTS" ), context );
110 mJoinStyle =
static_cast< Qgis::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
111 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
123 double offset = mOffset;
124 if ( mDynamicOffset )
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 offsetCurve(double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
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.
@ 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.
Definition for a property.
@ Double
Double value (including negative values)
A store for object properties.
QList< QgsFeature > QgsFeatureList