1 //***************************************************************************** 2 // FILE: ossimCoarseGridModel.h 3 // 4 // Copyright (C) 2001 ImageLinks, Inc. 5 // 6 // License: MIT 7 // 8 // See LICENSE.txt file in the top level directory for more details. 9 // 10 // AUTHOR: Oscar Kramer 11 // 12 // DESCRIPTION: 13 // Contains declaration of class ossimCoarseGridModel. This is an 14 // implementation of an interpolation sensor model. 15 // 16 //***************************************************************************** 17 // $Id: ossimCoarseGridModel.h 22825 2014-07-07 23:14:52Z dburken $ 18 19 #ifndef ossimCoarseGridModel_HEADER 20 #define ossimCoarseGridModel_HEADER 1 21 22 #include <ossim/projection/ossimSensorModel.h> 23 #include <ossim/base/ossimIpt.h> 24 #include <ossim/base/ossimDblGrid.h> 25 #include <ossim/base/ossimFilename.h> 26 27 class ossimImageGeometry; 28 29 /****************************************************************************** 30 * 31 * CLASS: ossimCoarseGridModel 32 * 33 *****************************************************************************/ 34 class OSSIMDLLEXPORT ossimCoarseGridModel : public ossimSensorModel 35 { 36 public: 37 ossimCoarseGridModel(); 38 ossimCoarseGridModel(const ossimCoarseGridModel& copy_this); 39 40 /** Accepts name of geometry file. This can be either MET ECG geom file, or 41 * OSSIM keywordlist geometry file.*/ 42 ossimCoarseGridModel(const ossimFilename& geom_file); 43 44 /** Accepts OSSIM keywordlist geometry file. */ 45 ossimCoarseGridModel(const ossimKeywordlist& geom_kwl); 46 47 ~ossimCoarseGridModel(); 48 49 /** This method will build a grid from any projector. The accuracy of the grid can be 50 * controlled by the static method setInterpolationError(). 51 * @param imageBounds Must be the image space bounds for the projection. 52 * @param proj The projector that will be used to approximate a bilinear grid over. */ 53 virtual void buildGrid(const ossimDrect& imageBounds, 54 ossimProjection* proj, 55 double heightDelta=500.0, 56 bool enableHeightFlag=false, 57 bool makeAdjustableFlag=true); 58 virtual void buildGrid(const ossimDrect& imageBounds, 59 ossimImageGeometry* geom, 60 double heightDelta=500.0, 61 bool enableHeightFlag=false, 62 bool makeAdjustableFlag=true); 63 64 /** This is used when building a grid from a projector. You can set the interpolation error. 65 * The default is subpixel accuracy (within .1 of a pixel). */ 66 static void setInterpolationError(double error=.1); 67 static void setMinGridSpacing(ossim_int32 minSpacing = 100); 68 69 /** Extends base-class implementation. Dumps contents of object to std::ostream. */ 70 virtual std::ostream& print(std::ostream& out) const; 71 72 /** Fulfills ossimObject base-class pure virtuals. Saves geometry KWL files. 73 * @return Returns true if successful. */ 74 virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0) const; 75 76 /** Fulfills ossimObject base-class pure virtuals. Loads geometry KWL files. 77 * @return Returns true if successful. */ 78 virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0); 79 80 /** Writes a template of geometry keywords processed by loadState and 81 * saveState to output stream. */ 82 static void writeGeomTemplate(std::ostream& os); 83 84 /** Returns pointer to a new instance, copy of this. */ dup()85 virtual ossimObject* dup() const { return new ossimCoarseGridModel(*this); } 86 87 /** Saves the coarse grid to the specified file. 88 * @return Returns true if successful. */ 89 bool saveCoarseGrid(const ossimFilename& cgFileName) const; 90 91 /** Loads the coarse grid from the specified file. 92 * @return Returns true if successful. */ 93 bool loadCoarseGrid(const ossimFilename& cgFileName); 94 95 virtual void imagingRay(const ossimDpt& image_point, ossimEcefRay& image_ray) const; 96 97 98 virtual void lineSampleToWorld(const ossimDpt& image_point, ossimGpt& gpt) const; 99 100 /** This is the virtual that performs the actual work of projecting the image point 101 * to the earth at some specified elevation. */ 102 virtual void lineSampleHeightToWorld(const ossimDpt& image_point, 103 const double& heightEllipsoid, 104 ossimGpt& world_pt) const; 105 106 virtual void initAdjustableParameters(); 107 108 /*! 109 * ossimOptimizableProjection 110 */ useForward()111 inline virtual bool useForward()const {return false;} //!image to ground faster 112 113 /** Overrides base ossimSensorModel::isAffectedByElevation method. 114 * @return true if height enabled, false if not. */ 115 virtual bool isAffectedByElevation() const; 116 117 protected: 118 119 /** Deletes existing allocated memory and reallocates 120 * new space. This may happen if a new grid is loaded over an existing one. */ 121 void reallocateGrid(const ossimIpt& size); 122 123 //! Initializes base class data members after grids have been assigned. 124 void initializeModelParams(ossimIrect irect); 125 126 //! Implements its own extrapolation since this can be handled by ossimDblGrid. 127 virtual ossimGpt extrapolate (const ossimDpt& imgPt, const double& height=ossim::nan()) const; 128 129 mutable ossimFilename theGridFilename; 130 ossimDblGrid theLatGrid; // degrees 131 ossimDblGrid theLonGrid; // degrees 132 ossimDblGrid theDlatDhGrid; // degrees/meter 133 ossimDblGrid theDlonDhGrid; // degrees/meter 134 ossimDblGrid* theDlatDparamGrid; // degrees/(units-of-param) 135 ossimDblGrid* theDlonDparamGrid; // degrees/(units-of-param) 136 137 static double theInterpolationError; 138 static ossim_int32 theMinGridSpacing; 139 ossimAdjustmentInfo theInitialAdjustment; 140 bool theHeightEnabledFlag; 141 142 TYPE_DATA 143 }; 144 145 #endif 146