I am developing a Python app in which starting from a source point (given in lat, lon) after reaching a destination point I want to be notified after reaching my destination.

What I had actually thought to do was recalculating the current position of the user after some interval with calculating its distance. When the distance becomes less than 0.1 to the destination. I'd assume that the user have reached the destination. (According to Haversine formula).

Could anyone pls suggest me a better approach with OSRM apis? as this approach would be compute-intensive.

Thanks in advance. Rachna.

asked 02 Jun '20, 10:32

rachnarai's gravatar image

accept rate: 0%

edited 04 Jun '20, 19:56


I don't see why this involves a router at all. Just compare the current position with the position of the destination. If the calculated distance is small enough you have reached your destination. Why do you need a routing engine for this task?

(02 Jun '20, 14:11) scai ♦

Hi Alex, yes there won't be any need to do this. But after getting the current user location, at some interval I would need to calculate distance from that point to destination and this distance will be called several times until user reaches his destination. Will this approach be valid anyway? I'm doubtful about it, because I'd be needing to calculate distance periodically.

(02 Jun '20, 17:58) rachnarai

Do you need to calculate the road distance periodically or just the bee line (you mentioned the Haversine formula in your question)?

(02 Jun '20, 19:40) TZorn

Just the Haversine formula, only concerned with comparison. Thats all

(02 Jun '20, 19:45) rachnarai

Then I can't see what you would need a router for, either. I repeat scai's question: Why do you believe you need a router? What is the router supposed to do?

Do you need something to geo-locate the destination? That would be a one-time call only and you don't have to repeat that with every distance calculation iteration.

(03 Jun '20, 10:01) TZorn

I would already have the destination geocode, but I would have to get the User's current location which would be changing repeatedly due to his moment.

So I need to compare this location until this current location matches the destination geocode.

Therefore, for this I would need to calculate distance until the distance becomes < 0.1. (That's how we compare two geocodes)

Now coming to the question I have asked, I want to reduce the number of calls to my distance calculation function. (of course I would do this after some interval but this can be reduced if i get the estimated time.)

So, for that I wanted to get the estimated time in order to reach a point then after that if user couldn't reach there, I'd calculate estimated time again and check again whether he has reached. (Or by other way as this can be done in multiple ways.) So I had thought maybe this can reduce time complexity in order to accomplish this. Then I came across the OSRM routing engine which gives estimated time and distance but that will be too complicated and would be too compute intensive.

I'm hoping now that my question is clear, Awaiting for your thoughts and suggestions.

(03 Jun '20, 12:59) rachnarai

You can calculate the ETA on your own by looking at distance and speed. Of course this will be less accurate than using a router. However it will also be much cheaper, so you can perform it more frequently. If the ETA is far in the future then use scarce recalculations, if the ETA is near or the distance is short then increase the recalculation frequency.

(04 Jun '20, 07:03) scai ♦

Calculating the distance is pretty cheap. So why not do something like this: If the bee-line distance is > 5km re-calculate every minute. If the distance is > 1km re-calculate every 10 seconds. After that re-calculate every second. I assume a car here. Intervals could be longer or shorter for foot traffic or an airplane.

(04 Jun '20, 07:59) TZorn
showing 5 of 9 show 4 more comments
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 Jun '20, 10:32

question was seen: 466 times

last updated: 04 Jun '20, 19:56

powered by OSQA