Skip to content
Permalink
Browse files

Add utils method for external layers

  • Loading branch information
pblottiere committed Mar 5, 2019
1 parent ec3e15f commit ed31a3295141896b73c21e03120645badbc29697
Showing with 26 additions and 15 deletions.
  1. +23 −15 src/server/services/wms/qgswmsparameters.cpp
  2. +3 −0 src/server/services/wms/qgswmsparameters.h
@@ -19,6 +19,8 @@
#include "qgsdatasourceuri.h"
#include "qgsmessagelog.h"

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

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

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

QgsWmsParametersLayer param;
@@ -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;
@@ -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
{
@@ -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 );
}
}
@@ -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;

0 comments on commit ed31a32

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