OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimThreeParamDatum.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 // $Id: ossimThreeParamDatum.cpp 19795 2011-06-30 15:04:48Z gpotts $
10 
11 #include <cmath>
12 
17 #include <ossim/base/ossimGpt.h>
20 
21 RTTI_DEF1(ossimThreeParamDatum, "ossimThreeParamDatum", ossimDatum);
23 {
24 
25  if(ossim::almostEqual(param1(), 0.0)&&
26  ossim::almostEqual(param2(), 0.0)&&
27  ossim::almostEqual(param3(), 0.0))
28  {
29  return ossimGpt(aPt.latd(),
30  aPt.lond(),
31  aPt.latd(),
32  ossimGpt().datum());
33  }
34 
35  ossimEcefPoint p1 = aPt;
36  ossimEcefPoint p2;
37 
38 
39  if(withinMolodenskyRange(aPt.latd()))
40  {
41  ossimWgs84Datum wgs84;
42  double latin, lonin, hgtin;
43  double latout, lonout, hgtout;
44 
45  double da = wgs84.ellipsoid()->getA() - ellipsoid()->getA();
46  double df = wgs84.ellipsoid()->getFlattening() - ellipsoid()->getFlattening();
47 
48  latin = aPt.latr();
49  lonin = aPt.lonr();
50  hgtin = aPt.height();
51 
52  if(aPt.isHgtNan())
53  {
54  hgtin = 0.0;
55  }
56  molodenskyShift(ellipsoid()->getA(), da, ellipsoid()->getFlattening(), df, param1(), param2(), param3(),
57  latin, lonin, hgtin,
58  latout, lonout, hgtout);
59  ossimGpt g;
60 
61  g.latr(latout);
62  g.lonr(lonout);
63  g.height(hgtout);
64  g.datum(this);
65  return g;
66  }
67  else
68  {
69  p2 = ossimEcefPoint(p1.x() + theParam1,
70  p1.y() + theParam2,
71  p1.z() + theParam3);
72  }
73 
74  return ossimGpt(p2); // defaults to WGS84
75 }
76 
78 {
79  if(ossim::almostEqual(param1(), 0.0)&&
80  ossim::almostEqual(param2(), 0.0)&&
81  ossim::almostEqual(param3(), 0.0))
82  {
83  return ossimGpt(aPt.latd(),
84  aPt.lond(),
85  aPt.latd(),
86  this);
87  }
88  ossimEcefPoint p1=aPt;
89  ossimEcefPoint p2=aPt;
90 
91  if(withinMolodenskyRange(aPt.latd()))
92  {
93  ossimWgs84Datum wgs84;
94  double latin, lonin, hgtin;
95  double latout, lonout, hgtout;
96 
97  double da = ellipsoid()->getA() - wgs84.ellipsoid()->getA();
98  double df = ellipsoid()->getFlattening() - wgs84.ellipsoid()->getFlattening();
99 
100  latin = aPt.latr();
101  lonin = aPt.lonr();
102  hgtin = aPt.height();
103 
104  if(aPt.isHgtNan())
105  {
106  hgtin = 0.0;
107  }
108  molodenskyShift(wgs84.ellipsoid()->getA(), da, wgs84.ellipsoid()->getFlattening(), df, -param1(), -param2(), -param3(),
109  latin, lonin, hgtin,
110  latout, lonout, hgtout);
111  ossimGpt g;
112 
113  g.latr(latout);
114  g.lonr(lonout);
115  g.height(hgtout);
116  g.datum(this);
117  return g;
118  }
119  else
120  {
121  p2 = ossimEcefPoint(p1.x() - theParam1,
122  p1.y() - theParam2,
123  p1.z() - theParam3);
124  }
125 
126 
127  return ossimGpt(p2, this);
128 }
129 
130 
132 {
133  const ossimDatum *aDatum = aPt.datum();
134 
135  if( code() == aDatum->code())
136  {
137  return ossimGpt(aPt.latd(), aPt.lond(), aPt.height(), this);
138  }
139 
140  if(aDatum)
141  {
142  return shiftFromWgs84(aDatum->shiftToWgs84(aPt));
143  }
144 
145  return aPt;
146 }
147 
149 {
150  const ossimThreeParamDatum* datum = dynamic_cast<const ossimThreeParamDatum*> (&obj);
151 
152  bool result = datum&&ossimDatum::isEqualTo(obj, compareType);
153 
154  if(result)
155  {
156  result = (ossim::almostEqual(theParam1, datum->theParam1)&&
159  }
160 
161  return result;
162 }
virtual ossimGpt shiftToWgs84(const ossimGpt &aPt) const =0
virtual ossimGpt shiftToWgs84(const ossimGpt &aPt) const
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
virtual const ossimString & code() const
Definition: ossimDatum.h:57
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 ossim_float64 param1() const
bool withinMolodenskyRange(const ossimGpt &pt) const
Definition: ossimDatum.h:124
virtual bool isEqualTo(const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
const double & getA() const
double lonr() const
Returns the longitude in radian measure.
Definition: ossimGpt.h:76
virtual const ossimEllipsoid * ellipsoid() const
Definition: ossimDatum.h:60
double height() const
Definition: ossimGpt.h:107
virtual ossimGpt shiftFromWgs84(const ossimGpt &aPt) const
virtual void molodenskyShift(double a, double da, double f, double df, double dx, double dy, double dz, double Lat_in, double Lon_in, double Hgt_in, double &Lat_out, double &Lon_out, double &Hgt_out) const
Definition: ossimDatum.cpp:38
virtual ossimGpt shift(const ossimGpt &aPt) const
double y() const
virtual ossim_float64 param2() const
double latr() const
latr().
Definition: ossimGpt.h:66
const double & getFlattening() const
RTTI_DEF1(ossimThreeParamDatum, "ossimThreeParamDatum", ossimDatum)
virtual ossim_float64 param3() const
double z() const