Skip to content

Commit

Permalink
Tyr OSRM serializer: create bannerInstructions in step (valhalla#4093)
Browse files Browse the repository at this point in the history
* Tyr osrm_serializer: Create bannerInstructions in step

* Tyr osrm_serializer: Make sure maneuver_type and turn_modifier isn't called twice

* Adds API flag to configure usage of bannerInstructions in OSRM serializer, default is false

* Tyr: Adds 'secondary' bannerInstructions

* Tyr: route_serializer_osrm apply clang-format

* Apply clang-format to worker.cc

* Tyr OSRM serializer removes unnecessary 'std::move' calls

* Tyr OSRM serializer break out intersections lane_indications function

* WIP: Tyr route_serializer_osrm - adds 'sub' lane instructions to bannerInstructions

* Tyr: OSRM serializer #lane_indications function pass turn_lane as pointer

* Tyr OSRM serializer: Makes sure, there is always a bannerInstructions in the final step

* Tyr OSRM serializer: Removes arrive_banner_instructions function

* Tyr OSRM serializer: Adds initial version of gurka test

* Tyr OSRM serializer: Apply clang-format

* Tyr OSRM serializer expand gurka test

* Tyr OSRM serialize improve gurka test to cover ref tag

* Tyr OSRM serializer: Creates additional bannerInstruction with 'sub' banner if the lanes come late in the step

* Tyr OSRM serializer: Adds lane_indications test

* Adds documentation on how to use the OSRM format with the optional banner_instructions

* Adds bannerInstructions enhancement to CHANGELOG

* Update proto/options.proto

Co-authored-by: Kevin Kreiser <[email protected]>

* Update docs/docs/api/turn-by-turn/api-reference.md

Co-authored-by: Kevin Kreiser <[email protected]>

* Tyr OSRM serializer: simplify lane_indications function signature

* Tyr OSRM serializer: Improve bannerInstructions - add exits, use only last lane information and pick better primary / secondary banners

* Tyr OSRM serializer: Add tests for motorway exit in bannerInstructions

* Tyr OSRM serializer: Adds degrees and driving_side to primary banner instruction for roundabouts and their exit steps

* Refactor test_osrm_serializer to use a test fixture class

* Small changes after code review

---------

Co-authored-by: Kevin Kreiser <[email protected]>
  • Loading branch information
eikes and kevinkreiser authored Aug 29, 2023
1 parent d38153e commit fe67191
Show file tree
Hide file tree
Showing 6 changed files with 840 additions and 99 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* ADDED: add primary key in the landmark sqlite database and a method to retrieve landmarks via their primary keys [#4224](https://github.com/valhalla/valhalla/pull/4224)
* ADDED: `sources_to_targets` action for `/expansion` [#4263](https://github.com/valhalla/valhalla/pull/4263)
* ADDED: update graph tile to allow adding landmarks to edge info, and refactor edgeinfo.cc [#4233](https://github.com/valhalla/valhalla/pull/4233)
* ADDED: Support for `bannerInstructions` attribute in OSRM serializer via `banner_instructions` request parameter [#4093](https://github.com/valhalla/valhalla/pull/4093)

## Release Date: 2023-05-11 Valhalla 3.4.0
* **Removed**
Expand Down
17 changes: 12 additions & 5 deletions docs/docs/api/turn-by-turn/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ The following options are available for `truck` costing.
##### Bicycle costing options
The default bicycle costing is tuned toward road bicycles with a slight preference for using [cycleways](http://wiki.openstreetmap.org/wiki/Key:cycleway) or roads with bicycle lanes. Bicycle routes use regular roads where needed or where no direct bicycle lane options exist, but avoid roads without bicycle access. The costing model recognizes several factors unique to bicycle travel and offers several options for tuning bicycle routes. Several factors unique to travel by bicycle influence the resulting route.

* The types of roads suitable for bicycling depend on the type of bicycle. Road bicycles (skinny or narrow tires) generally are suited to paved roads or perhaps very short sections of compacted gravel. They are not designed for riding on coarse gravel or most paths and tracks through wooded areas or farmland. Mountain bikes, on the other hand, are able to traverse a wider set of surfaces.
* Average travel speed can be highly variable and can depend on bicycle type, fitness and experience of the cyclist, road surface, and hills. The costing model assumes a default speed on smooth, flat roads for each supported bicycle type. This speed can be overridden by an input option. The base speed is modulated by surface type (in conjunction with the bicycle type). In addition, speed is modified based on the hilliness of a road section.
* Bicyclists vary in their tolerance for riding on roads. Most novice bicyclists, and even other bicyclists, prefer cycleways and dedicated cycling paths and would rather avoid all but the quietest neighborhood roads. Other cyclists may be experienced riding on roads and prefer to take roadways because they often provide the fastest way to get between two places. The bicycle costing model accounts for this with a `use_roads` factor to indicate a cyclist's tolerance for riding on roads.
* Bicyclists vary in their fitness level and experience level, and many want to avoid hilly roads, and especially roads with very steep uphill or even downhill sections. Even if the fastest path is over a mountain, many cyclists prefer a flatter path that avoids the climb and descent up and over the mountain.
* The types of roads suitable for bicycling depend on the type of bicycle. Road bicycles (skinny or narrow tires) generally are suited to paved roads or perhaps very short sections of compacted gravel. They are not designed for riding on coarse gravel or most paths and tracks through wooded areas or farmland. Mountain bikes, on the other hand, are able to traverse a wider set of surfaces.
* Average travel speed can be highly variable and can depend on bicycle type, fitness and experience of the cyclist, road surface, and hills. The costing model assumes a default speed on smooth, flat roads for each supported bicycle type. This speed can be overridden by an input option. The base speed is modulated by surface type (in conjunction with the bicycle type). In addition, speed is modified based on the hilliness of a road section.
* Bicyclists vary in their tolerance for riding on roads. Most novice bicyclists, and even other bicyclists, prefer cycleways and dedicated cycling paths and would rather avoid all but the quietest neighborhood roads. Other cyclists may be experienced riding on roads and prefer to take roadways because they often provide the fastest way to get between two places. The bicycle costing model accounts for this with a `use_roads` factor to indicate a cyclist's tolerance for riding on roads.
* Bicyclists vary in their fitness level and experience level, and many want to avoid hilly roads, and especially roads with very steep uphill or even downhill sections. Even if the fastest path is over a mountain, many cyclists prefer a flatter path that avoids the climb and descent up and over the mountain.

The following options described above for autos also apply to bicycle costing methods: `maneuver_penalty`, `gate_cost`, `gate_penalty`, `country_crossing_cost`, `country_costing_penalty`, and `service_penalty`.

Expand Down Expand Up @@ -269,8 +269,16 @@ Directions options should be specified at the top level of the JSON object.
| `units` | Distance units for output. Allowable unit types are miles (or mi) and kilometers (or km). If no unit type is specified, the units default to kilometers. |
| `language` | The language of the narration instructions based on the [IETF BCP 47](https://tools.ietf.org/html/bcp47) language tag string. If no language is specified or the specified language is unsupported, United States-based English (en-US) is used. [Currently supported language list](#supported-language-tags) |
| `directions_type` | An enum with 3 values. <ul><li>`none` indicating no maneuvers or instructions should be returned.</li><li>`maneuvers` indicating that only maneuvers be returned.</li><li>`instructions` indicating that maneuvers with instructions should be returned (this is the default if not specified).</li></ul> |
| `format` | Four options are available: <ul><li>`json` is default valhalla routing directions JSON format</li><li>`gpx` returns the route as a GPX (GPS exchange format) XML track</li><li>`osrm` creates a OSRM compatible route directions JSON</li><li>`pbf` formats the result using protocol buffers</li></ul> |
| `banner_instructions` | If the format is `osrm`, this boolean indicates if each step should have the additional `bannerInstructions` attribute, which can be displayed in some navigation system SDKs. |
| `alternates` | A number denoting how many alternate routes should be provided. There may be no alternates or less alternates than the user specifies. Alternates are not yet supported on multipoint routes (that is, routes with more than 2 locations). They are also not supported on time dependent routes. |

For example a bus request with the result in Spanish using the OSRM (Open Source Routing Machine) format with the additional bannerInstructions in the steps would use the following json:

```json
{"locations":[{"lat":40.730930,"lon":-73.991379},{"lat":40.749706,"lon":-73.991562}],"format":"osrm","costing":"bus","banner_instructions":true,"language":"es-ES"}
```

##### Supported language tags

| Language tag | Language alias | Description |
Expand Down Expand Up @@ -312,7 +320,6 @@ Directions options should be specified at the top level of the JSON object.
| `exclude_locations` | A set of locations to exclude or avoid within a route can be specified using a JSON array of avoid_locations. The avoid_locations have the same format as the locations list. At a minimum each avoid location must include latitude and longitude. The avoid_locations are mapped to the closest road or roads and these roads are excluded from the route path computation.|
| `exclude_polygons` | One or multiple exterior rings of polygons in the form of nested JSON arrays, e.g. `[[[lon1, lat1], [lon2,lat2]],[[lon1,lat1],[lon2,lat2]]]`. Roads intersecting these rings will be avoided during path finding. If you only need to avoid a few specific roads, it's **much** more efficient to use `exclude_locations`. Valhalla will close open rings (i.e. copy the first coordinate to the last position).|
| `date_time` | This is the local date and time at the location.<ul><li>`type`<ul><li>0 - Current departure time.</li><li>1 - Specified departure time</li><li>2 - Specified arrival time. Not yet implemented for multimodal costing method.</li></li>3 - Invariant specified time. Time does not vary over the course of the path. Not implemented for multimodal or bike share routing</li></ul></li><li>`value` - the date and time is specified in ISO 8601 format (YYYY-MM-DDThh:mm) in the local time zone of departure or arrival. For example "2016-07-03T08:06"</li></ul><br> |
| `out_format` | Output format. If no `out_format` is specified, JSON is returned. Future work includes PBF (protocol buffer) support. |
| `id` | Name your route request. If `id` is specified, the naming will be sent thru to the response. |
| `linear_references` | When present and `true`, the successful `route` response will include a key `linear_references`. Its value is an array of base64-encoded [OpenLR location references][openlr], one for each graph edge of the road network matched by the input trace. |
| `prioritize_bidirectional` | Prioritize `bidirectional a*` when `date_time.type = depart_at/current`. By default `time_dependent_forward a*` is used in these cases, but `bidirectional a*` is much faster. Currently it does not update the time (and speeds) when searching for the route path, but the ETA on that route is recalculated based on the time-dependent speeds |
Expand Down
1 change: 1 addition & 0 deletions proto/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,5 @@ message Options {
uint32 matrix_locations = 54; // a one to many or many to one time distance matrix. Does not affect
} // sources_to_targets when either sources or targets has more than 1 location
// or when CostMatrix is the selected matrix mode.
bool banner_instructions = 55; // Whether to return bannerInstructions in the OSRM serializer response
}
Loading

0 comments on commit fe67191

Please sign in to comment.