Skip to content

Commit ea2e8a5

Browse files
authored
Make lanes more comprehensive and predictable (#26)
* Reorganized lanes; added more dual, triple use lanes * Added lanes documentation * Mentioned flipping image; defined leftward and rightward * Added unhighlighted lane canvases * Added unhighlighted opposite lanes * Fixed duplicate asset names
1 parent ce0af27 commit ea2e8a5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Lanes.pcvd

975 KB
Binary file not shown.

docs/lanes.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Lanes
2+
3+
Lanes.pcvd is organized into three tabs based on the number of indications in a lane. All single-use lane configurations are included, and the most common dual-use and triple-use configurations are also included.
4+
5+
Each canvas is named according to the format `lane a or b or c` or `lane a or b or c using d`, where _a_, _b_, and _c_ are indications and _d_ is a valid indication matching one of the other three indications. _b_, _c_, and _d_ are only present in some of the canvas names.
6+
7+
## Translating lane indications to a canvas
8+
9+
This naming scheme assumes the following algorithm for translating the Mapbox Directions API’s [lane objects](https://docs.mapbox.com/api/navigation/directions/#lane-object)`indications` array to a canvas:
10+
11+
1. Classify each indication as leftward or rightward:
12+
* If the array contains both leftward and rightward indications:
13+
* If `valid_indication` is leftward, prepend `opposite ` to any rightward indication and set the `flipped` flag.
14+
* If `valid_indication` is rightward, prepend `opposite ` to any leftward indication.
15+
* Otherwise, if the array contains a leftward indication, set the `flipped` flag.
16+
1. For each indication, replace any occurrence of `left` or `right` with `turn`.
17+
1. If `valid_indication` is set, replace any occurrence of `left` or `right` with `turn`.
18+
1. Sort the array of indications in the following order: `opposite uturn`, `opposite sharp turn`, `opposite turn`, `opposite slight turn`, `straight`, `slight turn`, `turn`, `sharp turn`, `uturn`.
19+
1. If there are more than three indications, keep one that matches `valid_indication` and two others and discard the rest.
20+
1. Set the canvas name to `lane ` followed by the array of indications joined by ` or `.
21+
1. If `valid_indication` is set, append ` using ` and the value of `valid_indication` to the canvas name.
22+
1. Look up the canvas by name:
23+
* If the canvas exists, draw it using the `primary_color` and `secondary_color`.
24+
* Otherwise, if it does not exist:
25+
* If `valid_indication` is set, draw the canvas with that name using the `primary_color`.
26+
* Otherwise, if `valid_indication` is unset, draw the canvas `straight` using the `secondary_color`.
27+
1. If the `flipped` flag is set, flip the image horizontally.
28+
29+
In the algorithm above, “leftward” means `sharp left`, `left`, or `slight left`; “rightward” means `slight right`, `right`, or `sharp_right`. `uturn` is leftward if the driving side is to the right and rightward if the driving side is to the left.

0 commit comments

Comments
 (0)