Skip to content

Commit

Permalink
Add radtan distortion (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov authored Nov 7, 2023
1 parent e1959ec commit d5571c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/ale/Distortion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace ale {
DAWNFC,
LROLROCNAC,
CAHVOR,
LUNARORBITER
LUNARORBITER,
RADTAN
};
}

Expand Down
20 changes: 18 additions & 2 deletions src/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ double getSemiMinorRadius(json isd) {
// type. Defaults to transverse
DistortionType getDistortionModel(json isd) {
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();

Expand All @@ -362,6 +362,8 @@ DistortionType getDistortionModel(json isd) {
return DistortionType::CAHVOR;
} else if (distortion.compare("lunarorbiter") == 0) {
return DistortionType::LUNARORBITER;
} else if (distortion.compare("radtan") == 0) {
return DistortionType::RADTAN;
}
} catch (...) {
throw std::runtime_error("Could not parse the distortion model.");
Expand Down Expand Up @@ -528,6 +530,20 @@ std::vector<double> getDistortionCoeffs(json isd) {
coefficients = std::vector<double>(4, 0.0);
}
} break;
case DistortionType::RADTAN: {
try {
coefficients = isd.at("optical_distortion")
.at("radtan")
.at("coefficients")
.get<std::vector<double>>();

return coefficients;
} catch (...) {
throw std::runtime_error(
"Could not parse the radtan distortion model coefficients.");
coefficients = std::vector<double>(5, 0.0);
}
} break;
}
throw std::runtime_error(
"Could not parse the distortion model coefficients.");
Expand Down

0 comments on commit d5571c1

Please sign in to comment.