2

How can I set the route profile 'foot'? Using the default profile 'car' I can't calculate the distance between any location (in the woods) and a nearby footpath.

The error message I get is:

> Encoding does not match: Graphhopper config:
> foot|speed_factor=1.0|speed_bits=4|turn_costs=false|version=5 Graph:
> car|speed_factor=5.0|speed_bits=5|turn_costs=false|version=2 Change
> configuration to match the graph or delete ...
> gelederland-latest.osm-gh/

My code is:

graphHopper = new GraphHopper().forMobile();
EncodingManager encodingManager = EncodingManager.create( FlagEncoderFactory.FOOT);
graphHopper.setEncodingManager(encodingManager);
graphHopper.setProfiles(Arrays.asList( new ProfileConfig("my_foot").setVehicle("foot").setWeighting("fastest")));
graphHopper.load(getRoutingDataFolder());

The routing data I use? First I retrieved the raw OSM file via http://download.geofabrik.de/europe/netherlands/gelderland.html. Afterwards I prepared the Graphhopper routing data via the command:

./graphhopper.sh -a import -i gelderland-latest.osm.pbf

UPDATE: does this suffice? I am trying:

./graphhopper.sh -a import -p foot,bike,car -i netherlands-latest.osm.pbf  
tm1701
  • 7,307
  • 17
  • 79
  • 168

1 Answers1

3

The issue was that the Graph (i.e. the graphhopper generated routing files) were not aligned with the config settings in the app.

In the answer below I wanted to have a routing facility for both foot, bike and car. It is of course possible to get only routing for only 1 type of 'vehicle'. I tested this also for the routing profile 'foot'.

To get this alignment, I first edited the config.yml file in a clone of the graphhopper project. In the config file I changed:

graph.flag_encoders: foot,bike,car

and:

profiles:
  - name: foot
    vehicle: foot
    weighting: fastest

and

profiles_ch:
  - profile: foot

I generated the Graph data with this command:

./graphhopper.sh -a import -p foot,bike,car -i netherlands-latest.osm.pbf  

Then it is important to config your app with the same profile. So even working with only the 'foot' profile in your app will give a mismatch -- exactly as the error message suggests.

The app contains this code for measuring the distance of any point to a path:

graphHopper = new GraphHopper().forMobile();
EncodingManager encodingManager = EncodingManager.create( FlagEncoderFactory.FOOT + "," + FlagEncoderFactory.BIKE + "," + FlagEncoderFactory.CAR);
graphHopper.setEncodingManager(encodingManager);
graphHopper.setProfiles(Arrays.asList(
        new ProfileConfig("my_foot").setVehicle("foot").setWeighting("fastest"),
        new ProfileConfig("my_bike").setVehicle("bike").setWeighting("fastest"),
        new ProfileConfig("my_car").setVehicle("car").setWeighting("fastest")));
graphHopper.load(routingDataFolder);
tm1701
  • 7,307
  • 17
  • 79
  • 168