Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements Exit Numbers + Names #4215

Merged
merged 6 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# 5.9.0
- Changes from 5.8
- Algorithm:
- Changes from 5.8:
- Algorithm:
- Multi-Level Dijkstra:
- Plugins supported: `table`
- API:
- Support for exits numbers and names. New member `exits` in `RouteStep`, based on `junction:ref` on ways
- Profiles:
- `result.exits` allows you to set a way's exit numbers and names, see [`junction:ref`](http://wiki.openstreetmap.org/wiki/Proposed_features/junction_details)

# 5.8.0
- Changes from 5.7
Expand Down
1 change: 1 addition & 0 deletions docs/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ step.
- `ref`: A reference number or code for the way. Optionally included, if ref data is available for the given way.
- `pronunciation`: The pronunciation hint of the way name. Will be `undefined` if there is no pronunciation hit.
- `destinations`: The destinations of the way. Will be `undefined` if there are no destinations.
- `exits`: The exit numbers or names of the way. Will be `undefined` if there are no exit numbers or names.
- `mode`: A string signifying the mode of transportation.
- `maneuver`: A `StepManeuver` object representing the maneuver.
- `intersections`: A list of `Intersection` objects that are passed along the segment, the very first belonging to the StepManeuver
Expand Down
2 changes: 2 additions & 0 deletions docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ roundabout | Boolean | Is this part of a roundabou
circular | Boolean | Is this part of a non-roundabout circular junction?
name | String | Name of the way
ref | String | Road number
destinations | String | The road's destinations
exits | String | The ramp's exit numbers or names
pronunciation | String | Name pronunciation
road_classification.motorway_class | Boolean | Guidance: way is a motorway
road_classification.link_class | Boolean | Guidance: way is a slip/link road
Expand Down
98 changes: 98 additions & 0 deletions features/guidance/exit-numbers-names.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@routing @guidance
Feature: Exit Numbers and Names

Background:
Given the profile "car"
Given a grid size of 10 meters

Scenario: Exit number on the way after the motorway junction
Given the node map
"""
a . . b . c . . d
` e . . f
"""

And the nodes
| node | highway |
| b | motorway_junction |

And the ways
| nodes | highway | name | junction:ref |
| abcd | motorway | MainRoad | |
| be | motorway_link | ExitRamp | 3 |
| ef | motorway_link | ExitRamp | |

When I route I should get
| waypoints | route | turns | exits |
| a,f | MainRoad,ExitRamp,ExitRamp | depart,off ramp slight right,arrive | ,3, |


Scenario: Exit number on the way, motorway junction node tag missing, multiple numbers
Given the node map
"""
a . . b . c . . d
` e . . f
"""

And the ways
| nodes | highway | name | junction:ref |
| abcd | motorway | MainRoad | |
| be | motorway_link | ExitRamp | 10;12 |
| ef | motorway_link | ExitRamp | |

When I route I should get
| waypoints | route | turns | exits |
| a,f | MainRoad,ExitRamp,ExitRamp | depart,off ramp slight right,arrive | ,10;12, |


Scenario: Exit number on the ways after the motorway junction, multiple exits
Given the node map
"""
a . . b . c . . d
` e . . f
` g . . h
"""

And the nodes
| node | highway |
| b | motorway_junction |

And the ways
| nodes | highway | name | junction:ref |
| abcd | motorway | MainRoad | |
| be | motorway_link | ExitRamp | 3 |
| ef | motorway_link | ExitRamp | |
| bg | motorway_link | ExitRamp | 3 |
| gh | motorway_link | ExitRamp | |

When I route I should get
| waypoints | route | turns | exits |
| a,f | MainRoad,ExitRamp,ExitRamp | depart,off ramp slight right,arrive | ,3, |
| a,h | MainRoad,ExitRamp,ExitRamp | depart,off ramp right,arrive | ,3, |



# http://www.openstreetmap.org/way/417524818#map=17/37.38663/-121.97972
Scenario: Exit 393 on Bayshore Freeway
Given the node map
"""
a
` b
` c
. ` d
f ` e
"""

And the nodes
| node | highway |
| c | motorway_junction |

And the ways
| nodes | highway | name | junction:ref | oneway | destination |
| abcde | motorway | Bayshore Freeway | | yes | |
| cf | motorway_link | | 393 | yes | Great America Parkway;Bowers Avenue |

When I route I should get
| waypoints | route | turns | exits | destinations |
| a,e | Bayshore Freeway,Bayshore Freeway | depart,arrive | , | , |
| a,f | Bayshore Freeway,, | depart,off ramp slight right,arrive | ,393,393 | ,Great America Parkway, Bowers Avenue,Great America Parkway, Bowers Avenue |
4 changes: 4 additions & 0 deletions features/support/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ module.exports = function () {
return this.extractInstructionList(instructions, s => s.destinations || '');
};

this.exitsList = (instructions) => {
return this.extractInstructionList(instructions, s => s.exits || '');
};

this.reverseBearing = (bearing) => {
if (bearing >= 180)
return bearing - 180.;
Expand Down
6 changes: 4 additions & 2 deletions features/support/shared_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function () {
var afterRequest = (err, res, body) => {
if (err) return cb(err);
if (body && body.length) {
let destinations, pronunciations, instructions, refs, bearings, turns, modes, times,
let destinations, exits, pronunciations, instructions, refs, bearings, turns, modes, times,
distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches;

let json = JSON.parse(body);
Expand All @@ -48,6 +48,7 @@ module.exports = function () {
pronunciations = this.pronunciationList(json.routes[0]);
refs = this.refList(json.routes[0]);
destinations = this.destinationsList(json.routes[0]);
exits = this.exitsList(json.routes[0]);
bearings = this.bearingList(json.routes[0]);
turns = this.turnList(json.routes[0]);
intersections = this.intersectionList(json.routes[0]);
Expand Down Expand Up @@ -177,6 +178,7 @@ module.exports = function () {
putValue('distances', distances);
putValue('pronunciations', pronunciations);
putValue('destinations', destinations);
putValue('exits', exits);
putValue('weight_name', weight_name);
putValue('weights', weights);
putValue('weight', weight);
Expand Down Expand Up @@ -243,7 +245,7 @@ module.exports = function () {
} else if (row.waypoints) {
row.waypoints.split(',').forEach((n) => {
var node = this.findNodeByName(n.trim());
if (!node) return cb(new Error('*** unknown waypoint node "%s"', n.trim()));
if (!node) return cb(new Error(util.format('*** unknown waypoint node "%s"', n.trim())));
waypoints.push(node);
});
got.waypoints = row.waypoints;
Expand Down
1 change: 1 addition & 0 deletions features/testbot/nil.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Feature: Testbot - Check assigning nil values
result.name = nil
result.ref = nil
result.destinations = nil
result.exits = nil
result.pronunciation = nil
result.turn_lanes_forward = nil
result.turn_lanes_backward = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return m_name_table.GetDestinationsForID(id);
}

StringView GetExitsForID(const NameID id) const override final
{
return m_name_table.GetExitsForID(id);
}

StringView GetDatasourceName(const DatasourceID id) const override final
{
return m_datasources->GetSourceName(id);
Expand Down
2 changes: 2 additions & 0 deletions include/engine/datafacade/datafacade_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class BaseDataFacade

virtual StringView GetDestinationsForID(const NameID id) const = 0;

virtual StringView GetExitsForID(const NameID id) const = 0;

virtual std::string GetTimestamp() const = 0;

virtual bool GetContinueStraightDefault() const = 0;
Expand Down
5 changes: 5 additions & 0 deletions include/engine/guidance/assemble_steps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
const auto ref = facade.GetRefForID(step_name_id);
const auto pronunciation = facade.GetPronunciationForID(step_name_id);
const auto destinations = facade.GetDestinationsForID(step_name_id);
const auto exits = facade.GetExitsForID(step_name_id);
const auto distance = leg_geometry.segment_distances[segment_index];

steps.push_back(RouteStep{step_name_id,
name.to_string(),
ref.to_string(),
pronunciation.to_string(),
destinations.to_string(),
exits.to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
segment_duration / 10.,
Expand Down Expand Up @@ -196,6 +198,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
facade.GetRefForID(step_name_id).to_string(),
facade.GetPronunciationForID(step_name_id).to_string(),
facade.GetDestinationsForID(step_name_id).to_string(),
facade.GetExitsForID(step_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
Expand Down Expand Up @@ -237,6 +240,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
facade.GetRefForID(source_name_id).to_string(),
facade.GetPronunciationForID(source_name_id).to_string(),
facade.GetDestinationsForID(source_name_id).to_string(),
facade.GetExitsForID(source_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
Expand Down Expand Up @@ -275,6 +279,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
facade.GetRefForID(target_name_id).to_string(),
facade.GetPronunciationForID(target_name_id).to_string(),
facade.GetDestinationsForID(target_name_id).to_string(),
facade.GetExitsForID(target_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
ZERO_DURATION,
Expand Down
10 changes: 8 additions & 2 deletions include/engine/guidance/collapsing_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ inline bool haveSameName(const RouteStep &lhs, const RouteStep &rhs)

// ok, bite the sour grape and check the strings already
else
return !util::guidance::requiresNameAnnounced(
lhs.name, lhs.ref, lhs.pronunciation, rhs.name, rhs.ref, rhs.pronunciation);
return !util::guidance::requiresNameAnnounced(lhs.name,
lhs.ref,
lhs.pronunciation,
lhs.exits,
rhs.name,
rhs.ref,
rhs.pronunciation,
rhs.exits);
}

// alias for readability, both turn right | left
Expand Down
3 changes: 3 additions & 0 deletions include/engine/guidance/route_step.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct RouteStep
std::string ref;
std::string pronunciation;
std::string destinations;
std::string exits;
std::string rotary_name;
std::string rotary_pronunciation;
double duration; // duration in seconds
Expand Down Expand Up @@ -114,6 +115,7 @@ inline void RouteStep::Invalidate()
ref.clear();
pronunciation.clear();
destinations.clear();
exits.clear();
rotary_name.clear();
rotary_pronunciation.clear();
duration = 0;
Expand Down Expand Up @@ -178,6 +180,7 @@ inline RouteStep &RouteStep::AdaptStepSignage(const RouteStep &origin)
name = origin.name;
pronunciation = origin.pronunciation;
destinations = origin.destinations;
exits = origin.exits;
ref = origin.ref;

return *this;
Expand Down
4 changes: 4 additions & 0 deletions include/extractor/extraction_way.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct ExtractionWay
ref.clear();
pronunciation.clear();
destinations.clear();
exits.clear();
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
backward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
turn_lanes_forward.clear();
Expand All @@ -69,6 +70,8 @@ struct ExtractionWay
const char *GetRef() const { return ref.c_str(); }
void SetDestinations(const char *value) { detail::maybeSetString(destinations, value); }
const char *GetDestinations() const { return destinations.c_str(); }
void SetExits(const char *value) { detail::maybeSetString(exits, value); }
const char *GetExits() const { return exits.c_str(); }
void SetPronunciation(const char *value) { detail::maybeSetString(pronunciation, value); }
const char *GetPronunciation() const { return pronunciation.c_str(); }
void SetTurnLanesForward(const char *value)
Expand Down Expand Up @@ -96,6 +99,7 @@ struct ExtractionWay
std::string ref;
std::string pronunciation;
std::string destinations;
std::string exits;
std::string turn_lanes_forward;
std::string turn_lanes_backward;
guidance::RoadClassification road_classification;
Expand Down
13 changes: 7 additions & 6 deletions include/extractor/extractor_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ class Way;

namespace std
{
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string>>
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string, std::string>>
{
std::size_t
operator()(const std::tuple<std::string, std::string, std::string, std::string> &mk) const
std::size_t operator()(
const std::tuple<std::string, std::string, std::string, std::string, std::string> &mk) const
noexcept
{
std::size_t seed = 0;
boost::hash_combine(seed, std::get<0>(mk));
boost::hash_combine(seed, std::get<1>(mk));
boost::hash_combine(seed, std::get<2>(mk));
boost::hash_combine(seed, std::get<3>(mk));
boost::hash_combine(seed, std::get<4>(mk));
return seed;
}
};
Expand All @@ -55,9 +56,9 @@ struct ProfileProperties;
class ExtractorCallbacks
{
private:
// used to deduplicate street names, refs, destinations, pronunciation: actually maps to name
// ids
using MapKey = std::tuple<std::string, std::string, std::string, std::string>;
// used to deduplicate street names, refs, destinations, pronunciation, exits:
// actually maps to name ids
using MapKey = std::tuple<std::string, std::string, std::string, std::string, std::string>;
using MapVal = unsigned;
std::unordered_map<MapKey, MapVal> string_map;
guidance::LaneDescriptionMap lane_description_map;
Expand Down
3 changes: 2 additions & 1 deletion include/util/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ inline void print(const engine::guidance::RouteStep &step)
std::cout << ")";
}
std::cout << "] name[" << step.name_id << "]: " << step.name << " Ref: " << step.ref
<< " Pronunciation: " << step.pronunciation << "Destination: " << step.destinations;
<< " Pronunciation: " << step.pronunciation << "Destination: " << step.destinations
<< "Exits: " << step.exits;
}

inline void print(const std::vector<engine::guidance::RouteStep> &steps)
Expand Down
Loading