USGS

Isis 3.0 Application Source Code Reference

Home

MdisGeometry.h

Go to the documentation of this file.
00001 #ifndef MdisGeometry_h
00002 #define MdisGeometry_h
00003 /**
00004  * @file
00005  * $Revision: 1.7 $
00006  * $Date: 2009/09/19 00:12:10 $
00007  *
00008  *   Unless noted otherwise, the portions of Isis written by the USGS are
00009  *   public domain. See individual third-party library and package descriptions
00010  *   for intellectual property information, user agreements, and related
00011  *   information.
00012  *
00013  *   Although Isis has been used by the USGS, no warranty, expressed or
00014  *   implied, is made by the USGS as to the accuracy and functioning of such
00015  *   software and related material nor shall the fact of distribution
00016  *   constitute any such warranty, and no responsibility is assumed by the
00017  *   USGS in connection therewith.
00018  *
00019  *   For additional information, launch
00020  *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html
00021  *   in a browser or see the Privacy & Disclaimers page on the Isis website,
00022  *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
00023  *   http://www.usgs.gov/privacy.html.
00024  */
00025 
00026 #include <string>
00027 #include <vector>
00028 #include <iostream>
00029 
00030 #include "Pvl.h"
00031 #include "Cube.h"
00032 #include "Camera.h"
00033 #include "SpiceManager.h"
00034 #include "IException.h"
00035 
00036 namespace Isis {
00037 
00038   /**
00039    * @brief Computes all MDIS Geometric keywords
00040    *
00041    * This class computes a set of MESSENGER/MIDS geometric parameters from an
00042    * ISIS cube file.  The cube file must have been initialized with SPICE
00043    * kernels (typically by spiceinit).
00044    *
00045    * Many of the parameters are provided by the ISIS Spice/Cameraclass
00046    * hierarchy, but there are a few that utilize NAIF toolkit
00047    * functionality/features that require loading of the kernels that otherwise
00048    * would not be necessary.  These are parameters that require velecity vectors
00049    * and pixel smear components (currently not provided directly via the ISIS
00050    * API).
00051    *
00052    * Some of the keywords may not be computable for several reasons.  There may
00053    * not be appropriate kernel data coverage for the specified image acquisition
00054    * time, the boresight pixel does not intersect the surface, or the corner
00055    * pixels are off planet.  In these cases, the null string is replaced if the
00056    * actions is set appropriately.
00057    *
00058    * @ingroup Utility
00059    * @author 2007-08-14 Kris Becker
00060    * @internal
00061    * @history 2008-04-14 Kris Becker - Removed the isTargetValid() method as it
00062    *          was not implemented; Corrected computation of
00063    *          SC_TARGET_POSITION_VECTOR and TARGET_CENTER_DISTANCE when target
00064    *          is anything but Sky (it was previously only computed when the
00065    *          center reference pixel intersected the target).
00066    * @history 2009-09-18 Debbie A. Cook - corrected pxlscl and explen in 
00067    *                       MdisGeometry
00068    * @history 2012-04-06 Kris Becker - Corrected TWIST_ANGLE computation to 
00069    *                       ensure it is restricted to the 0-360 degree domain.
00070    * @history 2012-07-06 Debbie A. Cook, Updated Spice members to be more compliant with Isis 
00071    *                       coding standards.  References #972..
00072    * @history 2012-10-11 Debbie A. Cook, Updated to use new Target class.  References Mantis tickets 
00073    *                       #775 and #1114.
00074    */
00075   class MdisGeometry {
00076     public:
00077 
00078       /** Default constructor */
00079       MdisGeometry() : _label(), _orglabel(), _nSubframes(0), _camera(0),
00080         _digitsPrecision(_defaultDigits),
00081         _NullDefault("\"N/A\""), _doUpdate(true), _spice() { }
00082       MdisGeometry(const QString &filename);
00083       MdisGeometry(Cube &cube);
00084       virtual ~MdisGeometry() {
00085         delete _camera;
00086       }
00087 
00088       void setCube(const QString &filename);
00089       static bool validateTarget(Pvl &label, bool makeValid = true);
00090       virtual void refCenterCoord(double &sample, double &line) const;
00091       virtual void refUpperLeftCoord(double &sample, double &line) const;
00092       virtual void refUpperRightCoord(double &sample, double &line) const;
00093       virtual void refLowerLeftCoord(double &sample, double &line) const;
00094       virtual void refLowerRightCoord(double &sample, double &line) const;
00095       Pvl getGeometry(const QString &filename);
00096 
00097 
00098       /**
00099        *  @brief Sets digits of precision for floating point keywords
00100        *
00101        *  This method can be used to set the number of digits that follow the
00102        *  decimal point when formatting floating point keyword values.  PDS will
00103        *  typically specify 5 digits of precision (which is the defined by
00104        *  _defaultDigits).
00105        *
00106        */
00107       void setPrecision(int ndigits) {
00108         _digitsPrecision = ndigits;
00109       }
00110 
00111       /**
00112        * @brief Sets the string to be used for uncomputable values
00113        *
00114        * Use this method to set the string that will be used when values cannot
00115        * be computed.  PDS recommends the value of "N/A" for these cases.
00116        *
00117        * @param nullstring Value of the string to use
00118        */
00119       void setNull(const QString &nullstring) {
00120         _NullDefault = nullstring;
00121       }
00122 
00123       /**
00124        * @brief Value in use for uncomputable values
00125        *
00126        * @return QString Uncomputed value string
00127        */
00128       QString getNull() const {
00129         return (_NullDefault);
00130       }
00131 
00132       /**
00133        * @brief Select action when values cannot be computed
00134        *
00135        * When keyword values cannot be computed, the caller can set the action
00136        * taken for the keyword.  If action is true, the keyword value is set to
00137        * the null string.  If false, no action is taken and the keyword is not
00138        * generated.
00139        *
00140        * @param action True sets uncomputable keywords to null string,
00141        *               false is a noop.
00142        */
00143       void updateNullKeys(bool action = true) {
00144         _doUpdate = action;
00145       }
00146 
00147     protected:
00148       /** Return const reference to Camera model */
00149       const Camera &getCamera() const {
00150         return (*_camera);
00151       }
00152       /** Return reference to Camera model */
00153       Camera &getCamera() {
00154         return (*_camera);
00155       }
00156 
00157     private:
00158       enum { _defaultDigits = 5 };     //!< (PDS) Default digits of precision
00159       Pvl           _label;            //!< Label used to initialize camera model
00160       Pvl           _orglabel;         //!< Original label of PDS product
00161       int           _nSubframes;       //!< Number subframes in image
00162       Camera       *_camera;           //!< Camera model initiated from cube label
00163       int           _digitsPrecision;  //!< Current digits of precision
00164       QString   _NullDefault;      //!< Current null string
00165       bool          _doUpdate;         //!< Action when vlue is uncomputable
00166       SpiceManager _spice;             //!< SPICE kernel manager
00167 
00168       void init(Cube &cube);
00169 
00170       void GeometryKeys(Pvl &geom);
00171       void TargetKeys(Pvl &geom);
00172       void SubframeTargetKeys(Pvl &geom);
00173       bool getSubframeCoordinates(int frameno, double &sample, double &line,
00174                                   double &width, double &height);
00175       void SpacecraftKeys(Pvl &geom);
00176       void ViewingAndLightingKeys(Pvl &geom);
00177       bool SmearComponents(double &smear_magnitude, double &smear_azimuth);
00178       std::vector<double> ScVelocityVector();
00179 
00180       PvlKeyword format(const QString &name, const double &value,
00181                         const QString &unit = "") const;
00182       PvlKeyword format(const QString &name, const std::vector<double> &values,
00183                         const QString &unit = "") const;
00184       PvlKeyword format(const QString &name,
00185                         const std::vector<QString> &values,
00186                         const QString &unit = "") const;
00187       PvlKeyword format(const QString &name,
00188                         const std::vector<std::string> &values,
00189                         const QString &unit = "") const;
00190       QString DoubleToString(const double &value) const;
00191   };
00192 
00193 }     // namespace Isis
00194 #endif
00195