Files
qt5-legatus-legacy/Lts/Common/LtsElevation/lts_elevation_manager.h
T
2026-08-13 18:33:10 +02:00

163 lines
4.5 KiB
C++
Executable File

/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLTE, 2023-11-08
*/
#pragma once
#include "logger.h"
#include <LtsElevation/ltselevation_export.h>
#include <LtsUtilsCore/qpoint3d.h>
//#include <LtsSession/lts_session_data_dds.h>
#include <QObject>
#include <QPointer>
#include <QStringList>
#include <QCoreApplication> // qAddPostRoutine
#include <memory>
#include <iosfwd>
// !!! Do NOT include files of __SituationMap/Elevation__ in this header file!!
namespace LtsSession
{
class LtsSessionDataDds;
} // namespace LtsSession
namespace ExerciseManagement
{
namespace Interface
{
class Dtc;
}
}
namespace AssetManagement
{
namespace Interface
{
class Dtc;
}
}
namespace LtsElevation
{
enum class LineOfSight { LOS_UNDEFINED,
LOS_ERROR,
LOS_VISIBLE,
LOS_INVISIBLE };
class LtsElevationManager;
using LTS_ELEVATION_MANAGER_TYPE = QPointer<LtsElevationManager>;
/**
* @brief The LtsElevationManager class provides access to the terrain / elevation
* It wraps the SituationMap::ElevationMapManger.
*/
class LTSELEVATION_EXPORT LtsElevationManager : public QObject
{
public:
// main access:
/**
* @brief createInstance create method for singleton.
*
* @param exerciseId to be choosen.
* @param exmDtc access to ExerciseManagement
* @param asmDtc access to AssetDataManagement
*
* <b>Example:
*
* \code
// Server: Prepare at MainHandler
// (dtcs necessary for very first call)
LtsElevation::LtsElevationManager *ltsElevationManager =
LtsElevation::LtsElevationManager::createInstance(exerciseId,
dds()->exmDtc(),
dds()->asmDtc());
// Server: Use later on - e.g. Ces plugin:
// (dtcs not necessary anymore)
LtsElevation::LtsElevationManager *ltsElevationManager =
LtsElevation::LtsElevationManager::createInstance(exerciseId);
* \endcode
*
*/
static LTS_ELEVATION_MANAGER_TYPE createInstance(int exerciseId,
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc = {},
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc = {});
static LTS_ELEVATION_MANAGER_TYPE getInstance(int exerciseId);
static LTS_ELEVATION_MANAGER_TYPE createInstanceForTrainingAreaId(int trainingAreaId,
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc = nullptr);
// // For WS / OperatorApplication maybe like:
// static LtsElevationManager *createInstance(int exerciseId, LtsSession::LtsSessionDataDds *session);
static void cleanupAll();
virtual ~LtsElevationManager();
bool waitForInitialization();
bool isValid() const;
double elevation(double lon_rad, double lat_rad, double defaultValue = std::numeric_limits<double>::min(), bool *bIsCovered = nullptr) const;
LineOfSight lineOfSightCalculation(const LtsUtils::QPoint3D &startPointGeo_absZ,
const LtsUtils::QPoint3D &endPointGeo_absZ);
LineOfSight lineOfSightCalculation(const QPointF &startPointGeo, double startHat,
const QPointF &endPointGeo, double endHat);
protected:
explicit LtsElevationManager();
/**
* @brief initDDS
* @param exmDtc
* @param asmDtc
*/
void initDDS(const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc);
bool init(const QStringList &filePaths_rough_to_fine);
static int exerciseIdToTrainingAreaId(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc);
// static bool setupDtcs();
QStringList getFilenamesForExercise(int exerciseId);
QStringList getFilenamesForTrainingArea(int trainingAreaId);
// !!! For UnitTest only !!!
// !!! For UnitTest only !!!
// !!! For UnitTest only !!!
static LTS_ELEVATION_MANAGER_TYPE createInstanceUnitTest(int id, const QStringList &filePaths_rough_to_fine);
private:
// bool initDefaultValues();
class Private;
Private *d;
LOGGER_T m_logger; ///< Interface of the Logging-Facility
};
LTSELEVATION_EXPORT const QString toString(const LtsElevation::LineOfSight &value);
LTSELEVATION_EXPORT std::ostream &operator<< (std::ostream &stream,
const LtsElevation::LineOfSight value);
} // namespace LtsElevation