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