QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
20 #include "qgstiledownloadmanager.h"
21 #include "qgseptdecoder.h"
22 #include "qgslazdecoder.h"
23 #include "qgsapplication.h"
25 
26 //
27 // QgsEptPointCloudBlockRequest
28 //
29 
31 
32 QgsEptPointCloudBlockRequest::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 )
35  : QgsPointCloudBlockRequest( node, uri, attributes, requestedAttributes, scale, offset, filterExpression ),
36  mDataType( dataType )
37 {
38  QNetworkRequest nr( mUri );
39  nr.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
40  nr.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
42  connect( mTileDownloadManagerReply.get(), &QgsTileDownloadManagerReply::finished, this, &QgsEptPointCloudBlockRequest::blockFinishedLoading );
43 }
44 
45 void 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  {
56  mBlock = QgsEptDecoder::decompressBinary( mTileDownloadManagerReply->data(), mAttributes, mRequestedAttributes, mScale, mOffset, mFilterExpression );
57  }
58  else if ( mDataType == QLatin1String( "zstandard" ) )
59  {
60  mBlock = QgsEptDecoder::decompressZStandard( mTileDownloadManagerReply->data(), mAttributes, mRequestedAttributes, mScale, mOffset, mFilterExpression );
61  }
62  else if ( mDataType == QLatin1String( "laszip" ) )
63  {
64  mBlock = QgsLazDecoder::decompressLaz( mTileDownloadManagerReply->data(), mRequestedAttributes, mFilterExpression );
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 
QgsPointCloudBlockRequest::mNode
IndexedPointCloudNode mNode
Definition: qgspointcloudblockrequest.h:66
qgsremoteeptpointcloudindex.h
QgsEptPointCloudBlockRequest::QgsEptPointCloudBlockRequest
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)
QgsPointCloudBlockRequest constructor Requests the block data of size blockSize at offset blockOffset...
QgsTileDownloadManagerReply::finished
void finished()
Emitted when the reply has finished (either with a success or with a failure)
QgsPointCloudBlockRequest::mScale
QgsVector3D mScale
Definition: qgspointcloudblockrequest.h:73
qgstiledownloadmanager.h
QgsApplication::tileDownloadManager
static QgsTileDownloadManager * tileDownloadManager()
Returns the application's tile download manager, used for download of map tiles when rendering.
Definition: qgsapplication.cpp:2430
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
qgseptpointcloudblockrequest.h
qgseptdecoder.h
qgsapplication.h
IndexedPointCloudNode
Represents a indexed point cloud node in octree.
Definition: qgspointcloudindex.h:57
QgsPointCloudBlockRequest::mBlock
QgsPointCloudBlock * mBlock
Definition: qgspointcloudblockrequest.h:71
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsPointCloudBlockRequest::mAttributes
QgsPointCloudAttributeCollection mAttributes
Definition: qgspointcloudblockrequest.h:68
QgsPointCloudBlockRequest::mRequestedAttributes
QgsPointCloudAttributeCollection mRequestedAttributes
Definition: qgspointcloudblockrequest.h:69
QgsPointCloudBlockRequest::mUri
QString mUri
Definition: qgspointcloudblockrequest.h:67
qgslazdecoder.h
QgsPointCloudBlockRequest::mErrorStr
QString mErrorStr
Definition: qgspointcloudblockrequest.h:72
QgsPointCloudBlockRequest
Base class for handling loading QgsPointCloudBlock asynchronously.
Definition: qgspointcloudblockrequest.h:36
QgsPointCloudBlockRequest::mOffset
QgsVector3D mOffset
Definition: qgspointcloudblockrequest.h:73
QgsPointCloudBlockRequest::finished
void finished()
Emitted when the request processing has finished.
IndexedPointCloudNode::toString
QString toString() const
Encode node to string.
Definition: qgspointcloudindex.cpp:58
QgsPointCloudBlockRequest::mTileDownloadManagerReply
std::unique_ptr< QgsTileDownloadManagerReply > mTileDownloadManagerReply
Definition: qgspointcloudblockrequest.h:70
QgsPointCloudBlockRequest::mFilterExpression
QgsPointCloudExpression mFilterExpression
Definition: qgspointcloudblockrequest.h:74