Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
**
|
||||
** @RDE_HEADER@
|
||||
** Implementation of dialog to modify xml symbols
|
||||
** $Id$
|
||||
** $HeadURL$
|
||||
** $Author$
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
**
|
||||
** Hardware-Environment: Intel-PC
|
||||
** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5
|
||||
**
|
||||
** Language ........: C++ 11
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
**
|
||||
** Author ...........: Jörg Turla, SPD G, Tel. 3132
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
**
|
||||
** Notes .........:
|
||||
**
|
||||
** 09.01.2018, JT : First edition for use with Qt5
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "symbology_xml_export.h"
|
||||
|
||||
#include "symbol_types.h"
|
||||
|
||||
#include <QtCore/QChar>
|
||||
#include <QtCore/QString>
|
||||
|
||||
/**
|
||||
* \brief The SidcCodec namespace enables the encoding and decoding of a (base) symbol id of xml symbols.
|
||||
* The completly encoded id concists of the base symbol id and additional information like state, uncertainty
|
||||
* affiliation and mobility which are coded as numbers. As separator and '-' is used. The completly encoded
|
||||
* symbol id is used in AdvancedSymbology::SymbolDictionary as SIDC to store the symbol.
|
||||
* @see SymbolDictionary, SidcCodec
|
||||
*
|
||||
*/
|
||||
namespace SymbologyXML
|
||||
{
|
||||
/**
|
||||
* Functions to encode a symbol id.
|
||||
* @{
|
||||
*/
|
||||
inline
|
||||
QString xmlSymbolEncodeId( uint baseId
|
||||
, SymbolTypes::t_state state
|
||||
, SymbolTypes::t_uncertainty uncertainty
|
||||
, SymbolTypes::t_affil affil
|
||||
, SymbolTypes::t_mob mob)
|
||||
{
|
||||
return QStringLiteral("%1-%2-%3-%4-%5").arg(baseId).arg(int(state)).arg(int(uncertainty)).arg(int(affil)).arg(int(mob));
|
||||
} // QString xmlSymbolEncodeId(...)
|
||||
|
||||
|
||||
inline
|
||||
QString xmlSymbolEncodeId( const QString &baseId
|
||||
, SymbolTypes::t_state state
|
||||
, SymbolTypes::t_uncertainty uncertainty
|
||||
, SymbolTypes::t_affil affil
|
||||
, SymbolTypes::t_mob mob)
|
||||
{
|
||||
bool ok;
|
||||
|
||||
uint baseIdInt = baseId.toUInt(&ok);
|
||||
|
||||
return (ok) ? xmlSymbolEncodeId(baseIdInt,state,uncertainty,affil,mob) : QString();
|
||||
} // QString xmlSymbolEncodeId
|
||||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* Functions to decode a symbol id.
|
||||
* @{
|
||||
*/
|
||||
inline
|
||||
bool xmlSymbolDecodeId( const QString &encodedId
|
||||
, QString &baseId
|
||||
, SymbolTypes::t_state &state
|
||||
, SymbolTypes::t_uncertainty &uncertainty
|
||||
, SymbolTypes::t_affil &affil
|
||||
, SymbolTypes::t_mob &mob)
|
||||
{
|
||||
QVector<QStringRef> tokenVector = encodedId.splitRef( QLatin1Char('-') );
|
||||
if (tokenVector.size() == 5)
|
||||
{
|
||||
bool ok = false;
|
||||
uint tokenCode[5];
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
tokenCode[i] = tokenVector[i].toUInt(&ok);
|
||||
if (!ok) break;
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
baseId = QString::number(tokenCode[0]);
|
||||
state = SymbolTypes::t_state(tokenCode[1]);
|
||||
uncertainty = SymbolTypes::t_uncertainty(tokenCode[2]);
|
||||
affil = SymbolTypes::t_affil(tokenCode[3]);
|
||||
mob = SymbolTypes::t_mob(tokenCode[4]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
baseId = encodedId;
|
||||
return false;
|
||||
} // bool xmlSymbolDecodeId(...)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Function to extract the base symbol id from encoded id string.
|
||||
*/
|
||||
inline
|
||||
QString xmlSymbolExtractBaseSidc(const QString &sidc)
|
||||
{
|
||||
return sidc.section( QLatin1Char('-'),0,0 );
|
||||
}
|
||||
}; // namespace SymbologyXML
|
||||
Reference in new issue
Block a user