diff --git a/src/core/pointcloud/qgscopcpointcloudindex.cpp b/src/core/pointcloud/qgscopcpointcloudindex.cpp index ac2b0c06e11d..2f130eb127fb 100644 --- a/src/core/pointcloud/qgscopcpointcloudindex.cpp +++ b/src/core/pointcloud/qgscopcpointcloudindex.cpp @@ -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 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 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 ); } diff --git a/src/core/pointcloud/qgspointcloudlayer.cpp b/src/core/pointcloud/qgspointcloudlayer.cpp index 2bcf85332a0b..e2288ad901d8 100644 --- a/src/core/pointcloud/qgspointcloudlayer.cpp +++ b/src/core/pointcloud/qgspointcloudlayer.cpp @@ -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(); diff --git a/tests/src/providers/testqgscopcprovider.cpp b/tests/src/providers/testqgscopcprovider.cpp index be1c34dcaf55..48d273b1c8be 100644 --- a/tests/src/providers/testqgscopcprovider.cpp +++ b/tests/src/providers/testqgscopcprovider.cpp @@ -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 ); diff --git a/tests/src/providers/testqgseptprovider.cpp b/tests/src/providers/testqgseptprovider.cpp index e312fc8a8419..2797ab7e6504 100644 --- a/tests/src/providers/testqgseptprovider.cpp +++ b/tests/src/providers/testqgseptprovider.cpp @@ -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) } {