Skip to content
moxon home

Geo

The /geo endpoint calculates the distance and bearing between two GPS coordinates using the Haversine formula.

gethttps://api.moxon.dev/v6/geo

How it works?

The Haversine formula computes the great-circle distance between two points on a sphere — the shortest path over the Earth's surface, ignoring elevation. Bearing is the initial compass heading from point A to point B, expressed in degrees (0° = North) and as a cardinal direction.

Try itget/v6/geo

Parameters

  • lat1numberrequired

    Latitude of point A (-90/+90)

  • lon1numberrequired

    Longitude of point A (-180/+180)

  • lat2numberrequired

    Latitude of point B (-90/+90)

  • lon2numberrequired

    Longitude of point B (-180/+180)

Response Fields

  • distance.kmnumber

    Distance in kilometers

  • distance.milesnumber

    Distance in miles

  • distance.nauticalMilesnumber

    Distance in nautical miles

  • bearing.degreesnumber

    Bearing in degrees (0–360)

  • bearing.cardinalstring

    Cardinal direction (N, NNE, NE, ENE, E, etc.)

  • from.latnumber

    Parsed latitude of point A

  • from.lonnumber

    Parsed longitude of point A

  • to.latnumber

    Parsed latitude of point B

  • to.lonnumber

    Parsed longitude of point B

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400lat1 must be a numberA coordinate is not a valid number
  • 400lat1 must be between -90 and 90Latitude is out of range
  • 400lon1 must be between -180 and 180Longitude is out of range