Isis 3 Programmer Reference
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");
202  for ( int k = 0 ; k < spks.size() ; k++ ) {
203  QString spkFile = spks[k];
204  SpiceChar ktype[32];
205  SpiceChar source[128];
206  SpiceInt handle;
207  SpiceBoolean found;
208  // Get info on SPK kernel mainly the NAIF handle for comment parsing
209  (void) kinfo_c(spkFile.toLatin1().data(), sizeof(ktype), sizeof(source), ktype,
210  source, &handle, &found);
211  if (found == SPICETRUE) {
212  // SPK is open so read and parse all the comments.
213  SpiceChar commnt[1001];
214  SpiceBoolean done(SPICEFALSE);
215  SpiceInt n;
216 
217  // NOTE it is specially important to read all comments so this routine
218  // is reentrant! NAIF will automatically reset the pointer to the
219  // first comment line when and only when the last comment line is
220  // read. This is not apparent in the NAIF documentation.
221  while ( !done ) {
222  dafec_c(handle, 1, sizeof(commnt), &n, commnt, &done);
223  QString cmmt(commnt);
224  int pos = 0;
225  if ( (pos = cmmt.indexOf(qtag, pos, Qt::CaseInsensitive)) != -1 ) {
226  // We can put more effort into this when the need arises and
227  // we have a better handle on options.
228  abcorr = "NONE";
229  }
230  }
231  // Don't need to read any more kernel comments if we found one with
232  // the tag in it.
233  if ( !abcorr.isEmpty() ) break;
234  }
235  }
237 
238  // Set internal state only if it was found in the kernels, otherwise the
239  // existing state is preserved.
240  if (!abcorr.isEmpty()) { m_abcorr = abcorr; }
241  return (!abcorr.isEmpty());
242  }
243 
246  return ("NONE" != m_abcorr);
247  }
248 
249 
270  Spice *spice) {
271 
272  try {
273  QString ikernKey = "INS" + toString(ikCode) + "_SWAP_OBSERVER_TARGET";
274  QString value = spice->getString(ikernKey).toUpper();
275  m_swapObserverTarget = ("TRUE" == value);
276  }
277  catch (IException &ie) {
278  // Not there is a false condition
279  m_swapObserverTarget = false;
280  }
281 
282  return (m_swapObserverTarget);
283  }
284 
285 
288  return (m_swapObserverTarget);
289  }
290 
293  m_swapObserverTarget = true;
294  }
295 
298  m_swapObserverTarget = false;
299  }
300 
301 
322  Spice *spice) {
323 
324  try {
325  QString ikernKey = "INS" + toString(ikCode) + "_LT_SURFACE_CORRECT";
326  QString value = spice->getString(ikernKey).toUpper();
327  m_sc_to_surf_ltcorr = ("TRUE" == value);
328  }
329  catch (IException &ie) {
330  // Not there is a false condition
331  m_sc_to_surf_ltcorr = false;
332  }
333 
334  return (m_sc_to_surf_ltcorr);
335  }
336 
339  return (m_sc_to_surf_ltcorr);
340  }
341 
344  m_sc_to_surf_ltcorr = true;
345  }
346 
350  m_sc_to_surf_ltcorr = false;
351  }
352 
353 
365  m_abcorr = "LT+S";
366  m_swapObserverTarget = false;
367  m_sc_to_surf_ltcorr = false;
368  return;
369  }
370 
371 
372 } // namespace Isis
bool checkLightTimeToSurfaceCorrect(int ikCode, Spice *spice)
Determines state of surface to s/c light time correction.
LightTimeCorrectionState()
Default constructor sets default state of light time corrections.
QStringList getKernelList(const QString &ktype="") const
Provide a list of all the kernels found.
Definition: Kernels.cpp:689
void setAberrationCorrection(const QString &correction)
Sets the aberration correction directly.
Provides interface to user configurable Light Time correction feature.
bool checkAberrationCorrection(int ikCode, Spice *spice)
Apply instrument (team) specific light time/stellar aborration option.
bool isObserverTargetSwapped() const
Returns state swap observer/target.
Determine SPICE kernels defined in an ISIS file.
Definition: Kernels.h:111
QString getAberrationCorrection() const
Returns the value of the current stellar aberration state.
void setNoSwapObserverTarget()
Turns off swapping of observer/target (default)
bool checkObserverTargetSwap(int ikCode, Spice *spice)
Check status of target/observer swap specification.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
bool isLightTimeToSurfaceCorrected() const
Returns state of light time from surface to center body correction.
int Discover()
Determine which NAIF kernels are currently loaded in the pool.
Definition: Kernels.cpp:252
void setNoCorrectLightTimeToSurface()
Disables state of light time from surface to center body for correction.
bool operator==(const LightTimeCorrectionState &state) const
Compare two instances of the LightTimeCorrectionState objects.
void setCorrectLightTimeToSurface()
Sets state of light time from surface to center body for orrection.
void setDefaultState()
Set default conditions for light time correction state.
bool checkSpkKernelsForAberrationCorrection()
Check for light time/stellar aberration tag in SPK comments.
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1185
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool isLightTimeCorrected() const
Is light time to target corrected?
Obtain SPICE information for a spacecraft.
Definition: Spice.h:294
void setSwapObserverTarget()
Turns on swapping of observer/target.