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 = std::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 = std::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 = std::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< Qgis::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral(
"JOIN_STYLE" ), context ) );
111 mMiterLimit = parameterAsDouble( parameters, QStringLiteral(
"MITER_LIMIT" ), context );
123 double offset = mOffset;
124 if ( mDynamicOffset )