Skip to content

Commit 9bde607

Browse files
authored
v1.52.0 (#16)
* Add constructor overloads that accept IEllipsoid as parameter for AlbersEqualArea and LambertConformalConic. * Modify overloads of Forward and Reverse in AlbersEqualArea, AzimuthalEquidistant, CassiniSoldner and LambertConformalConic to return coordinates as tuples. * Add overloads of Direct and Inverse in Geodesic/GeodesicLine, GeodesicExact/GeodesicLineExact and Rhumb/RhumbLineExact, that return the computation results as a single object. * Modify methods using out parameters defined in NormalGravity, GravityModel, GravityCircle, MagneticModel and MagnegticCircle to return results as tuples. * Enable strong name signing. * Fix stack overflow bug for Forward and Reverse in TransverseMercatorExact. * Add definitions of popular reference ellipsoids. * Update documentation
1 parent d4fc99f commit 9bde607

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4017
-599
lines changed

GeographicLib/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
using System.Runtime.CompilerServices;
22

3-
[assembly:InternalsVisibleTo("GeographicLibTests")]
3+
[assembly:InternalsVisibleTo("GeographicLibTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010075aba3dfe6f7b4a1b3fcd295a4a8652d77e891c02eb11600df39913e623d179a8d3951bea92c6e60733f08d8971270b8e4debb7432935c9c008c5bdfd051bc7e43be4590a81c9f7864fbee1c36481f11aea8f045c95c51779af69cd1c3945ac060d6550bd24b1aadccc2305cbdad75b448997af88d357f90ca97742144b372e8")]

GeographicLib/CMath.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ abstract class CMath
2020

2121
public abstract double Frexp(double x, out int e);
2222

23-
#if !NET5_0
23+
#if !NET5_0_OR_GREATER
2424
public abstract double CopySign(double x, double y);
2525

2626
public abstract double ScaleB(double number, int exp);
2727

2828
public abstract double FusedMultiplyAdd(double x, double y, double z);
29+
30+
public abstract double Log2(double x);
2931
#endif
3032

3133
#if NETSTANDARD2_0

GeographicLib/CMathManaged.cs

Lines changed: 377 additions & 60 deletions
Large diffs are not rendered by default.

GeographicLib/CMathNative.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace GeographicLib
1111
{
12-
#if NET5_0
12+
#if NET5_0_OR_GREATER
1313
class CMathNative : CMath
1414
{
1515
[ModuleInitializer]
@@ -110,6 +110,9 @@ private class CMathWindows : CMath
110110
[DllImport(CRuntimeLibrary)]
111111
private static extern double frexp(double x, out int e);
112112

113+
[DllImport(CRuntimeLibrary)]
114+
public static extern double log2(double x);
115+
113116
public override double Expm1(double x) => expm1(x);
114117

115118
public override double ScaleB(double number, int exp) => scalbn(number, exp);
@@ -126,6 +129,8 @@ private class CMathWindows : CMath
126129

127130
public override double Frexp(double x, out int e) => frexp(x, out e);
128131

132+
public override double Log2(double x) => log2(x);
133+
129134
#if NETSTANDARD2_0
130135
[DllImport(CRuntimeLibrary)]
131136
public static extern double atanh(double x);
@@ -172,6 +177,9 @@ private class CMathLinux : CMath
172177
[DllImport(CRuntimeLibrary)]
173178
private static extern double frexp(double x, out int e);
174179

180+
[DllImport(CRuntimeLibrary)]
181+
public static extern double log2(double x);
182+
175183
public override double Expm1(double x) => expm1(x);
176184

177185
public override double ScaleB(double number, int exp) => scalbn(number, exp);
@@ -188,6 +196,8 @@ private class CMathLinux : CMath
188196

189197
public override double Frexp(double x, out int e) => frexp(x, out e);
190198

199+
public override double Log2(double x) => log2(x);
200+
191201
#if NETSTANDARD2_0
192202
[DllImport(CRuntimeLibrary)]
193203
public static extern double atanh(double x);
@@ -234,6 +244,9 @@ private class CMathOSX : CMath
234244
[DllImport(CRuntimeLibrary)]
235245
private static extern double frexp(double x, out int e);
236246

247+
[DllImport(CRuntimeLibrary)]
248+
public static extern double log2(double x);
249+
237250
public override double Expm1(double x) => expm1(x);
238251

239252
public override double ScaleB(double number, int exp) => scalbn(number, exp);
@@ -250,6 +263,8 @@ private class CMathOSX : CMath
250263

251264
public override double Frexp(double x, out int e) => frexp(x, out e);
252265

266+
public override double Log2(double x) => log2(x);
267+
253268
#if NETSTANDARD2_0
254269
[DllImport(CRuntimeLibrary)]
255270
public static extern double atanh(double x);

GeographicLib/Ellipsoid.cs

Lines changed: 121 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public Ellipsoid(double a, double f)
6464

6565
internal Memory<double> RectifyingToConformalCoeffs => _tm._bet;
6666

67-
/// <summary>
68-
/// Gets a value representing the equatorial radius of the ellipsoid (meters). This is the value used in the constructor.
69-
/// </summary>
70-
public double EquatorialRadius => _a;
67+
/// <summary>
68+
/// Gets a value representing the equatorial radius of the ellipsoid (meters). This is the value used in the constructor.
69+
/// </summary>
70+
public double EquatorialRadius => _a;
7171

7272
/// <summary>
7373
/// Gets a value representing the polar semi-axis (meters).
@@ -440,7 +440,7 @@ public double TransverseCurvatureRadius(double phi)
440440
}
441441

442442
/// <summary>
443-
///
443+
/// Calculate the radius of curvature of the ellipsoid in the normal section at specified latitude inclined at specified angle.
444444
/// </summary>
445445
/// <param name="phi">the geographic latitude (degrees).</param>
446446
/// <param name="azi">the angle between the meridian and the normal section (degrees).</param>
@@ -566,9 +566,123 @@ public double NormalCurvatureRadius(double phi, double azi)
566566
#endregion
567567

568568
/// <summary>
569-
/// A global instantiation of Ellipsoid with the parameters for the WGS84 ellipsoid.
569+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the WGS-84 (1984) reference ellipsoid.
570570
/// </summary>
571-
/// <returns></returns>
572571
public static Ellipsoid WGS84 { get; } = new Ellipsoid(Constants.WGS84_a, Constants.WGS84_f);
572+
573+
/// <summary>
574+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Maupertuis (1738) reference ellipsoid.
575+
/// </summary>
576+
public static Ellipsoid Maupertuis { get; } = new Ellipsoid(6397300, 1 / 191d);
577+
578+
/// <summary>
579+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Plessis (1817) reference ellipsoid.
580+
/// </summary>
581+
public static Ellipsoid Plessis { get; } = new Ellipsoid(6376523, 1 / 308.64);
582+
583+
/// <summary>
584+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Everest (1830) reference ellipsoid.
585+
/// </summary>
586+
public static Ellipsoid Everest { get; } = new Ellipsoid(6377299.365, 1 / 300.80172554);
587+
588+
/// <summary>
589+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Everest 1830 Modified (1967) reference ellipsoid.
590+
/// </summary>
591+
public static Ellipsoid Everest1830Modified { get; } = new Ellipsoid(6377304.063, 1 / 300.8017);
592+
593+
/// <summary>
594+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Everest 1830 (1967 Definition) reference ellipsoid.
595+
/// </summary>
596+
public static Ellipsoid Everest1830 { get; } = new Ellipsoid(6377299.365, 1 / 300.80172554);
597+
598+
/// <summary>
599+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Airy (1830) reference ellipsoid.
600+
/// </summary>
601+
public static Ellipsoid Airy { get; } = new Ellipsoid(6377563.396, 1 / 299.3249646);
602+
603+
/// <summary>
604+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Bessel (1841) reference ellipsoid.
605+
/// </summary>
606+
public static Ellipsoid Bessel { get; } = new Ellipsoid(6377397.155, 1 / 299.1528128);
607+
608+
/// <summary>
609+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Clarke (1866) reference ellipsoid.
610+
/// </summary>
611+
public static Ellipsoid Clarke1866 { get; } = new Ellipsoid(6378206.4, 1 / 294.9786982);
612+
613+
/// <summary>
614+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Clarke (1878) reference ellipsoid.
615+
/// </summary>
616+
public static Ellipsoid Clarke1878 { get; } = new Ellipsoid(6378190, 1 / 293.4659980);
617+
618+
/// <summary>
619+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Clarke (1880) reference ellipsoid.
620+
/// </summary>
621+
public static Ellipsoid Clarke1880 { get; } = new Ellipsoid(6378249.145, 1 / 293.465);
622+
623+
/// <summary>
624+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Helmert (1906) reference ellipsoid.
625+
/// </summary>
626+
public static Ellipsoid Helmert { get; } = new Ellipsoid(6378200, 1 / 298.3);
627+
628+
/// <summary>
629+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Hayford (1910) reference ellipsoid.
630+
/// </summary>
631+
public static Ellipsoid Hayford { get; } = new Ellipsoid(6378388, 1 / 297d);
632+
633+
/// <summary>
634+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the International (1924) reference ellipsoid.
635+
/// </summary>
636+
public static Ellipsoid International { get; } = new Ellipsoid(6378388, 1 / 297d);
637+
638+
/// <summary>
639+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Krassovsky (1940) reference ellipsoid.
640+
/// </summary>
641+
public static Ellipsoid Krassovsky { get; } = new Ellipsoid(6378245, 1 / 298.3);
642+
643+
/// <summary>
644+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the WGS66 (1966) reference ellipsoid.
645+
/// </summary>
646+
public static Ellipsoid WGS66 { get; } = new Ellipsoid(6378145, 1 / 298.25);
647+
648+
/// <summary>
649+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the Australian National (1966) reference ellipsoid.
650+
/// </summary>
651+
public static Ellipsoid AustralianNational { get; } = new Ellipsoid(6378160, 1 / 298.25);
652+
653+
/// <summary>
654+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the New International (1967) reference ellipsoid.
655+
/// </summary>
656+
public static Ellipsoid NewInternational { get; } = new Ellipsoid(6378157.5, 1 / 298.24961539);
657+
658+
/// <summary>
659+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the GRS-67 (1967) reference ellipsoid.
660+
/// </summary>
661+
public static Ellipsoid GRS67 { get; } = new Ellipsoid(6378160, 1 / 298.247167427);
662+
663+
/// <summary>
664+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the South American (1969) reference ellipsoid.
665+
/// </summary>
666+
public static Ellipsoid SouthAmerican { get; } = new Ellipsoid(6378160, 1 / 298.25);
667+
668+
/// <summary>
669+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the WGS-72 (1972) reference ellipsoid.
670+
/// </summary>
671+
public static Ellipsoid WGS72 { get; } = new Ellipsoid(6378135, 1 / 298.26);
672+
673+
/// <summary>
674+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the GRS-80 (1979) reference ellipsoid.
675+
/// </summary>
676+
public static Ellipsoid GRS80 { get; } = new Ellipsoid(6378137, 1 / 298.257222101);
677+
678+
/// <summary>
679+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the IERS (1989) reference ellipsoid.
680+
/// </summary>
681+
public static Ellipsoid IERS1989 { get; } = new Ellipsoid(6378136, 1 / 298.257);
682+
683+
/// <summary>
684+
/// A global instantiation of <see cref="Ellipsoid"/> with the parameters for the IERS (2003) reference ellipsoid.
685+
/// </summary>
686+
public static Ellipsoid IERS2003 { get; } = new Ellipsoid(6378136.6, 1 / 298.25642);
573687
}
574688
}

GeographicLib/Geocentric.cs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ public Geocentric(IEllipsoid ellipsoid) : this(ellipsoid.EquatorialRadius, ellip
135135
/// <param name="X"><i>x</i> component of geocentric coordinate (meters).</param>
136136
/// <param name="Y"><i>y</i> component of geocentric coordinate (meters).</param>
137137
/// <param name="Z"><i>z</i> component of geocentric coordinate (meters).</param>
138-
/// <param name="M"> the length of the vector is 9, fill with the rotation matrix in row-major order.</param>
138+
/// <param name="M">if the length of the vector is 9, fill with the rotation matrix in row-major order.</param>
139139
/// <returns>
140140
/// <list type="bullet">
141-
/// <item><i>X</i>, <i>x</i> component of geocentric coordinate (meters).</item>
142-
/// <item><i>Y</i>, <i>y</i> component of geocentric coordinate (meters).</item>
143-
/// <item><i>Z</i>, <i>z</i> component of geocentric coordinate (meters).</item>
141+
/// <item><i>lat</i>, latitude of point (degrees).</item>
142+
/// <item><i>lon</i>, longitude of point (degrees).</item>
143+
/// <item><i>h</i>, height of point above the ellipsoid (meters).</item>
144144
/// </list>
145145
/// </returns>
146146
/// <remarks>
@@ -164,7 +164,7 @@ public Geocentric(IEllipsoid ellipsoid) : this(ellipsoid.EquatorialRadius, ellip
164164
/// If there are still multiple solutions with different latitudes (applies only if <i>Z</i> = 0),
165165
/// then the solution with <i>lat</i> > 0 is returned.
166166
/// If there are still multiple solutions with different longitudes (applies only if <i>X</i> = <i>Y</i> = 0)
167-
/// then <i>lon</i> = <c>0</c> is returned. The value of h returned satisfies <i>h</i> ≥ − <i>a</i> (1 − <i>e</i>^2) / sqrt(1 − <i>e</i>^2 sin^2<i>lat</i>).
167+
/// then <i>lon</i> = <c>0</c> is returned. The value of <i>h</i> returned satisfies <i>h</i> ≥ − <i>a</i> (1 − <i>e</i>^2) / sqrt(1 − <i>e</i>^2 sin^2<i>lat</i>).
168168
/// The value of lon returned is in the range [−180°, 180°].
169169
/// </para>
170170
/// </remarks>
@@ -190,6 +190,20 @@ internal static void Rotate(ReadOnlySpan<double> M,
190190
Z = M[6] * x + M[7] * y + M[8] * z;
191191
}
192192

193+
/// <summary>
194+
/// Perform [X,Y,Z]^t = M.[x,y,z]^t (typically local cartesian to geocentric)
195+
/// </summary>
196+
/// <param name="M"></param>
197+
/// <param name="x"></param>
198+
/// <param name="y"></param>
199+
/// <param name="z"></param>
200+
/// <returns></returns>
201+
internal static (double X, double Y, double Z) Rotate(ReadOnlySpan<double> M, double x, double y, double z)
202+
{
203+
Unrotate(M, x, y, z, out var X, out var Y, out var Z);
204+
return (X, Y, Z);
205+
}
206+
193207
/// <summary>
194208
/// Perform [x,y,z]^t = M^t.[X,Y,Z]^t (typically geocentric to local cartesian)
195209
/// </summary>
@@ -209,6 +223,20 @@ internal static void Unrotate(ReadOnlySpan<double> M,
209223
z = M[2] * X + M[5] * Y + M[8] * Z;
210224
}
211225

226+
/// <summary>
227+
/// Perform [x,y,z]^t = M^t.[X,Y,Z]^t (typically geocentric to local cartesian)
228+
/// </summary>
229+
/// <param name="M"></param>
230+
/// <param name="X"></param>
231+
/// <param name="Y"></param>
232+
/// <param name="Z"></param>
233+
/// <returns></returns>
234+
internal static (double x, double y, double z) Unrotate(ReadOnlySpan<double> M, double X, double Y, double Z)
235+
{
236+
Unrotate(M, X, Y, Z, out var x, out var y, out var z);
237+
return (x, y, z);
238+
}
239+
212240
/// <summary>
213241
/// This rotation matrix is given by the following quaternion operations
214242
/// qrot(lam, [0,0,1]) * qrot(phi, [0,-1,0]) * [1,1,1,1]/2

GeographicLib/Geocodes/GARS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace GeographicLib.Geocodes
1414
/// The Global Area Reference System is described in
1515
/// <list type="bullet">
1616
/// <item><a href="https://en.wikipedia.org/wiki/Global_Area_Reference_System"></a></item>
17-
/// <item><a href="http://earth-info.nga.mil/GandG/coordsys/grids/gars.html"></a></item>
17+
/// <item><a href="https://earth-info.nga.mil/index.php?dir=coordsys&amp;action=coordsys#tab_gars"></a></item>
1818
/// </list>
1919
/// <para>
2020
/// It provides a compact string representation of a geographic area (expressed as latitude and longitude).

GeographicLib/Geocodes/Georef.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace GeographicLib.Geocodes
1414
/// The World Geographic Reference System is described in
1515
/// <list type="bullet">
1616
/// <item><a href="https://en.wikipedia.org/wiki/Georef"></a></item>
17-
/// <item><a href="http://earth-info.nga.mil/GandG/coordsys/grids/georef.pdf"></a></item>
17+
/// <item><a href="https://web.archive.org/web/20161214054445/http://earth-info.nga.mil/GandG/coordsys/grids/georef.pdf"></a></item>
1818
/// </list>
1919
/// <para>
2020
/// It provides a compact string representation of a geographic area (expressed as latitude and longitude).

0 commit comments

Comments
 (0)