Shorthand.Geodesy 1.2.0

A small library with helper methods to convert between WGS84 and RT90/SWEREF. Also has utilities to calculate distances between coordinates.

Install-Package Shorthand.Geodesy -Version 1.2.0
dotnet add package Shorthand.Geodesy --version 1.2.0
<PackageReference Include="Shorthand.Geodesy" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shorthand.Geodesy --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Shorthand.Geodesy Helper methods to convert between WGS84 and RT90/SWEREF99 and calculate distances between coordinates.

This was earlier published to CodePlex under the name CrazyBeavers Geodesy (also by me) but I've cleaned up the code and renamed it from its old silly name when moving to GitHub.

Installation

Install the nuget package using Install-Package Shorthand.Geodesy, dotnet add Shorthand.Geodesy or clone and reference the project in the repository.

Usage

Convert grid to geodetic

// Create a new GridCoordinate with a specified projection
var gridCoord = new GridCoordinate { X = 7094946, Y = 1693701, Projection = SwedishProjections.RT90_25GonV };

// Use the GaussKruger-algorithm to convert the GridCoordinate to a GeodeticCoordinate
GeodeticCoordinate geoCoord = GaussKruger.GridToGeodetic(gridCoord);

The result of the above calculation should yield a new GeodeticCoordinate with the values of about Latitude = 63.90786 and Longitude = 19.75247.

Convert geodetic to grid

// Create a new GeodeticCoordinate
var geoCoord = new GeodeticCoordinate { Latitude = 63.90786d, Longitude = 19.75247d };

// Use the GaussKruger-algorithm to convert the GeodeticCoordinate to a GridCoordinate with the specified projection
var gridCoord = GaussKruger.GeodeticToGrid(coordinate, SwedishProjections.RT90_25GonV);

The result of the above calculation should yield a new GridCoordinate with the values of about X = 7094946 and Y = 1693701.

Calculating distance between coordinates

// Create a pair of coordinates
var coordinate1 = new GeodeticCoordinate { Latitude = 63.83451d, Longitude = 20.24655d };
var coordinate2 = new GeodeticCoordinate { Latitude = 63.85763d, Longitude = 20.33569d };

// Calculate the distance between the coordinates using the haversine formula
double distance = DistanceCalculator.Haversine(coordinate1, coordinate2);

The result of the above calculation should be slightly over 5 kilometers.

Run tests

dotnet test .\tests\Shorthand.Geodesy.Tests\

Shorthand.Geodesy Helper methods to convert between WGS84 and RT90/SWEREF99 and calculate distances between coordinates.

This was earlier published to CodePlex under the name CrazyBeavers Geodesy (also by me) but I've cleaned up the code and renamed it from its old silly name when moving to GitHub.

Installation

Install the nuget package using Install-Package Shorthand.Geodesy, dotnet add Shorthand.Geodesy or clone and reference the project in the repository.

Usage

Convert grid to geodetic

// Create a new GridCoordinate with a specified projection
var gridCoord = new GridCoordinate { X = 7094946, Y = 1693701, Projection = SwedishProjections.RT90_25GonV };

// Use the GaussKruger-algorithm to convert the GridCoordinate to a GeodeticCoordinate
GeodeticCoordinate geoCoord = GaussKruger.GridToGeodetic(gridCoord);

The result of the above calculation should yield a new GeodeticCoordinate with the values of about Latitude = 63.90786 and Longitude = 19.75247.

Convert geodetic to grid

// Create a new GeodeticCoordinate
var geoCoord = new GeodeticCoordinate { Latitude = 63.90786d, Longitude = 19.75247d };

// Use the GaussKruger-algorithm to convert the GeodeticCoordinate to a GridCoordinate with the specified projection
var gridCoord = GaussKruger.GeodeticToGrid(coordinate, SwedishProjections.RT90_25GonV);

The result of the above calculation should yield a new GridCoordinate with the values of about X = 7094946 and Y = 1693701.

Calculating distance between coordinates

// Create a pair of coordinates
var coordinate1 = new GeodeticCoordinate { Latitude = 63.83451d, Longitude = 20.24655d };
var coordinate2 = new GeodeticCoordinate { Latitude = 63.85763d, Longitude = 20.33569d };

// Calculate the distance between the coordinates using the haversine formula
double distance = DistanceCalculator.Haversine(coordinate1, coordinate2);

The result of the above calculation should be slightly over 5 kilometers.

Run tests

dotnet test .\tests\Shorthand.Geodesy.Tests\

Dependencies

• .NETFramework 4.6

• No dependencies.

• .NETStandard 2.0

• No dependencies.

GitHub Usage

This package is not used by any popular GitHub repositories.