QGIS API Documentation 3.41.0-Master (3291e9ff48b)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsServerOgcApi Class Reference

QGIS Server OGC API endpoint. More...

#include <qgsserverogcapi.h>

Inheritance diagram for QgsServerOgcApi:
Inheritance graph
[legend]

Public Types

enum  ContentType {
  GEOJSON , OPENAPI3 , JSON , HTML ,
  XML
}
 Media types used for content negotiation, insert more specific first. More...
 
enum  Rel {
  alternate , describedBy , collection , item ,
  self , service_desc , service_doc , prev ,
  next , license , items , conformance ,
  data
}
 Rel link types. More...
 

Public Member Functions

 QgsServerOgcApi (QgsServerInterface *serverIface, const QString &rootPath, const QString &name, const QString &description=QString(), const QString &version=QString())
 QgsServerOgcApi constructor.
 
 ~QgsServerOgcApi () override
 
const QString description () const override
 Returns the API description.
 
virtual void executeRequest (const QgsServerApiContext &context) const override
 Executes a request by passing the given context to the API handlers.
 
const std::vector< std::shared_ptr< QgsServerOgcApiHandler > > handlers () const
 Returns registered handlers.
 
const QString name () const override
 Returns the API name.
 
template<class T , typename... Args>
void registerHandler (Args... args)
 Registers an OGC API handler passing Args to the constructor.
 
void registerHandler (QgsServerOgcApiHandler *handler)
 Registers an OGC API handler, ownership of the handler is transferred to the API.
 
const QString rootPath () const override
 Returns the root path for the API.
 
const QString version () const override
 Returns the version of the service.
 
- Public Member Functions inherited from QgsServerApi
 QgsServerApi (QgsServerInterface *serverIface)
 Creates a QgsServerApi object.
 
virtual ~QgsServerApi ()=default
 
virtual bool accept (const QUrl &url) const
 Returns true if the given url is handled by the API, default implementation checks for the presence of rootPath inside the url path.
 
QgsServerInterfaceserverIface () const
 Returns the server interface.
 

Static Public Member Functions

static const QHash< QgsServerOgcApi::ContentType, QList< QgsServerOgcApi::ContentType > > contentTypeAliases ()
 Returns contentType specializations (e.g.
 
static QgsServerOgcApi::ContentType contentTypeFromExtension (const std::string &extension)
 Returns the Content-Type value corresponding to extension.
 
static const QMap< QgsServerOgcApi::ContentType, QStringList > contentTypeMimes ()
 Returns a map of contentType => list of mime types.
 
static QString contentTypeToExtension (const QgsServerOgcApi::ContentType &ct)
 Returns the file extension for a ct (Content-Type).
 
static std::string contentTypeToStdString (const QgsServerOgcApi::ContentType &ct)
 Returns the string representation of a ct (Content-Type) attribute.
 
static QString contentTypeToString (const QgsServerOgcApi::ContentType &ct)
 Returns the string representation of a ct (Content-Type) attribute.
 
static Q_DECL_DEPRECATED QgsServerOgcApi::ContentType contenTypeFromExtension (const std::string &extension)
 Returns the Content-Type value corresponding to extension.
 
static std::string mimeType (const QgsServerOgcApi::ContentType &contentType)
 Returns the mime-type for the contentType or an empty string if not found.
 
static std::string relToString (const QgsServerOgcApi::Rel &rel)
 Returns the string representation of rel attribute.
 
static QUrl sanitizeUrl (const QUrl &url)
 Returns a sanitized url with extra slashes removed and the path URL component that always starts with a slash.
 

Detailed Description

QGIS Server OGC API endpoint.

QgsServerOgcApi provides the foundation for the new generation of REST-API based OGC services (e.g. WFS3).

This class can be used directly and configured by registering handlers as instances of QgsServerOgcApiHandler.

class Handler1(QgsServerOgcApiHandler):
"""A handler, see QgsServerOgcApiHandler for an example"""
...
h = Handler1()
api = QgsServerOgcApi(serverInterface(), "/api1", "apione", "A firs API", "1.0")
api.registerHandler(h)
server.serverInterface().serviceRegistry().registerApi(api)
The QgsServerOgcApiHandler abstract class represents a OGC API handler to be registered in QgsServerO...
QGIS Server OGC API endpoint.
Since
QGIS 3.10

Definition at line 48 of file qgsserverogcapi.h.

Member Enumeration Documentation

◆ ContentType

Media types used for content negotiation, insert more specific first.

Enumerator
GEOJSON 
OPENAPI3 

"application/openapi+json;version=3.0"

JSON 
HTML 
XML 

Definition at line 79 of file qgsserverogcapi.h.

◆ Rel

Rel link types.

Enumerator
alternate 

Refers to a substitute for this context.

describedBy 

Refers to a resource providing information about the link’s context.

collection 

The target IRI points to a resource that is a member of the collection represented by the context IRI.

item 

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.

service_desc 

Identifies service description for the context that is primarily intended for consumption by machines.

service_doc 

Identifies service documentation for the context that is primarily intended for human consumption.

prev 

Indicates that the link’s context is a part of a series, and that the previous in the series is the link targe.

next 

Indicates that the link’s context is a part of a series, and that the next in the series is the link target.

license 

Refers to a license associated with this context.

items 

Refers to a resource that is comprised of members of the collection represented by the link’s context.

conformance 

The target IRI points to a resource which represents the collection resource for the context IRI.

data 

The target IRI points to resource data.

Definition at line 57 of file qgsserverogcapi.h.

Constructor & Destructor Documentation

◆ QgsServerOgcApi()

QgsServerOgcApi::QgsServerOgcApi ( QgsServerInterface serverIface,
const QString &  rootPath,
const QString &  name,
const QString &  description = QString(),
const QString &  version = QString() 
)

QgsServerOgcApi constructor.

Parameters
serverIfacepointer to the server interface
rootPathroot path for this API (usually starts with a "/", e.g. "/wfs3")
nameAPI name
descriptionAPI description
versionAPI version

Definition at line 50 of file qgsserverogcapi.cpp.

◆ ~QgsServerOgcApi()

QgsServerOgcApi::~QgsServerOgcApi ( )
override

Definition at line 60 of file qgsserverogcapi.cpp.

Member Function Documentation

◆ contentTypeAliases()

const QHash< QgsServerOgcApi::ContentType, QList< QgsServerOgcApi::ContentType > > QgsServerOgcApi::contentTypeAliases ( )
static

Returns contentType specializations (e.g.

JSON => [GEOJSON, OPENAPI3], XML => [GML])

Note
not available in Python bindings

Definition at line 125 of file qgsserverogcapi.cpp.

◆ contentTypeFromExtension()

QgsServerOgcApi::ContentType QgsServerOgcApi::contentTypeFromExtension ( const std::string &  extension)
static

Returns the Content-Type value corresponding to extension.

Since
QGIS 3.38

Definition at line 156 of file qgsserverogcapi.cpp.

◆ contentTypeMimes()

const QMap< QgsServerOgcApi::ContentType, QStringList > QgsServerOgcApi::contentTypeMimes ( )
static

Returns a map of contentType => list of mime types.

Note
not available in Python bindings

Definition at line 120 of file qgsserverogcapi.cpp.

◆ contentTypeToExtension()

QString QgsServerOgcApi::contentTypeToExtension ( const QgsServerOgcApi::ContentType ct)
static

Returns the file extension for a ct (Content-Type).

Definition at line 151 of file qgsserverogcapi.cpp.

◆ contentTypeToStdString()

std::string QgsServerOgcApi::contentTypeToStdString ( const QgsServerOgcApi::ContentType ct)
static

Returns the string representation of a ct (Content-Type) attribute.

Definition at line 145 of file qgsserverogcapi.cpp.

◆ contentTypeToString()

QString QgsServerOgcApi::contentTypeToString ( const QgsServerOgcApi::ContentType ct)
static

Returns the string representation of a ct (Content-Type) attribute.

Definition at line 138 of file qgsserverogcapi.cpp.

◆ contenTypeFromExtension()

static Q_DECL_DEPRECATED QgsServerOgcApi::ContentType QgsServerOgcApi::contenTypeFromExtension ( const std::string &  extension)
inlinestatic

Returns the Content-Type value corresponding to extension.

Deprecated:
QGIS 3.40. Use contentTypeFromExtension().

Definition at line 177 of file qgsserverogcapi.h.

◆ description()

const QString QgsServerOgcApi::description ( ) const
inlineoverridevirtual

Returns the API description.

Implements QgsServerApi.

Definition at line 105 of file qgsserverogcapi.h.

◆ executeRequest()

void QgsServerOgcApi::executeRequest ( const QgsServerApiContext context) const
overridevirtual

Executes a request by passing the given context to the API handlers.

Implements QgsServerApi.

Definition at line 87 of file qgsserverogcapi.cpp.

◆ handlers()

const std::vector< std::shared_ptr< QgsServerOgcApiHandler > > QgsServerOgcApi::handlers ( ) const

Returns registered handlers.

Definition at line 189 of file qgsserverogcapi.cpp.

◆ mimeType()

std::string QgsServerOgcApi::mimeType ( const QgsServerOgcApi::ContentType contentType)
static

Returns the mime-type for the contentType or an empty string if not found.

Definition at line 180 of file qgsserverogcapi.cpp.

◆ name()

const QString QgsServerOgcApi::name ( ) const
inlineoverridevirtual

Returns the API name.

Implements QgsServerApi.

Definition at line 104 of file qgsserverogcapi.h.

◆ registerHandler() [1/2]

template<class T , typename... Args>
void QgsServerOgcApi::registerHandler ( Args...  args)
inline

Registers an OGC API handler passing Args to the constructor.

Note
not available in Python bindings

Definition at line 136 of file qgsserverogcapi.h.

◆ registerHandler() [2/2]

void QgsServerOgcApi::registerHandler ( QgsServerOgcApiHandler handler)

Registers an OGC API handler, ownership of the handler is transferred to the API.

Definition at line 65 of file qgsserverogcapi.cpp.

◆ relToString()

std::string QgsServerOgcApi::relToString ( const QgsServerOgcApi::Rel rel)
static

Returns the string representation of rel attribute.

Definition at line 130 of file qgsserverogcapi.cpp.

◆ rootPath()

const QString QgsServerOgcApi::rootPath ( ) const
inlineoverridevirtual

Returns the root path for the API.

Implements QgsServerApi.

Definition at line 107 of file qgsserverogcapi.h.

◆ sanitizeUrl()

QUrl QgsServerOgcApi::sanitizeUrl ( const QUrl &  url)
static

Returns a sanitized url with extra slashes removed and the path URL component that always starts with a slash.

Definition at line 71 of file qgsserverogcapi.cpp.

◆ version()

const QString QgsServerOgcApi::version ( ) const
inlineoverridevirtual

Returns the version of the service.

Note
the default implementation returns an empty string

Reimplemented from QgsServerApi.

Definition at line 106 of file qgsserverogcapi.h.


The documentation for this class was generated from the following files: