/** * SpiceKernelMgr.hh * * Created on: 08 jul. 2016 * Author: AKKA IS */ #ifndef SPICEKERNELMGR_HH_ #define SPICEKERNELMGR_HH_ #include #include "dsgpatt_Singleton.hh" #include "SpiceKernelConfig.hh" #include "SpiceKernelLogger.hh" namespace AMDA { namespace SpiceKernel { /** * @class SpiceKernelMgr * @brief Singleton to manage spice kernel * @details */ class SpiceKernelMgr : public ::Singleton { public: template bool transform(const char* fromFrame, const char* toFrame, bool isPosition, double time, const std::vector& input, std::vector& output) { if (!SpiceKernelMgr::getInstance()->loadDataFilesForFrameName(fromFrame)) { LOG4CXX_ERROR(gLogger, "SpiceKernelMgr::transform - Error to load data files for frame " << fromFrame); return false; } if (!SpiceKernelMgr::getInstance()->loadDataFilesForFrameName(toFrame)) { LOG4CXX_ERROR(gLogger, "SpiceKernelMgr::transform - Error to load data files for frame " << toFrame); return false; } double et = timeStampToEt(time); double rotation[3][3]; if (!getRotationMatrix(fromFrame, toFrame, et, rotation)) return false; double translation[3] = {0,0,0}; if (!getTranslation(fromFrame, toFrame, isPosition, et, translation)) return false; double vin[3] = {(double)input[0] - translation[0], (double)input[1] - translation[1], (double)input[2] - translation[2]}; double vout[3]; if (!computeTransformation(vin, translation, rotation, vout)) return false; output.reserve(3); output[0] = (T)vout[0]; output[1] = (T)vout[1]; output[2] = (T)vout[2]; return true; } double timeStampToEt(double timeStamp); double timeStampToJulianDate(double timeStamp); protected: friend class ::Singleton; SpiceKernelMgr(); virtual ~SpiceKernelMgr(); private: void loadConfig(); int getBodyCenterFromFrameName(const char *frameName); int getFrameIdFromFrameName(const char *frameName); bool isDataFileLoaded(const char* filePath); bool loadListOfDataFiles(std::list dataFilesList); bool loadDataFilesForFrameName(const char *frameName); bool loadGenericDataFiles(); bool getRotationMatrix(const char* fromFrame, const char* toChar, double et, double rotate[3][3]); bool getTranslation(const char* fromFrame, const char* toFrame, bool isPosition, double et, double translation[3]); bool computeTransformation(double input[3], double translation[3], double rotation[3][3], double output[3]); bool _genericDataFilesLoaded; boost::shared_ptr _config; std::list _loadedDataFiles; std::list _DataFilesLoadedForFrameName; std::map _bodyCenterFromFrameNameMap; std::map _frameIdFromFrameNameMap; }; } /* SpiceKernelMgr */ } /* AMDA */ #endif // SPICEKERNELMGR_HH_