How to find the distance between two points along a specific route?

后端 未结 2 1743
忘了有多久
忘了有多久 2021-01-03 12:37

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

2条回答
  •  生来不讨喜
    2021-01-03 13:33

    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.

提交回复
热议问题