QGIS API Documentation 4.3.0-Master (389d690bb77)
Loading...
Searching...
No Matches
qgsstacparser.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsstacparser.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 QGSSTACPARSER_H
17#define QGSSTACPARSER_H
18
19#include <nlohmann/json.hpp>
20
21#include "qgis.h"
22#include "qgsstacasset.h"
23#include "qgsstacobject.h"
24
25#include <QUrl>
26
27class QgsStacCatalog;
30class QgsStacItem;
32
33
43class CORE_EXPORT QgsStacParser
44{
45 public:
47 QgsStacParser() = default;
48
50 void setData( const QByteArray &data );
51
56 void setBaseUrl( const QUrl &url );
57
63 std::unique_ptr< QgsStacCatalog > catalog();
64
65
71 std::unique_ptr< QgsStacCollection > collection() SIP_SKIP;
72
78 std::unique_ptr< QgsStacItem > item() SIP_SKIP;
79
86
93
95 Qgis::StacObjectType type() const;
96
98 QString error() const;
99
100 private:
101#ifdef SIP_RUN
103#endif
104
105 std::unique_ptr< QgsStacItem > parseItem( const nlohmann::json &data );
106 std::unique_ptr< QgsStacCatalog > parseCatalog( const nlohmann::json &data );
107 std::unique_ptr< QgsStacCollection > parseCollection( const nlohmann::json &data );
108
109 QVector< QgsStacLink > parseLinks( const nlohmann::json &data );
110 QMap< QString, QgsStacAsset > parseAssets( const nlohmann::json &data );
111 static bool isSupportedStacVersion( const QString &version );
113 static QString getString( const nlohmann::json &data );
114
115 nlohmann::json mData;
117 std::unique_ptr<QgsStacObject> mObject;
118 QString mError;
119 QUrl mBaseUrl;
120};
121
122
123#endif // QGSSTACPARSER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
StacObjectType
Available types of stac objects.
Definition qgis.h:6885
@ Unknown
Type is not known.
Definition qgis.h:6886
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.
Stores data associated with a STAC Item Collection.
Stores data associated with a STAC Item.
Definition qgsstacitem.h:35
QString error() const
Returns the last parsing error.
QgsStacCollectionList * collections()
Returns the parsed STAC API Collections If parsing failed, nullptr is returned The caller takes owner...
void setBaseUrl(const QUrl &url)
Sets the base url that will be used to resolve relative links.
QgsStacParser()=default
Default constructor.
std::unique_ptr< QgsStacItem > item()
Returns the parsed STAC Item If parsing failed, nullptr is returned The caller takes ownership of the...
std::unique_ptr< QgsStacItemCollection > itemCollection()
Returns the parsed STAC API Item Collection If parsing failed, nullptr is returned The caller takes o...
std::unique_ptr< QgsStacCatalog > catalog()
Returns the parsed STAC Catalog If parsing failed, nullptr is returned The caller takes ownership of ...
Qgis::StacObjectType type() const
Returns the type of the parsed object.
std::unique_ptr< QgsStacCollection > collection()
Returns the parsed STAC Collection If parsing failed, nullptr is returned The caller takes ownership ...
void setData(const QByteArray &data)
Sets the JSON data to be parsed.
#define SIP_FORCE
Definition qgis_sip.h:143
#define SIP_SKIP
Definition qgis_sip.h:138