00001 // CLASSIFICATION: UNCLASSIFIED 00002 00003 #ifndef BritishNationalGrid_H 00004 #define BritishNationalGrid_H 00005 00006 /***************************************************************************/ 00007 /* RSC IDENTIFIER: BRITISH NATIONAL GRID 00008 * 00009 * ABSTRACT 00010 * 00011 * This component provides conversions between Geodetic coordinates 00012 * (latitude and longitude) and British National Grid coordinates. 00013 * 00014 * ERROR HANDLING 00015 * 00016 * This component checks parameters for valid values. If an invalid value 00017 * is found the error code is combined with the current error code using 00018 * the bitwise or. This combining allows multiple error codes to be 00019 * returned. The possible error codes are: 00020 * 00021 * BNG_NO_ERROR : No errors occurred in function 00022 * BNG_LAT_ERROR : Latitude outside of valid range 00023 * (49.5 to 61.5 degrees) 00024 * BNG_LON_ERROR : Longitude outside of valid range 00025 * (-10.0 to 3.5 degrees) 00026 * BNG_EASTING_ERROR : Easting outside of valid range 00027 * (depending on ellipsoid and 00028 * projection parameters) 00029 * BNG_NORTHING_ERROR : Northing outside of valid range 00030 * (depending on ellipsoid and 00031 * projection parameters) 00032 * BNG_STRING_ERROR : A BNG string error: string too long, 00033 * too short, or badly formed 00034 * BNG_INVALID_AREA_ERROR : Coordinate is outside of valid area 00035 * BNG_ELLIPSOID_ERROR : Invalid ellipsoid - must be Airy 00036 * 00037 * REUSE NOTES 00038 * 00039 * BRITISH NATIONAL GRID is intended for reuse by any application that 00040 * performs a British National Grid projection or its inverse. 00041 * 00042 * REFERENCES 00043 * 00044 * Further information on BRITISH NATIONAL GRID can be found in the 00045 * Reuse Manual. 00046 * 00047 * BRITISH NATIONAL GRID originated from : 00048 * 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 * BRITISH NATIONAL GRID has no restrictions. 00060 * 00061 * ENVIRONMENT 00062 * 00063 * BRITISH NATIONAL GRID was tested and certified in the following 00064 * environments: 00065 * 00066 * 1. Solaris 2.5 with GCC, version 2.8.1 00067 * 2. Windows 95 with MS Visual C++, version 6 00068 * 00069 * MODIFICATIONS 00070 * 00071 * Date Description 00072 * ---- ----------- 00073 * 09-06-00 Original Code 00074 * 03-02-07 Original C++ Code 00075 * 00076 * 00077 */ 00078 00079 #include "DtccApi.h" 00080 #include "CoordinateSystem.h" 00081 00082 00083 00084 namespace MSP 00085 { 00086 namespace CCS 00087 { 00088 class EllipsoidParameters; 00089 class TransverseMercator; 00090 class BNGCoordinates; 00091 class GeodeticCoordinates; 00092 00093 00094 /***************************************************************************/ 00095 /* 00096 * DEFINES 00097 */ 00098 class MSP_DTCC_API BritishNationalGrid : public CoordinateSystem 00099 { 00100 public: 00101 00102 /* 00103 * The constructor receives the ellipsoid code and sets 00104 * the corresponding state variables. If any errors occur, an exception is thrown 00105 * with a description of the error. 00106 * 00107 * ellipsoidCode : 2-letter code for ellipsoid (input) 00108 */ 00109 00110 BritishNationalGrid( char *ellipsoidCode ); 00111 00112 00113 BritishNationalGrid( const BritishNationalGrid &bng ); 00114 00115 00116 ~BritishNationalGrid( void ); 00117 00118 00119 BritishNationalGrid& operator=( const BritishNationalGrid &bng ); 00120 00121 00122 /* 00123 * The function getParameters returns the current ellipsoid 00124 * code. 00125 * 00126 * ellipsoidCode : 2-letter code for ellipsoid (output) 00127 */ 00128 00129 EllipsoidParameters* getParameters() const; 00130 00131 00132 /* 00133 * The function convertFromGeodetic converts geodetic (latitude and 00134 * longitude) coordinates to a BNG coordinate string, according to the 00135 * current ellipsoid parameters. If any errors occur, an exception is thrown 00136 * with a description of the error. 00137 * 00138 * longitude : Longitude, in radians (input) 00139 * latitude : Latitude, in radians (input) 00140 * precision : Precision level of BNG string (input) 00141 * BNGString : British National Grid coordinate string (output) 00142 * 00143 */ 00144 00145 MSP::CCS::BNGCoordinates* convertFromGeodetic( MSP::CCS::GeodeticCoordinates* geodeticCoordinates, long precision ); 00146 00147 00148 /* 00149 * The function convertToGeodetic converts a BNG coordinate string 00150 * to geodetic (latitude and longitude) coordinates, according to the current 00151 * ellipsoid parameters. If any errors occur, an exception is thrown 00152 * with a description of the error. 00153 * 00154 * BNGString : British National Grid coordinate string (input) 00155 * longitude : Longitude, in radians (output) 00156 * latitude : Latitude, in radians (output) 00157 * 00158 */ 00159 00160 MSP::CCS::GeodeticCoordinates* convertToGeodetic( MSP::CCS::BNGCoordinates* bngCoordinates ); 00161 00162 00163 /* 00164 * The function convertFromTransverseMercator converts Transverse Mercator 00165 * (easting and northing) coordinates to a BNG coordinate string, according 00166 * to the current ellipsoid parameters. If any errors occur, an exception is thrown 00167 * with a description of the error. 00168 * 00169 * easting : Easting (X), in meters (input) 00170 * northing : Northing (Y), in meters (input) 00171 * precision : Precision level of BNG string (input) 00172 * BNGString : British National Grid coordinate string (output) 00173 */ 00174 00175 MSP::CCS::BNGCoordinates* convertFromTransverseMercator( MapProjectionCoordinates* mapProjectionCoordinates, long precision ); 00176 00177 00178 /* 00179 * The function convertToTransverseMercator converts a BNG coordinate string 00180 * to Transverse Mercator projection (easting and northing) coordinates 00181 * according to the current ellipsoid parameters. If any errors occur, an exception is thrown 00182 * with a description of the error. 00183 * 00184 * BNGString : British National Grid coordinate string (input) 00185 * easting : Easting (X), in meters (output) 00186 * northing : Northing (Y), in meters (output) 00187 */ 00188 00189 MSP::CCS::MapProjectionCoordinates* convertToTransverseMercator( MSP::CCS::BNGCoordinates* bngCoordinates ); 00190 00191 private: 00192 00193 TransverseMercator* transverseMercator; 00194 00195 char BNG_Letters[3]; 00196 double BNG_Easting; 00197 double BNG_Northing; 00198 char BNG_Ellipsoid_Code[3]; 00199 00200 }; 00201 } 00202 } 00203 00204 #endif 00205 00206 00207 // CLASSIFICATION: UNCLASSIFIED