QGIS API Documentation 4.3.0-Master (389d690bb77)
Loading...
Searching...
No Matches
qgsstaccatalog.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsstaccatalog.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 "qgsstaccatalog.h"
17
18#include <QString>
19
20using namespace Qt::StringLiterals;
21
22QgsStacCatalog::QgsStacCatalog( const QString &id, const QString &version, const QString &description, const QVector< QgsStacLink > &links )
23 : QgsStacObject( id, version, links )
25{}
26
31
33{
34 QString html = u"<html><head></head>\n<body>\n"_s;
35
36 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Catalog"_L1 );
37 html += "<table class=\"list-view\">\n"_L1;
38 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"id"_s, id() );
39 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"stac_version"_s, stacVersion() );
40 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"title"_s, title() );
41 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"description"_s, description() );
42 html += "</table>\n"_L1;
43
44 if ( !mStacExtensions.isEmpty() )
45 {
46 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Extensions"_L1 );
47 html += "<ul>\n"_L1;
48 for ( const QString &extension : mStacExtensions )
49 {
50 html += u"<li>%1</li>\n"_s.arg( extension );
51 }
52 html += "</ul>\n"_L1;
53 }
54
55 if ( !mConformanceClasses.isEmpty() )
56 {
57 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Conformance Classes"_L1 );
58 html += "<ul>\n"_L1;
59 for ( const QString &cc : mConformanceClasses )
60 {
61 html += u"<li>%1</li>\n"_s.arg( cc );
62 }
63 html += "</ul>\n"_L1;
64 }
65
66 html += u"<h1>%1</h1>\n<hr>\n"_s.arg( "Links"_L1 );
67 for ( const QgsStacLink &link : mLinks )
68 {
69 html += "<table class=\"list-view\">\n"_L1;
70 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"relation"_s, link.relation() );
71 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"title"_s, link.title() );
72 html += u"<tr><td class=\"highlight\">%1</td><td><a href=\"%2\">%2</a></td></tr>\n"_s.arg( u"url"_s, link.href() );
73 html += u"<tr><td class=\"highlight\">%1</td><td>%2</td></tr>\n"_s.arg( u"type"_s, link.mediaType() );
74 html += "</table><br/>\n"_L1;
75 }
76
77 html += "\n</body>\n</html>\n"_L1;
78 return html;
79}
80
81QString QgsStacCatalog::title() const
82{
83 return mTitle;
84}
85
86void QgsStacCatalog::setTitle( const QString &title )
87{
88 mTitle = title;
89}
90
92{
93 return mDescription;
94}
95
100
101bool QgsStacCatalog::conformsTo( const QString &conformanceClass ) const
102{
103 return mConformanceClasses.contains( conformanceClass );
104}
105
106void QgsStacCatalog::setConformanceClasses( const QStringList &conformanceClasses )
107{
108 mConformanceClasses = QSet< QString >( conformanceClasses.constBegin(), conformanceClasses.constEnd() );
109}
110
111void QgsStacCatalog::addConformanceClass( const QString &conformanceClass )
112{
113 mConformanceClasses.insert( conformanceClass );
114}
StacObjectType
Available types of stac objects.
Definition qgis.h:6885
@ Catalog
STAC catalog.
Definition qgis.h:6887
void addConformanceClass(const QString &conformanceClass)
Adds conformanceClass to the list of catalog's conformance classes.
QString toHtml() const override
Returns an HTML representation of the STAC object.
void setTitle(const QString &title)
Sets a short descriptive one-line title for the Catalog.
QString description() const
Returns a Detailed multi-line description to fully explain the Catalog.
Qgis::StacObjectType type() const override
Returns the Type of the STAC object.
QSet< QString > mConformanceClasses
void setConformanceClasses(const QStringList &conformanceClasses)
Sets the list of conformanceClasses this catalog conforms to.
QgsStacCatalog()=delete
Default constructor deleted, use the variant with required parameters.
bool conformsTo(const QString &conformanceClass) const
Checks if the catalog is a STAC API conforming to the specified conformanceClass.
void setDescription(const QString &description)
Sets a detailed multi-line description to fully explain the Catalog.
QString title() const
Returns a short descriptive one-line title for the Catalog.
QString stacVersion() const
Returns the STAC version the object implements.
QString id() const
Id of the STAC object.
QVector< QgsStacLink > mLinks
QgsStacObject()=delete
Default constructor is used for creating invalid objects.
QStringList mStacExtensions
QVector< QgsStacLink > links() const
Returns the STAC links included in the object.