Go to file
Daniel Strobusch f834e5e9d8
update README.md for 1.3.0
2022-12-08 11:51:53 +01:00
.github/workflows built with swift 5.7 2022-12-08 11:36:08 +01:00
Sources use geodesic 2.0 2022-12-08 11:42:35 +01:00
Tests update built and include basic iOS built. 2022-02-14 19:35:49 +01:00
.gitignore implemented wrapper for geographiclib. 2018-04-01 01:38:13 +02:00
.swiftlint.yml excluding .build from linting. 2018-05-05 13:27:53 +02:00
LICENSE implemented wrapper for geographiclib. 2018-04-01 01:38:13 +02:00
Package.swift implemented wrapper for geographiclib. 2018-04-01 01:38:13 +02:00
README.md update README.md for 1.3.0 2022-12-08 11:51:53 +01:00

README.md

geodesic

Swift Version Platform Build GeographicLib Version

Solver for the inverse geodesic problem in Swift.

The inverse geodesic problem must be solved to compute the distance between two points on an oblate spheroid, or ellipsoid in general. The generalization to ellipsoids, which are not oblate spheroids is not further considered here, hence the term ellipsoid will be used synonymous with oblate spheroid.

The distance between two points is also known as the Vincenty distance.

Here is an example to compute the distance between two points (the poles in this case) on the WGS 84 ellipsoid.

import geodesic
let d = distance((lat: Double.pi / 2,lon: 0), (lat: -Double.pi / 2, lon: 0))

and that's it.

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.3.0"),
    ]
)

Implementation Details

This Swift package is a wrapper for the C library for Geodesics. The author of this library is Charles Karney ( charles@karney.com). 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 build fails. No problems with clang on Linux.