Different route using truck profile in Web Graphhopper and locally

Hello guys,

I’ve been trying to route within a specifica start/end, but when I use the truck profile, I got a different route from graphhopper web, comparing to what I have running locally.

Locally

Graphhopper Web

The route should be taken, is the route in Graphhopper Web.

I troubleshooted the routing graph in my local graphhopper, and I realized that max_weight, max_height, and max_width are “infinity”, as the following img.


Unfortunately, the graphhopper web doesn’t contain the routing graph to compare.


Currently, I’ve been running osm planet-250505 basemap with graphhopper 9.1, and my config file, is like the following:

graphhopper:
      datareader.file: ""
      custom_models.directory: /graphhopper/profiles
      profiles:
        - name: car
          custom_model_files: [ car.json ]
        - name: truck
          weighting: custom
          custom_model_files: [ truck.json ]
      profiles_ch:
        - profile: car
        - profile: truck
      profiles_lm: []
      prepare.min_network_size: 1000
      prepare.subnetworks.threads: 1
      routing.non_ch.max_waypoint_distance: 100000000 #100.000.000
      routing.max_visited_nodes: 10000000 #10.000.000
      import.osm.ignored_highways: footway,cycleway,path,pedestrian,steps # typically useful for motorized-only routing
      graph.location: graph-cache
      graph.dataaccess.default_type: RAM_STORE
      graph.encoded_values: hgv,max_weight,max_height,max_width,toll,car_access,car_average_speed,road_access
    server:
      application_connectors:
        - type: http
          port: 8989
          bind_host: localhost
          max_request_header_size: 50k
      request_log:
        appenders: []
      admin_connectors:
        - type: http
          port: 8990
          bind_host: localhost
    logging:
      appenders:
        - type: file
          time_zone: UTC
          current_log_filename: logs/graphhopper.log
          log_format: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
          archive: true
          archived_log_filename_pattern: ./logs/graphhopper-%d.log.gz
          archived_file_count: 30
          never_block: true
        - type: console
          time_zone: UTC
          log_format: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
      loggers:
        "com.graphhopper.osm_warnings":
          level: DEBUG
          additive: false
          appenders:
            - type: file
              currentLogFilename: logs/osm_warnings.log
              archive: false
              logFormat: '[%level] %msg%n'

Could someone tell me what may be causing this difference?

Hi @felipe.mendes,

I have ran into a few problems to where locally is not giving same result as the Web.

However, the Web is usually running the latest, so 10.x at least. I would recommend upgrading to that if you can.

Also, using those Geo points you have, notice on the web if you click car, you get the same as your local truck. And if you click on Truck, make sure you click Settings, and notice the difference between “Delivery van” vs “Big Truck”.

What you need to find out is what does the Web version of [ “big_truck.json” ] file looks like (not sure if that is available if it was modified from link below about custom_models). Notice your config points to that, usually in /<graphhopper_home>/profiles. Here, you want to edit that truck.json file. In that json file, you can add all kinds of stuff: See here:

So i would upgrade to 10.2 at least if you can (requires newer JDK though, and you will have to recreate the graph directory) and then make your own truck profile, and mess around with that. See more profile stuff here:

Note truck.json was changed 3 months ago. (Anything multiplied by 0 should cause the truck to not take the route. They have added some more stuff)

And on your local server, click the little gear (top left) and you can mess around with the profiles there first. This is useful, because every time you modify the json file, you need to rebuild the graph directory (first time graphhopper is ran) which takes a long time if you are using that big of an OSM file. So, better to mess around with restrictions here, and once you get it right, change the truck.json. (Don’t forget to delete the old graph directory once you are done messing around with the restrictions, because if you don’t your new truck.json file is ignored if i remember right).

Hope this helps

Hello @floormat

And if you click on Truck, make sure you click Settings, and notice the difference between “Delivery van” vs “Big Truck”

I checked this option in GH Web, and if I change the settings among Delivery Van and Big Truck, this affect the route, as you can see below.


Now, it’s not possible to just replace the custom_model truck configuration that you mentioned here (graphhopper/core/src/main/resources/com/graphhopper/custom_models at master · graphhopper/graphhopper · GitHub), cause it gives an error.

.

Any other idea?

@felipe.mendes

Just to confirm, you think the GraphHopper Web is better route, correct?

If you are lucky, an admin from GraphHopper will give you their “Big Truck.json” file.

But, if you want your local to do the same, try this: (I don’t have a local copy of 9.x running a map of your area). I really recommend you upgrading to 10.2 if you can as they changed stuff for profiles. (meaning that config below may NOT work on your 9.1?)

Using GraphHopper Web, go to custom model, and use this:
{
“distance_influence”: 15,
“priority”: [
{ “if”: “hgv == NO”, “multiply_by”: “0” },
{ “if”: “road_access != PRIVATE && hgv != DELIVERY && hgv != DESTINATION”, “multiply_by”: “0.09” },
{ “if”: “max_width < 3 || max_height < 4”, “multiply_by”: “0” },
{ “if”: “max_weight < 18”, “multiply_by”: “0.01” }
]
}

(When messing around with it, it appears the limit you are seeking is max_weight < 18? Once i changed that to .01, it showed your route. If you set it to 0, you get no route available.)

Notice the route changes to what you want (i think) with the above custom model. So to get your own local copy to see this, you need to go into your graphhopper server location, under there is a directory called “profiles” (according to your config.yml). In there “could” be a car.json and truck.json. (But on some installs i notice they are not there because they are defaults, no worries). Just create a third profile, call it truck2 if you want. You will have to create a truck2.json file, and put the above in it. Then you will have to recreate the graph-cache which looks like from your config should be the directory graph-cache. You need to delete the directory (or rename it if you have space), then start the graphhopper server and it will recreate it. This can take a LONG time, so if you have a smaller map to test with that is better.

Notes:

  1. if you don’t delete or rename the cache directory, notice the server just restarts quickly, because it just uses what is there.
  2. when you add truck2.json, you need to add it to your config.yml too under profiles, AND under profiles_ch:

Hopefully that makes sense.

So
profiles_ch:
- profile: car
- profile: truck
- profile: truck2
and
profiles:
- name: car
custom_model_files: [ car.json ]
- name: truck
weighting: custom
custom_model_files: [ truck.json ]
- name: truck2
custom_model_files: [ truck2.json]

and of course the truck2.json file in /profiles directory.

Hint: i have a small map i start with. Then when i get that working, i stop the server, rename graph-cache to graph-cache.small or something like that, then let the big one run. This way, testing only takes a few minutes to create and run a whole new profile without using the whole world map which can a LOT of time to create graph-cache directory.

Hopefully that helps

Hello @floormat ,

Sorry for taking to long to answer you.

Unfortunately, I’m not able to bump my graphhopper version right now. But I tried the custom model you’ve created as example, and It worked exactly as I need.

For now, I will proceed with the second alternative. I’ll create another profile, the first considering “delivery vans”, and the other for “Big Truck”.

This may be enough, I believe.

Thank you very much for your help and your time!!!