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
split thin algorithm into two
- Loading branch information
Showing
7 changed files
with
255 additions
and
70 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
94 changes: 94 additions & 0 deletions
94
src/analysis/processing/pdal/qgsalgorithmpdalthinbydecimate.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,94 @@ | ||
/*************************************************************************** | ||
qgsalgorithmpdalthinbydecimate.cpp | ||
--------------------- | ||
begin : May 2023 | ||
copyright : (C) 2023 by Alexander Bruy | ||
email : alexander dot bruy 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 "qgsalgorithmpdalthinbydecimate.h" | ||
|
||
#include "qgsrunprocess.h" | ||
#include "qgspointcloudlayer.h" | ||
|
||
///@cond PRIVATE | ||
|
||
QString QgsPdalThinByDecimateAlgorithm::name() const | ||
{ | ||
return QStringLiteral( "thinbydecimate" ); | ||
} | ||
|
||
QString QgsPdalThinByDecimateAlgorithm::displayName() const | ||
{ | ||
return QObject::tr( "Thin (by skipping points)" ); | ||
} | ||
|
||
QString QgsPdalThinByDecimateAlgorithm::group() const | ||
{ | ||
return QObject::tr( "Point cloud data management" ); | ||
} | ||
|
||
QString QgsPdalThinByDecimateAlgorithm::groupId() const | ||
{ | ||
return QStringLiteral( "pointclouddatamanagement" ); | ||
} | ||
|
||
QStringList QgsPdalThinByDecimateAlgorithm::tags() const | ||
{ | ||
return QObject::tr( "pdal,lidar,thin,reduce,decrease,size,decimate,skip" ).split( ',' ); | ||
} | ||
|
||
QString QgsPdalThinByDecimateAlgorithm::shortHelpString() const | ||
{ | ||
return QObject::tr( "This algorithm creates a thinned version of the point cloud by keeping only every N-th point." ); | ||
} | ||
|
||
QgsPdalThinByDecimateAlgorithm *QgsPdalThinByDecimateAlgorithm::createInstance() const | ||
{ | ||
return new QgsPdalThinByDecimateAlgorithm(); | ||
} | ||
|
||
void QgsPdalThinByDecimateAlgorithm::initAlgorithm( const QVariantMap & ) | ||
{ | ||
addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) ); | ||
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "POINTS_NUMBER" ), QObject::tr( "Number of points to skip" ), QgsProcessingParameterNumber::Integer, 1, false, 1 ) ); | ||
createCommonParameters(); | ||
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Thinned (by decimation)" ) ) ); | ||
} | ||
|
||
QStringList QgsPdalThinByDecimateAlgorithm::createArgumentLists( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) | ||
{ | ||
Q_UNUSED( feedback ); | ||
|
||
QgsPointCloudLayer *layer = parameterAsPointCloudLayer( parameters, QStringLiteral( "INPUT" ), context, QgsProcessing::LayerOptionsFlag::SkipIndexGeneration ); | ||
if ( !layer ) | ||
throw QgsProcessingException( invalidPointCloudError( parameters, QStringLiteral( "INPUT" ) ) ); | ||
|
||
const QString outputName = parameterAsOutputLayer( parameters, QStringLiteral( "OUTPUT" ), context ); | ||
QString outputFile = fixOutputFileName( layer->source(), outputName, context ); | ||
setOutputValue( QStringLiteral( "OUTPUT" ), outputFile ); | ||
|
||
int step = parameterAsInt( parameters, QStringLiteral( "POINTS_NUMBER" ), context ); | ||
|
||
QStringList args = { QStringLiteral( "thin" ), | ||
QStringLiteral( "--input=%1" ).arg( layer->source() ), | ||
QStringLiteral( "--output=%1" ).arg( outputFile ), | ||
QStringLiteral( "--mode=every-nth" ), | ||
QStringLiteral( "--step-every-nth=%1" ).arg( step ) | ||
}; | ||
|
||
applyCommonParameters( args, layer->crs(), parameters, context ); | ||
applyThreadsParameter( args, context ); | ||
return args; | ||
} | ||
|
||
///@endcond |
54 changes: 54 additions & 0 deletions
54
src/analysis/processing/pdal/qgsalgorithmpdalthinbydecimate.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*************************************************************************** | ||
qgsalgorithmpdalthinbyradius.h | ||
--------------------- | ||
begin : February 2023 | ||
copyright : (C) 2023 by Alexander Bruy | ||
email : alexander dot bruy 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 QGSALGORITHMPDALTHINBYDECIMATE_H | ||
#define QGSALGORITHMPDALTHINBYDECIMATE_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis_sip.h" | ||
#include "qgspdalalgorithmbase.h" | ||
|
||
///@cond PRIVATE | ||
|
||
/** | ||
* Native point cloud thin by decimation (skipping points). | ||
*/ | ||
class QgsPdalThinByDecimateAlgorithm : public QgsPdalAlgorithmBase | ||
{ | ||
|
||
public: | ||
|
||
QgsPdalThinByDecimateAlgorithm() = default; | ||
void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; | ||
QString name() const override; | ||
QString displayName() const override; | ||
QString group() const override; | ||
QString groupId() const override; | ||
QStringList tags() const override; | ||
QString shortHelpString() const override; | ||
QgsPdalThinByDecimateAlgorithm *createInstance() const override SIP_FACTORY; | ||
|
||
QStringList createArgumentLists( const QVariantMap ¶meters, | ||
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override; | ||
|
||
friend class TestQgsProcessingPdalAlgs; | ||
}; | ||
|
||
///@endcond PRIVATE | ||
|
||
#endif // QGSALGORITHMPDALTHINBYDECIMATE_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
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
Oops, something went wrong.