diff --git a/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp b/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp index 7479f9cfe2..f0855d7566 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp @@ -531,11 +531,29 @@ bool HorizonsDialog::isValidInput() { isValid = false; message = "Step size not selected"; } - // In the case of arcseconds, first option - else if (_timeTypeCombo->currentIndex() == 0) { - if (60 > _stepEdit->text().toInt() || _stepEdit->text().toInt() > 3600) { + // Check if input is numerical + bool couldConvert = false; + int32_t step = _stepEdit->text().toInt(&couldConvert); + if (!couldConvert) { + isValid = false; + message = "Step size needs to be a number in range 1 to " + + std::to_string(std::numeric_limits::max()); + } + else { + // In the case of arcseconds (first option) range is different + if (_timeTypeCombo->currentIndex() == 0) { + if (60 > step || step > 3600) { + isValid = false; + message = "Angular step size needs to be in range 60 to 3600"; + } + } + // Numbers only and in range 1 to 2147483647 (max of 32 bit int) + // Horizons read the step size into a 32 bit int, but verifies the input on their + // website as a uint32_t. If step size over 32 bit int is sent, this error + // message is recived: Cannot read numeric value -- re-enter + else if (1 > step || step > std::numeric_limits::max()) { isValid = false; - message = "Angular step size need to be in range 60 to 3600"; + message = "Step size is outside valid range 1 to " + std::to_string(std::numeric_limits::max()); } } @@ -784,6 +802,13 @@ bool HorizonsDialog::handleResult(openspace::HorizonsFile::HorizonsResult& resul break; } + case openspace::HorizonsFile::HorizonsResult::ErrorSpan: + appendLog( + "Step size is too big, exceeds available time span for target", + HorizonsDialog::LogLevel::Error + ); + break; + case openspace::HorizonsFile::HorizonsResult::ErrorTimeRange: { appendLog("Time range is outside the valid range for target '" + _targetName + "'.", HorizonsDialog::LogLevel::Error); diff --git a/modules/space/horizonsfile.cpp b/modules/space/horizonsfile.cpp index 70ea3b144c..e21995855e 100644 --- a/modules/space/horizonsfile.cpp +++ b/modules/space/horizonsfile.cpp @@ -66,6 +66,10 @@ HorizonsFile::HorizonsResult HorizonsFile::isValidAnswer(const json& answer) { if (errorMessage.find("Projected output length") != std::string::npos) { return HorizonsFile::HorizonsResult::ErrorSize; } + // STEP_SIZE too big, exceeds available span. + else if (errorMessage.find("STEP_SIZE too big") != std::string::npos) { + return HorizonsFile::HorizonsResult::ErrorSpan; + } // No ephemeris for target "X" after A.D. Y UT else if (errorMessage.find("No ephemeris for target") != std::string::npos) { return HorizonsFile::HorizonsResult::ErrorTimeRange; @@ -125,6 +129,12 @@ HorizonsFile::HorizonsResult HorizonsFile::isValidHorizonsFile() const { return HorizonsFile::HorizonsResult::ErrorSize; } + // Selected time range too big for avalable time span? + if (line.find("STEP_SIZE too big") != std::string::npos) { + fileStream.close(); + return HorizonsFile::HorizonsResult::ErrorSpan; + } + // Outside valid time range? if (line.find("No ephemeris for target") != std::string::npos) { // Available time range is located several lines before this in the file diff --git a/modules/space/horizonsfile.h b/modules/space/horizonsfile.h index dc70e2e718..c41c1bdf1b 100644 --- a/modules/space/horizonsfile.h +++ b/modules/space/horizonsfile.h @@ -55,6 +55,7 @@ public: // Erros caught by the error field in the json output ErrorSize, + ErrorSpan, ErrorTimeRange, ErrorNoObserver, ErrorObserverTargetSame,