Skip to content

Can't recreate car4wd in version 6 which will ignore fords and pass through grade 5 highways #2703

Closed

Description

@HarelM

Describe the bug
Car4wd was remove, I saw the example of how to recreate it in latest version, but I can't find a way make the block_fords to be "disabled", I'm not sure if this is a bug or misconfiguration, but I can't find a way to make it work no matter what I try...

To Reproduce

In version 6.x use the following configuration file:
https://github.com/IsraelHikingMap/Site/blob/87fdd540301dda8fb869edbcd0a4ebe49ae46c52/gh-config.yml
TL;DR:

 profiles:
    - name: car4wd
      vehicle: roads
      weighting: custom
      custom_model:
        distance_influence: 1
        speed:
          - if: "track_type == GRADE4 || track_type == GRADE5"
            limit_to: 5
          - else: ""
            limit_to: "car_average_speed"
        priority:
          - if: "track_type != GRADE4 && track_type != GRADE5 && car_access == false"
            multiply_by: "0"
          - if: "road_class == TRACK"
            multiply_by: "20"
...
  graph.flag_encoders: car|block_fords=false|block_barriers=false,hike|block_fords=false,mtb|block_fords=false|block_barriers=false
  graph.encoded_values: road_class,road_class_link,road_environment,max_speed,road_access,track_type,surface

I can't make car4wd pass through fords, I tried to add roads|block_fords=false to the graph.flag_encoders and it didn't help.
For example here (this doesn't reproduce in your site since it's not the same profile but you can test this location):
https://graphhopper.com/maps/?point=30.365441%2C35.147625&point=30.366071%2C35.146402&profile=car&layer=Omniscale

Steps to reproduce the behavior. For examples:

  1. Use version 6.2 from the docker image
  2. Use latest israel and palestine pbf
  3. include the config.yml you are using - see the link above
  4. run java -Ddw.graphhopper.datareader.file=your.osm.pbf -jar *.jar server config-example.yml

Expected behavior
block_fords should be respected
System Information
block_fords is not respected

Provide version of Operating system, JVM and GraphHopper
Whatever is in the following docker image: openjdk:11.0-jre - linux, JRE 11 basically.

Screenshots & Logs

This is from my site:
image

Let me know if you need more info, I'll be happy to provide....

Activity

  1. changed the title [-]Can't recreate car4wd in version 6[/-] [+]Can't recreate car4wd in version 6 which will ignore fords and pass through grade 5 highways[/+] on Nov 30, 2022
  2. easbar commented on Nov 30, 2022

    @easbar
    Member

    Yes, the roads 'vehicle' currently ignores all barriers and doesn't consider the block_fords option.

  3. HarelM commented on Nov 30, 2022

    @HarelM
    ContributorAuthor

    Thanks for the fast reply!
    Bummer, is there a way for me to work around this? Some configuration to use in order to allow a car vehicle to pass through grade4/5? Or roads vehicle to pass through fords?

  4. karussell commented on Dec 1, 2022

    @karussell
    Member

    You wrote in version 6, but do you mean in master? Because in 6 we still had car4wd as vehicle. (Unfortunately in 6.x something seems to be indeed wrong there with the specific roads vehicle configuration you used.)

    Now, I just tried the example above in master and it passes the ford you mentioned.

    It should also pass grade4/5 as you explicitly use car_access only when it is not grade4/5.

  5. HarelM commented on Dec 1, 2022

    @HarelM
    ContributorAuthor

    I'm using the 6.2 tag. I now see this wasn't officially released, but only tagged here in GitHub.
    Are you suggesting reverting to version 6? I thought I could use the latest tagged release to reduce upgrade effort later on when upgrading to the next version as we are not upgrading every time a new version is released, unfortunately...

  6. karussell commented on Dec 1, 2022

    @karussell
    Member

    6.2 tag is fine. I think we included the removal of car4wd into the wrong release - fixed this. Will investigate why this does not work with 6.2.

  7. added a commit that references this issue on Dec 1, 2022
  8. karussell commented on Dec 1, 2022

    @karussell
    Member

    The missing & tiny bug fix is this one: 881058e. But we currently fix old releases only if the bug is critical.

    So you either have to continue using 5.0 or switch to the preliminary release 7.0-pre1 to use this feature. Sorry for the hassle.

  9. easbar commented on Dec 1, 2022

    @easbar
    Member

    block_fords=true still does not work, though. The roads vehicle simply ignores all barriers currently.

  10. karussell commented on Dec 1, 2022

    @karussell
    Member

    Yes, but this is intended. roads should access everything including fords.

    And car supports this config, and so car_access can be used in the custom model for roads to achieve the same.

    It would be nice if we could exclude fords also via the custom model ala road_environment == FORD but currently the barrier tags are not copied into the edge I think and so it only works for way ford tags.

  11. easbar commented on Dec 1, 2022

    @easbar
    Member

    And car supports this config, and so car_access can be used in the custom model for roads to achieve the same.

    Yes, but how? I mean if you add something like priority: if: car_access == false, multiply_by: false you get car access everywhere, not just for the barrier edges. Or how could it be useful to combine vehicle: roads with a custom model that uses car_access?

    It would be nice if we could exclude fords also via the custom model ala road_environment == FORD but currently the barrier tags are not copied into the edge I think and so it only works for way ford tags.

    Yes, but that would be almost trivial, because it is easy to recognize barrier edges during the import. Actually a single bit would be enough to mark barrier edges as, well, barrier edges. Then we could do something like:

    if: barrier == true && car_access == false

    ?

    Or, of course just something like barrier == FORD if we used a few more bits to store the type of barrier.

  12. karussell commented on Dec 1, 2022

    @karussell
    Member

    I mean if you add something like priority: if: car_access == false, multiply_by: false you get car access everywhere, not just for the barrier edges

    You would have to exclude edges like done for grade4/5 in the above custom model.

    Yes, but that would be almost trivial, because it is easy to recognize barrier edges during the import.

    This would be really cool. One cool thing would be if the access tags properly change car/bike/foot_access.

    Could we then support also other node tags like crossing/zebras or railway=(level_)crossing?

    Or, of course just something like barrier == FORD if we used a few more bits to store the type of barrier.

    For now I would change only road_environment in this case and try if a boolean barrier is sufficient

  13. easbar commented on Dec 1, 2022

    @easbar
    Member

    You would have to exclude edges like done for grade4/5 in the above custom model.

    You mean to replicate the old car4wd we should now use a custom model with vehicle: car? And use grade4/5 in the custom model? But we cannot really open these roads when they are already closed by the car vehicle?

    One cool thing would be if the access tags properly change car/bike/foot_access.

    Can you explain this further?

    Could we then support also other node tags like crossing/zebras or railway=(level_)crossing?

    Yes, all node tags are available to all tag parsers via way.getTag("node_tags", null).

    For now I would change only road_environment in this case and try if a boolean barrier is sufficient

    Ok, sure.

  14. karussell commented on Dec 1, 2022

    @karussell
    Member

    You mean to replicate the old car4wd we should now use a custom model with vehicle: car? And use grade4/5 in the custom model? But we cannot really open these roads when they are already closed by the car vehicle?

    You can only do this via the roads vehicle. And then a custom_model like above or like this.

    One cool thing would be if the access tags properly change car/bike/foot_access.

    Can you explain this further?

    Barriers have access tags. And when we have all node_tags TagParser then e.g. the car_access EV can be filled accordingly. And so in the custom_model it does not really matter for these access EVs if it is a way or a barrier.

    update: oh, I guess we already do this

  15. easbar commented on Dec 1, 2022

    @easbar
    Member

    update: oh, I guess we already do this

    Yes, we already do this. A barrier edge is just like a normal edge and we can use all the node tags of the barrier node to determine the encoded values for this edge.

    Yes, all node tags are available to all tag parsers via way.getTag("node_tags", null).

    Sorry, this is wrong. It is only true barrier edges. So far we ignore all other node tags, but that can be changed rather easily.

  16. HarelM commented on Mar 2, 2023

    @HarelM
    ContributorAuthor

    Is solving this planned for version 7?
    We are currently in version 5 since we couldn't find a solution to the removal of car4wd (with block_fords=false in version 6).
    I've seen other removal of profiles, which is great, since we'll be able to configure everything in the configuration file, but I just want to make sure this issue is not forgotten.

  17. added this to the 7.0 milestone on Mar 2, 2023
  18. karussell commented on Mar 2, 2023

    @karussell
    Member

    I think this is fixed in master: #2703 (comment) and you should be able to use car4wd as before.

    Or do you mean the related node tags issue? For that see #2705 (it would be nice to have it in v7 but it is more likely v8)

  19. HarelM commented on Mar 2, 2023

    @HarelM
    ContributorAuthor

    No, just the ability to receive the current behavior of the hike, bike, and 4wd profiles we have right now in the latest version.
    I'll download and run the latest version and see if I get the expected results after setting up everything.
    It might take a while to get everything right as there are probably some additional configuration that have changed, but once I get it to work I'll report it here.
    If you prefer that I discuss this somewhere else, please let me know, sorry for spamming this thread.

  20. HarelM commented on Mar 2, 2023

    @HarelM
    ContributorAuthor

    I took the latest version for a spin (i.e. from last night that is), here are my observations, let me know if other issues are in place or you guys can take care of filing those:

    1. in the config-example.yml there's a reference to bike2.json, I couldn't find it in the repo:
      # custom_model_file: bike2.json
    2. car4wd as configured in the custom_model file passes through fords (yay!)
    3. When I don't add to the config import.osm.ignored_highways import fails. While I get the requirement for adding this to make sure you keep the size of the graph in check, upgrading and failing on this can be annoying, I would consider writing a warning, but treating this as an empty list in case this variable is not provided. IDK if this makes sense, this is just a thought...
    4. foot profile is passing through closed gates where it shouldn't pass:
      See the following red gate:

    image

    This is where it is in the graphhopper site:
    https://graphhopper.com/maps/?point=32.603965%2C35.062892&point=32.60422%2C35.06418&profile=foot&layer=Omniscale

    The following is the relevant node in OSM which has access private:
    https://www.openstreetmap.org/node/4430713688

    The following is my config file:

    Details
    graphhopper:
    
      # OpenStreetMap input file PBF or XML, can be changed via command line -Ddw.graphhopper.datareader.file=some.pbf
      datareader.file: ""
      # Local folder used by graphhopper to store its data
      graph.location: graph-cache
    
    
      ##### Routing Profiles ####
    
      # Routing can be done only for profiles listed below. For more information about profiles and custom profiles have a
      # look into the documentation at docs/core/profiles.md or the examples under web/src/test/java/com/graphhopper/application/resources/
      # or the CustomWeighting class for the raw details.
      #
      # In general a profile consists of the following
      # - name (required): a unique string identifier for the profile
      # - vehicle (required): refers to the `graph.vehicles` used for this profile
      # - weighting (required): the weighting used for this profile like custom,fastest,shortest or short_fastest
      # - turn_costs (true/false, default: false): whether or not turn restrictions should be applied for this profile.
      #
      # Depending on the above fields there are other properties that can be used, e.g.
      # - distance_factor: 0.1 (can be used to fine tune the time/distance trade-off of short_fastest weighting)
      # - u_turn_costs: 60 (time-penalty for doing a u-turn in seconds (only possible when `turn_costs: true`)).
      #   Note that since the u-turn costs are given in seconds the weighting you use should also calculate the weight
      #   in seconds, so for example it does not work with shortest weighting.
      # - custom_model_file: when you specified "weighting: custom" you need to set a json file inside your custom_model_folder
      #   or working directory that defines the custom_model. If you want an empty model you can also set "custom_model_file: empty".
      #   You can also use th e`custom_model` field instead and specify your custom model in the profile directly.
      #
      # To prevent long running routing queries you should usually enable either speed or hybrid mode for all the given
      # profiles (see below). Or at least limit the number of `routing.max_visited_nodes`.
      profiles:
        - name: car4wd
          vehicle: roads
          weighting: custom
          custom_model:
            distance_influence: 1
            speed:
              - if: "track_type == GRADE4 || track_type == GRADE5"
                limit_to: 5
              - else: ""
                limit_to: "car_average_speed"
            priority:
              - if: "track_type != GRADE4 && track_type != GRADE5 && car_access == false"
                multiply_by: "0"
        - name: hike
          vehicle: roads
          weighting: custom
          custom_model:
            priority:
              - if: "true"
                multiply_by: "foot_priority"
              - if: "!foot_access && hike_rating < 4"
                multiply_by: "0"
              - if: "foot_network == INTERNATIONAL || foot_network == NATIONAL"
                multiply_by: "1.7"
              - else_if: "foot_network == REGIONAL || foot_network == LOCAL"
                multiply_by: "1.5"
            speed:
              - if: "hike_rating < 1"
                limit_to: "foot_average_speed"
              - else_if: "hike_rating > 2"
                limit_to: "2"
              - else: ""
                limit_to: "4"
              - if: "average_slope >= 15"
                limit_to: "1.5"
              - else_if: "average_slope >=  7"
                limit_to: "2.5"
              - else_if: "average_slope >=  4"
                multiply_by: "0.85"
              - else_if: "average_slope <= -4"
                multiply_by: "1.05"
        - name: mtb
          vehicle: mtb
          weighting: short_fastest
    
      # Speed mode:
      # Its possible to speed up routing by doing a special graph preparation (Contraction Hierarchies, CH). This requires
      # more RAM/disk space for holding the prepared graph but also means less memory usage per request. Using the following
      # list you can define for which of the above routing profiles such preparation shall be performed. Note that to support
      # profiles with `turn_costs: true` a more elaborate preparation is required (longer preparation time and more memory
      # usage) and the routing will also be slower than with `turn_costs: false`.
      profiles_ch:
        - profile: car4wd
        - profile: hike
        - profile: mtb
    
      # Hybrid mode:
      # Similar to speed mode, the hybrid mode (Landmarks, LM) also speeds up routing by doing calculating auxiliary data
      # in advance. Its not as fast as speed mode, but more flexible.
      #
      # Advanced usage: It is possible to use the same preparation for multiple profiles which saves memory and preparation
      # time. To do this use e.g. `preparation_profile: my_other_profile` where `my_other_profile` is the name of another
      # profile for which an LM profile exists. Important: This only will give correct routing results if the weights
      # calculated for the profile are equal or larger (for every edge) than those calculated for the profile that was used
      # for the preparation (`my_other_profile`)
      profiles_lm: []
    
    
      #### Vehicles ####
    
      # The vehicle defines the base for how the routing of a profile behaves. It can be fine tuned using the options:
      # name=mycustomvehicle,block_private=true,turn_costs=true,transportation_mode=MOTOR_VEHICLE (only for the roads vehicle)
      # Still, it is recommended to avoid changing the vehicle settings and change the custom model instead.
      graph.vehicles: roads|block_fords=false|block_barriers=false,car|block_fords=false|block_barriers=false,foot|block_fords=false,mtb|block_fords=false|block_barriers=false
      # Other standard vehicles: foot,bike,mtb,racingbike,motorcycle,wheelchair
    
    
      #### Encoded Values ####
    
      # Add additional information to every edge. Used for path details (#1548) and custom models (docs/core/custom-models.md)
      # Default values are: road_class,road_class_link,road_environment,max_speed,road_access
      # More are: surface,smoothness,max_width,max_height,max_weight,hgv,max_axle_load,max_length,hazmat,hazmat_tunnel,hazmat_water,toll,track_type,
      #           mtb_rating, hike_rating,horse_rating,lanes
      graph.encoded_values: road_class,road_class_link,road_environment,max_speed,road_access,track_type,surface,hike_rating,average_slope,max_slope
    
      #### Speed, hybrid and flexible mode ####
    
      # To make CH preparation faster for multiple profiles you can increase the default threads if you have enough RAM.
      # Change this setting only if you know what you are doing and if the default worked for you.
      # prepare.ch.threads: 1
    
      # To tune the performance vs. memory usage for the hybrid mode use
      # prepare.lm.landmarks: 16
    
      # Make landmark preparation parallel if you have enough RAM. Change this only if you know what you are doing and if
      # the default worked for you.
      # prepare.lm.threads: 1
    
    
      #### Elevation ####
    
      # To populate your graph with elevation data use SRTM, default is noop (no elevation). Read more about it in docs/core/elevation.md
      graph.elevation.provider: srtm
    
      # default location for cache is /tmp/srtm
      graph.elevation.cache_dir: /usr/src/app/elevation/
    
      # If you have a slow disk or plenty of RAM change the default MMAP to:
      graph.elevation.dataaccess: RAM_STORE
    
      # To enable bilinear interpolation when sampling elevation at points (default uses nearest neighbor):
      # graph.elevation.interpolate: bilinear
    
      # Reduce ascend/descend per edge without changing the maximum slope:
      # graph.elevation.edge_smoothing: ramer
      # removes elevation fluctuations up to max_elevation (in meter) and replaces the elevation with a value based on the average slope
      # graph.elevation.edge_smoothing.ramer.max_elevation: 5
      # A potentially bigger reduction of ascend/descend is possible, but maximum slope will often increase (do not use when average_slope or maximum_slope shall be used in a custom_model)
      # graph.elevation.edge_smoothing: moving_average
    
      # To increase elevation profile resolution, use the following two parameters to tune the extra resolution you need
      # against the additional storage space used for edge geometries. You should enable bilinear interpolation when using
      # these features (see #1953 for details).
      # - first, set the distance (in meters) at which elevation samples should be taken on long edges
      # graph.elevation.long_edge_sampling_distance: 60
      # - second, set the elevation tolerance (in meters) to use when simplifying polylines since the default ignores
      #   elevation and will remove the extra points that long edge sampling added
      # graph.elevation.way_point_max_distance: 10
    
    
      #### Urban density (built-up areas) ####
    
      # This feature allows classifying roads into 'rural', 'residential' and 'city' areas (encoded value 'urban_density')
      # Use 1 or more threads to enable the feature
      # graph.urban_density.threads: 8
      # Use higher/lower sensitivities if too little/many roads fall into the according categories.
      # Using smaller radii will speed up the classification, but only change these values if you know what you are doing.
      # If you do not need the (rather slow) city classification set city_radius to zero.
      # graph.urban_density.residential_radius: 300
      # graph.urban_density.residential_sensitivity: 60
      # graph.urban_density.city_radius: 2000
      # graph.urban_density.city_sensitivity: 30
    
    
      #### Subnetworks ####
    
      # In many cases the road network consists of independent components without any routes going in between. In
      # the most simple case you can imagine an island without a bridge or ferry connection. The following parameter
      # allows setting a minimum size (number of edges) for such detached components. This can be used to reduce the number
      # of cases where a connection between locations might not be found.
      prepare.min_network_size: 200
    
    
      #### Routing ####
    
      # You can define the maximum visited nodes when routing. This may result in not found connections if there is no
      # connection between two points within the given visited nodes. The default is Integer.MAX_VALUE. Useful for flexibility mode
      # routing.max_visited_nodes: 1000000
    
      # Control how many active landmarks are picked per default, this can improve query performance
      # routing.lm.active_landmarks: 4
    
      # You can limit the max distance between two consecutive waypoints of flexible routing requests to be less or equal
      # the given distance in meter. Default is set to 1000km.
      routing.non_ch.max_waypoint_distance: 1000000
    
    
      #### Storage ####
    
      import.osm.ignored_highways:
    
      # configure the memory access, use RAM_STORE for well equipped servers (default and recommended)
      graph.dataaccess.default_type: RAM_STORE
    
      # will write way names in the preferred language (language code as defined in ISO 639-1 or ISO 639-2):
      # datareader.preferred_language: en
    
      # Sort the graph after import to make requests roughly ~10% faster. Note that this requires significantly more RAM on import.
      # graph.do_sort: true
    
    
      #### Custom Areas ####
    
      # GraphHopper reads GeoJSON polygon files including their properties from this directory and makes them available
      # to all tag parsers and vehicles. Country borders (see countries.geojson) are always included automatically.
      # custom_areas.directory: path/to/custom_areas
    
    
      #### Country Rules ####
    
      # GraphHopper applies country-specific routing rules during import (not enabled by default).
      # You need to redo the import for changes to take effect.
      # country_rules.enabled: true
    
    # Dropwizard server configuration
    server:
      application_connectors:
      - type: http
        port: 8989
        # for security reasons bind to localhost
        bind_host: localhost
      request_log:
          appenders: []
      admin_connectors:
      - type: http
        port: 8990
        bind_host: localhost
    # See https://www.dropwizard.io/en/latest/manual/core.html#logging
    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"
  21. karussell commented on Mar 2, 2023

    @karussell
    Member

    Thanks for trying this out in such a great detail! Will fix the problem with bike2.

    When I don't add to the config import.osm.ignored_highways import fails.

    It is annoying but IMO it can be more annoying if graphhopper consumes more memory and e.g. crashes for the new version.

    foot profile is passing through closed gates where it shouldn't pass:

    Yeah, this is an ugly bug I fixed today: 11c3dee

    Is the problem you saw fixed with the very latest master?

  22. HarelM commented on Mar 2, 2023

    @HarelM
    ContributorAuthor

    Thanks for the quick response! I've just created a new docker image with the latest main and everything seems to be working as expected according to my minimal tests with fords, and some basic access qualifiers.
    Is moving the ford to the custom_model planned for version 7?
    In any case, keep up the good work!
    Once this is officially released we will be able to migrate our site to use the new custom model which will allow us to prefer using tracks for 4wd profile, which is a nice addition :-)

  23. added a commit that references this issue on Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions