bmwcarit / barefoot

Java map matching library for integrating the map into software and services with state-of-the-art online and offline map matching that can be used stand-alone and in the cloud.
Apache License 2.0
664 stars 185 forks source link

How to get route time? #136

Open fly2008begin opened 5 years ago

fly2008begin commented 5 years ago

Hello!Why the function time() returns NULL in class Route when I run the MatcherExample .offline() ? 微信截图_20190328111801 I check the function toDebugJSON() to solve the above problem. I found that you use "for" to get samples' time,but why the size of samples() is not equal to sequence() sometimes? Then how to get time in object route?

微信截图_20190328112357

smattheis commented 5 years ago

1.) The parameter time represents the time cost (travel time) for the route. This is usually not calculated and stored by default but after it's calculated once it is buffered in that variable, see: https://github.com/bmwcarit/barefoot/blob/1faaea46f171415d745f3cbaf26d3df725d5b580/src/main/java/com/bmwcarit/barefoot/roadmap/Route.java#L100-L107 2.) The size of the sequence in the k-state depends on your policy for matching samples. That means, if samples are temporal out-of-order or you configured a minimal distance or minimum time interval, it will omit samples to improve robustness such that the sequence is not the same size as your sample set, see parameters minDistance and minInterval here: https://github.com/bmwcarit/barefoot/blob/1faaea46f171415d745f3cbaf26d3df725d5b580/src/main/java/com/bmwcarit/barefoot/matcher/Matcher.java#L353-L366