Hi,
So far I’ve successfuly implemented spatial rules for ~10 countries. Here are the changes I had to do:
- Create a new
<country-name>SpatialRule.java
file with a class extendingDefaultSpatialRule
(as with the german file example:core/src/main/java/com/graphhopper/routing/util/spatialrules/countries/<country-name>SpatialRule.java
- Override
getMaxSpeed
method to set the correct speeds. - Override
getId
to return the 3 letter id of the country or whatever id you are using in your geojson file. - Add a case to the switch in
graphhopper/core/src/main/java/com/graphhopper/routing/util/spatialrules/CountriesSpatialRuleFactory.java
with the country id. - Specify the spatial rule file with the
spatial_rules.location
field inconfig.yml
Now this will work for some profiles only, see Custom spatial rule with custom vehicule profile.
I wanted to get this to work with other profiles so I ended up creating my own custom profile that kind of merges the DataFlagEncoder
with the CarFlagEncoder
. This required patches to many files along the way, if you want more details let me know.
Hope this helps