mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
add some basic skelet for point cloud data providers
This commit is contained in:
parent
9039aadf6f
commit
b796dbb07b
@ -0,0 +1,63 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/pointcloud/qgspointclouddataprovider.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class QgsPointCloudDataProvider: QgsDataProvider
|
||||||
|
{
|
||||||
|
%Docstring
|
||||||
|
Base class for providing data for QgsPointCloudLayer
|
||||||
|
|
||||||
|
Responsible for reading native point cloud data and returning the indexed data?
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
The API is considered EXPERIMENTAL and can be changed without a notice
|
||||||
|
|
||||||
|
.. versionadded:: 3.18
|
||||||
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgspointclouddataprovider.h"
|
||||||
|
%End
|
||||||
|
public:
|
||||||
|
QgsPointCloudDataProvider( const QString &uri,
|
||||||
|
const QgsDataProvider::ProviderOptions &providerOptions,
|
||||||
|
QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
|
||||||
|
%Docstring
|
||||||
|
Ctor
|
||||||
|
%End
|
||||||
|
|
||||||
|
~QgsPointCloudDataProvider();
|
||||||
|
virtual QgsCoordinateReferenceSystem crs() const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual QgsRectangle extent() const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isValid() const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual QString name() const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual QString description() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/pointcloud/qgspointclouddataprovider.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
@ -47,6 +47,9 @@ QgsPointCloudLayer cannot be copied.
|
|||||||
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
|
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
|
||||||
|
|
||||||
|
|
||||||
|
virtual QgsPointCloudDataProvider *dataProvider();
|
||||||
|
|
||||||
|
|
||||||
virtual bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context );
|
virtual bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context );
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +67,6 @@ QgsPointCloudLayer cannot be copied.
|
|||||||
virtual QString loadDefaultStyle( bool &resultFlag /Out/ );
|
virtual QString loadDefaultStyle( bool &resultFlag /Out/ );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private: // Private methods
|
private: // Private methods
|
||||||
QgsPointCloudLayer( const QgsPointCloudLayer &rhs );
|
QgsPointCloudLayer( const QgsPointCloudLayer &rhs );
|
||||||
};
|
};
|
||||||
|
@ -35,12 +35,8 @@ Represents a 2D renderer of point cloud data
|
|||||||
explicit QgsPointCloudRenderer( QgsPointCloudLayer *layer, QgsRenderContext &context );
|
explicit QgsPointCloudRenderer( QgsPointCloudLayer *layer, QgsRenderContext &context );
|
||||||
~QgsPointCloudRenderer();
|
~QgsPointCloudRenderer();
|
||||||
|
|
||||||
|
|
||||||
virtual bool render();
|
virtual bool render();
|
||||||
|
|
||||||
%Docstring
|
|
||||||
QgsPointCloudRenderer cannot be copied.
|
|
||||||
%End
|
|
||||||
|
|
||||||
void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
|
void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
|
||||||
void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
|
void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
|
||||||
|
@ -33,6 +33,10 @@ Abstract base class for spatial data provider implementations.
|
|||||||
{
|
{
|
||||||
sipType = sipType_QgsMeshDataProvider;
|
sipType = sipType_QgsMeshDataProvider;
|
||||||
}
|
}
|
||||||
|
else if ( qobject_cast<QgsPointCloudDataProvider *>( sipCpp ) )
|
||||||
|
{
|
||||||
|
sipType = sipType_QgsPointCloudDataProvider;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sipType = 0;
|
sipType = 0;
|
||||||
|
@ -439,6 +439,7 @@
|
|||||||
%Include auto_generated/mesh/qgsmeshcalculator.sip
|
%Include auto_generated/mesh/qgsmeshcalculator.sip
|
||||||
%Include auto_generated/pointcloud/qgspointcloudlayer.sip
|
%Include auto_generated/pointcloud/qgspointcloudlayer.sip
|
||||||
%Include auto_generated/pointcloud/qgspointcloudrenderer.sip
|
%Include auto_generated/pointcloud/qgspointcloudrenderer.sip
|
||||||
|
%Include auto_generated/pointcloud/qgspointclouddataprovider.sip
|
||||||
%Include auto_generated/metadata/qgsabstractmetadatabase.sip
|
%Include auto_generated/metadata/qgsabstractmetadatabase.sip
|
||||||
%Include auto_generated/metadata/qgslayermetadata.sip
|
%Include auto_generated/metadata/qgslayermetadata.sip
|
||||||
%Include auto_generated/metadata/qgslayermetadataformatter.sip
|
%Include auto_generated/metadata/qgslayermetadataformatter.sip
|
||||||
|
@ -807,7 +807,7 @@ Adds a vector tile layer to the current project.
|
|||||||
.. versionadded:: 3.14
|
.. versionadded:: 3.14
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName ) = 0;
|
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
|
||||||
%Docstring
|
%Docstring
|
||||||
Adds a point cloud layer to the current project.
|
Adds a point cloud layer to the current project.
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ Emitted when a vector tile layer has been selected for addition.
|
|||||||
.. versionadded:: 3.14
|
.. versionadded:: 3.14
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void addPointCloudLayer( const QString &url, const QString &baseName );
|
void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
|
||||||
%Docstring
|
%Docstring
|
||||||
Emitted when a point cloud layer has been selected for addition.
|
Emitted when a point cloud layer has been selected for addition.
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointClou
|
|||||||
QgsPointCloud3DSymbolHandler *handler = new QgsPointCloud3DSymbolHandler;
|
QgsPointCloud3DSymbolHandler *handler = new QgsPointCloud3DSymbolHandler;
|
||||||
mHandler.reset( handler );
|
mHandler.reset( handler );
|
||||||
|
|
||||||
QgsPointCloudIndex *pc = layer->pointCloudIndex();
|
QgsPointCloudIndex *pc = layer->dataProvider()->index();
|
||||||
|
|
||||||
//QgsExpressionContext exprContext( Qgs3DUtils::globalProjectLayerExpressionContext( layer ) );
|
//QgsExpressionContext exprContext( Qgs3DUtils::globalProjectLayerExpressionContext( layer ) );
|
||||||
//exprContext.setFields( layer->fields() );
|
//exprContext.setFields( layer->fields() );
|
||||||
|
@ -178,6 +178,12 @@ QVariantMap QgsPackageAlgorithm::processAlgorithm( const QVariantMap ¶meters
|
|||||||
errored = true;
|
errored = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
|
//not supported
|
||||||
|
feedback->pushDebugInfo( QObject::tr( "Packaging point cloud layers is not supported." ) );
|
||||||
|
errored = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case QgsMapLayerType::VectorTileLayer:
|
case QgsMapLayerType::VectorTileLayer:
|
||||||
//not supported
|
//not supported
|
||||||
feedback->pushDebugInfo( QObject::tr( "Packaging vector tile layers is not supported." ) );
|
feedback->pushDebugInfo( QObject::tr( "Packaging vector tile layers is not supported." ) );
|
||||||
|
@ -2096,7 +2096,7 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
|
|||||||
}
|
}
|
||||||
else if ( u.layerType == QLatin1String( "pointcloud" ) )
|
else if ( u.layerType == QLatin1String( "pointcloud" ) )
|
||||||
{
|
{
|
||||||
addPointCloudLayer( uri, u.name );
|
addPointCloudLayer( uri, u.name, u.providerKey );
|
||||||
}
|
}
|
||||||
else if ( u.layerType == QLatin1String( "vector-tile" ) )
|
else if ( u.layerType == QLatin1String( "vector-tile" ) )
|
||||||
{
|
{
|
||||||
@ -5709,9 +5709,9 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayer( const QString &url, const QStri
|
|||||||
return addVectorTileLayerPrivate( url, baseName );
|
return addVectorTileLayerPrivate( url, baseName );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPointCloudLayer *QgisApp::addPointCloudLayer( const QString &url, const QString &baseName )
|
QgsPointCloudLayer *QgisApp::addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey )
|
||||||
{
|
{
|
||||||
return addPointCloudLayerPrivate( url, baseName );
|
return addPointCloudLayerPrivate( url, baseName, providerKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, const QString &baseName, const bool guiWarning )
|
QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, const QString &baseName, const bool guiWarning )
|
||||||
@ -5756,7 +5756,7 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, cons
|
|||||||
return layer.release();
|
return layer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate( const QString &uri, const QString &baseName, bool guiWarning )
|
QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate( const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarning )
|
||||||
{
|
{
|
||||||
QgsCanvasRefreshBlocker refreshBlocker;
|
QgsCanvasRefreshBlocker refreshBlocker;
|
||||||
QgsSettings settings;
|
QgsSettings settings;
|
||||||
@ -5771,7 +5771,7 @@ QgsPointCloudLayer *QgisApp::addPointCloudLayerPrivate( const QString &uri, cons
|
|||||||
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );
|
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );
|
||||||
|
|
||||||
// create the layer
|
// create the layer
|
||||||
std::unique_ptr<QgsPointCloudLayer> layer( new QgsPointCloudLayer( uri, base ) );
|
std::unique_ptr<QgsPointCloudLayer> layer( new QgsPointCloudLayer( uri, base, providerKey ) );
|
||||||
|
|
||||||
if ( !layer || !layer->isValid() )
|
if ( !layer || !layer->isValid() )
|
||||||
{
|
{
|
||||||
@ -7623,7 +7623,7 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
|
|||||||
// Try to load as point cloud layer after raster & vector & mesh
|
// Try to load as point cloud layer after raster & vector & mesh
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
{
|
{
|
||||||
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), false ) );
|
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), QStringLiteral( "pointcloud" ), false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
|
@ -1165,7 +1165,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
|||||||
* in the Map Legend so it should be formed in a meaningful way.
|
* in the Map Legend so it should be formed in a meaningful way.
|
||||||
* \since QGIS 3.18
|
* \since QGIS 3.18
|
||||||
*/
|
*/
|
||||||
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName );
|
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief overloaded version of the private addLayer method that takes a list of
|
* \brief overloaded version of the private addLayer method that takes a list of
|
||||||
@ -2095,7 +2095,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
|||||||
QgsVectorTileLayer *addVectorTileLayerPrivate( const QString &uri, const QString &baseName, bool guiWarning = true );
|
QgsVectorTileLayer *addVectorTileLayerPrivate( const QString &uri, const QString &baseName, bool guiWarning = true );
|
||||||
|
|
||||||
//! Open a point cloyd layer - this is the generic function which takes all parameters
|
//! Open a point cloyd layer - this is the generic function which takes all parameters
|
||||||
QgsPointCloudLayer *addPointCloudLayerPrivate( const QString &uri, const QString &baseName, bool guiWarning = true );
|
QgsPointCloudLayer *addPointCloudLayerPrivate( const QString &uri,
|
||||||
|
const QString &baseName,
|
||||||
|
const QString &providerKey,
|
||||||
|
bool guiWarning = true );
|
||||||
|
|
||||||
bool addVectorLayersPrivate( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType, bool guiWarning = true );
|
bool addVectorLayersPrivate( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType, bool guiWarning = true );
|
||||||
QgsVectorLayer *addVectorLayerPrivate( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey, bool guiWarning = true );
|
QgsVectorLayer *addVectorLayerPrivate( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey, bool guiWarning = true );
|
||||||
|
@ -167,9 +167,9 @@ QgsVectorTileLayer *QgisAppInterface::addVectorTileLayer( const QString &url, co
|
|||||||
return qgis->addVectorTileLayer( url, baseName );
|
return qgis->addVectorTileLayer( url, baseName );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPointCloudLayer *QgisAppInterface::addPointCloudLayer( const QString &url, const QString &baseName )
|
QgsPointCloudLayer *QgisAppInterface::addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey )
|
||||||
{
|
{
|
||||||
return qgis->addPointCloudLayer( url, baseName );
|
return qgis->addPointCloudLayer( url, baseName, providerKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgisAppInterface::addProject( const QString &projectName )
|
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;
|
QgsRasterLayer *addRasterLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
|
||||||
QgsMeshLayer *addMeshLayer( 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;
|
QgsVectorTileLayer *addVectorTileLayer( const QString &url, const QString &baseName ) override;
|
||||||
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName ) override;
|
QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
|
||||||
bool addProject( const QString &projectName ) override;
|
bool addProject( const QString &projectName ) override;
|
||||||
bool newProject( bool promptToSaveFlag = false ) override;
|
bool newProject( bool promptToSaveFlag = false ) override;
|
||||||
void reloadConnections( ) override;
|
void reloadConnections( ) override;
|
||||||
|
@ -627,6 +627,7 @@ SET(QGIS_CORE_SRCS
|
|||||||
pointcloud/qgspointclouddataitems.cpp
|
pointcloud/qgspointclouddataitems.cpp
|
||||||
pointcloud/qgspointcloudprovidermetadata.cpp
|
pointcloud/qgspointcloudprovidermetadata.cpp
|
||||||
pointcloud/qgspointclouddecoder.cpp
|
pointcloud/qgspointclouddecoder.cpp
|
||||||
|
pointcloud/qgspointclouddataprovider.cpp
|
||||||
|
|
||||||
labeling/qgslabelfeature.cpp
|
labeling/qgslabelfeature.cpp
|
||||||
labeling/qgslabelingengine.cpp
|
labeling/qgslabelingengine.cpp
|
||||||
@ -1303,6 +1304,7 @@ SET(QGIS_CORE_HDRS
|
|||||||
pointcloud/qgspointclouddataitems.h
|
pointcloud/qgspointclouddataitems.h
|
||||||
pointcloud/qgspointcloudprovidermetadata.h
|
pointcloud/qgspointcloudprovidermetadata.h
|
||||||
pointcloud/qgspointclouddecoder.h
|
pointcloud/qgspointclouddecoder.h
|
||||||
|
pointcloud/qgspointclouddataprovider.h
|
||||||
|
|
||||||
metadata/qgsabstractmetadatabase.h
|
metadata/qgsabstractmetadatabase.h
|
||||||
metadata/qgslayermetadata.h
|
metadata/qgslayermetadata.h
|
||||||
|
@ -5150,6 +5150,8 @@ static QVariant fcnGetLayerProperty( const QVariantList &values, const QgsExpres
|
|||||||
return QCoreApplication::translate( "expressions", "Plugin" );
|
return QCoreApplication::translate( "expressions", "Plugin" );
|
||||||
case QgsMapLayerType::AnnotationLayer:
|
case QgsMapLayerType::AnnotationLayer:
|
||||||
return QCoreApplication::translate( "expressions", "Annotation" );
|
return QCoreApplication::translate( "expressions", "Annotation" );
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
|
return QCoreApplication::translate( "expressions", "Point Cloud" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3580,6 +3580,7 @@ bool QgsPalLabeling::staticWillUseLayer( const QgsMapLayer *layer )
|
|||||||
case QgsMapLayerType::RasterLayer:
|
case QgsMapLayerType::RasterLayer:
|
||||||
case QgsMapLayerType::PluginLayer:
|
case QgsMapLayerType::PluginLayer:
|
||||||
case QgsMapLayerType::MeshLayer:
|
case QgsMapLayerType::MeshLayer:
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
case QgsMapLayerType::AnnotationLayer:
|
case QgsMapLayerType::AnnotationLayer:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
62
src/core/pointcloud/qgspointclouddataprovider.cpp
Normal file
62
src/core/pointcloud/qgspointclouddataprovider.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qgspointclouddataprovider.cpp
|
||||||
|
-----------------------
|
||||||
|
begin : October 2020
|
||||||
|
copyright : (C) 2020 by Peter Petrik
|
||||||
|
email : zilolv at gmail dot com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "qgis.h"
|
||||||
|
#include "qgspointclouddataprovider.h"
|
||||||
|
#include "qgspointcloudindex.h"
|
||||||
|
|
||||||
|
QgsPointCloudDataProvider::QgsPointCloudDataProvider(
|
||||||
|
const QString &uri,
|
||||||
|
const QgsDataProvider::ProviderOptions &options,
|
||||||
|
QgsDataProvider::ReadFlags flags )
|
||||||
|
: QgsDataProvider( uri, options, flags )
|
||||||
|
, mIndex( new QgsPointCloudIndex )
|
||||||
|
{
|
||||||
|
mIsValid = mIndex->load( uri );
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsPointCloudDataProvider::~QgsPointCloudDataProvider() = default;
|
||||||
|
|
||||||
|
QgsCoordinateReferenceSystem QgsPointCloudDataProvider::crs() const
|
||||||
|
{
|
||||||
|
return QgsCoordinateReferenceSystem::fromWkt( mIndex->wkt() );
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsRectangle QgsPointCloudDataProvider::extent() const
|
||||||
|
{
|
||||||
|
return mIndex->extent();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QgsPointCloudDataProvider::isValid() const
|
||||||
|
{
|
||||||
|
return mIsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QgsPointCloudDataProvider::name() const
|
||||||
|
{
|
||||||
|
return QStringLiteral( "pointclouds" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QgsPointCloudDataProvider::description() const
|
||||||
|
{
|
||||||
|
return QStringLiteral( "Point Clouds" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsPointCloudIndex *QgsPointCloudDataProvider::index()
|
||||||
|
{
|
||||||
|
return mIndex.get();
|
||||||
|
}
|
64
src/core/pointcloud/qgspointclouddataprovider.h
Normal file
64
src/core/pointcloud/qgspointclouddataprovider.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qgspointclouddataprovider.h
|
||||||
|
---------------------
|
||||||
|
begin : October 2020
|
||||||
|
copyright : (C) 2020 by Peter Petrik
|
||||||
|
email : zilolv at gmail dot com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QGSPOINTCLOUDDATAPROVIDER_H
|
||||||
|
#define QGSPOINTCLOUDDATAPROVIDER_H
|
||||||
|
|
||||||
|
#include "qgis_core.h"
|
||||||
|
#include "qgsdataprovider.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class QgsPointCloudIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup core
|
||||||
|
* Base class for providing data for QgsPointCloudLayer
|
||||||
|
*
|
||||||
|
* Responsible for reading native point cloud data and returning the indexed data?
|
||||||
|
*
|
||||||
|
* \note The API is considered EXPERIMENTAL and can be changed without a notice
|
||||||
|
*
|
||||||
|
* \since QGIS 3.18
|
||||||
|
*/
|
||||||
|
class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
//! Ctor
|
||||||
|
QgsPointCloudDataProvider( const QString &uri,
|
||||||
|
const QgsDataProvider::ProviderOptions &providerOptions,
|
||||||
|
QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
|
||||||
|
|
||||||
|
~QgsPointCloudDataProvider();
|
||||||
|
QgsCoordinateReferenceSystem crs() const override;
|
||||||
|
|
||||||
|
QgsRectangle extent() const override;
|
||||||
|
|
||||||
|
bool isValid() const override;
|
||||||
|
|
||||||
|
QString name() const override;
|
||||||
|
|
||||||
|
QString description() const override;
|
||||||
|
|
||||||
|
QgsPointCloudIndex *index() SIP_SKIP;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<QgsPointCloudIndex> mIndex;
|
||||||
|
bool mIsValid = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QGSMESHDATAPROVIDER_H
|
@ -19,10 +19,16 @@
|
|||||||
#include "qgspointcloudrenderer.h"
|
#include "qgspointcloudrenderer.h"
|
||||||
#include "qgspointcloudindex.h"
|
#include "qgspointcloudindex.h"
|
||||||
#include "qgsrectangle.h"
|
#include "qgsrectangle.h"
|
||||||
|
#include "qgspointclouddataprovider.h"
|
||||||
|
|
||||||
QgsPointCloudLayer::QgsPointCloudLayer( const QString &path, const QString &baseName )
|
QgsPointCloudLayer::QgsPointCloudLayer( const QString &path,
|
||||||
|
const QString &baseName,
|
||||||
|
const QString &providerLib,
|
||||||
|
const QgsPointCloudLayer::LayerOptions &options )
|
||||||
: QgsMapLayer( QgsMapLayerType::PointCloudLayer, baseName, path )
|
: QgsMapLayer( QgsMapLayerType::PointCloudLayer, baseName, path )
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(providerLib)
|
||||||
|
Q_UNUSED(options)
|
||||||
setValid( loadDataSource() );
|
setValid( loadDataSource() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,10 +43,10 @@ QgsPointCloudLayer *QgsPointCloudLayer::clone() const
|
|||||||
|
|
||||||
QgsRectangle QgsPointCloudLayer::extent() const
|
QgsRectangle QgsPointCloudLayer::extent() const
|
||||||
{
|
{
|
||||||
if ( !mPointCloudIndex )
|
if ( !mDataProvider )
|
||||||
return QgsRectangle();
|
return QgsRectangle();
|
||||||
|
|
||||||
return mPointCloudIndex->extent();
|
return mDataProvider->index()->extent();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsMapLayerRenderer *QgsPointCloudLayer::createMapRenderer( QgsRenderContext &rendererContext )
|
QgsMapLayerRenderer *QgsPointCloudLayer::createMapRenderer( QgsRenderContext &rendererContext )
|
||||||
@ -48,6 +54,16 @@ QgsMapLayerRenderer *QgsPointCloudLayer::createMapRenderer( QgsRenderContext &re
|
|||||||
return new QgsPointCloudRenderer( this, rendererContext );
|
return new QgsPointCloudRenderer( this, rendererContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsPointCloudDataProvider *QgsPointCloudLayer::dataProvider()
|
||||||
|
{
|
||||||
|
return mDataProvider.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QgsPointCloudDataProvider *QgsPointCloudLayer::dataProvider() const
|
||||||
|
{
|
||||||
|
return mDataProvider.get();
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsPointCloudLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext &context )
|
bool QgsPointCloudLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext &context )
|
||||||
{
|
{
|
||||||
setValid( loadDataSource() );
|
setValid( loadDataSource() );
|
||||||
@ -96,18 +112,14 @@ QString QgsPointCloudLayer::loadDefaultStyle( bool &resultFlag )
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPointCloudIndex *QgsPointCloudLayer::pointCloudIndex() const
|
|
||||||
{
|
|
||||||
return mPointCloudIndex.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QgsPointCloudLayer::loadDataSource()
|
bool QgsPointCloudLayer::loadDataSource()
|
||||||
{
|
{
|
||||||
mPointCloudIndex.reset( new QgsPointCloudIndex() );
|
|
||||||
bool success = mPointCloudIndex->load( source() );
|
|
||||||
|
|
||||||
if ( success )
|
mDataProvider.reset( new QgsPointCloudDataProvider( source(), QgsDataProvider::ProviderOptions() ) );
|
||||||
setCrs( QgsCoordinateReferenceSystem::fromWkt( mPointCloudIndex->wkt() ) );
|
|
||||||
|
|
||||||
return success;
|
if ( mDataProvider->isValid() )
|
||||||
|
setCrs( mDataProvider->crs() );
|
||||||
|
|
||||||
|
return mDataProvider->isValid();
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#ifndef QGSPOINTCLOUDLAYER_H
|
#ifndef QGSPOINTCLOUDLAYER_H
|
||||||
#define QGSPOINTCLOUDLAYER_H
|
#define QGSPOINTCLOUDLAYER_H
|
||||||
|
|
||||||
class QgsPointCloudIndex;
|
|
||||||
class QgsPointCloudRenderer;
|
class QgsPointCloudRenderer;
|
||||||
|
|
||||||
|
#include "qgspointclouddataprovider.h"
|
||||||
#include "qgsmaplayer.h"
|
#include "qgsmaplayer.h"
|
||||||
#include "qgis_core.h"
|
#include "qgis_core.h"
|
||||||
|
|
||||||
@ -41,10 +41,44 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting options for loading point cloud layers.
|
||||||
|
*/
|
||||||
|
struct LayerOptions
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for LayerOptions with optional \a transformContext.
|
||||||
|
* \note transformContext argument was added in QGIS 3.8
|
||||||
|
*/
|
||||||
|
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext( ) )
|
||||||
|
: transformContext( transformContext )
|
||||||
|
{}
|
||||||
|
|
||||||
|
QgsCoordinateTransformContext transformContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls whether the layer is allowed to have an invalid/unknown CRS.
|
||||||
|
*
|
||||||
|
* If TRUE, then no validation will be performed on the layer's CRS and the layer
|
||||||
|
* layer's crs() may be invalid() (i.e. the layer will have no georeferencing available
|
||||||
|
* and will be treated as having purely numerical coordinates).
|
||||||
|
*
|
||||||
|
* If FALSE (the default), the layer's CRS will be validated using QgsCoordinateReferenceSystem::validate(),
|
||||||
|
* which may cause a blocking, user-facing dialog asking users to manually select the correct CRS for the
|
||||||
|
* layer.
|
||||||
|
*/
|
||||||
|
bool skipCrsValidation = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor - creates a point cloud layer
|
* Constructor - creates a point cloud layer
|
||||||
*/
|
*/
|
||||||
explicit QgsPointCloudLayer( const QString &path = QString(), const QString &baseName = QString() );
|
explicit QgsPointCloudLayer( const QString &path = QString(),
|
||||||
|
const QString &baseName = QString(),
|
||||||
|
const QString &providerLib = QStringLiteral( "pointcloud" ),
|
||||||
|
const QgsPointCloudLayer::LayerOptions &options = QgsPointCloudLayer::LayerOptions());
|
||||||
|
|
||||||
~QgsPointCloudLayer() override;
|
~QgsPointCloudLayer() override;
|
||||||
|
|
||||||
@ -57,6 +91,9 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
|
|||||||
QgsRectangle extent() const override;
|
QgsRectangle extent() const override;
|
||||||
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
|
QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
|
||||||
|
|
||||||
|
QgsPointCloudDataProvider *dataProvider() override;
|
||||||
|
const QgsPointCloudDataProvider *dataProvider() const override SIP_SKIP;
|
||||||
|
|
||||||
bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
|
bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
|
||||||
|
|
||||||
bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||||
@ -70,8 +107,6 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
|
|||||||
void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
|
void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
|
||||||
QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
|
QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
|
||||||
|
|
||||||
QgsPointCloudIndex *pointCloudIndex() const SIP_SKIP;
|
|
||||||
|
|
||||||
private: // Private methods
|
private: // Private methods
|
||||||
bool loadDataSource();
|
bool loadDataSource();
|
||||||
|
|
||||||
@ -84,7 +119,7 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
|
|||||||
QgsPointCloudLayer( const QgsPointCloudLayer &rhs );
|
QgsPointCloudLayer( const QgsPointCloudLayer &rhs );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<QgsPointCloudIndex> mPointCloudIndex;
|
std::unique_ptr<QgsPointCloudDataProvider> mDataProvider;
|
||||||
|
|
||||||
//! Renderer assigned to the layer to draw map
|
//! Renderer assigned to the layer to draw map
|
||||||
std::unique_ptr<QgsPointCloudRenderer> mRenderer;
|
std::unique_ptr<QgsPointCloudRenderer> mRenderer;
|
||||||
|
@ -100,7 +100,7 @@ static QList<IndexedPointCloudNode> _traverseTree( QgsPointCloudIndex *pc, const
|
|||||||
bool QgsPointCloudRenderer::render()
|
bool QgsPointCloudRenderer::render()
|
||||||
{
|
{
|
||||||
// TODO cache!?
|
// TODO cache!?
|
||||||
QgsPointCloudIndex *pc = mLayer->pointCloudIndex();
|
QgsPointCloudIndex *pc = mLayer->dataProvider()->index();
|
||||||
|
|
||||||
QgsRenderContext &context = *renderContext();
|
QgsRenderContext &context = *renderContext();
|
||||||
|
|
||||||
@ -154,8 +154,8 @@ void QgsPointCloudRenderer::readXml( const QDomElement &elem, const QgsReadWrite
|
|||||||
void QgsPointCloudRenderer::drawData( QPainter *painter, const QVector<qint32> &data, const QgsPointCloudRendererConfig &config )
|
void QgsPointCloudRenderer::drawData( QPainter *painter, const QVector<qint32> &data, const QgsPointCloudRendererConfig &config )
|
||||||
{
|
{
|
||||||
const QgsMapToPixel mapToPixel = renderContext()->mapToPixel();
|
const QgsMapToPixel mapToPixel = renderContext()->mapToPixel();
|
||||||
const QgsVector3D scale = mLayer->pointCloudIndex()->scale();
|
const QgsVector3D scale = mLayer->dataProvider()->index()->scale();
|
||||||
const QgsVector3D offset = mLayer->pointCloudIndex()->offset();
|
const QgsVector3D offset = mLayer->dataProvider()->index()->offset();
|
||||||
|
|
||||||
QgsRectangle mapExtent = renderContext()->mapExtent();
|
QgsRectangle mapExtent = renderContext()->mapExtent();
|
||||||
|
|
||||||
|
@ -176,6 +176,8 @@ QgsMapLayer *QgsProcessingUtils::mapLayerFromStore( const QString &string, QgsMa
|
|||||||
return !canUseLayer( qobject_cast< QgsVectorTileLayer * >( layer ) );
|
return !canUseLayer( qobject_cast< QgsVectorTileLayer * >( layer ) );
|
||||||
case QgsMapLayerType::AnnotationLayer:
|
case QgsMapLayerType::AnnotationLayer:
|
||||||
return true;
|
return true;
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} ), layers.end() );
|
} ), layers.end() );
|
||||||
|
@ -55,6 +55,10 @@ class CORE_EXPORT QgsDataProvider : public QObject
|
|||||||
{
|
{
|
||||||
sipType = sipType_QgsMeshDataProvider;
|
sipType = sipType_QgsMeshDataProvider;
|
||||||
}
|
}
|
||||||
|
else if ( qobject_cast<QgsPointCloudDataProvider *>( sipCpp ) )
|
||||||
|
{
|
||||||
|
sipType = sipType_QgsPointCloudDataProvider;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sipType = 0;
|
sipType = 0;
|
||||||
|
@ -149,6 +149,7 @@ QPainterPath QgsMapClippingUtils::calculatePainterClipRegion( const QList<QgsMap
|
|||||||
case QgsMapLayerType::MeshLayer:
|
case QgsMapLayerType::MeshLayer:
|
||||||
case QgsMapLayerType::RasterLayer:
|
case QgsMapLayerType::RasterLayer:
|
||||||
case QgsMapLayerType::PluginLayer:
|
case QgsMapLayerType::PluginLayer:
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
case QgsMapLayerType::AnnotationLayer:
|
case QgsMapLayerType::AnnotationLayer:
|
||||||
// for these layer types, we ignore the region's featureClip behavior.
|
// for these layer types, we ignore the region's featureClip behavior.
|
||||||
break;
|
break;
|
||||||
|
@ -123,6 +123,7 @@ bool QgsMapRendererJob::prepareLabelCache() const
|
|||||||
case QgsMapLayerType::AnnotationLayer:
|
case QgsMapLayerType::AnnotationLayer:
|
||||||
case QgsMapLayerType::PluginLayer:
|
case QgsMapLayerType::PluginLayer:
|
||||||
case QgsMapLayerType::MeshLayer:
|
case QgsMapLayerType::MeshLayer:
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,6 +961,7 @@ bool QgsMapRendererJob::needTemporaryImage( QgsMapLayer *ml )
|
|||||||
}
|
}
|
||||||
|
|
||||||
case QgsMapLayerType::MeshLayer:
|
case QgsMapLayerType::MeshLayer:
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
case QgsMapLayerType::VectorTileLayer:
|
case QgsMapLayerType::VectorTileLayer:
|
||||||
case QgsMapLayerType::PluginLayer:
|
case QgsMapLayerType::PluginLayer:
|
||||||
break;
|
break;
|
||||||
|
@ -90,7 +90,11 @@ QgsMimeDataUtils::Uri::Uri( QgsMapLayer *layer )
|
|||||||
layerType = QStringLiteral( "mesh" );
|
layerType = QStringLiteral( "mesh" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QgsMapLayerType::PointCloudLayer:
|
||||||
|
{
|
||||||
|
layerType = QStringLiteral( "pointcloud" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QgsMapLayerType::VectorTileLayer:
|
case QgsMapLayerType::VectorTileLayer:
|
||||||
{
|
{
|
||||||
layerType = QStringLiteral( "vector-tile" );
|
layerType = QStringLiteral( "vector-tile" );
|
||||||
|
@ -48,6 +48,6 @@ void QgsPointCloudSourceSelect::addButtonClicked()
|
|||||||
|
|
||||||
for ( const QString &path : QgsFileWidget::splitFilePaths( mPath ) )
|
for ( const QString &path : QgsFileWidget::splitFilePaths( mPath ) )
|
||||||
{
|
{
|
||||||
emit addPointCloudLayer( path, QFileInfo( path ).baseName() ) ;
|
emit addPointCloudLayer( path, QFileInfo( path ).baseName(), QStringLiteral( "pointcloud" ) ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -712,7 +712,7 @@ class GUI_EXPORT QgisInterface : public QObject
|
|||||||
* Adds a point cloud layer to the current project.
|
* Adds a point cloud layer to the current project.
|
||||||
* \since QGIS 3.18
|
* \since QGIS 3.18
|
||||||
*/
|
*/
|
||||||
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName ) = 0;
|
virtual QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
|
||||||
|
|
||||||
//! Adds (opens) a project
|
//! Adds (opens) a project
|
||||||
virtual bool addProject( const QString &project ) = 0;
|
virtual bool addProject( const QString &project ) = 0;
|
||||||
|
@ -116,7 +116,7 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
|
|||||||
* Emitted when a point cloud layer has been selected for addition.
|
* Emitted when a point cloud layer has been selected for addition.
|
||||||
* \since QGIS 3.18
|
* \since QGIS 3.18
|
||||||
*/
|
*/
|
||||||
void addPointCloudLayer( const QString &url, const QString &baseName );
|
void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when one or more OGR supported layers are selected for addition
|
* Emitted when one or more OGR supported layers are selected for addition
|
||||||
|
@ -126,7 +126,7 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
|
|||||||
* Emitted when a point cloud layer was selected for addition: for signal forwarding to QgisApp
|
* Emitted when a point cloud layer was selected for addition: for signal forwarding to QgisApp
|
||||||
* \since QGIS 3.18
|
* \since QGIS 3.18
|
||||||
*/
|
*/
|
||||||
void addPointCloudLayer( const QString &pointCloudLayerPath, const QString &baseName );
|
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
|
//! 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 );
|
void replaceSelectedVectorLayer( const QString &oldId, const QString &uri, const QString &layerName, const QString &provider );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user