Skip to content
Permalink
Browse files

[Server] Various code cleaning for server cache manager and WMTS service

  • Loading branch information
rldhont committed Aug 28, 2018
1 parent b82c30e commit 6b8d04b081348c36515ed06469c5c1dcf9ccb81b
@@ -11,8 +11,6 @@





class QgsServerCacheManager
{
%Docstring
@@ -422,6 +422,8 @@ Returns the WMTS service url defined in a QGIS project.
:param project: the QGIS project

:return: url if defined in project, an empty string otherwise.

.. versionadded:: 3.4
%End
};

@@ -17,8 +17,8 @@
* *
***************************************************************************/

#ifndef QGSSERVERCACHEPLUGIN_H
#define QGSSERVERCACHEPLUGIN_H
#ifndef QGSSERVERCACHEFILTER_H
#define QGSSERVERCACHEFILTER_H

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

#endif // QGSSERVERCACHEPLUGIN_H
#endif // QGSSERVERCACHEFILTER_H
@@ -31,9 +31,6 @@

SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )

class QgsServerCachePlugin;


/**
* \ingroup server
* \class QgsServerCacheManager
@@ -62,7 +62,7 @@ class QgsServerInterfaceImpl : public QgsServerInterface


/**
* Register a server cache filter
* Registers a server cache filter
* \param serverCache the server cache to register
* \param priority the priority used to order them
* \since QGIS 3.4
@@ -350,9 +350,10 @@ namespace QgsServerProjectUtils

/**
* Returns the WMTS service url defined in a QGIS project.
* \param project the QGIS project
* \returns url if defined in project, an empty string otherwise.
*/
* \param project the QGIS project
* \returns url if defined in project, an empty string otherwise.
* \since QGIS 3.4
*/
SERVER_EXPORT QString wmtsServiceUrl( const QgsProject &project );
};

@@ -145,7 +145,7 @@ namespace QgsWmts
if ( !keywords.isEmpty() )
{
QDomElement keywordsElem = doc.createElement( QStringLiteral( "ows:Keywords" ) );
for ( const QString k : keywords )
for ( const QString &k : keywords )
{
QDomElement keywordElem = doc.createElement( QStringLiteral( "ows:Keyword" ) );
QDomText keywordText = doc.createTextNode( k );
@@ -333,7 +333,7 @@ namespace QgsWmts
elem.appendChild( formatElem );
};

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

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

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

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

//wmts:TileMatrix
int tmIdx = 0;
for ( const tileMatrixDef tm : tms.tileMatrixList )
for ( const tileMatrixDef &tm : tms.tileMatrixList )
{
QDomElement tmElement = doc.createElement( QStringLiteral( "TileMatrix" )/*wmts:TileMatrix*/ );

@@ -34,10 +34,10 @@ namespace QgsWmts
QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetFeatureInfo" ), params, project, serverIface );

// GetFeatureInfo query items
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::QUERY_LAYERS ), params.layer() );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::I ), params.i() );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::J ), params.j() );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::INFO_FORMAT ), params.infoFormatAsString() );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::QUERY_LAYERS ), params.layer() );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::I ), params.i() );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::J ), params.j() );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::INFO_FORMAT ), params.infoFormatAsString() );

QgsServerParameters wmsParams( query );
QgsServerRequest wmsRequest( "?" + query.query( QUrl::FullyDecoded ) );
@@ -22,18 +22,18 @@
namespace QgsWmts
{
//
// QgsWmsParameter
// QgsWmsParameterForWmts
//
QString QgsWmsParameter::name( const QgsWmsParameter::Name name )
QString QgsWmsParameterForWmts::name( const QgsWmsParameterForWmts::Name name )
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameterForWmts::Name>() );
return metaEnum.valueToKey( name );
}

QgsWmsParameter::Name QgsWmsParameter::name( const QString &name )
QgsWmsParameterForWmts::Name QgsWmsParameterForWmts::name( const QString &name )
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
return ( QgsWmsParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameterForWmts::Name>() );
return ( QgsWmsParameterForWmts::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
}

//
@@ -32,11 +32,11 @@ namespace QgsWmts

/**
* \ingroup server
* \class QgsWmts::QgsWmsParameter
* \class QgsWmts::QgsWmsParameterForWmts
* \brief WMS parameter used by WMTS service.
* \since QGIS 3.4
*/
class QgsWmsParameter : public QgsServerParameterDefinition
class QgsWmsParameterForWmts : public QgsServerParameterDefinition
{
Q_GADGET

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

/**
* Converts a string into a parameter's name (UNKNOWN in case of an
* invalid string).
*/
static QgsWmsParameter::Name name( const QString &name );
static QgsWmsParameterForWmts::Name name( const QString &name );
};

/**
@@ -309,7 +309,7 @@ namespace QgsWmts
QStringList wmtsPngGroupNameList = project->readListEntry( QStringLiteral( "WMTSPngLayers" ), QStringLiteral( "Group" ) );
QStringList wmtsJpegGroupNameList = project->readListEntry( QStringLiteral( "WMTSJpegLayers" ), QStringLiteral( "Group" ) );

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

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

int tmIdx = -1;
for ( const tileMatrixDef tm : tms.tileMatrixList )
for ( const tileMatrixDef &tm : tms.tileMatrixList )
{
++tmIdx;

@@ -521,7 +521,7 @@ namespace QgsWmts
if ( !wmtsGroupNameList.isEmpty() )
{
QgsLayerTreeGroup *treeRoot = project->layerTreeRoot();
for ( QString gName : wmtsGroupNameList )
for ( const QString &gName : wmtsGroupNameList )
{
QgsLayerTreeGroup *treeGroup = treeRoot->findGroup( gName );
if ( !treeGroup )
@@ -541,7 +541,7 @@ namespace QgsWmts
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#endif
for ( QString lId : wmtsLayerIdList )
for ( const QString &lId : wmtsLayerIdList )
{
QgsMapLayer *l = project->mapLayer( lId );
if ( !l )
@@ -654,18 +654,18 @@ namespace QgsWmts
query.addQueryItem( QgsServerParameter::name( QgsServerParameter::SERVICE ), QStringLiteral( "WMS" ) );
query.addQueryItem( QgsServerParameter::name( QgsServerParameter::VERSION_SERVICE ), QStringLiteral( "1.3.0" ) );
query.addQueryItem( QgsServerParameter::name( QgsServerParameter::REQUEST ), request );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::LAYERS ), layer );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::STYLES ), QString() );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::CRS ), tms.ref );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::BBOX ), bbox );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::WIDTH ), QStringLiteral( "256" ) );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::HEIGHT ), QStringLiteral( "256" ) );
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::FORMAT ), format );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::LAYERS ), layer );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::STYLES ), QString() );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::CRS ), tms.ref );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::BBOX ), bbox );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::WIDTH ), QStringLiteral( "256" ) );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::HEIGHT ), QStringLiteral( "256" ) );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::FORMAT ), format );
if ( params.format() == QgsWmtsParameters::Format::PNG )
{
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::TRANSPARENT ), QStringLiteral( "true" ) );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::TRANSPARENT ), QStringLiteral( "true" ) );
}
query.addQueryItem( QgsWmsParameter::name( QgsWmsParameter::DPI ), QStringLiteral( "96" ) );
query.addQueryItem( QgsWmsParameterForWmts::name( QgsWmsParameterForWmts::DPI ), QStringLiteral( "96" ) );

return query;
}

0 comments on commit 6b8d04b

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