QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgspointclouddataprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointclouddataprovider.h
3  ---------------------
4  begin : October 2020
5  copyright : (C) 2020 by Peter Petrik
6  email : zilolv at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPOINTCLOUDDATAPROVIDER_H
19 #define QGSPOINTCLOUDDATAPROVIDER_H
20 
21 #include "qgis_core.h"
22 #include "qgsdataprovider.h"
23 #include "qgspointcloudattribute.h"
24 #include "qgsstatisticalsummary.h"
25 #include "qgspointcloudindex.h"
26 #include "qgspoint.h"
27 #include "qgsray3d.h"
28 #include <memory>
29 
31 class QgsPointCloudIndex;
33 class QgsGeometry;
35 
46 class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
47 {
48  Q_OBJECT
49  public:
50 
55  {
56  NoCapabilities = 0,
57  ReadLayerMetadata = 1 << 0,
58  WriteLayerMetadata = 1 << 1,
59  CreateRenderer = 1 << 2,
60  };
61 
62  Q_DECLARE_FLAGS( Capabilities, Capability )
63 
64 
68  {
69  NotIndexed = 0,
70  Indexing = 1 << 0,
71  Indexed = 1 << 1
72  };
73 
75  QgsPointCloudDataProvider( const QString &uri,
76  const QgsDataProvider::ProviderOptions &providerOptions,
77  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
78 
79  ~QgsPointCloudDataProvider() override;
80 
81 #ifndef SIP_RUN
82 
92  QVector<QVariantMap> identify( double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
93 #else
94 
104  SIP_PYLIST identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
105  % MethodCode
106  {
107  QVector<QMap<QString, QVariant>> res = sipCpp->identify( a0, *a1, *a2, a3 );
108  sipRes = PyList_New( res.size() );
109  for ( int i = 0; i < res.size(); ++i )
110  {
111  PyObject *dict = PyDict_New();
112  for ( QString key : res[i].keys() )
113  {
114  PyObject *keyObj = sipConvertFromNewType( new QString( key ), sipType_QString, Py_None );
115  PyObject *valObj = sipConvertFromNewType( new QVariant( res[i][key] ), sipType_QVariant, Py_None );
116  PyDict_SetItem( dict, keyObj, valObj );
117  }
118  PyList_SET_ITEM( sipRes, i, dict );
119  }
120  }
121  % End
122 #endif
123 
127  virtual QgsPointCloudDataProvider::Capabilities capabilities() const;
128 
133  virtual QgsPointCloudAttributeCollection attributes() const = 0;
134 
140  virtual void loadIndex( ) = 0;
141 
149  virtual void generateIndex( ) = 0;
150 
151 
155  virtual PointCloudIndexGenerationState indexingState( ) = 0;
156 
164  virtual QgsPointCloudIndex *index() const SIP_SKIP {return nullptr;}
165 
169  bool hasValidIndex() const;
170 
174  virtual qint64 pointCount() const = 0;
175 
187  virtual QgsGeometry polygonBounds() const;
188 
195  virtual QVariantMap originalMetadata() const;
196 
210  virtual QgsPointCloudRenderer *createRenderer( const QVariantMap &configuration = QVariantMap() ) const SIP_FACTORY;
211 
217  virtual bool hasStatisticsMetadata() const;
218 
219 #ifndef SIP_RUN
220 
231  virtual QVariant metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
232 #else
233 
244  SIP_PYOBJECT metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
245  % MethodCode
246  {
247  const QVariant res = sipCpp->metadataStatistic( *a0, a1 );
248  if ( !res.isValid() )
249  {
250  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
251  sipIsErr = 1;
252  }
253  else
254  {
255  QVariant *v = new QVariant( res );
256  sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
257  }
258  }
259  % End
260 #endif
261 
270  virtual QVariantList metadataClasses( const QString &attribute ) const;
271 
272 
273 #ifndef SIP_RUN
274 
285  virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
286 
287 #else
288 
298  SIP_PYOBJECT metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
299  % MethodCode
300  {
301  const QVariant res = sipCpp->metadataClassStatistic( *a0, *a1, a2 );
302  if ( !res.isValid() )
303  {
304  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
305  sipIsErr = 1;
306  }
307  else
308  {
309  QVariant *v = new QVariant( res );
310  sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
311  }
312  }
313  % End
314 #endif
315 
316 
321  QgsPointCloudStatistics metadataStatistics();
322 
323  bool supportsSubsetString() const override { return true; }
324  QString subsetString() const override;
325  bool setSubsetString( const QString &subset, bool updateFeatureCount = false ) override;
326 
333  static QMap< int, QString > lasClassificationCodes();
334 
341  static QMap< int, QString > translatedLasClassificationCodes();
342 
348  static QMap< int, QString > dataFormatIds();
349 
355  static QMap< int, QString > translatedDataFormatIds();
356 
357  signals:
358 
362  void indexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state );
363 
364  private:
365  QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, double maxError, double nodeError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange );
366 
368  QString mSubsetString;
369 };
370 
371 #endif // QGSMESHDATAPROVIDER_H
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:40
QgsDataProvider::setSubsetString
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
Definition: qgsdataprovider.h:262
QgsPointCloudDataProvider::supportsSubsetString
bool supportsSubsetString() const override
Returns true if the provider supports setting of subset strings.
Definition: qgspointclouddataprovider.h:323
qgspointcloudattribute.h
QgsPointCloudStatistics
Class used to store statistics of a point cloud dataset.
Definition: qgspointcloudstatistics.h:61
qgspoint.h
qgsstatisticalsummary.h
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
IndexedPointCloudNode
Represents a indexed point cloud node in octree.
Definition: qgspointcloudindex.h:57
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgsray3d.h
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsPointCloudDataProvider::Capability
Capability
Capabilities that providers may implement.
Definition: qgspointclouddataprovider.h:54
QgsPointCloudDataProvider
Base class for providing data for QgsPointCloudLayer.
Definition: qgspointclouddataprovider.h:46
qgspointcloudindex.h
QgsStatisticalSummary::Statistic
Statistic
Enumeration of flags that specify statistics to be calculated.
Definition: qgsstatisticalsummary.h:48
QgsDoubleRange
QgsRange which stores a range of double values.
Definition: qgsrange.h:202
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
qgsdataprovider.h
QgsPointCloudDataProvider::PointCloudIndexGenerationState
PointCloudIndexGenerationState
Point cloud index state.
Definition: qgspointclouddataprovider.h:67
QgsDataProvider::subsetString
virtual QString subsetString() const
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
Definition: qgsdataprovider.h:282
QgsPointCloudIndex
Represents a indexed point clouds data in octree.
Definition: qgspointcloudindex.h:163
QgsPointCloudDataProvider::index
virtual QgsPointCloudIndex * index() const
Returns the point cloud index associated with the provider.
Definition: qgspointclouddataprovider.h:164