00001 // CLASSIFICATION: UNCLASSIFIED 00002 00003 #ifndef ObliqueMercator_H 00004 #define ObliqueMercator_H 00005 00006 /***************************************************************************/ 00007 /* RSC IDENTIFIER: OBLIQUE MERCATOR 00008 * 00009 * ABSTRACT 00010 * 00011 * This component provides conversions between Geodetic coordinates 00012 * (latitude and longitude in radians) and Oblique Mercator 00013 * projection coordinates (easting and northing in meters). 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 * OMERC_NO_ERROR : No errors occurred in function 00023 * OMERC_LAT_ERROR : Latitude outside of valid range 00024 * (-90 to 90 degrees) 00025 * OMERC_LON_ERROR : Longitude outside of valid range 00026 * (-180 to 360 degrees) 00027 * OMERC_ORIGIN_LAT_ERROR : Origin latitude outside of valid range 00028 * (-89 to 89 degrees) 00029 * OMERC_LAT1_ERROR : First latitude outside of valid range 00030 * (-89 to 89 degrees, excluding 0) 00031 * OMERC_LAT2_ERROR : First latitude outside of valid range 00032 * (-89 to 89 degrees) 00033 * OMERC_LON1_ERROR : First longitude outside of valid range 00034 * (-180 to 360 degrees) 00035 * OMERC_LON2_ERROR : Second longitude outside of valid range 00036 * (-180 to 360 degrees) 00037 * OMERC_LAT1_LAT2_ERROR : First and second latitudes can not be equal 00038 * OMERC_DIFF_HEMISPHERE_ERROR: First and second latitudes can not be 00039 * in different hemispheres 00040 * OMERC_EASTING_ERROR : Easting outside of valid range 00041 * (depends on ellipsoid and projection 00042 * parameters) 00043 * OMERC_NORTHING_ERROR : Northing outside of valid range 00044 * (depends on ellipsoid and projection 00045 * parameters) 00046 * OMERC_A_ERROR : Semi-major axis less than or equal to zero 00047 * OMERC_INV_F_ERROR : Inverse flattening outside of valid range 00048 * (250 to 350) 00049 * OMERC_SCALE_FACTOR_ERROR : Scale factor outside of valid 00050 * range (0.3 to 3.0) 00051 * OMERC_LON_WARNING : Distortion will result if longitude is 90 degrees or more 00052 * from the Central Meridian 00053 * 00054 * REUSE NOTES 00055 * 00056 * OBLIQUE MERCATOR is intended for reuse by any application that 00057 * performs an Oblique Mercator projection or its inverse. 00058 * 00059 * REFERENCES 00060 * 00061 * Further information on OBLIQUE MERCATOR can be found in the Reuse Manual. 00062 * 00063 * OBLIQUE MERCATOR originated from: U.S. Army Topographic Engineering Center 00064 * Geospatial Information Division 00065 * 7701 Telegraph Road 00066 * Alexandria, VA 22310-3864 00067 * 00068 * LICENSES 00069 * 00070 * None apply to this component. 00071 * 00072 * RESTRICTIONS 00073 * 00074 * OBLIQUE MERCATOR has no restrictions. 00075 * 00076 * ENVIRONMENT 00077 * 00078 * OBLIQUE MERCATOR was tested and certified in the following environments: 00079 * 00080 * 1. Solaris 2.5 with GCC, version 2.8.1 00081 * 2. MSDOS with MS Visual C++, version 6 00082 * 00083 * MODIFICATIONS 00084 * 00085 * Date Description 00086 * ---- ----------- 00087 * 06-07-00 Original Code 00088 * 03-02-07 Original C++ Code 00089 * 00090 * 00091 */ 00092 00093 00094 #include "CoordinateSystem.h" 00095 00096 00097 namespace MSP 00098 { 00099 namespace CCS 00100 { 00101 class ObliqueMercatorParameters; 00102 class MapProjectionCoordinates; 00103 class GeodeticCoordinates; 00104 00105 00106 /***************************************************************************/ 00107 /* 00108 * DEFINES 00109 */ 00110 00111 class ObliqueMercator : public CoordinateSystem 00112 { 00113 public: 00114 00115 /* 00116 * The constructor receives the ellipsoid parameters and 00117 * projection parameters as inputs, and sets the corresponding state 00118 * variables. If any errors occur, an exception is thrown with a description 00119 * of the error. 00120 * 00121 * ellipsoidSemiMajorAxis : Semi-major axis of ellipsoid, in meters (input) 00122 * ellipsoidFlattening : Flattening of ellipsoid (input) 00123 * originLatitude : Latitude, in radians, at which the (input) 00124 * point scale factor is 1.0 00125 * longitude1 : Longitude, in radians, of first point lying on 00126 * central line (input) 00127 * latitude1 : Latitude, in radians, of first point lying on 00128 * central line (input) 00129 * longitude2 : Longitude, in radians, of second point lying on 00130 * central line (input) 00131 * latitude2 : Latitude, in radians, of second point lying on 00132 * central line (input) 00133 * falseEasting : A coordinate value, in meters, assigned to the 00134 * central meridian of the projection (input) 00135 * falseNorthing : A coordinate value, in meters, assigned to the 00136 * origin latitude of the projection (input) 00137 * scaleFactor : Multiplier which reduces distances in the 00138 * projection to the actual distance on the 00139 * ellipsoid (input) 00140 * errorStatus : Error status (output) 00141 */ 00142 00143 ObliqueMercator( double ellipsoidSemiMajorAxis, double ellipsoidFlattening, double originLatitude, double longitude1, double latitude1, double longitude2, double latitude2, double falseEasting, double falseNorthing, double scaleFactor ); 00144 00145 00146 ObliqueMercator( const ObliqueMercator &om ); 00147 00148 00149 ~ObliqueMercator( void ); 00150 00151 00152 ObliqueMercator& operator=( const ObliqueMercator &om ); 00153 00154 00155 /* 00156 * The function getParameters returns the current ellipsoid 00157 * parameters and Oblique Mercator projection parameters. 00158 * 00159 * ellipsoidSemiMajorAxis : Semi-major axis of ellipsoid, in meters (output) 00160 * ellipsoidFlattening : Flattening of ellipsoid (output) 00161 * originLatitude : Latitude, in radians, at which the (output) 00162 * point scale factor is 1.0 00163 * longitude1 : Longitude, in radians, of first point lying on 00164 * central line (output) 00165 * latitude1 : Latitude, in radians, of first point lying on 00166 * central line (output) 00167 * longitude2 : Longitude, in radians, of second point lying on 00168 * central line (output) 00169 * latitude2 : Latitude, in radians, of second point lying on 00170 * central line (output) 00171 * falseEasting : A coordinate value, in meters, assigned to the 00172 * central meridian of the projection (output) 00173 * falseNorthing : A coordinate value, in meters, assigned to the 00174 * origin latitude of the projection (output) 00175 * scaleFactor : Multiplier which reduces distances in the 00176 * projection to the actual distance on the 00177 * ellipsoid (output) 00178 */ 00179 00180 ObliqueMercatorParameters* getParameters() const; 00181 00182 00183 /* 00184 * The function convertFromGeodetic converts geodetic (latitude and 00185 * longitude) coordinates to Oblique Mercator projection (easting and 00186 * northing) coordinates, according to the current ellipsoid and Oblique Mercator 00187 * projection parameters. If any errors occur, an exception is thrown with a description 00188 * of the error. 00189 * 00190 * longitude : Longitude (lambda), in radians (input) 00191 * latitude : Latitude (phi), in radians (input) 00192 * easting : Easting (X), in meters (output) 00193 * northing : Northing (Y), in meters (output) 00194 */ 00195 00196 MSP::CCS::MapProjectionCoordinates* convertFromGeodetic( MSP::CCS::GeodeticCoordinates* geodeticCoordinates ); 00197 00198 00199 /* 00200 * The function convertToGeodetic converts Oblique Mercator projection 00201 * (easting and northing) coordinates to geodetic (latitude and longitude) 00202 * coordinates, according to the current ellipsoid and Oblique Mercator projection 00203 * coordinates. If any errors occur, an exception is thrown with a description 00204 * of the error. 00205 * 00206 * easting : Easting (X), in meters (input) 00207 * northing : Northing (Y), in meters (input) 00208 * longitude : Longitude (lambda), in radians (output) 00209 * latitude : Latitude (phi), in radians (output) 00210 */ 00211 00212 MSP::CCS::GeodeticCoordinates* convertToGeodetic( MSP::CCS::MapProjectionCoordinates* mapProjectionCoordinates ); 00213 00214 private: 00215 00216 /* Ellipsoid Parameters, default to WGS 84 */ 00217 double es; 00218 double es_OVER_2; 00219 double OMerc_A; 00220 double OMerc_B; 00221 double OMerc_E; 00222 double OMerc_gamma; 00223 double OMerc_azimuth; /* Azimuth of central line as it crosses origin lat */ 00224 double OMerc_Origin_Long; /* Longitude at center of projection */ 00225 double cos_gamma; 00226 double sin_gamma; 00227 double sin_azimuth; 00228 double cos_azimuth; 00229 double A_over_B; 00230 double B_over_A; 00231 double OMerc_u; /* Coordinates for center point (uc , vc), vc = 0 */ 00232 /* at center lat and lon */ 00233 /* Oblique Mercator projection Parameters */ 00234 double OMerc_Origin_Lat; /* Latitude of projection center, in radians */ 00235 double OMerc_Lat_1; /* Latitude of first point lying on central line */ 00236 double OMerc_Lon_1; /* Longitude of first point lying on central line */ 00237 double OMerc_Lat_2; /* Latitude of second point lying on central line */ 00238 double OMerc_Lon_2; /* Longitude of second point lying on central line */ 00239 double OMerc_Scale_Factor; /* Scale factor at projection center */ 00240 double OMerc_False_Northing; /* False northing, in meters, at projection center */ 00241 double OMerc_False_Easting; /* False easting, in meters, at projection center */ 00242 00243 double OMerc_Delta_Northing; 00244 double OMerc_Delta_Easting; 00245 00246 00247 double omercT( double lat, double e_sinlat, double e_over_2 ); 00248 00249 }; 00250 } 00251 } 00252 00253 #endif 00254 00255 00256 // CLASSIFICATION: UNCLASSIFIED