mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Add a WMS request class
This commit is contained in:
parent
28a3138075
commit
5ba7cfb146
@ -58,6 +58,8 @@ Constructor
|
||||
:param headers:
|
||||
%End
|
||||
|
||||
QgsServerRequest( const QgsServerRequest &other );
|
||||
|
||||
virtual ~QgsServerRequest();
|
||||
|
||||
static QString methodToString( const Method &method );
|
||||
@ -94,7 +96,7 @@ to uppercase
|
||||
Returns parameters
|
||||
%End
|
||||
|
||||
void setParameter( const QString &key, const QString &value );
|
||||
virtual void setParameter( const QString &key, const QString &value );
|
||||
%Docstring
|
||||
Set a parameter
|
||||
%End
|
||||
@ -104,7 +106,7 @@ Set a parameter
|
||||
Gets a parameter value
|
||||
%End
|
||||
|
||||
void removeParameter( const QString &key );
|
||||
virtual void removeParameter( const QString &key );
|
||||
%Docstring
|
||||
Remove a parameter
|
||||
%End
|
||||
@ -147,7 +149,7 @@ Check for QByteArray.isNull() to check if data
|
||||
is available.
|
||||
%End
|
||||
|
||||
void setUrl( const QUrl &url );
|
||||
virtual void setUrl( const QUrl &url );
|
||||
%Docstring
|
||||
Set the request url
|
||||
%End
|
||||
|
||||
@ -34,6 +34,15 @@ QgsServerRequest::QgsServerRequest( const QUrl &url, Method method, const Header
|
||||
mParams.load( QUrlQuery( url ) );
|
||||
}
|
||||
|
||||
QgsServerRequest::QgsServerRequest( const QgsServerRequest &other )
|
||||
: mUrl( other.mUrl )
|
||||
, mOriginalUrl( other.mOriginalUrl )
|
||||
, mMethod( other.mMethod )
|
||||
, mHeaders( other.mHeaders )
|
||||
, mParams( other.mParams )
|
||||
{
|
||||
}
|
||||
|
||||
QString QgsServerRequest::methodToString( const QgsServerRequest::Method &method )
|
||||
{
|
||||
static QMetaEnum metaEnum = QMetaEnum::fromType<QgsServerRequest::Method>();
|
||||
|
||||
@ -82,6 +82,8 @@ class SERVER_EXPORT QgsServerRequest
|
||||
*/
|
||||
QgsServerRequest( const QUrl &url, QgsServerRequest::Method method = QgsServerRequest::GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers() );
|
||||
|
||||
QgsServerRequest( const QgsServerRequest &other );
|
||||
|
||||
//! destructor
|
||||
virtual ~QgsServerRequest() = default;
|
||||
|
||||
@ -119,7 +121,7 @@ class SERVER_EXPORT QgsServerRequest
|
||||
/**
|
||||
* Set a parameter
|
||||
*/
|
||||
void setParameter( const QString &key, const QString &value );
|
||||
virtual void setParameter( const QString &key, const QString &value );
|
||||
|
||||
/**
|
||||
* Gets a parameter value
|
||||
@ -129,7 +131,7 @@ class SERVER_EXPORT QgsServerRequest
|
||||
/**
|
||||
* Remove a parameter
|
||||
*/
|
||||
void removeParameter( const QString &key );
|
||||
virtual void removeParameter( const QString &key );
|
||||
|
||||
/**
|
||||
* Returns the header value
|
||||
@ -167,7 +169,7 @@ class SERVER_EXPORT QgsServerRequest
|
||||
/**
|
||||
* Set the request url
|
||||
*/
|
||||
void setUrl( const QUrl &url );
|
||||
virtual void setUrl( const QUrl &url );
|
||||
|
||||
/**
|
||||
* Returns the request url as seen by the web server,
|
||||
|
||||
@ -21,6 +21,7 @@ set (WMS_SRCS
|
||||
qgswmsparameters.cpp
|
||||
qgswmsrestorer.cpp
|
||||
qgswmsrendercontext.cpp
|
||||
qgswmsrequest.cpp
|
||||
)
|
||||
|
||||
set (WMS_HDRS
|
||||
|
||||
57
src/server/services/wms/qgswmsrequest.cpp
Normal file
57
src/server/services/wms/qgswmsrequest.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
qgswmsrequest.cpp
|
||||
|
||||
Define request class for getting request contents for WMS service
|
||||
-------------------
|
||||
begin : 2021-02-10
|
||||
copyright : (C) 2021 by Paul Blottiere
|
||||
email : blottiere.paul@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgswmsrequest.h"
|
||||
|
||||
namespace QgsWms
|
||||
{
|
||||
QgsWmsRequest::QgsWmsRequest( const QgsServerRequest &other )
|
||||
: QgsServerRequest( other )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
const QgsWmsParameters &QgsWmsRequest::wmsParameters() const
|
||||
{
|
||||
return mWmsParams;
|
||||
}
|
||||
|
||||
void QgsWmsRequest::setParameter( const QString &key, const QString &value )
|
||||
{
|
||||
QgsServerRequest::setParameter( key, value );
|
||||
init();
|
||||
}
|
||||
|
||||
void QgsWmsRequest::removeParameter( const QString &key )
|
||||
{
|
||||
QgsServerRequest::removeParameter( key );
|
||||
init();
|
||||
}
|
||||
|
||||
void QgsWmsRequest::setUrl( const QUrl &url )
|
||||
{
|
||||
QgsServerRequest::setUrl( url );
|
||||
init();
|
||||
}
|
||||
|
||||
void QgsWmsRequest::init()
|
||||
{
|
||||
mWmsParams = QgsWmsParameters( QUrlQuery( url() ) );
|
||||
}
|
||||
}
|
||||
68
src/server/services/wms/qgswmsrequest.h
Normal file
68
src/server/services/wms/qgswmsrequest.h
Normal file
@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
qgswmsrequest.h
|
||||
|
||||
Define request class for getting request contents for WMS service
|
||||
-------------------
|
||||
begin : 2021-02-10
|
||||
copyright : (C) 2021 by Paul Blottiere
|
||||
email : blottiere.paul@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSWMSREQUEST_H
|
||||
#define QGSWMSREQUEST_H
|
||||
|
||||
#include "qgsserverrequest.h"
|
||||
#include "qgswmsparameters.h"
|
||||
|
||||
namespace QgsWms
|
||||
{
|
||||
|
||||
/**
|
||||
* \ingroup server
|
||||
* QgsWmsServerRequest
|
||||
* Class defining request interface passed to WMS service
|
||||
* QgsService::executeRequest() method.
|
||||
*
|
||||
* \since QGIS 3.20
|
||||
*/
|
||||
|
||||
class QgsWmsRequest : public QgsServerRequest
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Copy onstructor
|
||||
*/
|
||||
QgsWmsRequest( const QgsServerRequest &other );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~QgsWmsRequest() override = default;
|
||||
|
||||
const QgsWmsParameters &wmsParameters() const;
|
||||
|
||||
void setParameter( const QString &key, const QString &value ) override;
|
||||
|
||||
void removeParameter( const QString &key ) override;
|
||||
|
||||
void setUrl( const QUrl &url ) override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
QgsWmsParameters mWmsParams;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user