QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgssensorthingsshareddata.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssensorthingsshareddata.h
3 ----------------
4 begin : November 2023
5 copyright : (C) 2013 Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSSENSORTHINGSSHAREDDATA_H
17#define QGSSENSORTHINGSSHAREDDATA_H
18
19#include "qgsfields.h"
21#include "qgshttpheaders.h"
22#include "qgsfeature.h"
23#include "qgsspatialindex.h"
25
26#include <QReadWriteLock>
27
28class QgsFeedback;
29
30#define SIP_NO_FILE
32
36class QgsSensorThingsSharedData
37{
38
39 public:
40 QgsSensorThingsSharedData( const QString &uri );
41
45 static QUrl parseUrl( const QUrl &url, bool *isTestEndpoint = nullptr );
46
50 QString error() const { return mError; }
51
52 QgsCoordinateReferenceSystem crs() const { return mSourceCRS; }
53 QgsRectangle extent() const;
54 long long featureCount( QgsFeedback *feedback = nullptr ) const;
55 QString subsetString() const;
56
57 bool hasCachedAllFeatures() const;
58 bool getFeature( QgsFeatureId id, QgsFeature &f, QgsFeedback *feedback = nullptr );
59 QgsFeatureIds getFeatureIdsInExtent( const QgsRectangle &extent, QgsFeedback *feedback, const QString &thisPage, QString &nextPage,
60 const QgsFeatureIds &alreadyFetchedIds );
61
62 void clearCache();
63
64 private:
65
66 bool processFeatureRequest( QString &nextPage, QgsFeedback *feedback,
67 const std::function< void( const QgsFeature & ) > &fetchedFeatureCallback,
68 const std::function< bool() > &continueFetchingCallback,
69 const std::function< void() > &onNoMoreFeaturesCallback );
70
71 friend class QgsSensorThingsProvider;
72 mutable QReadWriteLock mReadWriteLock{ QReadWriteLock::Recursive };
73
74 QString mAuthCfg;
75 QgsHttpHeaders mHeaders;
76 QString mRootUri;
77
78 mutable QString mError;
79
80 QString mEntityBaseUri;
81 QString mSubsetString;
82
84
85 int mFeatureLimit = 0;
87 QString mGeometryField;
88 QgsFields mFields;
89
90 QgsRectangle mFilterExtent;
91
93 QgsRectangle mFetchedFeatureExtent;
94
96
97 mutable long long mFeatureCount = static_cast< long long >( Qgis::FeatureCountState::Uncounted );
98
99 QHash<QString, QgsFeatureId> mIotIdToFeatureId;
100 QMap<QgsFeatureId, QgsFeature> mCachedFeatures;
101 QgsGeometry mCachedExtent;
102
103 QgsFeatureId mNextFeatureId = 0;
104 bool mHasCachedAllFeatures = false;
105
106 int mMaximumPageSize = QgsSensorThingsUtils::DEFAULT_PAGE_SIZE;
107
108 QgsSpatialIndex mSpatialIndex;
109 mutable QString mNextPage;
110};
111
113
114#endif // QGSSENSORTHINGSSHAREDDATA_H
SensorThingsEntity
OGC SensorThings API entity types.
Definition: qgis.h:4865
@ Invalid
An invalid/unknown entity.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition: qgis.h:182
@ Unknown
Unknown.
This class represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
Container of fields for a vector layer.
Definition: qgsfields.h:45
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
This class implements simple http header management.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
static constexpr int DEFAULT_PAGE_SIZE
Default page size.
A spatial index for QgsFeature objects.
@ Uncounted
Feature count not yet computed.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
const QgsCoordinateReferenceSystem & crs