Skip to content
Permalink
Browse files
UI initial implementation for remote ept files
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 8, 2021
1 parent e870065 commit ede1c6394e90c76747cc6ab3e10dfce41e215cf3
Showing with 473 additions and 99 deletions.
  1. +40 −0 python/core/auto_generated/pointcloud/qgspointcloudblockhandle.sip.in
  2. +1 −0 python/core/auto_generated/pointcloud/qgspointcloudlayer.sip.in
  3. +1 −0 python/core/auto_generated/qgsprovidermetadata.sip.in
  4. +1 −0 python/core/auto_generated/qgsproviderregistry.sip.in
  5. +1 −1 python/gui/auto_generated/qgisinterface.sip.in
  6. +1 −1 python/gui/auto_generated/qgsabstractdatasourcewidget.sip.in
  7. +19 −7 src/app/qgisapp.cpp
  8. +2 −1 src/app/qgisapp.h
  9. +2 −2 src/app/qgisappinterface.cpp
  10. +1 −1 src/app/qgisappinterface.h
  11. +12 −2 src/core/pointcloud/qgspointcloudblockhandle.h
  12. +5 −2 src/core/pointcloud/qgspointcloudlayer.cpp
  13. +3 −0 src/core/pointcloud/qgspointcloudlayer.h
  14. +2 −0 src/core/pointcloud/qgspointcloudlayerrenderer.cpp
  15. +23 −4 src/core/providers/ept/qgseptprovider.cpp
  16. +5 −0 src/core/providers/ept/qgseptprovider.h
  17. +9 −0 src/core/qgsprovidermetadata.cpp
  18. +3 −0 src/core/qgsprovidermetadata.h
  19. +9 −0 src/core/qgsproviderregistry.cpp
  20. +3 −0 src/core/qgsproviderregistry.h
  21. +6 −6 src/gui/providers/ogr/qgsogrsourceselect.h
  22. +105 −11 src/gui/providers/qgspointcloudsourceselect.cpp
  23. +8 −1 src/gui/providers/qgspointcloudsourceselect.h
  24. +1 −1 src/gui/qgisinterface.h
  25. +1 −1 src/gui/qgsabstractdatasourcewidget.h
  26. +4 −1 src/gui/qgsbrowserdockwidget_p.cpp
  27. +1 −1 src/gui/qgsdatasourcemanagerdialog.h
  28. +1 −0 src/ui/mesh/qgsmdalsourceselectbase.ui
  29. +201 −56 src/ui/pointcloud/qgspointcloudsourceselectbase.ui
  30. +2 −0 tests/src/providers/testqgspdalprovider.cpp
@@ -0,0 +1,40 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/pointcloud/qgspointcloudblockhandle.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsPointCloudBlockHandle : QObject
{
%Docstring
Base class for handling loading :py:class:`QgsPointCloudBlock` asynchronously

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.20
%End

%TypeHeaderCode
#include "qgspointcloudblockhandle.h"
%End
public:
QgsPointCloudBlockHandle( const QString &dataType, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, QgsTileDownloadManagerReply *tileDownloadManagerReply );
signals:
void blockLoadingSucceeded( QgsPointCloudBlock *block );
void blockLoadingFailed( const QString &errorStr );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/pointcloud/qgspointcloudblockhandle.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -50,6 +50,7 @@ Constructor for LayerOptions with optional ``transformContext``.

explicit QgsPointCloudLayer( const QString &path = QString(),
const QString &baseName = QString(),
const QString &dataSourceType = QString(),
const QString &providerLib = QStringLiteral( "pointcloud" ),
const QgsPointCloudLayer::LayerOptions &options = QgsPointCloudLayer::LayerOptions() );
%Docstring
@@ -313,6 +313,7 @@ Creates a new instance of the raster data provider.
.. versionadded:: 3.10
%End


virtual bool createMeshData(
const QgsMesh &mesh,
const QString uri,
@@ -127,6 +127,7 @@ Creates new instance of raster data provider
.. versionadded:: 3.10
%End


QList<QPair<QString, QString> > pyramidResamplingMethods( const QString &providerKey );
%Docstring
Returns list of raster pyramid resampling methods
@@ -821,7 +821,7 @@ Adds a vector tile layer to the current project.
.. versionadded:: 3.14
%End

virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &dataSourceType, const QString &baseName, const QString &providerKey ) = 0;
%Docstring
Adds a point cloud layer to the current project.

@@ -118,7 +118,7 @@ Emitted when a vector tile layer has been selected for addition.
.. versionadded:: 3.14
%End

void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
void addPointCloudLayer( const QString &url, const QString &baseName, const QString &dataSourceType, const QString &providerKey );
%Docstring
Emitted when a point cloud layer has been selected for addition.

@@ -2008,7 +2008,9 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
}
else if ( u.layerType == QLatin1String( "pointcloud" ) )
{
addPointCloudLayer( uri, u.name, u.providerKey );
QString dataSourceType = QStringLiteral( "remote" );
if ( QFileInfo::exists( uri ) ) dataSourceType = QStringLiteral( "file" );
addPointCloudLayer( uri, u.name, dataSourceType, u.providerKey );
}
else if ( u.layerType == QLatin1String( "vector-tile" ) )
{
@@ -5607,9 +5609,9 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayer( const QString &url, const QStri
return addVectorTileLayerPrivate( url, baseName );
}

QgsPointCloudLayer *QgisApp::addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey )
QgsPointCloudLayer *QgisApp::addPointCloudLayer( const QString &url, const QString &baseName, const QString &dataSourceType, const QString &providerKey )
{
return addPointCloudLayerPrivate( url, baseName, providerKey );
return addPointCloudLayerPrivate( url, baseName, dataSourceType, providerKey );
}

QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, const QString &baseName, const bool guiWarning )
@@ -5654,7 +5656,12 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, cons
return layer.release();
}

QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate( const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarning )
QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate(
const QString &uri,
const QString &baseName,
const QString &dataSourceType,
const QString &providerKey,
bool guiWarning )
{
QgsCanvasRefreshBlocker refreshBlocker;
QgsSettings settings;
@@ -5669,7 +5676,7 @@ QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate( const QString &uri, cons
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );

// create the layer
std::unique_ptr<QgsPointCloudLayer> layer( new QgsPointCloudLayer( uri, base, providerKey ) );
std::unique_ptr<QgsPointCloudLayer> layer( new QgsPointCloudLayer( uri, base, dataSourceType, providerKey ) );

if ( !layer || !layer->isValid() )
{
@@ -7454,8 +7461,13 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
break;

case QgsMapLayerType::PointCloudLayer:
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), candidateProviders.at( 0 ).metadata()->key(), false ) );
break;
{
QString dataSourceType = "remote";
if ( QFileInfo::exists( fileName ) )
dataSourceType = "file";
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), dataSourceType, candidateProviders.at( 0 ).metadata()->key(), false ) );
}
break;
}
}

@@ -1161,7 +1161,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* in the Map Legend so it should be formed in a meaningful way.
* \since QGIS 3.18
*/
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &dataSourceType, const QString &providerKey );

/**
* \brief overloaded version of the private addLayer method that takes a list of
@@ -2114,6 +2114,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

//! Open a point cloud layer - this is the generic function which takes all parameters
QgsPointCloudLayer *addPointCloudLayerPrivate( const QString &uri,
const QString &dataSourceType,
const QString &baseName,
const QString &providerKey,
bool guiWarning = true );
@@ -168,9 +168,9 @@ QgsVectorTileLayer *QgisAppInterface::addVectorTileLayer( const QString &url, co
return qgis->addVectorTileLayer( url, baseName );
}

QgsPointCloudLayer *QgisAppInterface::addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey )
QgsPointCloudLayer *QgisAppInterface::addPointCloudLayer( const QString &url, const QString &dataSourceType, const QString &baseName, const QString &providerKey )
{
return qgis->addPointCloudLayer( url, baseName, providerKey );
return qgis->addPointCloudLayer( url, baseName, dataSourceType, providerKey );
}

bool QgisAppInterface::addProject( const QString &projectName )
@@ -71,7 +71,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
QgsRasterLayer *addRasterLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
QgsVectorTileLayer *addVectorTileLayer( const QString &url, const QString &baseName ) override;
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &dataSourceType, const QString &baseName, const QString &providerKey ) override;
bool addProject( const QString &projectName ) override;
bool newProject( bool promptToSaveFlag = false ) override;
void reloadConnections( ) override;
@@ -4,12 +4,22 @@
#include <QObject>

#include "qgspointcloudattribute.h"
#include "qgstiledownloadmanager.h"

#define SIP_NO_FILE

class QgsTileDownloadManagerReply;
class QgsPointCloudAttributeCollection;
class QgsPointCloudBlock;

class QgsPointCloudBlockHandle : public QObject
/**
* \ingroup core
* \brief Base class for handling loading QgsPointCloudBlock asynchronously
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.20
*/
class CORE_EXPORT QgsPointCloudBlockHandle : public QObject
{
Q_OBJECT
public:
@@ -32,13 +32,16 @@
#include "qgsmaplayerlegend.h"
#include "qgsmaplayerfactory.h"
#include <QUrl>
#include "qgseptprovider.h"

This comment has been minimized.

Copy link
@3nids

3nids Apr 14, 2021

Member

@NEDJIMAbelgacem this breaks the build if you don't enable WITH_EPT


QgsPointCloudLayer::QgsPointCloudLayer( const QString &path,
const QString &baseName,
const QString &dataSourceType,
const QString &providerLib,
const QgsPointCloudLayer::LayerOptions &options )
: QgsMapLayer( QgsMapLayerType::PointCloudLayer, baseName, path )
, mElevationProperties( new QgsPointCloudLayerElevationProperties( this ) )
, mDataSourceType( dataSourceType )
{

if ( !path.isEmpty() && !providerLib.isEmpty() )
@@ -62,7 +65,7 @@ QgsPointCloudLayer *QgsPointCloudLayer::clone() const
options.transformContext = transformContext();
options.skipCrsValidation = true;

QgsPointCloudLayer *layer = new QgsPointCloudLayer( source(), name(), mProviderKey, options );
QgsPointCloudLayer *layer = new QgsPointCloudLayer( source(), name(), mDataSourceType, mProviderKey, options );
QgsMapLayer::clone( layer );

if ( mRenderer )
@@ -299,7 +302,7 @@ void QgsPointCloudLayer::setDataSource( const QString &dataSource, const QString
flags |= QgsDataProvider::FlagTrustDataSource;
}

mDataProvider.reset( qobject_cast<QgsPointCloudDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options, flags ) ) );
mDataProvider.reset( qobject_cast<QgsPointCloudDataProvider *>( QgsProviderRegistry::instance()->createEptDataProvider( provider, dataSource, mDataSourceType, options, flags ) ) );
if ( !mDataProvider )
{
QgsDebugMsg( QStringLiteral( "Unable to get point cloud data provider" ) );
@@ -90,6 +90,7 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
*/
explicit QgsPointCloudLayer( const QString &path = QString(),
const QString &baseName = QString(),
const QString &dataSourceType = QString(),
const QString &providerLib = QStringLiteral( "pointcloud" ),
const QgsPointCloudLayer::LayerOptions &options = QgsPointCloudLayer::LayerOptions() );

@@ -185,6 +186,8 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
std::unique_ptr<QgsPointCloudRenderer> mRenderer;

QgsPointCloudLayerElevationProperties *mElevationProperties = nullptr;

QString mDataSourceType;
};


@@ -17,6 +17,8 @@

#include <QElapsedTimer>
#include <QPointer>
#include <QTimer>
#include <QDebug>

#include "qgspointcloudlayerrenderer.h"
#include "qgspointcloudlayer.h"
@@ -16,6 +16,8 @@
***************************************************************************/

#include "qgis.h"
#include "qgslogger.h"
#include "qgsproviderregistry.h"
#include "qgseptprovider.h"
#include "qgseptpointcloudindex.h"
#include "qgsremoteeptpointcloudindex.h"
@@ -33,13 +35,14 @@
QgsEptProvider::QgsEptProvider(
const QString &uri,
const QgsDataProvider::ProviderOptions &options,
const QString &dataSourceType,
QgsDataProvider::ReadFlags flags )
: QgsPointCloudDataProvider( uri, options, flags )
{
if ( QFileInfo::exists( uri ) )
mIndex.reset( new QgsEptPointCloudIndex );
else
if ( dataSourceType == QStringLiteral( "remote" ) )
mIndex.reset( new QgsRemoteEptPointCloudIndex );
else
mIndex.reset( new QgsEptPointCloudIndex );

std::unique_ptr< QgsScopedRuntimeProfile > profile;
if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
@@ -48,6 +51,17 @@ QgsEptProvider::QgsEptProvider(
loadIndex( );
}

QgsEptProvider *QgsEptProvider::create( const QString &providerKey, const QString &uri, const QString &dataSourceType, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
{
QgsEptProvider *ret = QgsProviderRegistry::instance()->createEptDataProvider( providerKey, uri, dataSourceType, options, flags );
if ( !ret )
{
QgsDebugMsg( "Cannot resolve 'createEptDataProviderFunction' function in " + providerKey + " provider" );
}

return ret;
}

QgsEptProvider::~QgsEptProvider() = default;

QgsCoordinateReferenceSystem QgsEptProvider::crs() const
@@ -130,7 +144,12 @@ QgsEptProviderMetadata::QgsEptProviderMetadata():

QgsEptProvider *QgsEptProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
{
return new QgsEptProvider( uri, options, flags );
return new QgsEptProvider( uri, options, "", flags );
}

QgsEptProvider *QgsEptProviderMetadata::createEptDataProvider( const QString &uri, const QString &dataSourceType, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
{
return new QgsEptProvider( uri, options, dataSourceType, flags );
}

QList<QgsDataItemProvider *> QgsEptProviderMetadata::dataItemProviders() const
@@ -38,9 +38,13 @@ class QgsEptProvider: public QgsPointCloudDataProvider
public:
QgsEptProvider( const QString &uri,
const QgsDataProvider::ProviderOptions &providerOptions,
const QString &dataSourceType,
QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );

~QgsEptProvider();

static QgsEptProvider *create( const QString &providerKey, const QString &uri, const QString &dataSourceType, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags );

QgsCoordinateReferenceSystem crs() const override;

QgsRectangle extent() const override;
@@ -68,6 +72,7 @@ class QgsEptProviderMetadata : public QgsProviderMetadata
QgsEptProviderMetadata();
QgsProviderMetadata::ProviderMetadataCapabilities capabilities() const override;
QgsEptProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
QgsEptProvider *createEptDataProvider( const QString &uri, const QString &dataSourceType, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
QList< QgsDataItemProvider * > dataItemProviders() const override;
int priorityForUri( const QString &uri ) const override;
QList< QgsMapLayerType > validLayerTypesForUri( const QString &uri ) const override;
@@ -181,6 +181,15 @@ QgsRasterDataProvider *QgsProviderMetadata::createRasterDataProvider(
return nullptr;
}

QgsEptProvider *QgsProviderMetadata::createEptDataProvider(
const QString &,
const QString &,
const QgsDataProvider::ProviderOptions &,
QgsDataProvider::ReadFlags )
{
return nullptr;
}

bool QgsProviderMetadata::createMeshData(
const QgsMesh &,
const QString,
@@ -43,6 +43,7 @@ class QgsTransaction;
class QgsRasterDataProvider;
class QgsMeshDataProvider;
class QgsAbstractDatabaseProviderConnection;
class QgsEptProvider;

struct QgsMesh;

@@ -385,6 +386,8 @@ class CORE_EXPORT QgsProviderMetadata : public QObject
const QgsCoordinateReferenceSystem &crs,
const QStringList &createOptions = QStringList() ) SIP_FACTORY;

SIP_SKIP virtual QgsEptProvider *createEptDataProvider( const QString &uri, const QString &dataSourceType, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) SIP_FACTORY;

/**
* Creates mesh data source, that is the mesh frame stored in file, memory or with other way (depending of the provider)
* \since QGIS 3.16
@@ -570,6 +570,15 @@ QgsRasterDataProvider *QgsProviderRegistry::createRasterDataProvider( const QStr
return nullptr;
}

QgsEptProvider *QgsProviderRegistry::createEptDataProvider( const QString &providerKey, const QString &uri, const QString &dataSourceType, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
{
QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );
if ( meta )
return meta->createEptDataProvider( uri, dataSourceType, options, flags );

return nullptr;
}

QList<QPair<QString, QString> > QgsProviderRegistry::pyramidResamplingMethods( const QString &providerKey )
{
QgsProviderMetadata *meta = findMetadata_( mProviders, providerKey );

0 comments on commit ede1c63

Please sign in to comment.