22 QString QgsOffsetLinesAlgorithm::name()
const 24 return QStringLiteral(
"offsetline" );
27 QString QgsOffsetLinesAlgorithm::displayName()
const 29 return QObject::tr(
"Offset lines" );
32 QStringList QgsOffsetLinesAlgorithm::tags()
const 34 return QObject::tr(
"offset,linestring" ).split(
',' );
37 QString QgsOffsetLinesAlgorithm::group()
const 39 return QObject::tr(
"Vector geometry" );
42 QString QgsOffsetLinesAlgorithm::groupId()
const 44 return QStringLiteral(
"vectorgeometry" );
47 QString QgsOffsetLinesAlgorithm::outputName()
const 49 return QObject::tr(
"Offset" );
52 QString 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." );
62 QString QgsOffsetLinesAlgorithm::shortDescription()
const 64 return QObject::tr(
"Offsets lines by a specified distance." );
67 QgsOffsetLinesAlgorithm *QgsOffsetLinesAlgorithm::createInstance()
const 69 return new QgsOffsetLinesAlgorithm();
72 void QgsOffsetLinesAlgorithm::initParameters(
const QVariantMap & )
74 std::unique_ptr< QgsProcessingParameterDistance > offset = qgis::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 = qgis::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 = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MITER_LIMIT" ), QObject::tr(
"Miter limit" ),
QgsProcessingParameterNumber::Double, 2,
false, 1 );
89 addParameter( miterLimitParam.release() );
92 QList<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< QgsGeometry::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
111 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
123 double offset = mOffset;
124 if ( mDynamicOffset )
Base class for providing feedback from a processing algorithm.
QList< QgsFeature > QgsFeatureList
A geometry is the spatial representation of a feature.
QgsGeometry offsetCurve(double distance, int segments, JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
A store for object properties.
Double value (including negative values)
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.
JoinStyle
Join styles for buffers.
Contains information about the context in which a processing algorithm is executed.
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...