Allow private access for travel only if it is the origin or destination

Does anyone know how or where to write in: private = avoid , if public path exists?

We are wanting to access private spaces, such as private roads and gated communities. However, we don’t want to travel through these private spaces if it is the fasted route, only if the private space is the origin or destination.

I assume just allowing private access (private access Yes) could allow the fastest routes to be calculated through private areas, even if the private area is not the origin or destination.

Maybe just the Avoid statement does this?

I assume you make some changes and it is baked in when compiling graphhopper.

Any help here would be greatly appreciated!

Hiya, could you do something like set private access priority really low? So that it only uses it as a last resort?

Thanks Gregws!

Do you know what command this would be or line ? … I can grep the lines if I know the search terms.

This software is frankly brand new to me and I am not a domain expert, just trying to set it up for students, running off a cloud server, so they can call the origin and destination.

Thanks

I’m not sure I fully understood your question, but if you want to allow routing through private areas (ways tagged as access/vehicle/etc=private), but only in case they are the origin or destination, you probably want to treat these ways the same as ways that are tagged as access/vehicle/etc=destination.

@easbar

Yes, I would only like to enter private areas if it is the origin or destination.

I am trying to set it up for students, running off a cloud server, so they can call the origin and destination. Therefore, I think these changes would be in the graphhopper GitHub code, but let me know if I am wrong.

Do you know where you make this setting in the graphhopper GitHub code, so when I build it, it builds automatically with these settings?

Im only on my phone, but something like this in code.

customModel model = new CustomModel();
model.addToPriority(If(“road_access == PRIVATE”, MULTIPLY, 1.0));

graphHopper.setProfiles(Arrays.asList(
new CustomProfile(“van”).setCustomModel(new CustomModel(model)).setVehicle(“car”).setTurnCosts(true).putHint(“u_turn_costs”, 3),
new CustomProfile(“newWalk”).setCustomModel(new CustomModel(model)).setVehicle(“foot”)
));

Depending on your implementation, you may want to configure this in your config file instead.

Essentially, my thought is that the pathing will use higher priority roads over the private access only if necessary.
This doesnt specifically set that private roads are never used in the middle of the path, but hopefully it will minimize the use of them.
Easy to implement, but might not have your exact requirement.

It should be possible without modifying the code even. Assuming we are talking about car routing the following configuration should work (modify your config.yml file accordingly and make sure you do a fresh import (delete the -gh folder before you restart the server)).

graph.vehicles: car|block_private=false # this opens up roads tagged as 'private' which would be closed otherwise
profiles:
  - name: car
    vehicle: car
    weighting: custom
    turn_costs: true
    u_turn_costs: 400
    custom_model: {
        "distance_influence": 70,
        "priority": [
          { "if": "road_access == PRIVATE || road_access == DESTINATION", "multiply_by": 10 }
        ]
    }

The last bit adds a penalty for roads tagged as private and destination. This way they are reachable, but are generally avoided by the router. How much they are avoided can be controlled by the multiply_by factor. The roads are still used if no other option exists, i.e. when the origin or destination is located along such a road.

Than you @easbar and @Gregws !!! I will try these options.

This is kinda the generic approach I was visualizing in my head; however, I was not sure how to implement it in graphhopper.

Thanks again!

Hello! @easbar I have tried this solution. However, it still does not select the private areas as viable locations (origin or destination). Is there another setting somewhere that I need to set, which allows the private areas to be accessed at all?

Note: I deleted the container it was built with, and built an entirely new container, ensuring there was not a remnant from the last build creating an error.

Any additional thoughts here?

You mean you set block_private=false, but private roads are still not accessible? Can you share your configuration file, GH version and map data you used? Otherwise it is hard to guess what is going wrong. Normally private roads should be accessible with this setting.

config_yml.txt (10.5 KB)

I have attached the config.yml I tried (Note: I had to change to .txt to attach in this thread).

Also, we would like to add the car, bike, and foot with the same conditions.

Any help or thoughts are greatly appreciated.

Thanks!

We are using “graphhopper V 6.0”.
cd graphhopper
git fetch --all --tags
git checkout 6.0

this map “http://download.geofabrik.de/north-america/us-latest.osm.pbf

You might have to use graph.flag_encoders: car|block_private=false instead of graph.vehicles: car|block_private=false. This configuration changed somewhere around version 6, I think.

Thanks, I will try this.

If I want to do all car, bike, and foot,… it is like this?

graph.flag_encoders: car|block_private=false, bike|block_private=false, foot|block_private=false
profiles:
- name: car
vehicle: car
weighting: custom
custom_model: {
“distance_influence”: 70,
“priority”: [
{ “if”: “road_access == PRIVATE || road_access == DESTINATION”, “multiply_by”: 1000 }
]
}

- name: bike
  vehicle: bike
  weighting: custom
  custom_model: {
    "distance_influence": 70,
    "priority": [ 
      { "if": "road_access == PRIVATE || road_access == DESTINATION", "multiply_by": 1000 }
    ]
  }

- name: foot
  vehicle: foot
  weighting: custom
  custom_model: {
    "distance_influence": 70,
    "priority": [ 
      { "if": "road_access == PRIVATE || road_access == DESTINATION", "multiply_by": 1000 }
    ]
  }

Yes, graph.flag_encoders: car|block_private=false, bike|block_private=false, foot|block_private=false should open private roads for profiles using car, bike or foot as vehicle (for the GH version you are using, for later versions you need to do the same with graph.vehicles instead).

Cool! Thanks! I am rebuilding it now

Thanks for the input! I am making progress and almost have it.

I tested some points. It seems that it allows private roads, but it now routes through private roads, it the destination is between them, and we would like it to avoid private roads unless it is the destination.

How would I accomplish this also? Maybe remove the “|| road_access == DESTINATION” part?

Original (as stated above):

  • name: foot
    vehicle: foot
    weighting: custom
    custom_model: {
    “distance_influence”: 70,
    “priority”: [
    { “if”: “road_access == PRIVATE || road_access == DESTINATION”, “multiply_by”: 1000 }
    ]
    }

new (potential solution?):

  • name: foot
    vehicle: foot
    weighting: custom
    custom_model: {
    “distance_influence”: 70,
    “priority”: [
    { “if”: "road_access == PRIVATE , “multiply_by”: 1000 }
    ]
    }

Try a factor smaller than 1 like 0.1 (instead of 1000)

@karussell @Gregws @easbar Thanks! This seems to work. If I want to add military access with a penalty just as the private assess, how would I do this to the below? Meaning I want a penalty for private and military access.

graph.vehicles: car|block_private=false # this opens up roads tagged as 'private' which would be closed otherwise
profiles:
  - name: car
    vehicle: car
    weighting: custom
    custom_model: {
        "distance_influence": 70,
        "priority": [
          { "if": "road_access == PRIVATE || road_access == DESTINATION", "multiply_by": 0.001 }
        ]
    }

Do you have an example for such military access?

@easbar @bcrawfordGT We are using the following link to query the travel time between two points. The result we got from Graphhopper shows that “Connection between locations not found”. We noticed that the first point may located inside a military region.

query link:

http://server_ip_address/route?point=32.024098,-81.119763&point=32.052898,-81.095808&vehicle=car

the associated way with military attribute:

Way: ‪Gannam Avenue‬ (‪9083896‬) | OpenStreetMap