QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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"
21#include "qgswcsutils.h"
24#include "qgswcsgetcoverage.h"
25
26#define QSTR_COMPARE( str, lit )\
27 (str.compare( QLatin1String( lit ), Qt::CaseInsensitive ) == 0)
28
29namespace QgsWcs
30{
31
38 class Service: public QgsService
39 {
40 public:
41
47 : mServerIface( serverIface )
48 {}
49
50 QString name() const override { return QStringLiteral( "WCS" ); }
51 QString version() const override { return implementationVersion(); }
52
53 void executeRequest( const QgsServerRequest &request, QgsServerResponse &response,
54 const QgsProject *project ) override
55 {
56 Q_UNUSED( project )
57
58 const QgsServerRequest::Parameters params = request.parameters();
59 QString versionString = params.value( "VERSION" );
60
61 // Set the default version
62 if ( versionString.isEmpty() )
63 {
64 versionString = version();
65 }
66
67 // Get the request
68 const QString req = params.value( QStringLiteral( "REQUEST" ) );
69 if ( req.isEmpty() )
70 {
71 throw QgsServiceException( QStringLiteral( "OperationNotSupported" ),
72 QStringLiteral( "Please add or check the value of the REQUEST parameter" ), 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( QStringLiteral( "OperationNotSupported" ),
91 QStringLiteral( "Request %1 is not supported" ).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( QStringLiteral( "WCSModule::registerSelf called" ), 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:107
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QMap< QString, QString > Parameters
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
Class defining the service module interface for QGIS server services.
QgsServiceRegistry Class defining the registry manager for QGIS server services.
void registerService(QgsService *service)
Register a service by its name and version.
QgsService Class defining interfaces for QGIS server services.
Definition: qgsservice.h:39
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:39
void executeRequest(const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project) override
Execute the requests and set result in QgsServerRequest.
Definition: qgswcs.cpp:53
Service(QgsServerInterface *serverIface)
Constructor for WCS service.
Definition: qgswcs.cpp:46
QString version() const override
Definition: qgswcs.cpp:51
QString name() const override
Definition: qgswcs.cpp:50
WCS implementation.
Definition: qgswcs.cpp:30
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.
Definition: qgswcsutils.cpp:30
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:5790
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
#define QSTR_COMPARE(str, lit)
Definition: qgswcs.cpp:26
QGISEXTERN QgsServiceModule * QGS_ServiceModule_Init()
Definition: qgswcs.cpp:120
QGISEXTERN void QGS_ServiceModule_Exit(QgsServiceModule *)
Definition: qgswcs.cpp:125