QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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"
24#include "qgspointcloudindex.h"
26#include "qgspoint.h"
27#include "qgsray3d.h"
28#include <memory>
29
33class QgsGeometry;
35
47{
48 Q_OBJECT
49 public:
50
55 {
56 NoCapabilities = 0,
57 ReadLayerMetadata = 1 << 0,
58 WriteLayerMetadata = 1 << 1,
59 CreateRenderer = 1 << 2,
60 ContainSubIndexes = 1 << 3,
61 };
62
63 Q_DECLARE_FLAGS( Capabilities, Capability )
64
65
69 {
70 NotIndexed = 0,
71 Indexing = 1 << 0,
72 Indexed = 1 << 1
73 };
74
76 QgsPointCloudDataProvider( const QString &uri,
77 const QgsDataProvider::ProviderOptions &providerOptions,
78 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
79
81
82#ifndef SIP_RUN
83
93 QVector<QVariantMap> identify( double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
94#else
95
105 SIP_PYLIST identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
106 % MethodCode
107 {
108 QVector<QMap<QString, QVariant>> res = sipCpp->identify( a0, *a1, *a2, a3 );
109 sipRes = PyList_New( res.size() );
110 for ( int i = 0; i < res.size(); ++i )
111 {
112 PyObject *dict = PyDict_New();
113 for ( QString key : res[i].keys() )
114 {
115 PyObject *keyObj = sipConvertFromNewType( new QString( key ), sipType_QString, Py_None );
116 PyObject *valObj = sipConvertFromNewType( new QVariant( res[i][key] ), sipType_QVariant, Py_None );
117 PyDict_SetItem( dict, keyObj, valObj );
118 }
119 PyList_SET_ITEM( sipRes, i, dict );
120 }
121 }
122 % End
123#endif
124
128 virtual QgsPointCloudDataProvider::Capabilities capabilities() const;
129
135
141 virtual void loadIndex( ) = 0;
142
150 virtual void generateIndex( ) = 0;
151
152
157
165 virtual QgsPointCloudIndex *index() const SIP_SKIP {return nullptr;}
166
175 virtual QVector<QgsPointCloudSubIndex> subIndexes() SIP_SKIP { return QVector<QgsPointCloudSubIndex>(); }
176
185 virtual void loadSubIndex( int n ) SIP_SKIP { Q_UNUSED( n ) return; }
186
190 bool hasValidIndex() const;
191
195 virtual qint64 pointCount() const = 0;
196
208 virtual QgsGeometry polygonBounds() const;
209
216 virtual QVariantMap originalMetadata() const;
217
231 virtual QgsPointCloudRenderer *createRenderer( const QVariantMap &configuration = QVariantMap() ) const SIP_FACTORY;
232
238 virtual bool hasStatisticsMetadata() const;
239
240#ifndef SIP_RUN
241
252 virtual QVariant metadataStatistic( const QString &attribute, Qgis::Statistic statistic ) const;
253#else
254
265 SIP_PYOBJECT metadataStatistic( const QString &attribute, Qgis::Statistic statistic ) const;
266 % MethodCode
267 {
268 const QVariant res = sipCpp->metadataStatistic( *a0, a1 );
269 if ( !res.isValid() )
270 {
271 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
272 sipIsErr = 1;
273 }
274 else
275 {
276 QVariant *v = new QVariant( res );
277 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
278 }
279 }
280 % End
281#endif
282
291 virtual QVariantList metadataClasses( const QString &attribute ) const;
292
293
294#ifndef SIP_RUN
295
306 virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, Qgis::Statistic statistic ) const;
307
308#else
309
319 SIP_PYOBJECT metadataClassStatistic( const QString &attribute, const QVariant &value, Qgis::Statistic statistic ) const;
320 % MethodCode
321 {
322 const QVariant res = sipCpp->metadataClassStatistic( *a0, *a1, a2 );
323 if ( !res.isValid() )
324 {
325 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
326 sipIsErr = 1;
327 }
328 else
329 {
330 QVariant *v = new QVariant( res );
331 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
332 }
333 }
334 % End
335#endif
336
337
342 QgsPointCloudStatistics metadataStatistics();
343
344 bool supportsSubsetString() const override { return true; }
345 QString subsetString() const override;
346 bool setSubsetString( const QString &subset, bool updateFeatureCount = false ) override;
347
354 static QMap< int, QString > lasClassificationCodes();
355
362 static QMap< int, QString > translatedLasClassificationCodes();
363
369 static QMap< int, QString > dataFormatIds();
370
376 static QMap< int, QString > translatedDataFormatIds();
377
378 signals:
379
384
385 protected:
388
389 private:
390 QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, double maxError, double nodeError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange );
391
392};
393
394#endif // QGSMESHDATAPROVIDER_H
Represents a indexed point cloud node in octree.
Statistic
Available generic statistics.
Definition qgis.h:4685
Abstract base class for spatial data provider implementations.
virtual QString subsetString() const
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
QgsRange which stores a range of double values.
Definition qgsrange.h:201
A geometry is the spatial representation of a feature.
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.
bool supportsSubsetString() const override
Returns true if the provider supports setting of subset strings.
virtual QVector< QgsPointCloudSubIndex > subIndexes()
Returns a list of sub indexes available if the provider supports multiple indexes,...
virtual void generateIndex()=0
Triggers generation of the point cloud index.
virtual void loadSubIndex(int n)
Triggers loading of the point cloud index for the n th sub index.
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.
QString mSubsetString
String used to define a subset of the layer.
void indexGenerationStateChanged(QgsPointCloudDataProvider::PointCloudIndexGenerationState state)
Emitted when point cloud generation state is changed.
PointCloudIndexGenerationState
Point cloud index state.
virtual QgsPointCloudIndex * index() const
Returns the point cloud index associated with the provider.
virtual PointCloudIndexGenerationState indexingState()=0
Gets the current index generation state.
Represents a indexed point clouds data in octree.
Abstract base class for 2d point cloud renderers.
Class used to store statistics of a point cloud dataset.
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76
Setting options for creating vector data providers.