00001 // CLASSIFICATION: UNCLASSIFIED 00002 00003 #ifndef Bonne_H 00004 #define Bonne_H 00005 00006 /***************************************************************************/ 00007 /* RSC IDENTIFIER: BONNE 00008 * 00009 * ABSTRACT 00010 * 00011 * This component provides conversions between Geodetic coordinates 00012 * (latitude and longitude in radians) and Bonne projection coordinates 00013 * (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 * BONN_NO_ERROR : No errors occurred in function 00023 * BONN_LAT_ERROR : Latitude outside of valid range 00024 * (-90 to 90 degrees) 00025 * BONN_LON_ERROR : Longitude outside of valid range 00026 * (-180 to 360 degrees) 00027 * BONN_EASTING_ERROR : Easting outside of valid range 00028 * (False_Easting +/- ~20,500,000 m, 00029 * depending on ellipsoid parameters 00030 * and Origin_Latitude) 00031 * BONN_NORTHING_ERROR : Northing outside of valid range 00032 * (False_Northing +/- ~23,500,000 m, 00033 * depending on ellipsoid parameters 00034 * and Origin_Latitude) 00035 * BONN_ORIGIN_LAT_ERROR : Origin latitude outside of valid range 00036 * (-90 to 90 degrees) 00037 * BONN_CENT_MER_ERROR : Central meridian outside of valid range 00038 * (-180 to 360 degrees) 00039 * BONN_A_ERROR : Semi-major axis less than or equal to zero 00040 * BONN_INV_F_ERROR : Inverse flattening outside of valid range 00041 * (250 to 350) 00042 * 00043 * REUSE NOTES 00044 * 00045 * BONNE is intended for reuse by any application that performs a 00046 * Bonne projection or its inverse. 00047 * 00048 * REFERENCES 00049 * 00050 * Further information on BONNE can be found in the Reuse Manual. 00051 * 00052 * BONNE originated from : U.S. Army Topographic Engineering Center 00053 * Geospatial Information Division 00054 * 7701 Telegraph Road 00055 * Alexandria, VA 22310-3864 00056 * 00057 * LICENSES 00058 * 00059 * None apply to this component. 00060 * 00061 * RESTRICTIONS 00062 * 00063 * BONNE has no restrictions. 00064 * 00065 * ENVIRONMENT 00066 * 00067 * BONNE was tested and certified in the following environments: 00068 * 00069 * 1. Solaris 2.5 with GCC 2.8.1 00070 * 2. MS Windows 95 with MS Visual C++ 6 00071 * 00072 * MODIFICATIONS 00073 * 00074 * Date Description 00075 * ---- ----------- 00076 * 04-16-99 Original Code 00077 * 03-05-07 Original C++ Code 00078 * 00079 */ 00080 00081 00082 #include "CoordinateSystem.h" 00083 00084 00085 namespace MSP 00086 { 00087 namespace CCS 00088 { 00089 class Sinusoidal; 00090 class MapProjection4Parameters; 00091 class MapProjectionCoordinates; 00092 class GeodeticCoordinates; 00093 00094 00095 /***************************************************************************/ 00096 /* 00097 * DEFINES 00098 */ 00099 00100 class Bonne : public CoordinateSystem 00101 { 00102 public: 00103 00104 /* 00105 * The constructor receives the ellipsoid parameters and 00106 * Bonne projection parameters as inputs, and sets the corresponding state 00107 * variables. If any errors occur, an exception is thrown with a description 00108 * of the error. 00109 * 00110 * ellipsoidSemiMajorAxis : Semi-major axis of ellipsoid, in meters (input) 00111 * ellipsoidFlattening : Flattening of ellipsoid (input) 00112 * centralMeridian : Longitude in radians at the center of (input) 00113 * the projection 00114 * originLatitude : Latitude in radians at which the (input) 00115 * point scale factor is 1.0 00116 * falseEasting : A coordinate value in meters assigned to the 00117 * central meridian of the projection. (input) 00118 * falseNorthing : A coordinate value in meters assigned to the 00119 * origin latitude of the projection (input) 00120 */ 00121 00122 Bonne( double ellipsoidSemiMajorAxis, double ellipsoidFlattening, double centralMeridian, double originLatitude, double falseEasting, double falseNorthing ); 00123 00124 00125 Bonne( const Bonne &b ); 00126 00127 00128 ~Bonne( void ); 00129 00130 00131 Bonne& operator=( const Bonne &b ); 00132 00133 00134 /* 00135 * The function getParameters returns the current ellipsoid 00136 * parameters and Bonne projection parameters. 00137 * 00138 * ellipsoidSemiMajorAxis : Semi-major axis of ellipsoid, in meters (output) 00139 * ellipsoidFlattening : Flattening of ellipsoid (output) 00140 * centralMeridian : Longitude in radians at the center of (output) 00141 * the projection 00142 * originLatitude : Latitude in radians at which the (output) 00143 * point scale factor is 1.0 00144 * falseEasting : A coordinate value in meters assigned to the 00145 * central meridian of the projection. (output) 00146 * falseNorthing : A coordinate value in meters assigned to the 00147 * origin latitude of the projection (output) 00148 */ 00149 00150 MapProjection4Parameters* getParameters() const; 00151 00152 00153 /* 00154 * The function convertFromGeodetic converts geodetic (latitude and 00155 * longitude) coordinates to Bonne projection (easting and northing) 00156 * coordinates, according to the current ellipsoid and Bonne projection 00157 * parameters. If any errors occur, an exception is thrown with a description 00158 * of the error. 00159 * 00160 * longitude : Longitude (lambda) in radians (input) 00161 * latitude : Latitude (phi) in radians (input) 00162 * easting : Easting (X) in meters (output) 00163 * northing : Northing (Y) in meters (output) 00164 */ 00165 00166 MSP::CCS::MapProjectionCoordinates* convertFromGeodetic( MSP::CCS::GeodeticCoordinates* geodeticCoordinates ); 00167 00168 00169 /* 00170 * The function convertToGeodetic converts Bonne projection 00171 * (easting and northing) coordinates to geodetic (latitude and longitude) 00172 * coordinates, according to the current ellipsoid and Bonne projection 00173 * coordinates. If any errors occur, an exception is thrown with a description 00174 * of the error. 00175 * 00176 * easting : Easting (X) in meters (input) 00177 * northing : Northing (Y) in meters (input) 00178 * longitude : Longitude (lambda) in radians (output) 00179 * latitude : Latitude (phi) in radians (output) 00180 */ 00181 00182 MSP::CCS::GeodeticCoordinates* convertToGeodetic( MSP::CCS::MapProjectionCoordinates* mapProjectionCoordinates ); 00183 00184 private: 00185 00186 Sinusoidal* sinusoidal; 00187 00188 /* Ellipsoid Parameters, default to WGS 84 */ 00189 double es2; /* Eccentricity (0.08181919084262188000) squared */ 00190 double es4; /* es2 * es2 */ 00191 double es6; /* es4 * es2 */ 00192 double M1; /* Bonn_M(Bonna,c0lat,c1s2lat,c2s4lat,c3s6lat) */ 00193 double m1; /* Bonn_m(coslat,sinlat,es2) */ 00194 double c0; /* 1 - es2 / 4.0 - 3.0 * es4 / 64.0 - 5.0 * es6 / 256.0 */ 00195 double c1; /* 3.0 * es2 / 8.0 + 3.0 * es4 / 32.0 + 45.0 * es6 / 1024.0 */ 00196 double c2; /* 15.0 * es4 / 256.0 + 45.0 * es6 / 1024.0 */ 00197 double c3; /* 35.0 * es6 / 3072.0 */ 00198 double a0; /* 3.0 * e1 / 2.0 - 27.0 * e3 / 32.0 */ 00199 double a1; /* 21.0 * e2 / 16.0 - 55.0 * e4 / 32.0 */ 00200 double a2; /* 151.0 * e3 / 96.0 */ 00201 double a3; /* 1097.0 * e4 / 512.0 */ 00202 00203 /* Bonne projection Parameters */ 00204 double Bonn_Origin_Lat; /* Latitude of origin in radians */ 00205 double Bonn_Origin_Long; /* Longitude of origin in radians */ 00206 double Bonn_False_Northing; /* False northing in meters */ 00207 double Bonn_False_Easting; /* False easting in meters */ 00208 double Sin_Bonn_Origin_Lat; /* sin(Bonn_Origin_Lat) */ 00209 double Bonn_am1sin; /* Bonn_a * m1 / Sin_Bonn_Origin_Lat */ 00210 00211 /* Maximum variance for easting and northing values for WGS 84. */ 00212 double Bonn_Max_Easting; 00213 double Bonn_Min_Easting; 00214 double Bonn_Delta_Northing; 00215 00216 00217 double bonnm( double coslat, double sinlat ); 00218 00219 double bonnM( double c0lat, double c1s2lat, double c2s4lat, double c3s6lat ); 00220 00221 double floatEq( double x, double v, double epsilon ); 00222 }; 00223 } 00224 } 00225 00226 #endif 00227 00228 00229 // CLASSIFICATION: UNCLASSIFIED