Skip to content
Snippets Groups Projects
Select Git revision
  • 932c8ea669f680c4f1ecbbb79bd5a5b88575fe62
  • main default protected
  • oleg-alexandrov-patch-1
  • radtan
  • 2.0
  • Kelvinrr-patch-1
  • acpaquette-patch-1
  • gxp_testing
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • 1.7.0
  • 1.6.0
  • 1.5.2
  • 1.5.1
  • 1.5.0
  • 1.4.1
  • 1.4.0
  • 1.3.1
  • 1.3.0
  • 1.2.0
  • 1.1.1
  • 1.1.0
  • 1.0.0
24 results

UsgsAstroFrameSensorModel.cpp

Blame
    • acpaquette's avatar
      932c8ea6
      Logging Update (#289) · 932c8ea6
      acpaquette authored
      * Added and registered the log when a new plugin is being created
      
      * Updated frame and ls models to log to a registered spdlogger only if it exists
      
      * Updated h files in line with new named logger approach
      
      * Fixed failing tests
      
      * Resolved rebase changes that snuck back in
      
      * Set default logger for framer
      
      * Updated default logger for the framer
      
      * Added more checks to prevent seg faults from a poorly set environment variable
      
      * Removed try catch blocks and one register command
      
      * Updated sensor models to carry around a pointer to the logger
      Logging Update (#289)
      acpaquette authored
      * Added and registered the log when a new plugin is being created
      
      * Updated frame and ls models to log to a registered spdlogger only if it exists
      
      * Updated h files in line with new named logger approach
      
      * Fixed failing tests
      
      * Resolved rebase changes that snuck back in
      
      * Set default logger for framer
      
      * Updated default logger for the framer
      
      * Added more checks to prevent seg faults from a poorly set environment variable
      
      * Removed try catch blocks and one register command
      
      * Updated sensor models to carry around a pointer to the logger
    FrameCameraTests.cpp 3.26 KiB
    #include "UsgsAstroFramePlugin.h"
    #include "UsgsAstroFrameSensorModel.h"
    
    #include <json.hpp>
    
    #include <sstream>
    #include <fstream>
    
    #include <gtest/gtest.h>
    
    using json = nlohmann::json;
    
    class FrameSensorModel : public ::testing::Test {
       protected:
    
          UsgsAstroFrameSensorModel *sensorModel;
    
          void SetUp() override {
             sensorModel = NULL;
             std::ifstream isdFile("data/simpleFramerISD.json");
             json jsonIsd = json::parse(isdFile);
             csm::Isd isd;
             for (json::iterator it = jsonIsd.begin(); it != jsonIsd.end(); ++it) {
                json jsonValue = it.value();
                if (jsonValue.size() > 1) {
                   for (int i = 0; i < jsonValue.size(); i++) {
                      isd.addParam(it.key(), jsonValue[i].dump());
                   }
                }
                else {
                   isd.addParam(it.key(), jsonValue.dump());
                }
             }
             isdFile.close();
    
             UsgsAstroFramePlugin frameCameraPlugin;
             
             csm::Model *model = frameCameraPlugin.constructModelFromISD(
                   isd,
                   "USGS_ASTRO_FRAME_SENSOR_MODEL");
             
             sensorModel = dynamic_cast<UsgsAstroFrameSensorModel *>(model);
             
             ASSERT_NE(sensorModel, nullptr);
          }
    
          void TearDown() override {
             if (sensorModel) {
                delete sensorModel;
                sensorModel = NULL;
             }
          }
    };
    
    //NOTE: The imagePt layour is (Lines,Samples)
    //      Also subtract 0.5 from the lines/samples. Hence Samples=0 and Lines=15 -> 14.5,-0.5
    
    //centered and slightly off-center:
    TEST_F(FrameSensorModel, Center) {
       csm::ImageCoord imagePt(7.0, 7.0);
       csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
       EXPECT_NEAR(groundPt.x, 10.0, 1e-8);
       EXPECT_NEAR(groundPt.y, 0, 1e-8);
       EXPECT_NEAR(groundPt.z, 0, 1e-8);
    }
    TEST_F(FrameSensorModel, SlightlyOffCenter) {
       csm::ImageCoord imagePt(7.0, 6.0);
       csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
       EXPECT_NEAR(groundPt.x, 9.80194018, 1e-8);
       EXPECT_NEAR(groundPt.y, 0, 1e-8);
       EXPECT_NEAR(groundPt.z, 1.98039612, 1e-8);
    }
    
    //Test all four corners:
    TEST_F(FrameSensorModel, OffBody1) {
       csm::ImageCoord imagePt(14.5, -0.5);
       csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
       EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
       EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8);
       EXPECT_NEAR(groundPt.z, 14.99325304, 1e-8);
    }
    TEST_F(FrameSensorModel, OffBody2) {
       csm::ImageCoord imagePt(-0.5, 14.5);
       csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
       EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
       EXPECT_NEAR(groundPt.y, 14.99325304, 1e-8);
       EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8);
    }
    TEST_F(FrameSensorModel, OffBody3) {
       csm::ImageCoord imagePt(-0.5, -0.5);
       csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
       EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
       EXPECT_NEAR(groundPt.y, 14.99325304, 1e-8);
       EXPECT_NEAR(groundPt.z, 14.99325304, 1e-8);
    }
    TEST_F(FrameSensorModel, OffBody4) {
       csm::ImageCoord imagePt(14.5, 14.5);
       csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
       EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
       EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8);
       EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8);
    }