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

Refactored the verbal text formatter to handle logic for street name and sign #3369

Merged
merged 4 commits into from
Oct 25, 2021

Conversation

dgearhart
Copy link
Member

@dgearhart dgearhart commented Oct 25, 2021

Simplified code for narrative builder and signs

Tasklist

  • Gurka tests pass
  • RAD tests pass
  • Update the changelog

@@ -52,8 +52,7 @@ std::string StreetNames::ToString(uint32_t max_count,
if (!name_string.empty()) {
name_string += delim;
}
name_string +=
(verbal_formatter) ? verbal_formatter->Format(street_name->value()) : street_name->value();
name_string += (verbal_formatter) ? verbal_formatter->Format(street_name) : street_name->value();
Copy link
Member Author

Choose a reason for hiding this comment

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

simplified call to Format

// If markup string exists then use it
if (markup_string) {
return *markup_string;
std::string VerbalTextFormatter::Format(const std::unique_ptr<baldr::StreetName>& street_name,
Copy link
Member Author

Choose a reason for hiding this comment

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

handles the formatting logic for street names

return verbal_text;
}

std::string VerbalTextFormatter::Format(const odin::Sign& sign,
Copy link
Member Author

Choose a reason for hiding this comment

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

handles the formatting logic for signs

return VerbalTextFormatter::Format(text, markup_string);
}

std::string VerbalTextFormatterUs::Format(const std::string& text) const {
Copy link
Member Author

Choose a reason for hiding this comment

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

simplified and cleaned up

return VerbalTextFormatter::Format(text, markup_string);
}

std::string VerbalTextFormatterUsTx::Format(const std::string& text) const {
Copy link
Member Author

Choose a reason for hiding this comment

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

simplified and cleaned up

@@ -49,7 +49,7 @@ void MarkupFormatter::set_markup_enabled(bool markup_enabled) {
}

boost::optional<std::string>
MarkupFormatter::Format(const std::unique_ptr<baldr::StreetName>& street_name) const {
MarkupFormatter::FormatPhonemeElement(const std::unique_ptr<baldr::StreetName>& street_name) const {
Copy link
Member Author

Choose a reason for hiding this comment

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

better name for method

@@ -66,7 +66,7 @@ MarkupFormatter::Format(const std::unique_ptr<baldr::StreetName>& street_name) c
return boost::none;
}

boost::optional<std::string> MarkupFormatter::Format(const Sign& sign) const {
boost::optional<std::string> MarkupFormatter::FormatPhonemeElement(const Sign& sign) const {
Copy link
Member Author

Choose a reason for hiding this comment

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

better name for method

(verbal_formatter)
? verbal_formatter->Format(street_name->value(), markup_formatter_.Format(street_name))
: street_name->value();
street_names_string += (verbal_formatter)
Copy link
Member Author

Choose a reason for hiding this comment

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

simplified code for street name formatting

((markup_formatter) ? markup_formatter->Format(sign)
: boost::none))
: sign.text();
sign_string +=
Copy link
Member Author

Choose a reason for hiding this comment

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

simplified code for sign formatting

@dgearhart dgearhart merged commit 3957ff5 into master Oct 25, 2021
@dgearhart dgearhart self-assigned this Oct 26, 2021
@dgearhart dgearhart deleted the verbal_text_formatter_refactor branch January 5, 2022 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants