00001 #pragma once 00002 /** 00003 * \file NETGeographicLib/AlbersEqualArea.h 00004 * \brief Header for NETGeographicLib::AlbersEqualArea 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::AlbersEqualArea. 00017 * 00018 * This class allows .NET applications to access 00019 * GeographicLib::AlbersEqualArea 00020 * 00021 * Implementation taken from the report, 00022 * - J. P. Snyder, 00023 * <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projections: A 00024 * Working Manual</a>, USGS Professional Paper 1395 (1987), 00025 * pp. 101--102. 00026 * 00027 * This is a implementation of the equations in Snyder except that divided 00028 * differences will be [have been] used to transform the expressions into 00029 * ones which may be evaluated accurately. [In this implementation, the 00030 * projection correctly becomes the cylindrical equal area or the azimuthal 00031 * equal area projection when the standard latitude is the equator or a 00032 * pole.] 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 minimum azimuthal scale, with an azimuthal scale specified on 00038 * this parallel. This latitude is also used as the latitude of origin which 00039 * is returned by AlbersEqualArea::OriginLatitude. The azimuthal scale on 00040 * the latitude of origin is given by AlbersEqualArea::CentralScale. The 00041 * case with two standard parallels at opposite poles is singular and is 00042 * disallowed. The central meridian (which is a trivial shift of the 00043 * longitude) is specified as the \e lon0 argument of the 00044 * AlbersEqualArea::Forward and AlbersEqualArea::Reverse functions. 00045 * AlbersEqualArea::Forward and AlbersEqualArea::Reverse also return the 00046 * meridian convergence, γ, and azimuthal scale, \e k. A small square 00047 * aligned with the cardinal directions is projected to a rectangle with 00048 * dimensions \e k (in the E-W direction) and 1/\e k (in the N-S direction). 00049 * The E-W sides of the rectangle are oriented γ degrees 00050 * counter-clockwise from the \e x axis. There is no provision in this class 00051 * for specifying a false easting or false northing or a different latitude 00052 * of origin. 00053 * 00054 * C# Example: 00055 * \include example-AlbersEqualArea.cs 00056 * Managed C++ Example: 00057 * \include example-AlbersEqualArea.cpp 00058 * Visual Basic Example: 00059 * \include example-AlbersEqualArea.vb 00060 * 00061 * <B>INTERFACE DIFFERENCES:</B><BR> 00062 * A constructor has been provided that creates the standard projections. 00063 * 00064 * The MajorRadius, Flattening, OriginLatitude, and CentralScale functions 00065 * are implemented as properties. 00066 **********************************************************************/ 00067 public ref class AlbersEqualArea 00068 { 00069 private: 00070 // pointer to the unmanaged GeographicLib::AlbersEqualArea 00071 GeographicLib::AlbersEqualArea* m_pAlbersEqualArea; 00072 00073 // Frees the unmanaged m_pAlbersEqualArea when object is destroyed. 00074 !AlbersEqualArea(); 00075 public: 00076 /** 00077 Standard AlbersEqualAreaProjections that assume the WGS84 ellipsoid. 00078 *********************************************************************/ 00079 enum class StandardTypes 00080 { 00081 CylindricalEqualArea, //!< cylindrical equal area projection (stdlat = 0, and \e k0 = 1) 00082 AzimuthalEqualAreaNorth, //!< Lambert azimuthal equal area projection (stdlat = 90°, and \e k0 = 1) 00083 AzimuthalEqualAreaSouth //!< Lambert azimuthal equal area projection (stdlat = −90°, and \e k0 = 1) 00084 }; 00085 00086 //! \brief Destructor 00087 ~AlbersEqualArea() { this->!AlbersEqualArea(); } 00088 00089 /**! 00090 * Constructor for one of the standard types. 00091 * @param[in] type The desired standard type. 00092 **********************************************************************/ 00093 AlbersEqualArea( StandardTypes type ); 00094 00095 /** 00096 * Constructor with a single standard parallel. 00097 * 00098 * @param[in] a equatorial radius of ellipsoid (meters). 00099 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00100 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening 00101 * to 1/\e f. 00102 * @param[in] stdlat standard parallel (degrees), the circle of tangency. 00103 * @param[in] k0 azimuthal scale on the standard parallel. 00104 * @exception GeographicErr if \e a, (1 − \e f ) \e a, or \e k0 is 00105 * not positive. 00106 * @exception GeographicErr if \e stdlat is not in [−90°, 00107 * 90°]. 00108 **********************************************************************/ 00109 AlbersEqualArea(double a, double f, double stdlat, double k0); 00110 00111 /** 00112 * Constructor with two standard parallels. 00113 * 00114 * @param[in] a equatorial radius of ellipsoid (meters). 00115 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00116 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening 00117 * to 1/\e f. 00118 * @param[in] stdlat1 first standard parallel (degrees). 00119 * @param[in] stdlat2 second standard parallel (degrees). 00120 * @param[in] k1 azimuthal 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 \e stdlat1 and \e stdlat2 are 00125 * opposite poles. 00126 **********************************************************************/ 00127 AlbersEqualArea(double a, double f, double stdlat1, double stdlat2, double k1); 00128 00129 /** 00130 * Constructor with two standard parallels specified by sines and cosines. 00131 * 00132 * @param[in] a equatorial radius of ellipsoid (meters). 00133 * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere. 00134 * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening 00135 * to 1/\e f. 00136 * @param[in] sinlat1 sine of first standard parallel. 00137 * @param[in] coslat1 cosine of first standard parallel. 00138 * @param[in] sinlat2 sine of second standard parallel. 00139 * @param[in] coslat2 cosine of second standard parallel. 00140 * @param[in] k1 azimuthal scale on the standard parallels. 00141 * @exception GeographicErr if \e a, (1 − \e f ) \e a, or \e k1 is 00142 * not positive. 00143 * @exception GeographicErr if \e stdlat1 or \e stdlat2 is not in 00144 * [−90°, 90°], or if \e stdlat1 and \e stdlat2 are 00145 * opposite poles. 00146 * 00147 * This allows parallels close to the poles to be specified accurately. 00148 * This routine computes the latitude of origin and the azimuthal scale at 00149 * this latitude. If \e dlat = abs(\e lat2 − \e lat1) ≤ 160°, 00150 * then the error in the latitude of origin is less than 4.5 × 00151 * 10<sup>−14</sup>d;. 00152 **********************************************************************/ 00153 AlbersEqualArea(double a, double f, 00154 double sinlat1, double coslat1, 00155 double sinlat2, double coslat2, 00156 double k1); 00157 00158 /** 00159 * Set the azimuthal scale for the projection. 00160 * 00161 * @param[in] lat (degrees). 00162 * @param[in] k azimuthal scale at latitude \e lat (default 1). 00163 * @exception GeographicErr \e k is not positive. 00164 * @exception GeographicErr if \e lat is not in (−90°, 00165 * 90°). 00166 * 00167 * This allows a "latitude of conformality" to be specified. 00168 **********************************************************************/ 00169 void SetScale(double lat, double k); 00170 00171 /** 00172 * Forward projection, from geographic to Lambert conformal conic. 00173 * 00174 * @param[in] lon0 central meridian longitude (degrees). 00175 * @param[in] lat latitude of point (degrees). 00176 * @param[in] lon longitude of point (degrees). 00177 * @param[out] x easting of point (meters). 00178 * @param[out] y northing of point (meters). 00179 * @param[out] gamma meridian convergence at point (degrees). 00180 * @param[out] k azimuthal scale of projection at point; the radial 00181 * scale is the 1/\e k. 00182 * 00183 * The latitude origin is given by AlbersEqualArea::LatitudeOrigin(). No 00184 * false easting or northing is added and \e lat should be in the range 00185 * [−90°, 90°]; \e lon and \e lon0 should be in the 00186 * range [−540°, 540°). The values of \e x and \e y 00187 * returned for points which project to infinity (i.e., one or both of the 00188 * poles) will be large but finite. 00189 **********************************************************************/ 00190 void Forward(double lon0, double lat, double lon, 00191 [System::Runtime::InteropServices::Out] double% x, 00192 [System::Runtime::InteropServices::Out] double% y, 00193 [System::Runtime::InteropServices::Out] double% gamma, 00194 [System::Runtime::InteropServices::Out] double% k); 00195 00196 /** 00197 * Reverse projection, from Lambert conformal conic to geographic. 00198 * 00199 * @param[in] lon0 central meridian longitude (degrees). 00200 * @param[in] x easting of point (meters). 00201 * @param[in] y northing of point (meters). 00202 * @param[out] lat latitude of point (degrees). 00203 * @param[out] lon longitude of point (degrees). 00204 * @param[out] gamma meridian convergence at point (degrees). 00205 * @param[out] k azimuthal scale of projection at point; the radial 00206 * scale is the 1/\e k. 00207 * 00208 * The latitude origin is given by AlbersEqualArea::LatitudeOrigin(). No 00209 * false easting or northing is added. \e lon0 should be in the range 00210 * [−540°, 540°). The value of \e lon returned is in 00211 * the range [−180°, 180°). The value of \e lat 00212 * returned is in the range [−90°, 90°]. If the 00213 * input point is outside the legal projected space the nearest pole is 00214 * returned. 00215 **********************************************************************/ 00216 void Reverse(double lon0, double x, double y, 00217 [System::Runtime::InteropServices::Out] double% lat, 00218 [System::Runtime::InteropServices::Out] double% lon, 00219 [System::Runtime::InteropServices::Out] double% gamma, 00220 [System::Runtime::InteropServices::Out] double% k); 00221 00222 /** 00223 * AlbersEqualArea::Forward without returning the convergence and 00224 * scale. 00225 **********************************************************************/ 00226 void Forward(double lon0, double lat, double lon, 00227 [System::Runtime::InteropServices::Out] double% x, 00228 [System::Runtime::InteropServices::Out] double% y); 00229 00230 /** 00231 * AlbersEqualArea::Reverse without returning the convergence and 00232 * scale. 00233 **********************************************************************/ 00234 void Reverse(double lon0, double x, double y, 00235 [System::Runtime::InteropServices::Out] double% lat, 00236 [System::Runtime::InteropServices::Out] double% lon); 00237 00238 /** \name Inspector functions 00239 **********************************************************************/ 00240 ///@{ 00241 /** 00242 * @return \e a the equatorial radius of the ellipsoid (meters). This is 00243 * the value used in the constructor. 00244 **********************************************************************/ 00245 property double MajorRadius { double get(); } 00246 00247 /** 00248 * @return \e f the flattening of the ellipsoid. This is the value used in 00249 * the constructor. 00250 **********************************************************************/ 00251 property double Flattening { double get(); } 00252 00253 /** 00254 * @return latitude of the origin for the projection (degrees). 00255 * 00256 * This is the latitude of minimum azimuthal scale and equals the \e stdlat 00257 * in the 1-parallel constructor and lies between \e stdlat1 and \e stdlat2 00258 * in the 2-parallel constructors. 00259 **********************************************************************/ 00260 property double OriginLatitude { double get(); } 00261 00262 /** 00263 * @return central scale for the projection. This is the azimuthal scale 00264 * on the latitude of origin. 00265 **********************************************************************/ 00266 property double CentralScale { double get(); } 00267 ///@} 00268 }; 00269 } // namespace NETGeographic