OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGpt.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt.
4 //
5 // Author: Garrett Potts
6 //
7 // Description:
8 //
9 // Contains class declaration for gpt.
10 //
11 // CONSTRUCTOR TAKES LAT/LON IN DEGREES!!!
12 //
13 // Height is relative to the ellipsoid in meters.
14 //
15 //*******************************************************************
16 // $Id: ossimGpt.h 23159 2015-02-20 20:09:20Z okramer $
17 
18 #ifndef ossimGpt_HEADER
19 #define ossimGpt_HEADER 1
20 
22 #include <ossim/base/ossimDpt.h>
23 #include <ossim/base/ossimDpt3d.h>
26 #include <ossim/base/ossimString.h>
27 #include <iosfwd>
28 
29 class ossimDatum;
30 
32 {
33 public:
37  ossimGpt(const double alat=0, // degrees
38  const double alon=0, // degrees
39  const double ahgt=0,
40  const ossimDatum* aDatum=ossimDatumFactory::instance()->wgs84())
41  : lat(alat),
42  lon(alon),
43  hgt(ahgt), // relative to the ellipsoid
44  theDatum(aDatum) {}//limitLonTo180();}
45 
49  ossimGpt(const ossimGpt& src);
50 
54  ossimGpt(const ossimEcefPoint &aPt,
55  const ossimDatum* aDatum=ossimDatumFactory::instance()->wgs84());
56 
60  ossimGpt(const ossimDpt3d &aPt) :
61  lat(aPt.y), lon(aPt.x), hgt(aPt.z), theDatum(ossimDatumFactory::instance()->wgs84()) {}
62 
66  double latr()const{return lat*RAD_PER_DEG;}
67 
71  void latr(double radianValue){lat = radianValue*DEG_PER_RAD;}
72 
76  double lonr()const{return lon*RAD_PER_DEG;}
77 
81  void lonr(double radianValue)
82  {lon = radianValue*DEG_PER_RAD; }//limitLonTo180();}
83 
87  double latd()const{return lat;}
88 
92  void latd(double degreeValue){lat = degreeValue;}
93 
97  double lond()const{return lon;}
98 
102  void lond(double degreeValue){lon = degreeValue; }//limitLonTo180();}
103 
107  double height()const{return hgt;}
108 
114  double heightMSL() const;
115 
121  void height(double height){hgt = height;}
122 
128  void heightMSL(double heightMSL);
129 
130  void makeNan(){lat=ossim::nan(); lon=ossim::nan(); hgt=ossim::nan();}
131  bool isNan()const
132  {
133  return (ossim::isnan(lat)&&ossim::isnan(lon)&&ossim::isnan(hgt));
134  }
135  bool hasNans()const
136  {
137  return (ossim::isnan(lat)||ossim::isnan(lon)||ossim::isnan(hgt));
138  }
139  bool isLatNan()const{return ossim::isnan(lat);}
140  bool isLonNan()const{return ossim::isnan(lon);}
141  bool isLonLatNan()const{return (ossim::isnan(lat)||ossim::isnan(lon));}
142  bool isLatLonNan() const{return (ossim::isnan(lat)||ossim::isnan(lon));}
143  bool isHgtNan()const{return ossim::isnan(hgt);}
144 
145  std::ostream& print(std::ostream& os, ossim_uint32 precision=15) const;
146 
148  const ossimGpt& pt);
149 
159  ossimString toString(ossim_uint32 precision=15) const;
160 
173  void toPoint(const std::string& s);
174 
190  ossimGpt& pt);
191 
196  const ossimDatum* datum()const{return theDatum;}
197 
203  void datum(const ossimDatum* aDatum){theDatum = aDatum?aDatum:theDatum;}
204 
208  void changeDatum(const ossimDatum *datum);
209 
210  const ossimGpt& operator = (const ossimGpt &aPt);
211  bool operator ==(const ossimGpt& gpt)const;
212 
213  bool operator != (const ossimGpt& gpt) const { return !(*this == gpt); }
214 
220  { if (lon <= -180.0) lon += 360.0; else if (lon > 180.0) lon -= 360.0; }
221 
226  void wrap();
227 
228  void clampLon(double low, double high)
229  {
230  if(lon < low) lon = low;
231  if(lon > high) lon = high;
232  }
233 
234  void clampLat(double low, double high)
235  {
236  if(lat < low) lat = low;
237  if(lat > high) lat = high;
238  }
239 
240  void clampHgt(double low, double high)
241  {
242  if(hgt < low) hgt = low;
243  if(hgt > high) hgt = high;
244  }
245 
250  double distanceTo(const ossimGpt& arg_gpt) const;
251 
258  double azimuthTo(const ossimGpt& arg_gpt) const;
259 
260  ossimDpt metersPerDegree() const;
261 
262  ossimString toDmsString()const;
263 
264  bool isEqualTo(const ossimGpt& rhs, ossimCompareType compareType=OSSIM_COMPARE_FULL)const;
265  ossim_float64 lat; //> latitude in degrees measure
266  ossim_float64 lon; //> longitude in degrees measure
267 
275 
276 private:
277 
282 
283 };
284 
285 inline const ossimGpt& ossimGpt::operator=(const ossimGpt& aPt)
286 {
287  if ( this != &aPt )
288  {
289  lat = aPt.lat;
290  lon = aPt.lon;
291  hgt = aPt.hgt;
292 
293  if(aPt.datum())
294  {
295  theDatum = aPt.datum();
296  }
297  if(!theDatum)
298  {
300  }
301  }
302  return *this;
303 }
304 
305 inline void ossimGpt::wrap()
306 {
307  if ( lon > 180.0 )
308  {
309  do
310  {
311  lon = lon - 360.0;
312  } while ( lon > 180.0 );
313  }
314  else if ( lon < -180.0 )
315  {
316  do
317  {
318  lon = lon + 360.0;
319  } while ( lon < -180.0 );
320  }
321  if ( lat > 90.0 )
322  {
323  if ( lat > 360.0 ) // Remove total wraps.
324  {
325  do
326  {
327  lat = lat - 360.0;
328  } while ( lat > 360.0);
329  }
330  if ( lat > 270.0 ) // Between 270 and 360.
331  {
332  lat = lat - 360.0;
333  }
334  else if ( lat > 90 ) // Between 90 and 270.
335  {
336  lat = 180.0 - lat;
337  }
338  }
339  else if ( lat < -90.0 )
340  {
341  if ( lat < -360.0 ) // Remove total wraps.
342  {
343  do
344  {
345  lat = lat + 360.0;
346  } while ( lat < -360.0);
347  }
348  if ( lat < -270.0 )
349  {
350  lat = 360.0 + lat; // Between -270 and -360;
351  }
352  else if ( lat < -90.0 )
353  {
354  lat = -180.0 - lat;
355  }
356  }
357 }
358 
359 #endif /* #ifndef ossimGpt_HEADER */
void datum(const ossimDatum *aDatum)
Note: this will not do a shift.
Definition: ossimGpt.h:203
ossim_uint32 x
const ossimGpt & operator=(const ossimGpt &aPt)
Definition: ossimGpt.h:285
ossimGpt(const ossimDpt3d &aPt)
Argument aPt (x, y, z) is understood to represent (lon, lat, hgt) relative to WGS84 datum...
Definition: ossimGpt.h:60
#define OSSIMDLLEXPORT
void lond(double degreeValue)
Assumes the passed in value is in degrees.
Definition: ossimGpt.h:102
bool operator!=(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:111
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
#define DEG_PER_RAD
bool isLonNan() const
Definition: ossimGpt.h:140
const ossimDatum * theDatum
Know reference location plus an implied ellipsoid.
Definition: ossimGpt.h:281
ossim_uint32 y
void latd(double degreeValue)
Assumes the passed in value is in degrees.
Definition: ossimGpt.h:92
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
void clampLon(double low, double high)
Definition: ossimGpt.h:228
T wrap(T x, T a, T b)
Definition: ossimCommon.h:180
void makeNan()
Definition: ossimGpt.h:130
void clampHgt(double low, double high)
Definition: ossimGpt.h:240
ossim_float64 hgt
Height in meters above the ellipsiod.
Definition: ossimGpt.h:274
std::ostream & print(H5::H5File *file, std::ostream &out)
Print method.
Definition: ossimH5Util.cpp:41
ossimCompareType
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
void wrap()
Wrap method to maintain longitude between -180 and +180 and latitude between -90 and +90...
Definition: ossimGpt.h:305
bool isLatNan() const
Definition: ossimGpt.h:139
bool isHgtNan() const
Definition: ossimGpt.h:143
void limitLonTo180()
METHOD: limitLonTo180() Converts the lon data member to a value between -180 and +180: ...
Definition: ossimGpt.h:219
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
bool isNan() const
Definition: ossimGpt.h:131
double ossim_float64
ostream & operator<<(ostream &out, const ossimAxes &axes)
Definition: ossimAxes.h:88
ossim_float64 lon
Definition: ossimGpt.h:266
double lonr() const
Returns the longitude in radian measure.
Definition: ossimGpt.h:76
unsigned int ossim_uint32
double height() const
Definition: ossimGpt.h:107
static ossimDatumFactory * instance()
void clampLat(double low, double high)
Definition: ossimGpt.h:234
bool operator==(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:101
void lonr(double radianValue)
Assumes the value being passed in is in radians.
Definition: ossimGpt.h:81
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
bool isLonLatNan() const
Definition: ossimGpt.h:141
bool hasNans() const
Definition: ossimGpt.h:135
#define OSSIM_DLL
double latr() const
latr().
Definition: ossimGpt.h:66
void latr(double radianValue)
Returns the latitude in radian measure.
Definition: ossimGpt.h:71
ossimGpt(const double alat=0, const double alon=0, const double ahgt=0, const ossimDatum *aDatum=ossimDatumFactory::instance() ->wgs84())
Constructor.
Definition: ossimGpt.h:37
void height(double height)
Sets the "hgt" data member to height.
Definition: ossimGpt.h:121
ossim_float64 lat
Definition: ossimGpt.h:265
const ossimDatum * wgs84() const
bool isLatLonNan() const
Definition: ossimGpt.h:142
OSSIM_DLL void operator>>(ossimIStream &in, ossimOStream &out)
#define RAD_PER_DEG
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91