Hi Tuan, the speed is internally stored in just a few bits of the long value (edgeState.getFlags)
And to convert this for that we divide speed through the specified factor and use maximum 'speedBits' for the speed. E.g. 5 bits => 32 values => *5 => max speed of 160 So if you want a speed factor of 1 you need like 7 to 8 bits. Another idea could be to have a table lookup instead of the factor to make it more precise and compact at the same time. Kind Regards, Peter On 03.07.2015 09:36, Tuan Nguyen wrote: > Hi Peter, > > Thanks for the clarification on speed unit. > > My validation logic was to check if getSpeed() in current graph > EXACTLY match the double value that I set before. This usually does > not match as you said, "due to the limited resolution". > > Btw, can you elaborate a bit on the use of speedBits, speedFactor when > storing speed? I know how to update speed through your blog posts but > I cannot understand internally how it works. Or if you can point me to > another resource, that would be much appreciated. > > > Kind Regards, > Tuan. > > On 3 July 2015 at 17:21, Peter <[email protected] > <mailto:[email protected]>> wrote: > > Hi, > > good that you solved the problem but would you elaborate a bit on > this: > "They are always different as the way Graphhopper processes double > value." > > Do you mean that getSpeed returns two different values before and > after flush? Or just the speed you are expecting vs. what getSpeed > returns - then, yes this is expected due to limited resolution > which you can tune in the flagencoder. > > And the speed is km/h ... We even do not support mile in the UI (yet) > https://github.com/graphhopper/graphhopper/issues/396 > > Peter > > > On 03.07.2015 07:53, Emux wrote: >> On 03/07/2015 05:12 πμ, Tuan Nguyen wrote: >>> By the way, is the speed used in Graphhopper km/hour or mile/hour? >> >> I expect it to be units based on the SI system. >> >> -- >> Emux >> Cruiser <http://wiki.openstreetmap.org/wiki/Cruiser> - Atlas >> <http://wiki.openstreetmap.org/wiki/Atlas_%28navigation_application%29> >
_______________________________________________ GraphHopper mailing list [email protected] https://lists.openstreetmap.org/listinfo/graphhopper
