[processing] add new options to build vpc algorithm

This includes options to calculate statistics from the input data,
calculate exact boundaries and build an overview point cloud
This commit is contained in:
Alexander Bruy 2023-04-11 13:34:12 +03:00 committed by Martin Dobias
parent f89591b78f
commit c4774d64a1
2 changed files with 59 additions and 5 deletions

View File

@ -60,6 +60,9 @@ QgsPdalBuildVpcAlgorithm *QgsPdalBuildVpcAlgorithm::createInstance() const
void QgsPdalBuildVpcAlgorithm::initAlgorithm( const QVariantMap & )
{
addParameter( new QgsProcessingParameterMultipleLayers( QStringLiteral( "LAYERS" ), QObject::tr( "Input layers" ), QgsProcessing::TypePointCloud ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "BOUNDARY" ), QObject::tr( "Calculate boundary polygons" ), false ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "STATISTICS" ), QObject::tr( "Calculate statistics" ), false ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "OVERVIEW" ), QObject::tr( "Build overview point cloud" ), false ) );
addParameter( new QgsProcessingParameterFileDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Virtual point cloud file" ), QObject::tr( "VPC files (*.vpc *.VPC)" ) ) );
}
@ -77,11 +80,26 @@ QStringList QgsPdalBuildVpcAlgorithm::createArgumentLists( const QVariantMap &pa
setOutputValue( QStringLiteral( "OUTPUT" ), outputFile );
QStringList args;
args.reserve( layers.count() + 2 );
args.reserve( layers.count() + 5 );
args << QStringLiteral( "build_vpc" )
<< QStringLiteral( "--output=%1" ).arg( outputFile );
if ( parameterAsBool( parameters, QStringLiteral( "BOUNDARY" ), context ) )
{
args << "--boundary";
}
if ( parameterAsBool( parameters, QStringLiteral( "STATISTICS" ), context ) )
{
args << "--stats";
}
if ( parameterAsBool( parameters, QStringLiteral( "OVERVIEW" ), context ) )
{
args << "--overview";
}
addThreadsParameter( args );
for ( const QgsMapLayer *layer : std::as_const( layers ) )

View File

@ -154,7 +154,7 @@ void TestQgsProcessingPdalAlgs::reproject()
QCOMPARE( args, QStringList() << QStringLiteral( "translate" )
<< QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath )
<< QStringLiteral( "--output=%1" ).arg( outputPointCloud )
<< QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326") )
<< QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) )
);
// set max threads to 2, a --threads argument should be added
@ -163,7 +163,7 @@ void TestQgsProcessingPdalAlgs::reproject()
QCOMPARE( args, QStringList() << QStringLiteral( "translate" )
<< QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath )
<< QStringLiteral( "--output=%1" ).arg( outputPointCloud )
<< QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326") )
<< QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) )
<< QStringLiteral( "--threads=2" )
);
}
@ -188,7 +188,7 @@ void TestQgsProcessingPdalAlgs::fixProjection()
QCOMPARE( args, QStringList() << QStringLiteral( "translate" )
<< QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath )
<< QStringLiteral( "--output=%1" ).arg( outputPointCloud )
<< QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326") )
<< QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) )
);
// set max threads to 2, a --threads argument should be added
@ -197,7 +197,7 @@ void TestQgsProcessingPdalAlgs::fixProjection()
QCOMPARE( args, QStringList() << QStringLiteral( "translate" )
<< QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath )
<< QStringLiteral( "--output=%1" ).arg( outputPointCloud )
<< QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326") )
<< QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) )
<< QStringLiteral( "--threads=2" )
);
}
@ -749,11 +749,47 @@ void TestQgsProcessingPdalAlgs::buildVpc()
<< pointCloud2
);
// calculate exact boundaries
parameters.insert( QStringLiteral( "BOUNDARY" ), true );
args = alg->createArgumentLists( parameters, *context, &feedback );
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
<< QStringLiteral( "--output=%1" ).arg( outputFile )
<< QStringLiteral( "--boundary" )
<< pointCloud1
<< pointCloud2
);
// calculate statistics
parameters.insert( QStringLiteral( "STATISTICS" ), true );
args = alg->createArgumentLists( parameters, *context, &feedback );
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
<< QStringLiteral( "--output=%1" ).arg( outputFile )
<< QStringLiteral( "--boundary" )
<< QStringLiteral( "--stats" )
<< pointCloud1
<< pointCloud2
);
// build overview
parameters.insert( QStringLiteral( "OVERVIEW" ), true );
args = alg->createArgumentLists( parameters, *context, &feedback );
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
<< QStringLiteral( "--output=%1" ).arg( outputFile )
<< QStringLiteral( "--boundary" )
<< QStringLiteral( "--stats" )
<< QStringLiteral( "--overview" )
<< pointCloud1
<< pointCloud2
);
// set max threads to 2, a --threads argument should be added
QgsSettings().setValue( QStringLiteral( "/Processing/Configuration/MAX_THREADS" ), 2 );
args = alg->createArgumentLists( parameters, *context, &feedback );
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
<< QStringLiteral( "--output=%1" ).arg( outputFile )
<< QStringLiteral( "--boundary" )
<< QStringLiteral( "--stats" )
<< QStringLiteral( "--overview" )
<< QStringLiteral( "--threads=2" )
<< pointCloud1
<< pointCloud2