Skip to content
Permalink
Browse files
add /ept.json is missing message box and refactor nodeData
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 8, 2021
1 parent 6288314 commit f65c7d210c87f48646cc78717f288034512f824b
@@ -88,73 +88,20 @@ void QgsRemoteEptPointCloudIndex::load( const QString &url )

QgsPointCloudBlock *QgsRemoteEptPointCloudIndex::nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request )
{
if ( !loadNodeHierarchy( n ) )
QgsPointCloudBlockRequest *blockRequest = asyncNodeData( n, request );
if ( !blockRequest )
return nullptr;

QString fileUrl;
QString fileName;
if ( mDataType == QLatin1String( "binary" ) )
{

fileUrl = QStringLiteral( "%1/ept-data/%2.bin" ).arg( mUrlDirectoryPart, n.toString() );
fileName = QStringLiteral( "/tmp/%1.bin" ).arg( n.toString() );
}
else if ( mDataType == QLatin1String( "zstandard" ) )
{
fileUrl = QStringLiteral( "%1/ept-data/%2.zst" ).arg( mUrlDirectoryPart, n.toString() );
fileName = QStringLiteral( "/tmp/%1.zst" ).arg( n.toString() );
}
else if ( mDataType == QLatin1String( "laszip" ) )
{
fileUrl = QStringLiteral( "%1/ept-data/%2.laz" ).arg( mUrlDirectoryPart, n.toString() );
fileName = QStringLiteral( "/tmp/%1.laz" ).arg( n.toString() );
}
else
{
return nullptr; // unsupported
}

QgsFileDownloader downloader( fileUrl, fileName );

QEventLoop loop;

QUrl downloadedUrl;
QStringList errorMessages;
connect( &downloader, &QgsFileDownloader::downloadCompleted, [&]( const QUrl & url )
{
downloadedUrl = url;
loop.quit();
} );
connect( &downloader, &QgsFileDownloader::downloadCanceled, &loop, &QEventLoop::quit );
connect( &downloader, &QgsFileDownloader::downloadError, [&]( QStringList errorMessagesList )
{
errorMessages = errorMessagesList;
loop.exit();
} );

downloader.startDownload();
connect( blockRequest, &QgsPointCloudBlockRequest::finished, &loop, &QEventLoop::quit );
loop.exec();

if ( downloadedUrl.isEmpty() )
if ( !blockRequest->block() )
{
qDebug() << "Error downloading " << fileUrl << " : " << errorMessages;
return nullptr;
QgsDebugMsg( QStringLiteral( "Error downloading node %1 data, error : %2 " ).arg( n.toString(), blockRequest->errorStr() ) );
}
qDebug() << "File downloaded";

if ( mDataType == QLatin1String( "binary" ) )
{
return QgsEptDecoder::decompressBinary( fileName, attributes(), request.attributes() );
}
else if ( mDataType == QLatin1String( "zstandard" ) )
{
return QgsEptDecoder::decompressZStandard( fileName, attributes(), request.attributes() );
}
else if ( mDataType == QLatin1String( "laszip" ) )
{
return QgsEptDecoder::decompressLaz( fileName, attributes(), request.attributes() );
}
return nullptr;
return blockRequest->block();
}

QgsPointCloudBlockRequest *QgsRemoteEptPointCloudIndex::asyncNodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request )
@@ -92,6 +92,14 @@ void QgsPointCloudSourceSelect::addButtonClicked()
return;
}

if ( !mPath.endsWith( QStringLiteral( "/ept.json" ) ) )
{
QMessageBox::information( this,
tr( "Add Point Cloud Layers" ),
tr( "Unvalid point cloud URL \"%1\", please make sure your URL ends with /ept.json" ).arg( mPath ) );
return;
}

// auto determine preferred provider for each path
const QList< QgsProviderRegistry::ProviderCandidateDetails > preferredProviders = QgsProviderRegistry::instance()->preferredProvidersForUri( mPath );
// maybe we should raise an assert if preferredProviders size is 0 or >1? Play it safe for now...

0 comments on commit f65c7d2

Please sign in to comment.