OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimSensorModel.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // FILE: ossimSensorModel.h
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // AUTHOR: Oscar Kramer
7 //
8 // DESCRIPTION:
9 // Contains declaration of class ossimSensorModel. This is the base class to
10 // all sensor model-related projections including replacement models such as
11 // coarse grids and polynomial models. This base class supports adjustable
12 // parameters for registration adjustment.
13 //
14 // Important note to sensor model implementors: In order to avoid a separate
15 // set of "initial adjustable parameters," this design assumes ALL initial
16 // values are 0. When designing the derived-class model, insure that the
17 // adjustable parameters are 0-based. This applies to theAdjustableParams
18 // array declared in this base class only. The derived classes can declare
19 // their own adjstable params that are more descriptive and that can be
20 // assigned an initial value that is non-zero, but that are linearly related
21 // to the adjustable params of this class. In that case, the updateModel()
22 // method will compute the derived-class's parameters based on
23 // theAdjustableParams array, after an adjustment is made.
24 //
25 // LIMITATIONS: None.
26 //
27 //*****************************************************************************
28 // $Id: ossimSensorModel.h 23297 2015-05-05 20:32:16Z dburken $
29 
30 #ifndef ossimSensorModel_HEADER
31 #define ossimSensorModel_HEADER 1
32 
37 #include <ossim/base/ossimString.h>
39 #include <ossim/base/ossimDrect.h>
40 #include <ossim/base/ossimCommon.h> /* for ossim::nan() */
43 #include <ossim/matrix/newmat.h>
44 #include <ossim/matrix/newmatap.h>
46 class ossimKeywordlist;
47 class ossimTieGptSet;
48 
49 /*!****************************************************************************
50  *
51  * CLASS: ossimSensorModel
52  *
53  *****************************************************************************/
57 {
58 public:
59 
61  {
62  COV_INVALID = 0,
63  COV_PARTIAL = 1,
64  COV_FULL = 2
65  };
66 
68  {
69  OBS_INIT =-99,
70  EVALUATE =-98,
71  P_WRT_X = -1,
72  P_WRT_Y = -2,
73  P_WRT_Z = -3
74  };
75 
80  ossimSensorModel(const ossimSensorModel& copy_this);
81  ossimSensorModel(const ossimKeywordlist& geom_kwl);
82 
84  const ossimSensorModel& operator=( const ossimSensorModel& rhs );
85 
86  virtual ossimObject* getBaseObject();
87  virtual const ossimObject* getBaseObject()const;
88 
92  virtual ossimGpt origin() const {return theRefGndPt; }
93  virtual ossimDpt getMetersPerPixel() const {return ossimDpt(fabs(theGSD.x),
94  fabs(theGSD.y));}
95 
97  virtual const double& getNominalPosError() const { return theNominalPosError; }
98 
100  virtual const double& getRelativePosError() const { return theRelPosError; }
101 
103  virtual void setNominalPosError(const double& ce90) { theNominalPosError = ce90; }
104 
106  virtual void setRelativePosError(const double& ce90) { theRelPosError = ce90; }
107 
114  virtual void lineSampleToWorld(const ossimDpt& image_point,
115  ossimGpt& world_point) const;
116  virtual void worldToLineSample(const ossimGpt& world_point,
117  ossimDpt& image_point) const;
118 
124  virtual void lineSampleHeightToWorld(const ossimDpt& lineSampPt,
125  const double& heightEllipsoid,
126  ossimGpt& worldPt) const = 0;
133  virtual void imagingRay(const ossimDpt& image_point,
134  ossimEcefRay& image_ray) const;
135 
140  virtual std::ostream& print(std::ostream& out) const;
141 
147  void setRefImgPt(const ossimDpt& pt);
148 
154  void setRefGndPt(const ossimGpt& pt);
155 
156 
157  void setImageRect(const ossimDrect& imageRect);
158  void setGroundRect(const ossimGpt& ul,
159  const ossimGpt& ur,
160  const ossimGpt& lr,
161  const ossimGpt& ll);
166  ossimDpt imageSize() const { return theImageSize; }
167  void setImageSize(const ossimDpt& size){theImageSize = size;}
173  {
174  updateModel();
175  }
182  virtual void updateModel() {}
183 
189  virtual bool saveState(ossimKeywordlist& kwl,
190  const char* prefix=0) const;
191 
192  virtual bool loadState(const ossimKeywordlist& kwl,
193  const char* prefix=0);
194 
199  virtual bool insideImage(const ossimDpt& p) const
200  {
201 /* return( (p.u>=(0.0-FLT_EPSILON)) && */
202 /* (p.u<=(double)(theImageSize.u-(1-FLT_EPSILON))) && */
203 /* (p.v>=(0.0-FLT_EPSILON)) && */
204 /* (p.v<=(double)(theImageSize.v-(1-FLT_EPSILON))) ); */
205  // if it's close to the edge we will consider it inside the image
206  //
207  return theImageClipRect.pointWithin(p, 2.0);
208  }
209 
215  static void writeGeomTemplate(ostream& os);
216 
220  virtual bool operator==(const ossimProjection& proj) const; //inline below
221 
223  const ossimString& getImageID() const { return theImageID; }
224  const ossimDrect& getImageClipRect() const { return theImageClipRect; }
225 
229  virtual ossim_uint32 degreesOfFreedom()const;
230  inline virtual bool needsInitialState()const {return true;}
231  virtual double optimizeFit(const ossimTieGptSet& tieSet,
232  double* targetVariance=0);
233 
240  virtual ossimDpt getForwardDeriv(int parmIdx, const ossimGpt& gpos, double hdelta=1e-11);
241 
248  virtual ossimGpt getInverseDeriv(int parmIdx, const ossimDpt& ipos, double hdelta=1e-11);
249 
254  virtual ossimSensorModel::CovMatStatus getObsCovMat(
255  const ossimDpt& ipos, NEWMAT::SymmetricMatrix& Cov,
256  const ossim_float64 defPointingSigma = 0.5) const;
257 
263  virtual bool isAffectedByElevation() const { return true; }
264 
272  void computeGsd();
273 
282  virtual bool getImageGeometry(
283  const ossimString& /* key */, const ossimString& /* value */,
284  ossimKeywordlist& /* geomKwl */ ) const { return false; }
285 
286 protected:
287  virtual ~ossimSensorModel();
288 
289 
296  virtual ossimDpt extrapolate (const ossimGpt& gp) const;
297  virtual ossimGpt extrapolate (const ossimDpt& ip,
298  const double& height=ossim::nan()) const;
299 
316  void buildNormalEquation(const ossimTieGptSet& tieSet,
317  NEWMAT::SymmetricMatrix& A,
318  NEWMAT::ColumnVector& residue,
319  NEWMAT::ColumnVector& projResidue,
320  double pstep_scale);
321 
326  NEWMAT::ColumnVector getResidue(const ossimTieGptSet& tieSet);
327 
328  NEWMAT::ColumnVector solveLeastSquares(NEWMAT::SymmetricMatrix& A, NEWMAT::ColumnVector& r)const;
329 
333  NEWMAT::Matrix invert(const NEWMAT::Matrix& m)const;
334 
336 
341 
344  ossimDpt theGSD; // meters
346  ossimGpt theRefGndPt; // should be image center
347  ossimDpt theRefImgPt; // should be image center
350  ossim_float64 theRelPosError; // meters, relative to other models in the set
352 
357 
361 
367 
370 
371 TYPE_DATA
372 };
373 
374 //================= BEGIN INLINE DEFINITIONS =================================
375 
376 //*****************************************************************************
377 // OPERATOR ==
378 //*****************************************************************************
379 inline bool ossimSensorModel::operator==(const ossimProjection& proj) const
380 {
381  // const ossimSensorModel* model
382  // = PTR_CAST(ossimSensorModel, (const ossimProjection*) &proj);
383  const ossimSensorModel* model = dynamic_cast<const ossimSensorModel*>( &proj );
384  if ( (!model) ||
385  (theSensorID != model->theSensorID) ||
386  (theImageID != model->theImageID) ||
388  return false;
389 
390  return true;
391 }
392 
393 #endif
ossimString theSensorID
virtual const double & getNominalPosError() const
Returns the estimated Absolute horizontal position error (CE90) of the sensor model.
ossim_float64 theRelPosError
#define OSSIMDLLEXPORT
virtual bool isAffectedByElevation() const
Implementation of pure virtual ossimProjection::isAffectedByElevation method.
Represents serializable keyword/value map.
ossimString theImageID
virtual void updateModel()
Provides the derived adjustable class an opportunity to update its state after a param change...
virtual ossim_uint32 degreesOfFreedom() const =0
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
virtual const double & getRelativePosError() const
Returns the estimated RELATIVE horizontal position error (CE90) of the sensor model.
virtual void setNominalPosError(const double &ce90)
Assigns the absolute image position error uncertainty (abs CE90)
virtual double optimizeFit(const ossimTieGptSet &tieSet, double *targetVariance=0)=0
#define A(r, c)
ossimDpt imageSize() const
double ossim_float64
ossimDpt theSubImageOffset
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual class enabling projection optimization (can be used for outlier rejection - RANSAC) ...
yy_size_t size
ossim_float64 theNominalPosError
#define TYPE_DATA
Definition: ossimRtti.h:339
virtual void lineSampleHeightToWorld(const ossimDpt &lineSampPt, const double &heightAboveEllipsoid, ossimGpt &worldPt) const =0
unsigned int ossim_uint32
ossimPolygon theBoundGndPolygon
virtual void adjustableParametersChanged()
virtual bool needsInitialState() const
needsInitialState()
bool operator==(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:101
virtual void updateModel()
virtual ossimDpt getMetersPerPixel() const
ossimRefPtr< ossimProjection > theSeedFunction
Used as an initial guess for iterative solutions and a guess for points outside the support bounds...
virtual bool getImageGeometry(const ossimString &, const ossimString &, ossimKeywordlist &) const
Extracts geometry info from a non-ossim key,value pair to an ossim keyword list.
ossimDrect theImageClipRect
const ossimDrect & getImageClipRect() const
storage class for a set of geographic tie points, between master and slave images ...
std::ostream & print(std::ostream &out) const
Dumps the currently active adjustment to ostream.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual ossimObject * getBaseObject()=0
virtual ossimGpt origin() const
virtual bool insideImage(const ossimDpt &p) const
const ossimAdjustableParameterInterface & operator=(const ossimAdjustableParameterInterface &rhs)
ossimDpt theParWRTx
Partials for current point.
virtual void lineSampleToWorld(const ossimDpt &lineSampPt, ossimGpt &worldPt) const =0
virtual bool operator==(const ossimProjection &proj) const
const ossimString & getImageID() const
Access methods:
ossimDpt theObs
Observations & residuals for current point.
virtual void worldToLineSample(const ossimGpt &worldPoint, ossimDpt &lineSampPt) const =0
virtual void setRelativePosError(const double &ce90)
Assigns the relative image position error uncertainty (rel CE90)
ossim_float64 theMeanGSD
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
void setImageSize(const ossimDpt &size)