Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add native densify by interval algorithm
- Loading branch information
Showing
7 changed files
with
248 additions
and
83 deletions.
There are no files selected for viewing
77 changes: 0 additions & 77 deletions
77
python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
This file was deleted.
Oops, something went wrong.
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,98 @@ | ||
/*************************************************************************** | ||
qgsalgorithmdensifygeometries.cpp | ||
--------------------- | ||
begin : January 2019 | ||
copyright : (C) 2019 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 "qgsalgorithmdensifygeometries.h" | ||
|
||
QString QgsDensifyGeometriesAlgorithm::name() const | ||
{ | ||
return QStringLiteral( "densifygeometriesgivenaninterval" ); | ||
} | ||
|
||
QString QgsDensifyGeometriesAlgorithm::displayName() const | ||
{ | ||
return QObject::tr( "Densify by interval" ); | ||
} | ||
|
||
QStringList QgsDensifyGeometriesAlgorithm::tags() const | ||
{ | ||
return QObject::tr( "add,vertex,vertices,points,nodes" ).split( ',' ); | ||
} | ||
|
||
QString QgsDensifyGeometriesAlgorithm::group() const | ||
{ | ||
return QObject::tr( "Vector geometry" ); | ||
} | ||
|
||
QString QgsDensifyGeometriesAlgorithm::groupId() const | ||
{ | ||
return QStringLiteral( "vectorgeometry" ); | ||
} | ||
|
||
QString QgsDensifyGeometriesAlgorithm::shortHelpString() const | ||
{ | ||
return QObject::tr( "Geometries are densified by adding additional vertices on " | ||
"edges that have a maximum distance of the interval parameter " | ||
"in map units." ); | ||
} | ||
|
||
QString QgsDensifyGeometriesAlgorithm::shortDescription() const | ||
{ | ||
return QObject::tr( "Creates a densified version of geometries." ); | ||
} | ||
|
||
QgsDensifyGeometriesAlgorithm *QgsDensifyGeometriesAlgorithm::createInstance() const | ||
{ | ||
return new QgsDensifyGeometriesAlgorithm; | ||
|
||
} | ||
|
||
QList<int> QgsDensifyGeometriesAlgorithm::inputLayerTypes() const | ||
{ | ||
return QList<int>() << QgsProcessing::TypeVectorLine << QgsProcessing::TypeVectorPolygon; | ||
} | ||
|
||
void QgsDensifyGeometriesAlgorithm::initParameters( const QVariantMap &configuration ) | ||
{ | ||
Q_UNUSED( configuration ) | ||
addParameter( new QgsProcessingParameterDistance( QStringLiteral( "INTERVAL" ), | ||
QObject::tr( "Interval between vertices to add" ), | ||
1, QStringLiteral( "INPUT" ), false, 0, 10000000 ) ); | ||
} | ||
|
||
QString QgsDensifyGeometriesAlgorithm::outputName() const | ||
{ | ||
return QObject::tr( "Densified" ); | ||
} | ||
|
||
QgsFeatureList QgsDensifyGeometriesAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) | ||
{ | ||
Q_UNUSED( context ); | ||
Q_UNUSED( feedback ); | ||
QgsFeature modifiedFeature = feature; | ||
if ( feature.hasGeometry() ) | ||
modifiedFeature.setGeometry( feature.geometry().densifyByDistance( mInterval ) ); | ||
|
||
return QgsFeatureList() << modifiedFeature; | ||
} | ||
|
||
bool QgsDensifyGeometriesAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) | ||
{ | ||
Q_UNUSED( feedback ); | ||
mInterval = parameterAsDouble( parameters, QStringLiteral( "INTERVAL" ), context ); | ||
return true; | ||
} |
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 @@ | ||
/*************************************************************************** | ||
qgsalgorithmdensifygeometries.h | ||
--------------------- | ||
begin : January 2019 | ||
copyright : (C) 2019 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 QGSALGORITHMDENSIFYGEOMETRIES_H | ||
#define QGSALGORITHMDENSIFYGEOMETRIES_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis.h" | ||
#include "qgsprocessingalgorithm.h" | ||
|
||
///@cond PRIVATE | ||
|
||
|
||
class QgsDensifyGeometriesAlgorithm : public QgsProcessingFeatureBasedAlgorithm | ||
{ | ||
public: | ||
|
||
QgsDensifyGeometriesAlgorithm() = 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; | ||
QgsDensifyGeometriesAlgorithm *createInstance() const override SIP_FACTORY; | ||
QList<int> inputLayerTypes() const override; | ||
|
||
protected: | ||
void initParameters( const QVariantMap &configuration = QVariantMap() ) override; | ||
QString outputName() const override; | ||
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; | ||
bool prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; | ||
|
||
private: | ||
double mInterval = 0.0; | ||
}; | ||
|
||
///@endcond PRIVATE | ||
#endif // QGSALGORITHMDENSIFYGEOMETRIES_H |
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
Oops, something went wrong.