96 lines
2.9 KiB
C++
Executable File
96 lines
2.9 KiB
C++
Executable File
/**
|
|
* Geopairing Config
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Gerlinde Rudolphus, ESZS, 2016-04-14
|
|
*/
|
|
|
|
#include "geoconfig.h"
|
|
#include <QFileInfo>
|
|
|
|
namespace N_ConfigSystem
|
|
{
|
|
|
|
GeoConfig::GeoConfig()
|
|
//: m_logger(CesGeoPairing::getLogger("GeoConfig"))
|
|
{
|
|
}
|
|
|
|
GeoConfig::~GeoConfig()
|
|
{
|
|
}
|
|
|
|
GeoConfig *GeoConfig::getInstance()
|
|
{
|
|
static GeoConfig geoConfig;
|
|
return &geoConfig;
|
|
}
|
|
|
|
bool GeoConfig::initFilename(const QString &fileName)
|
|
{
|
|
// const QFileInfo qFileInfo(fileName);
|
|
// INFO_LOG(m_logger) << LOGFUNCTION << " START, GeoConfig::absoluteFilePath ='" << qFileInfo.absoluteFilePath() << "'";
|
|
|
|
// AmmunitionMap
|
|
ConfigSettings::initFilename(fileName);
|
|
initializeAmmu();
|
|
|
|
// Elevation (srtm_38_02.tif -> Norddeutschland)
|
|
const QString elevationName = getString(QStringLiteral("Elevation"), QStringLiteral("MapFile"), QStringLiteral("/usr/share/arcgis/resources/elevation/srtm_38_02.tif"));
|
|
|
|
const QStringList &filePaths_rough_to_fine = elevationName.split(QStringLiteral(";"));
|
|
|
|
// INFO_LOG(m_logger) << LOGFUNCTION << " use following file(s) for ElevationMap: '" << elevationName << "'";
|
|
|
|
if (!m_elevationMapManager)
|
|
{
|
|
m_elevationMapManager = std::make_shared<SituationMap::ElevationMapManager>();
|
|
m_elevationMapManager->init(filePaths_rough_to_fine);
|
|
}
|
|
|
|
// TRACE_LOG(m_logger) << LOGFUNCTION << " END, filename ='" << fileName << "'";
|
|
return true;
|
|
}
|
|
|
|
// ---------------------------------------------------------------
|
|
// Initialize the GeoPairing implementation
|
|
// ---------------------------------------------------------------
|
|
void GeoConfig::initializeAmmu()
|
|
{
|
|
int l_numberOfAmmunitions = getInteger(QStringLiteral("GeoPairing"), QStringLiteral("NumberOfEntries"), 0);
|
|
QString s_filter = getString(QStringLiteral("GeoPairing"), QStringLiteral("KeyOfEntries"), QStringLiteral("Ammunition"));
|
|
|
|
m_AmmuMap.clear();
|
|
QString s_group = QStringLiteral("AmmunitionMap");
|
|
for (int i=0; i< l_numberOfAmmunitions; i++)
|
|
{
|
|
QString s_ammu_group = s_filter + QString::number(i+1);
|
|
QString s_unknown = QStringLiteral("<unknown>");
|
|
QString s_ammu_value = getString(s_group, s_ammu_group, s_unknown);
|
|
m_AmmuMap[i] = s_ammu_value;
|
|
}
|
|
|
|
m_ChargeMap.clear();
|
|
for (int i = 0; i < l_numberOfAmmunitions; i++)
|
|
{
|
|
QString s_ammu_group = s_filter + QString::number(i + 1);
|
|
|
|
QVector<double> l_charges = getFloatVector(QStringLiteral("ChargeMap"), s_ammu_group);
|
|
m_ChargeMap[i] = l_charges;
|
|
// INFO_LOG(m_logger) << "Store ChargeMap Entry: " << " i=" << i << " s_ammu_group = '" << s_ammu_group << "'";
|
|
// for (int j = 0; j < l_charges.size(); j++)
|
|
// INFO_LOG(m_logger) << j << " = " << l_charges[j];
|
|
}
|
|
}
|
|
|
|
double GeoConfig::getElevation(const double lon, const double lat) const
|
|
{
|
|
if (!m_elevationMapManager)
|
|
return 0;
|
|
m_elevationMapManager->waitForInitialization();
|
|
return m_elevationMapManager->elevation(lon, lat);
|
|
}
|
|
|
|
} // namespace N_ConfigSystem
|