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 1 commit
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
Prev Previous commit
Next Next commit
updated to use new strlen function and added towards to succinct inst…
…ructions
  • Loading branch information
kdiluca committed Apr 19, 2021
commit 5024d83fd0c443ea62dc0d377f3ac4d1fc5e662e
4 changes: 2 additions & 2 deletions src/odin/maneuversbuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ void ManeuversBuilder::ProcessVerbalSuccinctTransitionInstruction(std::list<Mane
break;
}
if (get_word_count(street_name->value()) > kMaxWordCount ||
street_name->value().length() > kMaxStreetNameLength) {
strlen_utf8(street_name->value()) > kMaxStreetNameLength) {
maneuver.set_long_street_name(true);
break;
}
Expand All @@ -939,7 +939,7 @@ void ManeuversBuilder::ProcessVerbalSuccinctTransitionInstruction(std::list<Mane
break;
}
if (get_word_count(roundabout_exit_street_name->value()) > kMaxWordCount ||
roundabout_exit_street_name->value().length() > kMaxStreetNameLength) {
strlen_utf8(roundabout_exit_street_name->value()) > kMaxStreetNameLength) {
maneuver.set_long_street_name(true);
break;
}
Expand Down
177 changes: 158 additions & 19 deletions src/odin/narrativebuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void NarrativeBuilder::Build(std::list<Maneuver>& maneuvers) {

// Set verbal succinct transition instruction
maneuver.set_verbal_succinct_transition_instruction(
FormVerbalSuccinctRampStraightTransitionInstruction());
FormVerbalRampStraightInstruction(maneuver));

// Set verbal transition alert instruction
maneuver.set_verbal_transition_alert_instruction(
Expand All @@ -184,8 +184,7 @@ void NarrativeBuilder::Build(std::list<Maneuver>& maneuvers) {
maneuver.set_instruction(FormRampInstruction(maneuver));

// Set verbal succinct transition instruction
maneuver.set_verbal_succinct_transition_instruction(
FormVerbalSuccinctRampTransitionInstruction(maneuver));
maneuver.set_verbal_succinct_transition_instruction(FormVerbalRampInstruction(maneuver));

// Set verbal transition alert instruction
maneuver.set_verbal_transition_alert_instruction(FormVerbalAlertRampInstruction(maneuver));
Expand Down Expand Up @@ -345,7 +344,7 @@ void NarrativeBuilder::Build(std::list<Maneuver>& maneuvers) {

// Set verbal succinct transition instruction
maneuver.set_verbal_succinct_transition_instruction(
FormVerbalSuccinctExitRoundaboutTransitionInstruction());
FormVerbalSuccinctExitRoundaboutTransitionInstruction(maneuver));

// Set verbal pre transition instruction
maneuver.set_verbal_pre_transition_instruction(FormVerbalExitRoundaboutInstruction(maneuver));
Expand All @@ -361,7 +360,7 @@ void NarrativeBuilder::Build(std::list<Maneuver>& maneuvers) {

// Set verbal succinct transition instruction
maneuver.set_verbal_succinct_transition_instruction(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove for now

FormVerbalSuccinctEnterFerryTransitionInstruction());
FormVerbalSuccinctEnterFerryTransitionInstruction(maneuver));

// Set verbal transition alert instruction
maneuver.set_verbal_transition_alert_instruction(
Expand Down Expand Up @@ -3961,9 +3960,15 @@ std::string NarrativeBuilder::FormVerbalSuccinctContinueTransitionInstruction(Ma
return instruction;
}

std::string NarrativeBuilder::FormVerbalSuccinctTurnTransitionInstruction(Maneuver& maneuver) {
std::string
NarrativeBuilder::FormVerbalSuccinctTurnTransitionInstruction(Maneuver& maneuver,
bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {

// "0": "Turn/Bear/Make a sharp <RELATIVE_DIRECTION>."
// "4": "Turn/Bear/Make a sharp <RELATIVE_DIRECTION> at <JUNCTION_NAME>."
// "5": "Turn/Bear/Make a sharp <RELATIVE_DIRECTION> toward <TOWARD_SIGN>."

const TurnSubset* subset = nullptr;
switch (maneuver.type()) {
Expand All @@ -3986,13 +3991,32 @@ std::string NarrativeBuilder::FormVerbalSuccinctTurnTransitionInstruction(Maneuv
std::string instruction;
instruction.reserve(kInstructionInitialCapacity);
uint8_t phrase_id = 0;
std::string junction_name;
std::string guide_sign;

if (maneuver.HasGuideSign()) {
// Set the toward phrase - it takes priority over street names and junction name
phrase_id = 5;
// Assign guide sign
guide_sign = maneuver.signs().GetGuideString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
} else if (maneuver.HasJunctionNameSign()) {
// Set the junction phrase - it takes priority over street names
phrase_id = 4;
// Assign guide sign
junction_name =
maneuver.signs().GetJunctionNameString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}

// Set instruction to the determined tagged phrase
instruction = subset->phrases.at(std::to_string(phrase_id));

// Replace phrase tags with values
boost::replace_all(instruction, kRelativeDirectionTag,
FormRelativeTwoDirection(maneuver.type(), subset->relative_directions));
boost::replace_all(instruction, kJunctionNameTag, junction_name);
boost::replace_all(instruction, kTowardSignTag, guide_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
Expand All @@ -4002,26 +4026,49 @@ std::string NarrativeBuilder::FormVerbalSuccinctTurnTransitionInstruction(Maneuv
return instruction;
}

std::string NarrativeBuilder::FormVerbalSuccinctUturnTransitionInstruction(Maneuver& maneuver) {
std::string
NarrativeBuilder::FormVerbalSuccinctUturnTransitionInstruction(Maneuver& maneuver,
bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {
// "0": "Make a <RELATIVE_DIRECTION> U-turn."
// "6": "Make a <RELATIVE_DIRECTION> U-turn at <JUNCTION_NAME>."
// "7": "Make a <RELATIVE_DIRECTION> U-turn toward <TOWARD_SIGN>."

std::string instruction;
instruction.reserve(kInstructionInitialCapacity);
uint8_t phrase_id = 0;
std::string junction_name;
std::string guide_sign;

if (maneuver.HasGuideSign()) {
// Set the toward phrase - it takes priority over street names and junction name
phrase_id = 7;
// Assign guide sign
guide_sign = maneuver.signs().GetGuideString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
} else if (maneuver.HasJunctionNameSign()) {
// Set the junction phrase - it takes priority over street names
phrase_id = 6;
// Assign guide sign
junction_name =
maneuver.signs().GetJunctionNameString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}
// Set instruction to the determined tagged phrase
instruction = dictionary_.uturn_verbal_subset.phrases.at(std::to_string(phrase_id));

// Replace phrase tags with values
boost::replace_all(instruction, kRelativeDirectionTag,
FormRelativeTwoDirection(maneuver.type(),
dictionary_.uturn_verbal_subset.relative_directions));
boost::replace_all(instruction, kJunctionNameTag, junction_name);
boost::replace_all(instruction, kTowardSignTag, guide_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
FormArticulatedPrepositions(instruction);
}

return instruction;
}

Expand Down Expand Up @@ -4121,22 +4168,49 @@ std::string NarrativeBuilder::FormVerbalSuccinctExitTransitionInstruction(Maneuv
return instruction;
}

std::string NarrativeBuilder::FormVerbalSuccinctKeepTransitionInstruction(Maneuver& maneuver,
const std::string& delim) {
std::string
NarrativeBuilder::FormVerbalSuccinctKeepTransitionInstruction(Maneuver& maneuver,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove for now

bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {
// "0": "Keep <RELATIVE_DIRECTION> at the fork."
// "1": "Keep <RELATIVE_DIRECTION> to take exit <NUMBER_SIGN>.",
// "4": "Keep <RELATIVE_DIRECTION> toward <TOWARD_SIGN>.",
// "5": "Keep <RELATIVE_DIRECTION> to take exit <NUMBER_SIGN> toward <TOWARD_SIGN>.",

std::string exit_number_sign;
std::string toward_sign;
std::string instruction;
instruction.reserve(kInstructionInitialCapacity);

// If they exist, process guide signs
if (maneuver.HasGuideSign()) {
if (maneuver.HasGuideTowardSign()) {
// Assign guide sign
toward_sign =
maneuver.signs().GetGuideTowardString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}
} else {
// If it exists, process exit toward sign
if (maneuver.HasExitTowardSign()) {
// Assign toward sign
toward_sign =
maneuver.signs().GetExitTowardString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}
}

uint8_t phrase_id = 0;
if (maneuver.HasExitNumberSign()) {
phrase_id += 1;
// Assign number sign
exit_number_sign =
maneuver.signs().GetExitNumberString(0, false, delim, maneuver.verbal_formatter());
}
if (!toward_sign.empty()) {
phrase_id += 4;
}

// Set instruction to the determined tagged phrase
instruction = dictionary_.keep_verbal_subset.phrases.at(std::to_string(phrase_id));
Expand All @@ -4146,6 +4220,7 @@ std::string NarrativeBuilder::FormVerbalSuccinctKeepTransitionInstruction(Maneuv
FormRelativeThreeDirection(maneuver.type(),
dictionary_.keep_verbal_subset.relative_directions));
boost::replace_all(instruction, kNumberSignTag, exit_number_sign);
boost::replace_all(instruction, kTowardSignTag, toward_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
Expand All @@ -4155,29 +4230,46 @@ std::string NarrativeBuilder::FormVerbalSuccinctKeepTransitionInstruction(Maneuv
return instruction;
}

std::string NarrativeBuilder::FormVerbalSuccinctMergeTransitionInstruction(Maneuver& maneuver) {
std::string
NarrativeBuilder::FormVerbalSuccinctMergeTransitionInstruction(Maneuver& maneuver,
bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {
// "0": "Merge."
// "1": "Merge <RELATIVE_DIRECTION>."
// "4": "Merge toward <TOWARD_SIGN>."
// "5": "Merge <RELATIVE_DIRECTION> toward <TOWARD_SIGN>."

std::string instruction;
instruction.reserve(kInstructionInitialCapacity);

// Determine which phrase to use
uint8_t phrase_id = 0;
std::string guide_sign;

if (maneuver.HasGuideSign()) {
// Use toward phrase if street names is empty
phrase_id = 4;
// Assign guide sign
guide_sign = maneuver.signs().GetGuideString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}

// Check for merge relative direction
std::string relative_direction;
if ((maneuver.type() == DirectionsLeg_Maneuver_Type_kMergeLeft) ||
(maneuver.type() == DirectionsLeg_Maneuver_Type_kMergeRight)) {
phrase_id += 1;
relative_direction =
FormRelativeTwoDirection(maneuver.type(),
dictionary_.merge_verbal_subset.relative_directions);
}

// Set instruction to the determined tagged phrase
instruction = dictionary_.merge_verbal_subset.phrases.at(std::to_string(phrase_id));

// Replace phrase tags with values
boost::replace_all(instruction, kRelativeDirectionTag, relative_direction);
boost::replace_all(instruction, kRelativeDirectionTag,
FormRelativeTwoDirection(maneuver.type(),
dictionary_.merge_verbal_subset.relative_directions));
boost::replace_all(instruction, kTowardSignTag, guide_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
Expand All @@ -4187,14 +4279,20 @@ std::string NarrativeBuilder::FormVerbalSuccinctMergeTransitionInstruction(Maneu
return instruction;
}

std::string
NarrativeBuilder::FormVerbalSuccinctEnterRoundaboutTransitionInstruction(Maneuver& maneuver) {
std::string NarrativeBuilder::FormVerbalSuccinctEnterRoundaboutTransitionInstruction(
Maneuver& maneuver,
bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {
// "0": "Enter the roundabout.",
// "1": "Enter the roundabout and take the <ORDINAL_VALUE> exit."
// "4": "Enter the roundabout and take the <ORDINAL_VALUE> exit toward <TOWARD_SIGN>.",
// "7": "Enter the roundabout and take the exit toward <TOWARD_SIGN>.",

std::string instruction;
instruction.reserve(kInstructionInitialCapacity);
uint8_t phrase_id = 0;
std::string guide_sign;
std::string ordinal_value;
if ((maneuver.roundabout_exit_count() >= kRoundaboutExitCountLowerBound) &&
(maneuver.roundabout_exit_count() <= kRoundaboutExitCountUpperBound)) {
Expand All @@ -4204,12 +4302,21 @@ NarrativeBuilder::FormVerbalSuccinctEnterRoundaboutTransitionInstruction(Maneuve
ordinal_value = dictionary_.enter_roundabout_verbal_subset.ordinal_values.at(
maneuver.roundabout_exit_count() - 1);
}
if (maneuver.roundabout_exit_signs().HasGuide()) {
// Skip to the toward phrase - it takes priority over street names
phrase_id += 3;
// Assign guide sign
guide_sign =
maneuver.roundabout_exit_signs().GetGuideString(element_max_count, limit_by_consecutive_count,
delim, maneuver.verbal_formatter());
}

// Set instruction to the determined tagged phrase
instruction = dictionary_.enter_roundabout_verbal_subset.phrases.at(std::to_string(phrase_id));

// Replace phrase tags with values
boost::replace_all(instruction, kOrdinalValueTag, ordinal_value);
boost::replace_all(instruction, kTowardSignTag, guide_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
Expand All @@ -4219,16 +4326,32 @@ NarrativeBuilder::FormVerbalSuccinctEnterRoundaboutTransitionInstruction(Maneuve
return instruction;
}

std::string NarrativeBuilder::FormVerbalSuccinctExitRoundaboutTransitionInstruction() {
std::string NarrativeBuilder::FormVerbalSuccinctExitRoundaboutTransitionInstruction(
Maneuver& maneuver,
bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {
// "0": "Exit the roundabout."
// "3": "Exit the roundabout toward <TOWARD_SIGN>."

std::string instruction;
instruction.reserve(kInstructionInitialCapacity);
uint8_t phrase_id = 0;
std::string guide_sign;

if (maneuver.HasGuideSign()) {
// Skip to the toward phrase - it takes priority over street names
phrase_id = 3;
// Assign guide sign
guide_sign = maneuver.signs().GetGuideString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}

// Set instruction to the determined tagged phrase
instruction = dictionary_.exit_roundabout_verbal_subset.phrases.at(std::to_string(phrase_id));

boost::replace_all(instruction, kTowardSignTag, guide_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
FormArticulatedPrepositions(instruction);
Expand All @@ -4237,16 +4360,32 @@ std::string NarrativeBuilder::FormVerbalSuccinctExitRoundaboutTransitionInstruct
return instruction;
}

std::string NarrativeBuilder::FormVerbalSuccinctEnterFerryTransitionInstruction() {
std::string
NarrativeBuilder::FormVerbalSuccinctEnterFerryTransitionInstruction(Maneuver& maneuver,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove for now

bool limit_by_consecutive_count,
uint32_t element_max_count,
const std::string& delim) {
// "0": "Take the Ferry."
// "3": "Take the ferry toward <TOWARD_SIGN>."

std::string instruction;
instruction.reserve(kInstructionInitialCapacity);
uint8_t phrase_id = 0;
std::string guide_sign;

if (maneuver.HasGuideSign()) {
// Skip to the toward phrase - it takes priority over street names
phrase_id = 3;
// Assign guide sign
guide_sign = maneuver.signs().GetGuideString(element_max_count, limit_by_consecutive_count, delim,
maneuver.verbal_formatter());
}

// Set instruction to the determined tagged phrase
instruction = dictionary_.enter_ferry_verbal_subset.phrases.at(std::to_string(phrase_id));

boost::replace_all(instruction, kTowardSignTag, guide_sign);

// If enabled, form articulated prepositions
if (articulated_preposition_enabled_) {
FormArticulatedPrepositions(instruction);
Expand Down
Loading