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 * 5-02-11 DR 28872, interface added to allow setting zone override 00074 * for each fromGeodetic call. The override in the call has 00075 * precedence over what is set in the class constructor. 00076 * 5-09-11 DR 28908, add default constructor 00077 */ 00078 00079 00080 #include <map> 00081 #include "CoordinateSystem.h" 00082 00083 00084 namespace MSP 00085 { 00086 namespace CCS 00087 { 00088 class UTMParameters; 00089 class TransverseMercator; 00090 class UTMCoordinates; 00091 class GeodeticCoordinates; 00092 00093 00094 /***********************************************************************/ 00095 /* 00096 * DEFINES 00097 */ 00098 00099 class MSP_DTCC_API UTM : public CoordinateSystem 00100 { 00101 public: 00102 00103 /* 00104 * The constructor receives the ellipsoid parameters and 00105 * UTM zone override parameter as inputs, and sets the 00106 * corresponding state variables. If any errors occur, 00107 * an exception is thrown with a description of the error. 00108 * 00109 * ellipsoidSemiMajorAxis : Semi-major axis in meters (input) 00110 * ellipsoidFlattening : Flattening of ellipsoid (input) 00111 * override : UTM override zone, 0 indicates no override (input) 00112 */ 00113 00114 UTM(); 00115 00116 UTM( 00117 double ellipsoidSemiMajorAxis, 00118 double ellipsoidFlattening, 00119 long override = 0 ); 00120 00121 00122 UTM( const UTM &u ); 00123 00124 00125 ~UTM( void ); 00126 00127 00128 UTM& operator=( const UTM &u ); 00129 00130 00131 /* 00132 * The function getParameters returns the current ellipsoid 00133 * parameters and UTM zone override parameter. 00134 * 00135 * ellipsoidSemiMajorAxis : Semi-major axis (meters) (output) 00136 * ellipsoidFlattening : Flattening of ellipsoid (output) 00137 * override : UTM override zone, zero indicates no override (output) 00138 */ 00139 00140 UTMParameters* getParameters() const; 00141 00142 00143 /* 00144 * The function convertFromGeodetic converts geodetic (latitude and 00145 * longitude) coordinates to UTM projection (zone, hemisphere, 00146 * easting and northing) coordinates according to the current 00147 * ellipsoid and UTM zone override parameters. If any errors occur, 00148 * an exception is thrown with a description of the error. 00149 * 00150 * longitude : Longitude in radians (input) 00151 * latitude : Latitude in radians (input) 00152 * utmZoneOverride : zone override (input) 00153 * zone : UTM zone (output) 00154 * hemisphere : North or South hemisphere (output) 00155 * easting : Easting (X) in meters (output) 00156 * northing : Northing (Y) in meters (output) 00157 */ 00158 00159 MSP::CCS::UTMCoordinates* convertFromGeodetic( 00160 MSP::CCS::GeodeticCoordinates* geodeticCoordinates, 00161 int utmZoneOverride = 0 ); 00162 00163 00164 /* 00165 * The function convertToGeodetic converts UTM projection (zone, 00166 * hemisphere, easting and northing) coordinates to geodetic 00167 * (latitude and longitude) coordinates, according to the 00168 * current ellipsoid parameters. If any errors occur, 00169 * an exception is thrown with a description of the error. 00170 * 00171 * zone : UTM zone (input) 00172 * hemisphere : North or South hemisphere (input) 00173 * easting : Easting (X) in meters (input) 00174 * northing : Northing (Y) in meters (input) 00175 * longitude : Longitude in radians (output) 00176 * latitude : Latitude in radians (output) 00177 */ 00178 00179 MSP::CCS::GeodeticCoordinates* convertToGeodetic( 00180 MSP::CCS::UTMCoordinates* utmCoordinates ); 00181 00182 private: 00183 00184 std::map< int, TransverseMercator* > transverseMercatorMap; 00185 00186 long UTM_Override; /* Zone override flag */ 00187 }; 00188 } 00189 } 00190 00191 #endif 00192 00193 00194 // CLASSIFICATION: UNCLASSIFIED