QGIS API Documentation 4.3.0-Master (389d690bb77)
Loading...
Searching...
No Matches
qgsstaccollection.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsstaccollection.cpp
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#include "qgsstaccollection.h"
17
18#include <QString>
19#include <QTextDocument>
20
21using namespace Qt::StringLiterals;
22
23QgsStacCollection::QgsStacCollection( const QString &id, const QString &version, const QString &description, const QVector< QgsStacLink > &links, const QString &license, const QgsStacExtent &extent )
24 : QgsStacCatalog( id, version, description, links )
25 , mLicense( license )
26 , mExtent( extent )
27{}
28
33
35{
36 QString html = u"<html><head></head>\n<body>\n"_s;
37
38 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Collection"_L1 );
39 html += "<table class=\"list-view\">\n"_L1;
40 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"id"_s, id() );
41 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"stac_version"_s, stacVersion() );
42 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"title"_s, title() );
43 QTextDocument descr;
44 descr.setMarkdown( description() );
45 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"description"_s, descr.toHtml() );
46 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"license"_s, license() );
47 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"keywords"_s, keywords().join( ',' ) );
48 html += "</table>\n"_L1;
49
50 if ( !mStacExtensions.isEmpty() )
51 {
52 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Extensions"_L1 );
53 html += "<ul>\n"_L1;
54 for ( const QString &extension : mStacExtensions )
55 {
56 html += u"<li>%1</li>\n"_s.arg( extension );
57 }
58 html += "</ul>\n"_L1;
59 }
60
61 if ( !mConformanceClasses.isEmpty() )
62 {
63 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Conformance Classes"_L1 );
64 html += "<ul>\n"_L1;
65 for ( const QString &cc : mConformanceClasses )
66 {
67 html += u"<li>%1</li>\n"_s.arg( cc );
68 }
69 html += "</ul>\n"_L1;
70 }
71
72 if ( !mProviders.isEmpty() )
73 {
74 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Providers"_L1 );
75 QTextDocument descr;
76 for ( const QgsStacProvider &p : mProviders )
77 {
78 html += "<table class=\"list-view\">\n"_L1;
79 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"name"_s, p.name() );
80 descr.setMarkdown( p.description() );
81 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"description"_s, descr.toHtml() );
82 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"roles"_s, p.roles().join( ',' ) );
83 html += u"<tr><td class=\"highlight\">%1</td><td><a href=\"%2\">%2</a></td></tr>\n"_s.arg( u"url"_s, p.url() );
84 html += "</table><br/>\n"_L1;
85 }
86 }
87
88 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Spatial Extent"_L1 );
89 html += "<table class=\"list-view\">\n"_L1;
90 QString extentString;
91 if ( mExtent.spatialExtent().is3D() )
92 extentString = mExtent.spatialExtent().toString();
93 else
94 extentString = mExtent.spatialExtent().toRectangle().toString();
95 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"overall"_s, extentString );
96
97
98 if ( mExtent.hasDetailedSpatialExtents() )
99 {
100 const QVector< QgsBox3D > extents = mExtent.detailedSpatialExtents();
101 for ( const QgsBox3D &extent : extents )
102 {
103 QString extentString;
104 if ( extent.is3D() )
105 extentString = extent.toString();
106 else
107 extentString = extent.toRectangle().toString();
108 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"detailed"_s, extentString );
109 }
110 }
111 html += "</table><br/>\n"_L1;
112
113
114 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Temporal Extent"_L1 );
115 html += "<table class=\"list-view\">\n"_L1;
116 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"start"_s, mExtent.temporalExtent().begin().toString() );
117 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"end"_s, mExtent.temporalExtent().end().toString() );
118 html += "</table><br/>\n"_L1;
119
120 if ( mExtent.hasDetailedTemporalExtents() )
121 {
122 html += "Detailed extents:\n"_L1;
123 const QVector< QgsDateTimeRange > extents = mExtent.detailedTemporalExtents();
124 for ( const QgsDateTimeRange &extent : extents )
125 {
126 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Temporal Extent"_L1 );
127 html += "<table class=\"list-view\">\n"_L1;
128 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"start"_s, extent.begin().toString() );
129 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"end"_s, extent.end().toString() );
130 html += "</table><br/>\n"_L1;
131 }
132 }
133
134 if ( !mSummaries.isEmpty() )
135 {
136 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Summaries"_L1 );
137 html += "<table class=\"list-view\">\n"_L1;
138 for ( auto it = mSummaries.constBegin(); it != mSummaries.constEnd(); ++it )
139 {
140 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( it.key(), it.value().toString() );
141 }
142 html += "</table><br/>\n"_L1;
143 }
144
145 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Links"_L1 );
146 for ( const QgsStacLink &link : mLinks )
147 {
148 html += "<table class=\"list-view\">\n"_L1;
149 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"relation"_s, link.relation() );
150 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"title"_s, link.title() );
151 html += u"<tr><td class=\"highlight\">%1</td><td><a href=\"%2\">%2</a></td></tr>\n"_s.arg( u"url"_s, link.href() );
152 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"type"_s, link.mediaType() );
153 html += "</table><br/>\n"_L1;
154 }
155
156 if ( !mAssets.isEmpty() )
157 {
158 QTextDocument descr;
159 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Assets"_L1 );
160 for ( auto it = mAssets.constBegin(); it != mAssets.constEnd(); ++it )
161 {
162 html += "<table class=\"list-view\">\n"_L1;
163 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"id"_s, it.key() );
164 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"title"_s, it->title() );
165 descr.setMarkdown( it->description() );
166 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"description"_s, descr.toHtml() );
167 html += u"<tr><td class=\"highlight\">%1</td><td><a href=\"%2\">%2</a></td></tr>\n"_s.arg( u"url"_s, it->href() );
168 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"type"_s, it->mediaType() );
169 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"roles"_s, it->roles().join( ',' ) );
170 html += "</table><br/>\n"_L1;
171 }
172 }
173
174 html += "\n</body>\n</html>\n"_L1;
175 return html;
176}
177
179{
180 return mKeywords;
181}
182
183void QgsStacCollection::setKeywords( const QStringList &keywords )
184{
185 mKeywords = keywords;
186}
187
189{
190 return mLicense;
191}
192
194{
195 mLicense = license;
196}
197
198QVector<QgsStacProvider> QgsStacCollection::providers() const
199{
200 return mProviders;
201}
202
203void QgsStacCollection::setProviders( const QVector<QgsStacProvider> &providers )
204{
205 mProviders = providers;
206}
207
209{
210 return mExtent;
211}
212
214{
215 mExtent = extent;
216}
217
219{
220 return mSummaries;
221}
222
224{
225 mSummaries = summaries;
226}
227
228QMap<QString, QgsStacAsset> QgsStacCollection::assets() const
229{
230 return mAssets;
231}
232
233void QgsStacCollection::setAssets( const QMap<QString, QgsStacAsset> &assets )
234{
235 mAssets = assets;
236}
StacObjectType
Available types of stac objects.
Definition qgis.h:6885
@ Collection
STAC collection.
Definition qgis.h:6888
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
QString description() const
Returns a Detailed multi-line description to fully explain the Catalog.
QSet< QString > mConformanceClasses
QgsStacCatalog()=delete
Default constructor deleted, use the variant with required parameters.
QString title() const
Returns a short descriptive one-line title for the Catalog.
void setSummaries(const QVariantMap &summaries)
Sets the map of property summaries to the collection.
void setExtent(const QgsStacExtent &extent)
Sets the collection's spatial and temporal extent.
QString license() const
Returns the Collection's license(s), either a SPDX License identifier, various if multiple licenses a...
void setKeywords(const QStringList &keywords)
Sets the list of keywords describing the Collection.
QString toHtml() const override
Returns an HTML representation of the STAC object.
Qgis::StacObjectType type() const override
Returns the Type of the STAC object.
QVariantMap summaries() const
Returns a map of property summaries from the collection.
void setLicense(const QString &license)
Sets the Collection's license(s), either a SPDX License identifier, various if multiple licenses appl...
QVector< QgsStacProvider > providers() const
Returns a list of providers, which may include all organizations capturing or processing the data or ...
QgsStacCollection()=delete
Default constructor deleted, use the variant with required parameters.
void setProviders(const QVector< QgsStacProvider > &providers)
Sets a list of providers, which may include all organizations capturing or processing the data or the...
QgsStacExtent extent() const
Returns the collection's spatial and temporal extent.
QStringList keywords() const
Returns the list of keywords describing the Collection.
QMap< QString, QgsStacAsset > assets() const
Returns a dictionary of asset objects in the catalog, each with a unique id key.
void setAssets(const QMap< QString, QgsStacAsset > &assets)
Sets the asset objects in the catalog, each with a unique id key.
Stores a STAC SpatioTemporal extent.
QString stacVersion() const
Returns the STAC version the object implements.
QString id() const
Id of the STAC object.
QVector< QgsStacLink > mLinks
QStringList mStacExtensions
QVector< QgsStacLink > links() const
Returns the STAC links included in the object.
Stores data related to a STAC provider.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:705