Small error in Routing via Java API, setOSMFile being called on superclass without this method

There might be a small error in the ‘java usage’ section of the map-matching and the Routing via Java API page. In both instances setOSMFile(osmFile) is being called on a GraphHopper object while this function only exists in its subclass GraphHopperOSM.
Current (map matching):

GraphHopper hopper = new GraphHopper();

Current (Routing via Java API in graphhopper/docs/core/

GraphHopper hopper = new GraphHopperOSM().forServer();

Possible solution:

GraphHopperOSM hopperOSM = new GraphHopperOSM();
GraphHopper hopper = hopperOSM.forServer();

My apologies if I am simply misunderstanding or overlooking something.
Thank you!

That is correct and is already fixed :wink:
Thanks for pointing this out!

1 Like

Ups, this was not properly fixed (will do in a sec) … we need a compiler for the docs Maybe someone knows a solution for this?

It does indeed seem that a compiler for the docs would be very useful, the map matching constructor used in the example seems to be outdated:

GraphHopperStorage graph = hopper.getGraphHopperStorage();
LocationIndexMatch locationIndex = new LocationIndexMatch(graph,
(LocationIndexTree) hopper.getLocationIndex());
MapMatching mapMatching = new MapMatching(graph, locationIndex, encoder);

Instead this should probably be something like this?

String algorithm = Parameters.Algorithms.DIJKSTRA_BI;
Weighting weighting = new FastestWeighting(encoder);
AlgorithmOptions algoOptions = new AlgorithmOptions(algorithm, weighting);
MapMatching mapMatching = new MapMatching(hopper, algoOptions);

1 Like

Thanks for finding this (will have a look), would love to have a proper solution, but see the issue - it does not seem to be that simple.