Unverified Commit 3f4bc1fa authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Merge pull request #6 from jlaura/master

GenericLS
parents fb1698fc 3574cf14
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ bin/*
# Ignore any Max stuff
.DS_Store

*.cpp
*.cpython*
__pycache__
__pycache__/*
+201 −0
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
//
//    FILENAME:          UsgsAstroLsISD.h
//
//    DESCRIPTION:
//
//     Image Support Data (ISD) to build the Astro Line Scanner sensor model.
//     The ISD format is defined by the imagery provider. A few common formats
//     include name/value pairs, XML, NITF TREs, and GeoTiff tags.
//
//     This ISD is formatted as a list of name/value pairs. The order of the 
//     list generally does not matter, except that the length of a vector needs
//     to be read in before the vector itself. Extra data in the support data 
//     file will be ignored.
//
//     There is data describing the ellipsoid that can optionally be in a 
//     seperate file.  This is to support legacy data, but is not encouraged.
//
//     For the Astro LS sensor model there is a close relationship between the
//     ISD and the State data. This is not always the case. So, it is best to 
//     seperate the ISD parsing (done here), the translation of ISD to state 
//     data (done in the plugin), and the instantiation of the sensor model 
//     from state data (done in the sensor model).
//
//    SOFTWARE HISTORY:
//
//    Date          Author       Comment
//    -----------   ----------   -------
//    16-Oct-2017   BAE Systems  Initial Release
//
//#############################################################################
#ifndef __USGS_ASTRO_LINE_SCANNER_ISD_H
#define __USGS_ASTRO_LINE_SCANNER_ISD_H

#include <vector>
#include <string>

#include <csm/csm.h>
#include <csm/Isd.h>
#include <csm/SettableEllipsoid.h>

class UsgsAstroLsISD
{
   public:


   UsgsAstroLsISD()
   {
      reset();
   }

   UsgsAstroLsISD(
      const std::string&   lis_file_name,
      const std::string&   ell_file_name)
   {
      reset();
      setISD(lis_file_name, ell_file_name);
   }
   
   virtual ~UsgsAstroLsISD() {}

   // Formats the support data as a string
   // This is mainly used to check that the 
   // support data is read in correctly.   
   std::string toString() const;

   // Initializes the class from ISD as formatted by the image provider.
   //
   // Note that if the ellipsoid data is found in the main ISD file,
   // the ellipsoid data file is not needed.
   void setISD(
      const std::string&   lis_file_name,
      const std::string&   ell_file_name);


   //--------------------------------------------------------------------------
   // Helper Routines
   //--------------------------------------------------------------------------
   // Initial check that support data file exists and looks like Astro LS ISD.
   static bool checkFileValidity(
      const csm::Isd&     image_support_data,
      std::string&        lis_file_name,
      std::string&        ell_file_name,
      std::string&        img_rel_name);

   
   // ISD elements;
   // The support data is defined by USGS. See the documentation at
   // http://htmlpreview.github.io/?https://github.com/USGS-Astrogeology/socet_set/blob/master/SS4HiRISE/Tutorials/ISD_keyword_examples/AstroLineScanner_ISD_Keywords.ls.htm
   // Even for fields that do not change, it is best to include them in 
   // the support data rather than hard code values in the sensor model.
   // Since this is not always done, some fields are optional.
   std::string         m_sensor_type;
   int                 m_total_lines;
   int                 m_total_samples;
   int                 m_platform;
   int                 m_aberr;
   int                 m_atmref;
   double              m_int_time;
   double              m_starting_ephemeris_time;
   double              m_center_ephemeris_time;
   double              m_detector_sample_summing;
   double              m_starting_sample;
   int                 m_ikcode;
   double              m_focal;
   double              m_isis_z_direction;
   double              m_optical_dist_coef[3];
   double              m_itranss[3];
   double              m_itransl[3];
   double              m_detector_sample_origin;
   double              m_detector_line_origin;
   double              m_detector_line_offset;
   double              m_mounting_angles[3];
   double              m_dt_ephem;
   double              m_t0_ephem;
   double              m_dt_quat;
   double              m_t0_quat;
   int                 m_number_of_ephem;
   int                 m_number_of_quaternions;
   std::vector<double> m_ephem_pts;
   std::vector<double> m_ephem_rates;
   std::vector<double> m_quaternions;
   std::vector<double> m_tri_parameters;
   double              m_semi_major_axis;
   double              m_eccentricity;

   // Optional fields
   double              m_ref_height;
   double              m_min_valid_ht;
   double              m_max_valid_ht;
   std::string         m_image_id;
   std::string         m_sensor_id;
   std::string         m_platform_id;
   std::string         m_traj_id;
   std::string         m_coll_id;
   std::string         m_ref_date_time;

   static const std::string mISD_KEYWORDS[];

   enum IsdKeywords
   {
      SENSOR_TYPE,
      TOTAL_LINES,
      TOTAL_SAMPLES,
      PLATFORM,
      ABERR,
      ATMREF,
      INT_TIME,
      STARTING_EPHEMERIS_TIME,
      CENTER_EPHEMERIS_TIME,
      DETECTOR_SAMPLE_SUMMING,
      STARTING_SAMPLE,
      IKCODE,
      FOCAL,
      ISIS_Z_DIRECTION,
      OPTICAL_DIST_COEF,
      ITRANSS,
      ITRANSL,
      DETECTOR_SAMPLE_ORIGIN,
      DETECTOR_LINE_ORIGIN,
      DETECTOR_LINE_OFFSET,
      MOUNTING_ANGLES,
      DT_EPHEM,
      T0_EPHEM,
      DT_QUAT,
      T0_QUAT,
      NUMBER_OF_EPHEM,
      NUMBER_OF_QUATERNIONS,
      EPHEM_PTS,
      EPHEM_RATES,
      QUATERNIONS,
      TRI_PARAMETERS,
      SEMI_MAJOR_AXIS,
      ECCENTRICITY,
      REFERENCE_HEIGHT,
      MIN_VALID_HT,
      MAX_VALID_HT,
      IMAGE_ID,
      SENSOR_ID,
      PLATFORM_ID,
      TRAJ_ID,
      COLL_ID,
      REF_DATE_TIME,
      NUM_ISD_KEYWORDS
   };

   protected:
   // Set to default values  
   void reset();
};

#endif
 No newline at end of file
+219 −0
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 <csm/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
+963 −0

File added.

Preview size limit exceeded, changes collapsed.

+204 −0
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:
//
//    Holds State data that runs the Astro Line Scanner Sensor Model.
//    The format of the state data is determined by the sensor model
//    developer. The CSM plugin converts ISD to state data and the
//    CSM sensor model is instantiated based on the state data.
//
//    By CSM convention, the sensor model name is the first element in
//    the state data. The rest of the state data is order independent
//    with the exception that the length of vectors must come before
//    the vector data.
//
//    For the Astro Line Scanner sensor model, the state data closely
//    follows the support data. This is not always the case. For this
//    model, the state data is a list name/value pairs.
//
//
//    SOFTWARE HISTORY:
//
//    Date          Author       Comment
//    -----------   ----------   -------
//    13-OCT-2017   BAE Systems  Initial Release
//
//#############################################################################
#ifndef __USGS_ASTRO_LINE_SCANNER_STATE_DATA_H
#define __USGS_ASTRO_LINE_SCANNER_STATE_DATA_H

#include <vector>
#include <string>

#include <csm/csm.h>
#include <csm/SettableEllipsoid.h>

class UsgsAstroLsStateData
{
   public:

   UsgsAstroLsStateData()
   {
      reset();
   }

   UsgsAstroLsStateData(const std::string &state)
   {
      reset();
      setState(state);
   }

   ~UsgsAstroLsStateData() {}

   // Formats the state data as a string.
   // This is the format that is used to instantiate a sensor model.
   std::string toString() const;

   // Formats the sate data as a JSON string.
   std::string toJson() const;

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

   // 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);

   // 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
   double       m_IntTime;                        // 10
   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[];

   enum
   {
       STA_SENSOR_MODEL_NAME,
       STA_IMAGE_IDENTIFIER,
       STA_SENSOR_TYPE,
       STA_TOTAL_LINES,
       STA_TOTAL_SAMPLES,
       STA_OFFSET_LINES,
       STA_OFFSET_SAMPLES,
       STA_PLATFORM_FLAG,
       STA_ABERR_FLAG,
       STA_ATMREF_FLAG,
       STA_INT_TIME,
       STA_STARTING_EPHEMERIS_TIME,
       STA_CENTER_EPHEMERIS_TIME,
       STA_DETECTOR_SAMPLE_SUMMING,
       STA_STARTING_SAMPLE,
       STA_IK_CODE,
       STA_FOCAL,
       STA_ISIS_Z_DIRECTION,
       STA_OPTICAL_DIST_COEF,
       STA_I_TRANS_S,
       STA_I_TRANS_L,
       STA_DETECTOR_SAMPLE_ORIGIN,
       STA_DETECTOR_LINE_ORIGIN,
       STA_DETECTOR_LINE_OFFSET,
       STA_MOUNTING_MATRIX,
       STA_SEMI_MAJOR_AXIS,
       STA_SEMI_MINOR_AXIS,
       STA_REFERENCE_DATE_AND_TIME,
       STA_PLATFORM_IDENTIFIER,
       STA_SENSOR_IDENTIFIER,
       STA_TRAJECTORY_IDENTIFIER,
       STA_COLLECTION_IDENTIFIER,
       STA_REF_ELEVATION,
       STA_MIN_ELEVATION,
       STA_MAX_ELEVATION,
       STA_DT_EPHEM,
       STA_T0_EPHEM,
       STA_DT_QUAT,
       STA_T0_QUAT,
       STA_NUM_EPHEM,
       STA_NUM_QUATERNIONS,
       STA_EPHEM_PTS,
       STA_EPHEM_RATES,
       STA_QUATERNIONS,
       STA_PARAMETER_VALS,
       STA_PARAMETER_TYPE,
       STA_REFERENCE_POINT_XYZ,
       STA_GSD,
       STA_FLYING_HEIGHT,
       STA_HALF_SWATH,
       STA_HALF_TIME,
       STA_COVARIANCE,
       STA_IMAGE_FLIP_FLAG,
       _NUM_STATE_KEYWORDS
   };

   // Set to default values
   void reset();
};

#endif
Loading