Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update PDAL algorithms to use expression for filter parameter
  • Loading branch information
alexbruy authored and wonder-sk committed May 2, 2023
1 parent 45791b1 commit 61cfdd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/analysis/processing/pdal/qgsalgorithmpdalfilter.cpp
Expand Up @@ -19,6 +19,7 @@

#include "qgsrunprocess.h"
#include "qgspointcloudlayer.h"
#include "qgspointcloudexpression.h"

///@cond PRIVATE

Expand Down Expand Up @@ -60,7 +61,7 @@ QgsPdalFilterAlgorithm *QgsPdalFilterAlgorithm::createInstance() const
void QgsPdalFilterAlgorithm::initAlgorithm( const QVariantMap & )
{
addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterString( QStringLiteral( "FILTER_EXPRESSION" ), QObject::tr( "Filter expression" ), QVariant(), false, true ) );
addParameter( new QgsProcessingParameterExpression( QStringLiteral( "FILTER_EXPRESSION" ), QObject::tr( "Filter expression" ), QVariant(), QStringLiteral( "INPUT" ), false, QgsProcessingParameterExpression::PointCloud ) );
addParameter( new QgsProcessingParameterExtent( QStringLiteral( "FILTER_EXTENT" ), QObject::tr( "Cropping extent" ), QVariant(), true ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Filtered" ) ) );
}
Expand All @@ -86,7 +87,8 @@ QStringList QgsPdalFilterAlgorithm::createArgumentLists( const QVariantMap &para
const QString filterExpression = parameterAsString( parameters, QStringLiteral( "FILTER_EXPRESSION" ), context ).trimmed();
if ( !filterExpression.isEmpty() )
{
args << QStringLiteral( "--filter=%1" ).arg( filterExpression );
QgsPointCloudExpression exp( filterExpression );
args << QStringLiteral( "--filter=%1" ).arg( exp.asPdalExpression() );
}

if ( parameters.value( QStringLiteral( "FILTER_EXTENT" ) ).isValid() )
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/processing/pdal/qgspdalalgorithmbase.cpp
Expand Up @@ -19,6 +19,7 @@

#include "qgsapplication.h"
#include "qgsrunprocess.h"
#include "qgspointcloudexpression.h"

///@cond PRIVATE

Expand Down Expand Up @@ -47,7 +48,7 @@ QString QgsPdalAlgorithmBase::wrenchExecutableBinary() const

void QgsPdalAlgorithmBase::createCommonParameters()
{
std::unique_ptr< QgsProcessingParameterString > filterParam = std::make_unique< QgsProcessingParameterString >( QStringLiteral( "FILTER_EXPRESSION" ), QObject::tr( "Filter expression" ), QVariant(), false, true );
std::unique_ptr< QgsProcessingParameterExpression > filterParam = std::make_unique< QgsProcessingParameterExpression >( QStringLiteral( "FILTER_EXPRESSION" ), QObject::tr( "Filter expression" ), QVariant(), QStringLiteral( "INPUT" ), true, QgsProcessingParameterExpression::PointCloud );
filterParam->setFlags( filterParam->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( filterParam.release() );

Expand All @@ -61,7 +62,8 @@ void QgsPdalAlgorithmBase::applyCommonParameters( QStringList &arguments, QgsCoo
const QString filterExpression = parameterAsString( parameters, QStringLiteral( "FILTER_EXPRESSION" ), context ).trimmed();
if ( !filterExpression.isEmpty() )
{
arguments << QStringLiteral( "--filter=%1" ).arg( filterExpression );
QgsPointCloudExpression exp( filterExpression );
arguments << QStringLiteral( "--filter=%1" ).arg( exp.asPdalExpression() );
}

if ( parameters.value( QStringLiteral( "FILTER_EXTENT" ) ).isValid() )
Expand Down

0 comments on commit 61cfdd3

Please sign in to comment.