-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move native c++ processing algorithms from core library to analysis
And split into separate files for each algorithm
- Loading branch information
1 parent
8dd8a9b
commit e92e20e
Showing
83 changed files
with
7,268 additions
and
4,407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/analysis/processing/qgsnativealgorithms.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsNativeAlgorithms: QgsProcessingProvider | ||
{ | ||
%Docstring | ||
.. versionadded:: 3.0 | ||
Native c++ processing algorithm provider. | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsnativealgorithms.h" | ||
%End | ||
public: | ||
|
||
QgsNativeAlgorithms( QObject *parent = 0 ); | ||
%Docstring | ||
Constructor for QgsNativeAlgorithms. | ||
%End | ||
|
||
virtual QIcon icon() const; | ||
|
||
virtual QString svgIconPath() const; | ||
|
||
virtual QString id() const; | ||
|
||
virtual QString name() const; | ||
|
||
virtual bool supportsNonFileBasedOutput() const; | ||
|
||
|
||
protected: | ||
|
||
virtual void loadAlgorithms(); | ||
|
||
|
||
}; | ||
|
||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/analysis/processing/qgsnativealgorithms.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/analysis/processing/qgsalgorithmaddincrementalfield.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*************************************************************************** | ||
qgsalgorithmaddincrementalfield.cpp | ||
----------------------------------- | ||
begin : April 2017 | ||
copyright : (C) 2017 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 "qgsalgorithmaddincrementalfield.h" | ||
|
||
///@cond PRIVATE | ||
|
||
QString QgsAddIncrementalFieldAlgorithm::name() const | ||
{ | ||
return QStringLiteral( "addautoincrementalfield" ); | ||
} | ||
|
||
QString QgsAddIncrementalFieldAlgorithm::displayName() const | ||
{ | ||
return QObject::tr( "Add autoincremental field" ); | ||
} | ||
|
||
QString QgsAddIncrementalFieldAlgorithm::shortHelpString() const | ||
{ | ||
return QObject::tr( "This algorithm adds a new integer field to a vector layer, with a sequential value for each feature.\n\n" | ||
"This field can be used as a unique ID for features in the layer. The new attribute " | ||
"is not added to the input layer but a new layer is generated instead.\n\n" | ||
"The initial starting value for the incremental series can be specified." ); | ||
} | ||
|
||
QStringList QgsAddIncrementalFieldAlgorithm::tags() const | ||
{ | ||
return QObject::tr( "add,create,serial,primary,key,unique,field" ).split( ',' ); | ||
} | ||
|
||
QString QgsAddIncrementalFieldAlgorithm::group() const | ||
{ | ||
return QObject::tr( "Vector table" ); | ||
} | ||
|
||
QString QgsAddIncrementalFieldAlgorithm::outputName() const | ||
{ | ||
return QObject::tr( "Incremented" ); | ||
} | ||
|
||
QList<int> QgsAddIncrementalFieldAlgorithm::inputLayerTypes() const | ||
{ | ||
return QList<int>() << QgsProcessing::TypeVector; | ||
} | ||
|
||
QgsAddIncrementalFieldAlgorithm *QgsAddIncrementalFieldAlgorithm::createInstance() const | ||
{ | ||
return new QgsAddIncrementalFieldAlgorithm(); | ||
} | ||
|
||
void QgsAddIncrementalFieldAlgorithm::initParameters( const QVariantMap & ) | ||
{ | ||
addParameter( new QgsProcessingParameterString( QStringLiteral( "FIELD_NAME" ), QObject::tr( "Field name" ), QStringLiteral( "AUTO" ) ) ); | ||
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "START" ), QObject::tr( "Start values at" ), | ||
QgsProcessingParameterNumber::Integer, 0, true ) ); | ||
} | ||
|
||
QgsFields QgsAddIncrementalFieldAlgorithm::outputFields( const QgsFields &inputFields ) const | ||
{ | ||
QgsFields outFields = inputFields; | ||
outFields.append( QgsField( mFieldName, QVariant::LongLong ) ); | ||
return outFields; | ||
} | ||
|
||
bool QgsAddIncrementalFieldAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback * ) | ||
{ | ||
mValue = parameterAsInt( parameters, QStringLiteral( "START" ), context ); | ||
mFieldName = parameterAsString( parameters, QStringLiteral( "FIELD_NAME" ), context ); | ||
return true; | ||
} | ||
|
||
QgsFeature QgsAddIncrementalFieldAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingFeedback * ) | ||
{ | ||
QgsFeature f = feature; | ||
QgsAttributes attributes = f.attributes(); | ||
attributes.append( mValue ); | ||
mValue++; | ||
f.setAttributes( attributes ); | ||
return f; | ||
} | ||
|
||
///@endcond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*************************************************************************** | ||
qgsalgorithmaddincrementalfield.h | ||
--------------------------------- | ||
begin : April 2017 | ||
copyright : (C) 2017 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 QGSALGORITHMADDINCREMENTALFIELD_H | ||
#define QGSALGORITHMADDINCREMENTALFIELD_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis.h" | ||
#include "qgsprocessingalgorithm.h" | ||
|
||
///@cond PRIVATE | ||
|
||
/** | ||
* Native add incremental field algorithm. | ||
*/ | ||
class QgsAddIncrementalFieldAlgorithm : public QgsProcessingFeatureBasedAlgorithm | ||
{ | ||
|
||
public: | ||
|
||
QgsAddIncrementalFieldAlgorithm() = default; | ||
QString name() const override; | ||
QString displayName() const override; | ||
virtual QStringList tags() const override; | ||
QString group() const override; | ||
QString shortHelpString() const override; | ||
QList<int> inputLayerTypes() const override; | ||
QgsAddIncrementalFieldAlgorithm *createInstance() const override SIP_FACTORY; | ||
|
||
protected: | ||
|
||
void initParameters( const QVariantMap &configuration = QVariantMap() ) override; | ||
QString outputName() const override; | ||
QgsFields outputFields( const QgsFields &inputFields ) const override; | ||
|
||
bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; | ||
QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override; | ||
|
||
private: | ||
|
||
long long mValue = 0; | ||
QString mFieldName; | ||
|
||
}; | ||
|
||
///@endcond PRIVATE | ||
|
||
#endif // QGSNATIVEALGORITHMS_H | ||
|
||
|
Oops, something went wrong.