Skip to content
Permalink
Browse files

Add DXF parameters in QgsWmsParameters

  • Loading branch information
pblottiere committed Mar 19, 2019
1 parent 9327834 commit 395360869bde6bcee0d249ce7b69d2a72f6be732
Showing with 124 additions and 1 deletion.
  1. +98 −0 src/server/services/wms/qgswmsparameters.cpp
  2. +26 −1 src/server/services/wms/qgswmsparameters.h
@@ -1817,4 +1817,102 @@ namespace QgsWms
{
return name.startsWith( EXTERNAL_LAYER_PREFIX );
}

QStringList QgsWmsParameters::dxfLayerAttributes() const
{
QStringList attributes;
const QMap<DxfFormatOption, QString> options = dxfFormatOptions();

if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
{
attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
}

return attributes;
}

bool QgsWmsParameters::dxfUseLayerTitleAsName() const
{
bool use = false;
const QMap<DxfFormatOption, QString> options = dxfFormatOptions();

if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
{
use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
}

return use;
}

double QgsWmsParameters::dxfScale() const
{
const QMap<DxfFormatOption, QString> options = dxfFormatOptions();

double scale = -1;
if ( options.contains( DxfFormatOption::SCALE ) )
{
scale = options[ DxfFormatOption::SCALE ].toDouble();
}

return scale;
}

QgsDxfExport::SymbologyExport QgsWmsParameters::dxfMode() const
{
const QMap<DxfFormatOption, QString> options = dxfFormatOptions();

QgsDxfExport::SymbologyExport symbo = QgsDxfExport::NoSymbology;

if ( ! options.contains( DxfFormatOption::MODE ) )
{
return symbo;
}

const QString mode = options[ DxfFormatOption::MODE ];
if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
{
symbo = QgsDxfExport::SymbolLayerSymbology;
}
else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
{
symbo = QgsDxfExport::FeatureSymbology;
}

return symbo;
}

QString QgsWmsParameters::dxfCodec() const
{
QString codec = QStringLiteral( "ISO-8859-1" );

if ( dxfFormatOptions().contains( DxfFormatOption::CODEC ) )
{
codec = dxfFormatOptions()[ DxfFormatOption::CODEC ];
}

return codec;
}

QMap<QgsWmsParameters::DxfFormatOption, QString> QgsWmsParameters::dxfFormatOptions() const
{
QMap<QgsWmsParameters::DxfFormatOption, QString> options;

const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::DxfFormatOption>() );
const QStringList opts = mWmsParameters[ QgsWmsParameter::FORMAT_OPTIONS ].toStringList( ';' );

for ( auto it = opts.constBegin(); it != opts.constEnd(); ++it )
{
const int equalIdx = it->indexOf( ':' );
if ( equalIdx > 0 && equalIdx < ( it->length() - 1 ) )
{
const QString name = it->left( equalIdx ).toUpper();
const QgsWmsParameters::DxfFormatOption option =
( QgsWmsParameters::DxfFormatOption ) metaEnum.keyToValue( name.toStdString().c_str() );
const QString value = it->right( it->length() - equalIdx - 1 );
options.insert( option, value );
}
}

return options;
}
}
@@ -28,6 +28,7 @@
#include "qgsprojectversion.h"
#include "qgsogcutils.h"
#include "qgsserverparameters.h"
#include "qgsdxfexport.h"

namespace QgsWms
{
@@ -174,7 +175,8 @@ namespace QgsWms
WITH_GEOMETRY,
WITH_MAPTIP,
WMTVER,
ATLAS_PK
ATLAS_PK,
FORMAT_OPTIONS
};
Q_ENUM( Name )

@@ -323,6 +325,17 @@ namespace QgsWms
};
Q_ENUM( Format )

//! Options for DXF format
enum DxfFormatOption
{
SCALE,
MODE,
LAYERATTRIBUTES,
USE_TITLE_AS_LAYERNAME,
CODEC
};
Q_ENUM( DxfFormatOption )

/**
* Constructor for WMS parameters with specific values.
* \param parameters Map of parameters where keys are parameters' names.
@@ -1177,6 +1190,18 @@ namespace QgsWms
*/
QStringList atlasPk() const;

QMap<DxfFormatOption, QString> dxfFormatOptions() const;

QStringList dxfLayerAttributes() const;

bool dxfUseLayerTitleAsName() const;

double dxfScale() const;

QgsDxfExport::SymbologyExport dxfMode() const;

QString dxfCodec() const;

private:
static bool isExternalLayer( const QString &name );

0 comments on commit 3953608

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