QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgswcs.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgswcs.cpp
3 -------------------------
4 begin : January 16 , 2017
5 copyright : (C) 2013 by René-Luc D'Hont ( parts from qgswcsserver )
6 (C) 2017 by David Marteau
7 email : rldhont at 3liz dot com
8 david dot marteau at 3liz dot com
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#include "qgsmodule.h"
23#include "qgswcsgetcoverage.h"
24#include "qgswcsutils.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
30#define QSTR_COMPARE( str, lit ) \
31 ( str.compare( QLatin1String( lit ), Qt::CaseInsensitive ) == 0 )
32
33namespace QgsWcs
34{
35
42 class Service : public QgsService
43 {
44 public:
50 : mServerIface( serverIface )
51 {}
52
53 QString name() const override { return u"WCS"_s; }
54 QString version() const override { return implementationVersion(); }
55
56 void executeRequest( const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project ) override
57 {
58 Q_UNUSED( project )
59
60 const QgsServerRequest::Parameters params = request.parameters();
61 QString versionString = params.value( "VERSION" );
62
63 // Set the default version
64 if ( versionString.isEmpty() )
65 {
66 versionString = version();
67 }
68
69 // Get the request
70 const QString req = params.value( u"REQUEST"_s );
71 if ( req.isEmpty() )
72 {
73 throw QgsServiceException( u"OperationNotSupported"_s, u"Please add or check the value of the REQUEST parameter"_s, 501 );
74 }
75
76 if ( QSTR_COMPARE( req, "GetCapabilities" ) )
77 {
78 writeGetCapabilities( mServerIface, project, versionString, request, response );
79 }
80 else if ( QSTR_COMPARE( req, "DescribeCoverage" ) )
81 {
82 writeDescribeCoverage( mServerIface, project, versionString, request, response );
83 }
84 else if ( QSTR_COMPARE( req, "GetCoverage" ) )
85 {
86 writeGetCoverage( mServerIface, project, versionString, request, response );
87 }
88 else
89 {
90 // Operation not supported
91 throw QgsServiceException( u"OperationNotSupported"_s, u"Request %1 is not supported"_s.arg( req ), 501 );
92 }
93 }
94
95 private:
96 QgsServerInterface *mServerIface = nullptr;
97 };
98
99
100} // namespace QgsWcs
101
109{
110 public:
111 void registerSelf( QgsServiceRegistry &registry, QgsServerInterface *serverIface ) override
112 {
113 QgsDebugMsgLevel( u"WCSModule::registerSelf called"_s, 2 );
114 registry.registerService( new QgsWcs::Service( serverIface ) );
115 }
116};
117
118
119// Entry points
121{
122 static QgsWcsModule module;
123 return &module;
124}
126{
127 // Nothing to do
128}
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:112
Defines interfaces exposed by QGIS Server and made available to plugins.
Defines requests passed to QgsService classes.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QMap< QString, QString > Parameters
Defines the response interface passed to QgsService.
Defines the service module interface for QGIS server services.
QgsServiceModule()=default
A registry manager for QGIS server services.
void registerService(QgsService *service)
Register a service by its name and version.
QgsService()
Constructor.
Service module specialized for WCS.
Definition qgswcs.cpp:109
void registerSelf(QgsServiceRegistry &registry, QgsServerInterface *serverIface) override
Asks the module to register all provided services.
Definition qgswcs.cpp:111
Exception class for WFS services.
OGC web service specialized for WCS.
Definition qgswcs.cpp:43
void executeRequest(const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project) override
Executes the requests and sets result in QgsServerRequest.
Definition qgswcs.cpp:56
Service(QgsServerInterface *serverIface)
Constructor for WCS service.
Definition qgswcs.cpp:49
QString version() const override
Returns the version of the service.
Definition qgswcs.cpp:54
QString name() const override
Returns the name of the service.
Definition qgswcs.cpp:53
WCS implementation.
Definition qgswcs.cpp:34
void writeDescribeCoverage(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WCS DescribeCoverage response.
QString implementationVersion()
Returns the highest version supported by this implementation.
void writeGetCoverage(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WCS DescribeCoverage response.
void writeGetCapabilities(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WCS GetCapabilities response.
#define QGISEXTERN
Definition qgis.h:7465
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63
#define QSTR_COMPARE(str, lit)
Definition qgswcs.cpp:30
QGISEXTERN QgsServiceModule * QGS_ServiceModule_Init()
Definition qgswcs.cpp:120
QGISEXTERN void QGS_ServiceModule_Exit(QgsServiceModule *)
Definition qgswcs.cpp:125