diff --git a/src/UsgsAstroSarSensorModel.cpp b/src/UsgsAstroSarSensorModel.cpp index f55bf38d94b2b212fec2bdfcf135b97b43951210..b75a9c1ad6446159e6712d4ef7ca8042ca11c586 100644 --- a/src/UsgsAstroSarSensorModel.cpp +++ b/src/UsgsAstroSarSensorModel.cpp @@ -275,6 +275,24 @@ void UsgsAstroSarSensorModel::replaceModelState(const string& argState){ m_covariance = stateJson["m_covariance"].get<vector<double>>(); m_sunPosition = stateJson["m_sunPosition"].get<vector<double>>(); m_sunVelocity = stateJson["m_sunVelocity"].get<vector<double>>(); + + + // If sensor model is being created for the first time, this routine will set the reference point + if (m_referencePointXyz.x == 0 && m_referencePointXyz.y == 0 && m_referencePointXyz.z == 0) { + MESSAGE_LOG("Updating State") + + double lineCtr = m_nLines / 2.0; + double sampCtr = m_nSamples / 2.0; + csm::ImageCoord ip(lineCtr, sampCtr); + MESSAGE_LOG("updateState: center image coordinate set to {} {}", + lineCtr, sampCtr) + + double refHeight = 0; + m_referencePointXyz = imageToGround(ip, refHeight); + MESSAGE_LOG("updateState: reference point (x, y, z) {} {} {}", + m_referencePointXyz.x, m_referencePointXyz.y, + m_referencePointXyz.z) + } } string UsgsAstroSarSensorModel::getModelState() const { diff --git a/tests/SarTests.cpp b/tests/SarTests.cpp index 2d11de9423310cf6504da3557b6739ea42ed8f6e..2efd10fa6eb4027fad02437e405b4d5e8e7dd85b 100644 --- a/tests/SarTests.cpp +++ b/tests/SarTests.cpp @@ -84,12 +84,12 @@ TEST_F(SarSensorModel, computeGroundPartials) { csm::EcefCoord groundPt(1737400.0, 0.0, 0.0); std::vector<double> partials = sensorModel->computeGroundPartials(groundPt); ASSERT_EQ(partials.size(), 6); - EXPECT_NEAR(partials[0], -0.00023385137104424322, 1e-8); - EXPECT_NEAR(partials[1], -3.3408269124235446e-05, 1e-8); - EXPECT_NEAR(partials[2], -1.0 / 7.5, 1e-8); - EXPECT_NEAR(partials[3], -33.057612335589731, 1e-8); - EXPECT_NEAR(partials[4], 6.3906252180458977e-05, 1e-8); - EXPECT_NEAR(partials[5], 0.0077565105242805047, 1e-8); + EXPECT_NEAR(partials[0], 6.5128150576280552e-09, 1e-8); + EXPECT_NEAR(partials[1], -5.1810407815840636e-15, 1e-8); + EXPECT_NEAR(partials[2], -0.13309947654685725, 1e-8); + EXPECT_NEAR(partials[3], -33.057625791698072, 1e-8); + EXPECT_NEAR(partials[4], 6.1985123841926308e-05, 1e-8); + EXPECT_NEAR(partials[5], 0.007743051337209989, 1e-8); } TEST_F(SarSensorModel, imageToProximateImagingLocus) {