Unverified Commit d0020883 authored by Kristin Berry's avatar Kristin Berry Committed by GitHub
Browse files

Updated state string to begin with the sensor model name as per the CSM standard. (#326)

parent 0d7d91b7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -166,4 +166,6 @@ std::vector<double> getSensorVelocities(nlohmann::json isd,
std::vector<double> getSensorOrientations(nlohmann::json isd,
                                          csm::WarningList *list = nullptr);
double getWavelength(nlohmann::json isd, csm::WarningList *list = nullptr);
nlohmann::json stateAsJson(std::string modelState);

#endif  // INCLUDE_USGSCSM_UTILITIES_H_
+6 −3
Original line number Diff line number Diff line
@@ -728,7 +728,8 @@ std::string UsgsAstroFrameSensorModel::getModelState() const {
       {m_referencePointXyz.x, m_referencePointXyz.y, m_referencePointXyz.z}},
      {"m_currentParameterCovariance", m_currentParameterCovariance}};

  return state.dump();
  std::string stateString = getModelName() + "\n" + state.dump();
  return stateString;
}

bool UsgsAstroFrameSensorModel::isValidModelState(
@@ -756,7 +757,7 @@ bool UsgsAstroFrameSensorModel::isValidModelState(
                                               "m_iTransS",
                                               "m_iTransL"};

  json jsonState = json::parse(stringState);
  json jsonState = stateAsJson(stringState);
  std::vector<std::string> missingKeywords;

  for (auto &key : requiredKeywords) {
@@ -811,7 +812,9 @@ bool UsgsAstroFrameSensorModel::isValidIsd(const std::string &Isd,

void UsgsAstroFrameSensorModel::replaceModelState(
    const std::string &stringState) {
  json state = json::parse(stringState);

  json state = stateAsJson(stringState);

  MESSAGE_LOG("Replacing model state");
  // The json library's .at() will except if key is missing
  try {
+4 −3
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string& stateString) {
  MESSAGE_LOG("Replacing model state")

  reset();
  auto j = json::parse(stateString);
  auto j = stateAsJson(stateString);
  int num_params = NUM_PARAMETERS;

  m_imageIdentifier = j["m_imageIdentifier"].get<std::string>();
@@ -282,7 +282,7 @@ void UsgsAstroLsSensorModel::replaceModelState(const std::string& stateString) {
std::string UsgsAstroLsSensorModel::getModelNameFromModelState(
    const std::string& model_state) {
  // Parse the string to JSON
  auto j = json::parse(model_state);
  auto j = stateAsJson(model_state);
  // If model name cannot be determined, return a blank string
  std::string model_name;

@@ -437,7 +437,8 @@ std::string UsgsAstroLsSensorModel::getModelState() const {
  state["m_sunVelocity"] = m_sunVelocity;
  MESSAGE_LOG("num sun velocities: {} ", m_sunVelocity.size())

  return state.dump();
  std::string stateString = getModelName() + "\n" + state.dump();
  return stateString;
}

//***************************************************************************
+2 −2
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ std::string UsgsAstroPlugin::loadImageSupportData(

std::string UsgsAstroPlugin::getModelNameFromModelState(
    const std::string &modelState, csm::WarningList *warnings) const {
  auto state = json::parse(modelState);
  auto state = stateAsJson(modelState);

  std::string name = state.value<std::string>("name_model", "");
  MESSAGE_LOG("Get model name from model state. State: {}, Name: {}",
@@ -353,7 +353,7 @@ csm::Model *UsgsAstroPlugin::constructModelFromISD(
csm::Model *UsgsAstroPlugin::constructModelFromState(
    const std::string &modelState, csm::WarningList *warnings) const {
  MESSAGE_LOG("Runing constructModelFromState with modelState: {}", modelState);
  json state = json::parse(modelState);
  json state = stateAsJson(modelState);
  std::string modelName = state["m_modelName"];
  MESSAGE_LOG("Using model name: {}", modelName);

+4 −3
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ string UsgsAstroSarSensorModel::getModelNameFromModelState(
    const string& model_state) {
  MESSAGE_LOG("Getting model name from model state: {}", model_state);
  // Parse the string to JSON
  auto j = json::parse(model_state);
  auto j = stateAsJson(model_state);
  // If model name cannot be determined, return a blank string
  string model_name;

@@ -219,7 +219,7 @@ void UsgsAstroSarSensorModel::replaceModelState(const string& argState) {
  reset();

  MESSAGE_LOG("Replacing model state with: {}", argState);
  auto stateJson = json::parse(argState);
  auto stateJson = stateAsJson(argState);

  m_imageIdentifier = stateJson["m_imageIdentifier"].get<string>();
  m_platformIdentifier = stateJson["m_platformIdentifier"].get<string>();
@@ -330,7 +330,8 @@ string UsgsAstroSarSensorModel::getModelState() const {
  state["m_scaleConversionTimes"] = m_scaleConversionTimes;
  state["m_covariance"] = m_covariance;

  return state.dump();
  std::string stateString = getModelName() + "\n" + state.dump();
  return stateString;
}

csm::ImageCoord UsgsAstroSarSensorModel::groundToImage(
Loading