Commit dd73b1bc authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by Jesse Mapel
Browse files

Refactoring to move to one plugin and removed unused classes. (#138)

* merge

* changed varrs

* reset test

* First iteration

* it compiles, although renaming this is still neccessary

* added source

* cleaned up, tests still need to pass

* post merge clean up

* validation updated, validation tests are now passing

* Addressed comments from Jesse

* last Jesse comment, convertISDToModelState doesn't check if pointer is invalid anymore as the sensor model should except

* model_name -> m_modelName for frame getState

* copy paste error in FrameSensorModel
parent 46c24d06
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -24,11 +24,9 @@ else()
endif(BUILD_CSM)

add_library(usgscsm SHARED
            src/UsgsAstroFramePlugin.cpp
            src/UsgsAstroPlugin.cpp
            src/UsgsAstroFrameSensorModel.cpp
            src/UsgsAstroLsPlugin.cpp
            src/UsgsAstroLsSensorModel.cpp
            src/UsgsAstroLsStateData.cpp)
            src/UsgsAstroLsSensorModel.cpp)

set_target_properties(usgscsm PROPERTIES
    VERSION ${PROJECT_VERSION}
+30 −15
Original line number Diff line number Diff line
@@ -9,6 +9,10 @@
#include "RasterGM.h"
#include "CorrelationModel.h"

#include <json.hpp>
using json = nlohmann::json;


class UsgsAstroFrameSensorModel : public csm::RasterGM {
  // UsgsAstroFramePlugin needs to access private members
  friend class UsgsAstroFramePlugin;
@@ -17,11 +21,19 @@ class UsgsAstroFrameSensorModel : public csm::RasterGM {
    UsgsAstroFrameSensorModel();
    ~UsgsAstroFrameSensorModel();


    bool isValidModelState(const std::string& stringState, csm::WarningList *warnings);
    bool isValidIsd(const std::string& stringIsd, csm::WarningList *warnings);

    virtual csm::ImageCoord groundToImage(const csm::EcefCoord &groundPt,
                                     double desiredPrecision=0.001,
                                     double *achievedPrecision=NULL,
                                     csm::WarningList *warnings=NULL) const;


    std::string constructStateFromIsd(const std::string& jsonIsd, csm::WarningList *warnings);
    void reset();

    virtual csm::ImageCoordCovar groundToImage(const csm::EcefCoordCovar &groundPt,
                                          double desiredPrecision=0.001,
                                          double *achievedPrecision=NULL,
@@ -316,7 +328,6 @@ protected:


  private:

    // Input parameters
    static const int m_numParameters;
    static const std::string m_parameterName[];
@@ -326,40 +337,43 @@ protected:
    std::vector<double> m_noAdjustments;
    std::vector<double> m_odtX;
    std::vector<double> m_odtY;

    static const int         _NUM_STATE_KEYWORDS;
    static const std::string _STATE_KEYWORD[];

    double m_transX[3];
    double m_transY[3];
    std::vector<double> m_transX;
    std::vector<double> m_transY;
    std::vector<double> m_spacecraftVelocity;
    std::vector<double> m_sunPosition;
    std::vector<double> m_ccdCenter;
    std::vector<double> m_iTransS;
    std::vector<double> m_iTransL;
    std::vector<double> m_boresight;
    double m_majorAxis;
    double m_minorAxis;
    double m_focalLength;
    double m_spacecraftVelocity[3];
    double m_sunPosition[3];
    double m_ccdCenter[2];
    double m_minElevation;
    double m_maxElevation;
    double m_line_pp;
    double m_sample_pp;
    double m_linePp;
    double m_samplePp;
    double m_startingDetectorSample;
    double m_startingDetectorLine;
    std::string m_targetName;
    std::string m_modelName;
    double m_ifov;
    std::string m_instrumentID;
    double m_focalLengthEpsilon;
    double m_originalHalfLines;
    std::string m_spacecraftName;
    double m_pixelPitch;
    double m_iTransS[3];
    double m_iTransL[3];

    double m_ephemerisTime;
    double m_originalHalfSamples;
    double m_boresight[3];
    int m_nLines;
    int m_nSamples;
    int m_nParameters;

    json _state;
    static const int         _NUM_STATE_KEYWORDS;
    static const int         NUM_PARAMETERS;
    static const std::string _STATE_KEYWORD[];

    csm::NoCorrelationModel _no_corr_model;

    double getValue(int index,const std::vector<double> &adjustments) const;
@@ -371,6 +385,7 @@ protected:
                                double xl, double yl,
                                double zl,
                                double& x,double& y, double&  z) const;

};

#endif
+0 −219
Original line number Diff line number Diff line
//----------------------------------------------------------------------------
//
//                                UNCLASSIFIED
//
// Copyright © 1989-2017 BAE Systems Information and Electronic Systems Integration Inc.
//                            ALL RIGHTS RESERVED
// Use of this software product is governed by the terms of a license
// agreement. The license agreement is found in the installation directory.
//
//             For support, please visit http://www.baesystems.com/gxp
//
// Description:
//  This class creates instances of the Astro Line Scanner sensor model.  The
//  sensor model can be created from either image support data or sensor model
//  state data. This plugin is an implementation of the CSM 3.0.3 CSM plugin
//  class. It supports ISD specified by image file name.  It is expected that
//  a support data file exist in the same directory with the images file name
//  with "_keywords.lis" appended instead of the original extension. An optional
//  file containing ellipsoid data (ellipsoid.ell) can also be placed in this
//  directory. Otherwise, the ellipsoid data is found in the .lis file.
//
//  Revision History:
//  Date        Name        Description
//  ----------- ---------   -----------------------------------------------
//  30-APR-2017 BAE Systems Initial Implementation based on CSM 2.0 code
//  16-OCT-2017 BAE Systems Update for CSM 3.0.3
//-----------------------------------------------------------------------------

#ifndef __USGS_ASTRO_LINE_SCANNER_PLUGIN_H
#define __USGS_ASTRO_LINE_SCANNER_PLUGIN_H

#include <string>
#include <Plugin.h>


class UsgsAstroLsPlugin : public csm::Plugin
{
public:

   //---
   // The public interface is inherited from the csm::Plugin class.
   //---

   //--------------------------------------------------------------------------
   // Plugin Interface
   //--------------------------------------------------------------------------
   virtual std::string getPluginName() const;
   //> This method returns the character std::string that identifies the
   //  plugin.
   //<

   //---
   // CSM Plugin Descriptors
   //---
   virtual std::string getManufacturer() const;
   //> This method returns name of the organization that created the plugin.
   //<

   virtual std::string getReleaseDate() const;
   //> This method returns release date of the plugin.
   //  The returned string follows the ISO 8601 standard.
   //
   //-    Precision   Format           Example
   //-    year        yyyy             "1961"
   //-    month       yyyymm           "196104"
   //-    day         yyyymmdd         "19610420"
   //<

   virtual csm::Version getCsmVersion() const;
   //> This method returns the CSM API version that the plugin conforms to.
   //<

   //---
   // Model Availability
   //---
   virtual size_t getNumModels() const;
   //> This method returns the number of types of models that this plugin
   //  can create.
   //<

   virtual std::string getModelName(size_t modelIndex) const;
   //> This method returns the name of the model for the given modelIndex.
   //  The order does not matter - the index is only used to cycle through
   //  all of the model names.
   //
   //  The model index must be less than getNumModels(), or an exception
   //  will be thrown.
   //<

   virtual std::string getModelFamily(size_t modelIndex) const;
   //> This method returns the model "family" for the model for the given
   //  modelIndex.  This should be the same as what is returned from
   //  csm::Model::getFamily() for the model.
   //
   //  SETs can use this information to exclude models when searching for a
   //  model to create.
   //
   //  The model index must be less than getNumModels(), or an exception
   //  will be thrown.
   //<

   //---
   // Model Descriptors
   //---
   virtual csm::Version getModelVersion(const std::string& modelName) const;
   //> This method returns the version of the code for the model given
   //  by modelIndex.  The Version object can be compared to other Version
   //  objects with its comparison operators.  Not to be confused with the
   //  CSM API version.
   //<

   //---
   // Model Construction
   //---
   virtual bool canModelBeConstructedFromState(
      const std::string& modelName,
      const std::string& modelState,
      csm::WarningList* warnings = NULL) const;
   //> This method returns a boolean indicating whether or not a model of the
   //  given modelName can be constructed from the given modelState.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

   virtual bool canModelBeConstructedFromISD(
      const csm::Isd& imageSupportData,
      const std::string& modelName,
      csm::WarningList* warnings = NULL) const;
   //> This method returns a boolean indicating whether or not a model of the
   //  given modelName can be constructed from the given imageSupportData.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

   virtual csm::Model* constructModelFromState(
      const std::string& modelState,
      csm::WarningList* warnings = NULL) const;
   //> This method allocates and initializes an object of the appropriate
   //  derived Model class with the given modelState and returns a pointer to
   //  the Model base class.  The object is allocated by this method using
   //  new; it is the responsibility of the calling application to delete it.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

   virtual csm::Model* constructModelFromISD(
      const csm::Isd& imageSupportData,
      const std::string& modelName,
      csm::WarningList* warnings = NULL) const;
   //> This method allocates and initializes an object of the appropriate
   //  derived Model class with the given imageSupportData and returns a
   //  pointer to the Model base class.  The object is allocated by this
   //  method using new; it is the responsibility of the calling
   //  application to delete it.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

   virtual std::string getModelNameFromModelState(
      const std::string& modelState,
      csm::WarningList* warnings = NULL) const;
   // This method returns the model name for which the given modelState
   // is applicable.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

   //---
   // Image Support Data Conversions
   //---
   virtual bool canISDBeConvertedToModelState(
      const csm::Isd& imageSupportData,
      const std::string& modelName,
      csm::WarningList* warnings = NULL) const;
   //> This method returns a boolean indicating whether or not a model state
   //  of the given modelName can be constructed from the given
   //  imageSupportData.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

   virtual std::string convertISDToModelState(
      const csm::Isd&    imageSupportData,
      const std::string& modelName,
      csm::WarningList*  warnings = NULL) const;
   //> This method returns a model state string for the given modelName,
   //  constructed from the given imageSupportData.
   //
   //  If a non-NULL warnings argument is received, it will be populated
   //  as applicable.
   //<

//private:

   //--------------------------------------------------------------------------
   // Constructors/Destructor
   //--------------------------------------------------------------------------

   UsgsAstroLsPlugin();
   ~UsgsAstroLsPlugin();

private:
   //--------------------------------------------------------------------------
   // Data Members
   //--------------------------------------------------------------------------

   // This is needed to allow the plugin to be registered.
   static const UsgsAstroLsPlugin  _theRegisteringObject;
   static const std::string mISD_KEYWORDS[];
   static const std::string mSTATE_KEYWORDS[];
}; // UsgsAstroLsPlugin

#endif // __USGS_ASTRO_LINE_SCANNER_PLUGIN_H
+101 −18
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#ifndef __USGS_ASTRO_LINE_SCANNER_SENSORMODEL_H
#define __USGS_ASTRO_LINE_SCANNER_SENSORMODEL_H

#include "UsgsAstroLsStateData.h"
#include <RasterGM.h>
#include <SettableEllipsoid.h>
#include <CorrelationModel.h>
@@ -37,6 +36,102 @@ class UsgsAstroLsSensorModel : public csm::RasterGM, virtual public csm::Settabl
{
public:

   // Initializes the class from state data as formatted
   // in a string by the toString() method
   void setState(const std::string &state);


    virtual void replaceModelState(const std::string& argState);
    //> This method attempts to initialize the current model with the state
    //  given by argState.  The argState argument can be a string previously
    //  retrieved from the getModelState method.
    //
    //  If argState contains a valid state for the current model,
    //  the internal state of the model is updated.
    //
    //  If the model cannot be updated to the given state, a csm::Error is
    //  thrown and the internal state of the model is undefined.
    //
    //  If the argument state string is empty, the model remains unchanged.
    //<


   // This method checks to see if the model name is recognized
   // in the input state string.
   static std::string getModelNameFromModelState(
      const std::string& model_state);

  std::string constructStateFromIsd(const std::string imageSupportData, csm::WarningList *list) const;

   // State data elements;
   std::string  m_imageIdentifier;                // 1
   std::string  m_sensorType;                     // 2
   int          m_totalLines;                     // 3
   int          m_totalSamples;                   // 4
   double       m_offsetLines;                    // 5
   double       m_offsetSamples;                  // 6
   int          m_platformFlag;                   // 7
   int          m_aberrFlag;                      // 8
   int          m_atmRefFlag;                     // 9
   std::vector<double> m_intTimeLines;
   std::vector<double> m_intTimeStartTimes;
   std::vector<double> m_intTimes;
   double       m_startingEphemerisTime;          // 11
   double       m_centerEphemerisTime;            // 12
   double       m_detectorSampleSumming;          // 13
   double       m_startingSample;                 // 14
   int          m_ikCode;                         // 15
   double       m_focal;                          // 16
   double       m_isisZDirection;                 // 17
   double       m_opticalDistCoef[3];             // 18
   double       m_iTransS[3];                     // 19
   double       m_iTransL[3];                     // 20
   double       m_detectorSampleOrigin;           // 21
   double       m_detectorLineOrigin;             // 22
   double       m_detectorLineOffset;             // 23
   double       m_mountingMatrix[9];              // 24
   double       m_semiMajorAxis;                  // 25
   double       m_semiMinorAxis;                  // 26
   std::string  m_referenceDateAndTime;           // 27
   std::string  m_platformIdentifier;             // 28
   std::string  m_sensorIdentifier;               // 29
   std::string  m_trajectoryIdentifier;           // 30
   std::string  m_collectionIdentifier;           // 31
   double       m_refElevation;                   // 32
   double       m_minElevation;                   // 33
   double       m_maxElevation;                   // 34
   double       m_dtEphem;                        // 35
   double       m_t0Ephem;                        // 36
   double       m_dtQuat;                         // 37
   double       m_t0Quat;                         // 38
   int          m_numEphem;                       // 39
   int          m_numQuaternions;                 // 40
   std::vector<double> m_ephemPts;                // 41
   std::vector<double> m_ephemRates;              // 42
   std::vector<double> m_quaternions;             // 43
   std::vector<double> m_parameterVals;           // 44
   std::vector<csm::param::Type> m_parameterType; // 45
   csm::EcefCoord m_referencePointXyz;            // 46
   double       m_gsd;                            // 47
   double       m_flyingHeight;                   // 48
   double       m_halfSwath;                      // 49
   double       m_halfTime;                       // 50
   std::vector<double> m_covariance;              // 51
   int          m_imageFlipFlag;                  // 52

   // Hardcoded
   static const std::string      _SENSOR_MODEL_NAME; // state date element 0

   static const std::string      _STATE_KEYWORD[];
   static const int              NUM_PARAM_TYPES;
   static const std::string      PARAM_STRING_ALL[];
   static const csm::param::Type PARAM_CHAR_ALL[];
   static const int              NUM_PARAMETERS;
   static const std::string      PARAMETER_NAME[];

   // Set to default values
   void reset();

   //--------------------------------------------------------------
   // Constructors/Destructor
   //--------------------------------------------------------------
@@ -44,8 +139,11 @@ public:
   UsgsAstroLsSensorModel();
   ~UsgsAstroLsSensorModel();

   virtual std::string getModelState() const;


   // Set the sensor model based on the input state data
   void set( const UsgsAstroLsStateData &state_data );
   void set( const std::string &state_data );


   //----------------------------------------------------------------
@@ -775,7 +873,7 @@ public:
   //---
   // Sensor Model State
   //---
   virtual std::string getModelState() const;
   // virtual std::string setModelState(std::string stateString) const;
   //> This method returns a string containing the data to exactly recreate
   //  the current model.  It can be used to restore this model to a
   //  previous state with the replaceModelState method or create a new
@@ -785,20 +883,6 @@ public:
   //  current state.
   //<

   virtual void replaceModelState(const std::string& argState);
   //> This method attempts to initialize the current model with the state
   //  given by argState.  The argState argument can be a string previously
   //  retrieved from the getModelState method.
   //
   //  If argState contains a valid state for the current model,
   //  the internal state of the model is updated.
   //
   //  If the model cannot be updated to the given state, a csm::Error is
   //  thrown and the internal state of the model is undefined.
   //
   //  If the argument state string is empty, the model remains unchanged.
   //<

   virtual csm::Ellipsoid getEllipsoid() const;
   //> This method returns the planetary ellipsoid.
   //<
@@ -951,7 +1035,6 @@ private:
   double determinant3x3(double mat[9]) const;


   UsgsAstroLsStateData _data;  // Holds the state data

   csm::NoCorrelationModel     _no_corr_model; // A way to report no correlation between images is supported
   std::vector<double>         _no_adjustment; // A vector of zeros indicating no internal adjustment
+0 −208

File deleted.

Preview size limit exceeded, changes collapsed.

Loading