33#include " engine/guidance/assemble_overview.hpp"
44#include " engine/guidance/assemble_route.hpp"
55#include " engine/guidance/assemble_steps.hpp"
6+ #include " engine/guidance/post_processing.hpp"
67
78#include < boost/test/test_case_template.hpp>
89#include < boost/test/unit_test.hpp>
@@ -17,4 +18,85 @@ BOOST_AUTO_TEST_CASE(rfc4648_test_vectors)
1718 // TODO(daniel-j-h):
1819}
1920
21+ BOOST_AUTO_TEST_CASE (trim_short_segments)
22+ {
23+ // using namespace osrm::extractor::guidance;
24+ using namespace osrm ::engine::guidance;
25+ using namespace osrm ::engine;
26+ using namespace osrm ::util;
27+
28+ Intersection intersection1{{FloatLongitude{-73.981154 }, FloatLatitude{40.767762 }},
29+ {302 },
30+ {1 },
31+ Intersection::NO_INDEX,
32+ 0 ,
33+ {0 , 255 },
34+ {}};
35+ Intersection intersection2{{FloatLongitude{-73.981495 }, FloatLatitude{40.768275 }},
36+ {180 },
37+ {1 },
38+ 0 ,
39+ Intersection::NO_INDEX,
40+ {0 , 255 },
41+ {}};
42+
43+ // Check that duplicated coordinate in the end is removed
44+ std::vector<RouteStep> steps = {{324 ,
45+ " Central Park West" ,
46+ " " ,
47+ " " ,
48+ " " ,
49+ " " ,
50+ " " ,
51+ 0.2 ,
52+ 1.9076601161280742 ,
53+ TRAVEL_MODE_DRIVING,
54+ {{FloatLongitude{-73.981492 }, FloatLatitude{40.768258 }},
55+ 329 ,
56+ 348 ,
57+ {TurnType::ExitRotary, DirectionModifier::Straight},
58+ WaypointType::Depart,
59+ 0 },
60+ 0 ,
61+ 3 ,
62+ {intersection1}},
63+ {324 ,
64+ " Central Park West" ,
65+ " " ,
66+ " " ,
67+ " " ,
68+ " " ,
69+ " " ,
70+ 0 ,
71+ 0 ,
72+ TRAVEL_MODE_DRIVING,
73+ {{FloatLongitude{-73.981495 }, FloatLatitude{40.768275 }},
74+ 0 ,
75+ 0 ,
76+ {TurnType::NoTurn, DirectionModifier::UTurn},
77+ WaypointType::Arrive,
78+ 0 },
79+ 2 ,
80+ 3 ,
81+ {intersection2}}};
82+
83+ LegGeometry geometry;
84+ geometry.locations = {{FloatLongitude{-73.981492 }, FloatLatitude{40.768258 }},
85+ {FloatLongitude{-73.981495 }, FloatLatitude{40.768275 }},
86+ {FloatLongitude{-73.981495 }, FloatLatitude{40.768275 }}};
87+ geometry.segment_offsets = {0 , 2 };
88+ geometry.segment_distances = {1.9076601161280742 };
89+ geometry.osm_node_ids = {OSMNodeID{0 }, OSMNodeID{1 }, OSMNodeID{2 }};
90+ geometry.annotations = {{1.9076601161280742 , 0.2 , 0 }, {0 , 0 , 0 }};
91+
92+ trimShortSegments (steps, geometry);
93+
94+ BOOST_CHECK_EQUAL (geometry.segment_distances .size (), 1 );
95+ BOOST_CHECK_EQUAL (geometry.segment_offsets .size (), 2 );
96+ BOOST_CHECK_EQUAL (geometry.segment_offsets .back (), 1 );
97+ BOOST_CHECK_EQUAL (geometry.annotations .size (), 1 );
98+ BOOST_CHECK_EQUAL (geometry.locations .size (), 2 );
99+ BOOST_CHECK_EQUAL (geometry.osm_node_ids .size (), 2 );
100+ }
101+
20102BOOST_AUTO_TEST_SUITE_END ()
0 commit comments