GraphHopper.com | Forum | GitHub | Maps | Blog

Restricted routing zones specified by a polygon


#1

How can I find a route that considers certain restricted areas (such as private territories or environmental no-drive zones) that is specified by a polygon? I want to be able to enable/disable the restriction at query time. I found “spatial rules” in the config file, but I am not sure if it’s the right solution.


#2

Yes, that might be the right solution if you know how to customize the Java code. Currently only the opposite via block_area is possible out of the box.


#3

Is there any documentation or code example how to start?


Respecting limited_traffic_zone boundaries
#4

See the web API docs


#5

There is not much about spatial rules in the docs, but I think I got a good understanding about them by reading the source code. Is there any way to enable/disable them at query time? The docs say that you need to re-import your graph after enabling spatial rules. Does it mean that it cannot be selectively switched on at query time?


#6

Spatial rules is pretty new and currently only really useful or customizable if you code in Java. E.g. have a look into the DataFlagEncoder that stores an ID per country. The same could be done for your restricted areas. Then in a custom Weighting you can easily enable or disable or change costs for an edge with such an information attached, i.e. you should be able to change this per request (if you disable CH).


Respecting limited_traffic_zone boundaries
#7

How about block_area? What do you think about implementing a polygon Shape and allowing parseBlockArea to parse polygons? parseBlockArea could also accept the id of the polygon only since the boundaries are already encoded in OSM files.


#8

Yes, sure, this is also possible and any contribution is welcome :slight_smile: !


#9

Do you have any idea the boundaries inside the OSM file are kept in storage or not? I want to be able to find the boundary by its id. I don’t think passing the whole polygon with any query is a good idea.
I seems to me that they are not kept. If that’s right, what is a good way to store the boundaries?


#10

Probably via relations but I have on idea how they are tagged. You can search the OSM wiki or use http://taginfo.openstreetmap.org/


#11

See the PR #1306