-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix country rule ordering #1911
Conversation
if (!spatialRuleBordersDirLocation.isEmpty()) { | ||
final BBox maxBounds = BBox.parseBBoxString(configuration.get("spatial_rules.max_bbox", "-180, 180, -90, 90")); | ||
final BBox maxBounds = BBox.parseBBoxString(configuration.get("countries.max_bbox", "-180, 180, -90, 90")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better singular country
?
Looks like a good workaround until we finish #1808
I'd like to stick with the more generic term as this directory might contain arbitrary borders in the very near future. |
Sorry, I meant we could just reorder Country, but I did not do this workaround.
Ok. Still for a more generic usage we would have to implement a more generic approach. Currently I do not see how we can provider arbitrary rules in Java, i.e. I would stick to the "country directory" and people with custom rules can have their custom directories? |
My plan would be to ship our current rules as files. The user may provide further border and rule definitions. e.g: |
But how would the user provide Java code to implement these custom SpatialRules? Ah, you mean they specify with some properties what should be done with the borders similar to what we currently do with the ChangeGraphResource file format ("overlay.json")? |
Yes. Not sure about the format but i'm leaning towards a similar solution like you're using for the custom weighting support. |
Ah, IMO with CustomWeighting this would work the opposite: we define the custom or country borders as separate GeoJSON (or externally) and then use them to avoid the area or cap max_speed: priority:
# avoid a certain area
area_custom1: 0.5
areas:
custom1:
type: "Feature"
geometry: { type: "Polygon", coordinates: [[[13.722, 51.053], [... |
That would be the same for the external rules concept.
External rules would either provide fallback values if the OSM material lacks sufficient tagging or could be used to overwrite existing values. IMHO the custom weighting and the spatial rules are quite similar in that they allow to influence routing decisions for a given area. The main difference is that the user can define a lot of SpatialRules with detailed geometries without sacrificing runtime performance e.g for countries, states or environmental protection zones |
@otbutz do you think if I revert the renaming of spatial_rules.borders_directory to country.borders_directory we merge this here? |
I'm just against the name change. The other changes look good 👍 |
fixes #1875
As we currently already sort the strings https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/util/spatialrules/SpatialRuleLookupBuilder.java#L86
the only required change for #1875 would be to reorder the Country enum (AUT should come before DEU).
But as this is too error-prone I decided for a better & special handling when using the Country enum in combination with the SpatialRuleFactory. This is currently done in SpatialRuleLookupHelper.buildAndInjectSpatialRuleIntoGH. I have renamed this to a more Country-specific name as it is nothing generic.
Also. To avoid mixing this in the future I have removed the SpatialRuleParser constructor the with enum-Country default.spatial_rules.borders_directory
is renamed tocountry.borders_directory
to make usage more clear