Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate real time distance traveled using google maps

There is a requirement to find the real time distance traveled using google maps. This should be calculated by the phone app itself. When I mean real time, I mean for example if the user is traveling to point A, the user can get to the point in many ways, what I want to do is calculate the total distance the user has traveled real time and not just assume and calculate the distance between the two points (which would not give the correct answer).

I googled around for this problem but could not find any method in doing so.

I personally thought of storing the longitude and latitude on the phone in a list and after the user reaches the destination the distance is caluclated using these points. However this means that I have to decide the interval in which these points are stored (every 1 min or so), which would mean that I would place location points in the list even though the user was actually still on the same road, which is quite unnecessary. Unless if anyone knows how to store the points at the appropriate time or some other solution

I am well more or less stumped on this problem, any help is really appreciated

The mobile platform is Android

Thanks, MilindaD

like image 580
MilindaD Avatar asked Mar 21 '11 15:03

MilindaD


1 Answers

I think the best solution is to save the position each X seconds, and then calculate the total distance iterating between them, and to get the time, you just need to see the diference between the last point and the first one.

This is how gps tracking apps work.

Hope this helps ;)

like image 137
Jordi Puigdellívol Avatar answered Oct 26 '22 15:10

Jordi Puigdellívol