Skip to content

Instantly share code, notes, and snippets.

@niksmac
Created January 21, 2015 11:51
Show Gist options
  • Select an option

  • Save niksmac/a18a504309224d3adcb0 to your computer and use it in GitHub Desktop.

Select an option

Save niksmac/a18a504309224d3adcb0 to your computer and use it in GitHub Desktop.
Drupal 7 Location Calculate distance between 2 location fields
Location module has the function location_distance_between() (also in D7).
It passes the call on to function earth_distance($longitude1, $latitude1, $longitude2, $latitude2), which lives inside the earth.inc file in the same package.
See also: http://en.wikipedia.org/wiki/Great-circle_distance, which points out some of the intricacies of numerical calculation and accuracy of long vs short distances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment