Skip to content

Commit 02046ae

Browse files
committed
Improve docs regarding encoded values and for now remove misleading documentation about FlagEncoders, graphhopper#2659
1 parent e4f67c3 commit 02046ae

File tree

5 files changed

+40
-78
lines changed

5 files changed

+40
-78
lines changed

docs/core/create-new-flagencoder.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

docs/core/custom-models.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,36 @@ encoded values are the following (some of their possible values are given in bra
7171
- surface: (PAVED, DIRT, SAND, GRAVEL, ...)
7272
- smoothness: (EXCELLENT, GOOD, INTERMEDIATE, ...)
7373
- toll: (MISSING, NO, HGV, ALL)
74+
- bike_network, foot_network: (MISSING, INTERNATIONAL, NATIONAL, REGIONAL, LOCAL, OTHER)
75+
- country: (`MISSING` or the country as a `ISO3166-1:alpha3` code e.g. `DEU`)
76+
- hazmat: (YES, NO), hazmat_tunnel: (A, B, .., E), hazmat_water: (YES, PERMISSIVE, NO)
77+
- hgv: (MISSING, YES, DESIGNATED, ...)
78+
- track_type: (MISSING, GRADE1, GRADE2, ..., GRADE5)
79+
- urban_density: (RURAL, RESIDENTIAL, CITY)
7480

75-
To learn about all available encoded values you can query the `/info` endpoint.
81+
82+
To learn about all available encoded values you can query the `/info` endpoint
7683

7784
Besides this kind of categories, which can take multiple different string values, there are also some that represent a
78-
boolean value (they are either true or false for a given edge), like:
85+
boolean value (they are either true or false for a given road segment), like:
7986

8087
- get_off_bike
8188
- road_class_link
89+
- roundabout
90+
- with postfix `_access` contains the access (as boolean) for a specific vehicle
8291

8392
There are also some that take on a numeric value, like:
8493

85-
- max_speed
86-
- max_weight
87-
- max_height
88-
- max_width
94+
- average_slope: a decimal for "elevation change" / edge_distance for a road segment; it changes the sign in reverse direction; see also max_slope
95+
- curvature: "beeline distance" / edge_distance (0..1) e.g. a curvy road is smaller than 1
96+
- hike_rating, horse_rating, mtb_rating: a number from 0 to 6 for the `sac_scale` in OSM, e.g. 0 means "missing", 1 means "hiking", 2 means "mountain_hiking" and so on
97+
- lanes: number of lanes
98+
- max_slope: an unsigned decimal for the maximum slope ("elevation change / distance_i") of an edge with `sum(distance_i)=edge_distance`. Important for longer road segments where ups (or downs) can be much bigger than the average_slope.
99+
- max_speed: the speed limit from a sign (km/h)
100+
- max_height (meter), max_width (meter), max_length (meter)
101+
- max_weight (ton), max_axle_load (in tons)
102+
- with postfix `_average_speed` contains the average speed (km/h) for a specific vehicle
103+
- with postfix `_priority` contains the road preference without changing the speed for a specific vehicle (0..1)
89104

90105
In the next section will see how we can use these encoded values to customize GraphHopper's route calculations.
91106

docs/core/elevation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ The default cache directory `/tmp/<provider name>` will be used. For large areas
1111
use a SSD disc, thus you need to specify the cache directory:
1212
`graph.elevation.cache_dir: /myssd/ele_cache/`
1313

14-
## What to download and where to store it?
14+
## Custom Models
15+
16+
The `average_slope` and `max_slope` attributes of a road segment can be used to make your routing
17+
elevation-aware, i.e. to prefer or avoid, to speed up or slow down your vehicle based on the elevation
18+
change. See the [custom model](custom-models.md) feature.
19+
20+
## What to download and where to store it?
1521

1622
All should work automatically but you can tune certain settings like the location where the files are
1723
downloaded and e.g. if the servers are not reachable, then you set:

docs/core/weighting.md

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
## Weighting
22

3-
A weighting allows to create a "weight" for an edge. The weight of an edge reflects the cost of travelling along this edge.
3+
Instead of creating a new Weighting implementation is is highly recommended to use the CustomWeighting instead, which is explained in
4+
the [profiles](profiles.md) and [custom models](custom-models.md) section.
5+
6+
A weighting allows to create a "weight" for an edge. The weight of an edge reflects the cost of travelling along this edge.
47
All implementations of [RoutingAlgorithm](https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/RoutingAlgorithm.java)
5-
in GraphHopper calculate the shortest path, which means the path with the [lowest overall cost from A to B](https://en.wikipedia.org/wiki/Shortest_path_problem).
6-
The definition of the cost function is up to you, so you can create a cost function (we call this weighting) for the fastest path.
7-
GraphHopper will still calculate the path with the lowest cost, but you can define the cost as a mix of distance speed, as shown in the [FastestWeighting](https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/weighting/FastestWeighting.java).
8+
in GraphHopper calculate the shortest path, which means the path with the [lowest overall cost from A to B](https://en.wikipedia.org/wiki/Shortest_path_problem).
9+
The definition of the cost function is up to you, so you can create a cost function (we call this weighting) for the fastest path.
10+
GraphHopper will still calculate the path with the lowest cost, but you can define the cost as a mix of distance speed, as shown in the
11+
[FastestWeighting](https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/weighting/FastestWeighting.java).
812

913
In order to create a custom weighting you need to do the following:
1014

11-
1. Implement the Weighting class
12-
2. Create a subclass of GraphHopper and override `createWeighting`
13-
14-
Or use the CustomWeighting feature explained in [profiles](profiles.md).
15+
1. Implement the Weighting class and the WeightingFactory
16+
2. Let the GraphHopper class know about your WeightingFactory via overriding createWeightingFactory
1517

1618
### Implement your own weighting
1719

@@ -23,26 +25,4 @@ a sample can be found in the [AvoidEdgesWeighting](https://github.com/graphhoppe
2325
If your weights change on a per-request base, like the [BlockAreaWeighting](https://github.com/graphhopper/graphhopper/blob/bbd62fded97be060fc09177f9fae794cea284554/core/src/main/java/com/graphhopper/routing/weighting/BlockAreaWeighting.java),
2426
you cannot use the 'speed mode', but have to use the 'hybrid mode' or 'flexible mode' (more details [here](https://github.com/graphhopper/graphhopper#technical-overview)).
2527
If you haven't disabled the 'speed mode' in your config, you have to disable it for the requests by appending `ch.disable=true`
26-
in the request url.
27-
28-
### Extend GraphHopper
29-
30-
For general information on how to extend GraphHopper have a look [here](low-level-api.md).
31-
32-
Extending GraphHopper is easy, just need to override the `createWeighting` method of the GraphHopper class.
33-
We return a new instance of our custom weighting if the string `my_custom_weighting` is given. Otherwise let the super class handle it:
34-
35-
```java
36-
class MyGraphHopper extends GraphHopper {
37-
38-
@Override
39-
public Weighting createWeighting(HintsMap hintsMap, FlagEncoder encoder, Graph graph) {
40-
String weightingStr = hintsMap.getWeighting().toLowerCase();
41-
if ("my_custom_weighting".equals(weightingStr)) {
42-
return new MyCustomWeighting(encoder);
43-
} else {
44-
return super.createWeighting(hintsMap, encoder, graph);
45-
}
46-
}
47-
}
48-
```
28+
in the request url.

docs/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ Various topics are explained in more detail separately:
4949

5050
* [Technical overview](./core/technical.md): Technical details about how GraphHopper its calculations are working.
5151
* [Custom models](./core/custom-models.md): This tutorial explains how to customize an existing vehicle profile to your needs without to know Java.
52+
* [Create custom weighting](./core/weighting.md): Documentation regarding Weighting. In almost all situations a custom model should be created instead.
5253
* [Simple routing](./core/routing.md): Tutorial how to integrate GraphHopper in your Java application (or pick any JVM language)
53-
* [Create custom weighting](./core/weighting.md): Documentation about how to create a custom weighting class to influence the track calculation.
5454
* [Import GTFS](../reader-gtfs): Simple steps to get GTFS import and routing done.
5555
* [LocationIndex](../example/src/main/java/com/graphhopper/example/LocationIndexExample.java): Code about how to get the location index for getting i.e. the nearest edge.
5656
* [Hybrid Mode](./core/landmarks.md): Details about speeding up the route calculation via A* and landmarks.
5757
* [Speed Mode](./core/ch.md): Details about speeding up the route calculations via [Contraction Hierarchies](http://en.wikipedia.org/wiki/Contraction_hierarchies).
5858
* [Low level API](./core/low-level-api.md): Instructions how to use GraphHopper as a Java library.
59-
* [Create new FlagEncoder](./core/create-new-flagencoder.md): Documentation to create new routing profiles to influence which ways to favor and how the track-time is calculated.
6059
* [Custom Areas and Country Rules](./core/custom-areas-and-country-rules.md): Instructions on how to on how to use and create new SpatialRules. SpatialRules are used to enforce country-specific routing rules.
6160
* [Turn Restrictions](./core/turn-restrictions.md): Details on how to enable and use turn restrictions.
6261
* [Isochrone generation in Java](./isochrone/java.md): Instruction on how to create isochrones using the low-level Java API.

0 commit comments

Comments
 (0)