Further fix tests

This commit is contained in:
David Koňařík 2024-11-28 17:45:18 +01:00 committed by Martin Dobias
parent 406a1b5bec
commit 5ac1517f43
4 changed files with 21 additions and 34 deletions

View File

@ -432,31 +432,28 @@ bool QgsCopcPointCloudIndex::hasNode( const QgsPointCloudNodeId &n ) const
QgsPointCloudNode QgsCopcPointCloudIndex::getNode( const QgsPointCloudNodeId &id ) const
{
fetchNodeHierarchy( id );
Q_ASSERT( fetchNodeHierarchy( id ) );
qint64 pointCount;
QList<QgsPointCloudNodeId> children;
{
QMutexLocker locker( &mHierarchyMutex );
pointCount = mHierarchy.value( id, -1 );
}
auto hierarchyIt = mHierarchy.constFind( id );
Q_ASSERT( hierarchyIt != mHierarchy.constEnd() );
children.reserve( 8 );
const int d = id.d() + 1;
const int x = id.x() * 2;
const int y = id.y() * 2;
const int z = id.z() * 2;
QList<QgsPointCloudNodeId> children;
children.reserve( 8 );
const int d = id.d() + 1;
const int x = id.x() * 2;
const int y = id.y() * 2;
const int z = id.z() * 2;
for ( int i = 0; i < 8; ++i )
for ( int i = 0; i < 8; ++i )
{
int dx = i & 1, dy = !!( i & 2 ), dz = !!( i & 4 );
const QgsPointCloudNodeId n2( d, x + dx, y + dy, z + dz );
bool found = fetchNodeHierarchy( n2 );
{
int dx = i & 1, dy = !!( i & 2 ), dz = !!( i & 4 );
const QgsPointCloudNodeId n2( d, x + dx, y + dy, z + dz );
mHierarchyMutex.unlock();
bool found = fetchNodeHierarchy( n2 );
mHierarchyMutex.lock();
QMutexLocker locker( &mHierarchyMutex );
if ( found && mHierarchy[id] >= 0 )
children.append( n2 );
}

View File

@ -871,10 +871,11 @@ void QgsPointCloudLayer::calculateStatistics()
}
}
// Use the layer statistics for now, until we can calculate complete ones
mStatistics = indexStats;
if ( attributes.empty() && indexStats.sampledPointsCount() > 0 )
{
// All attributes are covered by the saved stats, use them directly
mStatistics = indexStats;
// All attributes are covered by the saved stats, skip calculating anything
mStatisticsCalculationState = QgsPointCloudLayer::PointCloudStatisticsCalculationState::Calculated;
emit statisticsCalculationStateChanged( mStatisticsCalculationState );
resetRenderer();

View File

@ -828,9 +828,9 @@ void TestQgsCopcProvider::testPointCloudIndex()
QVERIFY( index->isValid() );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "0-0-0-0" ) ) ).pointCount(), 56721 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "1-1-1-1" ) ) ).pointCount(), -1 );
QVERIFY( !index->hasNode( QgsPointCloudNodeId::fromString( QStringLiteral( "1-1-1-1" ) ) ) );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "2-3-3-1" ) ) ).pointCount(), 446 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "9-9-9-9" ) ) ).pointCount(), -1 );
QVERIFY( !index->hasNode( QgsPointCloudNodeId::fromString( QStringLiteral( "9-9-9-9" ) ) ) );
QCOMPARE( index->pointCount(), 518862 );
QCOMPARE( index->zMin(), 2322.89625 );
@ -840,7 +840,6 @@ void TestQgsCopcProvider::testPointCloudIndex()
QCOMPARE( index->span(), 128 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "0-0-0-0" ) ) ).error(), 0.328125 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "1-1-1-1" ) ) ).error(), 0.1640625 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "2-3-3-1" ) ) ).error(), 0.08203125 );
{
@ -854,7 +853,7 @@ void TestQgsCopcProvider::testPointCloudIndex()
}
{
QgsBox3D bounds = index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "1-1-1-1" ) ) ).bounds();
QgsBox3D bounds = QgsPointCloudNode::bounds( index->rootNodeBounds(), QgsPointCloudNodeId::fromString( QStringLiteral( "1-1-1-1" ) ) );
QCOMPARE( bounds.xMinimum(), 515389 );
QCOMPARE( bounds.yMinimum(), 4918361 );
QCOMPARE( bounds.zMinimum(), 2343 );

View File

@ -633,7 +633,7 @@ void TestQgsEptProvider::testPointCloudIndex()
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "0-0-0-0" ) ) ).pointCount(), 41998 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "1-1-1-1" ) ) ).pointCount(), 48879 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "2-3-3-1" ) ) ).pointCount(), 41734 );
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "9-9-9-9" ) ) ).pointCount(), -1 );
QVERIFY( !index->hasNode( QgsPointCloudNodeId::fromString( QStringLiteral( "9-9-9-9" ) ) ) );
QCOMPARE( index->pointCount(), 518862 );
QCOMPARE( index->zMin(), 2322 );
@ -647,15 +647,6 @@ void TestQgsEptProvider::testPointCloudIndex()
QCOMPARE( index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "2-3-3-1" ) ) ).error(), 0.0859375 );
{
<<<<<<< HEAD
QgsPointCloudDataBounds bounds = index->nodeBounds( IndexedPointCloudNode::fromString( QStringLiteral( "0-0-0-0" ) ) );
QCOMPARE( bounds.xMin(), -88000 );
QCOMPARE( bounds.yMin(), -88000 );
QCOMPARE( bounds.zMin(), -88000 );
QCOMPARE( bounds.xMax(), 88000 );
QCOMPARE( bounds.yMax(), 88000 );
QCOMPARE( bounds.zMax(), 88000 );
=======
QgsBox3D bounds = index->getNode( QgsPointCloudNodeId::fromString( QStringLiteral( "0-0-0-0" ) ) ).bounds();
QCOMPARE( bounds.xMinimum(), 515363 );
QCOMPARE( bounds.yMinimum(), 4918339 );
@ -663,7 +654,6 @@ void TestQgsEptProvider::testPointCloudIndex()
QCOMPARE( bounds.xMaximum(), 515407 );
QCOMPARE( bounds.yMaximum(), 4918383 );
QCOMPARE( bounds.zMaximum(), 2353 );
>>>>>>> 4bac513354a (Refactor QgsPointCloudIndex)
}
{