Skip to content

Commit

Permalink
Add virtual point cloud provider
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and wonder-sk committed Apr 13, 2023
1 parent b391b26 commit f896513
Show file tree
Hide file tree
Showing 7 changed files with 733 additions and 3 deletions.
Expand Up @@ -35,6 +35,7 @@ Responsible for reading native point cloud data and returning the indexed data.
ReadLayerMetadata,
WriteLayerMetadata,
CreateRenderer,
ContainSubIndexes,
};

typedef QFlags<QgsPointCloudDataProvider::Capability> Capabilities;
Expand Down Expand Up @@ -121,6 +122,8 @@ Gets the current index generation state
%End




bool hasValidIndex() const;
%Docstring
Returns whether provider has index which is valid
Expand Down Expand Up @@ -291,6 +294,8 @@ Returns the map of LAS data format ID to translated string value.
Emitted when point cloud generation state is changed
%End

protected:

};

/************************************************************************
Expand Down
8 changes: 7 additions & 1 deletion src/core/CMakeLists.txt
Expand Up @@ -1607,6 +1607,7 @@ set(QGIS_CORE_HDRS
pointcloud/qgspointcloudlayerprofilegenerator.h
pointcloud/qgspointcloudlayerrenderer.h
pointcloud/qgspointcloudindex.h
pointcloud/qgspointcloudsubindex.h
pointcloud/qgspointclouddataprovider.h
pointcloud/qgspointcloudrenderer.h
pointcloud/qgspointcloudrendererregistry.h
Expand Down Expand Up @@ -2072,15 +2073,19 @@ endif()

if (WITH_COPC)
include_directories(providers/copc)
include_directories(providers/vpc)


set(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
providers/copc/qgscopcprovider.cpp
providers/vpc/qgsvirtualpointcloudprovider.cpp
pointcloud/qgscopcpointcloudindex.cpp
pointcloud/qgsremotecopcpointcloudindex.cpp
pointcloud/qgscopcpointcloudblockrequest.cpp
)
set(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
providers/copc/qgscopcprovider.h
providers/vpc/qgsvirtualpointcloudprovider.h
pointcloud/qgscopcpointcloudindex.h
pointcloud/qgsremotecopcpointcloudindex.h
pointcloud/qgscopcpointcloudblockrequest.h
Expand Down Expand Up @@ -2268,7 +2273,8 @@ endif()

if (WITH_COPC)
target_include_directories(qgis_core PUBLIC
${CMAKE_SOURCE_DIR}/src/core/providers/copc)
${CMAKE_SOURCE_DIR}/src/core/providers/copc
${CMAKE_SOURCE_DIR}/src/core/providers/vpc)
endif()

GENERATE_EXPORT_HEADER(
Expand Down
28 changes: 26 additions & 2 deletions src/core/pointcloud/qgspointclouddataprovider.h
Expand Up @@ -23,6 +23,7 @@
#include "qgspointcloudattribute.h"
#include "qgsstatisticalsummary.h"
#include "qgspointcloudindex.h"
#include "qgspointcloudsubindex.h"
#include "qgspoint.h"
#include "qgsray3d.h"
#include <memory>
Expand Down Expand Up @@ -57,6 +58,7 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
ReadLayerMetadata = 1 << 0, //!< Provider can read layer metadata from data store.
WriteLayerMetadata = 1 << 1, //!< Provider can write layer metadata to the data store. See QgsDataProvider::writeLayerMetadata()
CreateRenderer = 1 << 2, //!< Provider can create 2D renderers using backend-specific formatting information. See QgsPointCloudDataProvider::createRenderer().
ContainSubIndexes = 1 << 3, //!< Provider can contain multiple indexes. Virtual point cloud files for example
};

Q_DECLARE_FLAGS( Capabilities, Capability )
Expand Down Expand Up @@ -163,6 +165,26 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
*/
virtual QgsPointCloudIndex *index() const SIP_SKIP {return nullptr;}

/**
* Returns a list of sub indexes available if the provider supports multiple indexes, empty list otherwise.
*
* The sub indexes contain a pointer to the individual indexes which may be nullptr if not yet loaded.
*
* \note Not available in Python bindings
* \since QGIS 3.32
*/
virtual QVector<QgsPointCloudSubIndex> subIndexes() SIP_SKIP { return QVector<QgsPointCloudSubIndex>(); }

/**
* Triggers loading of the point cloud index for the \a n th sub index
*
* If the provider does not support multiple indexes then loadIndex() is called
*
* \note Not available in Python bindings
* \since QGIS 3.32
*/
virtual void loadIndex( int n ) SIP_SKIP { Q_UNUSED( n ) return loadIndex(); }

/**
* Returns whether provider has index which is valid
*/
Expand Down Expand Up @@ -361,11 +383,13 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
*/
void indexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state );

protected:
//! String used to define a subset of the layer
QString mSubsetString;

private:
QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, double maxError, double nodeError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange );

//! String used to define a subset of the layer
QString mSubsetString;
};

#endif // QGSMESHDATAPROVIDER_H
41 changes: 41 additions & 0 deletions src/core/pointcloud/qgspointcloudsubindex.h
@@ -0,0 +1,41 @@
/***************************************************************************
qgspointcloudsubindex.h
-----------------------
begin : March 2023
copyright : (C) 2023 by Stefanos Natsis
email : uclaros 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 QGSPOINTCLOUDSUBINDEX_H
#define QGSPOINTCLOUDSUBINDEX_H

#include <memory>
#include <QString>
#include "qgsgeometry.h"

///@cond PRIVATE
#define SIP_NO_FILE

class QgsPointCloudIndex;

class QgsPointCloudSubIndex
{
public:
std::shared_ptr<QgsPointCloudIndex> index;
QString uri;
QgsRectangle extent;
QgsGeometry geometry;
qint64 count;
};

///@endcond
#endif // QGSPOINTCLOUDSUBINDEX_H
6 changes: 6 additions & 0 deletions src/core/providers/qgsproviderregistry.cpp
Expand Up @@ -44,6 +44,7 @@

#ifdef HAVE_COPC
#include "providers/copc/qgscopcprovider.h"
#include "providers/vpc/qgsvirtualpointcloudprovider.h"
#endif

#include "qgsruntimeprofiler.h"
Expand Down Expand Up @@ -217,6 +218,11 @@ void QgsProviderRegistry::init()
QgsProviderMetadata *pc = new QgsCopcProviderMetadata();
mProviders[ pc->key() ] = pc;
}
{
const QgsScopedRuntimeProfile profile( QObject::tr( "Create Virtual point cloud provider" ) );
QgsProviderMetadata *pc = new QgsVirtualPointCloudProviderMetadata();
mProviders[ pc->key() ] = pc;
}
#endif
registerUnusableUriHandler( new PdalUnusableUriHandlerInterface() );

Expand Down

0 comments on commit f896513

Please sign in to comment.