From 44f837b2aba82531a19a41ac58d8991ca68f7969 Mon Sep 17 00:00:00 2001
From: Jesse Mapel <jmapel@usgs.gov>
Date: Tue, 10 Aug 2021 11:59:57 -0700
Subject: [PATCH] Added indent and new line to state dumps (#347)

* Added indent to state dumps

* Missed one
---
 src/UsgsAstroFrameSensorModel.cpp |  2 +-
 src/UsgsAstroLsSensorModel.cpp    | 12 ++++++------
 src/Utilities.cpp                 | 12 ++++++------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/UsgsAstroFrameSensorModel.cpp b/src/UsgsAstroFrameSensorModel.cpp
index 33720d3..1930432 100644
--- a/src/UsgsAstroFrameSensorModel.cpp
+++ b/src/UsgsAstroFrameSensorModel.cpp
@@ -752,7 +752,7 @@ std::string UsgsAstroFrameSensorModel::getModelState() const {
        {m_referencePointXyz.x, m_referencePointXyz.y, m_referencePointXyz.z}},
       {"m_currentParameterCovariance", m_currentParameterCovariance}};
 
-  std::string stateString = getModelName() + "\n" + state.dump();
+  std::string stateString = getModelName() + "\n" + state.dump(2);
   return stateString;
 }
 
diff --git a/src/UsgsAstroLsSensorModel.cpp b/src/UsgsAstroLsSensorModel.cpp
index 1fe6bed..3b39ee6 100644
--- a/src/UsgsAstroLsSensorModel.cpp
+++ b/src/UsgsAstroLsSensorModel.cpp
@@ -437,7 +437,7 @@ std::string UsgsAstroLsSensorModel::getModelState() const {
   state["m_sunVelocity"] = m_sunVelocity;
   MESSAGE_LOG("num sun velocities: {} ", m_sunVelocity.size())
 
-  std::string stateString = getModelName() + "\n" + state.dump();
+  std::string stateString = getModelName() + "\n" + state.dump(2);
   return stateString;
 }
 
@@ -453,24 +453,24 @@ void UsgsAstroLsSensorModel::applyTransformToState(ale::Rotation const& r, ale::
   std::vector<double> quaternions = j["m_quaternions"].get<std::vector<double>>();
   applyRotationToQuatVec(r, quaternions);
   j["m_quaternions"] = quaternions;
-  
+
   // Apply rotation and translation to positions
   std::vector<double> positions = j["m_positions"].get<std::vector<double>>();;
   applyRotationTranslationToXyzVec(r, t, positions);
   j["m_positions"] = positions;
-  
-  // Apply rotation to velocities. The translation does not get applied. 
+
+  // Apply rotation to velocities. The translation does not get applied.
   ale::Vec3d zero_t(0, 0, 0);
   std::vector<double> velocities = j["m_velocities"].get<std::vector<double>>();;
   applyRotationTranslationToXyzVec(r, zero_t, velocities);
   j["m_velocities"] = velocities;
-  
+
   // We do not change the Sun position or velocity. The idea is that
   // the Sun is so far, that minor camera adjustments won't affect
   // where the Sun is.
 
   // Update the state string
-  stateString = getModelNameFromModelState(stateString) + "\n" + j.dump();
+  stateString = getModelNameFromModelState(stateString) + "\n" + j.dump(2);
 }
 //***************************************************************************
 // UsgsAstroLineScannerSensorModel::reset
diff --git a/src/Utilities.cpp b/src/Utilities.cpp
index df3e5d2..6b448b9 100644
--- a/src/Utilities.cpp
+++ b/src/Utilities.cpp
@@ -1327,14 +1327,14 @@ json stateAsJson(std::string modelState) {
 // Apply a rotation to a vector of quaternions.
 void applyRotationToQuatVec(ale::Rotation const& r, std::vector<double> & quaternions) {
   int num_quat = quaternions.size();
-  
+
   for (int it = 0; it < num_quat/4; it++) {
 
     double * q = &quaternions[4*it];
 
     // Note that quaternion in q is stored in order x, y, z, w, while
     // the rotation matrix wants it as w, x, y, z.
-    
+
     std::vector<double> trans_q = (r * ale::Rotation(q[3], q[0], q[1], q[2])).toQuaternion();
 
     // Modify in-place
@@ -1348,14 +1348,14 @@ void applyRotationToQuatVec(ale::Rotation const& r, std::vector<double> & quater
 // Apply a rotation and translation to a vector of xyz vectors.
 void applyRotationTranslationToXyzVec(ale::Rotation const& r, ale::Vec3d const& t,
                                       std::vector<double> & xyz) {
-  
+
   int num_xyz = xyz.size();
   for (int it = 0; it < num_xyz/3; it++) {
-    
+
     double * p = &xyz[3*it];
 
     ale::Vec3d p_vec(p[0], p[1], p[2]);
-    
+
     // Apply the rotation
     p_vec = r(p_vec);
 
@@ -1366,6 +1366,6 @@ void applyRotationTranslationToXyzVec(ale::Rotation const& r, ale::Vec3d const&
     p[0] = p_vec.x;
     p[1] = p_vec.y;
     p[2] = p_vec.z;
-    
+
   }
 }
-- 
GitLab