I am working on a Spring Boot project that integrates GraphHopper (version 8) for car routing. My application is required to load an OSM (.pbf) file of the entire France, but I'm facing a significant performance issue: the initial loading and processing time at startup is extremely long, taking almost one hour.
Here's an overview of my environment and setup:
- Project: Spring Boot 3.2.1
- GraphHopper: version 8
- OSM File:
france-latest.osm.pbf - Goal: To calculate the driving distance between two points only.
The long loading time is a major concern, especially since it happens at each startup of the application. I am looking for advice or strategies to significantly reduce this initial loading time. Is there a way to optimize the OSM file processing in GraphHopper for this specific use case?
I am open to any suggestions, whether it's a change in configuration, a different approach in processing OSM data, or any other possible optimizations that could help in reducing the startup time.
Here's an example of my current GraphHopper configuration
@Bean
public GraphHopper graphHopper() {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile("src/main/resources/france-latest.osm.pbf");
hopper.getRouterConfig().setCalcPoints(false);
hopper.getRouterConfig().setInstructionsEnabled(false);
hopper.setGraphHopperLocation("target/routing-graph-cache");
hopper.setProfiles(new Profile("car").setVehicle("car").setTurnCosts(false));
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile("car"));
hopper.importOrLoad();
return hopper;
}
Usually GraphHopper runs the OSM import only once. On subsequent starts the server should just load the generated index files from disk which should take a few seconds at most. Maybe your application imports the OSM data every time you start the server for some reason? Btw you will find much better support for GraphHopper related questions at http://discuss.graphhopper.com