00001 // CLASSIFICATION: UNCLASSIFIED 00002 00003 #ifndef UTM_H 00004 #define UTM_H 00005 00006 /***************************************************************************/ 00007 /* RSC IDENTIFIER: UTM 00008 * 00009 * ABSTRACT 00010 * 00011 * This component provides conversions between geodetic coordinates 00012 * (latitude and longitudes) and Universal Transverse Mercator (UTM) 00013 * projection (zone, hemisphere, easting, and northing) coordinates. 00014 * 00015 * ERROR HANDLING 00016 * 00017 * This component checks parameters for valid values. If an invalid value 00018 * is found, the error code is combined with the current error code using 00019 * the bitwise or. This combining allows multiple error codes to be 00020 * returned. The possible error codes are: 00021 * 00022 * UTM_NO_ERROR : No errors occurred in function 00023 * UTM_LAT_ERROR : Latitude outside of valid range 00024 * (-80.5 to 84.5 degrees) 00025 * UTM_LON_ERROR : Longitude outside of valid range 00026 * (-180 to 360 degrees) 00027 * UTM_EASTING_ERROR : Easting outside of valid range 00028 * (100,000 to 900,000 meters) 00029 * UTM_NORTHING_ERROR : Northing outside of valid range 00030 * (0 to 10,000,000 meters) 00031 * UTM_ZONE_ERROR : Zone outside of valid range (1 to 60) 00032 * UTM_HEMISPHERE_ERROR : Invalid hemisphere ('N' or 'S') 00033 * UTM_ZONE_OVERRIDE_ERROR: Zone outside of valid range 00034 * (1 to 60) and within 1 of 'natural' zone 00035 * UTM_A_ERROR : Semi-major axis less than or equal to zero 00036 * UTM_INV_F_ERROR : Inverse flattening outside of valid range 00037 * (250 to 350) 00038 * 00039 * REUSE NOTES 00040 * 00041 * UTM is intended for reuse by any application that performs a Universal 00042 * Transverse Mercator (UTM) projection or its inverse. 00043 * 00044 * REFERENCES 00045 * 00046 * Further information on UTM can be found in the Reuse Manual. 00047 * 00048 * UTM originated from : U.S. Army Topographic Engineering Center 00049 * Geospatial Information Division 00050 * 7701 Telegraph Road 00051 * Alexandria, VA 22310-3864 00052 * 00053 * LICENSES 00054 * 00055 * None apply to this component. 00056 * 00057 * RESTRICTIONS 00058 * 00059 * UTM has no restrictions. 00060 * 00061 * ENVIRONMENT 00062 * 00063 * UTM was tested and certified in the following environments: 00064 * 00065 * 1. Solaris 2.5 with GCC, version 2.8.1 00066 * 2. MSDOS with MS Visual C++, version 6 00067 * 00068 * MODIFICATIONS 00069 * 00070 * Date Description 00071 * ---- ----------- 00072 * 2-27-07 Original C++ Code 00073 * 00074 */ 00075 00076 00077 #include <map> 00078 #include "CoordinateSystem.h" 00079 00080 00081 namespace MSP 00082 { 00083 namespace CCS 00084 { 00085 class UTMParameters; 00086 class TransverseMercator; 00087 class UTMCoordinates; 00088 class GeodeticCoordinates; 00089 00090 00091 /***************************************************************************/ 00092 /* 00093 * DEFINES 00094 */ 00095 00096 class UTM : public CoordinateSystem 00097 { 00098 public: 00099 00100 /* 00101 * The constructor receives the ellipsoid parameters and 00102 * UTM zone override parameter as inputs, and sets the corresponding state 00103 * variables. If any errors occur, an exception is thrown with a description 00104 * of the error. 00105 * 00106 * ellipsoidSemiMajorAxis : Semi-major axis of ellipsoid, in meters (input) 00107 * ellipsoidFlattening : Flattening of ellipsoid (input) 00108 * override : UTM override zone, zero indicates no override (input) 00109 */ 00110 00111 UTM( double ellipsoidSemiMajorAxis, double ellipsoidFlattening, long override ); 00112 00113 00114 UTM( const UTM &u ); 00115 00116 00117 ~UTM( void ); 00118 00119 00120 UTM& operator=( const UTM &u ); 00121 00122 00123 /* 00124 * The function getParameters returns the current ellipsoid 00125 * parameters and UTM zone override parameter. 00126 * 00127 * ellipsoidSemiMajorAxis : Semi-major axis of ellipsoid, in meters (output) 00128 * ellipsoidFlattening : Flattening of ellipsoid (output) 00129 * override : UTM override zone, zero indicates no override (output) 00130 */ 00131 00132 UTMParameters* getParameters() const; 00133 00134 00135 /* 00136 * The function convertFromGeodetic converts geodetic (latitude and 00137 * longitude) coordinates to UTM projection (zone, hemisphere, easting and 00138 * northing) coordinates according to the current ellipsoid and UTM zone 00139 * override parameters. If any errors occur, an exception is thrown 00140 * with a description of the error. 00141 * 00142 * longitude : Longitude in radians (input) 00143 * latitude : Latitude in radians (input) 00144 * zone : UTM zone (output) 00145 * hemisphere : North or South hemisphere (output) 00146 * easting : Easting (X) in meters (output) 00147 * northing : Northing (Y) in meters (output) 00148 */ 00149 00150 MSP::CCS::UTMCoordinates* convertFromGeodetic( MSP::CCS::GeodeticCoordinates* geodeticCoordinates ); 00151 00152 00153 /* 00154 * The function convertToGeodetic converts UTM projection (zone, 00155 * hemisphere, easting and northing) coordinates to geodetic(latitude 00156 * and longitude) coordinates, according to the current ellipsoid 00157 * parameters. If any errors occur, an exception is thrown 00158 * with a description of the error. 00159 * 00160 * zone : UTM zone (input) 00161 * hemisphere : North or South hemisphere (input) 00162 * easting : Easting (X) in meters (input) 00163 * northing : Northing (Y) in meters (input) 00164 * longitude : Longitude in radians (output) 00165 * latitude : Latitude in radians (output) 00166 */ 00167 00168 MSP::CCS::GeodeticCoordinates* convertToGeodetic( MSP::CCS::UTMCoordinates* utmCoordinates ); 00169 00170 private: 00171 00172 std::map< int, TransverseMercator* > transverseMercatorMap; 00173 00174 long UTM_Override; /* Zone override flag */ 00175 }; 00176 } 00177 } 00178 00179 #endif 00180 00181 00182 // CLASSIFICATION: UNCLASSIFIED