Skip to content
Permalink
Browse files

Fix "Array of offset lines" algorithm

  • Loading branch information
DelazJ authored and nyalldawson committed Sep 28, 2018
1 parent 9e5cc4b commit b478ee750cd81f6c794ca283e64e868934e6fb53
@@ -6111,8 +6111,8 @@ tests:
name: expected/feature_array.shp
type: vector

- algorithm: native:parallellines
name: Create parallel lines
- algorithm: native:arrayoffsetlines
name: Array of offset (parallel) lines
params:
COUNT: 3
INPUT:
@@ -66,7 +66,7 @@ SET(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmorderbyexpression.cpp
processing/qgsalgorithmorientedminimumboundingbox.cpp
processing/qgsalgorithmpackage.cpp
processing/qgsalgorithmparallellines.cpp
processing/qgsalgorithmarrayoffsetlines.cpp
processing/qgsalgorithmpointonsurface.cpp
processing/qgsalgorithmprojectpointcartesian.cpp
processing/qgsalgorithmpromotetomultipart.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmparallellines.cpp
qgsalgorithmarrayoffsetlines.cpp
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
@@ -15,57 +15,57 @@
* *
***************************************************************************/

#include "qgsalgorithmparallellines.h"
#include "qgsalgorithmarrayoffsetlines.h"

///@cond PRIVATE

QString QgsCreateParallelLinesAlgorithm::name() const
QString QgsCreateArrayOffsetLinesAlgorithm::name() const
{
return QStringLiteral( "parallellines" );
return QStringLiteral( "arrayoffsetlines" );
}

QString QgsCreateParallelLinesAlgorithm::displayName() const
QString QgsCreateArrayOffsetLinesAlgorithm::displayName() const
{
return QObject::tr( "Array of offset (parallel) lines" );
}

QStringList QgsCreateParallelLinesAlgorithm::tags() const
QStringList QgsCreateArrayOffsetLinesAlgorithm::tags() const
{
return QObject::tr( "offset,parallel,duplicate,create,spaced,copy,features,objects,step,repeat" ).split( ',' );
}

QString QgsCreateParallelLinesAlgorithm::group() const
QString QgsCreateArrayOffsetLinesAlgorithm::group() const
{
return QObject::tr( "Vector creation" );
}

QString QgsCreateParallelLinesAlgorithm::groupId() const
QString QgsCreateArrayOffsetLinesAlgorithm::groupId() const
{
return QStringLiteral( "vectorcreation" );
}

QString QgsCreateParallelLinesAlgorithm::outputName() const
QString QgsCreateArrayOffsetLinesAlgorithm::outputName() const
{
return QObject::tr( "Offset lines" );
}

QString QgsCreateParallelLinesAlgorithm::shortHelpString() const
QString QgsCreateArrayOffsetLinesAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm creates copies of line features in a layer, by creating multiple offset versions of each feature. "
"Each copy is offset by a preset distance." );
}

QString QgsCreateParallelLinesAlgorithm::shortDescription() const
QString QgsCreateArrayOffsetLinesAlgorithm::shortDescription() const
{
return QObject::tr( "Creates multiple offset copies of lines from a layer." );
}

QgsCreateParallelLinesAlgorithm *QgsCreateParallelLinesAlgorithm::createInstance() const
QgsCreateArrayOffsetLinesAlgorithm *QgsCreateArrayOffsetLinesAlgorithm::createInstance() const
{
return new QgsCreateParallelLinesAlgorithm();
return new QgsCreateArrayOffsetLinesAlgorithm();
}

void QgsCreateParallelLinesAlgorithm::initParameters( const QVariantMap & )
void QgsCreateArrayOffsetLinesAlgorithm::initParameters( const QVariantMap & )
{
std::unique_ptr< QgsProcessingParameterNumber > count = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "COUNT" ),
QObject::tr( "Number of features to create" ), QgsProcessingParameterNumber::Integer,
@@ -96,12 +96,12 @@ void QgsCreateParallelLinesAlgorithm::initParameters( const QVariantMap & )
addParameter( miterLimitParam.release() );
}

QList<int> QgsCreateParallelLinesAlgorithm::inputLayerTypes() const
QList<int> QgsCreateArrayOffsetLinesAlgorithm::inputLayerTypes() const
{
return QList< int >() << QgsProcessing::TypeVectorLine;
}

bool QgsCreateParallelLinesAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
bool QgsCreateArrayOffsetLinesAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
{
mCount = parameterAsInt( parameters, QStringLiteral( "COUNT" ), context );
mDynamicCount = QgsProcessingParameters::isDynamic( parameters, QStringLiteral( "COUNT" ) );
@@ -120,7 +120,7 @@ bool QgsCreateParallelLinesAlgorithm::prepareAlgorithm( const QVariantMap &param
return true;
}

QgsFeatureList QgsCreateParallelLinesAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback * )
QgsFeatureList QgsCreateArrayOffsetLinesAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback * )
{
QgsFeatureList result = QgsFeatureList();

@@ -169,7 +169,7 @@ QgsFeatureList QgsCreateParallelLinesAlgorithm::processFeature( const QgsFeature
return result;
}

QgsFields QgsCreateParallelLinesAlgorithm::outputFields( const QgsFields &inputFields ) const
QgsFields QgsCreateArrayOffsetLinesAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields output = inputFields;
output.append( QgsField( QStringLiteral( "instance" ), QVariant::Int ) );
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmparallellines.h
qgsalgorithmarrayoffsetlines.h
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
@@ -15,8 +15,8 @@
* *
***************************************************************************/

#ifndef QGSALGORITHMPARALLELLINES_H
#define QGSALGORITHMPARALLELLINES_H
#ifndef QGSALGORITHMARRAYOFFSETLINES_H
#define QGSALGORITHMARRAYOFFSETLINES_H

#define SIP_NO_FILE

@@ -28,20 +28,20 @@
/**
* Native create parallel lines algorithm.
*/
class QgsCreateParallelLinesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
class QgsCreateArrayOffsetLinesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{

public:

QgsCreateParallelLinesAlgorithm() = default;
QgsCreateArrayOffsetLinesAlgorithm() = 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;
QgsCreateArrayOffsetLinesAlgorithm *createInstance() const override SIP_FACTORY;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
QList<int> inputLayerTypes() const override;

@@ -71,6 +71,6 @@ class QgsCreateParallelLinesAlgorithm : public QgsProcessingFeatureBasedAlgorith

///@endcond PRIVATE

#endif // QGSALGORITHMPARALLELLINES_H
#endif // QGSALGORITHMARRAYOFFSETLINES_H


@@ -63,7 +63,7 @@
#include "qgsalgorithmorderbyexpression.h"
#include "qgsalgorithmorientedminimumboundingbox.h"
#include "qgsalgorithmpackage.h"
#include "qgsalgorithmparallellines.h"
#include "qgsalgorithmarrayoffsetlines.h"
#include "qgsalgorithmpointonsurface.h"
#include "qgsalgorithmprojectpointcartesian.h"
#include "qgsalgorithmpromotetomultipart.h"
@@ -188,7 +188,7 @@ void QgsNativeAlgorithms::loadAlgorithms()
addAlgorithm( new QgsOrderByExpressionAlgorithm() );
addAlgorithm( new QgsOrientedMinimumBoundingBoxAlgorithm() );
addAlgorithm( new QgsPackageAlgorithm() );
addAlgorithm( new QgsCreateParallelLinesAlgorithm() );
addAlgorithm( new QgsCreateArrayOffsetLinesAlgorithm() );
addAlgorithm( new QgsPointOnSurfaceAlgorithm() );
addAlgorithm( new QgsProjectPointCartesianAlgorithm() );
addAlgorithm( new QgsPromoteToMultipartAlgorithm() );
@@ -140,7 +140,7 @@ def test_support_in_place_edit(self):
LINESTRING_AND_POLYGON_ONLY_NOT_M_NOT_Z = {t: (t.rfind('M') < 1 and t.find('Z') == -1 and (t.find('LineString') >= 0 or t.find('Polygon') >= 0)) for t in _all_true().keys()}

self._support_inplace_edit_tester('native:smoothgeometry', LINESTRING_AND_POLYGON_ONLY)
self._support_inplace_edit_tester('native:parallellines', LINESTRING_ONLY)
self._support_inplace_edit_tester('native:arrayoffsetlines', LINESTRING_ONLY)
self._support_inplace_edit_tester('native:arraytranslatedfeatures', GEOMETRY_ONLY)
self._support_inplace_edit_tester('native:reprojectlayer', GEOMETRY_ONLY)
self._support_inplace_edit_tester('qgis:densifygeometries', LINESTRING_AND_POLYGON_ONLY)

0 comments on commit b478ee7

Please sign in to comment.
You can’t perform that action at this time.