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