Upgrate graphhopperOSM to v2.4

Hi,
Currently I am using graphhopperOSM v0.11 (pretty old) and I am upgrading to 2.4.

I have an issue when creating graphhopperOSM instance in setEncodingManager the new EncodingManager is no longer available.

Is there a new way to set the encodingManager?

What exactly are you trying to do? Also note that the most recent is 6.2.

No I am talking about GraphHopper Reader For OpenStreetMap Data Dependency (https://mvnrepository.com/artifact/com.graphhopper/graphhopper-reader-osm) which is in v2.4, and not the core dependency. (and to be honest if someone could explain to me the differences between core and Reader For OpenstreetMap dependency, would be appreciated)

my old code to create an instance of graphhopper is the below :

@Bean
    public GraphHopperOSM graphHopper() {
        GraphHopperOSM graphHopper = ((GraphHopperOSM) new GraphHopperOSM().forServer());
        String osmPath = "path to osm file";
        graphHopper.setOSMFile(osmPath);
        graphHopper.setGraphHopperLocation("path to osm file location");
        graphHopper.setEncodingManager(new EncodingManager("car"));
        graphHopper.setMinNetworkSize(200, 200);
        graphHopper.importOrLoad();
        return graphHopper;
    }

After upgrading to 2.4 i get error for the current line :

    graphHopper.setEncodingManager(new EncodingManager("car"));

The graphhopper-reader-osm module no longer exists. All of its functionality is now in core (also see here: Move the reader-osm module into core by easbar · Pull Request #2298 · graphhopper/graphhopper · GitHub), so you can use core 6.2 for what you are doing.

Using 6.2 your code should look something like this:

        GraphHopper graphHopper = new GraphHopper().init(
                        new GraphHopperConfig().
                                putObject("datareader.file", "path to osm file").
                                putObject("graph.location", "path to graphhopper folder (not osm file location!)").
                                putObject("prepare.min_network_size", 200). // skip this unless you know what you are doing, 200 is the default anyway
                                putObject("import.osm.ignored_highways", ""). // if you are only using car you can ignore paths, tracks etc. here, take a look at the documentation in `config-example.yml`
                                setProfiles(Arrays.asList(
                                        new Profile("car").setVehicle("car").setWeighting("fastest")
                                 ))).
       hopper.importOrLoad();
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.