22 QString QgsCreateArrayOffsetLinesAlgorithm::name()
const 24 return QStringLiteral(
"arrayoffsetlines" );
27 QString QgsCreateArrayOffsetLinesAlgorithm::displayName()
const 29 return QObject::tr(
"Array of offset (parallel) lines" );
32 QStringList QgsCreateArrayOffsetLinesAlgorithm::tags()
const 34 return QObject::tr(
"offset,parallel,duplicate,create,spaced,copy,features,objects,step,repeat" ).split(
',' );
37 QString QgsCreateArrayOffsetLinesAlgorithm::group()
const 39 return QObject::tr(
"Vector creation" );
42 QString QgsCreateArrayOffsetLinesAlgorithm::groupId()
const 44 return QStringLiteral(
"vectorcreation" );
47 QString QgsCreateArrayOffsetLinesAlgorithm::outputName()
const 49 return QObject::tr(
"Offset lines" );
52 QString 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." );
58 QString QgsCreateArrayOffsetLinesAlgorithm::shortDescription()
const 60 return QObject::tr(
"Creates multiple offset copies of lines from a layer." );
63 QgsCreateArrayOffsetLinesAlgorithm *QgsCreateArrayOffsetLinesAlgorithm::createInstance()
const 65 return new QgsCreateArrayOffsetLinesAlgorithm();
68 void QgsCreateArrayOffsetLinesAlgorithm::initParameters(
const QVariantMap & )
70 std::unique_ptr< QgsProcessingParameterNumber > count = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"COUNT" ),
73 count->setIsDynamic(
true );
75 count->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
76 addParameter( count.release() );
78 std::unique_ptr< QgsProcessingParameterDistance > offset = qgis::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"OFFSET" ),
79 QObject::tr(
"Offset step distance" ),
80 1.0, QStringLiteral(
"INPUT" ) );
81 offset->setIsDynamic(
true );
83 offset->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
84 addParameter( offset.release() );
88 addParameter( segmentParam.release() );
90 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 );
92 addParameter( joinStyleParam.release() );
94 auto miterLimitParam = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MITER_LIMIT" ), QObject::tr(
"Miter limit" ),
QgsProcessingParameterNumber::Double, 2,
false, 1 );
96 addParameter( miterLimitParam.release() );
99 QList<int> QgsCreateArrayOffsetLinesAlgorithm::inputLayerTypes()
const 106 mCount = parameterAsInt( parameters, QStringLiteral(
"COUNT" ), context );
109 mCountProperty = parameters.value( QStringLiteral(
"COUNT" ) ).value<
QgsProperty >();
111 mOffsetStep = parameterAsDouble( parameters, QStringLiteral(
"OFFSET" ), context );
113 if ( mDynamicOffset )
114 mOffsetStepProperty = parameters.value( QStringLiteral(
"OFFSET" ) ).value<
QgsProperty >();
116 mSegments = parameterAsInt( parameters, QStringLiteral(
"SEGMENTS" ), context );
117 mJoinStyle =
static_cast< QgsGeometry::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
118 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
135 result.reserve( count + 1 );
137 double offsetStep = mOffsetStep;
138 if ( mDynamicOffset )
145 outAttrs << QVariant( 0 ) << QVariant( 0 );
151 for (
int i = 0; i < count; ++i )
153 offset += offsetStep;
159 outAttrs << QVariant( i + 1 ) << QVariant( offset );
161 result << offsetFeature;
172 QgsFields QgsCreateArrayOffsetLinesAlgorithm::outputFields(
const QgsFields &inputFields )
const 175 output.
append(
QgsField( QStringLiteral(
"instance" ), QVariant::Int ) );
176 output.
append(
QgsField( QStringLiteral(
"offset" ), QVariant::Double ) );
180 QgsFeatureSink::SinkFlags QgsCreateArrayOffsetLinesAlgorithm::sinkFlags()
const Base class for providing feedback from a processing algorithm.
Parameter is an advanced parameter which should be hidden from users by default.
QList< QgsFeature > QgsFeatureList
Non-zero positive integer values.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
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.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false) ...
Encapsulate a field in an attribute table or data source.
A store for object properties.
Double value (including negative values)
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition for a property.
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.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
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...