-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Server][Feature][needs-docs] Add WMTS service
This commit contains the first line of code for WMTS service in QGIS server. The implementation is mainly for standard implementation.
- Loading branch information
Showing
10 changed files
with
1,462 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
|
|||
######################################################## | |||
# Files | |||
|
|||
SET (wmts_SRCS | |||
qgswmts.cpp | |||
qgswmtsutils.cpp | |||
qgswmtsgetcapabilities.cpp | |||
qgswmtsgettile.cpp | |||
) | |||
|
|||
######################################################## | |||
# Build | |||
|
|||
ADD_LIBRARY (wmts MODULE ${wmts_SRCS}) | |||
|
|||
|
|||
INCLUDE_DIRECTORIES(SYSTEM | |||
${GDAL_INCLUDE_DIR} | |||
${POSTGRES_INCLUDE_DIR} | |||
) | |||
|
|||
INCLUDE_DIRECTORIES( | |||
${CMAKE_BINARY_DIR}/src/core | |||
${CMAKE_BINARY_DIR}/src/python | |||
${CMAKE_BINARY_DIR}/src/analysis | |||
${CMAKE_BINARY_DIR}/src/server | |||
${CMAKE_CURRENT_BINARY_DIR} | |||
../wms | |||
../../../core | |||
../../../core/dxf | |||
../../../core/expression | |||
../../../core/geometry | |||
../../../core/metadata | |||
../../../core/raster | |||
../../../core/symbology | |||
../../../core/layertree | |||
../.. | |||
.. | |||
. | |||
) | |||
|
|||
|
|||
TARGET_LINK_LIBRARIES(wmts | |||
qgis_core | |||
qgis_server | |||
) | |||
|
|||
|
|||
######################################################## | |||
# Install | |||
|
|||
INSTALL(TARGETS wmts | |||
RUNTIME DESTINATION ${QGIS_SERVER_MODULE_DIR} | |||
LIBRARY DESTINATION ${QGIS_SERVER_MODULE_DIR} | |||
) | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,126 @@ | |||
/*************************************************************************** | |||
qgswmts.cpp | |||
------------------------- | |||
begin : July 23 , 2018 | |||
copyright : (C) 2018 by René-Luc D'Hont | |||
email : rldhont at 3liz dot 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 "qgsmodule.h" | |||
#include "qgswmtsutils.h" | |||
#include "qgswmtsgetcapabilities.h" | |||
#include "qgswmtsgettile.h" | |||
|
|||
#define QSTR_COMPARE( str, lit )\ | |||
(str.compare( QStringLiteral( lit ), Qt::CaseInsensitive ) == 0) | |||
|
|||
namespace QgsWmts | |||
{ | |||
|
|||
/** | |||
* \ingroup server | |||
* \class QgsWmts::Service | |||
* \brief OGC web service specialized for WMTS | |||
* \since QGIS 3.0 | |||
*/ | |||
class Service: public QgsService | |||
{ | |||
public: | |||
|
|||
/** | |||
* Constructor for WMTS service. | |||
* \param serverIface Interface for plugins. | |||
*/ | |||
Service( QgsServerInterface *serverIface ) | |||
: mServerIface( serverIface ) | |||
{} | |||
|
|||
QString name() const override { return QStringLiteral( "WMTS" ); } | |||
QString version() const override { return implementationVersion(); } | |||
|
|||
bool allowMethod( QgsServerRequest::Method method ) const override | |||
{ | |||
return method == QgsServerRequest::GetMethod || method == QgsServerRequest::PostMethod; | |||
} | |||
|
|||
void executeRequest( const QgsServerRequest &request, QgsServerResponse &response, | |||
const QgsProject *project ) override | |||
{ | |||
Q_UNUSED( project ); | |||
|
|||
QgsServerRequest::Parameters params = request.parameters(); | |||
QString versionString = params.value( "VERSION" ); | |||
|
|||
// Set the default version | |||
if ( versionString.isEmpty() ) | |||
{ | |||
versionString = version(); | |||
} | |||
|
|||
// Get the request | |||
QString req = params.value( QStringLiteral( "REQUEST" ) ); | |||
if ( req.isEmpty() ) | |||
{ | |||
throw QgsServiceException( QStringLiteral( "OperationNotSupported" ), | |||
QStringLiteral( "Please check the value of the REQUEST parameter" ) ); | |||
} | |||
|
|||
if ( QSTR_COMPARE( req, "GetCapabilities" ) ) | |||
{ | |||
writeGetCapabilities( mServerIface, project, versionString, request, response ); | |||
} | |||
else if ( QSTR_COMPARE( req, "GetTile" ) ) | |||
{ | |||
writeGetTile( mServerIface, project, versionString, request, response ); | |||
} | |||
else | |||
{ | |||
// Operation not supported | |||
throw QgsServiceException( QStringLiteral( "OperationNotSupported" ), | |||
QStringLiteral( "Request %1 is not supported" ).arg( req ) ); | |||
} | |||
} | |||
|
|||
private: | |||
QgsServerInterface *mServerIface = nullptr; | |||
}; | |||
|
|||
|
|||
} // namespace QgsWmts | |||
|
|||
/** | |||
* \ingroup server | |||
* \class QgsWmtsModule | |||
* \brief Service module specialized for WMTS | |||
* \since QGIS 3.4 | |||
*/ | |||
class QgsWmtsModule: public QgsServiceModule | |||
{ | |||
public: | |||
void registerSelf( QgsServiceRegistry ®istry, QgsServerInterface *serverIface ) override | |||
{ | |||
QgsDebugMsg( "WMTSModule::registerSelf called" ); | |||
registry.registerService( new QgsWmts::Service( serverIface ) ); | |||
} | |||
}; | |||
|
|||
|
|||
// Entry points | |||
QGISEXTERN QgsServiceModule *QGS_ServiceModule_Init() | |||
{ | |||
static QgsWmtsModule module; | |||
return &module; | |||
} | |||
QGISEXTERN void QGS_ServiceModule_Exit( QgsServiceModule * ) | |||
{ | |||
// Nothing to do | |||
} |
Oops, something went wrong.