Skip to content

Commit

Permalink
Fix "Array of offset lines" algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ authored and nyalldawson committed Sep 28, 2018
1 parent 9e5cc4b commit b478ee7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/CMakeLists.txt
Expand Up @@ -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
Expand Down
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmparallellines.cpp
qgsalgorithmarrayoffsetlines.cpp
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
Expand All @@ -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,
Expand Down Expand Up @@ -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" ) );
Expand All @@ -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();

Expand Down Expand Up @@ -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 ) );
Expand Down
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmparallellines.h
qgsalgorithmarrayoffsetlines.h
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
Expand All @@ -15,8 +15,8 @@
* *
***************************************************************************/

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

#define SIP_NO_FILE

Expand All @@ -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;

Expand Down Expand Up @@ -71,6 +71,6 @@ class QgsCreateParallelLinesAlgorithm : public QgsProcessingFeatureBasedAlgorith

///@endcond PRIVATE

#endif // QGSALGORITHMPARALLELLINES_H
#endif // QGSALGORITHMARRAYOFFSETLINES_H


4 changes: 2 additions & 2 deletions src/analysis/processing/qgsnativealgorithms.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsprocessinginplace.py
Expand Up @@ -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)
Expand Down

0 comments on commit b478ee7

Please sign in to comment.