OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
InfoSceneCoord.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 //
5 // License: LGPL
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 #include <otb/InfoSceneCoord.h>
13 #include <ossim/base/ossimDpt3d.h>
15 #include <ossim/base/ossimNotify.h>
16 #include <ossim/base/ossimString.h>
17 
18 namespace ossimplugins
19 {
20 
21 
22 static const char PREFIX[] = ".";
23 static const char REF_ROW[] = "refRow";
24 static const char REF_COLUMN[] = "refColumn";
25 static const char LAT[] = "lat";
26 static const char LON[] = "lon";
27 static const char AZIMUTH_TIME[] = "azimuthTimeUTC";
28 static const char RANGE_TIME[] = "rangeTime";
29 static const char INCIDENCE_ANGLE[] = "incidenceAngle";
30 
32  _refRow(0),
33  _refColumn(0),
34  _lat(0.0),
35  _lon(0.0),
36  _azimuthTimeUTC(),
37  _rangeTime(0.0),
38  _incidenceAngle(0.)
39 {
40 }
41 
43 {
44 }
45 
46 
48  _refRow(rhs._refRow),
49  _refColumn(rhs._refColumn),
50  _lat(rhs._lat),
51  _lon(rhs._lon),
52  _azimuthTimeUTC(rhs._azimuthTimeUTC),
53  _rangeTime(rhs._rangeTime),
54  _incidenceAngle(rhs._incidenceAngle)
55 {
56 }
57 
59 {
60  _refRow = rhs._refRow;
61  _refColumn = rhs._refColumn;
62  _lat = rhs._lat;
63  _lon = rhs._lon;
67  return *this;
68 }
69 
70 bool InfoSceneCoord::saveState(ossimKeywordlist& kwl, const char* prefix) const
71 {
72  std::string pfx;
73  if (prefix)
74  {
75  pfx = prefix;
76  }
77  pfx += PREFIX;
78  kwl.add(pfx.c_str(), REF_ROW, _refRow);
79  kwl.add(pfx.c_str(), REF_COLUMN, _refColumn);
80  kwl.add(pfx.c_str(), LAT, _lat);
81  kwl.add(pfx.c_str(), LON, _lon);
82  kwl.add(pfx.c_str(), AZIMUTH_TIME, _azimuthTimeUTC);
83  kwl.add(pfx.c_str(), RANGE_TIME, _rangeTime);
84  kwl.add(pfx.c_str(), INCIDENCE_ANGLE, _incidenceAngle);
85 
86  return true;
87 }
88 
89 bool InfoSceneCoord::loadState(const ossimKeywordlist& kwl, const char* prefix)
90 {
91  static const char MODULE[] = "InfoSceneCoord::loadState";
92  bool result = true;
93  std::string pfx;
94  if (prefix)
95  {
96  pfx = prefix;
97  }
98  ossimString s;
99  const char* lookup = 0;
100 
101  pfx += PREFIX;
102  lookup = kwl.find(pfx.c_str(), REF_ROW);
103  if (lookup)
104  {
105  s = lookup;
106  _refRow = s.toUInt32();
107  }
108  else
109  {
111  << MODULE << " Keyword not found: " << REF_ROW << " in "<<pfx.c_str()<<" path.\n";
112  result = false;
113  }
114 
115  lookup = kwl.find(pfx.c_str(), REF_COLUMN);
116  if (lookup)
117  {
118  s = lookup;
119  _refColumn = s.toUInt32();
120  }
121  else
122  {
124  << MODULE << " Keyword not found: " << REF_COLUMN << " in "<<pfx.c_str()<<" path.\n";
125  result = false;
126  }
127 
128  lookup = kwl.find(pfx.c_str(), LAT);
129  if (lookup)
130  {
131  s = lookup;
132  _lat = s.toDouble();
133  }
134  else
135  {
137  << MODULE << " Keyword not found: " << LAT << " in "<<pfx.c_str()<<" path.\n";
138  result = false;
139  }
140 
141  lookup = kwl.find(pfx.c_str(), LON);
142  if (lookup)
143  {
144  s = lookup;
145  _lon = s.toDouble();
146  }
147  else
148  {
150  << MODULE << " Keyword not found: " << LON << " in "<<pfx.c_str()<<" path.\n";
151  result = false;
152  }
153 
154  lookup = kwl.find(pfx.c_str(), AZIMUTH_TIME);
155  if (lookup)
156  {
157  s = lookup;
158  _azimuthTimeUTC = s;
159  }
160  else
161  {
163  << MODULE << " Keyword not found: " << AZIMUTH_TIME << " in "<<pfx.c_str()<<" path.\n";
164  result = false;
165  }
166 
167  lookup = kwl.find(pfx.c_str(), RANGE_TIME);
168  if (lookup)
169  {
170  s = lookup;
171  _rangeTime = s.toDouble();
172  }
173  else
174  {
176  << MODULE << " Keyword not found: " << RANGE_TIME << " in "<<pfx.c_str()<<" path.\n";
177  result = false;
178  }
179 
180  lookup = kwl.find(pfx.c_str(), INCIDENCE_ANGLE);
181  if (lookup)
182  {
183  s = lookup;
185  }
186  else
187  {
189  << MODULE << " Keyword not found: " << INCIDENCE_ANGLE << " in "<<pfx.c_str()<<" path.\n";
190  result = false;
191  }
192 
193  return result;
194 }
195 }
This class represents an InfoSceneCoord.
double _incidenceAngle
IncidenceAngle (incidenceAngle node).
Represents serializable keyword/value map.
virtual ~InfoSceneCoord()
Destructor.
const char * find(const char *key) const
ossim_uint32 toUInt32() const
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of the object from a keyword list.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimString _azimuthTimeUTC
azimuth time (azimuthTimeUTC node).
double toDouble() const
ossim_uint32 _refRow
Reference Row (refRow node).
ossim_uint32 _refColumn
Reference Column (refColumn node).
double _lon
Longitude (lon node).
double _lat
Latitude (lat node).
bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save object state to a keyword list.
double _rangeTime
range time (rangeTime node).
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
InfoSceneCoord & operator=(const InfoSceneCoord &rhs)
Affectation operator.