00001 /** 00002 * \file NETGeographicLib/OSGB.h 00003 * \brief Header for NETGeographicLib::OSGB class 00004 * 00005 * NETGeographicLib is copyright (c) Scott Heiman (2013) 00006 * GeographicLib is Copyright (c) Charles Karney (2010-2012) 00007 * <charles@karney.com> and licensed under the MIT/X11 License. 00008 * For more information, see 00009 * http://geographiclib.sourceforge.net/ 00010 **********************************************************************/ 00011 #pragma once 00012 00013 namespace NETGeographicLib 00014 { 00015 /** 00016 * \brief .NET wrapper for GeographicLib::OSGB. 00017 * 00018 * This class allows .NET applications to access GeographicLib::OSGB. 00019 * 00020 * The class implements the coordinate system used by the Ordnance Survey for 00021 * maps of Great Britain and conversions to the grid reference system. 00022 * 00023 * See 00024 * - <a href="http://www.ordnancesurvey.co.uk/docs/support/guide-coordinate-systems-great-britain.pdf"> 00025 * A guide to coordinate systems in Great Britain</a> 00026 * - <a href="http://www.ordnancesurvey.co.uk/docs/support/national-grid.pdf"> 00027 * Guide to the National Grid</a> 00028 * 00029 * \b WARNING: the latitudes and longitudes for the Ordnance Survey grid 00030 * system do not use the WGS84 datum. Do not use the values returned by this 00031 * class in the UTMUPS, MGRS, or Geoid classes without first converting the 00032 * datum (and vice versa). 00033 * 00034 * C# Example: 00035 * \include example-OSGB.cs 00036 * Managed C++ Example: 00037 * \include example-OSGB.cpp 00038 * Visual Basic Example: 00039 * \include example-OSGB.vb 00040 **********************************************************************/ 00041 public ref class OSGB 00042 { 00043 private: 00044 // hide the constructor since all member are static 00045 OSGB(void) {} 00046 public: 00047 00048 /** 00049 * Forward projection, from geographic to OSGB coordinates. 00050 * 00051 * @param[in] lat latitude of point (degrees). 00052 * @param[in] lon longitude of point (degrees). 00053 * @param[out] x easting of point (meters). 00054 * @param[out] y northing of point (meters). 00055 * @param[out] gamma meridian convergence at point (degrees). 00056 * @param[out] k scale of projection at point. 00057 * 00058 * \e lat should be in the range [−90°, 90°]; \e lon 00059 * should be in the range [−540°, 540°). 00060 **********************************************************************/ 00061 static void Forward(double lat, double lon, 00062 [System::Runtime::InteropServices::Out] double% x, 00063 [System::Runtime::InteropServices::Out] double% y, 00064 [System::Runtime::InteropServices::Out] double% gamma, 00065 [System::Runtime::InteropServices::Out] double% k); 00066 00067 /** 00068 * Reverse projection, from OSGB coordinates to geographic. 00069 * 00070 * @param[in] x easting of point (meters). 00071 * @param[in] y northing of point (meters). 00072 * @param[out] lat latitude of point (degrees). 00073 * @param[out] lon longitude of point (degrees). 00074 * @param[out] gamma meridian convergence at point (degrees). 00075 * @param[out] k scale of projection at point. 00076 * 00077 * The value of \e lon returned is in the range [−180°, 00078 * 180°). 00079 **********************************************************************/ 00080 00081 static void Reverse(double x, double y, 00082 [System::Runtime::InteropServices::Out] double% lat, 00083 [System::Runtime::InteropServices::Out] double% lon, 00084 [System::Runtime::InteropServices::Out] double% gamma, 00085 [System::Runtime::InteropServices::Out] double% k); 00086 00087 /** 00088 * OSGB::Forward without returning the convergence and scale. 00089 **********************************************************************/ 00090 static void Forward(double lat, double lon, 00091 [System::Runtime::InteropServices::Out] double% x, 00092 [System::Runtime::InteropServices::Out] double% y); 00093 00094 /** 00095 * OSGB::Reverse without returning the convergence and scale. 00096 **********************************************************************/ 00097 static void Reverse(double x, double y, 00098 [System::Runtime::InteropServices::Out] double% lat, 00099 [System::Runtime::InteropServices::Out] double% lon); 00100 00101 /** 00102 * Convert OSGB coordinates to a grid reference. 00103 * 00104 * @param[in] x easting of point (meters). 00105 * @param[in] y northing of point (meters). 00106 * @param[in] prec precision relative to 100 km. 00107 * @param[out] gridref National Grid reference. 00108 * @exception GeographicErr if \e prec, \e x, or \e y is outside its 00109 * allowed range. 00110 * @exception std::bad_alloc if the memory for \e gridref can't be 00111 * allocatied. 00112 * 00113 * \e prec specifies the precision of the grid reference string as follows: 00114 * - prec = 0 (min), 100km 00115 * - prec = 1, 10km 00116 * - prec = 2, 1km 00117 * - prec = 3, 100m 00118 * - prec = 4, 10m 00119 * - prec = 5, 1m 00120 * - prec = 6, 0.1m 00121 * - prec = 11 (max), 1μm 00122 * 00123 * The easting must be in the range [−1000 km, 1500 km) and the 00124 * northing must be in the range [−500 km, 2000 km). These bounds 00125 * are consistent with rules for the letter designations for the grid 00126 * system. 00127 **********************************************************************/ 00128 static void GridReference(double x, double y, int prec, 00129 [System::Runtime::InteropServices::Out] System::String^% gridref); 00130 00131 /** 00132 * Convert OSGB coordinates to a grid reference. 00133 * 00134 * @param[in] gridref National Grid reference. 00135 * @param[out] x easting of point (meters). 00136 * @param[out] y northing of point (meters). 00137 * @param[out] prec precision relative to 100 km. 00138 * @param[in] centerp if true (default), return center of the grid square, 00139 * else return SW (lower left) corner. 00140 * @exception GeographicErr if \e gridref is illegal. 00141 * 00142 * The grid reference must be of the form: two letters (not including I) 00143 * followed by an even number of digits (up to 22). 00144 **********************************************************************/ 00145 static void GridReference(System::String^ gridref, 00146 [System::Runtime::InteropServices::Out] double% x, 00147 [System::Runtime::InteropServices::Out] double% y, 00148 [System::Runtime::InteropServices::Out] int% prec, 00149 bool centerp ); 00150 00151 /** \name Inspector functions 00152 **********************************************************************/ 00153 ///@{ 00154 /** 00155 * @return \e a the equatorial radius of the Airy 1830 ellipsoid (meters). 00156 * 00157 * This is 20923713 ft converted to meters using the rule 1 ft = 00158 * 10<sup>9.48401603−10</sup> m. (The Airy 1830 value is returned 00159 * because the OSGB projection is based on this ellipsoid.) 00160 **********************************************************************/ 00161 static double MajorRadius(); 00162 00163 /** 00164 * @return \e f the inverse flattening of the Airy 1830 ellipsoid. 00165 * 00166 * For the Airy 1830 ellipsoid, \e a = 20923713 ft and \e b = 20853810 ft; 00167 * thus the flattening = (20923713 − 20853810)/20923713 = 00168 * 7767/2324857 = 1/299.32496459... (The Airy 1830 value is returned 00169 * because the OSGB projection is based on this ellipsoid.) 00170 **********************************************************************/ 00171 static double Flattening(); 00172 00173 /** 00174 * @return \e k0 central scale for the OSGB projection (0.9996012717). 00175 **********************************************************************/ 00176 static double CentralScale(); 00177 00178 /** 00179 * @return latitude of the origin for the OSGB projection (49 degrees). 00180 **********************************************************************/ 00181 static double OriginLatitude(); 00182 00183 /** 00184 * @return longitude of the origin for the OSGB projection (−2 00185 * degrees). 00186 **********************************************************************/ 00187 static double OriginLongitude(); 00188 00189 /** 00190 * @return false northing the OSGB projection (−100000 meters). 00191 **********************************************************************/ 00192 static double FalseNorthing(); 00193 00194 /** 00195 * @return false easting the OSGB projection (400000 meters). 00196 **********************************************************************/ 00197 static double FalseEasting(); 00198 ///@} 00199 }; 00200 } //