Contents

dastrobu/vincenty

Compute vincenty distance in Swift

Table of Contents

- Dependencies - Swift Package Manager

Installation

Dependencies

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/vincenty.git", from: "1.1.2"),
    ]
)

Cocoa Pods

Make sure a valid deployment target is setup in the Podfile and add

pod 'vincenty', '~> 1'

Implementation Details

This is a simple implementation of Vincenty's formulae. It is not the most accurate or most stable algorithm, however, easy to implement. There are more sophisticated implementations, see, e.g. geodesic.

Convergence and Tolerance

Convergence and the accuracy of the result can be controlled via two parameters.

try distance((lat: 0,lon: 0), (lat: 0, lon: 0), tol: 1e-10, maxIter: 200)

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.

try distance((lat: Double.pi / 2, lon: 0), (lat: -Double.pi / 2, lon: 0), ellipsoid (a: 6378137.0, f: 1/298.257222100882711))

Docs

Read the generated docs.

Package Metadata

Repository: dastrobu/vincenty

Homepage: https://dastrobu.github.io/vincenty/documentation/vincenty/

Stars: 10

Forks: 2

Open issues: 1

Default branch: main

Primary language: swift

License: Apache-2.0

Topics: distance-calculation, geodesic, geodesics, swift, swift-4, swift-5, swift-library, swift-linux, vincenty

README: README.md