QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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 nr.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
40 nr.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
41 mTileDownloadManagerReply.reset( QgsApplication::tileDownloadManager()->get( nr ) );
42 connect( mTileDownloadManagerReply.get(), &QgsTileDownloadManagerReply::finished, this, &QgsEptPointCloudBlockRequest::blockFinishedLoading );
43}
44
45void QgsEptPointCloudBlockRequest::blockFinishedLoading()
46{
47 mBlock = nullptr;
48 QString error;
49 if ( mTileDownloadManagerReply->error() == QNetworkReply::NetworkError::NoError )
50 {
51 try
52 {
53 mBlock = nullptr;
54 if ( mDataType == QLatin1String( "binary" ) )
55 {
57 }
58 else if ( mDataType == QLatin1String( "zstandard" ) )
59 {
61 }
62 else if ( mDataType == QLatin1String( "laszip" ) )
63 {
64 mBlock = QgsLazDecoder::decompressLaz( mTileDownloadManagerReply->data(), mRequestedAttributes, mFilterExpression, mFilterRect );
65 }
66 else
67 {
68 error = QStringLiteral( "Unknown data type %1;" ).arg( mDataType );
69 }
70 }
71 catch ( std::exception &e )
72 {
73 error = QStringLiteral( "Decompression error: %1" ).arg( e.what() );
74 }
75 }
76 else
77 {
78 error = QStringLiteral( "Network request error: %1" ).arg( mTileDownloadManagerReply->errorString() );
79 }
80 if ( !error.isEmpty() )
81 {
82 mErrorStr = QStringLiteral( "Error loading point cloud tile %1: \" %2 \"" ).arg( mNode.toString(), error );
83 }
84 emit finished();
85}
86
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
QgsPointCloudExpression mFilterExpression
void finished()
Emitted when the request processing has finished.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
void finished()
Emitted when the reply has finished (either with a success or with a failure)