24#include <QJsonDocument>
38#include "qgspointcloudexpression.h"
44QgsRemoteCopcPointCloudIndex::QgsRemoteCopcPointCloudIndex() =
default;
46QgsRemoteCopcPointCloudIndex::~QgsRemoteCopcPointCloudIndex() =
default;
48std::unique_ptr<QgsPointCloudIndex> QgsRemoteCopcPointCloudIndex::clone()
const
50 QgsRemoteCopcPointCloudIndex *clone =
new QgsRemoteCopcPointCloudIndex;
51 QMutexLocker locker( &mHierarchyMutex );
52 copyCommonProperties( clone );
53 return std::unique_ptr<QgsPointCloudIndex>( clone );
56void QgsRemoteCopcPointCloudIndex::load(
const QString &uri )
61 mIsValid = mLazInfo->isValid();
64 mIsValid = loadSchema( *mLazInfo.get() );
72 mError = tr(
"Unable to recognize %1 as a LAZ file: \"%2\"" ).arg( uri, mLazInfo->error() );
80 return std::unique_ptr<QgsPointCloudBlock>( cached );
83 std::unique_ptr<QgsPointCloudBlockRequest> blockRequest( asyncNodeData( n, request ) );
91 std::unique_ptr<QgsPointCloudBlock> block = blockRequest->takeBlock();
95 QgsDebugError( QStringLiteral(
"Error downloading node %1 data, error : %2 " ).arg( n.
toString(), blockRequest->errorStr() ) );
98 storeNodeDataToCache( block.get(), n, request );
107 scale(), offset(), mFilterExpression, request.
filterRect() );
110 if ( !fetchNodeHierarchy( n ) )
112 QMutexLocker locker( &mHierarchyMutex );
117 QgsPointCloudExpression filterExpression = mFilterExpression;
119 requestAttributes.
extend( attributes(), filterExpression.referencedAttributes() );
120 auto [ blockOffset, blockSize ] = mHierarchyNodePos.value( n );
121 int pointCount = mHierarchy.value( n );
124 scale(), offset(), filterExpression, request.
filterRect(),
125 blockOffset, blockSize, pointCount, *mLazInfo.get() );
128bool QgsRemoteCopcPointCloudIndex::isValid()
const
133void QgsRemoteCopcPointCloudIndex::fetchHierarchyPage( uint64_t offset, uint64_t byteSize )
const
135 Q_ASSERT( byteSize > 0 );
137 QNetworkRequest nr = QNetworkRequest( QUrl( mUri ) );
139 nr.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
140 nr.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
141 QByteArray queryRange = QStringLiteral(
"bytes=%1-%2" ).arg( offset ).arg( offset + byteSize - 1 ).toLocal8Bit();
142 nr.setRawHeader(
"Range", queryRange );
150 if ( reply->error() != QNetworkReply::NoError )
152 QgsDebugError( QStringLiteral(
"Request failed: " ) + mUri );
156 QByteArray data = reply->data();
158 populateHierarchy( data.constData(), byteSize );
161void QgsRemoteCopcPointCloudIndex::copyCommonProperties( QgsRemoteCopcPointCloudIndex *destination )
const
163 QgsCopcPointCloudIndex::copyCommonProperties( destination );
166 destination->mHierarchyNodes = mHierarchyNodes;
Represents a indexed point cloud node in octree.
QString toString() const
Encode node to string.
static QgsTileDownloadManager * tileDownloadManager()
Returns the application's tile download manager, used for download of map tiles when rendering.
Class for handling a QgsPointCloudBlockRequest using existing cached QgsPointCloudBlock.
Base class for handling loading QgsPointCloudBlock asynchronously from a remote COPC dataset.
Class for extracting information contained in LAZ file such as the public header block and variable l...
static QgsLazInfo fromUrl(QUrl &url)
Static function to create a QgsLazInfo class from a file over network.
Collection of point cloud attributes.
void extend(const QgsPointCloudAttributeCollection &otherCollection, const QSet< QString > &matchingNames)
Adds specific missing attributes from another QgsPointCloudAttributeCollection.
Base class for handling loading QgsPointCloudBlock asynchronously.
void finished()
Emitted when the request processing has finished.
Base class for storing raw data from point cloud nodes.
Point cloud data request.
QgsPointCloudAttributeCollection attributes() const
Returns attributes.
QgsRectangle filterRect() const
Returns the rectangle from which points will be taken, in point cloud's crs.
void finished()
Emitted when the reply has finished (either with a success or with a failure)
#define QgsDebugError(str)
#define QgsSetRequestInitiatorClass(request, _class)