Skip to content

Commit

Permalink
Remove large number formatting for non-US countries (#3015)
Browse files Browse the repository at this point in the history
* Removed number splitting logic for non-US countries
Added tests to verify no number splitting for non-US countries
Updated tests to felect new logic

* added 3015 to changelog
  • Loading branch information
dgearhart committed Apr 19, 2021
1 parent 180237f commit fa59a8d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* FIXED: Annotations fail with returning NaN speed when the same point is duplicated in route geometry [#2992](https://github.com/valhalla/valhalla/pull/2992)
* FIXED: Fix run_with_server.py to work on macOS [#3003](https://github.com/valhalla/valhalla/pull/3003)
* FIXED: Removed unexpected maneuvers at sharp bends [#2968](https://github.com/valhalla/valhalla/pull/2968)
* FIXED: Remove large number formatting for non-US countries [#3015](https://github.com/valhalla/valhalla/pull/3015)

* **Enhancement**
* Pedestrian crossing should be a separate TripLeg_Use [#2950](https://github.com/valhalla/valhalla/pull/2950)
Expand Down
2 changes: 0 additions & 2 deletions src/baldr/verbal_text_formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ VerbalTextFormatter::~VerbalTextFormatter() {
std::string VerbalTextFormatter::Format(const std::string& text) const {
std::string verbal_text(text);

verbal_text = FormNumberSplitTts(verbal_text);

return verbal_text;
}

Expand Down
6 changes: 3 additions & 3 deletions test/gurka/test_instructions_obvious_maneuver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ TEST_F(InstructionsObviousManeuver, NotObviousBecauseSameNameIntersectingEdgeRam
// Verify start maneuver prior to the continune maneuver
gurka::assert::raw::expect_instructions_at_maneuver_index(result, maneuver_index,
"Drive east on US 322.", "",
"Drive east on US 3 22.",
"Drive east on US 322.",
"Continue for 3 kilometers.");

// Verify continue because of same name intersecting edge
gurka::assert::raw::expect_instructions_at_maneuver_index(result, ++maneuver_index,
"Keep left to take US 422.",
"Keep left to take US 4 22.",
"Keep left to take US 4 22.",
"Keep left to take US 422.",
"Keep left to take US 422.",
"Continue for 6 kilometers.");
}
4 changes: 2 additions & 2 deletions test/gurka/test_instructions_sharp_bend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ TEST_F(InstructionsSharpBendPath, IgnoreLeft) {
// Verify single maneuver prior to the right turn
gurka::assert::raw::expect_instructions_at_maneuver_index(result, maneuver_index,
"Drive east on 船原西浦高原線/127.", "",
"Drive east on 船原西浦高原線, 1 27.",
"Drive east on 船原西浦高原線, 127.",
"Continue for 3 kilometers.");
}

Expand All @@ -131,7 +131,7 @@ TEST_F(InstructionsSharpBendPath, IgnoreRight) {
// Verify single maneuver prior to the right turn
gurka::assert::raw::expect_instructions_at_maneuver_index(result, maneuver_index,
"Drive east on 船原西浦高原線/127.", "",
"Drive east on 船原西浦高原線, 1 27.",
"Drive east on 船原西浦高原線, 127.",
"Continue for 3 kilometers.");
}
//#############################################################################
Expand Down
4 changes: 2 additions & 2 deletions test/gurka/test_instructions_small_end_ramp_forks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TEST_F(InstructionsSmallEndRampForks, LeftTurn) {
// Verify the turn left instructions
gurka::assert::raw::expect_instructions_at_maneuver_index(
result, maneuver_index, "Turn left onto Hershey Road/PA 743.", "Turn left onto Hershey Road.",
"Turn left onto Hershey Road, PA 7 43. Then You will arrive at your destination.",
"Turn left onto Hershey Road, PA 743. Then You will arrive at your destination.",
"Continue for 60 meters.");
}

Expand Down Expand Up @@ -123,6 +123,6 @@ TEST_F(InstructionsSmallEndRampForks, RightTurn) {
// Verify the turn right instructions
gurka::assert::raw::expect_instructions_at_maneuver_index(
result, maneuver_index, "Turn right onto Hershey Road/PA 743.", "Turn right onto Hershey Road.",
"Turn right onto Hershey Road, PA 7 43. Then You will arrive at your destination.",
"Turn right onto Hershey Road, PA 743. Then You will arrive at your destination.",
"Continue for 40 meters.");
}
2 changes: 1 addition & 1 deletion test/instructions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ TEST(Instructions, validate_exit_instructions) {
"test/pinpoints/instructions/exit_left_driving_side_left.pbf"},
expected_routes_size, expected_legs_size, expected_maneuvers_size, maneuver_index,
"Take exit 8 onto A120(W)|A120(W).", "Take exit 8.",
"Take exit 8 onto A1 20(W)|A1 20(W).", "");
"Take exit 8 onto A120(W)|A120(W).", "");

expected_maneuvers_size = 4;
// Test exit non-motorway in PA
Expand Down
32 changes: 19 additions & 13 deletions test/verbal_text_formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,37 @@ TEST(VeralTextFormatter, TestFormNumberSplitTtsString) {
TryFormNumberSplitTtsString("123456, 123456, 123456", "12 34 56, 12 34 56, 12 34 56");
TryFormNumberSplitTtsString("County Road 00-122", "County Road 00-1 22");
TryFormNumberSplitTtsString("Road 0110", "Road 01 10");
TryFormNumberSplitTtsString("PA 23", "PA 23");
TryFormNumberSplitTtsString("PA 283", "PA 2 83");
TryFormNumberSplitTtsString("US 202", "US 2 02");
TryFormNumberSplitTtsString("PA 1080", "PA 10 80");
TryFormNumberSplitTtsString("PA 40001", "PA 4 00 01");
TryFormNumberSplitTtsString("PA 4007", "PA 40 07");
TryFormNumberSplitTtsString("SR 1021", "SR 10 21");
TryFormNumberSplitTtsString("SR-1021", "SR-10 21");
TryFormNumberSplitTtsString("Sr 1021", "Sr 10 21");
TryFormNumberSplitTtsString("T609", "T6 09");
TryFormNumberSplitTtsString("US 422 Business Alternate", "US 4 22 Business Alternate");
}

void TryFormat(const string& source, const string& expected) {
VerbalTextFormatterTest formatter_test("US", "PA");
VerbalTextFormatterTest formatter_test("FR", "IDF");
string tts = formatter_test.Format(source);
EXPECT_EQ(tts, expected);
}

TEST(VeralTextFormatter, TestFormat) {
TryFormat("PA 23", "PA 23");
TryFormat("PA 283", "PA 2 83");
TryFormat("US 202", "US 2 02");
TryFormat("PA 1080", "PA 10 80");
TryFormat("PA 40001", "PA 4 00 01");
TryFormat("PA 4007", "PA 40 07");
TryFormat("SR 1021", "SR 10 21");
TryFormat("SR-1021", "SR-10 21");
TryFormat("Sr 1021", "Sr 10 21");
TryFormat("T609", "T6 09");
TryFormat("US 422 Business Alternate", "US 4 22 Business Alternate");
TryFormat("E411", "E411");
TryFormat("A104", "A104");
TryFormat("A154", "A154");
TryFormat("A320", "A320");
TryFormat("A406", "A406");
TryFormat("A844", "A844");
}

} // namespace

int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
}

0 comments on commit fa59a8d

Please sign in to comment.