00001 #pragma once 00002 /** 00003 * \file NETGeographicLib/LambertConformalConic.h 00004 * \brief Header for NETGeographicLib::LambertConformalConic class 00005 * 00006 * NETGeographicLib is copyright (c) Scott Heiman (2013) 00007 * GeographicLib is Copyright (c) Charles Karney (2010-2012) 00008 * <charles@karney.com> and licensed under the MIT/X11 License. 00009 * For more information, see 00010 * http://geographiclib.sourceforge.net/ 00011 **********************************************************************/ 00012 00013 namespace NETGeographicLib 00014 { 00015 /** 00016 * \brief .NET wrapper for GeographicLib::LambertConformalConic. 00017 * 00018 * This class allows .NET applications to access GeographicLib::LambertConformalConic. 00019 * 00020 * Implementation taken from the report, 00021 * - J. P. Snyder, 00022 * <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projections: A 00023 * Working Manual</a>, USGS Professional Paper 1395 (1987), 00024 * pp. 107--109. 00025 * 00026 * This is a implementation of the equations in Snyder except that divided 00027 * differences have been used to transform the expressions into ones which 00028 * may be evaluated accurately and that Newton's method is used to invert the 00029 * projection. In this implementation, the projection correctly becomes the 00030 * Mercator projection or the polar stereographic projection when the 00031 * standard latitude is the equator or a pole. The accuracy of the 00032 * projections is about 10 nm (10 nanometers). 00033 * 00034 * The ellipsoid parameters, the standard parallels, and the scale on the 00035 * standard parallels are set in the constructor. Internally, the case with 00036 * two standard parallels is converted into a single standard parallel, the 00037 * latitude of tangency (also the latitude of minimum scale), with a scale 00038 * specified on this parallel. This latitude is also used as the latitude of 00039 * origin which is returned by LambertConformalConic::OriginLatitude. The 00040 * scale on the latitude of origin is given by 00041 * LambertConformalConic::CentralScale. The case with two distinct standard 00042 * parallels where one is a pole is singular and is disallowed. The central 00043 * meridian (which is a trivial shift of the longitude) is specified as the 00044 * \e lon0 argument of the LambertConformalConic::Forward and 00045 * LambertConformalConic::Reverse functions. There is no provision in this 00046 * class for specifying a false easting or false northing or a different 00047 * latitude of origin. However these are can be simply included by the 00048 * calling function. For example the Pennsylvania South state coordinate 00049 * system (<a href="http://www.spatialreference.org/ref/epsg/3364/"> 00050 * EPSG:3364</a>) is obtained by: 00051 * C# Example: 00052 * \include example-LambertConformalConic.cs 00053 * Managed C++ Example: 00054 * \include example-LambertConformalConic.cpp 00055 * Visual Basic Example: 00056 * \include example-LambertConformalConic.vb 00057 * 00058 * <B>INTERFACE DIFFERENCES:</B><BR> 00059 * A default constructor has been provided that assumes a Mercator 00060 * projection. 00061 * 00062 * The MajorRadius, Flattening, OriginLatitude, and CentralScale 00063 * functions are implemented as properties. 00064 **********************************************************************/ 00065 public ref class LambertConformalConic 00066 { 00067 private: 00068 // Pointer to the unmanaged GeographicLib::LambertConformalConic. 00069 GeographicLib::LambertConformalConic* m_pLambertConformalConic; 00070 00071 // the finalizer frres the unmanaged memory when the object is destroyed. 00072 !LambertConformalConic(void); 00073 public: 00074 00075 /** 00076 * Constructor with a single standard parallel. 00077 * 00078 * @param[in] a equatorial radius of ellipsoid (meters). 00079 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00080 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening 00081 * to 1/\e f. 00082 * @param[in] stdlat standard parallel (degrees), the circle of tangency. 00083 * @param[in] k0 scale on the standard parallel. 00084 * @exception GeographicErr if \e a, (1 − \e f ) \e a, or \e k0 is 00085 * not positive. 00086 * @exception GeographicErr if \e stdlat is not in [−90°, 00087 * 90°]. 00088 **********************************************************************/ 00089 LambertConformalConic(double a, double f, double stdlat, double k0); 00090 00091 /** 00092 * Constructor with two standard parallels. 00093 * 00094 * @param[in] a equatorial radius of ellipsoid (meters). 00095 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00096 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening 00097 * to 1/\e f. 00098 * @param[in] stdlat1 first standard parallel (degrees). 00099 * @param[in] stdlat2 second standard parallel (degrees). 00100 * @param[in] k1 scale on the standard parallels. 00101 * @exception GeographicErr if \e a, (1 − \e f ) \e a, or \e k1 is 00102 * not positive. 00103 * @exception GeographicErr if \e stdlat1 or \e stdlat2 is not in 00104 * [−90°, 90°], or if either \e stdlat1 or \e 00105 * stdlat2 is a pole and \e stdlat1 is not equal \e stdlat2. 00106 **********************************************************************/ 00107 LambertConformalConic(double a, double f, double stdlat1, double stdlat2, double k1); 00108 00109 /** 00110 * Constructor with two standard parallels specified by sines and cosines. 00111 * 00112 * @param[in] a equatorial radius of ellipsoid (meters). 00113 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00114 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening 00115 * to 1/\e f. 00116 * @param[in] sinlat1 sine of first standard parallel. 00117 * @param[in] coslat1 cosine of first standard parallel. 00118 * @param[in] sinlat2 sine of second standard parallel. 00119 * @param[in] coslat2 cosine of second standard parallel. 00120 * @param[in] k1 scale on the standard parallels. 00121 * @exception GeographicErr if \e a, (1 − \e f ) \e a, or \e k1 is 00122 * not positive. 00123 * @exception GeographicErr if \e stdlat1 or \e stdlat2 is not in 00124 * [−90°, 90°], or if either \e stdlat1 or \e 00125 * stdlat2 is a pole and \e stdlat1 is not equal \e stdlat2. 00126 * 00127 * This allows parallels close to the poles to be specified accurately. 00128 * This routine computes the latitude of origin and the scale at this 00129 * latitude. In the case where \e lat1 and \e lat2 are different, the 00130 * errors in this routines are as follows: if \e dlat = abs(\e lat2 − 00131 * \e lat1) ≤ 160° and max(abs(\e lat1), abs(\e lat2)) ≤ 90 00132 * − min(0.0002, 2.2 × 10<sup>−6</sup>(180 − \e 00133 * dlat), 6 × 10<sup>−8</sup> <i>dlat</i><sup>2</sup>) (in 00134 * degrees), then the error in the latitude of origin is less than 4.5 00135 * × 10<sup>−14</sup>d and the relative error in the scale is 00136 * less than 7 × 10<sup>−15</sup>. 00137 **********************************************************************/ 00138 LambertConformalConic(double a, double f, 00139 double sinlat1, double coslat1, 00140 double sinlat2, double coslat2, 00141 double k1); 00142 00143 /** 00144 * The default constructor assumes a Mercator projection. 00145 **********************************************************************/ 00146 LambertConformalConic(); 00147 00148 /** 00149 * The destructor calls the finalizer. 00150 **********************************************************************/ 00151 ~LambertConformalConic() 00152 { this->!LambertConformalConic(); } 00153 00154 /** 00155 * Set the scale for the projection. 00156 * 00157 * @param[in] lat (degrees). 00158 * @param[in] k scale at latitude \e lat (default 1). 00159 * @exception GeographicErr \e k is not positive. 00160 * @exception GeographicErr if \e lat is not in [−90°, 00161 * 90°]. 00162 **********************************************************************/ 00163 void SetScale(double lat, double k); 00164 00165 /** 00166 * Forward projection, from geographic to Lambert conformal conic. 00167 * 00168 * @param[in] lon0 central meridian longitude (degrees). 00169 * @param[in] lat latitude of point (degrees). 00170 * @param[in] lon longitude of point (degrees). 00171 * @param[out] x easting of point (meters). 00172 * @param[out] y northing of point (meters). 00173 * @param[out] gamma meridian convergence at point (degrees). 00174 * @param[out] k scale of projection at point. 00175 * 00176 * The latitude origin is given by LambertConformalConic::LatitudeOrigin(). 00177 * No false easting or northing is added and \e lat should be in the range 00178 * [−90°, 90°]; \e lon and \e lon0 should be in the 00179 * range [−540°, 540°). The error in the projection 00180 * is less than about 10 nm (10 nanometers), true distance, and the errors 00181 * in the meridian convergence and scale are consistent with this. The 00182 * values of \e x and \e y returned for points which project to infinity 00183 * (i.e., one or both of the poles) will be large but finite. 00184 **********************************************************************/ 00185 void Forward(double lon0, double lat, double lon, 00186 [System::Runtime::InteropServices::Out] double% x, 00187 [System::Runtime::InteropServices::Out] double% y, 00188 [System::Runtime::InteropServices::Out] double% gamma, 00189 [System::Runtime::InteropServices::Out] double% k); 00190 00191 /** 00192 * Reverse projection, from Lambert conformal conic to geographic. 00193 * 00194 * @param[in] lon0 central meridian longitude (degrees). 00195 * @param[in] x easting of point (meters). 00196 * @param[in] y northing of point (meters). 00197 * @param[out] lat latitude of point (degrees). 00198 * @param[out] lon longitude of point (degrees). 00199 * @param[out] gamma meridian convergence at point (degrees). 00200 * @param[out] k scale of projection at point. 00201 * 00202 * The latitude origin is given by LambertConformalConic::LatitudeOrigin(). 00203 * No false easting or northing is added. \e lon0 should be in the range 00204 * [−540°, 540°). The value of \e lon returned is in 00205 * the range [−180°, 180°). The error in the 00206 * projection is less than about 10 nm (10 nanometers), true distance, and 00207 * the errors in the meridian convergence and scale are consistent with 00208 * this. 00209 **********************************************************************/ 00210 void Reverse(double lon0, double x, double y, 00211 [System::Runtime::InteropServices::Out] double% lat, 00212 [System::Runtime::InteropServices::Out] double% lon, 00213 [System::Runtime::InteropServices::Out] double% gamma, 00214 [System::Runtime::InteropServices::Out] double% k); 00215 00216 /** 00217 * LambertConformalConic::Forward without returning the convergence and 00218 * scale. 00219 **********************************************************************/ 00220 void Forward(double lon0, double lat, double lon, 00221 [System::Runtime::InteropServices::Out] double% x, 00222 [System::Runtime::InteropServices::Out] double% y); 00223 00224 /** 00225 * LambertConformalConic::Reverse without returning the convergence and 00226 * scale. 00227 **********************************************************************/ 00228 void Reverse(double lon0, double x, double y, 00229 [System::Runtime::InteropServices::Out] double% lat, 00230 [System::Runtime::InteropServices::Out] double% lon); 00231 00232 /** \name Inspector functions 00233 **********************************************************************/ 00234 ///@{ 00235 /** 00236 * @return \e a the equatorial radius of the ellipsoid (meters). This is 00237 * the value used in the constructor. 00238 **********************************************************************/ 00239 property double MajorRadius { double get(); } 00240 00241 /** 00242 * @return \e f the flattening of the ellipsoid. This is the 00243 * value used in the constructor. 00244 **********************************************************************/ 00245 property double Flattening { double get(); } 00246 00247 /** 00248 * @return latitude of the origin for the projection (degrees). 00249 * 00250 * This is the latitude of minimum scale and equals the \e stdlat in the 00251 * 1-parallel constructor and lies between \e stdlat1 and \e stdlat2 in the 00252 * 2-parallel constructors. 00253 **********************************************************************/ 00254 property double OriginLatitude { double get(); } 00255 00256 /** 00257 * @return central scale for the projection. This is the scale on the 00258 * latitude of origin. 00259 **********************************************************************/ 00260 property double CentralScale { double get(); } 00261 ///@} 00262 }; 00263 } //namespace NETGeographicLib