1
1
#include " OpenDriveMap.h"
2
2
#include < catch2/catch_test_macros.hpp>
3
+ #include < catch2/matchers/catch_matchers_vector.hpp>
3
4
#include < iostream>
4
5
5
- TEST_CASE (" Basic OpenDriveMap check" , " [xodr]" )
6
+ TEST_CASE (" basic map check" , " [xodr]" )
6
7
{
7
8
odr::OpenDriveMap odr_map (" test.xodr" );
8
9
REQUIRE (odr_map.xml_parse_result );
9
10
REQUIRE (!odr_map.get_roads ().empty ());
10
11
11
- // test routing
12
- auto graph = odr_map.get_routing_graph ();
13
- auto path = graph.shortest_path (odr::LaneKey (" 43" , 0.0 , 1 ), odr::LaneKey (" 41" , 0.0 , 1 ));
14
- REQUIRE (path.size () == 15 );
15
-
16
12
for (const odr::Road& road : odr_map.get_roads ())
17
13
{
18
14
INFO (" road: " << road.id << " , length: " << road.length );
@@ -30,4 +26,38 @@ TEST_CASE("Basic OpenDriveMap check", "[xodr]")
30
26
}
31
27
}
32
28
}
29
+ }
30
+
31
+ TEST_CASE (" routing check" , " [routing]" )
32
+ {
33
+ odr::OpenDriveMap odr_map (" test.xodr" );
34
+
35
+ const odr::RoutingGraph graph = odr_map.get_routing_graph ();
36
+
37
+ std::vector<odr::LaneKey> path, expected_path;
38
+ const odr::LaneKey posA (" 43" , 0.0 , 1 );
39
+ const odr::LaneKey posB (" 41" , 0.0 , 1 );
40
+ const odr::LaneKey posC (" 13" , 0.0 , -1 );
41
+ const odr::LaneKey posNaN (" no-exists" , 0.0 , 1 );
42
+
43
+ path = graph.shortest_path (posA, posB);
44
+ REQUIRE (path.size () == 15 );
45
+ REQUIRE (path.front () == posA);
46
+ REQUIRE (path.back () == posB);
47
+
48
+ path = graph.shortest_path (posA, posA);
49
+ REQUIRE (path.size () == 1 );
50
+ REQUIRE (path.front () == posA);
51
+
52
+ path = graph.shortest_path (posC, posB);
53
+ expected_path = {posC,
54
+ odr::LaneKey (" 405" , 0.0 , -1 ),
55
+ odr::LaneKey (" 405" , 14.0521019230889283591068306122906506061553955078125 , -1 ),
56
+ odr::LaneKey (" 16" , 0.0 , -1 ),
57
+ odr::LaneKey (" 17" , 0.0 , -1 ),
58
+ odr::LaneKey (" 18" , 0.0 , -1 ),
59
+ odr::LaneKey (" 747" , 0.0 , -1 ),
60
+ odr::LaneKey (" 747" , 1.76237248299736393164494074881076812744140625 , -1 ),
61
+ posB};
62
+ REQUIRE_THAT (path, Catch::Matchers::Equals (expected_path));
33
63
}
0 commit comments