Search code examples
phpgpscoordinatesdistancehaversine

Calculate distance between GPS points by coordinates


I'm having some trouble computing the distance between two GPS points by their coordinates.

point a
x = 7,2562
y = 47,7434599999999

point b 
x = 7,21978
y = 47,73836

I used the Haversine formula as described here. The result I get is 4.09 km.

However, locating those points on a map using a tool like this, I can measure a distance of 2.8 km

Several other formulas I tried also return a result around 4 km.

Any ideas what I would be missing ?


Solution

  • As pointed out by Roland Starke in the comments, the problem was the order of the coordinates. (7, 47 not 47, 7)