|
22 | 22 | #include "qgsprocessingcontext.h"
|
23 | 23 | #include "qgspdalalgorithms.h"
|
24 | 24 | #include "qgspdalalgorithmbase.h"
|
| 25 | +#include "qgspointcloudlayer.h" |
25 | 26 |
|
| 27 | +#include <QThread> |
26 | 28 |
|
27 | 29 | class TestQgsProcessingPdalAlgs : public QgsTest
|
28 | 30 | {
|
@@ -56,6 +58,8 @@ class TestQgsProcessingPdalAlgs : public QgsTest
|
56 | 58 | void thinByRadius();
|
57 | 59 | void tile();
|
58 | 60 |
|
| 61 | + void useIndexCopcFile(); |
| 62 | + |
59 | 63 | private:
|
60 | 64 | void updateFileListArg( QStringList &args, const QString &fileName );
|
61 | 65 |
|
@@ -854,5 +858,41 @@ void TestQgsProcessingPdalAlgs::filter()
|
854 | 858 | QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) );
|
855 | 859 | }
|
856 | 860 |
|
| 861 | +void TestQgsProcessingPdalAlgs::useIndexCopcFile() |
| 862 | +{ |
| 863 | + const QString pointCloudFileName = QString( TEST_DATA_DIR ) + "/point_clouds/las/cloud.las"; |
| 864 | + const QFileInfo pointCloudFileInfo( pointCloudFileName ); |
| 865 | + const QString pointCloudLayerPath = pointCloudFileInfo.filePath(); |
| 866 | + const QString copcIndexFileName = pointCloudFileInfo.absolutePath() + "/" + pointCloudFileInfo.completeBaseName() + ".copc.laz"; |
| 867 | + |
| 868 | + QgsPdalAlgorithmBase *alg = const_cast<QgsPdalAlgorithmBase *>( static_cast<const QgsPdalAlgorithmBase *>( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportvector" ) ) ) ); |
| 869 | + |
| 870 | + auto context = std::make_unique<QgsProcessingContext>(); |
| 871 | + context->setMaximumThreads( 0 ); |
| 872 | + |
| 873 | + QgsProcessingFeedback feedback; |
| 874 | + |
| 875 | + // generate index for use in algorithm |
| 876 | + QgsPointCloudLayer *lyr = new QgsPointCloudLayer( pointCloudLayerPath, "layer", "pdal" ); |
| 877 | + Q_UNUSED( lyr ); |
| 878 | + |
| 879 | + //wait for index to be generated |
| 880 | + while ( !QFileInfo::exists( copcIndexFileName ) ) |
| 881 | + { |
| 882 | + QThread::sleep( 1 ); |
| 883 | + } |
| 884 | + QVERIFY( QFileInfo::exists( copcIndexFileName ) ); |
| 885 | + |
| 886 | + const QString outputFile = QDir::tempPath() + "/points.gpkg"; |
| 887 | + |
| 888 | + QVariantMap parameters; |
| 889 | + parameters.insert( QStringLiteral( "INPUT" ), pointCloudLayerPath ); |
| 890 | + parameters.insert( QStringLiteral( "OUTPUT" ), outputFile ); |
| 891 | + |
| 892 | + QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); |
| 893 | + QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) << QStringLiteral( "--input=%1" ).arg( copcIndexFileName ) << QStringLiteral( "--output=%1" ).arg( outputFile ) ); |
| 894 | + QVERIFY( args.at( 1 ).endsWith( "copc.laz" ) ); |
| 895 | +} |
| 896 | + |
857 | 897 | QGSTEST_MAIN( TestQgsProcessingPdalAlgs )
|
858 | 898 | #include "testqgsprocessingpdalalgs.moc"
|
0 commit comments