Geo

Geo / GeoDistance / 0.1.1

README.md

0. TL;DR

This is an algorithm which gives you the distance in either miles or km format for two coordinate points.

1. Introduction

GeoDistance is an algorithm that uses Vincenty's formulae for calculating the distance between two coordinates. It accepts the longitude and latitude for two specific points, and returns the distance in either "miles" or "km" format.

Input

  • (Required) Lat1: Latitude of position 1.
  • (Required) Lon1: Longitude of position 1.
  • (Required) Lat2: Latitude of position 2.
  • (Required) Lon2: Longitude of position 2.
  • (Required) Type: The format of the distance (either "miles", or "km")

Output

  • Distance between the two positions. (either in "miles" or "km")

2. Example

  • Parameter 1: Latitude of position 1.
  • Parameter 2: Longitude of position 1.
  • Parameter 3: Latitude of position 2.
  • Parameter 4: Longitude of position 2.
{
    "lat1": 47.601518,
    "lon1": -122.334297,
    "lat2": 47.679217,
    "lon2": -122.386031,
    "type": "miles"
}

Output:

5.88637243160366