24using namespace Qt::StringLiterals;
28QString QgsOffsetLinesAlgorithm::name()
const
30 return u
"offsetline"_s;
33QString QgsOffsetLinesAlgorithm::displayName()
const
35 return QObject::tr(
"Offset lines" );
38QStringList QgsOffsetLinesAlgorithm::tags()
const
40 return QObject::tr(
"offset,linestring" ).split(
',' );
43QString QgsOffsetLinesAlgorithm::group()
const
45 return QObject::tr(
"Vector geometry" );
48QString QgsOffsetLinesAlgorithm::groupId()
const
50 return u
"vectorgeometry"_s;
53QString QgsOffsetLinesAlgorithm::outputName()
const
55 return QObject::tr(
"Offset" );
58QString QgsOffsetLinesAlgorithm::shortHelpString()
const
60 return QObject::tr(
"This algorithm offsets lines by a specified distance. Positive distances will offset lines to the left, and negative distances "
61 "will offset to the right of lines.\n\n"
62 "The segments parameter controls the number of line segments to use to approximate a quarter circle when creating rounded offsets.\n\n"
63 "The join style parameter specifies whether round, miter or beveled joins should be used when offsetting corners in a line.\n\n"
64 "The miter limit parameter is only applicable for miter join styles, and controls the maximum distance from the offset curve to "
65 "use when creating a mitered join." );
68QString QgsOffsetLinesAlgorithm::shortDescription()
const
70 return QObject::tr(
"Offsets lines by a specified distance." );
73QIcon QgsOffsetLinesAlgorithm::icon()
const
78QString QgsOffsetLinesAlgorithm::svgIconPath()
const
83QgsOffsetLinesAlgorithm *QgsOffsetLinesAlgorithm::createInstance()
const
85 return new QgsOffsetLinesAlgorithm();
88void QgsOffsetLinesAlgorithm::initParameters(
const QVariantMap & )
90 auto offset = std::make_unique<QgsProcessingParameterDistance>( u
"DISTANCE"_s, QObject::tr(
"Distance" ), 10.0, u
"INPUT"_s );
91 offset->setIsDynamic(
true );
93 offset->setDynamicLayerParameterName( u
"INPUT"_s );
94 addParameter( offset.release() );
97 addParameter( segmentParam.release() );
99 auto joinStyleParam = std::make_unique<QgsProcessingParameterEnum>( u
"JOIN_STYLE"_s, QObject::tr(
"Join style" ), QStringList() << QObject::tr(
"Round" ) << QObject::tr(
"Miter" ) << QObject::tr(
"Bevel" ),
false, 0 );
100 addParameter( joinStyleParam.release() );
103 addParameter( miterLimitParam.release() );
106QList<int> QgsOffsetLinesAlgorithm::inputLayerTypes()
const
118 mOffset = parameterAsDouble( parameters, u
"DISTANCE"_s, context );
120 if ( mDynamicOffset )
121 mOffsetProperty = parameters.value( u
"DISTANCE"_s ).value<
QgsProperty>();
123 mSegments = parameterAsInt( parameters, u
"SEGMENTS"_s, context );
124 mJoinStyle =
static_cast<Qgis::JoinStyle>( 1 + parameterAsInt( parameters, u
"JOIN_STYLE"_s, context ) );
125 mMiterLimit = parameterAsDouble( parameters, u
"MITER_LIMIT"_s, context );
137 double offset = mOffset;
138 if ( mDynamicOffset )
ProcessingSourceType
Processing data source types.
@ VectorLine
Vector line layers.
JoinStyle
Join styles for buffers.
@ Double
Double/float values.
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.
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...
Definition for a property.
@ Double
Double value (including negative values).
A store for object properties.
QList< QgsFeature > QgsFeatureList