Skip to content

Commit 408484d

Browse files
committed
[Server][Feature][needs-docs] Add QgsWmtsParameters to WMTS service
1 parent 6895926 commit 408484d

10 files changed

+652
-132
lines changed

src/server/services/wmts/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ SET (wmts_SRCS
88
qgswmtsgetcapabilities.cpp
99
qgswmtsgettile.cpp
1010
qgswmtsgetfeatureinfo.cpp
11+
qgswmtsparameters.cpp
12+
)
13+
14+
SET (wmts_MOC_HDRS
15+
qgswmtsparameters.h
1116
)
1217

1318
########################################################
1419
# Build
1520

16-
ADD_LIBRARY (wmts MODULE ${wmts_SRCS})
21+
QT5_WRAP_CPP(wmts_MOC_SRCS ${wmts_MOC_HDRS})
22+
23+
ADD_LIBRARY (wmts MODULE ${wmts_SRCS} ${wmts_MOC_SRCS} ${wmts_MOC_HDRS})
1724

1825

1926
INCLUDE_DIRECTORIES(SYSTEM

src/server/services/wmts/qgswmts.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ namespace QgsWmts
5858
{
5959
Q_UNUSED( project );
6060

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

6463
// Set the default version
64+
QString versionString = params.version();
6565
if ( versionString.isEmpty() )
6666
{
67-
versionString = version();
67+
versionString = version(); // defined in qgswfsutils.h
6868
}
6969

7070
// Get the request

src/server/services/wmts/qgswmtsgetcapabilities.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ namespace QgsWmts
320320
*/
321321
QDomElement contentsElement = doc.createElement( QStringLiteral( "Contents" )/*wmts:Contents*/ );
322322

323-
QList< tileMatrixSet > tmsList = getTileMatrixSetList( project );
323+
QList< tileMatrixSetDef > tmsList = getTileMatrixSetList( project );
324324
if ( !tmsList.isEmpty() )
325325
{
326326
QList< layerDef > wmtsLayers;
327327
QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( GEO_EPSG_CRS_AUTHID );
328-
QList<tileMatrixSet>::iterator tmsIt = tmsList.begin();
328+
QList<tileMatrixSetDef>::iterator tmsIt = tmsList.begin();
329329

330330
QStringList nonIdentifiableLayers = project->nonIdentifiableLayers();
331331

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

@@ -609,7 +609,7 @@ namespace QgsWmts
609609
tmsIt = tmsList.begin();
610610
for ( ; tmsIt != tmsList.end(); ++tmsIt )
611611
{
612-
tileMatrixSet &tms = *tmsIt;
612+
tileMatrixSetDef &tms = *tmsIt;
613613
if ( tms.ref != QLatin1String( "EPSG:4326" ) )
614614
{
615615
QgsRectangle rect;
@@ -636,10 +636,10 @@ namespace QgsWmts
636636
//wmts:TileMatrixSetLimits
637637
QDomElement tmsLimitsElement = doc.createElement( QStringLiteral( "TileMatrixSetLimits" )/*wmts:TileMatrixSetLimits*/ );
638638
int tmIdx = 0;
639-
QList<tileMatrix>::iterator tmIt = tms.tileMatrixList.begin();
639+
QList<tileMatrixDef>::iterator tmIt = tms.tileMatrixList.begin();
640640
for ( ; tmIt != tms.tileMatrixList.end(); ++tmIt )
641641
{
642-
tileMatrix &tm = *tmIt;
642+
tileMatrixDef &tm = *tmIt;
643643

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

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

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

701701
//wmts:TileMatrix
702702
int tmIdx = 0;
703-
QList<tileMatrix>::iterator tmIt = tms.tileMatrixList.begin();
703+
QList<tileMatrixDef>::iterator tmIt = tms.tileMatrixList.begin();
704704
for ( ; tmIt != tms.tileMatrixList.end(); ++tmIt )
705705
{
706-
tileMatrix &tm = *tmIt;
706+
tileMatrixDef &tm = *tmIt;
707707

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

src/server/services/wmts/qgswmtsgetfeatureinfo.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgswmsgetfeatureinfo.cpp
2+
qgswmtsgetfeatureinfo.cpp
33
-------------------------
44
begin : July 23 , 2017
55
copyright : (C) 2018 by René-Luc D'Hont
@@ -15,6 +15,7 @@
1515
* *
1616
***************************************************************************/
1717
#include "qgswmtsutils.h"
18+
#include "qgswmtsparameters.h"
1819
#include "qgswmtsgetfeatureinfo.h"
1920

2021
#include <QImage>
@@ -27,17 +28,16 @@ namespace QgsWmts
2728
QgsServerResponse &response )
2829
{
2930
Q_UNUSED( version );
30-
31-
QgsServerRequest::Parameters params = request.parameters();
31+
const QgsWmtsParameters params( QUrlQuery( request.url() ) );
3232

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

3636
// GetFeatureInfo query items
37-
query.addQueryItem( QStringLiteral( "query_layers" ), query.queryItemValue( QStringLiteral( "layers" ) ) );
38-
query.addQueryItem( QStringLiteral( "i" ), params.value( QStringLiteral( "I" ) ) );
39-
query.addQueryItem( QStringLiteral( "j" ), params.value( QStringLiteral( "J" ) ) );
40-
query.addQueryItem( QStringLiteral( "info_format" ), params.value( QStringLiteral( "INFOFORMAT" ) ) );
37+
query.addQueryItem( QStringLiteral( "query_layers" ), params.layer() );
38+
query.addQueryItem( QgsWmtsParameter::name( QgsWmtsParameter::I ), params.i() );
39+
query.addQueryItem( QgsWmtsParameter::name( QgsWmtsParameter::J ), params.j() );
40+
query.addQueryItem( QStringLiteral( "info_format" ), params.infoFormatAsString() );
4141

4242
QgsServerParameters wmsParams( query );
4343
QgsServerRequest wmsRequest( "?" + query.query( QUrl::FullyDecoded ) );

src/server/services/wmts/qgswmtsgetfeatureinfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgswmsgetfeatureinfo.h
2+
qgswmtsgetfeatureinfo.h
33
-------------------------
44
begin : July 23 , 2017
55
copyright : (C) 2018 by René-Luc D'Hont

src/server/services/wmts/qgswmtsgettile.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* *
1616
***************************************************************************/
1717
#include "qgswmtsutils.h"
18+
#include "qgswmtsparameters.h"
1819
#include "qgswmtsgettile.h"
1920

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

3234
// WMS query
3335
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetMap" ), params, project, serverIface );
@@ -44,16 +46,19 @@ namespace QgsWmts
4446
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
4547
if ( cacheManager && cache )
4648
{
47-
QString contentType = params.value( QStringLiteral( "FORMAT" ) );
49+
QgsWmtsParameters::Format f = params.format();
50+
QString contentType;
4851
QString saveFormat;
4952
std::unique_ptr<QImage> image;
50-
if ( contentType == QLatin1String( "image/jpeg" ) )
53+
if ( f == QgsWmtsParameters::Format::JPG )
5154
{
55+
contentType = QStringLiteral( "image/jpeg" );
5256
saveFormat = QStringLiteral( "JPEG" );
5357
image = qgis::make_unique<QImage>( 256, 256, QImage::Format_RGB32 );
5458
}
5559
else
5660
{
61+
contentType = QStringLiteral( "image/png" );
5762
saveFormat = QStringLiteral( "PNG" );
5863
image = qgis::make_unique<QImage>( 256, 256, QImage::Format_ARGB32_Premultiplied );
5964
}

0 commit comments

Comments
 (0)