Skip to content

Commit

Permalink
Fix hierarchy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 8, 2021
1 parent cadbbd0 commit b061162
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/core/pointcloud/qgsremoteeptpointcloudindex.cpp
Expand Up @@ -45,7 +45,10 @@

///@cond PRIVATE

QgsRemoteEptPointCloudIndex::QgsRemoteEptPointCloudIndex() : QgsEptPointCloudIndex() { }
QgsRemoteEptPointCloudIndex::QgsRemoteEptPointCloudIndex() : QgsEptPointCloudIndex()
{
mHierarchyNodes.insert( IndexedPointCloudNode( 0, 0, 0, 0 ) );
}

QgsRemoteEptPointCloudIndex::~QgsRemoteEptPointCloudIndex() = default;

Expand All @@ -54,6 +57,7 @@ QList<IndexedPointCloudNode> QgsRemoteEptPointCloudIndex::nodeChildren( const In
QList<IndexedPointCloudNode> lst;
if ( !loadNodeHierarchy( n ) )
return lst;

int d = n.d() + 1;
int x = n.x() * 2;
int y = n.y() * 2;
Expand Down Expand Up @@ -158,17 +162,14 @@ bool QgsRemoteEptPointCloudIndex::loadNodeHierarchy( const IndexedPointCloudNode
while ( currentNode.d() >= 0 );
}

QSet<IndexedPointCloudNode> toBeLoaded;
toBeLoaded.insert( IndexedPointCloudNode::fromString( QStringLiteral( "0-0-0-0" ) ) );

for ( int i = nodePathToRoot.size() - 1; i >= 0 && !mHierarchy.contains( nodeId ); --i )
{
IndexedPointCloudNode node = nodePathToRoot[i];
//! The hierarchy of the node is found => No need to load its file
if ( mHierarchy.contains( node ) )
continue;

if ( !toBeLoaded.contains( node ) )
if ( !mHierarchyNodes.contains( node ) )
continue;

const QString fileUrl = QStringLiteral( "%1/ept-hierarchy/%2.json" ).arg( mUrlDirectoryPart, node.toString() );
Expand Down Expand Up @@ -201,15 +202,11 @@ bool QgsRemoteEptPointCloudIndex::loadNodeHierarchy( const IndexedPointCloudNode
{
QString nodeIdStr = it.key();
int nodePointCount = it.value().toInt();
IndexedPointCloudNode nodeId = IndexedPointCloudNode::fromString( nodeIdStr );
if ( nodePointCount > 0 )
{
IndexedPointCloudNode nodeId = IndexedPointCloudNode::fromString( nodeIdStr );
mHierarchy[nodeId] = nodePointCount;
}
else if ( nodePointCount == -1 )
{
toBeLoaded.insert( IndexedPointCloudNode::fromString( nodeIdStr ) );
}
mHierarchyNodes.insert( nodeId );
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/pointcloud/qgsremoteeptpointcloudindex.h
Expand Up @@ -26,6 +26,7 @@
#include <QList>
#include <QFile>
#include <QUrl>
#include <QSet>

#include "qgspointcloudindex.h"
#include "qgspointcloudattribute.h"
Expand Down Expand Up @@ -67,6 +68,9 @@ class CORE_EXPORT QgsRemoteEptPointCloudIndex: public QgsEptPointCloudIndex
QString mUrlFileNamePart;

QUrl mUrl;

//! Contains the nodes that will have */ept-hierarchy/d-x-y-z.json file
mutable QSet<IndexedPointCloudNode> mHierarchyNodes;
};

///@endcond
Expand Down

0 comments on commit b061162

Please sign in to comment.