QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
21#include "qgseptdecoder.h"
22#include "qgslazdecoder.h"
23#include "qgsapplication.h"
25
26//
27// QgsEptPointCloudBlockRequest
28//
29
31
32QgsEptPointCloudBlockRequest::QgsEptPointCloudBlockRequest( const IndexedPointCloudNode &node, const QString &uri, const QString &dataType,
33 const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes,
34 const QgsVector3D &scale, const QgsVector3D &offset, const QgsPointCloudExpression &filterExpression, const QgsRectangle &filterRect )
35 : QgsPointCloudBlockRequest( node, uri, attributes, requestedAttributes, scale, offset, filterExpression, filterRect ),
36 mDataType( dataType )
37{
38 QNetworkRequest nr( mUri );
39 QgsSetRequestInitiatorClass( nr, QStringLiteral( "QgsEptPointCloudBlockRequest" ) );
41 nr.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
42 nr.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
43 mTileDownloadManagerReply.reset( QgsApplication::tileDownloadManager()->get( nr ) );
44 connect( mTileDownloadManagerReply.get(), &QgsTileDownloadManagerReply::finished, this, &QgsEptPointCloudBlockRequest::blockFinishedLoading );
45}
46
47void QgsEptPointCloudBlockRequest::blockFinishedLoading()
48{
49 mBlock = nullptr;
50 QString error;
51 if ( mTileDownloadManagerReply->error() == QNetworkReply::NetworkError::NoError )
52 {
53 try
54 {
55 mBlock = nullptr;
56 if ( mDataType == QLatin1String( "binary" ) )
57 {
59 }
60 else if ( mDataType == QLatin1String( "zstandard" ) )
61 {
63 }
64 else if ( mDataType == QLatin1String( "laszip" ) )
65 {
66 mBlock = QgsLazDecoder::decompressLaz( mTileDownloadManagerReply->data(), mRequestedAttributes, mFilterExpression, mFilterRect );
67 }
68 else
69 {
70 error = QStringLiteral( "Unknown data type %1;" ).arg( mDataType );
71 }
72 }
73 catch ( std::exception &e )
74 {
75 error = QStringLiteral( "Decompression error: %1" ).arg( e.what() );
76 }
77 }
78 else
79 {
80 error = QStringLiteral( "Network request error: %1" ).arg( mTileDownloadManagerReply->errorString() );
81 }
82 if ( !error.isEmpty() )
83 {
84 mErrorStr = QStringLiteral( "Error loading point cloud tile %1: \" %2 \"" ).arg( mNode.toString(), error );
85 }
86 emit finished();
87}
88
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.
QgsEptPointCloudBlockRequest(const IndexedPointCloudNode &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.
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:32
#define QgsSetRequestInitiatorClass(request, _class)
#define QgsSetRequestInitiatorId(request, str)