22QString QgsCreateArrayOffsetLinesAlgorithm::name()
const
24 return QStringLiteral(
"arrayoffsetlines" );
27QString QgsCreateArrayOffsetLinesAlgorithm::displayName()
const
29 return QObject::tr(
"Array of offset (parallel) lines" );
32QStringList QgsCreateArrayOffsetLinesAlgorithm::tags()
const
34 return QObject::tr(
"offset,parallel,duplicate,create,spaced,copy,features,objects,step,repeat" ).split(
',' );
37QString QgsCreateArrayOffsetLinesAlgorithm::group()
const
39 return QObject::tr(
"Vector creation" );
42QString QgsCreateArrayOffsetLinesAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorcreation" );
47QString QgsCreateArrayOffsetLinesAlgorithm::outputName()
const
49 return QObject::tr(
"Offset lines" );
52QString QgsCreateArrayOffsetLinesAlgorithm::shortHelpString()
const
54 return QObject::tr(
"This algorithm creates copies of line features in a layer, by creating multiple offset versions of each feature. "
55 "Each copy is offset by a preset distance." );
58QString QgsCreateArrayOffsetLinesAlgorithm::shortDescription()
const
60 return QObject::tr(
"Creates multiple offset copies of lines from a layer." );
68QgsCreateArrayOffsetLinesAlgorithm *QgsCreateArrayOffsetLinesAlgorithm::createInstance()
const
70 return new QgsCreateArrayOffsetLinesAlgorithm();
73void QgsCreateArrayOffsetLinesAlgorithm::initParameters(
const QVariantMap & )
75 std::unique_ptr< QgsProcessingParameterNumber > count = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"COUNT" ),
78 count->setIsDynamic(
true );
80 count->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
81 addParameter( count.release() );
83 std::unique_ptr< QgsProcessingParameterDistance > offset = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"OFFSET" ),
84 QObject::tr(
"Offset step distance" ),
85 1.0, QStringLiteral(
"INPUT" ) );
86 offset->setIsDynamic(
true );
88 offset->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
89 addParameter( offset.release() );
93 addParameter( segmentParam.release() );
95 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() );
101 addParameter( miterLimitParam.release() );
104QList<int> QgsCreateArrayOffsetLinesAlgorithm::inputLayerTypes()
const
111 mCount = parameterAsInt( parameters, QStringLiteral(
"COUNT" ), context );
114 mCountProperty = parameters.value( QStringLiteral(
"COUNT" ) ).value<
QgsProperty >();
116 mOffsetStep = parameterAsDouble( parameters, QStringLiteral(
"OFFSET" ), context );
118 if ( mDynamicOffset )
119 mOffsetStepProperty = parameters.value( QStringLiteral(
"OFFSET" ) ).value<
QgsProperty >();
121 mSegments = parameterAsInt( parameters, QStringLiteral(
"SEGMENTS" ), context );
122 mJoinStyle =
static_cast< Qgis::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
123 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
140 result.reserve( count + 1 );
142 double offsetStep = mOffsetStep;
143 if ( mDynamicOffset )
150 outAttrs << QVariant( 0 ) << QVariant( 0 );
156 for (
int i = 0; i < count; ++i )
158 offset += offsetStep;
164 outAttrs << QVariant( i + 1 ) << QVariant( offset );
166 result << offsetFeature;
177QgsFields QgsCreateArrayOffsetLinesAlgorithm::outputFields(
const QgsFields &inputFields )
const
180 output.
append(
QgsField( QStringLiteral(
"instance" ), QMetaType::Type::Int ) );
181 output.
append(
QgsField( QStringLiteral(
"offset" ), QMetaType::Type::Double ) );
@ VectorLine
Vector line layers.
JoinStyle
Join styles for buffers.
@ RegeneratesPrimaryKey
Algorithm always drops any existing primary keys or FID values and regenerates them in outputs.
QFlags< ProcessingAlgorithmDocumentationFlag > ProcessingAlgorithmDocumentationFlags
Flags describing algorithm behavior for documentation purposes.
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
@ Double
Double/float values.
QFlags< SinkFlag > SinkFlags
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
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)
@ IntegerPositiveGreaterZero
Non-zero positive integer values.
A store for object properties.
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
QList< QgsFeature > QgsFeatureList