GeographicLib is a small set of C++ classes for performing conversions between geographic, UTM, UPS, MGRS, geocentric, and local cartesian coordinates,for gravity (e.g., EGM2008), geoid height and geomagnetic field (e.g., WMM2020) calculations, and for solving geodesic problems.
GeographicLib.NET is a native .NET implementation of GeographicLib written in pure C#.
Unlike NETGeographicLib, GeographicLib.NET is implemented in pure C# without binding the C++ GeograpbicLib library by using C++/CLI or P/Invoke, thus achieves higher level of portability.
You should be able to use GeographicLib.NET with any target framework and platform that supports .NET Standard 2.0 or above.
Bellow is a list of implemented features.
- Projections (
AlbersEqualArea
,AzimuthalEquidistant
,CassiniSoldner
,Gnomonic
,LambertConformalConic
,PolarStereographic
andTransverseMercator
) - Geocodes (
GARS
,Geohash
,Georef
,MGRS
andOSGB
) - Coordinate conversions (
UTMUPS
,Geocentric
andLocalCartesian
) - Coordinate parsing/formatting (
DMS
andGeoCoords
) - Geodesic (
Geodesic
,GeodesicLine
,GeodesicExact
andGeodesicLineExact
) - Rhumb (
Rhumb
andRhumbLine
) - PolygonArea (
PolygonArea<T>
,PolygonArea
,PolygonAreaExact
andPolygonAreaRhumb
) - Geoid (
Geoid
) - GravityModel (
GravityCircle
,NormalGravity
andGravityModel
) - MagneticModel (
MagneticModel
,MagneticCircle
) - Auxilary classes (
MathEx
,Ellipoid
,EllipticFunction
andSphericalHarmonic
)
Geodesic
and GeodesicExact
are tested with the test set for geodesic.
TransverseMercator
and TransverseMercatorExact
are tested with data generated by 64-bit TransverseMercatorProj
utility ran on Windows.
Managed implemetation of C mathematical functions in MathEx
are tested with data generated by 64-bit Windows Universal C Runtime.
Stable releases of GeographicLib.NET are hosted on NuGet. You can install them using the following command:
dotnet add package GeographicLib.NET
Preview versions of GeographicLib.NET are hosted on NuGet pre-release channel. You can install them using the following command:
dotnet add package GeographicLib.NET --prerelease
GeographicLib uses several C mathematical functions that are not available in all versions of .NET. These functions are:
- remquo
- hypot
- log1p
- expm1
- frexp
- log2 (available since .NET 5.0)
- fma (available since .NET 5.0)
- scalbn (available since .NET 5.0)
- copysign (available since .NET 5.0)
- atanh (available since .NET Standard 2.1)
- asinh (available since .NET Standard 2.1)
- cbrt (available since .NET Standard 2.1)
GeographicLib.NET provides managed implementations of these functions (ported from musl libc).
GeographicLib.MathEx
class will use implementations provided by .NET runtime whenever possible, and will fallback to managed implementations when not available in .NET runtime.
You can also force GeographicLib.MathEx
to fallback to platform dependent implementations provided by system C runtime libraries,
rather than managed implementations, by setting GeographicLib.MathEx.UseManagedCMath
property to false
.
These functions provide better performance, but may produce inconsistent results on different platforms in some edge cases.
GeographicLib.NET includes a detailed XML documentation for all public APIs. Since the API surface of GeographicLib.NET is highly compatible with GeographicLib, you can also refer the its documentation here for usage and detailed explanation.
GeographicLib.NET adopts changes made in GeographicLib and aligns its version number with GeographicLib releases.
Bellow is a list of stable releases of GeographicLib.NET and changes made in .NET side in each release. For changes adopted from GeographicLib, please refer the its change log here.
-
NEW
- Target .NET 6.0 in addition to .NET 5.0, .NET Standard 2.1 and .NET Standard 2.0.
- Source Link support.
-
BREAKING
- Fixed typos in
Ellipsoid
. (RenamedSecondFlatterning
toSecondFlattening
andThirdFlatterning
toThirdFlattening
)
- Fixed typos in
-
FIX
- Fixed an issue that
Freeze
method inAlbersEqualArea
,LambertConformalConic
andPolarStereographic
was not working correctly. - Fixed duplicate instantiation of
WGS84
andGRS80
static properties defined inNormalGravity
. - Add missing support for World Magnetic Model Format v2.
- Fixed an issue that
-
BREAKING
- Modify overloads of
Forward
andReverse
inAlbersEqualArea
,AzimuthalEquidistant
,CassiniSoldner
andLambertConformalConic
to return coordinates as tuples. - Modify methods using
out
parameters defined inNormalGravity
,GravityModel
,GravityCircle
,MagneticModel
andMagnegticCircle
to return results as tuples.
- Modify overloads of
-
NEW
- Add constructor overloads that accept
IEllipsoid
as parameter forAlbersEqualArea
andLambertConformalConic
. - Add managed implementation of
log2
. - Add overloads of
Direct
andInverse
inGeodesic
/GeodesicLine
,GeodesicExact
/GeodesicLineExact
andRhumb
/RhumbLineExact
, that return the computation results as a single object. - Add definitions of popular reference ellipsoids in
Ellipsoid
class.
- Add constructor overloads that accept
-
FIX
- Fix stack overflow bug for
Forward(double lon0, double lat, double lon)
andReverse(double lon0, double x, double y)
inTransverseMercatorExact
.
- Fix stack overflow bug for
Initial stable release.