QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
qgsserverogcapi.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsserverogcapi.h - QgsServerOgcApi
3
4 ---------------------
5 begin : 10.7.2019
6 copyright : (C) 2019 by Alessandro Pasotti
7 email : elpaso at itopen dot it
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSSERVEROGCAPI_H
17#define QGSSERVEROGCAPI_H
18
19#include "qgsserverapi.h"
20#include "qgis_server.h"
21
22
24
48class SERVER_EXPORT QgsServerOgcApi : public QgsServerApi
49{
50 Q_GADGET
51
52 public:
53 // Note: non a scoped enum or qHash fails
55 enum Rel
56 {
57 // The following registered link relation types are used
68 // In addition the following link relation types are used for which no applicable registered link relation type could be identified:
71 data
72 };
73 Q_ENUM( Rel )
74
75 // Note: cannot be a scoped enum because qHash does not support them
85 Q_ENUM( ContentType )
86
87
95 QgsServerOgcApi( QgsServerInterface *serverIface, const QString &rootPath, const QString &name, const QString &description = QString(), const QString &version = QString() );
96
97 // QgsServerApi interface
98 const QString name() const override { return mName; }
99 const QString description() const override { return mDescription; }
100 const QString version() const override { return mVersion; }
101 const QString rootPath() const override { return mRootPath; }
102
103 ~QgsServerOgcApi() override;
104
108 virtual void executeRequest( const QgsServerApiContext &context ) const override SIP_THROW( QgsServerApiBadRequestException ) SIP_VIRTUALERRORHANDLER( serverapi_badrequest_exception_handler );
109
114 static const QMap<QgsServerOgcApi::ContentType, QStringList> contentTypeMimes() SIP_SKIP;
115
120 static const QHash<QgsServerOgcApi::ContentType, QList<QgsServerOgcApi::ContentType>> contentTypeAliases() SIP_SKIP;
121
122 // Utilities
123#ifndef SIP_RUN
124
129 template<class T, typename... Args>
130 void registerHandler( Args... args )
131 {
132 mHandlers.emplace_back( std::make_shared<T>( args... ) );
133 }
134#endif
135
139 void registerHandler( QgsServerOgcApiHandler *handler SIP_TRANSFER );
140
145 static QUrl sanitizeUrl( const QUrl &url );
146
150 static std::string relToString( const QgsServerOgcApi::Rel &rel );
151
155 static QString contentTypeToString( const QgsServerOgcApi::ContentType &ct );
156
160 static std::string contentTypeToStdString( const QgsServerOgcApi::ContentType &ct );
161
165 static QString contentTypeToExtension( const QgsServerOgcApi::ContentType &ct );
166
171 Q_DECL_DEPRECATED static QgsServerOgcApi::ContentType contenTypeFromExtension( const std::string &extension ) SIP_DEPRECATED { return contentTypeFromExtension( extension ); } // spellok
172
177 static QgsServerOgcApi::ContentType contentTypeFromExtension( const std::string &extension );
178
182 static std::string mimeType( const QgsServerOgcApi::ContentType &contentType );
183
187 const std::vector<std::shared_ptr<QgsServerOgcApiHandler>> handlers() const SIP_SKIP;
188
189 private:
190 QString mRootPath;
191 QString mName;
192 QString mDescription;
193 QString mVersion;
194
195 //Note: this cannot be unique because of SIP bindings
196 std::vector<std::shared_ptr<QgsServerOgcApiHandler>> mHandlers;
197
199 static QMap<QgsServerOgcApi::ContentType, QStringList> sContentTypeMime;
200
206 static QHash<QgsServerOgcApi::ContentType, QList<QgsServerOgcApi::ContentType>> sContentTypeAliases;
207};
208
209#endif // QGSSERVEROGCAPI_H
Bad request error API exception.
The QgsServerApiContext class encapsulates the resources for a particular client request: the request...
Server generic API endpoint abstract base class.
virtual void executeRequest(const QgsServerApiContext &context) const =0
Executes a request by passing the given context to the API handlers.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
The QgsServerOgcApiHandler abstract class represents a OGC API handler to be registered in QgsServerO...
QGIS Server OGC API endpoint.
const QString rootPath() const override
Returns the root path for the API.
void registerHandler(Args... args)
Registers an OGC API handler passing Args to the constructor.
const QString description() const override
Returns the API description.
ContentType
Media types used for content negotiation, insert more specific first.
@ OPENAPI3
"application/openapi+json;version=3.0"
Rel
Rel link types.
@ alternate
Refers to a substitute for this context.
@ collection
The target IRI points to a resource that is a member of the collection represented by the context IRI...
@ self
Conveys an identifier for the link’s context.
@ prev
Indicates that the link’s context is a part of a series, and that the previous in the series is the l...
@ service_doc
Identifies service documentation for the context that is primarily intended for human consumption.
@ conformance
The target IRI points to a resource which represents the collection resource for the context IRI.
@ describedBy
Refers to a resource providing information about the link’s context.
@ next
Indicates that the link’s context is a part of a series, and that the next in the series is the link ...
@ license
Refers to a license associated with this context.
@ service_desc
Identifies service description for the context that is primarily intended for consumption by machines...
@ items
Refers to a resource that is comprised of members of the collection represented by the link’s context...
@ item
The target IRI points to a resource that is a member of the collection represented by the context IRI...
const QString version() const override
Returns the version of the service.
const QString name() const override
Returns the API name.
static Q_DECL_DEPRECATED QgsServerOgcApi::ContentType contenTypeFromExtension(const std::string &extension)
Returns the Content-Type value corresponding to extension.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_VIRTUALERRORHANDLER(name)
Definition qgis_sip.h:196
#define SIP_THROW(name,...)
Definition qgis_sip.h:203