QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgseptpointcloudblockrequest.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscopcpointcloudblockrequest.cpp
3 --------------------
4 begin : March 2022
5 copyright : (C) 2022 by Belgacem Nedjima
6 email : belgacem dot nedjima at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19#include "moc_qgseptpointcloudblockrequest.cpp"
20
22#include "qgseptdecoder.h"
23#include "qgslazdecoder.h"
24#include "qgsapplication.h"
27
28//
29// QgsEptPointCloudBlockRequest
30//
31
33
34QgsEptPointCloudBlockRequest::QgsEptPointCloudBlockRequest( const QgsPointCloudNodeId &node, const QString &uri, const QString &dataType,
35 const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes,
36 const QgsVector3D &scale, const QgsVector3D &offset, const QgsPointCloudExpression &filterExpression, const QgsRectangle &filterRect )
37 : QgsPointCloudBlockRequest( node, uri, attributes, requestedAttributes, scale, offset, filterExpression, filterRect ),
38 mDataType( dataType )
39{
40 QNetworkRequest nr = QNetworkRequest( QUrl( mUri ) );
41 QgsSetRequestInitiatorClass( nr, QStringLiteral( "QgsEptPointCloudBlockRequest" ) );
43 nr.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
44 nr.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
45 mTileDownloadManagerReply.reset( QgsApplication::tileDownloadManager()->get( nr ) );
46 connect( mTileDownloadManagerReply.get(), &QgsTileDownloadManagerReply::finished, this, &QgsEptPointCloudBlockRequest::blockFinishedLoading );
47}
48
49void QgsEptPointCloudBlockRequest::blockFinishedLoading()
50{
51 mBlock = nullptr;
52 QString error;
53 if ( mTileDownloadManagerReply->error() == QNetworkReply::NetworkError::NoError )
54 {
55 try
56 {
57 mBlock = nullptr;
58 if ( mDataType == QLatin1String( "binary" ) )
59 {
61 }
62 else if ( mDataType == QLatin1String( "zstandard" ) )
63 {
65 }
66 else if ( mDataType == QLatin1String( "laszip" ) )
67 {
68 mBlock = QgsLazDecoder::decompressLaz( mTileDownloadManagerReply->data(), mRequestedAttributes, mFilterExpression, mFilterRect );
69 }
70 else
71 {
72 error = QStringLiteral( "Unknown data type %1;" ).arg( mDataType );
73 }
74 if ( mBlock )
75 {
80 }
81 }
82 catch ( std::exception &e )
83 {
84 error = QStringLiteral( "Decompression error: %1" ).arg( e.what() );
85 }
86 }
87 else
88 {
89 error = QStringLiteral( "Network request error: %1" ).arg( mTileDownloadManagerReply->errorString() );
90 }
91 if ( !error.isEmpty() )
92 {
93 mErrorStr = QStringLiteral( "Error loading point cloud tile %1: \" %2 \"" ).arg( mNode.toString(), error );
94 }
95 emit finished();
96}
97
static QgsTileDownloadManager * tileDownloadManager()
Returns the application's tile download manager, used for download of map tiles when rendering.
QgsEptPointCloudBlockRequest(const QgsPointCloudNodeId &node, const QString &Uri, const QString &dataType, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset, const QgsPointCloudExpression &filterExpression, const QgsRectangle &filterRect)
QgsPointCloudBlockRequest constructor Requests the block data of size blockSize at offset blockOffset...
Collection of point cloud attributes.
Base class for handling loading QgsPointCloudBlock asynchronously.
QgsPointCloudAttributeCollection mRequestedAttributes
std::unique_ptr< QgsTileDownloadManagerReply > mTileDownloadManagerReply
QgsPointCloudAttributeCollection mAttributes
std::unique_ptr< QgsPointCloudBlock > mBlock
QgsPointCloudExpression mFilterExpression
void finished()
Emitted when the request processing has finished.
static void storeNodeDataToCacheStatic(QgsPointCloudBlock *data, const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request, const QgsPointCloudExpression &expression, const QString &uri)
Stores existing data to the cache for the specified node, request, expression and uri.
Represents a indexed point cloud node's position in octree.
QString toString() const
Encode node to string.
Point cloud data request.
void setFilterRect(QgsRectangle extent)
Sets the rectangle from which points will be taken, in point cloud's crs.
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Set attributes filter in the request.
A rectangle specified with double values.
void finished()
Emitted when the reply has finished (either with a success or with a failure)
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
#define QgsSetRequestInitiatorClass(request, _class)
#define QgsSetRequestInitiatorId(request, str)