OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimSevenParamDatum.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts (gpotts@imagelinks.com)
6 //
7 // Description:
8 //
9 // SevenParamDatum. This is a base class for all
10 // seven param datums.
11 //*******************************************************************
12 // $Id: ossimSevenParamDatum.cpp 19795 2011-06-30 15:04:48Z gpotts $
13 
19 
20 RTTI_DEF1(ossimSevenParamDatum, "ossimSevenParamDatum", ossimDatum);
22 {
23  const ossimDatum* aDatum = aPt.datum();
24 
25  if( (ellipsoid()->getA()== aPt.datum()->ellipsoid()->getA())&&
26  (ellipsoid()->getB()== aPt.datum()->ellipsoid()->getB()))
27  {
28  return ossimGpt(aPt.latd(), aPt.lond(), aPt.height(), this);
29  }
30 
31  if(aDatum)
32  {
33  return shiftFromWgs84( aDatum->shiftToWgs84(aPt) );
34  }
35 
36  return aPt;
37 }
38 
40 {
41  ossimEcefPoint p1 = aPt;
42  ossimEcefPoint p2;
43 
44 // if(aPt.isHgtNan())
45 // {
46 // p1 = ossimEcefPoint(ossimGpt(aPt.latd(),
47 // aPt.lond(),
48 // 0,
49 // aPt.datum()));
50 // }
51 
52 // if(withinMolodenskyRange(aPt.latd()))
53 // {
54 // ossimWgs84Datum wgs84;
55 // double latin, lonin, hgtin;
56 // double latout, lonout, hgtout;
57 
58 // double a = wgs84.ellipsoid()->getA();
59 // double f = wgs84.ellipsoid()->getFlattening();
60 // double da = a - ellipsoid()->getA();
61 // double df = f - ellipsoid()->getFlattening();
62 
63 // latin = aPt.latr();
64 // lonin = aPt.lonr();
65 // hgtin = aPt.height();
66 
67 // if(aPt.isHgtNan())
68 // {
69 // hgtin = 0.0;
70 // }
71 // molodenskyShift(a, da, f, df, param1(), param2(), param3(),
72 // latin, lonin, hgtin,
73 // latout, lonout, hgtout);
74 
75 // ossimGpt g;
76 
77 // g.latr(latout);
78 // g.lonr(lonout);
79 // g.height(hgtout);
80 // if(aPt.isHgtNan())
81 // {
82 // g.height(OSSIM_DBL_NAN);
83 // }
84 // return g;
85 // }
86 // else
87  {
88  //this is straight from Geotrans
89  p2.x() = p1.x() + theParam1 + theParam6*p1.y() -
90  theParam5*p1.z() + theParam7*p1.x();
91  p2.y() = p1.y() + theParam2 - theParam6*p1.x()+
92  theParam4*p1.z() + theParam7*p1.y();
93  p2.z() = p1.z() + theParam3 + theParam5*p1.x() -
94  theParam4*p1.y() + theParam7*p1.z();
95  }
96 
97  return ossimGpt(p2); // defaults to WGS84
98 }
99 
101 {
102  ossimEcefPoint p1;
103  ossimEcefPoint p2;
104 
105  if(aPt.isHgtNan())
106  {
107  p1 = ossimEcefPoint(ossimGpt(aPt.latd(),
108  aPt.lond(),
109  0,
110  aPt.datum()));
111  }
112  else
113  {
114  p1 = ossimEcefPoint(aPt);
115  }
116 // if(withinMolodenskyRange(aPt.latd()))
117 // {
118 // ossimWgs84Datum wgs84;
119 // double latin, lonin, hgtin;
120 // double latout, lonout, hgtout;
121 
122 // double a = wgs84.ellipsoid()->getA();
123 // double f = wgs84.ellipsoid()->getFlattening();
124 // double da = ellipsoid()->getA() - a;
125 // double df = ellipsoid()->getFlattening() - f;
126 
127 // latin = aPt.latr();
128 // lonin = aPt.lonr();
129 // hgtin = aPt.height();
130 
131 // if(aPt.isHgtNan())
132 // {
133 // hgtin = 0.0;
134 // }
135 // molodenskyShift(a, da, f, df, -param1(), -param2(), -param3(),
136 // latin, lonin, hgtin,
137 // latout, lonout, hgtout);
138 // ossimGpt g;
139 
140 // g.latr(latout);
141 // g.lonr(lonout);
142 // g.height(hgtout);
143 // g.datum(this);
144 // return g;
145 // }
146 // else
147 // {
148  p2.x() = p1.x() - theParam1 - theParam6 * p1.y()
149  + theParam5 * p1.z() - theParam7 * p1.x();
150  p2.y() = p1.y() - theParam2 + theParam6 * p1.x()
151  - theParam4 *p1.z() - theParam7 * p1.y();
152 
153  p2.z() = p1.z() - theParam3 - theParam5 * p1.x()
154  + theParam4 * p1.y() - theParam7 * p1.z();
155 // }
156 
157  return ossimGpt(p2, this);
158 }
159 
161 {
162  const ossimSevenParamDatum* datum = dynamic_cast<const ossimSevenParamDatum*> (&obj);
163 
164  bool result = datum&&ossimDatum::isEqualTo(obj, compareType);
165 
166  if(result)
167  {
168  result = (ossim::almostEqual(theParam1, datum->theParam1)&&
175  );
176  }
177 
178  return result;
179 }
180 
RTTI_DEF1(ossimSevenParamDatum, "ossimSevenParamDatum", ossimDatum)
virtual ossimGpt shiftToWgs84(const ossimGpt &aPt) const =0
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
Definition: ossimCommon.h:53
virtual bool isEqualTo(const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
Definition: ossimDatum.cpp:179
double x() const
ossimCompareType
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
bool isHgtNan() const
Definition: ossimGpt.h:143
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
virtual bool isEqualTo(const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
const double & getA() const
virtual const ossimEllipsoid * ellipsoid() const
Definition: ossimDatum.h:60
double height() const
Definition: ossimGpt.h:107
ossimGpt shift(const ossimGpt &aPt) const
virtual ossimGpt shiftToWgs84(const ossimGpt &aPt) const
virtual ossimGpt shiftFromWgs84(const ossimGpt &aPt) const
double y() const
const double & getB() const
double z() const