OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
SensorParams.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/SensorParams.h>
14 #include <ossim/base/ossimString.h>
15 
16 namespace ossimplugins
17 {
18 
19 
20 static const char PREFIX[] = "sensor_params.";
21 static const char PRF_KW[] = "prf";
22 static const char SF_KW[] = "sampling_frequency";
23 static const char RWL_KW[] = "radar_wave_length";
24 static const char COL_DIR_KW[] = "column_direction";
25 static const char LIN_DIR_KW[] = "line_direction";
26 static const char SIGHT_DIR_KW[] = "sight_direction";
27 static const char SEMI_MAJOR_AXIS_KW[] = "semi_major_axis";
28 static const char SEMI_MINOR_AXIS_KW[] = "semi_minor_axis";
29 static const char NUM_AZIMUTH_LOOKS_KW[] = "number_azimuth_looks";
30 static const char NUM_RANGE_LOOKS_KW[] = "number_range_looks";
31 static const char DOPCEN_KW[] = "doppler_centroid";
32 static const char DOPCENLINEAR_KW[] = "doppler_centroid_linear_term";
33 static const char RANGETOFIRSTDATA_KW[] = "range_to_first_data_sample";
34 
36  _prf(0.0),
37  _sf(0.0),
38  _rwl(0.0),
39  _col_direction(1),
40  _lin_direction(1),
41  _sightDirection(Right),
42  _semiMajorAxis(6378137.0),
43  _semiMinorAxis(6356752.3141),
44  _nAzimuthLook(1),
45  _nRangeLook(1),
46  _dopcen(0.0),
47  _dopcenLinear(0.0)
48 {
49 }
50 
52 {
53 }
54 
56  _prf(rhs._prf),
57  _sf(rhs._sf),
58  _rwl(rhs._rwl),
59  _col_direction(rhs._col_direction),
60  _lin_direction(rhs._lin_direction),
61  _sightDirection(rhs._sightDirection),
62  _semiMajorAxis(rhs._semiMajorAxis),
63  _semiMinorAxis(rhs._semiMinorAxis),
64  _nAzimuthLook(rhs._nAzimuthLook),
65  _nRangeLook(rhs._nRangeLook),
66  _dopcen(rhs._dopcen),
67  _dopcenLinear(rhs._dopcenLinear)
68 {
69 }
70 
72 {
73  _prf = rhs._prf;
74  _sf = rhs._sf;
75  _rwl = rhs._rwl;
85  _dopcen = rhs._dopcen;
87  return *this;
88 }
89 
90 bool SensorParams::saveState(ossimKeywordlist& kwl, const char* prefix) const
91 {
92  std::string pfx;
93  if (prefix)
94  {
95  pfx = prefix;
96  }
97  pfx += PREFIX;
98 
99  kwl.add(pfx.c_str(), PRF_KW, _prf);
100  kwl.add(pfx.c_str(), SF_KW, _sf);
101  kwl.add(pfx.c_str(), RWL_KW, _rwl);
102  kwl.add(pfx.c_str(), COL_DIR_KW, _col_direction);
103  kwl.add(pfx.c_str(), LIN_DIR_KW, _lin_direction);
104  kwl.add(pfx.c_str(), SIGHT_DIR_KW, static_cast<int>(_sightDirection));
105  kwl.add(pfx.c_str(), SEMI_MAJOR_AXIS_KW, _semiMajorAxis);
106  kwl.add(pfx.c_str(), SEMI_MINOR_AXIS_KW, _semiMinorAxis);
107  kwl.add(pfx.c_str(), NUM_AZIMUTH_LOOKS_KW, _nAzimuthLook);
108  kwl.add(pfx.c_str(), NUM_RANGE_LOOKS_KW, _nRangeLook);
109  kwl.add(pfx.c_str(), DOPCEN_KW, _dopcen);
110  kwl.add(pfx.c_str(), DOPCENLINEAR_KW, _dopcenLinear);
111  return true;
112 }
113 
114 bool SensorParams::loadState(const ossimKeywordlist& kwl, const char* prefix)
115 {
116  bool result = true;
117 
118  std::string pfx;
119  if (prefix)
120  {
121  pfx = prefix;
122  }
123  pfx += PREFIX;
124 
125  ossimString s;
126  const char* lookup = 0;
127 
128  lookup = kwl.find(pfx.c_str(), PRF_KW);
129  if (lookup)
130  {
131  s = lookup;
132  _prf = s.toDouble();
133  }
134  else
135  {
136  result = false;
137  }
138 
139  lookup = kwl.find(pfx.c_str(), SF_KW);
140  if (lookup)
141  {
142  s = lookup;
143  _sf = s.toDouble();
144  }
145  else
146  {
147  result = false;
148  }
149 
150  lookup = kwl.find(pfx.c_str(), RWL_KW);
151  if (lookup)
152  {
153  s = lookup;
154  _rwl = s.toDouble();
155  }
156  else
157  {
158  result = false;
159  }
160 
161  lookup = kwl.find(pfx.c_str(), COL_DIR_KW);
162  if (lookup)
163  {
164  s = lookup;
165  _col_direction = s.toInt();
166  }
167  else
168  {
169  result = false;
170  }
171 
172  lookup = kwl.find(pfx.c_str(), LIN_DIR_KW);
173  if (lookup)
174  {
175  s = lookup;
176  _lin_direction = s.toInt();
177  }
178  else
179  {
180  result = false;
181  }
182 
183  lookup = kwl.find(pfx.c_str(), SIGHT_DIR_KW);
184  if (lookup)
185  {
186  s = lookup;
187  if ( s.toInt() == 0 )
188  {
190  }
191  else
192  {
194  }
195  }
196  else
197  {
198  result = false;
199  }
200 
201  lookup = kwl.find(pfx.c_str(), SEMI_MAJOR_AXIS_KW);
202  if (lookup)
203  {
204  s = lookup;
205  _semiMajorAxis = s.toDouble();
206  }
207  else
208  {
209  result = false;
210  }
211 
212  lookup = kwl.find(pfx.c_str(), SEMI_MINOR_AXIS_KW);
213  if (lookup)
214  {
215  s = lookup;
216  _semiMinorAxis = s.toDouble();
217  }
218  else
219  {
220  result = false;
221  }
222 
223  lookup = kwl.find(pfx.c_str(), NUM_AZIMUTH_LOOKS_KW);
224  if (lookup)
225  {
226  s = lookup;
227  _nAzimuthLook = s.toDouble();
228  }
229  else
230  {
231  result = false;
232  }
233 
234  lookup = kwl.find(pfx.c_str(), NUM_RANGE_LOOKS_KW);
235  if (lookup)
236  {
237  s = lookup;
238  _nRangeLook = s.toDouble();
239  }
240  else
241  {
242  result = false;
243  }
244 
245  lookup = kwl.find(pfx.c_str(), DOPCEN_KW);
246  if (lookup)
247  {
248  s = lookup;
249  _dopcen = s.toDouble();
250  }
251  else
252  {
253  result = false;
254  }
255  return result;
256 
257  lookup = kwl.find(pfx.c_str(), DOPCENLINEAR_KW);
258  if (lookup)
259  {
260  s = lookup;
261  _dopcenLinear = s.toDouble();
262  }
263  else
264  {
265  result = false;
266  }
267  return result;
268 
269 }
270 
271 }
double _prf
Nominal PRF, Hz.
Definition: SensorParams.h:203
virtual ~SensorParams()
Destructor.
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of the object from a keyword list.
Represents serializable keyword/value map.
SightDirection _sightDirection
Antenna pointing direction.
Definition: SensorParams.h:228
const char * find(const char *key) const
double _dopcen
Doppler centroid (at range 0)
Definition: SensorParams.h:255
This class handles the sensor parameters.
Definition: SensorParams.h:29
int _col_direction
Columns direction (1=increasing, -1=decreasing)
Definition: SensorParams.h:218
double _nAzimuthLook
Number of azimuth looks.
Definition: SensorParams.h:245
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
int _lin_direction
Lines direction (1=increasing, -1=decreasing)
Definition: SensorParams.h:223
bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save object state to a keyword list.
double toDouble() const
double _nRangeLook
Number of range looks.
Definition: SensorParams.h:250
double _sf
Sampling frequency.
Definition: SensorParams.h:208
double _semiMinorAxis
Ellipsoid semi_minor axis, m Default : WGS84.
Definition: SensorParams.h:240
SensorParams & operator=(const SensorParams &rhs)
Affectation operator.
double _semiMajorAxis
Ellipsoid semi_major axis, m Default : WGS84.
Definition: SensorParams.h:234
double _dopcenLinear
Doppler centroid linear term (wrt range in km)
Definition: SensorParams.h:260
double _rwl
Radar wave length.
Definition: SensorParams.h:213
int toInt() const