diff --git a/src/core/pointcloud/qgscopcpointcloudindex.cpp b/src/core/pointcloud/qgscopcpointcloudindex.cpp index 2c1ad603a2cd..dd6b4987c03d 100644 --- a/src/core/pointcloud/qgscopcpointcloudindex.cpp +++ b/src/core/pointcloud/qgscopcpointcloudindex.cpp @@ -460,7 +460,8 @@ QgsPointCloudNode QgsCopcPointCloudIndex::getNode( const QgsPointCloudNodeId &id } } - return QgsPointCloudNode( *this, id, pointCount, children ); + QgsBox3D bounds = QgsPointCloudNode::bounds( mRootBounds, id ); + return QgsPointCloudNode( id, pointCount, children, bounds.width() / mSpan, bounds ); } void QgsCopcPointCloudIndex::copyCommonProperties( QgsCopcPointCloudIndex *destination ) const diff --git a/src/core/pointcloud/qgseptpointcloudindex.cpp b/src/core/pointcloud/qgseptpointcloudindex.cpp index 4542279cf7b9..7f51fb830f04 100644 --- a/src/core/pointcloud/qgseptpointcloudindex.cpp +++ b/src/core/pointcloud/qgseptpointcloudindex.cpp @@ -498,7 +498,7 @@ QgsPointCloudNode QgsEptPointCloudIndex::getNode( const QgsPointCloudNodeId &id QMutexLocker locker( &mHierarchyMutex ); qint64 pointCount = mHierarchy.value( id, -1 ); if ( pointCount != -1 ) - return QgsPointCloudNode( *this, id, pointCount, node.children() ); + return QgsPointCloudNode( id, pointCount, node.children(), node.error(), node.bounds() ); } // If we fail, return with pointCount = -1 anyway diff --git a/src/core/pointcloud/qgspointcloudindex.cpp b/src/core/pointcloud/qgspointcloudindex.cpp index 724d1053e1ed..e52021d27406 100644 --- a/src/core/pointcloud/qgspointcloudindex.cpp +++ b/src/core/pointcloud/qgspointcloudindex.cpp @@ -122,23 +122,27 @@ uint qHash( const QgsPointCloudCacheKey &key ) QgsBox3D QgsPointCloudNode::bounds() const { - const QgsBox3D rootBounds = mIndex.rootNodeBounds(); + return mBounds; +} + +QgsBox3D QgsPointCloudNode::bounds( QgsBox3D rootBounds, QgsPointCloudNodeId id ) +{ const double d = rootBounds.xMaximum() - rootBounds.xMinimum(); - const double dLevel = d / pow( 2, mId.d() ); + const double dLevel = d / pow( 2, id.d() ); - const double xMin = rootBounds.xMinimum() + dLevel * mId.x(); - const double xMax = rootBounds.xMinimum() + dLevel * ( mId.x() + 1 ); - const double yMin = rootBounds.yMinimum() + dLevel * mId.y(); - const double yMax = rootBounds.yMinimum() + dLevel * ( mId.y() + 1 ); - const double zMin = rootBounds.zMinimum() + dLevel * mId.z(); - const double zMax = rootBounds.zMinimum() + dLevel * ( mId.z() + 1 ); + const double xMin = rootBounds.xMinimum() + dLevel * id.x(); + const double xMax = rootBounds.xMinimum() + dLevel * ( id.x() + 1 ); + const double yMin = rootBounds.yMinimum() + dLevel * id.y(); + const double yMax = rootBounds.yMinimum() + dLevel * ( id.y() + 1 ); + const double zMin = rootBounds.zMinimum() + dLevel * id.z(); + const double zMax = rootBounds.zMinimum() + dLevel * ( id.z() + 1 ); return QgsBox3D( xMin, yMin, zMin, xMax, yMax, zMax ); } float QgsPointCloudNode::error() const { - return bounds().width() / mIndex.span(); + return mError; } ///@endcond @@ -186,7 +190,8 @@ QgsPointCloudNode QgsPointCloudIndex::getNode( const QgsPointCloudNodeId &id ) c } } - return QgsPointCloudNode( *this, id, pointCount, children ); + QgsBox3D bounds = QgsPointCloudNode::bounds( mRootBounds, id ); + return QgsPointCloudNode( id, pointCount, children, bounds.width() / mSpan, bounds ); } QgsPointCloudAttributeCollection QgsPointCloudIndex::attributes() const diff --git a/src/core/pointcloud/qgspointcloudindex.h b/src/core/pointcloud/qgspointcloudindex.h index 215d9f0ab8fe..1a4e62879874 100644 --- a/src/core/pointcloud/qgspointcloudindex.h +++ b/src/core/pointcloud/qgspointcloudindex.h @@ -158,10 +158,14 @@ uint qHash( const QgsPointCloudCacheKey &key ); class CORE_EXPORT QgsPointCloudNode { public: - //! Constructs new node object. Should only be called by QgsPointCloudIndex::getNode() - QgsPointCloudNode( const QgsPointCloudIndex &index, QgsPointCloudNodeId id, qint64 pointCount, - QList childIds ) - : mIndex( index ), mId( id ), mPointCount( pointCount ), mChildIds( childIds ) + + /** + * Constructs new node object. Should only be called by QgsPointCloudIndex::getNode(). + * Bounds should always be computed by QgsPointCloudNode::bounds(). + */ + QgsPointCloudNode( QgsPointCloudNodeId id, qint64 pointCount, + QList childIds, float error, QgsBox3D bounds ) + : mId( id ), mPointCount( pointCount ), mChildIds( childIds ), mError( error ), mBounds( bounds ) { } //! Returns node's ID (unique in index) @@ -175,12 +179,16 @@ class CORE_EXPORT QgsPointCloudNode //! Returns node's bounding cube in CRS coords QgsBox3D bounds() const; + //! Returns bounding box of specific node + static QgsBox3D bounds( QgsBox3D rootBounds, QgsPointCloudNodeId id ); + private: - const QgsPointCloudIndex &mIndex; // Specific node metadata: QgsPointCloudNodeId mId; qint64 mPointCount; QList mChildIds; + float mError; + QgsBox3D mBounds; }; /**