Skip to content
Permalink
Browse files

[Server][Feature][needs-docs] Add QgsWmtsParameters to WMTS service

  • Loading branch information
rldhont committed Aug 12, 2018
1 parent 6895926 commit 408484d48637fed9e59fe7af27c98dc31d524f47
@@ -8,12 +8,19 @@ SET (wmts_SRCS
qgswmtsgetcapabilities.cpp
qgswmtsgettile.cpp
qgswmtsgetfeatureinfo.cpp
qgswmtsparameters.cpp
)

SET (wmts_MOC_HDRS
qgswmtsparameters.h
)

########################################################
# Build

ADD_LIBRARY (wmts MODULE ${wmts_SRCS})
QT5_WRAP_CPP(wmts_MOC_SRCS ${wmts_MOC_HDRS})

ADD_LIBRARY (wmts MODULE ${wmts_SRCS} ${wmts_MOC_SRCS} ${wmts_MOC_HDRS})


INCLUDE_DIRECTORIES(SYSTEM
@@ -58,13 +58,13 @@ namespace QgsWmts
{
Q_UNUSED( project );

QgsServerRequest::Parameters params = request.parameters();
QString versionString = params.value( QStringLiteral( "VERSION" ) );
const QgsWmtsParameters params( QUrlQuery( request.url() ) );

// Set the default version
QString versionString = params.version();
if ( versionString.isEmpty() )
{
versionString = version();
versionString = version(); // defined in qgswfsutils.h
}

// Get the request
@@ -320,12 +320,12 @@ namespace QgsWmts
*/
QDomElement contentsElement = doc.createElement( QStringLiteral( "Contents" )/*wmts:Contents*/ );

QList< tileMatrixSet > tmsList = getTileMatrixSetList( project );
QList< tileMatrixSetDef > tmsList = getTileMatrixSetList( project );
if ( !tmsList.isEmpty() )
{
QList< layerDef > wmtsLayers;
QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( GEO_EPSG_CRS_AUTHID );
QList<tileMatrixSet>::iterator tmsIt = tmsList.begin();
QList<tileMatrixSetDef>::iterator tmsIt = tmsList.begin();

QStringList nonIdentifiableLayers = project->nonIdentifiableLayers();

@@ -547,7 +547,7 @@ namespace QgsWmts
tmsIt = tmsList.begin();
for ( ; tmsIt != tmsList.end(); ++tmsIt )
{
tileMatrixSet &tms = *tmsIt;
tileMatrixSetDef &tms = *tmsIt;
if ( tms.ref == QLatin1String( "EPSG:4326" ) )
continue;

@@ -609,7 +609,7 @@ namespace QgsWmts
tmsIt = tmsList.begin();
for ( ; tmsIt != tmsList.end(); ++tmsIt )
{
tileMatrixSet &tms = *tmsIt;
tileMatrixSetDef &tms = *tmsIt;
if ( tms.ref != QLatin1String( "EPSG:4326" ) )
{
QgsRectangle rect;
@@ -636,10 +636,10 @@ namespace QgsWmts
//wmts:TileMatrixSetLimits
QDomElement tmsLimitsElement = doc.createElement( QStringLiteral( "TileMatrixSetLimits" )/*wmts:TileMatrixSetLimits*/ );
int tmIdx = 0;
QList<tileMatrix>::iterator tmIt = tms.tileMatrixList.begin();
QList<tileMatrixDef>::iterator tmIt = tms.tileMatrixList.begin();
for ( ; tmIt != tms.tileMatrixList.end(); ++tmIt )
{
tileMatrix &tm = *tmIt;
tileMatrixDef &tm = *tmIt;

QDomElement tmLimitsElement = doc.createElement( QStringLiteral( "TileMatrixLimits" )/*wmts:TileMatrixLimits*/ );

@@ -683,7 +683,7 @@ namespace QgsWmts
tmsIt = tmsList.begin();
for ( ; tmsIt != tmsList.end(); ++tmsIt )
{
tileMatrixSet &tms = *tmsIt;
tileMatrixSetDef &tms = *tmsIt;

//wmts:TileMatrixSet
QDomElement tmsElement = doc.createElement( QStringLiteral( "TileMatrixSet" )/*wmts:TileMatrixSet*/ );
@@ -700,10 +700,10 @@ namespace QgsWmts

//wmts:TileMatrix
int tmIdx = 0;
QList<tileMatrix>::iterator tmIt = tms.tileMatrixList.begin();
QList<tileMatrixDef>::iterator tmIt = tms.tileMatrixList.begin();
for ( ; tmIt != tms.tileMatrixList.end(); ++tmIt )
{
tileMatrix &tm = *tmIt;
tileMatrixDef &tm = *tmIt;

QDomElement tmElement = doc.createElement( QStringLiteral( "TileMatrix" )/*wmts:TileMatrix*/ );

@@ -1,5 +1,5 @@
/***************************************************************************
qgswmsgetfeatureinfo.cpp
qgswmtsgetfeatureinfo.cpp
-------------------------
begin : July 23 , 2017
copyright : (C) 2018 by René-Luc D'Hont
@@ -15,6 +15,7 @@
* *
***************************************************************************/
#include "qgswmtsutils.h"
#include "qgswmtsparameters.h"
#include "qgswmtsgetfeatureinfo.h"

#include <QImage>
@@ -27,17 +28,16 @@ namespace QgsWmts
QgsServerResponse &response )
{
Q_UNUSED( version );

QgsServerRequest::Parameters params = request.parameters();
const QgsWmtsParameters params( QUrlQuery( request.url() ) );

// WMS query
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetFeatureInfo" ), params, project, serverIface );

// GetFeatureInfo query items
query.addQueryItem( QStringLiteral( "query_layers" ), query.queryItemValue( QStringLiteral( "layers" ) ) );
query.addQueryItem( QStringLiteral( "i" ), params.value( QStringLiteral( "I" ) ) );
query.addQueryItem( QStringLiteral( "j" ), params.value( QStringLiteral( "J" ) ) );
query.addQueryItem( QStringLiteral( "info_format" ), params.value( QStringLiteral( "INFOFORMAT" ) ) );
query.addQueryItem( QStringLiteral( "query_layers" ), params.layer() );
query.addQueryItem( QgsWmtsParameter::name( QgsWmtsParameter::I ), params.i() );
query.addQueryItem( QgsWmtsParameter::name( QgsWmtsParameter::J ), params.j() );
query.addQueryItem( QStringLiteral( "info_format" ), params.infoFormatAsString() );

QgsServerParameters wmsParams( query );
QgsServerRequest wmsRequest( "?" + query.query( QUrl::FullyDecoded ) );
@@ -1,5 +1,5 @@
/***************************************************************************
qgswmsgetfeatureinfo.h
qgswmtsgetfeatureinfo.h
-------------------------
begin : July 23 , 2017
copyright : (C) 2018 by René-Luc D'Hont
@@ -15,6 +15,7 @@
* *
***************************************************************************/
#include "qgswmtsutils.h"
#include "qgswmtsparameters.h"
#include "qgswmtsgettile.h"

#include <QImage>
@@ -27,7 +28,8 @@ namespace QgsWmts
QgsServerResponse &response )
{
Q_UNUSED( version );
QgsServerRequest::Parameters params = request.parameters();
//QgsServerRequest::Parameters params = request.parameters();
const QgsWmtsParameters params( QUrlQuery( request.url() ) );

// WMS query
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetMap" ), params, project, serverIface );
@@ -44,16 +46,19 @@ namespace QgsWmts
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cache )
{
QString contentType = params.value( QStringLiteral( "FORMAT" ) );
QgsWmtsParameters::Format f = params.format();
QString contentType;
QString saveFormat;
std::unique_ptr<QImage> image;
if ( contentType == QLatin1String( "image/jpeg" ) )
if ( f == QgsWmtsParameters::Format::JPG )
{
contentType = QStringLiteral( "image/jpeg" );
saveFormat = QStringLiteral( "JPEG" );
image = qgis::make_unique<QImage>( 256, 256, QImage::Format_RGB32 );
}
else
{
contentType = QStringLiteral( "image/png" );
saveFormat = QStringLiteral( "PNG" );
image = qgis::make_unique<QImage>( 256, 256, QImage::Format_ARGB32_Premultiplied );
}

0 comments on commit 408484d

Please sign in to comment.
You can’t perform that action at this time.