23QString QgsOffsetLinesAlgorithm::name()
const
25 return QStringLiteral(
"offsetline" );
28QString QgsOffsetLinesAlgorithm::displayName()
const
30 return QObject::tr(
"Offset lines" );
33QStringList QgsOffsetLinesAlgorithm::tags()
const
35 return QObject::tr(
"offset,linestring" ).split(
',' );
38QString QgsOffsetLinesAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43QString QgsOffsetLinesAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48QString QgsOffsetLinesAlgorithm::outputName()
const
50 return QObject::tr(
"Offset" );
53QString QgsOffsetLinesAlgorithm::shortHelpString()
const
55 return QObject::tr(
"This algorithm offsets lines by a specified distance. Positive distances will offset lines to the left, and negative distances "
56 "will offset to the right of lines.\n\n"
57 "The segments parameter controls the number of line segments to use to approximate a quarter circle when creating rounded offsets.\n\n"
58 "The join style parameter specifies whether round, miter or beveled joins should be used when offsetting corners in a line.\n\n"
59 "The miter limit parameter is only applicable for miter join styles, and controls the maximum distance from the offset curve to "
60 "use when creating a mitered join." );
63QString QgsOffsetLinesAlgorithm::shortDescription()
const
65 return QObject::tr(
"Offsets lines by a specified distance." );
68QIcon QgsOffsetLinesAlgorithm::icon()
const
73QString QgsOffsetLinesAlgorithm::svgIconPath()
const
78QgsOffsetLinesAlgorithm *QgsOffsetLinesAlgorithm::createInstance()
const
80 return new QgsOffsetLinesAlgorithm();
83void QgsOffsetLinesAlgorithm::initParameters(
const QVariantMap & )
85 std::unique_ptr< QgsProcessingParameterDistance > offset = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"DISTANCE" ),
86 QObject::tr(
"Distance" ),
87 10.0, QStringLiteral(
"INPUT" ) );
88 offset->setIsDynamic(
true );
90 offset->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
91 addParameter( offset.release() );
94 addParameter( segmentParam.release() );
96 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 );
97 addParameter( joinStyleParam.release() );
99 auto miterLimitParam = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MITER_LIMIT" ), QObject::tr(
"Miter limit" ),
QgsProcessingParameterNumber::Double, 2,
false, 1 );
100 addParameter( miterLimitParam.release() );
103QList<int> QgsOffsetLinesAlgorithm::inputLayerTypes()
const
115 mOffset = parameterAsDouble( parameters, QStringLiteral(
"DISTANCE" ), context );
117 if ( mDynamicOffset )
118 mOffsetProperty = parameters.value( QStringLiteral(
"DISTANCE" ) ).value<
QgsProperty >();
120 mSegments = parameterAsInt( parameters, QStringLiteral(
"SEGMENTS" ), context );
121 mJoinStyle =
static_cast< Qgis::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
122 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
134 double offset = mOffset;
135 if ( mDynamicOffset )
JoinStyle
Join styles for buffers.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
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