QGIS API Documentation 4.3.0-Master (389d690bb77)
Loading...
Searching...
No Matches
qgsstaccontroller.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsstaccontroller.h
3 ---------------------
4 begin : August 2024
5 copyright : (C) 2024 by Stefanos Natsis
6 email : uclaros 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 QGSSTACCONTROLLER_H
17#define QGSSTACCONTROLLER_H
18
19#include <nlohmann/json.hpp>
20
21#include "qgis.h"
22#include "qgis_core.h"
23#include "qgshttpheaders.h"
24#include "qgsnetworkreply.h"
25#include "qgsstacobject.h"
26
27#include <QObject>
28
29class QgsStacObject;
30class QgsStacCatalog;
33class QgsStacItem;
35class QNetworkReply;
36
45class CORE_EXPORT QgsStacController : public QObject
46{
47 Q_OBJECT
48 public:
50 explicit QgsStacController() = default;
51
53 ~QgsStacController() override;
54
59 std::unique_ptr< QgsStacCatalog > openLocalCatalog( const QString &fileName ) const;
60
65 std::unique_ptr< QgsStacCollection > openLocalCollection( const QString &fileName ) const;
66
71 std::unique_ptr< QgsStacItem > openLocalItem( const QString &fileName ) const;
72
78 template<class T> std::unique_ptr< T > fetchStacObject( const QUrl &url, QString *error = nullptr ) SIP_SKIP;
79
85 std::unique_ptr< QgsStacItemCollection > fetchItemCollection( const QUrl &url, QString *error = nullptr );
86
92 std::unique_ptr< QgsStacCollectionList > fetchCollections( const QUrl &url, QString *error = nullptr );
93
100 int fetchStacObjectAsync( const QUrl &url );
101
108 int fetchItemCollectionAsync( const QUrl &url );
109
117 int fetchCollectionsAsync( const QUrl &url );
118
124
133 template<class T> std::unique_ptr< T > takeStacObject( int requestId ) SIP_SKIP;
134
143 std::unique_ptr< QgsStacItemCollection > takeItemCollection( int requestId );
144
154 std::unique_ptr< QgsStacCollectionList > takeCollections( int requestId );
155
160 QString authCfg() const;
161
166 void setAuthCfg( const QString &authCfg );
167
168 signals:
169
178 void finishedStacObjectRequest( int id, QString errorMessage );
179
188 void finishedItemCollectionRequest( int id, QString errorMessage );
189
199 void finishedCollectionsRequest( int id, QString errorMessage );
200
201 private slots:
202 void handleStacObjectReply();
203 void handleItemCollectionReply();
204 void handleCollectionsReply();
205
206 private:
207 QNetworkReply *fetchAsync( const QUrl &url );
208 QgsNetworkReplyContent fetchBlocking( const QUrl &url );
209
210 QString mAuthCfg;
211 QgsHttpHeaders mHeaders;
212 QMap< int, QgsStacObject *> mFetchedStacObjects;
213 QMap< int, QgsStacItemCollection *> mFetchedItemCollections;
214 QMap< int, QgsStacCollectionList *> mFetchedCollections;
215 QVector<QNetworkReply *> mReplies;
216 QString mError;
217};
218
219#endif // QGSSTACCONTROLLER_H
Implements simple HTTP header management.
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...
Stores data associated with a STAC Catalog.
Stores a list of STAC Collections, which is typically used to store the data returned by STAC API /co...
Stores data associated with a STAC Collection.
int fetchStacObjectAsync(const QUrl &url)
Initiates an asynchronous request for a STAC object using the url and returns an associated request i...
std::unique_ptr< QgsStacItemCollection > takeItemCollection(int requestId)
Returns the feature collection fetched with the specified requestId It should be used after the finis...
std::unique_ptr< QgsStacCollectionList > takeCollections(int requestId)
Returns the collections collection fetched with the specified requestId It should be used after the f...
std::unique_ptr< QgsStacCollection > openLocalCollection(const QString &fileName) const
Returns a STAC Collection by parsing a local file The caller takes ownership of the returned collecti...
int fetchCollectionsAsync(const QUrl &url)
Initiates an asynchronous request for a Collections collection using the url and returns an associate...
std::unique_ptr< QgsStacCatalog > openLocalCatalog(const QString &fileName) const
Returns a STAC Catalog by parsing a local file The caller takes ownership of the returned catalog.
void setAuthCfg(const QString &authCfg)
Sets the authentication config id which should be used during the request.
std::unique_ptr< QgsStacItem > openLocalItem(const QString &fileName) const
Returns a STAC Item by parsing a local file The caller takes ownership of the returned item.
std::unique_ptr< QgsStacItemCollection > fetchItemCollection(const QUrl &url, QString *error=nullptr)
Fetches a feature collection from url using a blocking network request.
int fetchItemCollectionAsync(const QUrl &url)
Initiates an asynchronous request for a feature collection using the url and returns an associated re...
QString authCfg() const
Returns the authentication config id which will be used during the request.
void finishedCollectionsRequest(int id, QString errorMessage)
This signal is fired when an async request initiated with fetchCollectionsAsync is finished.
std::unique_ptr< T > fetchStacObject(const QUrl &url, QString *error=nullptr)
Fetches a STAC object from url using a blocking network request.
void finishedItemCollectionRequest(int id, QString errorMessage)
This signal is fired when an async request initiated with fetchItemCollectionAsync is finished.
QgsStacController()=default
Default constructor.
std::unique_ptr< T > takeStacObject(int requestId)
Returns the STAC object fetched with the specified requestId.
void cancelPendingAsyncRequests()
Cancels all pending async requests.
std::unique_ptr< QgsStacCollectionList > fetchCollections(const QUrl &url, QString *error=nullptr)
Fetches collections from url using a blocking network request.
void finishedStacObjectRequest(int id, QString errorMessage)
This signal is fired when an async request initiated with fetchStacObjectAsync is finished.
Stores data associated with a STAC Item Collection.
Stores data associated with a STAC Item.
Definition qgsstacitem.h:35
Abstract base class for storing STAC objects.
#define SIP_SKIP
Definition qgis_sip.h:138