mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
pass a text file with input data files to build vpc tool (fix #53970)
This commit is contained in:
parent
c9da9b7680
commit
69895b4ffd
@ -117,11 +117,24 @@ QStringList QgsPdalBuildVpcAlgorithm::createArgumentLists( const QVariantMap &pa
|
|||||||
|
|
||||||
applyThreadsParameter( args, context );
|
applyThreadsParameter( args, context );
|
||||||
|
|
||||||
|
const QString fileName = QgsProcessingUtils::generateTempFilename( QStringLiteral( "inputFiles.txt" ), &context );
|
||||||
|
QFile listFile( fileName );
|
||||||
|
if ( !listFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
|
||||||
|
{
|
||||||
|
throw QgsProcessingException( QObject::tr( "Could not create input file list %1" ).arg( fileName ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream out( &listFile );
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
out.setCodec( "UTF-8" );
|
||||||
|
#endif
|
||||||
for ( const QgsMapLayer *layer : std::as_const( layers ) )
|
for ( const QgsMapLayer *layer : std::as_const( layers ) )
|
||||||
{
|
{
|
||||||
args << layer->source();
|
out << layer->source() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args << QStringLiteral( "--input-file-list=%1" ).arg( fileName );
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@ class TestQgsProcessingPdalAlgs: public QgsTest
|
|||||||
void tile();
|
void tile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateFileListArg( QStringList &args, const QString &fileName );
|
||||||
|
|
||||||
QString mPointCloudLayerPath;
|
QString mPointCloudLayerPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,6 +91,26 @@ void TestQgsProcessingPdalAlgs::init()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsProcessingPdalAlgs::updateFileListArg( QStringList &args, const QString &fileName )
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
bool found = false;
|
||||||
|
for ( const QString &arg : args )
|
||||||
|
{
|
||||||
|
if ( arg.contains( fileName, Qt::CaseInsensitive ) )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( found )
|
||||||
|
{
|
||||||
|
args[ i ] = QStringLiteral( "--input-file-list=%1" ).arg( fileName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TestQgsProcessingPdalAlgs::info()
|
void TestQgsProcessingPdalAlgs::info()
|
||||||
{
|
{
|
||||||
QgsPdalAlgorithmBase *alg = const_cast<QgsPdalAlgorithmBase *>( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:info" ) ) ) );
|
QgsPdalAlgorithmBase *alg = const_cast<QgsPdalAlgorithmBase *>( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:info" ) ) ) );
|
||||||
@ -998,64 +1020,65 @@ void TestQgsProcessingPdalAlgs::buildVpc()
|
|||||||
parameters.insert( QStringLiteral( "OUTPUT" ), outputFile );
|
parameters.insert( QStringLiteral( "OUTPUT" ), outputFile );
|
||||||
|
|
||||||
QStringList args = alg->createArgumentLists( parameters, *context, &feedback );
|
QStringList args = alg->createArgumentLists( parameters, *context, &feedback );
|
||||||
|
updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) );
|
||||||
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
||||||
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
||||||
<< pointCloud1
|
<< QStringLiteral( "--input-file-list=inputFiles.txt" )
|
||||||
);
|
);
|
||||||
|
|
||||||
// multiple layers
|
// multiple layers
|
||||||
parameters.insert( QStringLiteral( "LAYERS" ), QStringList() << pointCloud1 << pointCloud2 );
|
parameters.insert( QStringLiteral( "LAYERS" ), QStringList() << pointCloud1 << pointCloud2 );
|
||||||
args = alg->createArgumentLists( parameters, *context, &feedback );
|
args = alg->createArgumentLists( parameters, *context, &feedback );
|
||||||
|
updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) );
|
||||||
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
||||||
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
||||||
<< pointCloud1
|
<< QStringLiteral( "--input-file-list=inputFiles.txt" )
|
||||||
<< pointCloud2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// calculate exact boundaries
|
// calculate exact boundaries
|
||||||
parameters.insert( QStringLiteral( "BOUNDARY" ), true );
|
parameters.insert( QStringLiteral( "BOUNDARY" ), true );
|
||||||
args = alg->createArgumentLists( parameters, *context, &feedback );
|
args = alg->createArgumentLists( parameters, *context, &feedback );
|
||||||
|
updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) );
|
||||||
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
||||||
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
||||||
<< QStringLiteral( "--boundary" )
|
<< QStringLiteral( "--boundary" )
|
||||||
<< pointCloud1
|
<< QStringLiteral( "--input-file-list=inputFiles.txt" )
|
||||||
<< pointCloud2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// calculate statistics
|
// calculate statistics
|
||||||
parameters.insert( QStringLiteral( "STATISTICS" ), true );
|
parameters.insert( QStringLiteral( "STATISTICS" ), true );
|
||||||
args = alg->createArgumentLists( parameters, *context, &feedback );
|
args = alg->createArgumentLists( parameters, *context, &feedback );
|
||||||
|
updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) );
|
||||||
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
||||||
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
||||||
<< QStringLiteral( "--boundary" )
|
<< QStringLiteral( "--boundary" )
|
||||||
<< QStringLiteral( "--stats" )
|
<< QStringLiteral( "--stats" )
|
||||||
<< pointCloud1
|
<< QStringLiteral( "--input-file-list=inputFiles.txt" )
|
||||||
<< pointCloud2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// build overview
|
// build overview
|
||||||
parameters.insert( QStringLiteral( "OVERVIEW" ), true );
|
parameters.insert( QStringLiteral( "OVERVIEW" ), true );
|
||||||
args = alg->createArgumentLists( parameters, *context, &feedback );
|
args = alg->createArgumentLists( parameters, *context, &feedback );
|
||||||
|
updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) );
|
||||||
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
||||||
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
||||||
<< QStringLiteral( "--boundary" )
|
<< QStringLiteral( "--boundary" )
|
||||||
<< QStringLiteral( "--stats" )
|
<< QStringLiteral( "--stats" )
|
||||||
<< QStringLiteral( "--overview" )
|
<< QStringLiteral( "--overview" )
|
||||||
<< pointCloud1
|
<< QStringLiteral( "--input-file-list=inputFiles.txt" )
|
||||||
<< pointCloud2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// set max threads to 2, a --threads argument should be added
|
// set max threads to 2, a --threads argument should be added
|
||||||
context->setMaximumThreads( 2 );
|
context->setMaximumThreads( 2 );
|
||||||
args = alg->createArgumentLists( parameters, *context, &feedback );
|
args = alg->createArgumentLists( parameters, *context, &feedback );
|
||||||
|
updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) );
|
||||||
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" )
|
||||||
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
<< QStringLiteral( "--output=%1" ).arg( outputFile )
|
||||||
<< QStringLiteral( "--boundary" )
|
<< QStringLiteral( "--boundary" )
|
||||||
<< QStringLiteral( "--stats" )
|
<< QStringLiteral( "--stats" )
|
||||||
<< QStringLiteral( "--overview" )
|
<< QStringLiteral( "--overview" )
|
||||||
<< QStringLiteral( "--threads=2" )
|
<< QStringLiteral( "--threads=2" )
|
||||||
<< pointCloud1
|
<< QStringLiteral( "--input-file-list=inputFiles.txt" )
|
||||||
<< pointCloud2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user