Skip to content

Commit

Permalink
Add method to QgsPointCloudDataProvider to retrieve a polygon represe…
Browse files Browse the repository at this point in the history
…nting

the best available indication of the actual point cloud bounds
  • Loading branch information
nyalldawson authored and PeterPetrik committed Dec 3, 2020
1 parent 26fb54e commit 2d32594
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Expand Up @@ -63,6 +63,19 @@ Returns the attributes available from this data provider.
virtual int pointCount() const = 0;
%Docstring
Returns the total number of points available in the dataset.
%End

virtual QgsGeometry polygonBounds() const;
%Docstring
Returns the polygon bounds of the layer. The CRS of the returned geometry will match the provider's :py:func:`~QgsPointCloudDataProvider.crs`.

This method will return the best approximation for the actual bounds of points contained in the
dataset available from the provider's metadata. This may match the bounding box rectangle returned
by :py:func:`~QgsPointCloudDataProvider.extent`, or for some datasets a "convex hull" style polygon representing a more precise bounds
will be returned.

This method will not attempt to calculate the data bounds, rather it will return only whatever precomputed bounds
are included in the data source's metadata.
%End

virtual QgsPointCloudRenderer *createRenderer( const QVariantMap &configuration = QVariantMap() ) const /Factory/;
Expand Down
6 changes: 6 additions & 0 deletions src/core/pointcloud/qgspointclouddataprovider.cpp
Expand Up @@ -18,6 +18,7 @@
#include "qgis.h"
#include "qgspointclouddataprovider.h"
#include "qgspointcloudindex.h"
#include "qgsgeometry.h"
#include <mutex>

QgsPointCloudDataProvider::QgsPointCloudDataProvider(
Expand All @@ -35,6 +36,11 @@ QgsPointCloudDataProvider::Capabilities QgsPointCloudDataProvider::capabilities(
return QgsPointCloudDataProvider::NoCapabilities;
}

QgsGeometry QgsPointCloudDataProvider::polygonBounds() const
{
return QgsGeometry::fromRect( extent() );
}

QgsPointCloudRenderer *QgsPointCloudDataProvider::createRenderer( const QVariantMap & ) const
{
return nullptr;
Expand Down
14 changes: 14 additions & 0 deletions src/core/pointcloud/qgspointclouddataprovider.h
Expand Up @@ -26,6 +26,7 @@

class QgsPointCloudIndex;
class QgsPointCloudRenderer;
class QgsGeometry;

/**
* \ingroup core
Expand Down Expand Up @@ -86,6 +87,19 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
*/
virtual int pointCount() const = 0;

/**
* Returns the polygon bounds of the layer. The CRS of the returned geometry will match the provider's crs().
*
* This method will return the best approximation for the actual bounds of points contained in the
* dataset available from the provider's metadata. This may match the bounding box rectangle returned
* by extent(), or for some datasets a "convex hull" style polygon representing a more precise bounds
* will be returned.
*
* This method will not attempt to calculate the data bounds, rather it will return only whatever precomputed bounds
* are included in the data source's metadata.
*/
virtual QgsGeometry polygonBounds() const;

/**
* Creates a new 2D point cloud renderer, using provider backend specific information.
*
Expand Down

0 comments on commit 2d32594

Please sign in to comment.