Skip to content

Commit

Permalink
add /ept.json is missing message box and refactor nodeData
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 6288314 commit f65c7d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 59 deletions.
65 changes: 6 additions & 59 deletions src/core/pointcloud/qgsremoteeptpointcloudindex.cpp
Expand Up @@ -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 )
Expand Down
8 changes: 8 additions & 0 deletions src/gui/providers/qgspointcloudsourceselect.cpp
Expand Up @@ -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...
Expand Down

0 comments on commit f65c7d2

Please sign in to comment.