Testing GH profiles configuration

Hello guys!
I was wondering what kind of strategy follow to test or prove that my GraphHopper instance has the profiles properly configured (expected speeds, restrictions, etc). I was thinking if there is a way to test this in a unitary way.

Thanks in advance guys!

1 Like

You can use the path details that can be visualized in the maps app using the elevation diagram. There is one for average_speed which will show the speed that was calculated for your custom model. Unfortunately there is no built-in way to visualize turn restrictions yet.

Hi @easbar ! I was referring more programmatically, doing an Unitary Test.
I mean, prepare a test where I have a GraphHopper object and request a route against it, and check that for specific highways the speed used is the one expected.

I know that maybe it sounds a little bit redundant, but for whatever reason, we use wrongly the DSL provided (if, elseif, else) in the JSON custom profile, be sure to detect it with the programmatic test.

I want to do this test, because we had by mistake several if instructions instead of one if and several elseif and one else. Therefore that definition was causing unexpected behavior in the velocities.

The path details are also contained in the ResponsePath you get from the route you calculated using the GraphHopper object. A more low level approach would be checking the attributes of the edges directly. For example you can use LocationIndex to get a specific edge (close to some coordinate) or iterate over (and filter if needed) all edges using hopper.getGraphHopperStorage().getAllEdges(). Given an EdgeIteratorState you could get the average speed like this for example: edge.get(encoder.getAverageSpeed()). The best way to learn about these methods is looking at the unit tests I think.

But if you are using a custom weighting and want to know the calculated speed I think you should do it like here:

This stuff should probably be improved. It would be nice to have this in the documentation somewhere and even better would be some visual way to inspect calculated speeds etc. given a custom model. Hopefully we can add this to our maps app at some point.

1 Like

Amazing! Many thanks for the explanation I was looking for that!

1 Like
Powered by Discourse