简体   繁体   English

android-计算两个巴士站之间的距离

[英]android - Calculating the distance between two bus stop

I am developing an android app that features a function of reminder (when the bus arrive the target stop soon, do something.). 我正在开发一个具有提醒功能的android应用(当公交车很快到达目标站时,执行一些操作。)。

What details I have are: 我有哪些详细信息是:

  • each bus stop's lat/lng 每个巴士站的经纬度

  • the bus's average speed 巴士的平均速度

  • able to get user's current location(lat/lng) using GPS or Network provider 能够使用GPS或网络提供商获取用户的当前位置(经/纬度)

What I stunk on is: The user's location will change as the bus is moving. 我最烂的是:随着公共汽车的行驶,用户的位置将发生变化。 If I calculate the distance between the user's current location and the target stop's location, it seems not correct as it don't consider the bus route path. 如果我计算用户的当前位置和目标站点的位置之间的距离,这似乎是不正确的,因为它没有考虑公交路线。 If I consider the bus route path for calculation, how can I know what the next stop is? 如果考虑公交路线计算,我怎么知道下一站是什么? Have any solution? 有什么解决办法吗?

Thanks very much and appreciate your advice! 非常感谢,并感谢您的建议!

Maybe as an alternative solution: 也许作为替代解决方案:

As I understand you fetch your own position via GPS. 据我了解,您可以通过GPS获取自己的位置。 Maybe it's possible to check in a radius of 500 meters, if the bus stop you want to exit is within the 500 meters or not. 如果要退出的巴士站是否在500米以内,也许可以检查半径500米。 And if it's within you get an alarm. 如果它在您的范围内,则会发出警报。

For your problem you need to know the path the bus takes and every single stop it has. 对于您的问题,您需要了解公交车经过的路径以及公交车站的每一站。 Then you could calculate along the path how many meters you're away from the stop. 然后,您可以沿路径计算距停靠点有几米。

Hope I did not misunderstand you to much 希望我不要误会你

I assume your app is used by someone riding a given bus, and you want to alert them some time in advance of them arriving at their chosen stop. 我假设您的应用程序已被乘坐给定公交车的人使用,并且您想在他们到达所选停靠站之前提前提醒他们。

If you know the stops along the route (which you can get for most cities using the GTFS data), then you could try the following idea. 如果您知道路线上的站点(可以使用GTFS数据在大多数城市中找到这些站点),则可以尝试以下方法。 When you pass the stop before the stop requested, provide an alert. 当您在请求停止之前通过停止时,请提供警报。 If the stops are too close together,then you could alert on the 2nd stop before the requested one. 如果停靠点距离太近,那么您可以在第二停靠点之前发出警报。 You can know when you pass a stop comparing the bus location (from the user's location) and location of the stop. 您可以知道何时通过车站,比较巴士位置(从用户的位置)和车站的位置。 If the distance is less than say, 30 meters, then assume you are about to, or just passed the stop. 如果距离小于30米,则假设您即将到达,或刚刚经过车站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM