1 //*******************************************************************
2 //
3 // License:  See top level LICENSE.txt file.
4 //
5 // Author:  Oscar Kramer
6 //
7 // Description:
8 //
9 // Sensor Model for Radarsat1 SAR sensor.
10 //
11 //*******************************************************************
12 //  $Id:$
13 
14 #ifndef ossimRS1SarModel_HEADER
15 #define ossimRS1SarModel_HEADER 1
16 
17 #include <ossim/base/ossimLsrPoint.h>
18 #include <ossim/base/ossimLsrVector.h>
19 #include <ossim/base/ossimEcefPoint.h>
20 #include <ossim/base/ossimGpt.h>
21 #include <ossim/base/ossimDrect.h>
22 #include <ossim/base/ossimFilename.h>
23 #include <ossim/base/ossimDblGrid.h>
24 #include <ossim/projection/ossimSarModel.h>
25 #include <ossim/base/ossimLagrangeInterpolator.h>
26 #include <ossim/support_data/ossimCeosData.h>
27 
28 // Namespace class forward class declaration.
29 namespace NEWMAT
30 {
31    class Matrix;
32 }
33 
34 //*****************************************************************************
35 // CLASS:  ossimRS1SarModel
36 //*****************************************************************************
37 class ossimRS1SarModel : public ossimSensorModel
38 {
39 public:
40    ossimRS1SarModel();
41    ossimRS1SarModel(const ossimFilename& imageDir);
42 
43    virtual ~ossimRS1SarModel();
44 
45    enum ImagingMode
46    {
47       UNKNOWN_MODE = 0,
48       SCN,     // ScanSAR Narrow Beam
49       SCW,     // ScanSAR Wide Beam
50       SGC,     // SAR Georeferenced Coarse Resolution
51       SGF,     // SAR Georeferenced Fine Resolution
52       SGX,     // SAR Georeferenced Extra Fine Resolution
53       SLC,     // Single Look Complex
54       SPG,     // SAR Precision Geocoded
55       SSG,     // SAR Systematically Geocoded
56       RAW,
57       ERS
58    };
59 
60    enum DirectionFlag
61    {
62       UNKNOWN_DIRECTION = 0,
63       ASCENDING,
64       DESCENDING
65    };
66 
67    //! Fulfills ossimObject base-class pure virtuals. Saves modeling info to KWL.
68    //! Returns true if successful.
69    virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=NULL) const;
70 
71    //! Fulfills ossimObject base-class pure virtuals. Reads modeling info from KWL.
72    //! Returns true if successful.
73    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=NULL);
74 
75    //! Establishes geographic 3D point given image line, sample and ellipsoid height.
76    virtual void lineSampleHeightToWorld(const ossimDpt& imagePt,
77                                         const double& heightAboveEllipsoid,
78                                         ossimGpt& worldPt) const;
79 
80    //! Given an image point, returns a ray originating at some arbitrarily high
81    //! point (in this model at the sensor position) and pointing towards the target.
82    virtual void imagingRay(const ossimDpt& image_point, ossimEcefRay& image_ray) const;
83 
84    inline virtual bool useForward() const { return false; } //!image to ground faster
85 
86    //!  Returns pointer to a new instance, copy of this.
87    virtual ossimObject* dup() const { return 0; } // TBR
88 
89 protected:
90    void setImagingMode(char* modeStr);
91    void initFromCeos(const ossimFilename& dataDir);
92    void initAdjParms();
93    void establishEphemeris();
94    void eciToEcfXform(const double& julianDay, NEWMAT::Matrix& xform) const;
95    void establishOrpInterp();
96    void establishOrpGrid();
97    void establishVehicleSpace();
98    void interpolatedScanORP(const ossimDpt& orp, ossimEcefPoint& orp_ecf) const;
99    void deallocateMemory();
100 
101    ossimRefPtr<ossimCeosData> theCeosData;
102    ossimRefPtr<ossimLagrangeInterpolator> theArpPosInterp;   // in ECF
103    ossimRefPtr<ossimLagrangeInterpolator> theArpVelInterp;   // in ECF
104    ossimRefPtr<ossimLagrangeInterpolator> theLocalOrpInterp; // in ECF
105    ImagingMode     theImagingMode;
106    double          theIllumAzimuth;
107    double          theIllumElevation;
108    ossimEcefPoint  theORP;
109    double          theRefHeight;
110    double          theGHA;           // Greenwich Hour Angle of first eph. pt.
111    double          theEphFirstSampTime; // in seconds from start of day
112    double          theSinOrientation;
113    double          theCosOrientation;
114    double          theSinSkew;
115    ossimLsrSpace   theVehicleSpace;
116    ossimEcefVector thePosCorrection;
117    int             theFirstLineDay;   // julian day
118    double          theFirstLineTime;  // seconds
119    double          theTimePerLine;    // seconds
120    DirectionFlag   theDirectionFlag;
121    double          theSrGrCoeff[6];
122    ossimDpt        thePixelSpacing;
123    //***
124    // Additional data members used for scan-mode imagery:
125    //***
126    ossimDblGrid    theLatGrid;
127    ossimDblGrid    theLonGrid;
128 
129    //***
130    // Adjustable Parameters:
131    //***
132    double          theInTrackOffset; // meters
133    double          theCrTrackOffset; // meters
134    double          theRadialOffset;  // meters
135    double          theLineScale;
136    double          theSkew;
137    double          theOrientation; // degrees
138 
139    //***
140    // Adjustable model parameters array indexes:
141    //***
142    enum ADJUSTABLE_PARAM_INDEXES
143    {
144       INTRACK_OFFSET,
145       CRTRACK_OFFSET,
146       RADIAL_OFFSET,
147       LINE_SCALE,
148       SKEW,
149       ORIENTATION,
150       NUM_ADJUSTABLE_PARAMS  // not a parameter
151    };
152 
153 };
154 
155 
156 #endif
157