19#include "moc_qgsremotecopcpointcloudindex.cpp"
25#include <QJsonDocument>
39#include "qgspointcloudexpression.h"
45QgsRemoteCopcPointCloudIndex::QgsRemoteCopcPointCloudIndex() =
default;
47QgsRemoteCopcPointCloudIndex::~QgsRemoteCopcPointCloudIndex() =
default;
49std::unique_ptr<QgsPointCloudIndex> QgsRemoteCopcPointCloudIndex::clone()
const
51 QgsRemoteCopcPointCloudIndex *clone =
new QgsRemoteCopcPointCloudIndex;
52 QMutexLocker locker( &mHierarchyMutex );
53 copyCommonProperties( clone );
54 return std::unique_ptr<QgsPointCloudIndex>( clone );
57void QgsRemoteCopcPointCloudIndex::load(
const QString &uri )
62 mIsValid = mLazInfo->isValid();
65 mIsValid = loadSchema( *mLazInfo.get() );
73 mError = tr(
"Unable to recognize %1 as a LAZ file: \"%2\"" ).arg( uri, mLazInfo->error() );
81 return std::unique_ptr<QgsPointCloudBlock>( cached );
84 std::unique_ptr<QgsPointCloudBlockRequest> blockRequest( asyncNodeData( n, request ) );
92 std::unique_ptr<QgsPointCloudBlock> block = blockRequest->takeBlock();
96 QgsDebugError( QStringLiteral(
"Error downloading node %1 data, error : %2 " ).arg( n.
toString(), blockRequest->errorStr() ) );
99 storeNodeDataToCache( block.get(), n, request );
108 scale(), offset(), mFilterExpression, request.
filterRect() );
111 if ( !fetchNodeHierarchy( n ) )
113 QMutexLocker locker( &mHierarchyMutex );
118 QgsPointCloudExpression filterExpression = mFilterExpression;
120 requestAttributes.
extend( attributes(), filterExpression.referencedAttributes() );
121 auto [ blockOffset, blockSize ] = mHierarchyNodePos.value( n );
122 int pointCount = mHierarchy.value( n );
125 scale(), offset(), filterExpression, request.
filterRect(),
126 blockOffset, blockSize, pointCount, *mLazInfo.get() );
129bool QgsRemoteCopcPointCloudIndex::isValid()
const
134void QgsRemoteCopcPointCloudIndex::fetchHierarchyPage( uint64_t offset, uint64_t byteSize )
const
136 Q_ASSERT( byteSize > 0 );
138 QNetworkRequest nr = QNetworkRequest( QUrl( mUri ) );
140 nr.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
141 nr.setAttribute( QNetworkRequest::CacheSaveControlAttribute,
true );
142 QByteArray queryRange = QStringLiteral(
"bytes=%1-%2" ).arg( offset ).arg( offset + byteSize - 1 ).toLocal8Bit();
143 nr.setRawHeader(
"Range", queryRange );
151 if ( reply->error() != QNetworkReply::NoError )
153 QgsDebugError( QStringLiteral(
"Request failed: " ) + mUri );
157 QByteArray data = reply->data();
159 populateHierarchy( data.constData(), byteSize );
162void QgsRemoteCopcPointCloudIndex::copyCommonProperties( QgsRemoteCopcPointCloudIndex *destination )
const
164 QgsCopcPointCloudIndex::copyCommonProperties( destination );
167 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)