FramesTransformation.hh 2.17 KB
/*
 * FramesTransformation.hh
 *
 *  Created on: Jul 18, 2016
 *      Author: AKKA IS
 */

#ifndef FRAMESTRANSFORMATION_HH_
#define FRAMESTRANSFORMATION_HH_

#include "Parameter.hh"
#include "ParamData.hh"
#include "DataTypeMath.hh"
#include "Operation.hh"
#include "SpiceKernelMgr.hh"

namespace AMDA {
namespace Parameters {

/**
 * @class FramesTransformation
 * @brief It is responsible to compute the frames transformation.
 * @details This class implement the interface Operation.
 */
template<class TParamData>
class FramesTransformation : public Operation {

	typedef typename TParamData::ElementType ElemType;

public:
	/**
	 * @brief Constructor.
	 * @details Create the ParamData type of the input ParamData.
	 */
  FramesTransformation(Process& pProcess, TParamData& paramInput, const char* fromFrame, const char* toFrame, bool isPosition)
	: Operation(pProcess),
	  _paramInput(paramInput),
	  _paramOutput(new TParamData()),
	  _fromFrame(fromFrame),
	  _toFrame(toFrame),
	  _isPosition(isPosition) {
	  _paramDataOutput=_paramOutput;
  }

	/**
	 * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
	 */
  void  write(ParamDataIndexInfo &pParamDataIndexInfo) {
	  for (unsigned int _index = pParamDataIndexInfo._startIndex ;
			  _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
			  ++_index)
	  {
		  ElemType output = _paramInput.get(pParamDataIndexInfo._startIndex);

		  if (!isNAN(_paramInput.getDataList()[_index]))
			  AMDA::SpiceKernel::SpiceKernelMgr::getInstance()->transform(
					  _fromFrame.c_str(),
					  _toFrame.c_str(),
					  _isPosition,
					  _paramInput.getTime(_index),
					  _paramInput.getDataList()[_index],
					  output);
		  else
			  output << NotANumber();

		  _paramOutput->pushTime(_paramInput.getTime(_index));
		  _paramOutput->getDataList().push_back(output);
	  }
  }

private:
	/**<
	 * @brief It is the channel of data derived
	 */
  TParamData &_paramInput;

	/**<
	 * @brief It is the channel of the data derived
	 */
  TParamData *_paramOutput;

  std::string _fromFrame;

  std::string _toFrame;

  bool _isPosition;


};

} /* namespace Parameters */
} /* namespace AMDA */
#endif /* FRAMESTRANSFORMATION_HH_ */