简体   繁体   中英

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.).

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

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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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