Skip to content

Commit cff8469

Browse files
committedAug 20, 2018
[Server][Feature][needs-docs] Update WMTS service: Add GetFeatureInfo
Support GetFeatureInfo Request in WMTS.
1 parent dc7e8e4 commit cff8469

File tree

8 files changed

+315
-181
lines changed

8 files changed

+315
-181
lines changed
 

‎src/server/services/wmts/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SET (wmts_SRCS
77
qgswmtsutils.cpp
88
qgswmtsgetcapabilities.cpp
99
qgswmtsgettile.cpp
10+
qgswmtsgetfeatureinfo.cpp
1011
)
1112

1213
########################################################

‎src/server/services/wmts/qgswmts.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgswmtsutils.h"
2020
#include "qgswmtsgetcapabilities.h"
2121
#include "qgswmtsgettile.h"
22+
#include "qgswmtsgetfeatureinfo.h"
2223

2324
#define QSTR_COMPARE( str, lit )\
2425
(str.compare( QStringLiteral( lit ), Qt::CaseInsensitive ) == 0)
@@ -82,6 +83,10 @@ namespace QgsWmts
8283
{
8384
writeGetTile( mServerIface, project, versionString, request, response );
8485
}
86+
else if ( QSTR_COMPARE( req, "GetFeatureInfo" ) )
87+
{
88+
writeGetFeatureInfo( mServerIface, project, versionString, request, response );
89+
}
8590
else
8691
{
8792
// Operation not supported

‎src/server/services/wmts/qgswmtsgetcapabilities.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ namespace QgsWmts
302302
operationsMetadataElement.appendChild( getTileElement );
303303

304304
//ows:Operation element with name GetFeatureInfo
305-
/*QDomElement getFeatureInfoElement = getCapabilitiesElement.cloneNode().toElement();//this is the same as 'GetCapabilities'
305+
QDomElement getFeatureInfoElement = getCapabilitiesElement.cloneNode().toElement();//this is the same as 'GetCapabilities'
306306
getFeatureInfoElement.setAttribute( QStringLiteral( "name" ), QStringLiteral( "GetFeatureInfo" ) );
307-
operationsMetadataElement.appendChild( getFeatureInfoElement );*/
307+
operationsMetadataElement.appendChild( getFeatureInfoElement );
308308

309309
// End
310310
return operationsMetadataElement;
@@ -327,6 +327,8 @@ namespace QgsWmts
327327
QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( GEO_EPSG_CRS_AUTHID );
328328
QList<tileMatrixSet>::iterator tmsIt = tmsList.begin();
329329

330+
QStringList nonIdentifiableLayers = project->nonIdentifiableLayers();
331+
330332
// WMTS Project configuration
331333
bool wmtsProject = project->readBoolEntry( QStringLiteral( "WMTSLayers" ), QStringLiteral( "Project" ) );
332334

@@ -371,6 +373,10 @@ namespace QgsWmts
371373
if ( wmtsJpegProject )
372374
pLayer.formats << QStringLiteral( "image/jpeg" );
373375

376+
// Project is not queryable in WMS
377+
//pLayer.queryable = ( nonIdentifiableLayers.count() != project->count() );
378+
pLayer.queryable = false;
379+
374380
wmtsLayers.append( pLayer );
375381
}
376382

@@ -401,11 +407,12 @@ namespace QgsWmts
401407

402408
pLayer.abstract = treeGroup->customProperty( QStringLiteral( "wmsAbstract" ) ).toString();
403409

410+
QgsRectangle wgs84BoundingRect;
411+
bool queryable = false;
404412
for ( QgsLayerTreeLayer *layer : treeGroup->findLayers() )
405413
{
406414
QgsMapLayer *l = layer->layer();
407415
//transform the layer native CRS into WGS84
408-
QgsRectangle wgs84BoundingRect;
409416
QgsCoordinateReferenceSystem layerCrs = l->crs();
410417
Q_NOWARN_DEPRECATED_PUSH
411418
QgsCoordinateTransform exGeoTransform( layerCrs, wgs84 );
@@ -418,7 +425,13 @@ namespace QgsWmts
418425
{
419426
wgs84BoundingRect.combineExtentWith( QgsRectangle( -180, -90, 180, 90 ) );
420427
}
428+
if ( !queryable && !nonIdentifiableLayers.contains( l->id() ) )
429+
{
430+
queryable = true;
431+
}
421432
}
433+
pLayer.wgs84BoundingRect = wgs84BoundingRect;
434+
pLayer.queryable = queryable;
422435

423436
// Formats
424437
if ( wmtsPngGroupNameList.contains( gName ) )
@@ -477,9 +490,19 @@ namespace QgsWmts
477490
if ( wmtsJpegLayerIdList.contains( lId ) )
478491
pLayer.formats << QStringLiteral( "image/jpeg" );
479492

493+
pLayer.queryable = ( !nonIdentifiableLayers.contains( l->id() ) );
494+
480495
wmtsLayers.append( pLayer );
481496
}
482497

498+
// Append InfoFormat helper
499+
std::function < void ( QDomElement &, const QString & ) > appendInfoFormat = [&doc]( QDomElement & elem, const QString & format )
500+
{
501+
QDomElement formatElem = doc.createElement( QStringLiteral( "InfoFormat" )/*wmts:InfoFormat*/ );
502+
formatElem.appendChild( doc.createTextNode( format ) );
503+
elem.appendChild( formatElem );
504+
};
505+
483506
Q_FOREACH ( layerDef wmtsLayer, wmtsLayers )
484507
{
485508
if ( wmtsLayer.id.isEmpty() )
@@ -542,6 +565,15 @@ namespace QgsWmts
542565
layerElem.appendChild( layerFormatElem );
543566
}
544567

568+
if ( wmtsLayer.queryable )
569+
{
570+
appendInfoFormat( layerElem, QStringLiteral( "text/plain" ) );
571+
appendInfoFormat( layerElem, QStringLiteral( "text/html" ) );
572+
appendInfoFormat( layerElem, QStringLiteral( "text/xml" ) );
573+
appendInfoFormat( layerElem, QStringLiteral( "application/vnd.ogc.gml" ) );
574+
appendInfoFormat( layerElem, QStringLiteral( "application/vnd.ogc.gml/3.1.1" ) );
575+
}
576+
545577
tmsIt = tmsList.begin();
546578
for ( ; tmsIt != tmsList.end(); ++tmsIt )
547579
{
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/***************************************************************************
2+
qgswmsgetfeatureinfo.cpp
3+
-------------------------
4+
begin : July 23 , 2017
5+
copyright : (C) 2018 by René-Luc D'Hont
6+
email : rldhont at 3liz dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
#include "qgswmtsutils.h"
18+
#include "qgswmtsgetfeatureinfo.h"
19+
20+
#include <QImage>
21+
22+
namespace QgsWmts
23+
{
24+
25+
void writeGetFeatureInfo( QgsServerInterface *serverIface, const QgsProject *project,
26+
const QString &version, const QgsServerRequest &request,
27+
QgsServerResponse &response )
28+
{
29+
Q_UNUSED( version );
30+
31+
QgsServerRequest::Parameters params = request.parameters();
32+
33+
// WMS query
34+
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetFeatureInfo" ), params, project, serverIface );
35+
36+
// 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" ) ) );
41+
42+
QgsServerParameters wmsParams( query );
43+
QgsServerRequest wmsRequest( "?" + query.query( QUrl::FullyDecoded ) );
44+
QgsService *service = serverIface->serviceRegistry()->getService( wmsParams.service(), wmsParams.version() );
45+
service->executeRequest( wmsRequest, response, project );
46+
}
47+
48+
} // namespace QgsWmts
49+
50+
51+
52+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/***************************************************************************
2+
qgswmsgetfeatureinfo.h
3+
-------------------------
4+
begin : July 23 , 2017
5+
copyright : (C) 2018 by René-Luc D'Hont
6+
email : rldhont at 3liz dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
namespace QgsWmts
19+
{
20+
21+
/**
22+
* Output GetFeatureInfo response
23+
*/
24+
void writeGetFeatureInfo( QgsServerInterface *serverIface, const QgsProject *project,
25+
const QString &version, const QgsServerRequest &request,
26+
QgsServerResponse &response );
27+
28+
} // namespace QgsWmts

‎src/server/services/wmts/qgswmtsgettile.cpp

Lines changed: 2 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -30,184 +30,8 @@ namespace QgsWmts
3030

3131
QgsServerRequest::Parameters params = request.parameters();
3232

33-
//defining Layer
34-
QString layer;
35-
//read Layer
36-
QMap<QString, QString>::const_iterator layer_it = params.constFind( QStringLiteral( "LAYER" ) );
37-
if ( layer_it != params.constEnd() )
38-
{
39-
layer = layer_it.value();
40-
}
41-
else
42-
{
43-
throw QgsRequestNotWellFormedException( QStringLiteral( "Layer is mandatory" ) );
44-
}
45-
46-
//defining Format
47-
QString format;
48-
//read Format
49-
QMap<QString, QString>::const_iterator format_it = params.constFind( QStringLiteral( "FORMAT" ) );
50-
if ( format_it != params.constEnd() )
51-
{
52-
format = format_it.value();
53-
}
54-
else
55-
{
56-
throw QgsRequestNotWellFormedException( QStringLiteral( "Format is mandatory" ) );
57-
}
58-
59-
QList< tileMatrixSet > tmsList = getTileMatrixSetList( project );
60-
if ( tmsList.isEmpty() )
61-
{
62-
throw QgsServiceException( QStringLiteral( "UnknownError" ),
63-
QStringLiteral( "Service not well configured" ) );
64-
}
65-
66-
//defining TileMatrixSet ref
67-
QString tms_ref;
68-
//read TileMatrixSet
69-
QMap<QString, QString>::const_iterator tms_ref_it = params.constFind( QStringLiteral( "TILEMATRIXSET" ) );
70-
if ( tms_ref_it != params.constEnd() )
71-
{
72-
tms_ref = tms_ref_it.value();
73-
}
74-
else
75-
{
76-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrixSet is mandatory" ) );
77-
}
78-
79-
bool tms_ref_valid = false;
80-
tileMatrixSet tms;
81-
QList<tileMatrixSet>::iterator tmsIt = tmsList.begin();
82-
for ( ; tmsIt != tmsList.end(); ++tmsIt )
83-
{
84-
tileMatrixSet &tmsi = *tmsIt;
85-
if ( tmsi.ref == tms_ref )
86-
{
87-
tms_ref_valid = true;
88-
tms = tmsi;
89-
break;
90-
}
91-
}
92-
if ( !tms_ref_valid )
93-
{
94-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrixSet is unknown" ) );
95-
}
96-
97-
bool conversionSuccess = false;
98-
99-
//difining TileMatrix idx
100-
int tm_idx;
101-
//read TileMatrix
102-
QMap<QString, QString>::const_iterator tm_ref_it = params.constFind( QStringLiteral( "TILEMATRIX" ) );
103-
if ( tm_ref_it != params.constEnd() )
104-
{
105-
QString tm_ref = tm_ref_it.value();
106-
tm_idx = tm_ref.toInt( &conversionSuccess );
107-
if ( !conversionSuccess )
108-
{
109-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrix is unknown" ) );
110-
}
111-
}
112-
else
113-
{
114-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrix is mandatory" ) );
115-
}
116-
if ( tms.tileMatrixList.count() < tm_idx )
117-
{
118-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrix is unknown" ) );
119-
}
120-
tileMatrix tm = tms.tileMatrixList.at( tm_idx );
121-
122-
//defining TileRow
123-
int tr;
124-
//read TileRow
125-
QMap<QString, QString>::const_iterator tr_it = params.constFind( QStringLiteral( "TILEROW" ) );
126-
if ( tr_it != params.constEnd() )
127-
{
128-
QString tr_str = tr_it.value();
129-
conversionSuccess = false;
130-
tr = tr_str.toInt( &conversionSuccess );
131-
if ( !conversionSuccess )
132-
{
133-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileRow is unknown" ) );
134-
}
135-
}
136-
else
137-
{
138-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileRow is mandatory" ) );
139-
}
140-
if ( tm.row <= tr )
141-
{
142-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileRow is unknown" ) );
143-
}
144-
145-
//defining TileCol
146-
int tc;
147-
//read TileCol
148-
QMap<QString, QString>::const_iterator tc_it = params.constFind( QStringLiteral( "TILECOL" ) );
149-
if ( tc_it != params.constEnd() )
150-
{
151-
QString tc_str = tc_it.value();
152-
conversionSuccess = false;
153-
tc = tc_str.toInt( &conversionSuccess );
154-
if ( !conversionSuccess )
155-
{
156-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileCol is unknown" ) );
157-
}
158-
}
159-
else
160-
{
161-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileCol is mandatory" ) );
162-
}
163-
if ( tm.col <= tc )
164-
{
165-
throw QgsRequestNotWellFormedException( QStringLiteral( "TileCol is unknown" ) );
166-
}
167-
168-
int tileWidth = 256;
169-
int tileHeight = 256;
170-
double res = tm.resolution;
171-
double minx = tm.left + tc * ( tileWidth * res );
172-
double miny = tm.top - ( tr + 1 ) * ( tileHeight * res );
173-
double maxx = tm.left + ( tc + 1 ) * ( tileWidth * res );
174-
double maxy = tm.top - tr * ( tileHeight * res );
175-
QString bbox;
176-
if ( tms.ref == "EPSG:4326" )
177-
{
178-
bbox = qgsDoubleToString( miny, 6 ) + ',' +
179-
qgsDoubleToString( minx, 6 ) + ',' +
180-
qgsDoubleToString( maxy, 6 ) + ',' +
181-
qgsDoubleToString( maxx, 6 );
182-
}
183-
else
184-
{
185-
bbox = qgsDoubleToString( minx, 6 ) + ',' +
186-
qgsDoubleToString( miny, 6 ) + ',' +
187-
qgsDoubleToString( maxx, 6 ) + ',' +
188-
qgsDoubleToString( maxy, 6 );
189-
}
190-
191-
QUrlQuery query;
192-
if ( !params.value( QStringLiteral( "MAP" ) ).isEmpty() )
193-
{
194-
query.addQueryItem( QStringLiteral( "map" ), params.value( QStringLiteral( "MAP" ) ) );
195-
}
196-
query.addQueryItem( QStringLiteral( "service" ), QStringLiteral( "WMS" ) );
197-
query.addQueryItem( QStringLiteral( "version" ), QStringLiteral( "1.3.0" ) );
198-
query.addQueryItem( QStringLiteral( "request" ), QStringLiteral( "GetMap" ) );
199-
query.addQueryItem( QStringLiteral( "layers" ), layer );
200-
query.addQueryItem( QStringLiteral( "styles" ), QString() );
201-
query.addQueryItem( QStringLiteral( "crs" ), tms.ref );
202-
query.addQueryItem( QStringLiteral( "bbox" ), bbox );
203-
query.addQueryItem( QStringLiteral( "width" ), QStringLiteral( "256" ) );
204-
query.addQueryItem( QStringLiteral( "height" ), QStringLiteral( "256" ) );
205-
query.addQueryItem( QStringLiteral( "format" ), format );
206-
if ( format.startsWith( QStringLiteral( "image/png" ) ) )
207-
{
208-
query.addQueryItem( QStringLiteral( "transparent" ), QStringLiteral( "true" ) );
209-
}
210-
query.addQueryItem( QStringLiteral( "dpi" ), QStringLiteral( "96" ) );
33+
// WMS query
34+
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetMap" ), params, project );
21135

21236
QgsServerParameters wmsParams( query );
21337
QgsServerRequest wmsRequest( "?" + query.query( QUrl::FullyDecoded ) );

‎src/server/services/wmts/qgswmtsutils.cpp

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,191 @@ namespace QgsWmts
264264
return tmsList;
265265
}
266266

267+
QUrlQuery translateWmtsParamToWmsQueryItem( const QString &request, const QgsServerRequest::Parameters &params, const QgsProject *project )
268+
{
269+
270+
//defining Layer
271+
QString layer;
272+
//read Layer
273+
QMap<QString, QString>::const_iterator layer_it = params.constFind( QStringLiteral( "LAYER" ) );
274+
if ( layer_it != params.constEnd() )
275+
{
276+
layer = layer_it.value();
277+
}
278+
else
279+
{
280+
throw QgsRequestNotWellFormedException( QStringLiteral( "Layer is mandatory" ) );
281+
}
282+
283+
//defining Format
284+
QString format;
285+
//read Format
286+
QMap<QString, QString>::const_iterator format_it = params.constFind( QStringLiteral( "FORMAT" ) );
287+
if ( format_it != params.constEnd() )
288+
{
289+
format = format_it.value();
290+
}
291+
else
292+
{
293+
throw QgsRequestNotWellFormedException( QStringLiteral( "Format is mandatory" ) );
294+
}
295+
296+
QList< tileMatrixSet > tmsList = getTileMatrixSetList( project );
297+
if ( tmsList.isEmpty() )
298+
{
299+
throw QgsServiceException( QStringLiteral( "UnknownError" ),
300+
QStringLiteral( "Service not well configured" ) );
301+
}
302+
303+
//defining TileMatrixSet ref
304+
QString tms_ref;
305+
//read TileMatrixSet
306+
QMap<QString, QString>::const_iterator tms_ref_it = params.constFind( QStringLiteral( "TILEMATRIXSET" ) );
307+
if ( tms_ref_it != params.constEnd() )
308+
{
309+
tms_ref = tms_ref_it.value();
310+
}
311+
else
312+
{
313+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrixSet is mandatory" ) );
314+
}
315+
316+
bool tms_ref_valid = false;
317+
tileMatrixSet tms;
318+
QList<tileMatrixSet>::iterator tmsIt = tmsList.begin();
319+
for ( ; tmsIt != tmsList.end(); ++tmsIt )
320+
{
321+
tileMatrixSet &tmsi = *tmsIt;
322+
if ( tmsi.ref == tms_ref )
323+
{
324+
tms_ref_valid = true;
325+
tms = tmsi;
326+
break;
327+
}
328+
}
329+
if ( !tms_ref_valid )
330+
{
331+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrixSet is unknown" ) );
332+
}
333+
334+
bool conversionSuccess = false;
335+
336+
//difining TileMatrix idx
337+
int tm_idx;
338+
//read TileMatrix
339+
QMap<QString, QString>::const_iterator tm_ref_it = params.constFind( QStringLiteral( "TILEMATRIX" ) );
340+
if ( tm_ref_it != params.constEnd() )
341+
{
342+
QString tm_ref = tm_ref_it.value();
343+
tm_idx = tm_ref.toInt( &conversionSuccess );
344+
if ( !conversionSuccess )
345+
{
346+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrix is unknown" ) );
347+
}
348+
}
349+
else
350+
{
351+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrix is mandatory" ) );
352+
}
353+
if ( tms.tileMatrixList.count() < tm_idx )
354+
{
355+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileMatrix is unknown" ) );
356+
}
357+
tileMatrix tm = tms.tileMatrixList.at( tm_idx );
358+
359+
//defining TileRow
360+
int tr;
361+
//read TileRow
362+
QMap<QString, QString>::const_iterator tr_it = params.constFind( QStringLiteral( "TILEROW" ) );
363+
if ( tr_it != params.constEnd() )
364+
{
365+
QString tr_str = tr_it.value();
366+
conversionSuccess = false;
367+
tr = tr_str.toInt( &conversionSuccess );
368+
if ( !conversionSuccess )
369+
{
370+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileRow is unknown" ) );
371+
}
372+
}
373+
else
374+
{
375+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileRow is mandatory" ) );
376+
}
377+
if ( tm.row <= tr )
378+
{
379+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileRow is unknown" ) );
380+
}
381+
382+
//defining TileCol
383+
int tc;
384+
//read TileCol
385+
QMap<QString, QString>::const_iterator tc_it = params.constFind( QStringLiteral( "TILECOL" ) );
386+
if ( tc_it != params.constEnd() )
387+
{
388+
QString tc_str = tc_it.value();
389+
conversionSuccess = false;
390+
tc = tc_str.toInt( &conversionSuccess );
391+
if ( !conversionSuccess )
392+
{
393+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileCol is unknown" ) );
394+
}
395+
}
396+
else
397+
{
398+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileCol is mandatory" ) );
399+
}
400+
if ( tm.col <= tc )
401+
{
402+
throw QgsRequestNotWellFormedException( QStringLiteral( "TileCol is unknown" ) );
403+
}
404+
405+
int tileWidth = 256;
406+
int tileHeight = 256;
407+
double res = tm.resolution;
408+
double minx = tm.left + tc * ( tileWidth * res );
409+
double miny = tm.top - ( tr + 1 ) * ( tileHeight * res );
410+
double maxx = tm.left + ( tc + 1 ) * ( tileWidth * res );
411+
double maxy = tm.top - tr * ( tileHeight * res );
412+
QString bbox;
413+
if ( tms.ref == "EPSG:4326" )
414+
{
415+
bbox = qgsDoubleToString( miny, 6 ) + ',' +
416+
qgsDoubleToString( minx, 6 ) + ',' +
417+
qgsDoubleToString( maxy, 6 ) + ',' +
418+
qgsDoubleToString( maxx, 6 );
419+
}
420+
else
421+
{
422+
bbox = qgsDoubleToString( minx, 6 ) + ',' +
423+
qgsDoubleToString( miny, 6 ) + ',' +
424+
qgsDoubleToString( maxx, 6 ) + ',' +
425+
qgsDoubleToString( maxy, 6 );
426+
}
427+
428+
QUrlQuery query;
429+
if ( !params.value( QStringLiteral( "MAP" ) ).isEmpty() )
430+
{
431+
query.addQueryItem( QStringLiteral( "map" ), params.value( QStringLiteral( "MAP" ) ) );
432+
}
433+
query.addQueryItem( QStringLiteral( "service" ), QStringLiteral( "WMS" ) );
434+
query.addQueryItem( QStringLiteral( "version" ), QStringLiteral( "1.3.0" ) );
435+
query.addQueryItem( QStringLiteral( "request" ), request );
436+
query.addQueryItem( QStringLiteral( "layers" ), layer );
437+
query.addQueryItem( QStringLiteral( "styles" ), QString() );
438+
query.addQueryItem( QStringLiteral( "crs" ), tms.ref );
439+
query.addQueryItem( QStringLiteral( "bbox" ), bbox );
440+
query.addQueryItem( QStringLiteral( "width" ), QStringLiteral( "256" ) );
441+
query.addQueryItem( QStringLiteral( "height" ), QStringLiteral( "256" ) );
442+
query.addQueryItem( QStringLiteral( "format" ), format );
443+
if ( format.startsWith( QStringLiteral( "image/png" ) ) )
444+
{
445+
query.addQueryItem( QStringLiteral( "transparent" ), QStringLiteral( "true" ) );
446+
}
447+
query.addQueryItem( QStringLiteral( "dpi" ), QStringLiteral( "96" ) );
448+
449+
return query;
450+
}
451+
267452
} // namespace QgsWmts
268453

269454

‎src/server/services/wmts/qgswmtsutils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ namespace QgsWmts
8181
QgsRectangle wgs84BoundingRect;
8282

8383
QStringList formats;
84+
85+
bool queryable;
8486
};
8587

8688
/**
@@ -107,6 +109,11 @@ namespace QgsWmts
107109
tileMatrixSet getTileMatrixSet( tileMatrixInfo tmi );
108110
QList< tileMatrixSet > getTileMatrixSetList( const QgsProject *project );
109111

112+
/**
113+
* Translate WMTS parameters to WMS query item
114+
*/
115+
QUrlQuery translateWmtsParamToWmsQueryItem( const QString &request, const QgsServerRequest::Parameters &params, const QgsProject *project );
116+
110117
} // namespace QgsWmts
111118

112119
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.