Commit 3804e6c4 authored by acpaquette's avatar acpaquette Committed by Jesse Mapel
Browse files

Inaccurate Implementation for getReferenceDateAndTime (#256)

* Initial implementation and tests for getReferenceDateAndTime

* Updated both the line scanner and frame models accessor for reference date and time

* Updated line scanner test

* Updated frame model to transfer ephemeris time when replacing the model state

* Added frame model getReferenceDateAndTime test
parent f5796751
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -678,7 +678,19 @@ std::string UsgsAstroFrameSensorModel::getSensorMode() const {

std::string UsgsAstroFrameSensorModel::getReferenceDateAndTime() const {
  MESSAGE_LOG(this->m_logger, "Accessing reference data and time");
  return "";
  csm::EcefCoord referencePointGround = UsgsAstroFrameSensorModel::getReferencePoint();
  csm::ImageCoord referencePointImage = UsgsAstroFrameSensorModel::groundToImage(referencePointGround);
  time_t ephemTime = UsgsAstroFrameSensorModel::getImageTime(referencePointImage);
  struct tm t = {0};  // Initalize to all 0's
  t.tm_year = 100;  // This is year-1900, so 100 = 2000
  t.tm_mday = 1;
  time_t timeSinceEpoch = mktime(&t);
  time_t finalTime = ephemTime + timeSinceEpoch;
  char buffer [16];
  strftime(buffer, 16, "%Y%m%dT%H%M%S", localtime(&finalTime));
  buffer[15] = '\0';

  return buffer;
}


@@ -825,6 +837,7 @@ void UsgsAstroFrameSensorModel::replaceModelState(const std::string& stringState
        m_focalLengthEpsilon = state.at("m_focalLengthEpsilon").get<double>();
        m_nLines = state.at("m_nLines").get<int>();
        m_nSamples = state.at("m_nSamples").get<int>();
        m_ephemerisTime = state.at("m_ephemerisTime").get<int>();
        m_currentParameterValue = state.at("m_currentParameterValue").get<std::vector<double>>();
        m_ccdCenter = state.at("m_ccdCenter").get<std::vector<double>>();
        m_spacecraftVelocity = state.at("m_spacecraftVelocity").get<std::vector<double>>();
+16 −7
Original line number Diff line number Diff line
@@ -1283,10 +1283,20 @@ std::string UsgsAstroLsSensorModel::getTrajectoryIdentifier() const
//***************************************************************************
std::string UsgsAstroLsSensorModel::getReferenceDateAndTime() const
{
    throw csm::Error(
       csm::Error::UNSUPPORTED_FUNCTION,
       "Unsupported function",
       "UsgsAstroLsSensorModel::getReferenceDateAndTime");
    csm::EcefCoord referencePointGround = UsgsAstroLsSensorModel::getReferencePoint();
    csm::ImageCoord referencePointImage = UsgsAstroLsSensorModel::groundToImage(referencePointGround);
    double relativeTime = UsgsAstroLsSensorModel::getImageTime(referencePointImage);
    time_t ephemTime = m_centerEphemerisTime + relativeTime;
    struct tm t = {0};  // Initalize to all 0's
    t.tm_year = 100;  // This is year-1900, so 100 = 2000
    t.tm_mday = 1;
    time_t timeSinceEpoch = mktime(&t);
    time_t finalTime = ephemTime + timeSinceEpoch;
    char buffer [16];
    strftime(buffer, 16, "%Y%m%dT%H%M%S", localtime(&finalTime));
    buffer[15] = '\0';

    return buffer;
}

//***************************************************************************
@@ -1314,7 +1324,6 @@ double UsgsAstroLsSensorModel::getImageTime(
                         image_pt.line, time)

   return time;

}

//***************************************************************************
+5 −0
Original line number Diff line number Diff line
@@ -755,3 +755,8 @@ TEST_F(FrameSensorModelLogging, losEllipsoidIntersect) {
        xl, yl, zl,
        x, y, z);
}

TEST_F(OrbitalFrameSensorModel, ReferenceDateTime) {
  std::string date = sensorModel->getReferenceDateAndTime();
  EXPECT_EQ(date, "20000101T001640");
}
+5 −0
Original line number Diff line number Diff line
@@ -178,3 +178,8 @@ TEST_F(OrbitalLineScanSensorModel, InversionReallyHigh) {
    EXPECT_NEAR(imagePt.samp, imageReprojPt.samp, 0.002);
  }
}

TEST_F(OrbitalLineScanSensorModel, ReferenceDateTime) {
  std::string date = sensorModel->getReferenceDateAndTime();
  EXPECT_EQ(date, "20000101T001639");
}