USGS

Isis 3.0 Object Programmers' Reference

Home

LightTimeCorrectionState.cpp
Go to the documentation of this file.
1 
23 
24 #include <cfloat>
25 #include <iomanip>
26 
27 #include <string>
28 #include <vector>
29 
30 #include <QString>
31 
32 #include <SpiceZdf.h>
33 
34 #include "IException.h"
35 #include "IString.h"
36 #include "Kernels.h"
37 #include "Pvl.h"
38 #include "PvlGroup.h"
39 #include "NaifStatus.h"
40 #include "Spice.h"
41 
42 namespace Isis {
43 
59  }
60 
61 
76  Spice *spice) {
78  checkObserverTargetSwap(ikCode, spice);
79  checkAberrationCorrection(ikCode, spice);
80  checkLightTimeToSurfaceCorrect(ikCode, spice);
81  }
82 
83 
94  const {
96  return (false);
97  }
99  return (false);
100  }
102  return (false);
103  }
104  return (true);
105  }
106 
123  Spice *spice) {
124  try {
125  QString ikernKey = "INS" + toString(ikCode) + "_LIGHTTIME_CORRECTION";
126  QString abcorr = spice->getString(ikernKey);
127  m_abcorr = abcorr;
128  return (true);
129  }
130  catch (IException &ie) {
131  // Keyword not found or error encountered - ignore
132  }
133  return (false);
134  }
135 
136 
149  void LightTimeCorrectionState::setAberrationCorrection(const QString &correction) {
150  m_abcorr = correction;
151  return;
152  }
153 
154 
163  return (m_abcorr);
164  }
165 
166 
189  // Determine loaded-only kernels. Our search is restricted to only
190  // kernels that are loaded and, currently, only of SPK type is of
191  // interest.
192  Kernels kernels;
193  kernels.Discover();
194 
195  // Init the tag to Qt QString for effective searching
196  QString qtag("ID:USGS_SPK_ABCORR");
197  QString abcorr("");
198 
199  // Retrieve list of loaded SPKs from Kernel object
200  QStringList spks = kernels.getKernelList("SPK");
201  for ( int k = 0 ; k < spks.size() ; k++ ) {
202  QString spkFile = spks[k];
203  SpiceChar ktype[32];
204  SpiceChar source[128];
205  SpiceInt handle;
206  SpiceBoolean found;
207  // Get info on SPK kernel mainly the NAIF handle for comment parsing
208  (void) kinfo_c(spkFile.toAscii().data(), sizeof(ktype), sizeof(source), ktype,
209  source, &handle, &found);
210  if (found == SPICETRUE) {
211  // SPK is open so read and parse all the comments.
212  SpiceChar commnt[1001];
213  SpiceBoolean done(SPICEFALSE);
214  SpiceInt n;
215 
216  // NOTE it is specially important to read all comments so this routine
217  // is reentrant! NAIF will automatically reset the pointer to the
218  // first comment line when and only when the last comment line is
219  // read. This is not apparent in the NAIF documentation.
220  while ( !done ) {
221  dafec_c(handle, 1, sizeof(commnt), &n, commnt, &done);
222  QString cmmt(commnt);
223  int pos = 0;
224  if ( (pos = cmmt.indexOf(qtag, pos, Qt::CaseInsensitive)) != -1 ) {
225  // We can put more effort into this when the need arises and
226  // we have a better handle on options.
227  abcorr = "NONE";
228  }
229  }
230  // Don't need to read any more kernel comments if we found one with
231  // the tag in it.
232  if ( !abcorr.isEmpty() ) break;
233  }
234  }
235 
236  // Set internal state only if it was found in the kernels, otherwise the
237  // existing state is preserved.
238  if (!abcorr.isEmpty()) { m_abcorr = abcorr; }
239  return (!abcorr.isEmpty());
240  }
241 
244  return ("NONE" != m_abcorr);
245  }
246 
247 
268  Spice *spice) {
269 
270  try {
271  QString ikernKey = "INS" + toString(ikCode) + "_SWAP_OBSERVER_TARGET";
272  QString value = spice->getString(ikernKey).toUpper();
273  m_swapObserverTarget = ("TRUE" == value);
274  }
275  catch (IException &ie) {
276  // Not there is a false condition
277  m_swapObserverTarget = false;
278  }
279 
280  return (m_swapObserverTarget);
281  }
282 
283 
286  return (m_swapObserverTarget);
287  }
288 
291  m_swapObserverTarget = true;
292  }
293 
296  m_swapObserverTarget = false;
297  }
298 
299 
320  Spice *spice) {
321 
322  try {
323  QString ikernKey = "INS" + toString(ikCode) + "_LT_SURFACE_CORRECT";
324  QString value = spice->getString(ikernKey).toUpper();
325  m_sc_to_surf_ltcorr = ("TRUE" == value);
326  }
327  catch (IException &ie) {
328  // Not there is a false condition
329  m_sc_to_surf_ltcorr = false;
330  }
331 
332  return (m_sc_to_surf_ltcorr);
333  }
334 
337  return (m_sc_to_surf_ltcorr);
338  }
339 
342  m_sc_to_surf_ltcorr = true;
343  }
344 
348  m_sc_to_surf_ltcorr = false;
349  }
350 
351 
363  m_abcorr = "LT+S";
364  m_swapObserverTarget = false;
365  m_sc_to_surf_ltcorr = false;
366  return;
367  }
368 
369 
370 } // namespace Isis