Isis 3 Programmer Reference
LightTimeCorrectionState.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "LightTimeCorrectionState.h"
8
9#include <cfloat>
10#include <iomanip>
11
12#include <string>
13#include <vector>
14
15#include <QString>
16
17#include <SpiceZdf.h>
18
19#include "IException.h"
20#include "IString.h"
21#include "Kernels.h"
22#include "Pvl.h"
23#include "PvlGroup.h"
24#include "NaifStatus.h"
25#include "Spice.h"
26
27namespace Isis {
28
45
46
67
68
79 const {
81 return (false);
82 }
84 return (false);
85 }
87 return (false);
88 }
89 return (true);
90 }
91
108 Spice *spice) {
109 try {
110 QString ikernKey = "INS" + toString(ikCode) + "_LIGHTTIME_CORRECTION";
111 QString abcorr = spice->getString(ikernKey);
112 m_abcorr = abcorr;
113 return (true);
114 }
115 catch (IException &ie) {
116 // Keyword not found or error encountered - ignore
117 }
118 return (false);
119 }
120
121
134 void LightTimeCorrectionState::setAberrationCorrection(const QString &correction) {
135 m_abcorr = correction;
136 return;
137 }
138
139
148 return (m_abcorr);
149 }
150
151
174 // Determine loaded-only kernels. Our search is restricted to only
175 // kernels that are loaded and, currently, only of SPK type is of
176 // interest.
177 Kernels kernels;
178 kernels.Discover();
179
180 // Init the tag to Qt QString for effective searching
181 QString qtag("ID:USGS_SPK_ABCORR");
182 QString abcorr("");
183
184 // Retrieve list of loaded SPKs from Kernel object
185 QStringList spks = kernels.getKernelList("SPK");
187 for ( int k = 0 ; k < spks.size() ; k++ ) {
188 QString spkFile = spks[k];
189 SpiceChar ktype[32];
190 SpiceChar source[128];
191 SpiceInt handle;
192 SpiceBoolean found;
193 // Get info on SPK kernel mainly the NAIF handle for comment parsing
194 (void) kinfo_c(spkFile.toLatin1().data(), sizeof(ktype), sizeof(source), ktype,
195 source, &handle, &found);
196 if (found == SPICETRUE) {
197 // SPK is open so read and parse all the comments.
198 SpiceChar commnt[1001];
199 SpiceBoolean done(SPICEFALSE);
200 SpiceInt n;
201
202 // NOTE it is specially important to read all comments so this routine
203 // is reentrant! NAIF will automatically reset the pointer to the
204 // first comment line when and only when the last comment line is
205 // read. This is not apparent in the NAIF documentation.
206 while ( !done ) {
207 dafec_c(handle, 1, sizeof(commnt), &n, commnt, &done);
208 QString cmmt(commnt);
209 int pos = 0;
210 if ( (pos = cmmt.indexOf(qtag, pos, Qt::CaseInsensitive)) != -1 ) {
211 // We can put more effort into this when the need arises and
212 // we have a better handle on options.
213 abcorr = "NONE";
214 }
215 }
216 // Don't need to read any more kernel comments if we found one with
217 // the tag in it.
218 if ( !abcorr.isEmpty() ) break;
219 }
220 }
222
223 // Set internal state only if it was found in the kernels, otherwise the
224 // existing state is preserved.
225 if (!abcorr.isEmpty()) { m_abcorr = abcorr; }
226 return (!abcorr.isEmpty());
227 }
228
231 return ("NONE" != m_abcorr);
232 }
233
234
255 Spice *spice) {
256
257 try {
258 QString ikernKey = "INS" + toString(ikCode) + "_SWAP_OBSERVER_TARGET";
259 QString value = spice->getString(ikernKey).toUpper();
260 m_swapObserverTarget = ("TRUE" == value);
261 }
262 catch (IException &ie) {
263 // Not there is a false condition
264 m_swapObserverTarget = false;
265 }
266
267 return (m_swapObserverTarget);
268 }
269
270
273 return (m_swapObserverTarget);
274 }
275
278 m_swapObserverTarget = true;
279 }
280
283 m_swapObserverTarget = false;
284 }
285
286
307 Spice *spice) {
308
309 try {
310 QString ikernKey = "INS" + toString(ikCode) + "_LT_SURFACE_CORRECT";
311 QString value = spice->getString(ikernKey).toUpper();
312 m_sc_to_surf_ltcorr = ("TRUE" == value);
313 }
314 catch (IException &ie) {
315 // Not there is a false condition
316 m_sc_to_surf_ltcorr = false;
317 }
318
319 return (m_sc_to_surf_ltcorr);
320 }
321
324 return (m_sc_to_surf_ltcorr);
325 }
326
329 m_sc_to_surf_ltcorr = true;
330 }
331
335 m_sc_to_surf_ltcorr = false;
336 }
337
338
350 m_abcorr = "LT+S";
351 m_swapObserverTarget = false;
352 m_sc_to_surf_ltcorr = false;
353 return;
354 }
355
356
357} // namespace Isis
Isis exception class.
Definition IException.h:91
Determine SPICE kernels defined in an ISIS file.
Definition Kernels.h:94
int Discover()
Determine which NAIF kernels are currently loaded in the pool.
Definition Kernels.cpp:235
QStringList getKernelList(const QString &ktype="") const
Provide a list of all the kernels found.
Definition Kernels.cpp:672
Provides interface to user configurable Light Time correction feature.
void setCorrectLightTimeToSurface()
Sets state of light time from surface to center body for orrection.
bool checkObserverTargetSwap(int ikCode, Spice *spice)
Check status of target/observer swap specification.
void setSwapObserverTarget()
Turns on swapping of observer/target
bool checkSpkKernelsForAberrationCorrection()
Check for light time/stellar aberration tag in SPK comments.
bool isLightTimeToSurfaceCorrected() const
Returns state of light time from surface to center body correction.
bool checkLightTimeToSurfaceCorrect(int ikCode, Spice *spice)
Determines state of surface to s/c light time correction.
void setDefaultState()
Set default conditions for light time correction state.
bool checkAberrationCorrection(int ikCode, Spice *spice)
Apply instrument (team) specific light time/stellar aborration option.
QString getAberrationCorrection() const
Returns the value of the current stellar aberration state.
void setAberrationCorrection(const QString &correction)
Sets the aberration correction directly.
bool isLightTimeCorrected() const
Is light time to target corrected?
void setNoCorrectLightTimeToSurface()
Disables state of light time from surface to center body for correction.
LightTimeCorrectionState()
Default constructor sets default state of light time corrections.
void setNoSwapObserverTarget()
Turns off swapping of observer/target (default)
bool isObserverTargetSwapped() const
Returns state swap observer/target
bool operator==(const LightTimeCorrectionState &state) const
Compare two instances of the LightTimeCorrectionState objects.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Obtain SPICE information for a spacecraft.
Definition Spice.h:283
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1273
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211