Skip to content

Commit

Permalink
Further fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdkon committed Dec 2, 2024
1 parent cd61f2d commit 16058f4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
31 changes: 14 additions & 17 deletions src/core/pointcloud/qgscopcpointcloudindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/pointcloud/qgspointcloudlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions tests/src/providers/testqgscopcprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );

{
Expand All @@ -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 );
Expand Down
12 changes: 1 addition & 11 deletions tests/src/providers/testqgseptprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -647,23 +647,13 @@ 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 );
QCOMPARE( bounds.zMinimum(), 2309 );
QCOMPARE( bounds.xMaximum(), 515407 );
QCOMPARE( bounds.yMaximum(), 4918383 );
QCOMPARE( bounds.zMaximum(), 2353 );
>>>>>>> 4bac513354a (Refactor QgsPointCloudIndex)
}

{
Expand Down

0 comments on commit 16058f4

Please sign in to comment.