Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dependencies:
- qhull
- qt-main>=5.15, <5.16
- qwt <6.3.0
- spiceql >=1.2.0
- spiceql >=1.2.1
- sqlite >=3.46.0,<3.47
- suitesparse <7.7.0
- superlu
Expand Down
2 changes: 1 addition & 1 deletion environment_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies:
- qhull
- qt-main>=5.15, <5.16
- qwt <6.3.0
- spiceql >=1.2.0
- spiceql >=1.2.1
- sqlite >=3.46.0,<3.47
- suitesparse <7.7.0
- superlu
Expand Down
2 changes: 1 addition & 1 deletion environment_gcc4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies:
- qhull
- qt=5.9.6
- qwt=6.1.3
- spiceql >=1.2.0
- spiceql >=1.2.1
- sqlite
- suitesparse
- superlu
Expand Down
30 changes: 15 additions & 15 deletions isis/src/apollo/apps/apollopaninit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,22 @@ void IsisMain() {


//////////////////////////////////////////attach a target rotation table
bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
bool useWeb = Preference::Preferences().useWebSpice();
std::string frameName;
SpiceInt frameCode = 0;
try {
auto [output, kernels] = SpiceQL::getTargetFrameInfo(301, mission.toLower().toStdString(), useWeb);
cout << output << endl;
frameCode = output["frameCode"].get<SpiceInt>();
frameName = output["frameName"].get<std::string>();
} catch(std::invalid_argument) {
std::string naifTarget = "IAU_MOON";
auto [frameCode, kernels] = SpiceQL::translateNameToCode(naifTarget, mission.toLower().toStdString(), useWeb);
if(frameCode == 0) {
QString msg = "Can not find NAIF code for [" + QString::fromStdString(naifTarget) + "]";
throw IException(IException::Io, msg, _FILEINFO_);
}
}
SpiceInt frameCode = 0;
try {
auto [output, kernels] = SpiceQL::getTargetFrameInfo(301, mission.toLower().toStdString(), useWeb);
cout << output << endl;
frameCode = output["frameCode"].get<SpiceInt>();
frameName = output["frameName"].get<std::string>();
} catch(std::invalid_argument) {
std::string naifTarget = "IAU_MOON";
auto [frameCode, kernels] = SpiceQL::translateNameToCode(naifTarget, mission.toLower().toStdString(), useWeb);
if(frameCode == 0) {
QString msg = "Can not find NAIF code for [" + QString::fromStdString(naifTarget) + "]";
throw IException(IException::Io, msg, _FILEINFO_);
}
}


spRot = new SpiceRotation(frameCode);
Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/apps/appjit/LineScanCameraRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace Isis {

std::vector<ale::Rotation> rotationCache;

bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
bool useWeb = Preference::Preferences().useWebSpice();
auto [sunLt, kernels] = SpiceQL::getTargetStates(p_cacheTime, "MRO", "mars", "IAU_MARS", "NONE", "mro", {"reconstructed"}, {"reconstructed"}, useWeb);

double state[6];
Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/apps/shadow/shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace Isis {
userKernels = true;
}

bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
bool useWeb = Preference::Preferences().useWebSpice();

if (userKernels) {
auto [output, kernels] = SpiceQL::getTargetStates(etStart, "sun", observer, bff, "NONE", "base", {"reconstructed"}, {"reconstructed"}, useWeb, true);
Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/apps/spiceinit/spiceinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,4 +718,4 @@ namespace Isis {
delete sunPosTable;
sunPosTable = NULL;
}
}
}
4 changes: 4 additions & 0 deletions isis/src/base/objs/Preference/Preference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ namespace Isis {
return checkIfPrefEquals("ErrorFacility", "StackTrace", "Off");
}

bool Preference::useWebSpice() {
return checkIfPrefEquals("WebSpice", "UseWebSpice", "true", false);
}

void Preference::Shutdown() {
if(p_preference) {
delete p_preference;
Expand Down
1 change: 1 addition & 0 deletions isis/src/base/objs/Preference/Preference.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace Isis {
bool outputErrorAsPvl();
bool getShowDeprecatedPref();
bool getStackTracePref();
bool useWebSpice();

static Preference &Preferences(bool unitTest = false);

Expand Down
30 changes: 15 additions & 15 deletions isis/src/base/objs/RestfulSpice/RestfulSpice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@


// std::vector<std::vector<double>> getTargetStates(std::vector<double> ets, std::string target, std::string observer, std::string frame, std::string abcorr, std::string mission, std::string ckQuality, std::string spkQuality, std::vector<std::string> kernel_list){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// // @TODO validity checks
// json args = json::object({
Expand All @@ -129,7 +129,7 @@


// std::vector<std::vector<double>> getTargetOrientations(std::vector<double> ets, int toFrame, int refFrame, std::string mission, std::string ckQuality) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"ets", ets},
Expand All @@ -146,7 +146,7 @@
// }

// double strSclkToEt(int frameCode, std::string sclk, std::string mission) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"frameCode", frameCode},
Expand All @@ -161,7 +161,7 @@
// }

// double doubleSclkToEt(int frameCode, double sclk, std::string mission){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"frameCode", frameCode},
Expand All @@ -176,7 +176,7 @@
// }

// double utcToEt(std::string utc){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"utc", utc}
Expand All @@ -191,7 +191,7 @@


// std::string etToUtc(double et, std::string format, double precision){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// // TODO Add etToUtc to web api
// if (useWeb){
// json args = json::object({
Expand All @@ -207,7 +207,7 @@
// }

// std::string doubleEtToSclk(int frameCode, double et, std::string mission) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"frameCode", frameCode},
Expand All @@ -223,7 +223,7 @@
// }

// int translateNameToCode(std::string frame, std::string mission){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"frame", frame},
Expand All @@ -237,7 +237,7 @@
// }

// std::string translateCodeToName(int code, std::string mission){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"code", code},
Expand All @@ -251,7 +251,7 @@
// }

// std::vector<int> getFrameInfo(int frame, std::string mission) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"frame", frame},
Expand All @@ -266,7 +266,7 @@
// }

// json getTargetFrameInfo(int targetId, std::string mission) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"targetId", targetId},
Expand All @@ -280,7 +280,7 @@
// }

// json findMissionKeywords(std::string key, std::string mission){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"key", key},
Expand All @@ -294,7 +294,7 @@
// }

// json findTargetKeywords(std::string key, std::string mission){
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"key", key},
Expand All @@ -308,7 +308,7 @@
// }

// std::vector<std::vector<int>> frameTrace(double et, int initialFrame, std::string mission, std::string ckQuality) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"et", et},
Expand All @@ -324,7 +324,7 @@
// }

// std::vector<double> extractExactCkTimes(double observStart, double observEnd, int targetFrame, std::string mission, std::string ckQuality) {
// bool useWeb = QString(Preference::Preferences().findGroup("WebSpice")["UseWebSpice"]).toUpper() == "TRUE";
// bool useWeb = Preference::Preferences().useWebSpice();
// if (useWeb){
// json args = json::object({
// {"observStart", observStart},
Expand Down
25 changes: 13 additions & 12 deletions isis/src/base/objs/Spice/Spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ using json = nlohmann::json;
#include "Target.h"
#include "Blob.h"
#include "spiceql.h"
#include "Preference.h"

using namespace std;

Expand Down Expand Up @@ -72,7 +73,7 @@ namespace Isis {

// BONUS TODO: update to pull out separate init methods
// try using ALE
bool hasTables = (kernels["TargetPosition"][0] == "Table");
bool hasTables = (kernels.hasKeyword("TargetPosition") && !kernels["TargetPosition"].isNull() && kernels["TargetPosition"][0] == "Table");
m_usingNaif = !lab.hasObject("NaifKeywords") || !hasTables;
m_usingAle = false;

Expand All @@ -82,13 +83,13 @@ namespace Isis {
kernel_pvl << kernels;

json props;
if (kernels["InstrumentPointing"][0].toUpper() == "NADIR") {
if (kernels.hasKeyword("InstrumentPointing") && !kernels["InstrumentPointing"].isNull() && kernels["InstrumentPointing"][0].toUpper() == "NADIR") {
props["nadir"] = true;
}
props["web"] = true;
// props["kernels"] = kernel_pvl.str();

props["kernels"] = kernel_pvl.str();

json isd = ale::load(lab.fileName().toStdString(), props.dump(), "ale", false, false, true);
json isd = ale::load(lab.fileName().toStdString(), props.dump(), "ale", true, false, true);
m_usingAle = true;

isdInit(lab, isd);
Expand Down Expand Up @@ -132,9 +133,10 @@ namespace Isis {
m_bodyFrameCode = new SpiceInt;

m_naifKeywords = new PvlObject("NaifKeywords");

// Get the kernel group and load main kernels
PvlGroup kernels = lab.findGroup("Kernels", Pvl::Traverse);
m_mission_name = (QString)lab.findGroup("Instrument", Pvl::Traverse).findKeyword("SpacecraftName");

// Get the time padding first
if (kernels.hasKeyword("StartPadding")) {
Expand Down Expand Up @@ -293,7 +295,7 @@ namespace Isis {
// SpacecraftPosition. The old keywords were in existance before the
// Table option, so we don't need to check for Table under the old
// keywords.
if (kernels["InstrumentPointing"].size() == 0) {
if (!kernels["InstrumentPointing"].isNull() && kernels["InstrumentPointing"].size() == 0) {
throw IException(IException::Unknown,
"No camera pointing available",
_FILEINFO_);
Expand All @@ -306,7 +308,7 @@ namespace Isis {
}


if (kernels["InstrumentPosition"].size() == 0) {
if (!kernels["InstrumentPosition"].isNull() && kernels["InstrumentPosition"].size() == 0) {
throw IException(IException::Unknown,
"No instrument position available",
_FILEINFO_);
Expand Down Expand Up @@ -1245,15 +1247,14 @@ namespace Isis {
QVariant storedClockTime = getStoredResult(key, SpiceDoubleType);

if (storedClockTime.isNull()) {
bool useWeb = Preference::Preferences().useWebSpice();
SpiceDouble timeOutput;
NaifStatus::CheckErrors();
if (clockTicks) {
sct2e_c(sclkCode, (SpiceDouble) clockValue.toDouble(), &timeOutput);
timeOutput = SpiceQL::doubleSclkToEt(sclkCode, clockValue.toDouble(), m_mission_name.toStdString(), useWeb).first;
}
else {
scs2e_c(sclkCode, clockValue.toLatin1().data(), &timeOutput);
timeOutput = SpiceQL::strSclkToEt(sclkCode, clockValue.toLatin1().data(), m_mission_name.toStdString(), useWeb).first;
}
NaifStatus::CheckErrors();
storedClockTime = timeOutput;
storeResult(key, SpiceDoubleType, timeOutput);
}
Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/objs/Spice/Spice.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ namespace Isis {
SpiceInt *m_bodyFrameCode; /**< Naif's BODY_FRAME_CODE value. It is read
from the labels, if it exists. Otherwise,
it's calculated by the init() method.*/

QString m_mission_name;
PvlObject *m_naifKeywords; //!< NaifKeywords PvlObject from cube

bool m_usingNaif; /**< Indicates whether we are reading values from the
Expand Down
Loading