I\'m developing an android app for my college that helps students track the current location of the college bus and also give them an estimated time when the bus might reach
The Google Maps Android API Utility Library has a range of applications useful for your case, including calculating distance between two points, by using the computeDistanceBetween(LatLng from, LatLng to)
method from the SphericalUtil class.
Also check this link.
Google Distance Matrix API provides travel distance and time for a matrix of origins and destinations.
Or you could try Google Directions API.
Also, I believe this guy had the same doubt of yours.
Hope this helps you.
I would it solve this way:
1) The direct line of sight distance betweent two GPS points is simple, simply use Location.distanceBetween()
method, you will find hundres of posts here on SO.
2) The length of the route.
This part is more difficult. If you are not happy with the result of google:
Store your bus routes as rough sequence of lat/lon coordinates (a poly line). A point per street corner should be sufficient.
Then find the nearest point on the route, a simple brute force search should be sufficent for your task.
Then simply iterate from found route point till destination point, and sum up using the distanceBetween()
method.