Skip to content

Commit

Permalink
Add utils method for external layers
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Mar 18, 2019
1 parent ec3e15f commit ed31a32
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/server/services/wms/qgswmsparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "qgsdatasourceuri.h"
#include "qgsmessagelog.h"

const QString EXTERNAL_LAYER_PREFIX = QStringLiteral( "EXTERNAL_WMS:" );

namespace QgsWms
{
//
Expand Down Expand Up @@ -1409,7 +1411,7 @@ namespace QgsWms
{
QString layer = layers[i];

if ( layer.startsWith( QStringLiteral( "EXTERNAL_WMS:" ) ) )
if ( isExternalLayer( layer ) )
continue;

QgsWmsParametersLayer param;
Expand Down Expand Up @@ -1503,15 +1505,10 @@ namespace QgsWms
const QStringList layers = allLayersNickname();
for ( const QString &layer : allLayersNickname() )
{
if ( ! layer.startsWith( QStringLiteral( "EXTERNAL_WMS:" ) ) )
if ( ! isExternalLayer( layer ) )
continue;

QgsWmsParametersExternalLayer externalLayer;
externalLayer.mName = layer;
externalLayer.mName.remove( 0, 13 );
externalLayer.mUri = externalWMSUri( externalLayer.mName );

externalLayers << externalLayer;
externalLayers << externalLayerParameter( layer );
}

return externalLayers;
Expand Down Expand Up @@ -1615,14 +1612,9 @@ namespace QgsWms

for ( const auto &layer : allLayers )
{
if ( layer.startsWith( QStringLiteral( "EXTERNAL_WMS:" ) ) )
if ( isExternalLayer( layer ) )
{
QgsWmsParametersExternalLayer externalParam;
externalParam.mName = layer;
externalParam.mName.remove( 0, 13 );
externalParam.mUri = externalWMSUri( externalParam.mName );

eParams << externalParam;
eParams << externalLayerParameter( layer );
}
else
{
Expand Down Expand Up @@ -1810,4 +1802,20 @@ namespace QgsWms

return p;
}

QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
{
QgsWmsParametersExternalLayer param;

param.mName = name;
param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
param.mUri = externalWMSUri( param.mName );

return param;
}

bool QgsWmsParameters::isExternalLayer( const QString &name ) const
{
return name.startsWith( EXTERNAL_LAYER_PREFIX );
}
}
3 changes: 3 additions & 0 deletions src/server/services/wms/qgswmsparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,9 @@ namespace QgsWms
void raiseError( const QString &msg ) const;
void log( const QString &msg ) const;

bool isExternalLayer( const QString &name ) const;
QgsWmsParametersExternalLayer externalLayerParameter( const QString &name ) const;

QMultiMap<QString, QgsWmsParametersFilter> layerFilters( const QStringList &layers ) const;

QMap<QgsWmsParameter::Name, QgsWmsParameter> mWmsParameters;
Expand Down

0 comments on commit ed31a32

Please sign in to comment.