 # Calculate ETA using latitude and longitude.

Hello,

I want to ask if it is possible to calculate estimate time arrival (ETA) using latitude and longitude data from GPS? I searched but found nothing. I do not have any idea how to calculate it.

If it is possible can you teach me how to calculate ETA? What data that I need to calculate the ETA and can you provide me a simple code to calculate it.

Thank you.

No, you would have to also know the speed as well. If you know that then you only need to calculate the distance and use elementary school mathematics to calculate the time needed to cover that distance at that speed.

Delta_G: No, you would have to also know the speed as well. If you know that then you only need to calculate the distance and use elementary school mathematics to calculate the time needed to cover that distance at that speed.

How to calculate distance using latitude and longitude?

Are you assuming a straight line between points or do you need ground distance?

pert: Are you assuming a straight line between points or do you need ground distance?

I'm using latitude and longitude so I think a ground distance. Because I'm trying to get an ETA for a bus from departure place to arrival place.

Naqif: I'm using latitude and longitude so I think a ground distance. Because I'm trying to get an ETA for a bus from departure place to arrival place.

Getting a distance between two points on a graph is simple geometry. You have a distance in the x direction, and a distance in the y direction and that makes a right angle. The line connecting finishes a right triangle. Use Pythagoras to calculate the distance there. If you're talking about local bus routes that's probably fine. But if you're talking about cross country bus routes then you need to take into account that the Earth is not flat. There are some simple ways to handle that. If you'll do just a little bit of searching on the internet you should be able to find some ways. I don't know them off the top of my head but I bet I could get to something in a few seconds with google. Why don't you try it. It's a great site for finding things on the internet. It's at www.google.com if you've never been there.

Latitude and longitude makes sense only if you travel along the great circle (gooogle that!) and for that you need spheric trigonometry. Even a local bus travels much longer distance than the great circle line between two points. Only thing that works is a Google Maps kind of system with a street and road database with pathfinding. 2D Pythagorean distance calculation works only around the Equator. Not at the 60th latitude, where I live, where the longitudinal distance minute is only half of the latitudinal one.

For short distances, Pythagoras is fine. For long distances, use the Havesine formula. For bus travel time, empirical data will be the most accurate to get to an estimate time for it to travel from A to B. Time of day will matter.

Naqif: I want to ask if it is possible to calculate estimate time arrival (ETA) using latitude and longitude data from GPS? I searched but found nothing. I do not have any idea how to calculate it.

Well to calculate ETA, your probably going to at least know the distance between where the bus is and the arrival, so try a Google search on;

arduino calculate distance with gps

srnet: Well to calculate ETA, your probably going to at least know the distance between where the bus is and the arrival, so try a Google search on;

arduino calculate distance with gps

Thanks for your replied. Now I know how to find a distance between two points but how to calculate the ETA? Any suggestion?

Naqif: Thanks for your replied. Now I know how to find a distance between two points but how to calculate the ETA? Any suggestion?

See post #1.

As an example, if the bus is 10km away and travelling at 10kmph, how long before it arrives ?

Our local bus companies do it based on old data, not on actual distances. Over time they just logged how long it takes a bus to move between stops.

So in rush hour you can see longer time between two stops than at other hours (and with traffic jams being pretty reliable, those times are also quite reliable). Time spent at stops in rush hour is also much longer (more passengers to board - just the boarding may take 5 minutes - or having to wait for other buses occupying the same stop). Furthermore, estimated time of arrival (as displayed at bus stops) is constantly updated based on actual traffic conditions - so if you see the next bus is due in 5 minutes, it may change to 6 or 7, or suddenly jump to 3.

Traffic movement based on distance + speed is a very rough estimate at best, so your estimates on bus arrival times will be not much more accurate than the official time tables.

srnet: As an example, if the bus is 10km away and travelling at 10kmph, how long before it arrives ?

That's simple. 10 and 10, so that's 10 hours. Or was it 10 minutes... Mmm... Maybe I should go back to primary school, but at that time I wasn't using buses much, we did just about everything by bicycle!

Naqif: Thanks for your replied. Now I know how to find a distance between two points but how to calculate the ETA? Any suggestion?

If it were a straight line between points then Time = Distance X Speed, however it is highly unlikely that a bus will travel in a straight line therefore you need more information about the route just to calculate the distance.

Then there is the issue of measuring distance using lat & Long co ordinates with degrees and minutes Latitude being constant (one minute is 1,843 metres or one nautical mile) however because the lines of longitude go from pole to pole they are naturally closer together at the poles and further apart at the equator (one minute is approx 1,855 metres at the equator and 925 metres at 60 degrees Latitude) therefore any distance calculation needs a correction factor depending on where in the world you are measuring.