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