Skip to content
Permalink
Browse files
remove the use of dataSourceType
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 8, 2021
1 parent f08d3d0 commit c9890935bf896273f22ca0509024272652c79d40
@@ -50,7 +50,6 @@ 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
@@ -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 &dataSourceType, const QString &baseName, const QString &providerKey ) = 0;
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, 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 &dataSourceType, const QString &providerKey );
void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
%Docstring
Emitted when a point cloud layer has been selected for addition.

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

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

QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, const QString &baseName, const bool guiWarning )
@@ -5659,7 +5657,6 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, cons
QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate(
const QString &uri,
const QString &baseName,
const QString &dataSourceType,
const QString &providerKey,
bool guiWarning )
{
@@ -5676,7 +5673,7 @@ QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate(
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );

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

if ( !layer || !layer->isValid() )
{
@@ -7462,10 +7459,7 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )

case QgsMapLayerType::PointCloudLayer:
{
QString dataSourceType = "remote";
if ( QFileInfo::exists( fileName ) )
dataSourceType = "file";
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), dataSourceType, candidateProviders.at( 0 ).metadata()->key(), false ) );
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), 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 &dataSourceType, const QString &providerKey );
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );

/**
* \brief overloaded version of the private addLayer method that takes a list of
@@ -2115,7 +2115,6 @@ 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 &baseName,
const QString &dataSourceType,
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 &dataSourceType, const QString &baseName, const QString &providerKey )
QgsPointCloudLayer *QgisAppInterface::addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey )
{
return qgis->addPointCloudLayer( url, baseName, dataSourceType, providerKey );
return qgis->addPointCloudLayer( url, baseName, 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 &dataSourceType, const QString &baseName, const QString &providerKey ) override;
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
bool addProject( const QString &projectName ) override;
bool newProject( bool promptToSaveFlag = false ) override;
void reloadConnections( ) override;
@@ -36,14 +36,15 @@

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.startsWith( QStringLiteral( "http" ) ) )
mDataSourceType = "remote";
else
mDataSourceType = "file";
if ( !path.isEmpty() && !providerLib.isEmpty() )
{
QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
@@ -65,7 +66,7 @@ QgsPointCloudLayer *QgsPointCloudLayer::clone() const
options.transformContext = transformContext();
options.skipCrsValidation = true;

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

if ( mRenderer )
@@ -90,7 +90,6 @@ 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() );

@@ -51,17 +51,6 @@ 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
@@ -43,8 +43,6 @@ class QgsEptProvider: public QgsPointCloudDataProvider

~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;
@@ -82,7 +82,7 @@ void QgsPointCloudSourceSelect::addButtonClicked()
if ( preferredProviders.empty() )
continue;
qDebug() << "preferredProviders.at( 0 ).metadata()->key(): " << preferredProviders.at( 0 ).metadata()->key();
emit addPointCloudLayer( path, QFileInfo( path ).baseName(), mDataSourceType, preferredProviders.at( 0 ).metadata()->key() ) ;
emit addPointCloudLayer( path, QFileInfo( path ).baseName(), preferredProviders.at( 0 ).metadata()->key() ) ;
}
}
else if ( mDataSourceType == QStringLiteral( "remote" ) )
@@ -99,7 +99,7 @@ void QgsPointCloudSourceSelect::addButtonClicked()
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...
if ( !preferredProviders.empty() )
emit addPointCloudLayer( mPath, QFileInfo( mPath ).baseName(), mDataSourceType, preferredProviders.at( 0 ).metadata()->key() ) ;
emit addPointCloudLayer( mPath, QFileInfo( mPath ).baseName(), preferredProviders.at( 0 ).metadata()->key() ) ;
}
}

@@ -726,7 +726,7 @@ class GUI_EXPORT QgisInterface : public QObject
* Adds a point cloud layer to the current project.
* \since QGIS 3.18
*/
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &dataSourceType, const QString &baseName, const QString &providerKey ) = 0;
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;

//! Adds (opens) a project
virtual bool addProject( const QString &project ) = 0;
@@ -131,7 +131,7 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
* Emitted when a point cloud layer has been selected for addition.
* \since QGIS 3.18
*/
void addPointCloudLayer( const QString &url, const QString &baseName, const QString &dataSourceType, const QString &providerKey );
void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );

/**
* Emitted when one or more OGR supported layers are selected for addition
@@ -223,10 +223,7 @@ void QgsBrowserLayerProperties::setItem( QgsDataItem *item )
QgsDebugMsgLevel( QStringLiteral( "creating point cloud layer" ), 2 );
QgsPointCloudLayer::LayerOptions options { QgsProject::instance()->transformContext() };
options.skipCrsValidation = true;
QString dataSourceType = QStringLiteral( "remote" );
if ( QFileInfo::exists( layerItem->uri() ) )
dataSourceType = QStringLiteral( "file" );
mLayer = std::make_unique< QgsPointCloudLayer >( layerItem->uri(), layerItem->name(), dataSourceType, layerItem->providerKey(), options );
mLayer = std::make_unique< QgsPointCloudLayer >( layerItem->uri(), layerItem->name(), layerItem->providerKey(), options );
break;
}

@@ -137,7 +137,7 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
* Emitted when a point cloud layer was selected for addition: for signal forwarding to QgisApp
* \since QGIS 3.18
*/
void addPointCloudLayer( const QString &pointCloudLayerPath, const QString &baseName, const QString &dataSourceType, const QString &providerKey );
void addPointCloudLayer( const QString &pointCloudLayerPath, const QString &baseName, const QString &providerKey );

//! Replace the selected layer by a vector layer defined by uri, layer name, data source uri
void replaceSelectedVectorLayer( const QString &oldId, const QString &uri, const QString &layerName, const QString &provider );
@@ -162,7 +162,6 @@ void TestQgsPdalProvider::brokenPath()
std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >(
QStringLiteral( "not valid" ),
QStringLiteral( "layer" ),
QStringLiteral( "file" ),
QStringLiteral( "pdal" ) );
QVERIFY( !layer->isValid() );
}
@@ -175,7 +174,6 @@ void TestQgsPdalProvider::validLayer()
std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >(
mTestDataDir + QStringLiteral( "point_clouds/las/cloud.las" ),
QStringLiteral( "layer" ),
QStringLiteral( "file" ),
QStringLiteral( "pdal" ),
options
);

0 comments on commit c989093

Please sign in to comment.