Setting curvature in v5

Hi!

I recently switched to version 5 of GH. Before I worked with version 3.

Previously, in the custom model, I could adjust the curvature per request by calling motorcycle.curvature.

Can someone explain to me how I can adjust the curvature per request in version 5? Unfortunately I couldn’t find it in the documentation :frowning_face:.

thanks in advance,
kitcat

I don’t know what you are referring to. In GH 3 I cannot find anything called motorcycle.curvature. What exactly are you trying to do?

Hi, see /route-custom heading not working - #4 by karussell

as karussell pointed out this has now been changed to motorcycle$curvature, only I see minimal to no difference in my route when i use motorcycle$curvature.

Can you not paste some code / config or something? It is very hard to guess what you are trying to do. And yes in GH 5 the motorcycle curvature encoded value is called motorcycle$curvature

oh I’m sorry, you’re right. I’m still in the Monday mood :sweat_smile:.

Here is my config:

graphhopper:
  datareader.file: netherlands-latest.osm.pbf # OSM input file
  graph.location: graph-gh
  profiles:
    - name: motorcycle
      vehicle: motorcycle
      weighting: custom
      custom_model_file: empty
    - name: bike
      vehicle: bike
      weighting: custom
      custom_model_file: empty
    - name: foot
      vehicle: foot
      weighting: custom
      custom_model_file: empty
  profiles_lm:
    - profile: motorcycle
    - profile: bike
    - profile: foot
  prepare.lm.threads: 1
  graph.flag_encoders: foot,bike,motorcycle|turn_costs=true
  graph.encoded_values: toll, surface
  graph.elevation.provider: srtm
  routing.max_visited_nodes: 11000000
# PRODUCTION
  graph.elevation.cache_dir: /data/srtm/
  graph.dataaccess: RAM_STORE

server:
  application_connectors:
    - type: http
      port: 8989
      # DEVELOPMENT
#      bind_host: localhost
  admin_connectors:
    - type: http
      port: 8990
      # DEVELOPMENT
#      bind_host: localhost

# PRODUCTION
logging:
  appenders:
    - type: file
      time_zone: UTC+1
      current_log_filename: /data/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: /data/logs/graphhopper-%d.log.gz
      archived_file_count: 7
      never_block: true
    - type: console
      time_zone: UTC+1
      log_format: "%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"

POST Request with curvature:

{
    "custom_model": {
        "priority": [
            {
                "if": "motorcycle$curvature > 0.5",
                "multiply_by": 0.9
            },
            {
                "if": "road_class == MOTORWAY",
                "multiply_by": 0.1
            }
        ]
    },
    "profile": "motorcycle",
    "points": [
        [
            "7.185059",
            "52.676382"
        ],
        [
            "7.467957",
            "52.108192"
        ]
    ],
    "ch_disable": true,
    "points_encoded": false,
    "elevation": true
}

response:

{
    "hints": {
        "visited_nodes.sum": 74426,
        "visited_nodes.average": 74426.0
    },
    "info": {
        "copyrights": [
            "GraphHopper",
            "OpenStreetMap contributors"
        ],
        "took": 84
    },
    "paths": [
        {
            "distance": 83046.158,
            "weight": 10634.967878,
            "time": 4339564,
            "transfers": 0,
            "points_encoded": false,
            "bbox": [
                7.083785,
                52.107704,
                7.467016,
                52.676411
            ],
            "points": { ...

Request without curvature:

{
    "custom_model": {
        "priority": [
            {
                "if": "road_class == MOTORWAY",
                "multiply_by": 0.1
            }
        ]
    },
    "profile": "motorcycle",
    "points": [
        [
            "7.185059",
            "52.676382"
        ],
        [
            "7.467957",
            "52.108192"
        ]
    ],
    "ch_disable": true,
    "points_encoded": false,
    "elevation": true
}

response:

{
    "hints": {
        "visited_nodes.sum": 71048,
        "visited_nodes.average": 71048.0
    },
    "info": {
        "copyrights": [
            "GraphHopper",
            "OpenStreetMap contributors"
        ],
        "took": 82
    },
    "paths": [
        {
            "distance": 83046.158,
            "weight": 10152.794193,
            "time": 4339564,
            "transfers": 0,
            "points_encoded": false,
            "bbox": [
                7.083785,
                52.107704,
                7.467016,
                52.676411
            ],
            "points": { ....

As you can see the weight and the visited nodes change, but the distance and duration remain the same. Visually I hardly see anything change.

Do you have any idea what I’m doing wrong and how I can improve it?

This looks right. Maybe just try something like multiply_by: 0.01 or change the threshold for the curvature to make sure everything works as expected?

1 Like

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