Unverified Commit d5571c13 authored by Oleg Alexandrov's avatar Oleg Alexandrov Committed by GitHub
Browse files

Add radtan distortion (#575)

parent e1959ec2
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -9,7 +9,8 @@ namespace ale {
    DAWNFC,
    DAWNFC,
    LROLROCNAC,
    LROLROCNAC,
    CAHVOR,
    CAHVOR,
    LUNARORBITER
    LUNARORBITER,
    RADTAN
  };
  };
}
}


+18 −2
Original line number Original line Diff line number Diff line
@@ -342,9 +342,9 @@ double getSemiMinorRadius(json isd) {
// type. Defaults to transverse
// type. Defaults to transverse
DistortionType getDistortionModel(json isd) {
DistortionType getDistortionModel(json isd) {
  try {
  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();
    std::string distortion = (std::string)it.key();


@@ -362,6 +362,8 @@ DistortionType getDistortionModel(json isd) {
      return DistortionType::CAHVOR;
      return DistortionType::CAHVOR;
    } else if (distortion.compare("lunarorbiter") == 0) {
    } else if (distortion.compare("lunarorbiter") == 0) {
      return DistortionType::LUNARORBITER;
      return DistortionType::LUNARORBITER;
    } else if (distortion.compare("radtan") == 0) {
      return DistortionType::RADTAN;
    }
    }
  } catch (...) {
  } catch (...) {
    throw std::runtime_error("Could not parse the distortion model.");
    throw std::runtime_error("Could not parse the distortion model.");
@@ -528,6 +530,20 @@ std::vector<double> getDistortionCoeffs(json isd) {
        coefficients = std::vector<double>(4, 0.0);
        coefficients = std::vector<double>(4, 0.0);
      }
      }
    } break;
    } 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(
  throw std::runtime_error(
      "Could not parse the distortion model coefficients.");
      "Could not parse the distortion model coefficients.");