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

New Verbal Succinct Transition Instruction #2844

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7b2ab37
added new verbal_succinct_transition_instruction logic to maneuver, m…
kdiluca Feb 8, 2021
6d2ba97
fixed imports and check if streetnames exist per maneuver
kdiluca Feb 8, 2021
a337ab9
added more testing
kdiluca Feb 9, 2021
2fb15b3
fixed FormVerbalSuccinctStartTransitionInstruction
kdiluca Feb 9, 2021
f248903
Merge branch 'master' into kdiluca-long-streetnames
kdiluca Feb 9, 2021
39b1f5c
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Feb 10, 2021
a233607
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Feb 10, 2021
8a07c27
reorganized and updated narrativebuilder test
kdiluca Feb 10, 2021
4fccdc0
lint
kdiluca Feb 10, 2021
5da6131
more test edits
kdiluca Feb 10, 2021
756195d
update tests with succinct logic updates
kdiluca Feb 16, 2021
30b46c7
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Feb 16, 2021
56d963e
fixed formatting
kdiluca Feb 16, 2021
ee34ff7
fixed formatting
kdiluca Feb 16, 2021
dc944bb
updated changelog
kdiluca Feb 16, 2021
92f41c1
removing maneuver where not needed for now
kdiluca Feb 16, 2021
a3e4fd7
updated gurka tests
kdiluca Feb 17, 2021
2a3a217
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Feb 17, 2021
fcd44ac
Merge branch 'master' into kdiluca-long-streetnames
kdiluca Feb 22, 2021
ef9d7e9
Merge branch 'master' into kdiluca-long-streetnames
kdiluca Mar 2, 2021
303a36d
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Mar 2, 2021
ff714bd
Merge branch 'kdiluca-long-streetnames' of github.com:valhalla/valhal…
kdiluca Mar 2, 2021
696141b
updates
kdiluca Mar 2, 2021
0d279a8
refactor
kdiluca Mar 2, 2021
4751108
refactor
kdiluca Mar 2, 2021
d76217f
update ProcessVerbalSuccinctTransitionInstruction for street name count
dgearhart Mar 2, 2021
e39627b
Addded flag succinct flag for milticue
dgearhart Mar 2, 2021
8b66f77
Added call to process multicue for succinct
dgearhart Mar 2, 2021
3affd3e
Updated to make sure succinct exists before setting multicue
dgearhart Mar 2, 2021
c85781d
typo
dgearhart Mar 2, 2021
a567062
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Mar 4, 2021
591786a
fixed tests for succinct
kdiluca Mar 4, 2021
4cdc9ae
long street names test
kdiluca Mar 4, 2021
de749d5
update street name length threshold
kdiluca Mar 5, 2021
0f3ebc2
added missing breaks
dgearhart Mar 5, 2021
51af4a9
Changed back to 25 for kMaxStreetNameLength
dgearhart Mar 5, 2021
8ebd4d1
adding word length and count functions to util odin
kdiluca Apr 19, 2021
6c8f7d0
added Japenese tests
kdiluca Apr 19, 2021
6376d04
Merge remote-tracking branch 'origin/master' into kdiluca-strlen
kdiluca Apr 19, 2021
6527509
updated changelog
kdiluca Apr 19, 2021
6ea65d4
fixed merged conflict
kdiluca Apr 19, 2021
dbc58cd
updated util with new utf-8 strlen functions
kdiluca Apr 19, 2021
5024d83
updated to use new strlen function and added towards to succinct inst…
kdiluca Apr 19, 2021
ab33787
fix conflicts after master merge
kdiluca Apr 20, 2021
86d93c6
removed unused succinct functions and fixed destination succinct use
kdiluca Apr 21, 2021
71ceba7
updating tests for succinct
kdiluca Apr 21, 2021
0edc7b3
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Apr 22, 2021
dbd8e7a
fixed FormVerbalSuccinctDestinationTransitionInstruction to use relat…
kdiluca Apr 22, 2021
685665c
update
kdiluca Apr 22, 2021
ca8141a
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Apr 22, 2021
c7076dd
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Apr 22, 2021
edccd19
removed the setting of succinct if we are currently not going to use it
kdiluca Apr 22, 2021
68640de
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca May 28, 2021
79166c8
Merge remote-tracking branch 'origin/master' into kdiluca-long-street…
kdiluca Jun 1, 2021
221e5d5
removed succinct enter ferry and succinct keep and adjusted tests acc…
kdiluca Jun 1, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@
* CHANGED: nit(rename): Renames the encoded live speed properties [#2998](https://github.com/valhalla/valhalla/pull/2998)
* ADDED: ci: Vendors the codecov script [#3002](https://github.com/valhalla/valhalla/pull/3002)
* CHANGED: Allow None build type [#3005](https://github.com/valhalla/valhalla/pull/3005)
* CHANGED: ci: Build Python bindings for Mac OS [#3011](https://github.com/valhalla/valhalla/pull/3011)
* CHANGED: ci: Build Python bindings for Mac OS [#3013](https://github.com/valhalla/valhalla/pull/3013)
* ADDED: New verbal succinct transition instruction to maneuver & narrativebuilder. Currently this instruction will be used in place of a very long street name to avoid repetition of long names [#2844](https://github.com/valhalla/valhalla/pull/2844).

## Release Date: 2021-01-25 Valhalla 3.1.0
* **Removed**
Expand Down
63 changes: 32 additions & 31 deletions proto/directions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,42 +162,43 @@ message DirectionsLeg {
kReturnBikeAtBikeShare = 3;
}

optional Type type = 1; // Maneuver type
optional string text_instruction = 2; // text instruction
repeated StreetName street_name = 3; // street names
optional float length = 4; // kilometers or miles based on units
optional double time = 5; // seconds
optional CardinalDirection begin_cardinal_direction = 6; // CardinalDirection
optional uint32 begin_heading = 7; // 0-360
optional uint32 begin_shape_index = 8; // inclusive index
optional uint32 end_shape_index = 9; // inclusive index
optional bool portions_toll = 10; // has portions toll
optional bool portions_unpaved = 11; // has portions unpaved
optional string verbal_transition_alert_instruction = 12;// verbal transition alert instruction
optional string verbal_pre_transition_instruction = 13; // verbal pre-transition instruction
optional string verbal_post_transition_instruction = 14; // verbal post-transition instruction
repeated StreetName begin_street_name = 15; // begin street names
optional Sign sign = 16; // associated sign information, for example: exit number
optional uint32 roundabout_exit_count = 17; // which spoke to exit roundabout after entering
optional string depart_instruction = 18; // depart instruction - used with transit
optional string verbal_depart_instruction = 19; // verbal depart instruction - used with transit
optional string arrive_instruction = 20; // arrive instruction - used with transit
optional string verbal_arrive_instruction = 21; // verbal arrive instruction - used with transit
optional TransitInfo transit_info = 22; // transit attributes including a list of transit stops
optional bool verbal_multi_cue = 23; // verbal multi-cue flag
optional TravelMode travel_mode = 24; // travel mode
optional Type type = 1; // Maneuver type
optional string text_instruction = 2; // text instruction
repeated StreetName street_name = 3; // street names
optional float length = 4; // kilometers or miles based on units
optional double time = 5; // seconds
optional CardinalDirection begin_cardinal_direction = 6; // CardinalDirection
optional uint32 begin_heading = 7; // 0-360
optional uint32 begin_shape_index = 8; // inclusive index
optional uint32 end_shape_index = 9; // inclusive index
optional bool portions_toll = 10; // has portions toll
optional bool portions_unpaved = 11; // has portions unpaved
optional string verbal_transition_alert_instruction = 12; // verbal transition alert instruction
optional string verbal_pre_transition_instruction = 13; // verbal pre-transition instruction
optional string verbal_post_transition_instruction = 14; // verbal post-transition instruction
repeated StreetName begin_street_name = 15; // begin street names
optional Sign sign = 16; // associated sign information, for example: exit number
optional uint32 roundabout_exit_count = 17; // which spoke to exit roundabout after entering
optional string depart_instruction = 18; // depart instruction - used with transit
optional string verbal_depart_instruction = 19; // verbal depart instruction - used with transit
optional string arrive_instruction = 20; // arrive instruction - used with transit
optional string verbal_arrive_instruction = 21; // verbal arrive instruction - used with transit
optional TransitInfo transit_info = 22; // transit attributes including a list of transit stops
optional bool verbal_multi_cue = 23; // verbal multi-cue flag
optional TravelMode travel_mode = 24; // travel mode
optional VehicleType vehicle_type = 25;
optional PedestrianType pedestrian_type = 26;
optional BicycleType bicycle_type = 27;
optional TransitType transit_type = 28;
optional uint32 begin_path_index = 29; // Index in TripPath for first node of maneuver
optional uint32 end_path_index = 30; // Index in TripPath for last node of maneuver
optional bool to_stay_on = 31; // True if same name as previous maneuver
repeated StreetName roundabout_exit_street_names = 32; // Outbound street names from roundabout
optional uint32 turn_degree = 33; // Turn degree of maneuver
optional bool has_time_restrictions = 34; // Whether edge has any time restrictions or not
repeated GuidanceView guidance_views = 35; // List of guidance views
optional uint32 begin_path_index = 29; // Index in TripPath for first node of maneuver
optional uint32 end_path_index = 30; // Index in TripPath for last node of maneuver
optional bool to_stay_on = 31; // True if same name as previous maneuver
repeated StreetName roundabout_exit_street_names = 32; // Outbound street names from roundabout
optional uint32 turn_degree = 33; // Turn degree of maneuver
optional bool has_time_restrictions = 34; // Whether edge has any time restrictions or not
repeated GuidanceView guidance_views = 35; // List of guidance views
optional BssManeuverType bss_maneuver_type = 36;
optional string verbal_succinct_transition_instruction = 37; // verbal succinct transition instruction
}

optional uint64 trip_id = 1;
Expand Down
5 changes: 5 additions & 0 deletions src/odin/directionsbuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ void DirectionsBuilder::PopulateDirectionsLeg(const Options& options,
trip_maneuver->set_portions_unpaved(maneuver.portions_unpaved());
}

if (maneuver.HasVerbalSuccinctTransitionInstruction()) {
trip_maneuver->set_verbal_succinct_transition_instruction(
maneuver.verbal_succinct_transition_instruction());
}

if (maneuver.HasVerbalTransitionAlertInstruction()) {
trip_maneuver->set_verbal_transition_alert_instruction(
maneuver.verbal_transition_alert_instruction());
Expand Down
40 changes: 39 additions & 1 deletion src/odin/maneuver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Maneuver::Maneuver()
roundabout_exit_length_(0.0f), roundabout_exit_begin_heading_(0),
roundabout_exit_turn_degree_(0), roundabout_exit_shape_index_(0),
has_collapsed_small_end_ramp_fork_(false), has_collapsed_merge_maneuver_(false),
pedestrian_crossing_(false) {
pedestrian_crossing_(false), has_long_street_name_(false) {
street_names_ = std::make_unique<StreetNames>();
begin_street_names_ = std::make_unique<StreetNames>();
cross_street_names_ = std::make_unique<StreetNames>();
Expand Down Expand Up @@ -573,6 +573,24 @@ void Maneuver::set_intersecting_forward_edge(bool intersecting_forward_edge) {
intersecting_forward_edge_ = intersecting_forward_edge;
}

const std::string& Maneuver::verbal_succinct_transition_instruction() const {
return verbal_succinct_transition_instruction_;
}

void Maneuver::set_verbal_succinct_transition_instruction(
const std::string& verbal_succinct_transition_instruction) {
verbal_succinct_transition_instruction_ = verbal_succinct_transition_instruction;
}

void Maneuver::set_verbal_succinct_transition_instruction(
std::string&& verbal_succinct_transition_instruction) {
verbal_succinct_transition_instruction_ = std::move(verbal_succinct_transition_instruction);
}

bool Maneuver::HasVerbalSuccinctTransitionInstruction() const {
return (!verbal_succinct_transition_instruction_.empty());
}

const std::string& Maneuver::verbal_transition_alert_instruction() const {
return verbal_transition_alert_instruction_;
}
Expand Down Expand Up @@ -1092,6 +1110,15 @@ void Maneuver::set_bss_maneuver_type(DirectionsLeg_Maneuver_BssManeuverType type
bss_maneuver_type_ = type;
}

bool Maneuver::has_long_street_name() const {

return has_long_street_name_;
}

void Maneuver::set_long_street_name(bool has_long_street_name) {
has_long_street_name_ = has_long_street_name;
}

#ifdef LOGGING_LEVEL_TRACE
std::string Maneuver::ToString() const {
std::string man_str;
Expand Down Expand Up @@ -1190,6 +1217,9 @@ std::string Maneuver::ToString() const {
man_str += " | intersecting_forward_edge=";
man_str += std::to_string(intersecting_forward_edge_);

man_str += " | verbal_succinct_transition_instruction=";
man_str += verbal_succinct_transition_instruction_;

man_str += " | verbal_transition_alert_instruction=";
man_str += verbal_transition_alert_instruction_;

Expand Down Expand Up @@ -1262,6 +1292,9 @@ std::string Maneuver::ToString() const {
man_str += " | bus=";
man_str += std::to_string(bus_);

man_str += " | has_long_street_name=";
man_str += std::to_string(has_long_street_name_);

// TODO travel types

man_str += " | transit_connection=";
Expand Down Expand Up @@ -1414,6 +1447,11 @@ std::string Maneuver::ToParameterString() const {
man_str += delim;
man_str += std::to_string(roundabout_exit_shape_index_);

man_str += delim;
man_str += "\"";
man_str += verbal_succinct_transition_instruction_;
man_str += "\"";

man_str += delim;
man_str += "\"";
man_str += verbal_transition_alert_instruction_;
Expand Down
39 changes: 39 additions & 0 deletions src/odin/maneuversbuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "odin/maneuversbuilder.h"
#include "odin/sign.h"
#include "odin/signs.h"
#include "odin/util.h"

#include "proto/directions.pb.h"
#include "proto/options.pb.h"
Expand Down Expand Up @@ -55,6 +56,10 @@ constexpr float kUpcomingLanesThreshold = 3.f; // Kilometers
// Small end ramp fork threshold in kilometers
constexpr float kSmallEndRampForkThreshold = 0.125f;

// Thresholds for succinct phrase usage
constexpr uint32_t kMaxWordCount = 5;
constexpr uint32_t kMaxStreetNameLength = 25;

std::vector<std::string> split(const std::string& source, char delimiter) {
std::vector<std::string> tokens;
std::string token;
Expand Down Expand Up @@ -131,6 +136,8 @@ std::list<Maneuver> ManeuversBuilder::Build() {
// activate the correct lanes.
ProcessTurnLanes(maneuvers);

ProcessVerbalSuccinctTransitionInstruction(maneuvers);

#ifdef LOGGING_LEVEL_TRACE
int final_man_id = 1;
LOG_TRACE("############################################");
Expand Down Expand Up @@ -910,6 +917,38 @@ void ManeuversBuilder::CountAndSortSigns(std::list<Maneuver>& maneuvers) {
}
}

void ManeuversBuilder::ProcessVerbalSuccinctTransitionInstruction(std::list<Maneuver>& maneuvers) {
for (auto& maneuver : maneuvers) {
uint32_t street_name_count = 0;
for (const auto& street_name : maneuver.street_names()) {
if (street_name_count == kVerbalPreElementMaxCount) {
break;
}
if (get_word_count(street_name->value()) > kMaxWordCount ||
strlen_utf8(street_name->value()) > kMaxStreetNameLength) {
maneuver.set_long_street_name(true);
break;
}
++street_name_count;
}
if ((maneuver.type() == DirectionsLeg_Maneuver_Type_kRoundaboutEnter) &&
!maneuver.has_long_street_name()) {
uint32_t roundabout_exit_street_name_count = 0;
for (const auto& roundabout_exit_street_name : maneuver.roundabout_exit_street_names()) {
if (roundabout_exit_street_name_count == kVerbalPreElementMaxCount) {
break;
}
if (get_word_count(roundabout_exit_street_name->value()) > kMaxWordCount ||
strlen_utf8(roundabout_exit_street_name->value()) > kMaxStreetNameLength) {
maneuver.set_long_street_name(true);
break;
}
++roundabout_exit_street_name_count;
}
}
}
}

void ManeuversBuilder::ConfirmManeuverTypeAssignment(std::list<Maneuver>& maneuvers) {

for (auto& maneuver : maneuvers) {
Expand Down
Loading