Skip to content

Commit

Permalink
Check required tags of maneuver relations
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Feb 21, 2018
1 parent 8788b0f commit e9f5b75
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
25 changes: 18 additions & 7 deletions features/guidance/maneuver-tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: Maneuver tag support

When I route I should get
| waypoints | route | turns |
# Testing directly connected from/to
# Testing directly connected from/to
| a,j | A Street,C Street,J Street,J Street | depart,turn sharp right,turn left,arrive |
| b,g | A Street,C Street,C Street | depart,turn sharp right,arrive |
# Testing re-awakening suppressed turns
Expand Down Expand Up @@ -198,11 +198,22 @@ Feature: Maneuver tag support
| pt | 395 | no | primary |

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

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

And the relations
| type | node:via | way:via | way:to | maneuver | # |
| maneuver | p | yp | pb | suppress | invalid relation: missing way:from |

And the relations
| type | way:from | node:via | way:via | maneuver | # |
| maneuver | zy | p | yp | suppress | invalid relation: missing way:to |

When I route I should get
| waypoints | route | turns |
| z,t | NY Ave,395,395 | depart,on ramp left,arrive |
| z,b | NY Ave,,4th St,4th St | depart,on ramp left,fork slight right,arrive |
29 changes: 12 additions & 17 deletions src/extractor/maneuver_override_relation_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
maneuver_override.maneuver = relation.tags().get_value_by_key("maneuver", "");
maneuver_override.direction = relation.tags().get_value_by_key("direction", "");

boost::optional<std::uint64_t> from = boost::none, via = boost::none, to = boost::none;
std::vector<std::uint64_t> via_ways;
OSMNodeID via_node = SPECIAL_OSM_NODEID;
OSMWayID from = SPECIAL_OSM_WAYID, to = SPECIAL_OSM_WAYID;
std::vector<OSMWayID> via_ways;

for (const auto &member : relation.members())
{
Expand All @@ -74,24 +75,24 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
continue;
}
BOOST_ASSERT(0 == strcmp("via", role));
via = static_cast<std::uint64_t>(member.ref());
// set via node id
via_node = OSMNodeID{static_cast<std::uint64_t>(member.ref())};
break;
}
case osmium::item_type::way:
BOOST_ASSERT(0 == strcmp("from", role) || 0 == strcmp("to", role) ||
0 == strcmp("via", role));
if (0 == strcmp("from", role))
{
from = static_cast<std::uint64_t>(member.ref());
from = OSMWayID{static_cast<std::uint64_t>(member.ref())};
}
else if (0 == strcmp("to", role))
{
to = static_cast<std::uint64_t>(member.ref());
to = OSMWayID{static_cast<std::uint64_t>(member.ref())};
}
else if (0 == strcmp("via", role))
{
via_ways.push_back(static_cast<std::uint64_t>(member.ref()));
via_ways.push_back(OSMWayID{static_cast<std::uint64_t>(member.ref())});
}
break;
case osmium::item_type::relation:
Expand All @@ -103,18 +104,12 @@ ManeuverOverrideRelationParser::TryParse(const osmium::Relation &relation) const
}
}

if (from && (via || via_ways.size() > 0) && to)
if (from != SPECIAL_OSM_WAYID && to != SPECIAL_OSM_WAYID && via_node != SPECIAL_OSM_NODEID)
{
via_ways.insert(via_ways.begin(), *from);
via_ways.push_back(*to);
if (via)
{
maneuver_override.via_node = {*via};
}
for (const auto &n : via_ways)
{
maneuver_override.via_ways.push_back(OSMWayID{n});
}
maneuver_override.via_ways.push_back(from);
std::copy(via_ways.begin(), via_ways.end(), std::back_inserter(maneuver_override.via_ways));
maneuver_override.via_ways.push_back(to);
maneuver_override.via_node = via_node;
}
else
{
Expand Down

0 comments on commit e9f5b75

Please sign in to comment.