如何找到沿特定路线两点之间的距离是多少?两点、路线、距离

2023-09-05 09:45:23 作者:爱情,欠费了?

我发展我的大学一个Android应用程序,帮助学生跟踪大学总线的当前位置,并给他们一个估计的时间时,公交车可能会达到他们。截至目前我得到的总线(通过总线上的设备present)的当前位置和学生的位置。我被困在的地步,我必须找到两个GPS坐标之间的距离。我必须找到总线和学生沿着特定路线(即总线采用的路径)之间的距离。使用谷歌地图API的不会总是给沿着我想要的路线的距离。我如何找到两个点之间的距离沿特定路线?

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 them. As of now I get the current location of the bus(via a device present on the bus) and the location of the student. I'm stuck at the point where I have to find the distance between the two GPS co-ordinates. I have to find the distance between the bus and the student "along a specific route" (i.e the path the bus takes). Using Google Map APIs will not always give the distance along the route I want. How do I find the distance between two points along a specific route?

推荐答案

我会是解决这个问题的方式:

I would it solve this way:

1)直线视距的betweent两个GPS点很简单,只需使用 Location.distanceBetween()方法,你会发现SO帖子在这里hundres。

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)的路由的长度。 这部分是比较困难的。如果你不快乐与谷歌的结果: 存储您的巴士路线为纬度/经度坐标(聚线)粗略序列。每个街角一个点应该是足够了。 然后找到航线的最近点,一个简单的蛮力搜索应该sufficent您的任务。 然后,只需从发现的路由点到目的点迭代,并使用 distanceBetween()方法总结。

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.

 
精彩推荐