LRAUV  revA
Datum.h
Go to the documentation of this file.
1 
9 #ifndef DATUM_H_
10 #define DATUM_H_
11 
12 #include <math.h>
13 #include <cassert>
14 
15 #include "AuvMath.h"
16 
17 #include "../../Lib/geotrans/dt_cc/utm/utm.h"
18 #include "../../Lib/geotrans/dt_cc/tranmerc/tranmerc.h"
19 
21 static const double UTM_ZONE_WIDTH = M_PI / 30.;
22 
40 class Wgs84
41 {
42 public:
43 
49  static long UtmToLatLon( const double northings, const double eastings,
50  const unsigned int zone, const bool northernHemi,
51  double &lat, double &lon )
52  {
53  double myLat = 0.0, myLon = 0.0;
54  long myZone = zone;
55  long error = Convert_UTM_To_Geodetic( myZone, northernHemi ? 'N' : 'S',
56  eastings, northings, &myLat, &myLon );
57 
58  lat = myLat;
59  lon = myLon;
61  return error;
62  }
63 
66  static long LatLonToUtm( const double lat, const double lon,
67  double &northings, double &eastings,
68  unsigned int &zone, bool &northernHemi )
69  {
70  long myZone = 0;
71  double myNorthings = 0.0, myEastings = 0.0;
72  char myHemi = ' ';
73  long error = Convert_Geodetic_To_UTM( lat, lon,
74  &myZone, &myHemi,
75  &myEastings, &myNorthings );
76  zone = myZone;
77  eastings = myEastings;
78  northings = myNorthings;
79  northernHemi = ( myHemi == 'N' );
80  return error;
81  }
82 
83  static const char *UtmErrorToString( long error )
84  {
85  switch( error )
86  {
87  case UTM_NO_ERROR:
88  return "UTM_NO_ERROR";
89  case UTM_LAT_ERROR:
90  return "UTM_LAT_ERROR";
91  case UTM_LON_ERROR:
92  return "UTM_LON_ERROR";
93  case UTM_EASTING_ERROR:
94  return "UTM_EASTING_ERROR";
95  case UTM_NORTHING_ERROR:
96  return "UTM_NORTHING_ERROR";
97  case UTM_ZONE_ERROR:
98  return "UTM_ZONE_ERROR";
99  case UTM_HEMISPHERE_ERROR:
100  return "UTM_HEMISPHERE_ERROR";
101  case UTM_ZONE_OVERRIDE_ERROR:
102  return "UTM_ZONE_OVERRIDE_ERROR";
103  case UTM_A_ERROR:
104  return "UTM_A_ERROR";
105  case UTM_INV_F_ERROR:
106  return "UTM_INV_F_ERROR";
107  default:
108  return "(unknown)";
109  }
110  }
111 
112 private:
113 
115  {}
116  ;
117 };
118 
119 #endif /*DATUM_H_*/
Wgs84()
Definition: Datum.h:114
Contains the AuvMath class declaration.
static long LatLonToUtm(const double lat, const double lon, double &northings, double &eastings, unsigned int &zone, bool &northernHemi)
Converts a lat and lon (in radians!) to northings/eastings/zone.
Definition: Datum.h:66
static const char * UtmErrorToString(long error)
Definition: Datum.h:83
static long UtmToLatLon(const double northings, const double eastings, const unsigned int zone, const bool northernHemi, double &lat, double &lon)
Converts a UTM and zone to lat/lon (in radians!).
Definition: Datum.h:49
Provides Datum information, for only WGS84.
Definition: Datum.h:40