Skip to content

Commit

Permalink
switch to use QTemporaryFile
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 8, 2021
1 parent aca1146 commit a297d84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/core/pointcloud/qgseptdecoder.cpp
Expand Up @@ -27,6 +27,7 @@
#include <iostream>
#include <memory>
#include <cstring>
#include <QTemporaryFile>

#include <zstd.h>

Expand Down Expand Up @@ -478,12 +479,16 @@ QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
);
}

#include <QDebug>

QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QByteArray &byteArrayData,
const QString &nodeStr,
const QgsPointCloudAttributeCollection &attributes,
const QgsPointCloudAttributeCollection &requestedAttributes )
{
QString filename = QDir::tempPath() + QDir::separator() + QStringLiteral( "%1.laz" ).arg( nodeStr );
QTemporaryFile tempFile;
if ( !tempFile.open() )
return nullptr;
QString filename = tempFile.fileName();
std::ofstream file( filename.toStdString(), std::ios::binary | std::ios::out );
if ( file.is_open() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/pointcloud/qgseptdecoder.h
Expand Up @@ -36,7 +36,7 @@ namespace QgsEptDecoder
QgsPointCloudBlock *decompressZStandard( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressZStandard( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressLaz( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressLaz( const QByteArray &data, const QString &nodeStr, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressLaz( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
};

///@endcond
Expand Down
2 changes: 1 addition & 1 deletion src/core/pointcloud/qgspointcloudblockrequest.cpp
Expand Up @@ -66,7 +66,7 @@ void QgsPointCloudBlockRequest::blockFinishedLoading()
}
else if ( mDataType == QLatin1String( "laszip" ) )
{
mBlock = QgsEptDecoder::decompressLaz( mTileDownloadManagetReply->data(), mNode.toString(), mAttributes, mRequestedAttributes );
mBlock = QgsEptDecoder::decompressLaz( mTileDownloadManagetReply->data(), mAttributes, mRequestedAttributes );
}
else
{
Expand Down

0 comments on commit a297d84

Please sign in to comment.