1

I would like to create an app that shows the instructions to the user while traveling. The problem is that when you receive no positions for a while then probably the user went trough 2-3 instructions. After it when a new position arrives I would like to find the next instruction on the road.

What is the best way to find that instruction based on my position? Can Graphhopper help me to find it? Or should I recalculate the whole route in this case (from my position to destination)?

I tried locationIndex.findClosest() method but I don't know if it is the next or previous instruction.

Please give me some advices.

Thank you.

Blehi
  • 1,990
  • 1
  • 18
  • 20

1 Answers1

2

Try:

ghResponse.getInstructionList().find(currentPosition.latitude, currentPosition.longitude)
Karussell
  • 17,085
  • 16
  • 97
  • 197
  • Unfortunately around ~50-60m before the second instruction it tells me that the next instruction is the 3rd one. Perhaps do you know why? I think it should tell me the 3rd point only after I leaved the 2nd point right? – Blehi Dec 16 '14 at 16:52
  • Please post an issue on github will the route, a link to graphhopper maps or even better a simple test case (mentioning the area) – Karussell Dec 16 '14 at 17:07
  • Hmm .. I cannot reproduce it now but next time I will create an issue with the exact data. Thanks anyway. – Blehi Dec 16 '14 at 17:38
  • There was indeed an issue with this method, which is now fixed: https://github.com/graphhopper/graphhopper/issues/295 – Karussell Dec 21 '14 at 17:06
  • Thank you. Unfortunately my laptop died but after it will be repared I will try it. – Blehi Dec 21 '14 at 22:44