Skip to content

Commit

Permalink
use new point cloud attribute parameter in export raster and export
Browse files Browse the repository at this point in the history
vector PDAL algorithms
  • Loading branch information
alexbruy committed Apr 4, 2023
1 parent 959777c commit 2111d45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
19 changes: 2 additions & 17 deletions src/analysis/processing/pdal/qgsalgorithmpdalexportraster.cpp
Expand Up @@ -59,23 +59,8 @@ QgsPdalExportRasterAlgorithm *QgsPdalExportRasterAlgorithm::createInstance() con

void QgsPdalExportRasterAlgorithm::initAlgorithm( const QVariantMap & )
{
// for now we use hardcoded list of attributes, as currently there is
// no way to retrieve them from the point cloud layer without indexing
// it first. Later we will add a corresponding parameter type for it.
QStringList attributes =
{
QStringLiteral( "X" ),
QStringLiteral( "Y" ),
QStringLiteral( "Z" ),
QStringLiteral( "Intensity" ),
QStringLiteral( "ReturnNumber" ),
QStringLiteral( "NumberOfReturns" ),
QStringLiteral( "Classification" ),
QStringLiteral( "GpsTime" )
};

addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "ATTRIBUTE" ), QObject::tr( "Attribute" ), attributes, false, QStringLiteral( "Z" ), false, true ) );
addParameter( new QgsProcessingParameterPointCloudAttribute( QStringLiteral( "ATTRIBUTE" ), QObject::tr( "Attribute" ), QStringLiteral( "Z" ), QStringLiteral( "INPUT" ) ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "RESOLUTION" ), QObject::tr( "Resolution of the density raster" ), QgsProcessingParameterNumber::Integer, 1, false, 1 ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "TILE_SIZE" ), QObject::tr( "Tile size for parallel runs" ), QgsProcessingParameterNumber::Integer, 1000, false, 1 ) );

Expand Down Expand Up @@ -108,7 +93,7 @@ QStringList QgsPdalExportRasterAlgorithm::createArgumentLists( const QVariantMap
const QString outputFile = parameterAsOutputLayer( parameters, QStringLiteral( "OUTPUT" ), context );
setOutputValue( QStringLiteral( "OUTPUT" ), outputFile );

const QString attribute = parameterAsEnumString( parameters, QStringLiteral( "ATTRIBUTE" ), context );
const QString attribute = parameterAsString( parameters, QStringLiteral( "ATTRIBUTE" ), context );
const int resolution = parameterAsInt( parameters, QStringLiteral( "RESOLUTION" ), context );
const int tileSize = parameterAsInt( parameters, QStringLiteral( "TILE_SIZE" ), context );

Expand Down
24 changes: 6 additions & 18 deletions src/analysis/processing/pdal/qgsalgorithmpdalexportvector.cpp
Expand Up @@ -59,23 +59,8 @@ QgsPdalExportVectorAlgorithm *QgsPdalExportVectorAlgorithm::createInstance() con

void QgsPdalExportVectorAlgorithm::initAlgorithm( const QVariantMap & )
{
// for now we use hardcoded list of attributes, as currently there is
// no way to retrieve them from the point cloud layer without indexing
// it first. Later we will add a corresponding parameter type for it.
QStringList attributes =
{
QStringLiteral( "X" ),
QStringLiteral( "Y" ),
QStringLiteral( "Z" ),
QStringLiteral( "Intensity" ),
QStringLiteral( "ReturnNumber" ),
QStringLiteral( "NumberOfReturns" ),
QStringLiteral( "Classification" ),
QStringLiteral( "GpsTime" )
};

addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterEnum( QStringLiteral( "ATTRIBUTE" ), QObject::tr( "Attribute" ), attributes, false, QVariant(), true, true ) );
addParameter( new QgsProcessingParameterPointCloudAttribute( QStringLiteral( "ATTRIBUTE" ), QObject::tr( "Attribute" ), QVariant(), QStringLiteral( "INPUT" ), true, true ) );
addParameter( new QgsProcessingParameterVectorDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output vector" ), QgsProcessing::TypeVectorPoint ) );
}

Expand All @@ -97,8 +82,11 @@ QStringList QgsPdalExportVectorAlgorithm::createArgumentLists( const QVariantMap

if ( parameters.value( QStringLiteral( "ATTRIBUTE" ) ).isValid() )
{
const QString attribute = parameterAsEnumString( parameters, QStringLiteral( "ATTRIBUTE" ), context );
args << QStringLiteral( "--attribute=%1" ).arg( attribute );
const QStringList attributes = parameterAsStrings( parameters, QStringLiteral( "ATTRIBUTE" ), context );
for ( const QString &attr : attributes )
{
args << QStringLiteral( "--attribute=%1" ).arg( attr );
}
}

addThreadsParameter( args );
Expand Down

0 comments on commit 2111d45

Please sign in to comment.