I have created a new EncodedValue called routing_priority. When I print out the routing_priority for my data, the correct values are displayed and everything seems to be working.
However, when I play around with the custom model values and the priority values for each routing_priority, the routes stay the same. Please see the screenshots below of my Config.yml, custom model .json file and a screenshot of the GraphHopper web interface.
I’m not quite sure, but it’s because when you define custom model json file and run the graphhopper with that file, then web interface tweaking became obsolete, that ain’t gonna work. I’ve experienced that sometimes ago. I’m not sure if that is a feature or bug.
In GraphHopper version 4 I am able to define a custom model .json file with certain encoded_values (for example, track_type) and then subsequently tweak that encoded_value in the web interface. See the example below.
This is the route when I define the following priority values for track_type in the config.yml (on the right):
I am only guessing, but this could be related to: https://github.com/graphhopper/graphhopper/issues/2438. Do you start GH using the server command or do you use the Java API. And if you use the Java API how do you register your new encoded value?
Note that you can enable ‘local mvt’ in the layers menu of the web UI to inspect the encoded values for the single edges. You can also add your EV to the PathDetailsBuilderFactory so you can see your encoded value as path detail for debugging.
Thanks for the information @easbar . I am not sure which one of these suggestion I should try. Which one would you recommend? I have added my routing_priority encoded_value to the DefaultTagParserFactory.java and PathDetailsBuilderFactory.java
I start GH using the server command.
For some reason ‘local mvt’ is greyed out by me and I can’t select it.
Ok that should work since you are using the server command. So it probably must be something else that goes wrong. To use ‘Local MVT’ you a) need to zoom in far enough and b) set web.mvt.enabled: true in your config.
Thanks for the suggestion for ‘local mvt’. It is working when I zoom in. What is interesting that it is showing only these four encoded_values, even though I have a lot more specified in my config.yml. It is also showing max_speed = infinity. Why would this be the case?
private final IntEncodedValue routing_priorityEnc;
public OSMRoutingPriorityParser() {
this.routing_priorityEnc = RoutingPriority.create();
}
@Override
public void createEncodedValues(EncodedValueLookup lookup, List registerNewEncodedValue) {
registerNewEncodedValue.add(routing_priorityEnc);
}
@Override
public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay way, boolean ferry, IntsRef relationFlags) {
int routing_priorityCount = 5;
if (way.hasTag(“routing_priority”)) {
String noRoutingPriority = way.getTag(“routing_priority”);
Maybe @rilusmahmud is right. Did you try with an empty custom model server-side (data folder deletion & reimport required) or with an “extreme” value in the custom model (in the UI) e.g. exclude certain edges with routing_priority==0?
It seems that routing_priority is being considered in the route. I suspect that something is not correct in the code above. I will play around with the code and see if something comes right.
Okay, I can see the differences, but maybe there’s a silly quark or feature that got right there in the web interface. In the web interface, you have to maintain the same pattern as the custom model JSON file, and then it works. Otherwise, it remains the same as per the custom mode defined earlier. Then again, as @karussell mentioned earlier, the question remained for data folder deletion & reimport required.
I have these encoded_values specified in my config.yml: graph.encoded_values: max_speed,routing_priority,road_class,road_class_link,road_environment,road_access,surface,smoothness,track_type.
Why would the Local MVT only display name, road_environment, max_speed and road_class for my edges?
I do not want to hardcode all routing_priorityEnc values to 5. Each road segment has each own value ranging from 0 to 4. I want to display and use these routing_priorityEnc values for each road segment. From the screenshot below, it seems I have indeed hardcoded routing_priorityEnc to 5 for all roads .
Should I remove “int routing_priorityCount = 5”? My java knowledge is very beginner