[FEATURE][processing] "Create parallel lines" algorithm

This algorithm creates copies of line features in a layer, by
creating multiple parallel versions of each feature. Each copy is offset
by a preset distance.
This commit is contained in:
Nyall Dawson 2018-07-27 10:31:14 +10:00
parent b80ad5e96e
commit 76c84f14d7
8 changed files with 502 additions and 3 deletions

View File

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ create_parallel_lines.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-1</gml:X><gml:Y>-3.6</gml:Y></gml:coord>
<gml:coord><gml:X>11.42426406871193</gml:X><gml:Y>5</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,2 9,2 9,3 11,5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>0</ogr:instance>
<ogr:offset>0</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>11.1414213562373,4.85857864376269 9.2,2.91715728752538 9.2,1.8 6.0,1.8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>1</ogr:instance>
<ogr:offset>-0.2</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>11.2828427124746,4.71715728752538 9.4,2.83431457505076 9.4,1.6 6.0,1.6</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>2</ogr:instance>
<ogr:offset>-0.4</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>11.4242640687119,4.57573593128807 9.6,2.75147186257614 9.6,1.4 6.0,1.4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>3</ogr:instance>
<ogr:offset>-0.6</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.1">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>-1,-1 1,-1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>0</ogr:instance>
<ogr:offset>0</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.1">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1.0,-1.2 -1.0,-1.2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>1</ogr:instance>
<ogr:offset>-0.2</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.1">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1.0,-1.4 -1.0,-1.4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>2</ogr:instance>
<ogr:offset>-0.4</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.1">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1.0,-1.6 -1.0,-1.6</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>3</ogr:instance>
<ogr:offset>-0.6</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>2,0 2,2 3,2 3,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>0</ogr:instance>
<ogr:offset>0</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3.2,3.0 3.2,1.8 2.8,1.8 2.2,1.8 2.2,0.0</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>1</ogr:instance>
<ogr:offset>-0.2</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3.4,3.0 3.4,1.6 2.93333333333333,1.6 2.4,1.6 2.4,0.0</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>2</ogr:instance>
<ogr:offset>-0.4</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3.6,3.0 3.6,1.4 3.06666666666667,1.4 2.6,1.4 2.6,0.0</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>3</ogr:instance>
<ogr:offset>-0.6</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.3">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3,1 5,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>0</ogr:instance>
<ogr:offset>0</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.3">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5.0,0.8 3.0,0.8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>1</ogr:instance>
<ogr:offset>-0.2</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.3">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5.0,0.6 3.0,0.6</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>2</ogr:instance>
<ogr:offset>-0.4</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.3">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5.0,0.4 3.0,0.4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>3</ogr:instance>
<ogr:offset>-0.6</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-3 10,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>0</ogr:instance>
<ogr:offset>0</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.0,-3.2 7.0,-3.2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>1</ogr:instance>
<ogr:offset>-0.2</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.0,-3.4 7.0,-3.4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>2</ogr:instance>
<ogr:offset>-0.4</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.0,-3.6 7.0,-3.6</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>3</ogr:instance>
<ogr:offset>-0.6</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,-3 10,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>0</ogr:instance>
<ogr:offset>0</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.1414213562373,0.858578643762691 6.14142135623731,-3.14142135623731</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>1</ogr:instance>
<ogr:offset>-0.2</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.2828427124746,0.717157287525381 6.28284271247462,-3.28284271247462</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>2</ogr:instance>
<ogr:offset>-0.4</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.4242640687119,0.575735931288071 6.42426406871193,-3.42426406871193</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:instance>3</ogr:instance>
<ogr:offset>-0.6</ogr:offset>
</ogr:create_parallel_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:create_parallel_lines fid="lines.6">
<ogr:instance xsi:nil="true"/>
<ogr:offset xsi:nil="true"/>
</ogr:create_parallel_lines>
</gml:featureMember>
</ogr:FeatureCollection>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="create_parallel_lines" type="ogr:create_parallel_lines_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="create_parallel_lines_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="instance" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="offset" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

View File

@ -5908,5 +5908,20 @@ tests:
name: expected/feature_array.shp
type: vector
- algorithm: native:parallellines
name: Create parallel lines
params:
COUNT: 3
INPUT:
name: lines.gml
type: vector
JOIN_STYLE: 1
MITER_LIMIT: 2.0
OFFSET: -0.2
SEGMENTS: 8
results:
OUTPUT:
name: expected/create_parallel_lines.gml
type: vector
# See ../README.md for a description of the file format

View File

@ -61,6 +61,7 @@ SET(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmorderbyexpression.cpp
processing/qgsalgorithmorientedminimumboundingbox.cpp
processing/qgsalgorithmpackage.cpp
processing/qgsalgorithmparallellines.cpp
processing/qgsalgorithmpointonsurface.cpp
processing/qgsalgorithmprojectpointcartesian.cpp
processing/qgsalgorithmpromotetomultipart.cpp

View File

@ -36,12 +36,12 @@ QStringList QgsArrayFeaturesAlgorithm::tags() const
QString QgsArrayFeaturesAlgorithm::group() const
{
return QObject::tr( "Vector geometry" );
return QObject::tr( "Vector creation" );
}
QString QgsArrayFeaturesAlgorithm::groupId() const
{
return QStringLiteral( "vectorgeometry" );
return QStringLiteral( "vectorcreation" );
}
QString QgsArrayFeaturesAlgorithm::outputName() const
@ -69,7 +69,7 @@ void QgsArrayFeaturesAlgorithm::initParameters( const QVariantMap & )
{
std::unique_ptr< QgsProcessingParameterNumber > count = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "COUNT" ),
QObject::tr( "Number of features to create" ), QgsProcessingParameterNumber::Integer,
10, true, 1 );
10, false, 1 );
count->setIsDynamic( true );
count->setDynamicPropertyDefinition( QgsPropertyDefinition( QStringLiteral( "COUNT" ), QObject::tr( "Number of features to create" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) );
count->setDynamicLayerParameterName( QStringLiteral( "INPUT" ) );

View File

@ -0,0 +1,181 @@
/***************************************************************************
qgsalgorithmparallellines.cpp
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsalgorithmparallellines.h"
///@cond PRIVATE
QString QgsCreateParallelLinesAlgorithm::name() const
{
return QStringLiteral( "parallellines" );
}
QString QgsCreateParallelLinesAlgorithm::displayName() const
{
return QObject::tr( "Create parallel lines" );
}
QStringList QgsCreateParallelLinesAlgorithm::tags() const
{
return QObject::tr( "offset,duplicate,create,spaced,copy,features,objects,step,repeat" ).split( ',' );
}
QString QgsCreateParallelLinesAlgorithm::group() const
{
return QObject::tr( "Vector creation" );
}
QString QgsCreateParallelLinesAlgorithm::groupId() const
{
return QStringLiteral( "vectorcreation" );
}
QString QgsCreateParallelLinesAlgorithm::outputName() const
{
return QObject::tr( "Parallel lines" );
}
QString QgsCreateParallelLinesAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm creates copies of line features in a layer, by creating multiple parallel versions of each feature. "
"Each copy is offset by a preset distance." );
}
QString QgsCreateParallelLinesAlgorithm::shortDescription() const
{
return QObject::tr( "Creates multiple parallel copies of lines from a layer." );
}
QgsCreateParallelLinesAlgorithm *QgsCreateParallelLinesAlgorithm::createInstance() const
{
return new QgsCreateParallelLinesAlgorithm();
}
void QgsCreateParallelLinesAlgorithm::initParameters( const QVariantMap & )
{
std::unique_ptr< QgsProcessingParameterNumber > count = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "COUNT" ),
QObject::tr( "Number of features to create" ), QgsProcessingParameterNumber::Integer,
10, false, 1 );
count->setIsDynamic( true );
count->setDynamicPropertyDefinition( QgsPropertyDefinition( QStringLiteral( "COUNT" ), QObject::tr( "Number of features to create" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) );
count->setDynamicLayerParameterName( QStringLiteral( "INPUT" ) );
addParameter( count.release() );
std::unique_ptr< QgsProcessingParameterDistance > offset = qgis::make_unique< QgsProcessingParameterDistance >( QStringLiteral( "OFFSET" ),
QObject::tr( "Offset step distance" ),
1.0, QStringLiteral( "INPUT" ) );
offset->setIsDynamic( true );
offset->setDynamicPropertyDefinition( QgsPropertyDefinition( QStringLiteral( "OFFSET" ), QObject::tr( "Step distance" ), QgsPropertyDefinition::Double ) );
offset->setDynamicLayerParameterName( QStringLiteral( "INPUT" ) );
addParameter( offset.release() );
auto segmentParam = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "SEGMENTS" ), QObject::tr( "Segments" ), QgsProcessingParameterNumber::Integer, 8, false, 1 );
segmentParam->setFlags( segmentParam->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( segmentParam.release() );
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 );
joinStyleParam->setFlags( joinStyleParam->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( joinStyleParam.release() );
auto miterLimitParam = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "MITER_LIMIT" ), QObject::tr( "Miter limit" ), QgsProcessingParameterNumber::Double, 2, false, 1 );
miterLimitParam->setFlags( miterLimitParam->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( miterLimitParam.release() );
}
QList<int> QgsCreateParallelLinesAlgorithm::inputLayerTypes() const
{
return QList< int >() << QgsProcessing::TypeVectorLine;
}
bool QgsCreateParallelLinesAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
{
mCount = parameterAsInt( parameters, QStringLiteral( "COUNT" ), context );
mDynamicCount = QgsProcessingParameters::isDynamic( parameters, QStringLiteral( "COUNT" ) );
if ( mDynamicCount )
mCountProperty = parameters.value( QStringLiteral( "COUNT" ) ).value< QgsProperty >();
mOffsetStep = parameterAsDouble( parameters, QStringLiteral( "OFFSET" ), context );
mDynamicOffset = QgsProcessingParameters::isDynamic( parameters, QStringLiteral( "OFFSET" ) );
if ( mDynamicOffset )
mOffsetStepProperty = parameters.value( QStringLiteral( "OFFSET" ) ).value< QgsProperty >();
mSegments = parameterAsInt( parameters, QStringLiteral( "SEGMENTS" ), context );
mJoinStyle = static_cast< QgsGeometry::JoinStyle>( 1 + parameterAsInt( parameters, QStringLiteral( "JOIN_STYLE" ), context ) );
mMiterLimit = parameterAsDouble( parameters, QStringLiteral( "MITER_LIMIT" ), context );
return true;
}
QgsFeatureList QgsCreateParallelLinesAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback * )
{
QgsFeatureList result = QgsFeatureList();
if ( feature.hasGeometry() )
{
const QgsGeometry geometry = feature.geometry();
const QgsAttributes attr = feature.attributes();
int count = mCount;
if ( mDynamicCount )
count = mCountProperty.valueAsInt( context.expressionContext(), count );
result.reserve( count + 1 );
double offsetStep = mOffsetStep;
if ( mDynamicOffset )
offsetStep = mOffsetStepProperty.valueAsDouble( context.expressionContext(), offsetStep );
{
QgsFeature original = feature;
original.setGeometry( geometry );
QgsAttributes outAttrs = attr;
outAttrs << QVariant( 0 ) << QVariant( 0 );
original.setAttributes( outAttrs );
result << original;
}
double offset = 0;
for ( int i = 0; i < count; ++i )
{
offset += offsetStep;
QgsFeature offsetFeature = feature;
const QgsGeometry offsetGeometry = geometry.offsetCurve( offset, mSegments, mJoinStyle, mMiterLimit );
offsetFeature.setGeometry( offsetGeometry );
QgsAttributes outAttrs = attr;
outAttrs << QVariant( i + 1 ) << QVariant( offset );
offsetFeature.setAttributes( outAttrs );
result << offsetFeature;
}
}
else
{
result << feature;
}
return result;
}
QgsFields QgsCreateParallelLinesAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields output = inputFields;
output.append( QgsField( QStringLiteral( "instance" ), QVariant::Int ) );
output.append( QgsField( QStringLiteral( "offset" ), QVariant::Double ) );
return output;
}
///@endcond

View File

@ -0,0 +1,76 @@
/***************************************************************************
qgsalgorithmparallellines.h
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSALGORITHMPARALLELLINES_H
#define QGSALGORITHMPARALLELLINES_H
#define SIP_NO_FILE
#include "qgis.h"
#include "qgsprocessingalgorithm.h"
///@cond PRIVATE
/**
* Native create parallel lines algorithm.
*/
class QgsCreateParallelLinesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{
public:
QgsCreateParallelLinesAlgorithm() = default;
QString name() const override;
QString displayName() const override;
QStringList tags() const override;
QString group() const override;
QString groupId() const override;
QString shortHelpString() const override;
QString shortDescription() const override;
QgsCreateParallelLinesAlgorithm *createInstance() const override SIP_FACTORY;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
QList<int> inputLayerTypes() const override;
protected:
QString outputName() const override;
bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFields outputFields( const QgsFields &inputFields ) const override;
private:
int mCount = 0;
bool mDynamicCount = false;
QgsProperty mCountProperty;
double mOffsetStep = 0.0;
bool mDynamicOffset = false;
QgsProperty mOffsetStepProperty;
int mSegments = 8;
QgsGeometry::JoinStyle mJoinStyle = QgsGeometry::JoinStyleRound;
double mMiterLimit = 2;
};
///@endcond PRIVATE
#endif // QGSALGORITHMPARALLELLINES_H

View File

@ -58,6 +58,7 @@
#include "qgsalgorithmorderbyexpression.h"
#include "qgsalgorithmorientedminimumboundingbox.h"
#include "qgsalgorithmpackage.h"
#include "qgsalgorithmparallellines.h"
#include "qgsalgorithmpointonsurface.h"
#include "qgsalgorithmprojectpointcartesian.h"
#include "qgsalgorithmpromotetomultipart.h"
@ -173,6 +174,7 @@ void QgsNativeAlgorithms::loadAlgorithms()
addAlgorithm( new QgsOrderByExpressionAlgorithm() );
addAlgorithm( new QgsOrientedMinimumBoundingBoxAlgorithm() );
addAlgorithm( new QgsPackageAlgorithm() );
addAlgorithm( new QgsCreateParallelLinesAlgorithm() );
addAlgorithm( new QgsPointOnSurfaceAlgorithm() );
addAlgorithm( new QgsProjectPointCartesianAlgorithm() );
addAlgorithm( new QgsPromoteToMultipartAlgorithm() );