OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ossimplugins::PlatformPosition Class Reference

This class handles the platform position. More...

#include <PlatformPosition.h>

Public Member Functions

 PlatformPosition ()
 Constructor. More...
 
 ~PlatformPosition ()
 Destructor. More...
 
 PlatformPosition (const PlatformPosition &rhs)
 Copy constructor. More...
 
 PlatformPosition (Ephemeris **data, int nbrData)
 Constructor with initialisation. More...
 
PlatformPositionoperator= (const PlatformPosition &rhs)
 Affectation operator. More...
 
EphemerisInterpolate (JSDDateTime date) const
 This function interpolates its ephemeris to create a new ephemeris at the given date and time. More...
 
bool getPlatformPositionAtTime (JSDDateTime time, std::vector< double > &position, std::vector< double > &speed)
 This function interpolates its ephemeris to create and extract platform's position and speed. More...
 
PlatformPositionClone () const
 
void setData (Ephemeris **data, int nbrData)
 
EphemerisgetData (int noData) const
 
int getNbrData () const
 
bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Method to save object state to a keyword list. More...
 
bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of the object from a keyword list. More...
 

Protected Member Functions

void InitData (Ephemeris **data, int nbrData)
 Internal method to initialize data structures. More...
 
void InitAuxiliaryData ()
 
void Clear ()
 This function deletes all the contents of the class. More...
 

Protected Attributes

int _nbrData
 Number of platform positions. More...
 
Ephemeris ** _data
 Platform positions. More...
 

Private Attributes

double * _t
 
double ** _p
 
double ** _dp
 
HermiteInterpolator ** _interpolator
 

Detailed Description

This class handles the platform position.

Definition at line 33 of file PlatformPosition.h.

Constructor & Destructor Documentation

◆ PlatformPosition() [1/3]

ossimplugins::PlatformPosition::PlatformPosition ( )

Constructor.

Definition at line 28 of file PlatformPosition.cpp.

28  :
29  _nbrData(0),
30  _data(NULL),
31  _t(NULL),
32  _p(NULL),
33  _dp(NULL),
34  _interpolator(NULL)
35 {
36 }
int _nbrData
Number of platform positions.
Ephemeris ** _data
Platform positions.
HermiteInterpolator ** _interpolator

◆ ~PlatformPosition()

ossimplugins::PlatformPosition::~PlatformPosition ( )

Destructor.

Definition at line 38 of file PlatformPosition.cpp.

References Clear().

39 {
40  Clear();
41  }
void Clear()
This function deletes all the contents of the class.

◆ PlatformPosition() [2/3]

ossimplugins::PlatformPosition::PlatformPosition ( const PlatformPosition rhs)

Copy constructor.

Definition at line 70 of file PlatformPosition.cpp.

References _data, _nbrData, and InitData().

71 {
72  InitData(rhs._data, rhs._nbrData);
73 }
void InitData(Ephemeris **data, int nbrData)
Internal method to initialize data structures.

◆ PlatformPosition() [3/3]

ossimplugins::PlatformPosition::PlatformPosition ( Ephemeris **  data,
int  nbrData 
)

Constructor with initialisation.

Parameters
dataEphemeris
nbrDataNumber of Ephemeris in data
Remarks
All the ephemeris have to be in the same coordinates system
This constructor copy the content of data, so it's the calling fonction that have to manage the memory of data.

Definition at line 82 of file PlatformPosition.cpp.

References InitData().

83 {
84  InitData(data, nbrData);
85  }
void InitData(Ephemeris **data, int nbrData)
Internal method to initialize data structures.

Member Function Documentation

◆ Clear()

void ossimplugins::PlatformPosition::Clear ( )
protected

This function deletes all the contents of the class.

Definition at line 43 of file PlatformPosition.cpp.

References _data, _dp, _interpolator, _nbrData, _p, and _t.

Referenced by loadState(), operator=(), setData(), and ~PlatformPosition().

44 {
45  if(_data != NULL)
46  {
47  for (int i=0;i<_nbrData;i++)
48  {
49  delete _data[i];
50  }
51  delete [] _data;
52  }
53  _data = NULL;
54  _nbrData = 0;
55 
56  delete[] _t;
57  if ((_p != NULL) && (_dp != NULL)) {
58  for (int j=0; j<3; ++j) {
59  delete[] _p[j];
60  delete[] _dp[j];
61  delete _interpolator[j];
62  }
63  }
64  delete[] _p;
65  delete[] _dp;
66 
67  delete[] _interpolator;
68  }
int _nbrData
Number of platform positions.
Ephemeris ** _data
Platform positions.
HermiteInterpolator ** _interpolator

◆ Clone()

PlatformPosition* ossimplugins::PlatformPosition::Clone ( ) const
inline

Definition at line 79 of file PlatformPosition.h.

Referenced by ossimplugins::Sensor::Sensor(), and ossimplugins::ossimGeometricSarSensorModel::set_platformPosition().

80  {
81  return new PlatformPosition(*this);
82  };

◆ getData()

Ephemeris * ossimplugins::PlatformPosition::getData ( int  noData) const

Definition at line 197 of file PlatformPosition.cpp.

References _data, and _nbrData.

198 {
199  if(noData >=0 && noData < _nbrData)
200  {
201  return _data[noData];
202  }
203  return NULL;
204  }
int _nbrData
Number of platform positions.
Ephemeris ** _data
Platform positions.

◆ getNbrData()

int ossimplugins::PlatformPosition::getNbrData ( ) const

Definition at line 206 of file PlatformPosition.cpp.

References _nbrData.

207 {
208  return _nbrData;
209  }
int _nbrData
Number of platform positions.

◆ getPlatformPositionAtTime()

bool ossimplugins::PlatformPosition::getPlatformPositionAtTime ( JSDDateTime  time,
std::vector< double > &  position,
std::vector< double > &  speed 
)

This function interpolates its ephemeris to create and extract platform's position and speed.

Parameters
dateDate and time at wich the interpolation have to be done
Returns
true, or false if an error occurs

Definition at line 174 of file PlatformPosition.cpp.

References ossimplugins::Ephemeris::get_position(), ossimplugins::Ephemeris::get_speed(), and Interpolate().

Referenced by ossimplugins::ossimGeometricSarSensorModel::getPlatformPositionAtLine().

175 {
176  Ephemeris* ephemeris = this->Interpolate(time);
177  double* position_ptr = ephemeris->get_position();
178  double* speed_ptr = ephemeris->get_speed();
179  if (position.size() != 3) position.resize(3);
180  if (speed.size() != 3) speed.resize(3);
181  position[0] = position_ptr[0];
182  position[1] = position_ptr[1];
183  position[2] = position_ptr[2];
184  speed[0] = speed_ptr[0];
185  speed[1] = speed_ptr[1];
186  speed[2] = speed_ptr[2];
187  return true;
188 }
Ephemeris * Interpolate(JSDDateTime date) const
This function interpolates its ephemeris to create a new ephemeris at the given date and time...

◆ InitAuxiliaryData()

void ossimplugins::PlatformPosition::InitAuxiliaryData ( )
protected

Definition at line 98 of file PlatformPosition.cpp.

References _data, _dp, _interpolator, _nbrData, _p, _t, ossimplugins::Ephemeris::get_date(), ossimplugins::JSDDateTime::get_day0hTU(), ossimplugins::JSDDateTime::get_decimal(), ossimplugins::JulianDate::get_julianDate(), ossimplugins::Ephemeris::get_position(), ossimplugins::JSDDateTime::get_second(), and ossimplugins::Ephemeris::get_speed().

Referenced by InitData(), and loadState().

99 {
100  const double JOURCIVIL_LENGTH = 86400.0;
101  _t = new double[_nbrData];
102  _p = new double*[3];
103  _dp = new double*[3];
104  _interpolator = new HermiteInterpolator*[3];
105  for (int j=0; j<3; ++j) {
106  _p[j] = new double[_nbrData];
107  _dp[j] = new double[_nbrData];
108  }
109 
110  _t[0] = 0.0;
111  for (int i = 1; i < _nbrData; i++)
112  {
114  * JOURCIVIL_LENGTH
115  + _data[i]->get_date().get_second() - _data[0]->get_date().get_second()
116  + _data[i]->get_date().get_decimal() - _data[0]->get_date().get_decimal();
117  }
118 
119  for (int j = 0; j < 3; j++)
120  {
121  for (int i = 0; i < _nbrData; i++)
122  {
123  _p[j][i] = _data[i]->get_position()[j];
124  _dp[j][i] = _data[i]->get_speed()[j];
125  }
126  _interpolator[j] = new HermiteInterpolator(_nbrData, _t, _p[j], _dp[j]);
127  }
128 
129  }
int _nbrData
Number of platform positions.
double get_julianDate() const
Definition: JulianDate.h:70
double * get_speed()
Definition: Ephemeris.h:78
Ephemeris ** _data
Platform positions.
JulianDate get_day0hTU() const
Definition: JSDDateTime.h:71
double * get_position()
Definition: Ephemeris.h:68
double get_second() const
Definition: JSDDateTime.h:76
JSDDateTime get_date() const
Definition: Ephemeris.h:63
double get_decimal() const
Definition: JSDDateTime.h:81
HermiteInterpolator ** _interpolator

◆ InitData()

void ossimplugins::PlatformPosition::InitData ( Ephemeris **  data,
int  nbrData 
)
protected

Internal method to initialize data structures.

Definition at line 87 of file PlatformPosition.cpp.

References _data, _nbrData, ossimplugins::Ephemeris::Clone(), and InitAuxiliaryData().

Referenced by operator=(), PlatformPosition(), and setData().

88 {
89  _nbrData = nbrData;
90  _data = new Ephemeris*[_nbrData];
91  for (int i=0; i<_nbrData; i++)
92  {
93  _data[i] = data[i]->Clone();
94  }
96  }
int _nbrData
Number of platform positions.
Ephemeris ** _data
Platform positions.
virtual Ephemeris * Clone()
This function creatse a copy of the current class.
Definition: Ephemeris.h:58

◆ Interpolate()

Ephemeris * ossimplugins::PlatformPosition::Interpolate ( JSDDateTime  date) const

This function interpolates its ephemeris to create a new ephemeris at the given date and time.

Parameters
dateDate and time at wich the interpolation have to be done
Returns
The ephemeris at the given date, or NULL if an error occurs

Definition at line 131 of file PlatformPosition.cpp.

References _data, _interpolator, _nbrData, ossimplugins::Ephemeris::Clone(), ossimplugins::Ephemeris::get_date(), ossimplugins::JSDDateTime::get_day0hTU(), ossimplugins::JSDDateTime::get_decimal(), ossimplugins::JulianDate::get_julianDate(), ossimplugins::JSDDateTime::get_second(), ossimplugins::HermiteInterpolator::Interpolate(), ossimplugins::Ephemeris::set_date(), ossimplugins::Ephemeris::set_position(), and ossimplugins::Ephemeris::set_speed().

Referenced by getPlatformPositionAtTime(), ossimplugins::SarSensor::ImageToWorld(), ossimplugins::ossimCosmoSkymedModel::InitRefPoint(), ossimplugins::ossimErsSarModel::InitRefPoint(), ossimplugins::ossimAlosPalsarModel::InitRefPoint(), ossimplugins::ossimRadarSat2Model::InitRefPoint(), ossimplugins::ossimEnvisatAsarModel::InitRefPoint(), ossimplugins::ossimRadarSatModel::InitRefPoint(), and ossimplugins::ossimRadarSat2Model::initRefPoint().

132 {
133  const double JOURCIVIL_LENGTH = 86400.0;
134  Ephemeris* ephem = NULL;
135  if (_nbrData <= 1)
136  {
137  return NULL;
138  }
139  /*
140  * The first element of the list is cloned to ensure that the
141  * output ephemeris is expressed in the same coordinate system as
142  * input ones
143  */
144  ephem = _data[0]->Clone();
145 
146  /* NORMAL CASE */
147  /*------------*/
148  double dt = 0.0;
149 
150  if (ephem != NULL)
151  {
152  ephem->set_date(date);
153 
154  dt = (date.get_day0hTU().get_julianDate()
156  * JOURCIVIL_LENGTH
157  + date.get_second() - _data[0]->get_date().get_second()
158  + date.get_decimal() - _data[0]->get_date().get_decimal();
159 
160  /* Computation by Everett */
161  /*---------------------*/
162  double pos[3];
163  double speed[3];
164  for (int j = 0; j < 3; j++)
165  {
166  _interpolator[j]->Interpolate(dt, pos[j], speed[j]);
167  }
168  ephem->set_position(pos);
169  ephem->set_speed(speed);
170  }
171  return ephem;
172  }
int _nbrData
Number of platform positions.
double get_julianDate() const
Definition: JulianDate.h:70
void set_date(JSDDateTime date)
Definition: Ephemeris.h:88
Ephemeris ** _data
Platform positions.
JulianDate get_day0hTU() const
Definition: JSDDateTime.h:71
double get_second() const
Definition: JSDDateTime.h:76
virtual Ephemeris * Clone()
This function creatse a copy of the current class.
Definition: Ephemeris.h:58
JSDDateTime get_date() const
Definition: Ephemeris.h:63
double get_decimal() const
Definition: JSDDateTime.h:81
int Interpolate(double x, double &y, double &dy) const
This function performs the interpolation for the abscissa x.
HermiteInterpolator ** _interpolator

◆ loadState()

bool ossimplugins::PlatformPosition::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)

Method to the load (recreate) the state of the object from a keyword list.

Return true if ok or false on error.

Returns
true if load OK, false on error

Definition at line 236 of file PlatformPosition.cpp.

References _data, _nbrData, ossimString::chars(), Clear(), ossimKeywordlist::find(), InitAuxiliaryData(), ossimplugins::Ephemeris::loadState(), ossimString::toInt(), and ossimString::toString().

Referenced by ossimplugins::ossimGeometricSarSensorModel::loadState().

238 {
239  bool result = true;
240 
241  Clear();
242 
243  const char* lookup = 0;
244  lookup = kwl.find(prefix, NUMBER_PLATFORM_POSITIONS_KW);
245  if (!lookup)
246  {
247  return false;
248  }
249  ossimString s = lookup;
250  _nbrData = s.toInt();
251 
252  if (_nbrData)
253  {
254  std::string s1;
255  if (prefix)
256  {
257  s1 = prefix;
258  }
259 
260  _data = new Ephemeris*[_nbrData];
261  for (int i = 0; i < _nbrData; ++i)
262  {
263  std::string s2 = s1;
264  s2 += "platform_position[";
265  s2 += ossimString::toString(i).chars();
266  s2+= "]";
267 
268  _data[i] = new Ephemeris();
269  _data[i]->loadState(kwl, s2.c_str());
270  }
271  }
273  return result;
274  }
int _nbrData
Number of platform positions.
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
Ephemeris ** _data
Platform positions.
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of the object from a keyword list.
Definition: Ephemeris.cpp:100
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
void Clear()
This function deletes all the contents of the class.
int toInt() const

◆ operator=()

PlatformPosition & ossimplugins::PlatformPosition::operator= ( const PlatformPosition rhs)

Affectation operator.

Definition at line 75 of file PlatformPosition.cpp.

References _data, _nbrData, Clear(), and InitData().

76 {
77  Clear();
78  InitData(rhs._data, rhs._nbrData);
79  return *this;
80  }
void Clear()
This function deletes all the contents of the class.
void InitData(Ephemeris **data, int nbrData)
Internal method to initialize data structures.

◆ saveState()

bool ossimplugins::PlatformPosition::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const

Method to save object state to a keyword list.

Parameters
kwlKeyword list to save to.
prefixadded to keys when saved.
Returns
true on success, false on error.

Definition at line 212 of file PlatformPosition.cpp.

References _data, _nbrData, ossimKeywordlist::add(), ossimString::chars(), ossimplugins::Ephemeris::saveState(), and ossimString::toString().

Referenced by ossimplugins::ossimGeometricSarSensorModel::saveState().

214 {
215  kwl.add(prefix, NUMBER_PLATFORM_POSITIONS_KW, _nbrData);
216 
217  std::string s1;
218  if (prefix)
219  {
220  s1 = prefix;
221  }
222 
223  for (int i = 0; i < _nbrData; ++i)
224  {
225  std::string s2 = s1;
226  s2 += "platform_position[";
227  s2 += ossimString::toString(i).chars();
228  s2+= "]";
229  _data[i]->saveState(kwl, s2.c_str());
230  }
231 
232  return true;
233  }
int _nbrData
Number of platform positions.
bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save object state to a keyword list.
Definition: Ephemeris.cpp:78
static ossimString toString(bool aValue)
Numeric to string methods.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
Ephemeris ** _data
Platform positions.
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77

◆ setData()

void ossimplugins::PlatformPosition::setData ( Ephemeris **  data,
int  nbrData 
)

Definition at line 191 of file PlatformPosition.cpp.

References Clear(), and InitData().

Referenced by ossimplugins::ossimTerraSarProductDoc::initPlatformPosition().

192 {
193  Clear();
194  InitData(data, nbrData);
195 }
void Clear()
This function deletes all the contents of the class.
void InitData(Ephemeris **data, int nbrData)
Internal method to initialize data structures.

Member Data Documentation

◆ _data

Ephemeris** ossimplugins::PlatformPosition::_data
protected

Platform positions.

Definition at line 121 of file PlatformPosition.h.

Referenced by Clear(), getData(), InitAuxiliaryData(), InitData(), Interpolate(), loadState(), operator=(), PlatformPosition(), and saveState().

◆ _dp

double** ossimplugins::PlatformPosition::_dp
private

Definition at line 131 of file PlatformPosition.h.

Referenced by Clear(), and InitAuxiliaryData().

◆ _interpolator

HermiteInterpolator** ossimplugins::PlatformPosition::_interpolator
private

Definition at line 132 of file PlatformPosition.h.

Referenced by Clear(), InitAuxiliaryData(), and Interpolate().

◆ _nbrData

int ossimplugins::PlatformPosition::_nbrData
protected

Number of platform positions.

See also
_data

Definition at line 116 of file PlatformPosition.h.

Referenced by Clear(), getData(), getNbrData(), InitAuxiliaryData(), InitData(), Interpolate(), loadState(), operator=(), PlatformPosition(), and saveState().

◆ _p

double** ossimplugins::PlatformPosition::_p
private

Definition at line 130 of file PlatformPosition.h.

Referenced by Clear(), and InitAuxiliaryData().

◆ _t

double* ossimplugins::PlatformPosition::_t
private

Definition at line 129 of file PlatformPosition.h.

Referenced by Clear(), and InitAuxiliaryData().


The documentation for this class was generated from the following files: