QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 ) ( str.compare( QLatin1String( lit ), Qt::CaseInsensitive ) == 0 )
31
32namespace QgsWcs
33{
34
41 class Service : public QgsService
42 {
43 public:
49 : mServerIface( serverIface )
50 {}
51
52 QString name() const override { return u"WCS"_s; }
53 QString version() const override { return implementationVersion(); }
54
55 void executeRequest( const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project ) override
56 {
57 Q_UNUSED( project )
58
59 const QgsServerRequest::Parameters params = request.parameters();
60 QString versionString = params.value( "VERSION" );
61
62 // Set the default version
63 if ( versionString.isEmpty() )
64 {
65 versionString = version();
66 }
67
68 // Get the request
69 const QString req = params.value( u"REQUEST"_s );
70 if ( req.isEmpty() )
71 {
72 throw QgsServiceException( u"OperationNotSupported"_s, u"Please add or check the value of the REQUEST parameter"_s, 501 );
73 }
74
75 if ( QSTR_COMPARE( req, "GetCapabilities" ) )
76 {
77 writeGetCapabilities( mServerIface, project, versionString, request, response );
78 }
79 else if ( QSTR_COMPARE( req, "DescribeCoverage" ) )
80 {
81 writeDescribeCoverage( mServerIface, project, versionString, request, response );
82 }
83 else if ( QSTR_COMPARE( req, "GetCoverage" ) )
84 {
85 writeGetCoverage( mServerIface, project, versionString, request, response );
86 }
87 else
88 {
89 // Operation not supported
90 throw QgsServiceException( u"OperationNotSupported"_s, u"Request %1 is not supported"_s.arg( req ), 501 );
91 }
92 }
93
94 private:
95 QgsServerInterface *mServerIface = nullptr;
96 };
97
98
99} // namespace QgsWcs
100
108{
109 public:
110 void registerSelf( QgsServiceRegistry &registry, QgsServerInterface *serverIface ) override
111 {
112 QgsDebugMsgLevel( u"WCSModule::registerSelf called"_s, 2 );
113 registry.registerService( new QgsWcs::Service( serverIface ) );
114 }
115};
116
117
118// Entry points
120{
121 static QgsWcsModule module;
122 return &module;
123}
125{
126 // Nothing to do
127}
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:113
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:108
void registerSelf(QgsServiceRegistry &registry, QgsServerInterface *serverIface) override
Asks the module to register all provided services.
Definition qgswcs.cpp:110
Exception class for WFS services.
OGC web service specialized for WCS.
Definition qgswcs.cpp:42
void executeRequest(const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project) override
Executes the requests and sets result in QgsServerRequest.
Definition qgswcs.cpp:55
Service(QgsServerInterface *serverIface)
Constructor for WCS service.
Definition qgswcs.cpp:48
QString version() const override
Returns the version of the service.
Definition qgswcs.cpp:53
QString name() const override
Returns the name of the service.
Definition qgswcs.cpp:52
WCS implementation.
Definition qgswcs.cpp:33
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:7518
#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:119
QGISEXTERN void QGS_ServiceModule_Exit(QgsServiceModule *)
Definition qgswcs.cpp:124