Skip to content

Commit 655ceb8

Browse files
authored
Add sidepath name fallback using is_sidepath:of:name and street:name tags (#7288)
1 parent 4c9ffaa commit 655ceb8

File tree

6 files changed

+266
-6
lines changed

6 files changed

+266
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22
- Changes from 6.0.0
3+
- Profiles:
4+
- ADDED: Use `is_sidepath:of:name` and `street:name` as fallback names for unnamed sidewalks and sidepaths in foot and bicycle profiles [#7259](https://github.com/Project-OSRM/osrm-backend/issues/7259)
35
- Build:
46
- FIXED: Update Node.js binding path from `lib/binding` to `lib/binding_napi_v8` to match node-pre-gyp versioning conventions [#7272](https://github.com/Project-OSRM/osrm-backend/pull/7272)
57
- FIXED: Reduce MSVC compiler warnings by suppressing informational warnings while preserving bug-indicating warnings [#7253](https://github.com/Project-OSRM/osrm-backend/issues/7253)

docs/profiles.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ If you want to prioritize certain streets, increase the rate on these.
7171
A profile should set `api_version` at the top of your profile. This is done to ensure that older profiles are still supported when the api changes. If `api_version` is not defined, 0 will be assumed. The current api version is 4.
7272

7373
### Library files
74-
The folder [profiles/lib/](../profiles/lib/) contains LUA library files for handling many common processing tasks.
74+
The folder [profiles/lib/](../profiles/lib/) contains Lua library files for handling many common processing tasks.
7575

7676
File | Notes
7777
------------------|------------------------------
@@ -89,7 +89,7 @@ They all return a table of functions when you use `require` to load them. You ca
8989
### setup()
9090
The `setup` function is called once when the profile is loaded and must return a table of configurations. It's also where you can do other global setup, like loading data sources that are used during processing.
9191

92-
Note that processing of data is parallelized and several unconnected LUA interpreters will be running at the same time. The `setup` function will be called once for each. Each LUA interpreter will have its own set of globals.
92+
Note that processing of data is parallelized and several unconnected Lua interpreters will be running at the same time. The `setup` function will be called once for each. Each Lua interpreter will have its own set of globals.
9393

9494
The following global properties can be set under `properties` in the hash you return in the `setup` function:
9595

@@ -347,10 +347,34 @@ road_classification.road_priority_class | Enum | Guidance: order in priority
347347
road_classification.may_be_ignored | Boolean | Guidance: way is non-highway
348348
road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way
349349

350+
### Way names
351+
The `WayHandlers.names` function in [way_handlers.lua](../profiles/lib/way_handlers.lua) handles extraction of way names for routing instructions. It processes the following OSM tags:
352+
353+
Tag | Notes
354+
----------------------|------------------------------
355+
`name` | Primary name of the way
356+
`name:pronunciation` | Pronunciation hint for text-to-speech
357+
`ref` | Road reference number (e.g., "A1", "I-95")
358+
`junction:ref` | Exit or junction reference number
359+
360+
For unnamed sidewalks and sidepaths (where `highway=footway`, `highway=cycleway`, or `highway=path`), the function also supports fallback name tags when the way is marked as a sidepath:
361+
362+
Tag | Notes
363+
----------------------|------------------------------
364+
`is_sidepath:of:name` | Name of the street the sidepath follows (checked first)
365+
`street:name` | Alternative tag for the associated street name
366+
367+
The fallback is only applied when the way has one of these sidepath markers:
368+
- `footway=sidewalk`
369+
- `cycleway=sidepath`
370+
- `is_sidepath=yes`
371+
372+
This allows routing instructions to show street names for separately mapped sidewalks, e.g., "Turn right onto Main Street" instead of just "Turn right".
373+
350374
### process_segment(profile, segment)
351375
The `process_segment` function is called for every segment of OSM ways. A segment is a straight line between two OSM nodes.
352376

353-
On OpenStreetMap way cannot have different tags on different parts of a way. Instead you would split the way into several smaller ways. However many ways are long. For example, many ways pass hills without any change in tags.
377+
An OpenStreetMap way cannot have different tags on different parts of a way. Instead you would split the way into several smaller ways. However, many ways are long. For example, many ways pass over hills without any change in tags.
354378

355379
Processing each segment of an OSM way makes it possible to have different speeds on different parts of a way based on external data like data about elevation, pollution, noise or scenic value and adjust weight and duration of the segment accordingly.
356380

@@ -453,10 +477,10 @@ When turning from `a` to `b` via `x`,
453477
* `roads_on_the_left[1]` is the road `xe`
454478
* `roads_on_the_left[2]` is the road `xc`
455479

456-
Note that indices of arrays in lua are 1-based.
480+
Note that indices of arrays in Lua are 1-based.
457481

458482
#### `highway_turn_classification` and `access_turn_classification`
459-
When setting appropriate turn weights and duration, information about the highway and access tags of roads that are involved in the turn are necessary. The lua turn function `process_turn` does not have access to the original osrm tags anymore. However, `highway_turn_classification` and `access_turn_classification` can be set during setup. The classification set during setup can be later used in `process_turn`.
483+
When setting appropriate turn weights and duration, information about the highway and access tags of roads that are involved in the turn are necessary. The Lua turn function `process_turn` does not have access to the original OSM tags anymore. However, `highway_turn_classification` and `access_turn_classification` can be set during setup. The classification set during setup can be later used in `process_turn`.
460484

461485
**Example**
462486

@@ -513,7 +537,7 @@ function setup()
513537
end
514538
```
515539

516-
The input data must an ASCII file with rows of integers. e.g.:
540+
The input data must be an ASCII file with rows of integers, e.g.:
517541

518542
```
519543
0 0 0 0
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
@routing @bicycle @sidepath
2+
Feature: Bicycle - Sidepath street names
3+
4+
Background:
5+
Given the profile "bicycle"
6+
Given a grid size of 200 meters
7+
8+
Scenario: Bicycle - Use is_sidepath:of:name for cycleway sidepath
9+
Given the node map
10+
"""
11+
a b c
12+
"""
13+
14+
And the ways
15+
| nodes | highway | cycleway | name | is_sidepath:of:name |
16+
| ab | cycleway | sidepath | | Highway 1 |
17+
| bc | cycleway | sidepath | | Highway 2 |
18+
19+
When I route I should get
20+
| from | to | route |
21+
| a | c | Highway 1,Highway 2,Highway 2 |
22+
23+
Scenario: Bicycle - Use street:name for cycleway sidepath
24+
Given the node map
25+
"""
26+
a b
27+
"""
28+
29+
And the ways
30+
| nodes | highway | cycleway | name | street:name |
31+
| ab | cycleway | sidepath | | Bike Lane |
32+
33+
When I route I should get
34+
| from | to | route |
35+
| a | b | Bike Lane,Bike Lane |
36+
37+
Scenario: Bicycle - Explicit name takes priority
38+
Given the node map
39+
"""
40+
a b
41+
"""
42+
43+
And the ways
44+
| nodes | highway | cycleway | name | is_sidepath:of:name |
45+
| ab | cycleway | sidepath | Named Path | Fallback |
46+
47+
When I route I should get
48+
| from | to | route |
49+
| a | b | Named Path,Named Path |
50+
51+
Scenario: Bicycle - Use is_sidepath=yes with is_sidepath:of:name
52+
Given the node map
53+
"""
54+
a b
55+
"""
56+
57+
And the ways
58+
| nodes | highway | is_sidepath | name | is_sidepath:of:name |
59+
| ab | path | yes | | Cycle Route |
60+
61+
When I route I should get
62+
| from | to | route |
63+
| a | b | Cycle Route,Cycle Route |
64+
65+
Scenario: Bicycle - No fallback without sidepath marker
66+
Given the node map
67+
"""
68+
a b
69+
"""
70+
71+
And the ways
72+
| nodes | highway | name | street:name |
73+
| ab | cycleway | | Should Not Show |
74+
75+
When I route I should get
76+
| from | to | route |
77+
| a | b | , |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@routing @car @sidepath
2+
Feature: Car - Sidepath names should not affect car routing
3+
4+
Background:
5+
Given the profile "car"
6+
Given a grid size of 200 meters
7+
8+
Scenario: Car - Does not use sidepath name fallback on roads
9+
Given the node map
10+
"""
11+
a b
12+
"""
13+
14+
And the ways
15+
| nodes | highway | name | street:name |
16+
| ab | primary | | Should Not Show |
17+
18+
When I route I should get
19+
| from | to | route |
20+
| a | b | , |
21+
22+
Scenario: Car - Does not pick up is_sidepath:of:name on roads
23+
Given the node map
24+
"""
25+
a b
26+
"""
27+
28+
And the ways
29+
| nodes | highway | name | is_sidepath:of:name |
30+
| ab | primary | | Should Not Show |
31+
32+
When I route I should get
33+
| from | to | route |
34+
| a | b | , |
35+
36+
Scenario: Car - Sidepath markers do not affect car roads
37+
Given the node map
38+
"""
39+
a b
40+
"""
41+
42+
And the ways
43+
| nodes | highway | footway | name | is_sidepath:of:name |
44+
| ab | primary | sidewalk | | Should Not Show |
45+
46+
When I route I should get
47+
| from | to | route |
48+
| a | b | , |
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
@routing @foot @sidepath
2+
Feature: Foot - Sidepath street names
3+
4+
Background:
5+
Given the profile "foot"
6+
Given a grid size of 200 meters
7+
8+
Scenario: Foot - Use is_sidepath:of:name for unnamed sidewalk
9+
Given the node map
10+
"""
11+
a b c
12+
"""
13+
14+
And the ways
15+
| nodes | highway | footway | name | is_sidepath:of:name |
16+
| ab | footway | sidewalk | | Main Street |
17+
| bc | footway | sidewalk | | Oak Avenue |
18+
19+
When I route I should get
20+
| from | to | route |
21+
| a | c | Main Street,Oak Avenue,Oak Avenue |
22+
23+
Scenario: Foot - Use street:name for unnamed sidewalk
24+
Given the node map
25+
"""
26+
a b c
27+
"""
28+
29+
And the ways
30+
| nodes | highway | footway | name | street:name |
31+
| ab | footway | sidewalk | | Elm Street |
32+
| bc | footway | sidewalk | | Pine Road |
33+
34+
When I route I should get
35+
| from | to | route |
36+
| a | c | Elm Street,Pine Road,Pine Road |
37+
38+
Scenario: Foot - is_sidepath:of:name takes priority over street:name
39+
Given the node map
40+
"""
41+
a b
42+
"""
43+
44+
And the ways
45+
| nodes | highway | footway | name | is_sidepath:of:name | street:name |
46+
| ab | footway | sidewalk | | Primary Name | Secondary |
47+
48+
When I route I should get
49+
| from | to | route |
50+
| a | b | Primary Name,Primary Name |
51+
52+
Scenario: Foot - Explicit name tag takes priority over fallback
53+
Given the node map
54+
"""
55+
a b
56+
"""
57+
58+
And the ways
59+
| nodes | highway | footway | name | is_sidepath:of:name |
60+
| ab | footway | sidewalk | Explicit Name | Fallback Name |
61+
62+
When I route I should get
63+
| from | to | route |
64+
| a | b | Explicit Name,Explicit Name |
65+
66+
Scenario: Foot - Use is_sidepath=yes with street:name
67+
Given the node map
68+
"""
69+
a b
70+
"""
71+
72+
And the ways
73+
| nodes | highway | is_sidepath | name | street:name |
74+
| ab | path | yes | | River Path |
75+
76+
When I route I should get
77+
| from | to | route |
78+
| a | b | River Path,River Path |
79+
80+
Scenario: Foot - No fallback without sidepath marker
81+
Given the node map
82+
"""
83+
a b
84+
"""
85+
86+
And the ways
87+
| nodes | highway | name | street:name |
88+
| ab | footway | | Should Not Show |
89+
90+
When I route I should get
91+
| from | to | route |
92+
| a | b | , |

profiles/lib/way_handlers.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ function WayHandlers.names(profile,way,result,data)
3939
-- Set the name that will be used for instructions
4040
if name then
4141
result.name = name
42+
else
43+
-- Fallback for unnamed sidewalks and sidepaths
44+
-- Use is_sidepath:of:name or street:name when way is marked as a sidepath
45+
local sidepath_name = way:get_value_by_key("is_sidepath:of:name") or
46+
way:get_value_by_key("street:name")
47+
if sidepath_name then
48+
local highway = way:get_value_by_key("highway")
49+
local footway = way:get_value_by_key("footway")
50+
local cycleway = way:get_value_by_key("cycleway")
51+
local is_sidepath = way:get_value_by_key("is_sidepath")
52+
-- Only apply to footway/cycleway/path highway types
53+
if highway == "footway" or highway == "cycleway" or highway == "path" then
54+
if footway == "sidewalk" or cycleway == "sidepath" or is_sidepath == "yes" then
55+
result.name = sidepath_name
56+
end
57+
end
58+
end
4259
end
4360

4461
if ref then

0 commit comments

Comments
 (0)