Skip to content
Permalink
Browse files

Add some tests for ept and pdal layer loading, extent and crs

  • Loading branch information
nyalldawson committed Nov 6, 2020
1 parent 9c55b8b commit 88ac3ce589fbf17c426186c5523cecf093eec8f3
Showing with 43 additions and 0 deletions.
  1. +22 −0 tests/src/providers/testqgseptprovider.cpp
  2. +21 −0 tests/src/providers/testqgspdalprovider.cpp
@@ -28,6 +28,7 @@
#include "qgsapplication.h"
#include "qgsproviderregistry.h"
#include "qgseptprovider.h"
#include "qgspointcloudlayer.h"

/**
* \ingroup UnitTests
@@ -49,6 +50,8 @@ class TestQgsEptProvider : public QObject
void preferredUri();
void layerTypesForUri();
void uriIsBlocklisted();
void brokenPath();
void validLayer();

private:
QString mTestDataDir;
@@ -146,6 +149,25 @@ void TestQgsEptProvider::uriIsBlocklisted()
QVERIFY( QgsProviderRegistry::instance()->uriIsBlocklisted( QStringLiteral( "/home/nyall/ept-build.json" ) ) );
}

void TestQgsEptProvider::brokenPath()
{
// test loading a bad layer URI
std::unique_ptr< QgsPointCloudLayer > layer = qgis::make_unique< QgsPointCloudLayer >( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) );
QVERIFY( !layer->isValid() );
}

void TestQgsEptProvider::validLayer()
{
std::unique_ptr< QgsPointCloudLayer > layer = qgis::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "point_clouds/entwine/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) );
QVERIFY( layer->isValid() );

QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:28356" ) );
QGSCOMPARENEAR( layer->extent().xMinimum(), 498061.0, 0.1 );
QGSCOMPARENEAR( layer->extent().yMinimum(), 7050992.0, 0.1 );
QGSCOMPARENEAR( layer->extent().xMaximum(), 498068.0, 0.1 );
QGSCOMPARENEAR( layer->extent().yMaximum(), 7050998.0, 0.1 );
}


QGSTEST_MAIN( TestQgsEptProvider )
#include "testqgseptprovider.moc"
@@ -29,6 +29,7 @@
#include "qgsproviderregistry.h"
#include "qgspdalprovider.h"
#include "qgsmaplayer.h"
#include "qgspointcloudlayer.h"

/**
* \ingroup UnitTests
@@ -49,6 +50,8 @@ class TestQgsPdalProvider : public QObject
void decodeUri();
void layerTypesForUri();
void preferredUri();
void brokenPath();
void validLayer();

private:
QString mTestDataDir;
@@ -150,6 +153,24 @@ void TestQgsPdalProvider::preferredUri()
QVERIFY( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/cloud.las" ), QStringLiteral( "ept" ) ) );
}

void TestQgsPdalProvider::brokenPath()
{
// test loading a bad layer URI
std::unique_ptr< QgsPointCloudLayer > layer = qgis::make_unique< QgsPointCloudLayer >( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "pdal" ) );
QVERIFY( !layer->isValid() );
}

void TestQgsPdalProvider::validLayer()
{
std::unique_ptr< QgsPointCloudLayer > layer = qgis::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "point_clouds/las/cloud.las" ), QStringLiteral( "layer" ), QStringLiteral( "pdal" ) );
QVERIFY( layer->isValid() );

QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:28356" ) );
QGSCOMPARENEAR( layer->extent().xMinimum(), 498062.0, 0.1 );
QGSCOMPARENEAR( layer->extent().yMinimum(), 7050992.84, 0.1 );
QGSCOMPARENEAR( layer->extent().xMaximum(), 498067.39, 0.1 );
QGSCOMPARENEAR( layer->extent().yMaximum(), 7050997.04, 0.1 );
}

QGSTEST_MAIN( TestQgsPdalProvider )
#include "testqgspdalprovider.moc"

0 comments on commit 88ac3ce

Please sign in to comment.
You can’t perform that action at this time.