NETGeographicLib  1.43
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
LambertConformalConic.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * \file NETGeographicLib/LambertConformalConic.h
4  * \brief Header for NETGeographicLib::LambertConformalConic class
5  *
6  * NETGeographicLib is copyright (c) Scott Heiman (2013)
7  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
8  * <charles@karney.com> and licensed under the MIT/X11 License.
9  * For more information, see
10  * http://geographiclib.sourceforge.net/
11  **********************************************************************/
12 
13 namespace NETGeographicLib
14 {
15  /**
16  * \brief .NET wrapper for GeographicLib::LambertConformalConic.
17  *
18  * This class allows .NET applications to access GeographicLib::LambertConformalConic.
19  *
20  * Implementation taken from the report,
21  * - J. P. Snyder,
22  * <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projections: A
23  * Working Manual</a>, USGS Professional Paper 1395 (1987),
24  * pp. 107--109.
25  *
26  * This is a implementation of the equations in Snyder except that divided
27  * differences have been used to transform the expressions into ones which
28  * may be evaluated accurately and that Newton's method is used to invert the
29  * projection. In this implementation, the projection correctly becomes the
30  * Mercator projection or the polar stereographic projection when the
31  * standard latitude is the equator or a pole. The accuracy of the
32  * projections is about 10 nm (10 nanometers).
33  *
34  * The ellipsoid parameters, the standard parallels, and the scale on the
35  * standard parallels are set in the constructor. Internally, the case with
36  * two standard parallels is converted into a single standard parallel, the
37  * latitude of tangency (also the latitude of minimum scale), with a scale
38  * specified on this parallel. This latitude is also used as the latitude of
39  * origin which is returned by LambertConformalConic::OriginLatitude. The
40  * scale on the latitude of origin is given by
41  * LambertConformalConic::CentralScale. The case with two distinct standard
42  * parallels where one is a pole is singular and is disallowed. The central
43  * meridian (which is a trivial shift of the longitude) is specified as the
44  * \e lon0 argument of the LambertConformalConic::Forward and
45  * LambertConformalConic::Reverse functions. There is no provision in this
46  * class for specifying a false easting or false northing or a different
47  * latitude of origin. However these are can be simply included by the
48  * calling function. For example the Pennsylvania South state coordinate
49  * system (<a href="http://www.spatialreference.org/ref/epsg/3364/">
50  * EPSG:3364</a>) is obtained by:
51  * C# Example:
52  * \include example-LambertConformalConic.cs
53  * Managed C++ Example:
54  * \include example-LambertConformalConic.cpp
55  * Visual Basic Example:
56  * \include example-LambertConformalConic.vb
57  *
58  * <B>INTERFACE DIFFERENCES:</B><BR>
59  * A default constructor has been provided that assumes a Mercator
60  * projection.
61  *
62  * The MajorRadius, Flattening, OriginLatitude, and CentralScale
63  * functions are implemented as properties.
64  **********************************************************************/
65  public ref class LambertConformalConic
66  {
67  private:
68  // Pointer to the unmanaged GeographicLib::LambertConformalConic.
69  GeographicLib::LambertConformalConic* m_pLambertConformalConic;
70 
71  // the finalizer frres the unmanaged memory when the object is destroyed.
72  !LambertConformalConic(void);
73  public:
74 
75  /**
76  * Constructor with a single standard parallel.
77  *
78  * @param[in] a equatorial radius of ellipsoid (meters).
79  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
80  * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening
81  * to 1/\e f.
82  * @param[in] stdlat standard parallel (degrees), the circle of tangency.
83  * @param[in] k0 scale on the standard parallel.
84  * @exception GeographicErr if \e a, (1 &minus; \e f ) \e a, or \e k0 is
85  * not positive.
86  * @exception GeographicErr if \e stdlat is not in [&minus;90&deg;,
87  * 90&deg;].
88  **********************************************************************/
89  LambertConformalConic(double a, double f, double stdlat, double k0);
90 
91  /**
92  * Constructor with two standard parallels.
93  *
94  * @param[in] a equatorial radius of ellipsoid (meters).
95  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
96  * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening
97  * to 1/\e f.
98  * @param[in] stdlat1 first standard parallel (degrees).
99  * @param[in] stdlat2 second standard parallel (degrees).
100  * @param[in] k1 scale on the standard parallels.
101  * @exception GeographicErr if \e a, (1 &minus; \e f ) \e a, or \e k1 is
102  * not positive.
103  * @exception GeographicErr if \e stdlat1 or \e stdlat2 is not in
104  * [&minus;90&deg;, 90&deg;], or if either \e stdlat1 or \e
105  * stdlat2 is a pole and \e stdlat1 is not equal \e stdlat2.
106  **********************************************************************/
107  LambertConformalConic(double a, double f, double stdlat1, double stdlat2, double k1);
108 
109  /**
110  * Constructor with two standard parallels specified by sines and cosines.
111  *
112  * @param[in] a equatorial radius of ellipsoid (meters).
113  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
114  * Negative \e f gives a prolate ellipsoid. If \e f > 1, set flattening
115  * to 1/\e f.
116  * @param[in] sinlat1 sine of first standard parallel.
117  * @param[in] coslat1 cosine of first standard parallel.
118  * @param[in] sinlat2 sine of second standard parallel.
119  * @param[in] coslat2 cosine of second standard parallel.
120  * @param[in] k1 scale on the standard parallels.
121  * @exception GeographicErr if \e a, (1 &minus; \e f ) \e a, or \e k1 is
122  * not positive.
123  * @exception GeographicErr if \e stdlat1 or \e stdlat2 is not in
124  * [&minus;90&deg;, 90&deg;], or if either \e stdlat1 or \e
125  * stdlat2 is a pole and \e stdlat1 is not equal \e stdlat2.
126  *
127  * This allows parallels close to the poles to be specified accurately.
128  * This routine computes the latitude of origin and the scale at this
129  * latitude. In the case where \e lat1 and \e lat2 are different, the
130  * errors in this routines are as follows: if \e dlat = abs(\e lat2 &minus;
131  * \e lat1) &le; 160&deg; and max(abs(\e lat1), abs(\e lat2)) &le; 90
132  * &minus; min(0.0002, 2.2 &times; 10<sup>&minus;6</sup>(180 &minus; \e
133  * dlat), 6 &times 10<sup>&minus;8</sup> <i>dlat</i><sup>2</sup>) (in
134  * degrees), then the error in the latitude of origin is less than 4.5
135  * &times; 10<sup>&minus;14</sup>d and the relative error in the scale is
136  * less than 7 &times; 10<sup>&minus;15</sup>.
137  **********************************************************************/
138  LambertConformalConic(double a, double f,
139  double sinlat1, double coslat1,
140  double sinlat2, double coslat2,
141  double k1);
142 
143  /**
144  * The default constructor assumes a Mercator projection.
145  **********************************************************************/
147 
148  /**
149  * The destructor calls the finalizer.
150  **********************************************************************/
152  { this->!LambertConformalConic(); }
153 
154  /**
155  * Set the scale for the projection.
156  *
157  * @param[in] lat (degrees).
158  * @param[in] k scale at latitude \e lat (default 1).
159  * @exception GeographicErr \e k is not positive.
160  * @exception GeographicErr if \e lat is not in [&minus;90&deg;,
161  * 90&deg;].
162  **********************************************************************/
163  void SetScale(double lat, double k);
164 
165  /**
166  * Forward projection, from geographic to Lambert conformal conic.
167  *
168  * @param[in] lon0 central meridian longitude (degrees).
169  * @param[in] lat latitude of point (degrees).
170  * @param[in] lon longitude of point (degrees).
171  * @param[out] x easting of point (meters).
172  * @param[out] y northing of point (meters).
173  * @param[out] gamma meridian convergence at point (degrees).
174  * @param[out] k scale of projection at point.
175  *
176  * The latitude origin is given by LambertConformalConic::LatitudeOrigin().
177  * No false easting or northing is added and \e lat should be in the range
178  * [&minus;90&deg;, 90&deg;]; \e lon and \e lon0 should be in the
179  * range [&minus;540&deg;, 540&deg;). The error in the projection
180  * is less than about 10 nm (10 nanometers), true distance, and the errors
181  * in the meridian convergence and scale are consistent with this. The
182  * values of \e x and \e y returned for points which project to infinity
183  * (i.e., one or both of the poles) will be large but finite.
184  **********************************************************************/
185  void Forward(double lon0, double lat, double lon,
186  [System::Runtime::InteropServices::Out] double% x,
187  [System::Runtime::InteropServices::Out] double% y,
188  [System::Runtime::InteropServices::Out] double% gamma,
189  [System::Runtime::InteropServices::Out] double% k);
190 
191  /**
192  * Reverse projection, from Lambert conformal conic to geographic.
193  *
194  * @param[in] lon0 central meridian longitude (degrees).
195  * @param[in] x easting of point (meters).
196  * @param[in] y northing of point (meters).
197  * @param[out] lat latitude of point (degrees).
198  * @param[out] lon longitude of point (degrees).
199  * @param[out] gamma meridian convergence at point (degrees).
200  * @param[out] k scale of projection at point.
201  *
202  * The latitude origin is given by LambertConformalConic::LatitudeOrigin().
203  * No false easting or northing is added. \e lon0 should be in the range
204  * [&minus;540&deg;, 540&deg;). The value of \e lon returned is in
205  * the range [&minus;180&deg;, 180&deg;). The error in the
206  * projection is less than about 10 nm (10 nanometers), true distance, and
207  * the errors in the meridian convergence and scale are consistent with
208  * this.
209  **********************************************************************/
210  void Reverse(double lon0, double x, double y,
211  [System::Runtime::InteropServices::Out] double% lat,
212  [System::Runtime::InteropServices::Out] double% lon,
213  [System::Runtime::InteropServices::Out] double% gamma,
214  [System::Runtime::InteropServices::Out] double% k);
215 
216  /**
217  * LambertConformalConic::Forward without returning the convergence and
218  * scale.
219  **********************************************************************/
220  void Forward(double lon0, double lat, double lon,
221  [System::Runtime::InteropServices::Out] double% x,
222  [System::Runtime::InteropServices::Out] double% y);
223 
224  /**
225  * LambertConformalConic::Reverse without returning the convergence and
226  * scale.
227  **********************************************************************/
228  void Reverse(double lon0, double x, double y,
229  [System::Runtime::InteropServices::Out] double% lat,
230  [System::Runtime::InteropServices::Out] double% lon);
231 
232  /** \name Inspector functions
233  **********************************************************************/
234  ///@{
235  /**
236  * @return \e a the equatorial radius of the ellipsoid (meters). This is
237  * the value used in the constructor.
238  **********************************************************************/
239  property double MajorRadius { double get(); }
240 
241  /**
242  * @return \e f the flattening of the ellipsoid. This is the
243  * value used in the constructor.
244  **********************************************************************/
245  property double Flattening { double get(); }
246 
247  /**
248  * @return latitude of the origin for the projection (degrees).
249  *
250  * This is the latitude of minimum scale and equals the \e stdlat in the
251  * 1-parallel constructor and lies between \e stdlat1 and \e stdlat2 in the
252  * 2-parallel constructors.
253  **********************************************************************/
254  property double OriginLatitude { double get(); }
255 
256  /**
257  * @return central scale for the projection. This is the scale on the
258  * latitude of origin.
259  **********************************************************************/
260  property double CentralScale { double get(); }
261  ///@}
262  };
263 } //namespace NETGeographicLib
void SetScale(double lat, double k)
.NET wrapper for GeographicLib::LambertConformalConic.
void Forward(double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double% x, [System::Runtime::InteropServices::Out] double% y, [System::Runtime::InteropServices::Out] double% gamma, [System::Runtime::InteropServices::Out] double% k)
void Reverse(double lon0, double x, double y, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon, [System::Runtime::InteropServices::Out] double% gamma, [System::Runtime::InteropServices::Out] double% k)