diff --git a/src/UsgsAstroLsSensorModel.cpp b/src/UsgsAstroLsSensorModel.cpp index 3dd49a9babf97b462e13bb6a8710eed4e3ee5597..e65e58d7e0220804bd3150de8267aca05446641a 100644 --- a/src/UsgsAstroLsSensorModel.cpp +++ b/src/UsgsAstroLsSensorModel.cpp @@ -252,6 +252,7 @@ std::string UsgsAstroLsSensorModel::getModelNameFromModelState( std::string UsgsAstroLsSensorModel::getModelState() const { json state; + state["m_modelName"] = _SENSOR_MODEL_NAME; state["m_imageIdentifier"] = m_imageIdentifier; state["m_sensorType"] = m_sensorType; state["m_totalLines"] = m_totalLines; @@ -306,9 +307,9 @@ std::string UsgsAstroLsSensorModel::getModelState() const { state["m_imageFlipFlag"] = m_imageFlipFlag; state["m_referencePointXyz"] = json(); - state["m_referencePointXyz"]["x"] = m_referencePointXyz.x; - state["m_referencePointXyz"]["y"] = m_referencePointXyz.y; - state["m_referencePointXyz"]["z"] = m_referencePointXyz.z; + state["m_referencePointXyz"][0] = m_referencePointXyz.x; + state["m_referencePointXyz"][1] = m_referencePointXyz.y; + state["m_referencePointXyz"][2] = m_referencePointXyz.z; return state.dump(); } diff --git a/src/UsgsAstroPlugin.cpp b/src/UsgsAstroPlugin.cpp index ed977106d0fc99a22ddc17762c2f480af9a9f142..d731f6c02b6dae0a80e9861080877b6dd5631898 100644 --- a/src/UsgsAstroPlugin.cpp +++ b/src/UsgsAstroPlugin.cpp @@ -201,7 +201,7 @@ bool UsgsAstroPlugin::canISDBeConvertedToModelState(const csm::Isd &imageSupport std::string UsgsAstroPlugin::getStateFromISD(csm::Isd imageSupportData) const { std::string stringIsd = loadImageSupportData(imageSupportData); json jsonIsd = json::parse(stringIsd); - return convertISDToModelState(imageSupportData, jsonIsd.at("modelName")); + return convertISDToModelState(imageSupportData, jsonIsd.at("name_model")); } @@ -259,7 +259,7 @@ csm::Model *UsgsAstroPlugin::constructModelFromState(const std::string& modelSta csm::WarningList *warnings) const { json state = json::parse(modelState); - std::string modelName = state["modelName"]; + std::string modelName = state["m_modelName"]; if (modelName == UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME) { UsgsAstroFrameSensorModel* model = new UsgsAstroFrameSensorModel(); diff --git a/tests/LineScanCameraTests.cpp b/tests/LineScanCameraTests.cpp index 025df5cea25c4345ff588a762624a71e9f7ed412..84a813b94231636cbac301f3d3794a8ebfea81b8 100644 --- a/tests/LineScanCameraTests.cpp +++ b/tests/LineScanCameraTests.cpp @@ -15,14 +15,12 @@ using json = nlohmann::json; TEST_F(ConstVelocityLineScanSensorModel, State) { std::string modelState = sensorModel->getModelState(); - // EXPECT_NO_THROW( - // sensorModel->replaceModelState(modelState) - // ); + sensorModel->replaceModelState(modelState); // When this is different, the output is very hard to parse // TODO implement JSON diff for gtest - // EXPECT_EQ(sensorModel->getModelState(), modelState); + EXPECT_EQ(sensorModel->getModelState(), modelState); } // Fly by tests diff --git a/tests/PluginTests.cpp b/tests/PluginTests.cpp index f805a8c0eac100d48adf4861e64ccbffa7811ec1..795201a13370da0eaa684389afb56cbf542f6151 100644 --- a/tests/PluginTests.cpp +++ b/tests/PluginTests.cpp @@ -82,6 +82,14 @@ TEST_F(FrameIsdTest, Constructible) { "USGS_ASTRO_FRAME_SENSOR_MODEL")); } +TEST_F(FrameIsdTest, ConstructibleFromState) { + UsgsAstroPlugin testPlugin; + std::string modelState = testPlugin.getStateFromISD(isd); + EXPECT_TRUE(testPlugin.canModelBeConstructedFromState( + "USGS_ASTRO_FRAME_SENSOR_MODEL", + modelState)); +} + TEST_F(FrameIsdTest, NotConstructible) { UsgsAstroPlugin testPlugin; isd.setFilename("data/constVelocityLineScan.img"); @@ -142,6 +150,14 @@ TEST_F(ConstVelLineScanIsdTest, Constructible) { "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL")); } +TEST_F(ConstVelLineScanIsdTest, ConstructibleFromState) { + UsgsAstroPlugin testPlugin; + std::string modelState = testPlugin.getStateFromISD(isd); + EXPECT_TRUE(testPlugin.canModelBeConstructedFromState( + "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL", + modelState)); +} + TEST_F(ConstVelLineScanIsdTest, NotConstructible) { UsgsAstroPlugin testPlugin; isd.setFilename("data/simpleFramerISD.img");