diff --git a/include/usgscsm/Distortion.h b/include/usgscsm/Distortion.h index 81867ac33e7b32be4e7e4bb44bf843d948a29eb1..6bda2cce65f11a5e83ad126abe39449257e1cb6f 100644 --- a/include/usgscsm/Distortion.h +++ b/include/usgscsm/Distortion.h @@ -6,7 +6,9 @@ #include <tuple> #include <vector> -enum DistortionType { RADIAL, TRANSVERSE, KAGUYALISM, DAWNFC, LROLROCNAC, CAHVOR, RADTAN }; +// This should be synched with the enum in ale/Distortion.h +enum DistortionType { RADIAL, TRANSVERSE, KAGUYALISM, DAWNFC, LROLROCNAC, CAHVOR, + LUNARORBITER, RADTAN }; // Transverse distortion Jacobian void transverseDistortionJacobian(double x, double y, double *jacobian, @@ -23,6 +25,7 @@ void removeDistortion(double dx, double dy, double &ux, double &uy, void applyDistortion(double ux, double uy, double &dx, double &dy, std::vector<double> const& opticalDistCoeffs, DistortionType distortionType, - const double desiredPrecision = 1.0E-6, + const double desiredPrecisio + n = 1.0E-6, const double tolerance = 1.0E-6); #endif // INCLUDE_USGSCSM_DISTORTION_H_ diff --git a/src/Utilities.cpp b/src/Utilities.cpp index f3463ff5e23f73dbefe6ba5ce9747a78572850b2..035d46060f25e9e4ea55e7b4e916166ffee9cdf9 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -1060,9 +1060,9 @@ double getSemiMinorRadius(json isd, csm::WarningList *list) { // type. Defaults to transverse DistortionType getDistortionModel(json isd, csm::WarningList *list) { try { - json distoriton_subset = isd.at("optical_distortion"); + json distortion_subset = isd.at("optical_distortion"); - json::iterator it = distoriton_subset.begin(); + json::iterator it = distortion_subset.begin(); std::string distortion = (std::string)it.key(); @@ -1076,6 +1076,12 @@ DistortionType getDistortionModel(json isd, csm::WarningList *list) { return DistortionType::DAWNFC; } else if (distortion.compare("lrolrocnac") == 0) { return DistortionType::LROLROCNAC; + } else if (distortion.compare("cahvor") == 0) { + return DistortionType::CAHVOR; + } else if (distortion.compare("lunarorbiter") == 0) { + return DistortionType::LUNARORBITER; + } else if (distortion.compare("radtan") == 0) { + return DistortionType::RADTAN; } } catch (...) { if (list) { @@ -1105,6 +1111,10 @@ DistortionType getDistortionModel(int aleDistortionModel, return DistortionType::LROLROCNAC; }else if (aleDistortionType == ale::DistortionType::CAHVOR) { return DistortionType::CAHVOR; + }else if (aleDistortionType == ale::DistortionType::LUNARORBITER) { + return DistortionType::LUNARORBITER; + }else if (aleDistortionType == ale::DistortionType::RADTAN) { + return DistortionType::RADTAN; } } catch (...) { if (list) { @@ -1263,7 +1273,26 @@ std::vector<double> getDistortionCoeffs(json isd, csm::WarningList *list) { coefficients = std::vector<double>(6, 0.0); } } break; + case DistortionType::RADTAN: { + try { + coefficients = isd.at("optical_distortion") + .at("radtan") + .at("coefficients") + .get<std::vector<double>>(); + + return coefficients; + } catch (...) { + if (list) { + list->push_back(csm::Warning( + csm::Warning::DATA_NOT_AVAILABLE, + "Could not parse the radtan distortion model coefficients.", + "Utilities::getDistortion()")); + } + coefficients = std::vector<double>(5, 0.0); + } + } break; } + if (list) { list->push_back( csm::Warning(csm::Warning::DATA_NOT_AVAILABLE,