dastrobu/geodesic
Compute distances in Swift
Table of Contents
Installation
At least clang-3.6 is required. On linux one might need to install it explicitly. There are no dependencies on macOS.
Swift Package Manager
let package = Package(
dependencies: [
.package(url: "https://github.com/dastrobu/geodesic.git", from: "1.5.0"),
]
)Implementation Details
This Swift package is a wrapper for the C implementation of the geodesic routines in GeographicLib. The goal of this Swift package is to make some algorithms from GeographicLib available to the Swift world. Alternatively one can employ the package vincenty which is a much simpler solver for the inverse geodesic problem, completely written in Swift. Vincenty's formulae does, however, have some convergence problems in rare cases and may not give the same accuracy as Karney's algorithm.
Convergence and Tolerance
The computation does always converge and is said to compute up to machine precision. See documentation of GeographicLib for details.
WGS 84 and other Ellipsoids
By default the WGS 84 ellipsoid is employed, but different parameters can be specified, e.g. for the GRS 80 ellipsoid.
distance((lat: Double.pi / 2, lon: 0), (lat: -Double.pi / 2, lon: 0),
ellipsoid (a: 6378137.0, f: 1/298.257222100882711))Known Issues
- Compilation with gcc on Linux does not work.
swift buildfails. No problems with clang on Linux.
Package Metadata
Repository: dastrobu/geodesic
Stars: 6
Forks: 1
Open issues: 0
Default branch: main
Primary language: c
License: MIT
Topics: distance-calculation, geodesic, geodesics, swift, swift-4, swift-5, swift-library, swift-linux, vincenty, vincenty-formula
README: README.md