00001 /** 00002 * \file Constants.hpp 00003 * \brief Header for GeographicLib::Constants class 00004 * 00005 * Copyright (c) Charles Karney (2008) <charles@karney.com> 00006 * http://charles.karney.info/geographic 00007 * and licensed under the LGPL. 00008 **********************************************************************/ 00009 00010 #if !defined(CONSTANTS_HPP) 00011 #define CONSTANTS_HPP "$Id: Constants.hpp 6568 2009-03-01 17:58:41Z ckarney $" 00012 00013 namespace { 00014 char CONSTANTS_RCSID_H[] = CONSTANTS_HPP; 00015 } 00016 00017 namespace GeographicLib { 00018 00019 /** 00020 * \brief %Constants needed by %GeographicLib 00021 * 00022 * Define constants specifying the WGS84 ellipsoid, the UTM and UPS 00023 * projections, and various unit conversions. 00024 **********************************************************************/ 00025 class Constants { 00026 public: 00027 /** 00028 * pi 00029 **********************************************************************/ 00030 static inline double pi() throw() 00031 { return 3.141592653589793238462643383279502884; } 00032 /** 00033 * Factor to convert from degrees to radians 00034 **********************************************************************/ 00035 static inline double degree() throw() { return pi() / 180; } 00036 00037 /** \name Ellipsoid parameters 00038 **********************************************************************/ 00039 ///@{ 00040 /** 00041 * Major radius of WGS84 ellipsoid 00042 **********************************************************************/ 00043 static inline double WGS84_a() throw() { return 6378137 * meter(); } 00044 /** 00045 * Inverse flattening of WGS84 ellipsoid 00046 **********************************************************************/ 00047 static inline double WGS84_invf() throw() { return 298.257223563; } 00048 /** 00049 * Central scale factor for UTM 00050 **********************************************************************/ 00051 static inline double UTM_k0() throw() {return 0.9996; } 00052 /** 00053 * Central scale factor for UPS 00054 **********************************************************************/ 00055 static inline double UPS_k0() throw() { return 0.994; } 00056 ///@} 00057 00058 /** \name SI units 00059 **********************************************************************/ 00060 ///@{ 00061 /** 00062 * Factor to convert from meters to meters (i.e., 1, but this lets the 00063 * internal system of units be changed if necessary). 00064 **********************************************************************/ 00065 static inline double meter() throw() { return 1; } 00066 /** 00067 * Factor to convert from kilometers to meters. 00068 **********************************************************************/ 00069 static inline double kilometer() throw() { return 1000 * meter(); } 00070 ///@} 00071 00072 /** 00073 * Factor to convert from nautical miles (approximately 1 arc minute) to meters. 00074 **********************************************************************/ 00075 static inline double nauticalmile() throw() { return 1852 * meter(); } 00076 00077 /** \name Anachronistic British units 00078 **********************************************************************/ 00079 ///@{ 00080 /** 00081 * Factor to convert from international feet to meters. 00082 **********************************************************************/ 00083 static inline double foot() throw() { return 0.0254 * 12 * meter(); } 00084 /** 00085 * Factor to convert from yards to meters. 00086 **********************************************************************/ 00087 static inline double yard() throw() { return 3 * foot(); } 00088 /** 00089 * Factor to convert from fathoms to meters. 00090 **********************************************************************/ 00091 static inline double fathom() throw() { return 2 * yard(); } 00092 /** 00093 * Factor to convert from chains to meters. 00094 **********************************************************************/ 00095 static inline double chain() throw() { return 22 * yard(); } 00096 /** 00097 * Factor to convert from furlongs to meters. 00098 **********************************************************************/ 00099 static inline double furlong() throw() { return 10 * chain(); } 00100 /** 00101 * Factor to convert from statute miles to meters. 00102 **********************************************************************/ 00103 static inline double mile() throw() { return 8 * furlong(); } 00104 ///@} 00105 00106 /** \name Anachronistic US units 00107 **********************************************************************/ 00108 ///@{ 00109 /** 00110 * Factor to convert from US survery feet to meters. 00111 **********************************************************************/ 00112 static inline double surveyfoot() throw() 00113 { return 1200.0 / 3937.0 * meter(); } 00114 ///@} 00115 }; 00116 00117 } // namespace GeographicLib 00118 00119 #endif