QGIS API Documentation  3.19.0-Master (c022ae99b5)
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;
34 
45 class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
46 {
47  Q_OBJECT
48  public:
49 
54  {
55  NoCapabilities = 0,
56  ReadLayerMetadata = 1 << 0,
57  WriteLayerMetadata = 1 << 1,
58  CreateRenderer = 1 << 2,
59  };
60 
61  Q_DECLARE_FLAGS( Capabilities, Capability )
62 
63 
67  {
68  NotIndexed = 0,
69  Indexing = 1 << 0,
70  Indexed = 1 << 1
71  };
72 
74  QgsPointCloudDataProvider( const QString &uri,
75  const QgsDataProvider::ProviderOptions &providerOptions,
76  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
77 
79 
80 #ifndef SIP_RUN
81 
93  QVector<QVariantMap> identify( double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
94 #else
95 
107  SIP_PYLIST identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
108  % MethodCode
109  {
110  QVector<QMap<QString, QVariant>> res = sipCpp->identify( a0, *a1, *a2, a3 );
111  sipRes = PyList_New( res.size() );
112  for ( int i = 0; i < res.size(); ++i )
113  {
114  PyObject *dict = PyDict_New();
115  for ( QString key : res[i].keys() )
116  {
117  PyObject *keyObj = sipConvertFromNewType( new QString( key ), sipType_QString, Py_None );
118  PyObject *valObj = sipConvertFromNewType( new QVariant( res[i][key] ), sipType_QVariant, Py_None );
119  PyDict_SetItem( dict, keyObj, valObj );
120  }
121  PyList_SET_ITEM( sipRes, i, dict );
122  }
123  }
124  % End
125 #endif
126 
130  virtual QgsPointCloudDataProvider::Capabilities capabilities() const;
131 
137 
143  virtual void loadIndex( ) = 0;
144 
152  virtual void generateIndex( ) = 0;
153 
154 
159 
167  virtual QgsPointCloudIndex *index() const SIP_SKIP {return nullptr;}
168 
172  bool hasValidIndex() const;
173 
177  virtual qint64 pointCount() const = 0;
178 
190  virtual QgsGeometry polygonBounds() const;
191 
198  virtual QVariantMap originalMetadata() const;
199 
213  virtual QgsPointCloudRenderer *createRenderer( const QVariantMap &configuration = QVariantMap() ) const SIP_FACTORY;
214 #ifndef SIP_RUN
215 
226  virtual QVariant metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
227 #else
228 
239  SIP_PYOBJECT metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
240  % MethodCode
241  {
242  const QVariant res = sipCpp->metadataStatistic( *a0, a1 );
243  if ( !res.isValid() )
244  {
245  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
246  sipIsErr = 1;
247  }
248  else
249  {
250  QVariant *v = new QVariant( res );
251  sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
252  }
253  }
254  % End
255 #endif
256 
265  virtual QVariantList metadataClasses( const QString &attribute ) const;
266 
267 
268 #ifndef SIP_RUN
269 
280  virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
281 #else
282 
292  SIP_PYOBJECT metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
293  % MethodCode
294  {
295  const QVariant res = sipCpp->metadataClassStatistic( *a0, *a1, a2 );
296  if ( !res.isValid() )
297  {
298  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
299  sipIsErr = 1;
300  }
301  else
302  {
303  QVariant *v = new QVariant( res );
304  sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
305  }
306  }
307  % End
308 #endif
309 
316  static QMap< int, QString > lasClassificationCodes();
317 
324  static QMap< int, QString > translatedLasClassificationCodes();
325 
331  static QMap< int, QString > dataFormatIds();
332 
338  static QMap< int, QString > translatedDataFormatIds();
339 
340  signals:
341 
346 
347  private:
348  QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, double maxError, double nodeError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange );
349 };
350 
351 #endif // QGSMESHDATAPROVIDER_H
Represents a indexed point cloud node in octree.
Abstract base class for spatial data provider implementations.
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
Collection of point cloud attributes.
Base class for providing data for QgsPointCloudLayer.
Capability
Capabilities that providers may implement.
~QgsPointCloudDataProvider() override
virtual QgsPointCloudAttributeCollection attributes() const =0
Returns the attributes available from this data provider.
virtual void generateIndex()=0
Triggers generation of the point cloud index.
virtual QgsPointCloudIndex * index() const
Returns the point cloud index associated with the provider.
virtual void loadIndex()=0
Triggers loading of the point cloud index.
virtual qint64 pointCount() const =0
Returns the total number of points available in the dataset.
PointCloudIndexGenerationState
Point cloud index state.
virtual PointCloudIndexGenerationState indexingState()=0
Gets the current index generation state.
void indexGenerationStateChanged(PointCloudIndexGenerationState state)
Emitted when point cloud generation state is changed.
Represents a indexed point clouds data in octree.
Abstract base class for 2d point cloud renderers.
Statistic
Enumeration of flags that specify statistics to be calculated.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76
Setting options for creating vector data providers.