Hi there,
I’m relatively new to GH, but find it very powerful tool.
My question is about using specific road names in custom model JSONs. I tried “road_name” key which turned out to be invalid. Please find an example below.
{
"priority": [
{
"if": "!car_access",
"multiply_by": "0"
},
{
"if": "road_access == PRIVATE",
"multiply_by": "0.1"
}
],
"speed": [
{
"if": "road_class == MOTORWAY && road_name == Anadolu Otoyolu",
"limit_to": 70
},
{
"else_if": "road_class == TRUNK",
"limit_to": 50
},
{
"else_if": "road_class == PRIMARY",
"limit_to": 30
},
{
"else_if": "road_class == SECONDARY",
"limit_to": 25
},
{
"else_if": "road_class == TERTIARY",
"limit_to": 20
},
{
"else_if": "road_class == RESIDENTIAL",
"limit_to": 15
},
{
"else": "",
"limit_to": 60
}
]
}

simse
January 29, 2025, 10:39am
2
what is your goal? why would you need the road names?
the available encoded values / road attributes show up if you press STRG + SPACE
more info here:
# Custom Models
GraphHopper provides an easy-to-use way to customize its route calculations: Custom models allow you to modify the
default routing behavior by specifying a set of rules in JSON language. Here we will first explain some theoretical
background and then show how to use custom models in practice.
Try some live examples in [this blog post](https://www.graphhopper.com/blog/2020/05/31/examples-for-customizable-routing/)
and the [custom_models](../../core/src/main/resources/com/graphhopper/custom_models) folder on how to use them on the server-side.
## How GraphHopper's route calculations work
One of GraphHopper's most important functionality is the calculation of the 'optimal' route between two locations. To do
this, GraphHopper subdivides the entire road network into so called 'edges'. Every edge represents a certain road
segment between two junctions. Therefore finding the optimal route between two locations means finding the optimal
sequence of edges that connect the two locations. GraphHopper stores certain attributes (so called 'encoded values') for
every edge and applies a formula (the so called 'weighting') to calculate a numeric 'weight' for every edge. The total
weight of a route is the sum of all the edge's weights. The optimal route is the one where the total weight is the
smallest.
For example you can imagine the edge weight to be the time you need to travel from one junction to another. Finding the
This file has been truncated. show original
1 Like
easbar
January 29, 2025, 3:57pm
3
This is a valid use case: changing the speed of bigger motorway by name. Unfortunately currently there is no support for selecting roads by name in a custom model. A possible workaround might be drawing an area around the motorway and using the ‘areas’ feature of the custom model.
Suppose I have historical GPS data collected from vehicle tracking system for a set of vehicles. Naturally, vehicles tend to use same roads within the city. To integrate actual traffic data, I need to be able assign average speeds to specific road segments, depending on the time of the day and the day of week, etc.
system
Closed
April 29, 2025, 7:50pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.