Skip to content

Commit

Permalink
Fix array of translated features algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ authored and nyalldawson committed Sep 28, 2018
1 parent b9f20b0 commit 9e5cc4b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
Expand Up @@ -6095,7 +6095,7 @@ tests:
name: expected/filter_by_z.shp
type: vector

- algorithm: native:arrayfeatures
- algorithm: native:arraytranslatedfeatures
name: Array of point features
params:
COUNT: 3
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/CMakeLists.txt
Expand Up @@ -20,7 +20,7 @@ SET(QGIS_ANALYSIS_SRCS
interpolation/Vector3D.cpp

processing/qgsalgorithmaddincrementalfield.cpp
processing/qgsalgorithmarrayfeatures.cpp
processing/qgsalgorithmarraytranslatedfeatures.cpp
processing/qgsalgorithmassignprojection.cpp
processing/qgsalgorithmboundary.cpp
processing/qgsalgorithmboundingbox.cpp
Expand Down
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmarrayfeatures.cpp
qgsalgorithmarraytranslatedfeatures.cpp
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
Expand All @@ -15,57 +15,57 @@
* *
***************************************************************************/

#include "qgsalgorithmarrayfeatures.h"
#include "qgsalgorithmarraytranslatedfeatures.h"

///@cond PRIVATE

QString QgsArrayFeaturesAlgorithm::name() const
QString QgsArrayTranslatedFeaturesAlgorithm::name() const
{
return QStringLiteral( "arrayfeatures" );
return QStringLiteral( "arraytranslatedfeatures" );
}

QString QgsArrayFeaturesAlgorithm::displayName() const
QString QgsArrayTranslatedFeaturesAlgorithm::displayName() const
{
return QObject::tr( "Array of translated features" );
}

QStringList QgsArrayFeaturesAlgorithm::tags() const
QStringList QgsArrayTranslatedFeaturesAlgorithm::tags() const
{
return QObject::tr( "translate,parallel,offset,duplicate,grid,spaced,moved,copy,features,objects,step,repeat" ).split( ',' );
}

QString QgsArrayFeaturesAlgorithm::group() const
QString QgsArrayTranslatedFeaturesAlgorithm::group() const
{
return QObject::tr( "Vector creation" );
}

QString QgsArrayFeaturesAlgorithm::groupId() const
QString QgsArrayTranslatedFeaturesAlgorithm::groupId() const
{
return QStringLiteral( "vectorcreation" );
}

QString QgsArrayFeaturesAlgorithm::outputName() const
QString QgsArrayTranslatedFeaturesAlgorithm::outputName() const
{
return QObject::tr( "Translated" );
}

QString QgsArrayFeaturesAlgorithm::shortHelpString() const
QString QgsArrayTranslatedFeaturesAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm creates copies of features in a layer, by creating multiple translated versions of each feature. "
"Each copy is incrementally displaced by a preset amount in the x/y/z/m axis." );
}

QString QgsArrayFeaturesAlgorithm::shortDescription() const
QString QgsArrayTranslatedFeaturesAlgorithm::shortDescription() const
{
return QObject::tr( "Creates multiple translated copies of features in a layer." );
}

QgsArrayFeaturesAlgorithm *QgsArrayFeaturesAlgorithm::createInstance() const
QgsArrayTranslatedFeaturesAlgorithm *QgsArrayTranslatedFeaturesAlgorithm::createInstance() const
{
return new QgsArrayFeaturesAlgorithm();
return new QgsArrayTranslatedFeaturesAlgorithm();
}

void QgsArrayFeaturesAlgorithm::initParameters( const QVariantMap & )
void QgsArrayTranslatedFeaturesAlgorithm::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 @@ -108,7 +108,7 @@ void QgsArrayFeaturesAlgorithm::initParameters( const QVariantMap & )
addParameter( mOffset.release() );
}

bool QgsArrayFeaturesAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
bool QgsArrayTranslatedFeaturesAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
{
mCount = parameterAsInt( parameters, QStringLiteral( "COUNT" ), context );
mDynamicCount = QgsProcessingParameters::isDynamic( parameters, QStringLiteral( "COUNT" ) );
Expand Down Expand Up @@ -138,7 +138,7 @@ bool QgsArrayFeaturesAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
return true;
}

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

Expand Down Expand Up @@ -199,7 +199,7 @@ QgsFeatureList QgsArrayFeaturesAlgorithm::processFeature( const QgsFeature &feat
return result;
}

QgsWkbTypes::Type QgsArrayFeaturesAlgorithm::outputWkbType( QgsWkbTypes::Type inputWkbType ) const
QgsWkbTypes::Type QgsArrayTranslatedFeaturesAlgorithm::outputWkbType( QgsWkbTypes::Type inputWkbType ) const
{
QgsWkbTypes::Type wkb = inputWkbType;
if ( mDeltaZ != 0 )
Expand All @@ -209,7 +209,7 @@ QgsWkbTypes::Type QgsArrayFeaturesAlgorithm::outputWkbType( QgsWkbTypes::Type in
return wkb;
}

QgsFields QgsArrayFeaturesAlgorithm::outputFields( const QgsFields &inputFields ) const
QgsFields QgsArrayTranslatedFeaturesAlgorithm::outputFields( const QgsFields &inputFields ) const
{
QgsFields output = inputFields;
output.append( QgsField( QStringLiteral( "instance" ), QVariant::Int ) );
Expand Down
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmarrayfeatures.h
qgsalgorithmarraytranslatedfeatures.h
---------------------
begin : July 2018
copyright : (C) 2018 by Nyall Dawson
Expand All @@ -15,8 +15,8 @@
* *
***************************************************************************/

#ifndef QGSALGORITHMARRAYFEATURES_H
#define QGSALGORITHMARRAYFEATURES_H
#ifndef QGSALGORITHMARRAYTRANSLATEDFEATURES_H
#define QGSALGORITHMARRAYTRANSLATEDFEATURES_H

#define SIP_NO_FILE

Expand All @@ -28,20 +28,20 @@
/**
* Native create array of features algorithm.
*/
class QgsArrayFeaturesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
class QgsArrayTranslatedFeaturesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
{

public:

QgsArrayFeaturesAlgorithm() = default;
QgsArrayTranslatedFeaturesAlgorithm() = 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;
QgsArrayFeaturesAlgorithm *createInstance() const override SIP_FACTORY;
QgsArrayTranslatedFeaturesAlgorithm *createInstance() const override SIP_FACTORY;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;

protected:
Expand Down Expand Up @@ -78,6 +78,6 @@ class QgsArrayFeaturesAlgorithm : public QgsProcessingFeatureBasedAlgorithm

///@endcond PRIVATE

#endif // QGSALGORITHMARRAYFEATURES_H
#endif // QGSALGORITHMARRAYTRANSLATEDFEATURES_H


4 changes: 2 additions & 2 deletions src/analysis/processing/qgsnativealgorithms.cpp
Expand Up @@ -17,7 +17,7 @@

#include "qgsnativealgorithms.h"
#include "qgsalgorithmaddincrementalfield.h"
#include "qgsalgorithmarrayfeatures.h"
#include "qgsalgorithmarraytranslatedfeatures.h"
#include "qgsalgorithmassignprojection.h"
#include "qgsalgorithmboundary.h"
#include "qgsalgorithmboundingbox.h"
Expand Down Expand Up @@ -139,7 +139,7 @@ void QgsNativeAlgorithms::loadAlgorithms()
{
addAlgorithm( new QgsAddIncrementalFieldAlgorithm() );
addAlgorithm( new QgsAddUniqueValueIndexAlgorithm() );
addAlgorithm( new QgsArrayFeaturesAlgorithm() );
addAlgorithm( new QgsArrayTranslatedFeaturesAlgorithm() );
addAlgorithm( new QgsAssignProjectionAlgorithm() );
addAlgorithm( new QgsBoundaryAlgorithm() );
addAlgorithm( new QgsBoundingBoxAlgorithm() );
Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_qgsprocessinginplace.py
Expand Up @@ -141,7 +141,7 @@ def test_support_in_place_edit(self):

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:arrayfeatures', GEOMETRY_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)
self._support_inplace_edit_tester('qgis:densifygeometriesgivenaninterval', LINESTRING_AND_POLYGON_ONLY)
Expand Down Expand Up @@ -454,13 +454,13 @@ def test_multi_to_single(self):
# Check selected
self.assertEqual(len(self.multipoly_vl.selectedFeatureIds()), 2)

def test_arrayfeatures(self):
def test_arraytranslatedfeatures(self):
"""Check that this runs correctly and additional attributes are dropped"""

old_count = self.vl.featureCount()

old_features, new_features = self._alg_tester(
'native:arrayfeatures',
'native:arraytranslatedfeatures',
self.vl,
{
'COUNT': 2,
Expand Down

0 comments on commit 9e5cc4b

Please sign in to comment.