Loading GraphHopperServerConfiguration from a single file

Is it possible to load GraphHopper configuration in Low Level API from a file instead of piecing together via multiple granular calls of it’s interface? So instead of doing this:

GraphHopper graphHopperEngine = new GraphHopper().forMobile();
graphHopperEngine.setEncodingManager(EncodingManager.create(<my flags>));
graphHopperEngine.setProfiles(new Profile(<my profile>)...);
/// ... a lot more configuration
graphHopperEngine.load(<map folder>);

one would have an external file with all the configuration

  graph.location: <map folder>
  graph.flag_encoders: <my flags>
    - <my profile>
  # ... a lot more configuration

and initialize the engine along these lines:

GraphHopperConfig config = <load config from a file>
GraphHopper graphHopperEngine = new GraphHopper().forMobile();

The GraphHopper Web Service is doing exactly this, so I assume it’s somehow possible, yet I failed to identify how.

Yes, the init(config) call is what you are looking for. You just need some yaml deserialization to load the config from your file. GraphHopper uses Jackson with the yaml module for this.

Powered by Discourse