Skip to content

Commit 6b8d04b

Browse files
committed
[Server] Various code cleaning for server cache manager and WMTS service
1 parent b82c30e commit 6b8d04b

11 files changed

+45
-47
lines changed

python/server/auto_generated/qgsservercachemanager.sip.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212

1313

14-
15-
1614
class QgsServerCacheManager
1715
{
1816
%Docstring

python/server/auto_generated/qgsserverprojectutils.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ Returns the WMTS service url defined in a QGIS project.
422422
:param project: the QGIS project
423423

424424
:return: url if defined in project, an empty string otherwise.
425+
426+
.. versionadded:: 3.4
425427
%End
426428
};
427429

src/server/qgsservercachefilter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* *
1818
***************************************************************************/
1919

20-
#ifndef QGSSERVERCACHEPLUGIN_H
21-
#define QGSSERVERCACHEPLUGIN_H
20+
#ifndef QGSSERVERCACHEFILTER_H
21+
#define QGSSERVERCACHEFILTER_H
2222

2323
#include <QMultiMap>
2424
#include <QDomDocument>
@@ -133,4 +133,4 @@ class SERVER_EXPORT QgsServerCacheFilter
133133
//! The registry definition
134134
typedef QMultiMap<int, QgsServerCacheFilter *> QgsServerCacheFilterMap;
135135

136-
#endif // QGSSERVERCACHEPLUGIN_H
136+
#endif // QGSSERVERCACHEFILTER_H

src/server/qgsservercachemanager.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131

3232
SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
3333

34-
class QgsServerCachePlugin;
35-
36-
3734
/**
3835
* \ingroup server
3936
* \class QgsServerCacheManager

src/server/qgsserverinterfaceimpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class QgsServerInterfaceImpl : public QgsServerInterface
6262

6363

6464
/**
65-
* Register a server cache filter
65+
* Registers a server cache filter
6666
* \param serverCache the server cache to register
6767
* \param priority the priority used to order them
6868
* \since QGIS 3.4

src/server/qgsserverprojectutils.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,10 @@ namespace QgsServerProjectUtils
350350

351351
/**
352352
* Returns the WMTS service url defined in a QGIS project.
353-
* \param project the QGIS project
354-
* \returns url if defined in project, an empty string otherwise.
355-
*/
353+
* \param project the QGIS project
354+
* \returns url if defined in project, an empty string otherwise.
355+
* \since QGIS 3.4
356+
*/
356357
SERVER_EXPORT QString wmtsServiceUrl( const QgsProject &project );
357358
};
358359

src/server/services/wmts/qgswmtsgetcapabilities.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace QgsWmts
145145
if ( !keywords.isEmpty() )
146146
{
147147
QDomElement keywordsElem = doc.createElement( QStringLiteral( "ows:Keywords" ) );
148-
for ( const QString k : keywords )
148+
for ( const QString &k : keywords )
149149
{
150150
QDomElement keywordElem = doc.createElement( QStringLiteral( "ows:Keyword" ) );
151151
QDomText keywordText = doc.createTextNode( k );
@@ -333,7 +333,7 @@ namespace QgsWmts
333333
elem.appendChild( formatElem );
334334
};
335335

336-
for ( const layerDef wmtsLayer : wmtsLayers )
336+
for ( const layerDef &wmtsLayer : wmtsLayers )
337337
{
338338
if ( wmtsLayer.id.isEmpty() )
339339
continue;
@@ -376,7 +376,7 @@ namespace QgsWmts
376376
layerElem.appendChild( wgs84BBoxElement );
377377

378378
// Other bounding boxes
379-
for ( const tileMatrixSetDef tms : tmsList )
379+
for ( const tileMatrixSetDef &tms : tmsList )
380380
{
381381
if ( tms.ref == QLatin1String( "EPSG:4326" ) )
382382
continue;
@@ -419,7 +419,7 @@ namespace QgsWmts
419419
layerStyleElem.appendChild( layerStyleTitleElem );
420420
layerElem.appendChild( layerStyleElem );
421421

422-
for ( const QString format : wmtsLayer.formats )
422+
for ( const QString &format : wmtsLayer.formats )
423423
{
424424
QDomElement layerFormatElem = doc.createElement( QStringLiteral( "Format" ) );
425425
QDomText layerFormatText = doc.createTextNode( format );
@@ -436,7 +436,7 @@ namespace QgsWmts
436436
appendInfoFormat( layerElem, QStringLiteral( "application/vnd.ogc.gml/3.1.1" ) );
437437
}
438438

439-
for ( const tileMatrixSetDef tms : tmsList )
439+
for ( const tileMatrixSetDef &tms : tmsList )
440440
{
441441
tileMatrixSetLinkDef tmsl = getLayerTileMatrixSetLink( wmtsLayer, tms, project );
442442
if ( tmsl.ref.isEmpty() || tmsl.ref != tms.ref )
@@ -499,7 +499,7 @@ namespace QgsWmts
499499
void appendTileMatrixSetElements( QDomDocument &doc, QDomElement &contentsElement,
500500
QList< tileMatrixSetDef > tmsList )
501501
{
502-
for ( const tileMatrixSetDef tms : tmsList )
502+
for ( const tileMatrixSetDef &tms : tmsList )
503503
{
504504
//wmts:TileMatrixSet
505505
QDomElement tmsElement = doc.createElement( QStringLiteral( "TileMatrixSet" )/*wmts:TileMatrixSet*/ );
@@ -516,7 +516,7 @@ namespace QgsWmts
516516

517517
//wmts:TileMatrix
518518
int tmIdx = 0;
519-
for ( const tileMatrixDef tm : tms.tileMatrixList )
519+
for ( const tileMatrixDef &tm : tms.tileMatrixList )
520520
{
521521
QDomElement tmElement = doc.createElement( QStringLiteral( "TileMatrix" )/*wmts:TileMatrix*/ );
522522

src/server/services/wmts/qgswmtsgetfeatureinfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ namespace QgsWmts
3434
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetFeatureInfo" ), params, project, serverIface );
3535

3636
// GetFeatureInfo query items
37-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::QUERY_LAYERS ), params.layer() );
38-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::I ), params.i() );
39-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::J ), params.j() );
40-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::INFO_FORMAT ), params.infoFormatAsString() );
37+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::QUERY_LAYERS ), params.layer() );
38+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::I ), params.i() );
39+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::J ), params.j() );
40+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::INFO_FORMAT ), params.infoFormatAsString() );
4141

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

src/server/services/wmts/qgswmtsparameters.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
namespace QgsWmts
2323
{
2424
//
25-
// QgsWmsParameter
25+
// QgsWmsParameterForWmts
2626
//
27-
QString QgsWmsParameter::name( const QgsWmsParameter::Name name )
27+
QString QgsWmsParameterForWmts::name( const QgsWmsParameterForWmts::Name name )
2828
{
29-
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
29+
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameterForWmts::Name>() );
3030
return metaEnum.valueToKey( name );
3131
}
3232

33-
QgsWmsParameter::Name QgsWmsParameter::name( const QString &name )
33+
QgsWmsParameterForWmts::Name QgsWmsParameterForWmts::name( const QString &name )
3434
{
35-
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
36-
return ( QgsWmsParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
35+
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameterForWmts::Name>() );
36+
return ( QgsWmsParameterForWmts::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
3737
}
3838

3939
//

src/server/services/wmts/qgswmtsparameters.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ namespace QgsWmts
3232

3333
/**
3434
* \ingroup server
35-
* \class QgsWmts::QgsWmsParameter
35+
* \class QgsWmts::QgsWmsParameterForWmts
3636
* \brief WMS parameter used by WMTS service.
3737
* \since QGIS 3.4
3838
*/
39-
class QgsWmsParameter : public QgsServerParameterDefinition
39+
class QgsWmsParameterForWmts : public QgsServerParameterDefinition
4040
{
4141
Q_GADGET
4242

@@ -64,13 +64,13 @@ namespace QgsWmts
6464
/**
6565
* Converts a parameter's name into its string representation.
6666
*/
67-
static QString name( const QgsWmsParameter::Name );
67+
static QString name( const QgsWmsParameterForWmts::Name );
6868

6969
/**
7070
* Converts a string into a parameter's name (UNKNOWN in case of an
7171
* invalid string).
7272
*/
73-
static QgsWmsParameter::Name name( const QString &name );
73+
static QgsWmsParameterForWmts::Name name( const QString &name );
7474
};
7575

7676
/**

src/server/services/wmts/qgswmtsutils.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ namespace QgsWmts
309309
QStringList wmtsPngGroupNameList = project->readListEntry( QStringLiteral( "WMTSPngLayers" ), QStringLiteral( "Group" ) );
310310
QStringList wmtsJpegGroupNameList = project->readListEntry( QStringLiteral( "WMTSJpegLayers" ), QStringLiteral( "Group" ) );
311311

312-
for ( const QString gName : wmtsGroupNameList )
312+
for ( const QString &gName : wmtsGroupNameList )
313313
{
314314
QgsLayerTreeGroup *treeGroup = treeRoot->findGroup( gName );
315315
if ( !treeGroup )
@@ -385,7 +385,7 @@ namespace QgsWmts
385385
QStringList wmtsPngLayerIdList = project->readListEntry( QStringLiteral( "WMTSPngLayers" ), QStringLiteral( "Layer" ) );
386386
QStringList wmtsJpegLayerIdList = project->readListEntry( QStringLiteral( "WMTSJpegLayers" ), QStringLiteral( "Layer" ) );
387387

388-
for ( const QString lId : wmtsLayerIdList )
388+
for ( const QString &lId : wmtsLayerIdList )
389389
{
390390
QgsMapLayer *l = project->mapLayer( lId );
391391
if ( !l )
@@ -462,7 +462,7 @@ namespace QgsWmts
462462
rect = rect.intersect( tms.extent );
463463

464464
int tmIdx = -1;
465-
for ( const tileMatrixDef tm : tms.tileMatrixList )
465+
for ( const tileMatrixDef &tm : tms.tileMatrixList )
466466
{
467467
++tmIdx;
468468

@@ -521,7 +521,7 @@ namespace QgsWmts
521521
if ( !wmtsGroupNameList.isEmpty() )
522522
{
523523
QgsLayerTreeGroup *treeRoot = project->layerTreeRoot();
524-
for ( QString gName : wmtsGroupNameList )
524+
for ( const QString &gName : wmtsGroupNameList )
525525
{
526526
QgsLayerTreeGroup *treeGroup = treeRoot->findGroup( gName );
527527
if ( !treeGroup )
@@ -541,7 +541,7 @@ namespace QgsWmts
541541
#ifdef HAVE_SERVER_PYTHON_PLUGINS
542542
QgsAccessControl *accessControl = serverIface->accessControls();
543543
#endif
544-
for ( QString lId : wmtsLayerIdList )
544+
for ( const QString &lId : wmtsLayerIdList )
545545
{
546546
QgsMapLayer *l = project->mapLayer( lId );
547547
if ( !l )
@@ -654,18 +654,18 @@ namespace QgsWmts
654654
query.addQueryItem( QgsServerParameter::name( QgsServerParameter::SERVICE ), QStringLiteral( "WMS" ) );
655655
query.addQueryItem( QgsServerParameter::name( QgsServerParameter::VERSION_SERVICE ), QStringLiteral( "1.3.0" ) );
656656
query.addQueryItem( QgsServerParameter::name( QgsServerParameter::REQUEST ), request );
657-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::LAYERS ), layer );
658-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::STYLES ), QString() );
659-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::CRS ), tms.ref );
660-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::BBOX ), bbox );
661-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::WIDTH ), QStringLiteral( "256" ) );
662-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::HEIGHT ), QStringLiteral( "256" ) );
663-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::FORMAT ), format );
657+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::LAYERS ), layer );
658+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::STYLES ), QString() );
659+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::CRS ), tms.ref );
660+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::BBOX ), bbox );
661+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::WIDTH ), QStringLiteral( "256" ) );
662+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::HEIGHT ), QStringLiteral( "256" ) );
663+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::FORMAT ), format );
664664
if ( params.format() == QgsWmtsParameters::Format::PNG )
665665
{
666-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::TRANSPARENT ), QStringLiteral( "true" ) );
666+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::TRANSPARENT ), QStringLiteral( "true" ) );
667667
}
668-
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::DPI ), QStringLiteral( "96" ) );
668+
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::DPI ), QStringLiteral( "96" ) );
669669

670670
return query;
671671
}

0 commit comments

Comments
 (0)