Skip to content

Commit be49ed3

Browse files
committed
Check required tags of maneuver relations
1 parent 6763d4c commit be49ed3

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- CHANGED #4842: Lower priority links from a motorway now are used as motorway links [#4842](https://github.com/Project-OSRM/osrm-backend/pull/4842)
88
- CHANGED #4895: Use ramp bifurcations as fork intersections [#4895](https://github.com/Project-OSRM/osrm-backend/issues/4895)
99
- CHANGED #4893: Handle motorway forks with links as normal motorway intersections[#4893](https://github.com/Project-OSRM/osrm-backend/issues/4893)
10+
- FIXED #4905: Check required tags of `maneuver` relations [#4905](https://github.com/Project-OSRM/osrm-backend/pull/4905)
1011
- Profile:
1112
- FIXED: `highway=service` will now be used for restricted access, `access=private` is still disabled for snapping.
1213
- ADDED #4775: Exposes more information to the turn function, now being able to set turn weights with highway and access information of the turn as well as other roads at the intersection [#4775](https://github.com/Project-OSRM/osrm-backend/issues/4775)

features/guidance/maneuver-tag.feature

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Feature: Maneuver tag support
3030

3131
When I route I should get
3232
| waypoints | route | turns |
33-
# Testing directly connected from/to
33+
# Testing directly connected from/to
3434
| a,j | A Street,C Street,J Street,J Street | depart,turn sharp right,turn left,arrive |
3535
| b,g | A Street,C Street,C Street | depart,turn sharp right,arrive |
3636
# Testing re-awakening suppressed turns
@@ -198,11 +198,26 @@ Feature: Maneuver tag support
198198
| pt | 395 | no | primary |
199199

200200
And the relations
201-
| type | way:from | node:via | way:via | way:to | maneuver |
202-
| maneuver | zy | p | yp | pt | suppress |
201+
| type | way:from | node:via | way:via | way:to | maneuver | # |
202+
| maneuver | zy | p | yp | pt | suppress | original: depart,on ramp left,fork slight left,arrive |
203203

204-
When I route I should get
205-
| waypoints | route | turns |
206-
| z,t | NY Ave,395,395 | depart,on ramp left,arrive |
207-
#original | z,t | NY Ave,,395,395 | depart,on ramp left,fork slight left,arrive |
204+
And the relations
205+
| type | way:from | way:via | way:to | maneuver | # |
206+
| maneuver | zy | yp | pb | suppress | invalid relation: missing node:via |
208207

208+
And the relations
209+
| type | node:via | way:via | way:to | maneuver | # |
210+
| maneuver | p | yp | pb | suppress | invalid relation: missing way:from |
211+
212+
And the relations
213+
| type | way:from | node:via | way:via | maneuver | # |
214+
| maneuver | zy | p | yp | suppress | invalid relation: missing way:to |
215+
216+
And the relations
217+
| type | way:from | node:via | way:via | way:to | maneuver | # |
218+
| maneuver | zy | y, p | yp | pb | suppress | invalid relation: multiple node:via |
219+
220+
When I route I should get
221+
| waypoints | route | turns |
222+
| z,t | NY Ave,395,395 | depart,on ramp left,arrive |
223+
| z,b | NY Ave,,4th St,4th St | depart,on ramp left,fork slight right,arrive |

src/extractor/maneuver_override_relation_parser.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
5252
maneuver_override.maneuver = relation.tags().get_value_by_key("maneuver", "");
5353
maneuver_override.direction = relation.tags().get_value_by_key("direction", "");
5454

55-
boost::optional<std::uint64_t> from = boost::none, via = boost::none, to = boost::none;
56-
std::vector<std::uint64_t> via_ways;
55+
bool valid_relation = true;
56+
OSMNodeID via_node = SPECIAL_OSM_NODEID;
57+
OSMWayID from = SPECIAL_OSM_WAYID, to = SPECIAL_OSM_WAYID;
58+
std::vector<OSMWayID> via_ways;
5759

5860
for (const auto &member : relation.members())
5961
{
@@ -74,24 +76,27 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
7476
continue;
7577
}
7678
BOOST_ASSERT(0 == strcmp("via", role));
77-
via = static_cast<std::uint64_t>(member.ref());
7879
// set via node id
80+
valid_relation &= via_node == SPECIAL_OSM_NODEID;
81+
via_node = OSMNodeID{static_cast<std::uint64_t>(member.ref())};
7982
break;
8083
}
8184
case osmium::item_type::way:
8285
BOOST_ASSERT(0 == strcmp("from", role) || 0 == strcmp("to", role) ||
8386
0 == strcmp("via", role));
8487
if (0 == strcmp("from", role))
8588
{
86-
from = static_cast<std::uint64_t>(member.ref());
89+
valid_relation &= from == SPECIAL_OSM_WAYID;
90+
from = OSMWayID{static_cast<std::uint64_t>(member.ref())};
8791
}
8892
else if (0 == strcmp("to", role))
8993
{
90-
to = static_cast<std::uint64_t>(member.ref());
94+
valid_relation &= to == SPECIAL_OSM_WAYID;
95+
to = OSMWayID{static_cast<std::uint64_t>(member.ref())};
9196
}
9297
else if (0 == strcmp("via", role))
9398
{
94-
via_ways.push_back(static_cast<std::uint64_t>(member.ref()));
99+
via_ways.push_back(OSMWayID{static_cast<std::uint64_t>(member.ref())});
95100
}
96101
break;
97102
case osmium::item_type::relation:
@@ -103,18 +108,17 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
103108
}
104109
}
105110

106-
if (from && (via || via_ways.size() > 0) && to)
111+
// Check required roles
112+
valid_relation &= from != SPECIAL_OSM_WAYID;
113+
valid_relation &= to != SPECIAL_OSM_WAYID;
114+
valid_relation &= via_node != SPECIAL_OSM_NODEID;
115+
116+
if (valid_relation)
107117
{
108-
via_ways.insert(via_ways.begin(), *from);
109-
via_ways.push_back(*to);
110-
if (via)
111-
{
112-
maneuver_override.via_node = {*via};
113-
}
114-
for (const auto &n : via_ways)
115-
{
116-
maneuver_override.via_ways.push_back(OSMWayID{n});
117-
}
118+
maneuver_override.via_ways.push_back(from);
119+
std::copy(via_ways.begin(), via_ways.end(), std::back_inserter(maneuver_override.via_ways));
120+
maneuver_override.via_ways.push_back(to);
121+
maneuver_override.via_node = via_node;
118122
}
119123
else
120124
{

0 commit comments

Comments
 (0)