[GraphHopper] Fwd: Re: instruction too early

Laura Barroso laura.barroso at hab.desoft.cu
Tue Feb 17 15:48:14 UTC 2015


Yes, that will solve my issue, Backward search will be required too.

-----Mensaje original-----
De: Peter [mailto:graphhopper at gmx.de] 
Enviado el: martes, 17 de febrero de 2015 10:43
Para: graphhopper at openstreetmap.org
Asunto: Re: [GraphHopper] Fwd: Re: instruction too early

ok. So what you would need some method like this:

currentInstruction = find(lat, lon, maxDistance, previousInstruction)

which can be called several times (and is cheap&fast) and only searches e.g. forward for the closest instruction? Would this solve your issue?
Or would 'backward' search also be necessary as a user could go far off the route?

Peter


On 17.02.2015 16:32, Laura Barroso wrote:
> well,yes, I can probably do that, but I was thinking that if my 
> current location is near to one of the points that holds the 
> instruction then I will miss it, am I right?...however will do your suggestion.Thanks.
> My usecase is guide the user depending on the gps current location and 
> the route.
>
>> if you find once the next instruction why would you need to iterate 
>> over all points, why not just take the first of this instruction 
>> (getFirstLat
>> etc) and check the distance? what is your usecase?
>>
>> Peter
>>
>>
>> On 17.02.2015 16:15, Laura Barroso wrote:
>>> you mean something like this?
>>> DistanceCalc distCalc = Helper.DIST_EARTH;
>>> 			distCalc.calcDist(instruction.getPoints().getLat(0),
>>> instruction.getPoints().getLon(0),					 currentLocation.getLatitude(),
>>> currentLocation.getLongitude())
>>>
>>> but still will have iterate over all the points inside the 
>>> instruction...
>>> is there any better way????
>>>
>>>
>>>> Laura,
>>>>
>>>> why not find the next instruction and only display it if the 
>>>> current location is close to it? No need to do unnecessary find() calls.
>>>>
>>>>> until the max distance between
>>>>> one of the edges and the current position is right, even is that 
>>>>> mean that the user don't get any instruction at all
>>>> Why not specify the allowed maximum distance to the route in the 
>>>> find method appropriately?
>>>>
>>>> Regards,
>>>> Peter
>>>>
>>>>
>>>> On 17.02.2015 14:43, Laura Barroso wrote:
>>>>> oh boy, so that's what's happening...this is not good for me, I'm 
>>>>> not interested in knowing the next instruction until the max 
>>>>> distance between one of the edges and the current position is 
>>>>> right, even is that mean that the user don't get any instruction 
>>>>> at all because he don't get close enough to them. ok, Thanks a lot 
>>>>> for the clarification, now everything gets more sense.
>>>>> Thinking a good approach maybe override instructionList class in 
>>>>> order to modify this behavior to suit my needs. Second approach: 
>>>>> compute everything twice, one the instructionlist(in the find 
>>>>> method) and the second on my method...
>>>>>
>>>>>> Hi Laura,
>>>>>>
>>>>>> I took a look at InstructionList.find() and actually found some 
>>>>>> inconsistent behaviour:
>>>>>> https://github.com/graphhopper/graphhopper/issues/331
>>>>>>
>>>>>> Nevertheless I don't think this is the reason for the problems 
>>>>>> you described.
>>>>>>
>>>>>> Maybe to avoid misunderstandings, the find(lat, lon, dist) method 
>>>>>> is supposed to work as following:
>>>>>> Given lat,lon find the closest point on the route. If lat,lon is 
>>>>>> not more than than dist away from the route, then it yields the 
>>>>>> upcoming instruction (even if this instruction is a lot further 
>>>>>> away than dist).
>>>>>>
>>>>>>> Easy: any point in Havana I have test routes in Miramar, Vedado 
>>>>>>> and Guanabacoa, note those are like areas that are not close to 
>>>>>>> each other(at list Guanabacoa from the rest), the last point 
>>>>>>> that I test was:
>>>>>>> START:  latitud: 23.12529533541739 longitude: -82.41401873360883
>>>>>>> END: latitud: 23.124871881707463 longitude: -82.4237889156866 
>>>>>>> The route that I create was on foot, for android purpose. Thanks!
>>>>>>>
>>>>>>>
>>>>>> To find the reason for your exact problem, it would help a lot if 
>>>>>> you can also give me lat, lon coordinates for which you don't get 
>>>>>> any instruction or the instruction within wrong distance.
>>>>>>
>>>>>> Cheers,
>>>>>> Jan
>>>>>>
>>>>>>>> Hi Laura,
>>>>>>>>
>>>>>>>> thanks for the clarification. i will take a look into this, but 
>>>>>>>> it would be helpfull if you can provide me start and end point 
>>>>>>>> of the route, as well as one or two points where there is a 
>>>>>>>> wrong instruction or one missing.
>>>>>>>>
>>>>>>>> Jan
>>>>>>>>
>>>>>>>>> Hello, thanks for your reply, I was not referring to that 
>>>>>>>>> issue but it is quite similar to was happen to me... however I 
>>>>>>>>> know that graphhopper generate all the instructions for the 
>>>>>>>>> route, I check it out every time.
>>>>>>>>> The problem is that it gives me the wrong instruction at the 
>>>>>>>>> wrong time.
>>>>>>>>> The sniped code you see is part of the class that overrides 
>>>>>>>>> MyLocationOverlay, on the onLocationChanged method.
>>>>>>>>> I tell graphhopper to give me the next instruction in this 
>>>>>>>>> piece of
>>>>>>>>> code:
>>>>>>>>> Instruction instruction = il.find(location.getLatitude(), 
>>>>>>>>> location.getLongitude(), 2); il is the InstructionList that is 
>>>>>>>>> created as part of the route, I pass it to the class and every 
>>>>>>>>> time that location changes I check if there is anything to say 
>>>>>>>>> to the user.
>>>>>>>>> Hi Laura,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Hello everyone: I notices that graphhopper is giving me the 
>>>>>>>>>> instructions too early and sometimes it wont even give me 
>>>>>>>>>> anything, I think I read about an issue pointing that but now 
>>>>>>>>>> is close...
>>>>>>>>> maybe you refer to this issue
>>>>>>>>> https://github.com/graphhopper/graphhopper/issues/94 regarding 
>>>>>>>>> missing instructions?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I override MyLocationOverlay class, and this is my code:
>>>>>>>>>> @Override public void onLocationChanged(Location location) { 
>>>>>>>>>> super.onLocationChanged(location);
>>>>>>>>>> if (lastLocation == null || location != lastLocation) { 
>>>>>>>>>> lastLocation = location; if (il != null) { Instruction 
>>>>>>>>>> instruction = il.find(location.getLatitude(), 
>>>>>>>>>> location.getLongitude(), 2); if (instruction != null && 
>>>>>>>>>> instruction !=
>>>>>>>>> lastInstruction) {
>>>>>>>>>> lastInstruction = instruction; String text =
>>>>>>>>> lastInstruction.getTurnDescription(esTR);
>>>>>>>>>> Toast.makeText(context, text,
>>>>>>>>> Toast.LENGTH_LONG).show();
>>>>>>>>>> if (tts != null) { tts.speak(text, TextToSpeech.QUEUE_FLUSH, 
>>>>>>>>>> null); } } } } }
>>>>>>>>> I would take a look into this, but I don't understand yet 
>>>>>>>>> where exactly your code hooks into the GraphHopper Code. I do 
>>>>>>>>> not see any LocationOverlay class, but maybe you can point me 
>>>>>>>>> there with a github link.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Note that it suppose to give me the instruction with at list 
>>>>>>>>>> 2 meters of distance, last time I check it gave me the 
>>>>>>>>>> instruction with at list 5 meters of distance in the first 
>>>>>>>>>> edge...the next turn wont dispatch anything at all...what 
>>>>>>>>>> could be happening? My start point now is branch "issue 314" 
>>>>>>>>>> since I haven't being able to download the complete 
>>>>>>>>>> repository(problems with my connection).
>>>>>>>>>> any
>>>>>>>>>> help will be appreciated.
>>>>>>>>> Cheers,
>>>>>>>>> Jan
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>


_______________________________________________
GraphHopper mailing list
GraphHopper at openstreetmap.org
https://lists.openstreetmap.org/listinfo/graphhopper




More information about the GraphHopper mailing list