QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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"
25#include "qgspointcloudindex.h"
27#include "qgspoint.h"
28#include "qgsray3d.h"
29#include <memory>
30
34class QgsGeometry;
36
48{
49 Q_OBJECT
50 public:
51
56 {
57 NoCapabilities = 0,
58 ReadLayerMetadata = 1 << 0,
59 WriteLayerMetadata = 1 << 1,
60 CreateRenderer = 1 << 2,
61 ContainSubIndexes = 1 << 3,
62 };
63
64 Q_DECLARE_FLAGS( Capabilities, Capability )
65
66
70 {
71 NotIndexed = 0,
72 Indexing = 1 << 0,
73 Indexed = 1 << 1
74 };
75
77 QgsPointCloudDataProvider( const QString &uri,
78 const QgsDataProvider::ProviderOptions &providerOptions,
79 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
80
82
83#ifndef SIP_RUN
84
94 QVector<QVariantMap> identify( double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
95#else
96
106 SIP_PYLIST identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
107 % MethodCode
108 {
109 QVector<QMap<QString, QVariant>> res = sipCpp->identify( a0, *a1, *a2, a3 );
110 sipRes = PyList_New( res.size() );
111 for ( int i = 0; i < res.size(); ++i )
112 {
113 PyObject *dict = PyDict_New();
114 for ( QString key : res[i].keys() )
115 {
116 PyObject *keyObj = sipConvertFromNewType( new QString( key ), sipType_QString, Py_None );
117 PyObject *valObj = sipConvertFromNewType( new QVariant( res[i][key] ), sipType_QVariant, Py_None );
118 PyDict_SetItem( dict, keyObj, valObj );
119 }
120 PyList_SET_ITEM( sipRes, i, dict );
121 }
122 }
123 % End
124#endif
125
129 virtual QgsPointCloudDataProvider::Capabilities capabilities() const;
130
136
142 virtual void loadIndex( ) = 0;
143
151 virtual void generateIndex( ) = 0;
152
153
158
166 virtual QgsPointCloudIndex *index() const SIP_SKIP {return nullptr;}
167
176 virtual QVector<QgsPointCloudSubIndex> subIndexes() SIP_SKIP { return QVector<QgsPointCloudSubIndex>(); }
177
186 virtual void loadSubIndex( int n ) SIP_SKIP { Q_UNUSED( n ) return; }
187
191 bool hasValidIndex() const;
192
196 virtual qint64 pointCount() const = 0;
197
209 virtual QgsGeometry polygonBounds() const;
210
217 virtual QVariantMap originalMetadata() const;
218
232 virtual QgsPointCloudRenderer *createRenderer( const QVariantMap &configuration = QVariantMap() ) const SIP_FACTORY;
233
239 virtual bool hasStatisticsMetadata() const;
240
241#ifndef SIP_RUN
242
253 virtual QVariant metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
254#else
255
266 SIP_PYOBJECT metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
267 % MethodCode
268 {
269 const QVariant res = sipCpp->metadataStatistic( *a0, a1 );
270 if ( !res.isValid() )
271 {
272 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
273 sipIsErr = 1;
274 }
275 else
276 {
277 QVariant *v = new QVariant( res );
278 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
279 }
280 }
281 % End
282#endif
283
292 virtual QVariantList metadataClasses( const QString &attribute ) const;
293
294
295#ifndef SIP_RUN
296
307 virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
308
309#else
310
320 SIP_PYOBJECT metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
321 % MethodCode
322 {
323 const QVariant res = sipCpp->metadataClassStatistic( *a0, *a1, a2 );
324 if ( !res.isValid() )
325 {
326 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Statistic is not available" ).toUtf8().constData() );
327 sipIsErr = 1;
328 }
329 else
330 {
331 QVariant *v = new QVariant( res );
332 sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
333 }
334 }
335 % End
336#endif
337
338
343 QgsPointCloudStatistics metadataStatistics();
344
345 bool supportsSubsetString() const override { return true; }
346 QString subsetString() const override;
347 bool setSubsetString( const QString &subset, bool updateFeatureCount = false ) override;
348
355 static QMap< int, QString > lasClassificationCodes();
356
363 static QMap< int, QString > translatedLasClassificationCodes();
364
370 static QMap< int, QString > dataFormatIds();
371
377 static QMap< int, QString > translatedDataFormatIds();
378
379 signals:
380
385
386 protected:
389
390 private:
391 QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, double maxError, double nodeError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange );
392
393};
394
395#endif // QGSMESHDATAPROVIDER_H
Represents a indexed point cloud node in octree.
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:203
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.
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.