QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 long long featureCount( QgsFeedback *feedback = nullptr ) const;
54
55 bool hasCachedAllFeatures() const;
56 bool getFeature( QgsFeatureId id, QgsFeature &f, QgsFeedback *feedback = nullptr );
57 QgsFeatureIds getFeatureIdsInExtent( const QgsRectangle &extent, QgsFeedback *feedback, const QString &thisPage, QString &nextPage,
58 const QgsFeatureIds &alreadyFetchedIds );
59
60 void clearCache();
61
62 private:
63
64 bool processFeatureRequest( QString &nextPage, QgsFeedback *feedback,
65 const std::function< void( const QgsFeature & ) > &fetchedFeatureCallback,
66 const std::function< bool() > &continueFetchingCallback,
67 const std::function< void() > &onNoMoreFeaturesCallback );
68
69 friend class QgsSensorThingsProvider;
70 mutable QReadWriteLock mReadWriteLock{ QReadWriteLock::Recursive };
71
72 QString mAuthCfg;
73 QgsHttpHeaders mHeaders;
74 QString mRootUri;
75
76 mutable QString mError;
77
78 QString mEntityBaseUri;
79
81
83 QString mGeometryField;
84 QgsFields mFields;
86
87 mutable long long mFeatureCount = static_cast< long long >( Qgis::FeatureCountState::Uncounted );
88
89 QHash<QString, QgsFeatureId> mIotIdToFeatureId;
90 QMap<QgsFeatureId, QgsFeature> mCachedFeatures;
91 QgsGeometry mCachedExtent;
92
93 QgsFeatureId mNextFeatureId = 0;
94 bool mHasCachedAllFeatures = false;
95
96 int mMaximumPageSize = QgsSensorThingsUtils::DEFAULT_PAGE_SIZE;
97
98 QgsSpatialIndex mSpatialIndex;
99 mutable QString mNextPage;
100};
101
103
104#endif // QGSSENSORTHINGSSHAREDDATA_H
SensorThingsEntity
OGC SensorThings API entity types.
Definition qgis.h:4803
@ 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.
This class implements simple http header management.
A rectangle specified with double values.
static constexpr int DEFAULT_PAGE_SIZE
Default page size.
A spatial index for QgsFeature objects.
@ Uncounted
Feature count not yet computed.
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
const QgsCoordinateReferenceSystem & crs