MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman at MIT 2001-2002 and Oxford 00010 // University 2003-2005. email: pnewman@robots.ox.ac.uk. 00011 // 00012 // This file is part of a MOOS Core Component. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License as 00016 // published by the Free Software Foundation; either version 2 of the 00017 // License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 // General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00030 // MOOSGeodesy.h: interface for the CMOOSGeodesy class. 00031 // 00033 00034 #if !defined(AFX_MOOSGEODESY_H__95563F0D_91C8_43FF_B277_4247C8C25E4D__INCLUDED_) 00035 #define AFX_MOOSGEODESY_H__95563F0D_91C8_43FF_B277_4247C8C25E4D__INCLUDED_ 00036 00037 #if _MSC_VER > 1000 00038 #pragma once 00039 #endif // _MSC_VER > 1000 00040 00041 #ifndef PI 00042 #define PI 3.14159265 00043 #endif 00044 00045 const double FOURTHPI = PI / 4; 00046 const double deg2rad = PI / 180; 00047 const double rad2deg = 180.0 / PI; 00048 00049 #define EARTH_RADIUS 6378137.0 //meters - WGS84 semi-major axis 00050 00052 class CMOOSGeodesy 00053 { 00054 public: 00055 CMOOSGeodesy(); 00056 virtual ~CMOOSGeodesy(); 00057 00058 double GetOriginNorthing(); 00059 double GetOriginEasting(); 00060 bool LatLong2LocalUTM(double lat, double lon, double & MetersNorth, double & MetersEast); 00061 bool LocalGrid2LatLong(double dfEast, double dfNorth, double &dfLat, double &dfLon); 00062 bool UTM2LatLong(double dfX, double dfY, double& dfLat, double& dfLong); 00063 00064 00065 char * GetUTMZone(); 00066 int GetRefEllipsoid(); 00067 double GetMetersEast(); 00068 double GetMetersNorth(); 00069 double GetOriginLatitude(); 00070 double GetOriginLongitude(); 00071 bool Initialise(double lat, double lon); 00072 00073 private: 00074 bool m_bSTEP_AFTER_INIT; 00075 char m_sUTMZone[4]; 00076 int m_iRefEllipsoid; 00077 double m_dOriginEasting; 00078 double m_dOriginNorthing; 00079 double m_dEast; 00080 double m_dNorth; 00081 double m_dOriginLongitude; 00082 double m_dOriginLatitude; 00083 double m_dLocalGridX; 00084 double m_dLocalGridY; 00085 00086 void SetUTMZone(const char * utmZone); 00087 void SetRefEllipsoid(int refEllipsoid); 00088 void SetOriginEasting(double East); 00089 00090 void SetOriginNorthing(double North); 00091 bool LLtoUTM(int ReferenceEllipsoid, const double Lat, const double Long, double &UTMNorthing, double &UTMEasting, char* UTMZone=0); 00092 void SetMetersEast(double East); 00093 void SetMetersNorth(double North); 00094 char UTMLetterDesignator(double Lat); 00095 00096 void SetOriginLatitude(double lat); 00097 void SetOriginLongitude(double lon); 00098 void SetLocalGridY(double Y); 00099 void SetLocalGridX(double X); 00100 00101 00102 public: 00103 double GetLocalGridY(); 00104 double GetLocalGridX(); 00105 00106 bool LatLong2LocalGrid(double lat, double lon, double &MetersNorth, double &MetersEast); 00107 double DMS2DecDeg(double dfVal); 00108 class CEllipsoid 00109 { 00110 public: 00111 CEllipsoid(){}; 00112 CEllipsoid(int Id, const char* name, double radius, double ecc) 00113 { 00114 id = Id; 00115 ellipsoidName = name; 00116 EquatorialRadius = radius; 00117 eccentricitySquared = ecc; 00118 }; 00119 00120 int id; 00121 const char* ellipsoidName; 00122 double EquatorialRadius; 00123 double eccentricitySquared; 00124 00125 }; 00126 00127 }; 00128 00130 static CMOOSGeodesy::CEllipsoid ellipsoid[] = 00131 {// id, Ellipsoid name, Equatorial Radius, square of eccentricity 00132 CMOOSGeodesy::CEllipsoid( -1, "Placeholder", 0, 0),//placeholder only, To allow array indices to match id numbers 00133 CMOOSGeodesy::CEllipsoid( 1, "Airy", 6377563, 0.00667054), 00134 CMOOSGeodesy::CEllipsoid( 2, "Australian National", 6378160, 0.006694542), 00135 CMOOSGeodesy::CEllipsoid( 3, "Bessel 1841", 6377397, 0.006674372), 00136 CMOOSGeodesy::CEllipsoid( 4, "Bessel 1841 (Nambia) ", 6377484, 0.006674372), 00137 CMOOSGeodesy::CEllipsoid( 5, "Clarke 1866", 6378206, 0.006768658), 00138 CMOOSGeodesy::CEllipsoid( 6, "Clarke 1880", 6378249, 0.006803511), 00139 CMOOSGeodesy::CEllipsoid( 7, "Everest", 6377276, 0.006637847), 00140 CMOOSGeodesy::CEllipsoid( 8, "Fischer 1960 (Mercury) ", 6378166, 0.006693422), 00141 CMOOSGeodesy::CEllipsoid( 9, "Fischer 1968", 6378150, 0.006693422), 00142 CMOOSGeodesy::CEllipsoid( 10, "GRS 1967", 6378160, 0.006694605), 00143 CMOOSGeodesy::CEllipsoid( 11, "GRS 1980", 6378137, 0.00669438), 00144 CMOOSGeodesy::CEllipsoid( 12, "Helmert 1906", 6378200, 0.006693422), 00145 CMOOSGeodesy::CEllipsoid( 13, "Hough", 6378270, 0.00672267), 00146 CMOOSGeodesy::CEllipsoid( 14, "International", 6378388, 0.00672267), 00147 CMOOSGeodesy::CEllipsoid( 15, "Krassovsky", 6378245, 0.006693422), 00148 CMOOSGeodesy::CEllipsoid( 16, "Modified Airy", 6377340, 0.00667054), 00149 CMOOSGeodesy::CEllipsoid( 17, "Modified Everest", 6377304, 0.006637847), 00150 CMOOSGeodesy::CEllipsoid( 18, "Modified Fischer 1960", 6378155, 0.006693422), 00151 CMOOSGeodesy::CEllipsoid( 19, "South American 1969", 6378160, 0.006694542), 00152 CMOOSGeodesy::CEllipsoid( 20, "WGS 60", 6378165, 0.006693422), 00153 CMOOSGeodesy::CEllipsoid( 21, "WGS 66", 6378145, 0.006694542), 00154 CMOOSGeodesy::CEllipsoid( 22, "WGS-72", 6378135, 0.006694318), 00155 CMOOSGeodesy::CEllipsoid( 23, "WGS-84", 6378137, 0.00669438) 00156 }; 00157 00158 #endif // !defined(AFX_MOOSGEODESY_H__95563F0D_91C8_43FF_B277_4247C8C25E4D__INCLUDED_)