Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 : : //
3 : : // Copyright (C) 2018-2021 Intel Corporation
4 : : //
5 : : // SPDX-License-Identifier: MIT
6 : : //
7 : : // ----------------- END LICENSE BLOCK -----------------------------------
8 : :
9 : : #include "FactoryTests.hpp"
10 : : #include <ad/map/access/Factory.hpp>
11 : : #include <ad/map/access/Operation.hpp>
12 : : #include <ad/map/landmark/LandmarkOperation.hpp>
13 : : #include <ad/map/lane/ContactOperation.hpp>
14 : : #include <ad/map/lane/LaneOperation.hpp>
15 : : #include <ad/map/point/PointOperation.hpp>
16 : : #include <ad/map/restriction/RestrictionOperation.hpp>
17 : : #include <ad/map/test_support/NoLogTestMacros.hpp>
18 : : #include <gtest/gtest.h>
19 : : #include "../point/RandomGeometry.hpp"
20 : : #include "ad/map/point/BoundingSphereOperation.hpp"
21 : :
22 : : using namespace ::ad;
23 : : using namespace ::ad::map;
24 : : using namespace ::ad::map::access;
25 : : using namespace ::ad::map::point;
26 : :
27 : 7 : FactoryTest::FactoryTest()
28 : : {
29 : 7 : }
30 : :
31 : 7 : void FactoryTest::SetUp()
32 : : {
33 : 7 : access::cleanup();
34 : 7 : mVehicle.type = restriction::RoadUserType::INVALID;
35 : 7 : mVehicle.passengers = restriction::PassengerCount(2);
36 : 7 : mVehicle.length = physics::Distance(4.4);
37 : 7 : mVehicle.width = physics::Distance(2.2);
38 : 7 : mVehicle.height = physics::Distance(3.3);
39 : 7 : mVehicle.weight = physics::Weight(3000.);
40 [ + - ]: 7 : mStorePtr.reset(new access::Store());
41 : 7 : pFactory.reset(new access::Factory(*mStorePtr));
42 : 7 : Fill();
43 : 7 : }
44 : :
45 : 7 : void FactoryTest::TearDown()
46 : : {
47 : 7 : access::cleanup();
48 : 7 : }
49 : :
50 : 7 : bool FactoryTest::Fill()
51 : : {
52 : 7 : bool ok = false;
53 : :
54 : 7 : access::PartitionId p(0);
55 : :
56 [ + - ]: 7 : ok = pFactory->set(access::TrafficType::RIGHT_HAND_TRAFFIC);
57 : :
58 [ + - + - : 7 : ok = ok && pFactory->add(p, x11, lane::LaneType::NORMAL, lane::LaneDirection::POSITIVE);
+ - ]
59 [ + - + - : 7 : ok = ok && pFactory->add(p, x12, lane::LaneType::SHOULDER, lane::LaneDirection::NEGATIVE);
+ - ]
60 [ + - + - : 7 : ok = ok && pFactory->add(p, x13, lane::LaneType::MULTI, lane::LaneDirection::BIDIRECTIONAL);
+ - ]
61 : :
62 [ + - ]: 7 : edgeLeft11 = randGeometry(51, 11);
63 [ + - ]: 7 : edgeRight11 = randGeometry(edgeLeft11.ecefEdge.front(), 52, 12);
64 [ + - + - : 7 : ok = ok && pFactory->set(x11, edgeLeft11, edgeRight11);
+ - ]
65 [ + - ]: 7 : edgeLeft12 = randGeometry(edgeRight11.ecefEdge.front(), 53, 13);
66 [ + - ]: 7 : edgeRight12 = randGeometry(edgeLeft12.ecefEdge.front(), 54, 14);
67 [ + - + - : 7 : ok = ok && pFactory->set(x12, edgeLeft12, edgeRight12);
+ - ]
68 [ + - ]: 7 : edgeLeft13 = randGeometry(edgeRight12.ecefEdge.front(), 55, 15);
69 [ + - ]: 7 : edgeRight13 = randGeometry(edgeLeft13.ecefEdge.front(), 56, 16);
70 [ + - + - : 7 : ok = ok && pFactory->set(x13, edgeLeft13, edgeRight13);
+ - ]
71 : :
72 : 7 : lane::ContactLocation succ(lane::ContactLocation::SUCCESSOR);
73 : 7 : lane::ContactLocation pred(lane::ContactLocation::PREDECESSOR);
74 : 7 : lane::ContactLocation left(lane::ContactLocation::LEFT);
75 : 7 : lane::ContactLocation righ(lane::ContactLocation::RIGHT);
76 : :
77 [ + - ]: 14 : lane::ContactTypeList free({lane::ContactType::FREE});
78 [ + - ]: 14 : lane::ContactTypeList curb_up({lane::ContactType::FREE, lane::ContactType::CURB_UP});
79 [ + - ]: 14 : lane::ContactTypeList curb_down({lane::ContactType::FREE, lane::ContactType::CURB_DOWN});
80 : :
81 : 14 : restriction::Restriction all_vehicles;
82 : : all_vehicles.roadUserTypes
83 [ + - ]: 7 : = {restriction::RoadUserType::CAR, restriction::RoadUserType::BUS, restriction::RoadUserType::TRUCK};
84 : 14 : restriction::Restriction pedestrians;
85 [ + - ]: 7 : pedestrians.roadUserTypes = {restriction::RoadUserType::PEDESTRIAN};
86 : 14 : restriction::Restriction predestrian_and_bikes;
87 [ + - ]: 7 : predestrian_and_bikes.roadUserTypes = {restriction::RoadUserType::PEDESTRIAN, restriction::RoadUserType::BICYCLE};
88 : :
89 : 14 : restriction::RestrictionList all_vehicles_list;
90 [ + - ]: 7 : all_vehicles_list.push_back(all_vehicles);
91 : :
92 : 14 : restriction::RestrictionList pedestrian_list;
93 [ + - ]: 7 : pedestrian_list.push_back(pedestrians);
94 : :
95 : 14 : restriction::RestrictionList pedestrian_and_bikes_list;
96 [ + - ]: 7 : pedestrian_and_bikes_list.push_back(predestrian_and_bikes);
97 : :
98 : 14 : restriction::Restrictions all_vehicle_restrs;
99 [ + - ]: 7 : all_vehicle_restrs.conjunctions = all_vehicles_list;
100 : 14 : restriction::Restrictions pedestrian_restrs;
101 [ + - ]: 7 : pedestrian_restrs.conjunctions = pedestrian_list;
102 : 14 : restriction::Restrictions pedestrian_and_bikes_restrs;
103 [ + - ]: 7 : pedestrian_and_bikes_restrs.conjunctions = pedestrian_and_bikes_list;
104 : :
105 [ + - + - : 7 : ok = ok && pFactory->set(x11, all_vehicle_restrs);
+ - ]
106 [ + - + - : 7 : ok = ok && pFactory->set(x12, pedestrian_restrs);
+ - ]
107 [ + - + - : 7 : ok = ok && pFactory->set(x13, pedestrian_and_bikes_restrs);
+ - ]
108 : :
109 [ + - + - : 7 : ok = ok && pFactory->add(x11, x12, succ, free, all_vehicle_restrs);
+ - ]
110 [ + - + - : 7 : ok = ok && pFactory->add(x12, x11, pred, free, all_vehicle_restrs);
+ - ]
111 [ + - + - : 7 : ok = ok && pFactory->add(x12, x13, left, free, pedestrian_and_bikes_restrs);
+ - ]
112 [ + - + - : 7 : ok = ok && pFactory->add(x13, x12, righ, free, pedestrian_restrs);
+ - ]
113 [ + - + - : 7 : ok = ok && pFactory->add(x13, x11, succ, curb_up, all_vehicle_restrs);
+ - ]
114 [ + - + - : 7 : ok = ok && pFactory->add(x11, x13, pred, curb_down, all_vehicle_restrs);
+ - ]
115 : :
116 : 7 : landmark::LandmarkId landmarkId(1234);
117 : 7 : point::ECEFPoint orientation = point::createECEFPoint(0., 0., 0.);
118 : 7 : point::ECEFPoint position = point::createECEFPoint(1., 0., 0.);
119 [ + - + - ]: 14 : point::Geometry bounding_box = point::createGeometry({orientation, position}, true);
120 [ + - + - : 7 : ok = ok && pFactory->addLandmark(p, landmarkId, landmark::LandmarkType::UNKNOWN, position, orientation, bounding_box);
+ - ]
121 [ + - + - : 7 : ok = ok && pFactory->add(x11, landmarkId);
+ - ]
122 : :
123 [ + - + - : 7 : ok = ok && access::init(mStorePtr);
+ - + - -
- ]
124 : 14 : return ok;
125 : : }
126 : :
127 : 3 : void FactoryTest::Check(const lane::LaneId &id, lane::LaneType type, lane::LaneDirection direction)
128 : : {
129 [ + - ]: 3 : auto lane = lane::getLanePtr(id);
130 [ - + - - : 3 : ASSERT_TRUE(static_cast<bool>(lane));
- - - - -
- ]
131 [ + - - + : 3 : ASSERT_EQ(lane->id, id);
- - - - -
- ]
132 [ + - - + : 3 : ASSERT_EQ(lane->type, type);
- - - - -
- ]
133 [ + - - + : 3 : ASSERT_EQ(lane->direction, direction);
- - - - -
- ]
134 : : }
135 : :
136 : 3 : void FactoryTest::Check(const lane::LaneId &id, point::Geometry const &edgeLeft, point::Geometry const &edgeRight)
137 : : {
138 [ + - ]: 3 : auto lane = lane::getLanePtr(id);
139 [ - + - - : 3 : ASSERT_TRUE(static_cast<bool>(lane));
- - - - -
- ]
140 [ + - - + : 3 : ASSERT_EQ(lane->edgeLeft, edgeLeft);
- - - - -
- ]
141 [ + - - + : 3 : ASSERT_EQ(lane->edgeRight, edgeRight);
- - - - -
- ]
142 [ + - - + : 3 : ASSERT_NE(lane->edgeLeft, edgeRight);
- - - - -
- ]
143 [ + - - + : 3 : ASSERT_NE(lane->edgeRight, edgeLeft);
- - - - -
- ]
144 : : }
145 : :
146 : 6 : void FactoryTest::Check(const lane::LaneId &id_from,
147 : : const lane::LaneId &id_to,
148 : : lane::ContactLocation location,
149 : : const lane::ContactTypeList &types)
150 : : {
151 [ + - ]: 6 : auto lane = lane::getLanePtr(id_from);
152 [ - + - - : 6 : ASSERT_TRUE(static_cast<bool>(lane));
- - - - -
- ]
153 [ + - + - ]: 9 : for (auto contact_lane : lane->contactLanes)
154 : : {
155 [ + - + + ]: 9 : if (contact_lane.toLane == id_to)
156 : : {
157 [ + - - + : 6 : ASSERT_EQ(contact_lane.location, location);
- - - - -
- ]
158 [ + - - + : 6 : ASSERT_EQ(contact_lane.types, types);
- - - - -
- ]
159 : 6 : return;
160 : : }
161 : : }
162 [ # # # # : 0 : ASSERT_TRUE(false);
# # # # #
# ]
163 : : }
164 : :
165 : 12 : bool FactoryTest::IsAccessOk(const lane::LaneId &id, restriction::RoadUserType road_user_type)
166 : : {
167 [ + - ]: 24 : auto lane = lane::getLanePtr(id);
168 [ + - ]: 12 : if (lane)
169 : : {
170 : 12 : restriction::VehicleDescriptor vehicle = mVehicle;
171 : 12 : vehicle.type = road_user_type;
172 [ + - ]: 12 : return lane::isAccessOk(*lane, vehicle);
173 : : }
174 : : else
175 : : {
176 : 0 : return false;
177 : : }
178 : : }
179 : :
180 : 16 : bool FactoryTest::IsTransitionOk(const lane::LaneId &id_from,
181 : : const lane::LaneId &id_to,
182 : : lane::ContactLocation location,
183 : : restriction::RoadUserType road_user_type)
184 : : {
185 [ + - ]: 32 : auto lane = lane::getLanePtr(id_from);
186 [ + - ]: 16 : if (lane)
187 : : {
188 [ + - + - ]: 24 : for (auto contact_lane : lane->contactLanes)
189 : : {
190 [ + - + + ]: 24 : if (contact_lane.toLane == id_to)
191 : : {
192 [ + + ]: 16 : if (contact_lane.location != location)
193 : : {
194 : 4 : return false;
195 : : }
196 : 12 : restriction::VehicleDescriptor vehicle = mVehicle;
197 : 12 : vehicle.type = road_user_type;
198 [ + - ]: 12 : return lane::isAccessOk(contact_lane, vehicle);
199 : : }
200 : : }
201 : : }
202 : 0 : return false;
203 : : }
204 : :
205 : 2 : TEST_F(FactoryTest, TestFactory)
206 : : {
207 : : MapMetaData emptyMetaData;
208 : 1 : emptyMetaData.trafficType = TrafficType(99);
209 [ + - - + : 1 : ASSERT_FALSE(isValid(emptyMetaData));
- - - - -
- - - ]
210 [ + - ]: 1 : Check(x11, lane::LaneType::NORMAL, lane::LaneDirection::POSITIVE);
211 [ + - ]: 1 : Check(x12, lane::LaneType::SHOULDER, lane::LaneDirection::NEGATIVE);
212 [ + - ]: 1 : Check(x13, lane::LaneType::MULTI, lane::LaneDirection::BIDIRECTIONAL);
213 : :
214 [ + - ]: 1 : Check(x11, edgeLeft11, edgeRight11);
215 [ + - ]: 1 : Check(x12, edgeLeft12, edgeRight12);
216 [ + - ]: 1 : Check(x13, edgeLeft13, edgeRight13);
217 : :
218 : 1 : lane::ContactLocation succ(lane::ContactLocation::SUCCESSOR);
219 : 1 : lane::ContactLocation pred(lane::ContactLocation::PREDECESSOR);
220 : 1 : lane::ContactLocation left(lane::ContactLocation::LEFT);
221 : 1 : lane::ContactLocation righ(lane::ContactLocation::RIGHT);
222 : :
223 [ + - ]: 1 : lane::ContactTypeList free({lane::ContactType::FREE});
224 [ + - ]: 1 : lane::ContactTypeList curb_up({lane::ContactType::FREE, lane::ContactType::CURB_UP});
225 [ + - ]: 1 : lane::ContactTypeList curb_down({lane::ContactType::FREE, lane::ContactType::CURB_DOWN});
226 : :
227 [ + - ]: 1 : Check(x11, x12, succ, free);
228 [ + - ]: 1 : Check(x12, x11, pred, free);
229 [ + - ]: 1 : Check(x12, x13, left, free);
230 [ + - ]: 1 : Check(x13, x12, righ, free);
231 [ + - ]: 1 : Check(x13, x11, succ, curb_up);
232 [ + - ]: 1 : Check(x11, x13, pred, curb_down);
233 : :
234 [ + - - + : 1 : ASSERT_TRUE(IsAccessOk(x11, restriction::RoadUserType::BUS));
- - - - -
- - - ]
235 [ + - - + : 1 : ASSERT_TRUE(IsAccessOk(x11, restriction::RoadUserType::CAR));
- - - - -
- - - ]
236 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x11, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
237 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x11, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
238 : :
239 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x12, restriction::RoadUserType::BUS));
- - - - -
- - - ]
240 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x12, restriction::RoadUserType::CAR));
- - - - -
- - - ]
241 [ + - - + : 1 : ASSERT_TRUE(IsAccessOk(x12, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
242 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x12, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
243 : :
244 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x13, restriction::RoadUserType::BUS));
- - - - -
- - - ]
245 [ + - - + : 1 : ASSERT_FALSE(IsAccessOk(x13, restriction::RoadUserType::CAR));
- - - - -
- - - ]
246 [ + - - + : 1 : ASSERT_TRUE(IsAccessOk(x13, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
247 [ + - - + : 1 : ASSERT_TRUE(IsAccessOk(x13, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
248 : :
249 [ + - - + : 1 : ASSERT_TRUE(IsTransitionOk(x11, x12, succ, restriction::RoadUserType::BUS));
- - - - -
- - - ]
250 [ + - - + : 1 : ASSERT_TRUE(IsTransitionOk(x11, x12, succ, restriction::RoadUserType::CAR));
- - - - -
- - - ]
251 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x11, x12, succ, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
252 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x11, x12, succ, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
253 : :
254 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x12, x13, succ, restriction::RoadUserType::BUS));
- - - - -
- - - ]
255 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x12, x13, succ, restriction::RoadUserType::CAR));
- - - - -
- - - ]
256 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x12, x13, succ, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
257 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x12, x13, succ, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
258 : :
259 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x12, x13, left, restriction::RoadUserType::BUS));
- - - - -
- - - ]
260 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x12, x13, left, restriction::RoadUserType::CAR));
- - - - -
- - - ]
261 [ + - - + : 1 : ASSERT_TRUE(IsTransitionOk(x12, x13, left, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
262 [ + - - + : 1 : ASSERT_TRUE(IsTransitionOk(x12, x13, left, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
263 : :
264 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x13, x12, righ, restriction::RoadUserType::BUS));
- - - - -
- - - ]
265 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x13, x12, righ, restriction::RoadUserType::CAR));
- - - - -
- - - ]
266 [ + - - + : 1 : ASSERT_TRUE(IsTransitionOk(x13, x12, righ, restriction::RoadUserType::PEDESTRIAN));
- - - - -
- - - ]
267 [ + - - + : 1 : ASSERT_FALSE(IsTransitionOk(x13, x12, righ, restriction::RoadUserType::BICYCLE));
- - - - -
- - - ]
268 : :
269 [ + - + - ]: 1 : auto landmarks = lane::getLane(x11).visibleLandmarks;
270 [ + - - + : 1 : ASSERT_EQ(landmarks.size(), 1u);
- - - - -
- ]
271 [ + - - + : 1 : ASSERT_TRUE(landmarks.front() == landmark::LandmarkId(1234));
- - - - -
- - - ]
272 : :
273 [ + - ]: 1 : auto globalLandmarks = landmark::getLandmarks();
274 [ + - - + : 1 : ASSERT_EQ(globalLandmarks.size(), 1u);
- - - - -
- ]
275 [ + - - + : 1 : ASSERT_TRUE(landmarks.front() == globalLandmarks.front());
- - - - -
- - - ]
276 : :
277 : 1 : access::PartitionId p(0);
278 : 1 : lane::LaneId retId;
279 : 1 : GeoEdge leftBorderPoints, rightBorderPoints;
280 [ + - ]: 1 : leftBorderPoints.push_back(createGeoPoint(Longitude(8.3), Latitude(49.2), Altitude(115.)));
281 [ + - ]: 1 : leftBorderPoints.push_back(createGeoPoint(Longitude(8.5), Latitude(49.2), Altitude(115.)));
282 [ + - ]: 1 : rightBorderPoints.push_back(createGeoPoint(Longitude(8.3), Latitude(49.), Altitude(115.)));
283 [ + - ]: 1 : rightBorderPoints.push_back(createGeoPoint(Longitude(8.5), Latitude(49.), Altitude(115.)));
284 : :
285 [ + - ]: 1 : retId = pFactory->add(p, leftBorderPoints, rightBorderPoints);
286 [ + - - + : 1 : ASSERT_NE(lane::LaneId(), retId);
- - - - -
- ]
287 : :
288 : 1 : ad::map::restriction::Restriction rs1;
289 : 1 : ad::map::restriction::Restriction rs2;
290 [ + - ]: 1 : rs1.roadUserTypes = {restriction::RoadUserType::CAR};
291 [ + - ]: 1 : rs2.roadUserTypes = {restriction::RoadUserType::PEDESTRIAN};
292 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->add(x100, rs1, true));
+ - + - -
+ - - - -
- - - - +
- ]
293 [ + - - + : 1 : ASSERT_TRUE(pFactory->add(x11, rs1, true));
- - - - -
- - - ]
294 [ + - - + : 1 : ASSERT_TRUE(pFactory->add(x11, rs2, false));
- - - - -
- - - ]
295 : :
296 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, lane::LaneType::SHOULDER));
+ - + - -
+ - - - -
- - - - +
- ]
297 [ + - - + : 1 : ASSERT_TRUE(pFactory->set(x11, lane::LaneType::SHOULDER));
- - - - -
- - - ]
298 : 1 : lane::ComplianceVersion version1 = 0x20190905;
299 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, version1));
+ - + - -
+ - - - -
- - - - +
- ]
300 [ + - - + : 1 : ASSERT_TRUE(pFactory->set(x11, version1));
- - - - -
- - - ]
301 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, lane::LaneDirection::BIDIRECTIONAL));
+ - + - -
+ - - - -
- - - - +
- ]
302 [ + - - + : 1 : ASSERT_TRUE(pFactory->set(x11, lane::LaneDirection::BIDIRECTIONAL));
- - - - -
- - - ]
303 : :
304 : 1 : ad::physics::Speed speedLimitValue(1e3);
305 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, speedLimitValue));
+ - + - -
+ - - - -
- - - - +
- ]
306 : :
307 [ + - - + : 1 : ASSERT_TRUE(pFactory->set(x11, globalLandmarks));
- - - - -
- - - ]
308 : :
309 [ + - - + : 1 : ASSERT_TRUE(pFactory->deleteLane(x12));
- - - - -
- - - ]
310 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->deleteLane(x100));
+ - + - -
+ - - - -
- - - - +
- ]
311 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->deleteLane(xInValid));
+ - + - -
+ - - - -
- - - - +
- ]
312 : :
313 : 1 : landmark::LandmarkId landMarkInvalid;
314 [ + - - + : 1 : ASSERT_TRUE(pFactory->add(x11, landMarkInvalid)); // bugs?
- - - - -
- - - ]
315 : :
316 : 1 : landmark::LandmarkId landmarkId(1234);
317 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->add(x100, landmarkId));
+ - + - -
+ - - - -
- - - - +
- ]
318 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->deleteLandmark(landMarkInvalid));
+ - + - -
+ - - - -
- - - - +
- ]
319 [ + - - + : 1 : ASSERT_TRUE(pFactory->deleteLandmark(landmarkId));
- - - - -
- - - ]
320 : :
321 : 1 : restriction::Restriction all_vehicles;
322 : : all_vehicles.roadUserTypes
323 [ + - ]: 1 : = {restriction::RoadUserType::CAR, restriction::RoadUserType::BUS, restriction::RoadUserType::TRUCK};
324 : 1 : restriction::RestrictionList all_vehicles_list;
325 [ + - ]: 1 : all_vehicles_list.push_back(all_vehicles);
326 : 1 : restriction::Restrictions all_vehicle_restrs;
327 [ + - ]: 1 : all_vehicle_restrs.conjunctions = all_vehicles_list;
328 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, all_vehicle_restrs));
+ - + - -
+ - - - -
- - - - +
- ]
329 : :
330 : 1 : ad::map::lane::ContactLaneList cLaneList;
331 : 1 : lane::ContactLane contactLane;
332 : 1 : contactLane.toLane = x12;
333 : 1 : contactLane.location = succ;
334 [ + - ]: 1 : contactLane.types = free;
335 [ + - ]: 1 : contactLane.restrictions = all_vehicle_restrs;
336 : 1 : contactLane.trafficLightId = ad::map::landmark::LandmarkId();
337 [ + - ]: 1 : cLaneList.push_back(contactLane);
338 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->add(x100, cLaneList));
+ - + - -
+ - - - -
- - - - +
- ]
339 [ + - - + : 1 : ASSERT_TRUE(pFactory->add(x11, cLaneList));
- - - - -
- - - ]
340 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->deleteContacts(xInValid, x12));
+ - + - -
+ - - - -
- - - - +
- ]
341 [ + - - + : 1 : ASSERT_TRUE(pFactory->deleteContacts(x11, x12));
- - - - -
- - - ]
342 : :
343 : 1 : lane::LaneId x14{14}, x15{15}, x16{16};
344 : 1 : GeoEdge x14Left, x14Right, x15Left, x15Right, x16Left, x16Right;
345 [ + - ]: 1 : x14Left.push_back(createGeoPoint(Longitude(8.3), Latitude(49.2), Altitude(115.)));
346 [ + - ]: 1 : x14Left.push_back(createGeoPoint(Longitude(8.5), Latitude(49.2), Altitude(115.)));
347 [ + - ]: 1 : x14Right.push_back(createGeoPoint(Longitude(8.3), Latitude(49.), Altitude(115.)));
348 [ + - ]: 1 : x14Right.push_back(createGeoPoint(Longitude(8.5), Latitude(49.), Altitude(115.)));
349 [ + - ]: 1 : x15Left.push_back(createGeoPoint(Longitude(8.5), Latitude(49.2), Altitude(115.)));
350 [ + - ]: 1 : x15Left.push_back(createGeoPoint(Longitude(8.7), Latitude(49.2), Altitude(115.)));
351 [ + - ]: 1 : x15Right.push_back(createGeoPoint(Longitude(8.5), Latitude(49.), Altitude(115.)));
352 [ + - ]: 1 : x15Right.push_back(createGeoPoint(Longitude(8.7), Latitude(49.), Altitude(115.)));
353 [ + - ]: 1 : x16Left.push_back(createGeoPoint(Longitude(8.7), Latitude(49.2), Altitude(115.)));
354 [ + - ]: 1 : x16Left.push_back(createGeoPoint(Longitude(8.9), Latitude(49.2), Altitude(115.)));
355 [ + - ]: 1 : x16Right.push_back(createGeoPoint(Longitude(8.7), Latitude(49.), Altitude(115.)));
356 [ + - ]: 1 : x16Right.push_back(createGeoPoint(Longitude(8.9), Latitude(49.), Altitude(115.)));
357 [ + - ]: 1 : x14 = pFactory->add(p, x14Left, x14Right);
358 [ + - - + : 1 : ASSERT_NE(x14, lane::LaneId());
- - - - -
- ]
359 [ + - ]: 1 : x16 = pFactory->add(p, x16Left, x16Right);
360 [ + - - + : 1 : ASSERT_NE(x16, lane::LaneId());
- - - - -
- ]
361 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->autoConnect(xInValid, x14));
+ - + - -
+ - - - -
- - - - +
- ]
362 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->autoConnect(x100, x14));
+ - + - -
+ - - - -
- - - - +
- ]
363 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->autoConnect(x14, x100));
+ - + - -
+ - - - -
- - - - +
- ]
364 [ + - - + : 1 : ASSERT_FALSE(pFactory->autoConnect(x14, x16));
- - - - -
- - - ]
365 : 1 : lane::LaneId x17{17};
366 : 1 : GeoEdge x17Left, x17Right;
367 [ + - ]: 1 : x17Left.push_back(createGeoPoint(Longitude(8.5), Latitude(49.2), Altitude(115.)));
368 [ + - ]: 1 : x17Left.push_back(createGeoPoint(Longitude(8.9), Latitude(49.2), Altitude(115.)));
369 [ + - ]: 1 : x17Right.push_back(createGeoPoint(Longitude(8.5), Latitude(49.), Altitude(115.)));
370 [ + - ]: 1 : x17Right.push_back(createGeoPoint(Longitude(8.9), Latitude(49.), Altitude(115.)));
371 [ + - ]: 1 : x17 = pFactory->add(p, x17Left, x17Right);
372 [ + - - + : 1 : ASSERT_NE(x17, lane::LaneId());
- - - - -
- ]
373 [ + - - + : 1 : ASSERT_TRUE(pFactory->autoConnect(x16, x17));
- - - - -
- - - ]
374 : 1 : lane::LaneId x18{18};
375 : 1 : GeoEdge x18Left, x18Right;
376 [ + - ]: 1 : x18Left.push_back(createGeoPoint(Longitude(8.5), Latitude(49.2), Altitude(115.)));
377 [ + - ]: 1 : x18Left.push_back(createGeoPoint(Longitude(8.9), Latitude(49.2), Altitude(115.)));
378 [ + - ]: 1 : x18Right.push_back(createGeoPoint(Longitude(8.5), Latitude(49.), Altitude(115.)));
379 [ + - ]: 1 : x18Right.push_back(createGeoPoint(Longitude(8.9), Latitude(49.), Altitude(115.)));
380 [ + - ]: 1 : x18 = pFactory->add(p, x18Left, x18Right);
381 [ + - - + : 1 : ASSERT_NE(x18, lane::LaneId());
- - - - -
- ]
382 [ + - - + : 1 : ASSERT_TRUE(pFactory->autoConnect(x17, x18));
- - - - -
- - - ]
383 : :
384 : 1 : point::Geometry leftGeo, rightGeo;
385 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, leftGeo, rightGeo));
+ - + - -
+ - - - -
- - - - +
- ]
386 : :
387 [ + - ]: 1 : point::CoordinateTransform cf;
388 : 1 : point::ECEFEdge left_ecef;
389 : 1 : point::ECEFEdge right_ecef;
390 [ + - ]: 1 : cf.convert(x15Left, left_ecef);
391 [ + - ]: 1 : cf.convert(x15Right, right_ecef);
392 [ + - + - : 2 : EXPECT_THROW_NO_LOG(pFactory->add(p, left_ecef, right_ecef, x11, x12), std::runtime_error);
+ - + - +
- + - - +
- + - - -
- - - + -
- - ]
393 [ + - ]: 1 : retId = pFactory->add(p, left_ecef, right_ecef, x14, x16);
394 [ + - - + : 1 : ASSERT_NE(retId, lane::LaneId());
- - - - -
- ]
395 : :
396 : 1 : restriction::SpeedLimit speedLimit;
397 : 1 : speedLimit.speedLimit = physics::Speed(50.);
398 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->add(x100, speedLimit));
+ - + - -
+ - - - -
- - - - +
- ]
399 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, physics::Speed(50.)));
+ - + - -
+ - - - -
- - - - +
- ]
400 [ + - + - : 2 : ASSERT_TRUE_NO_LOG(pFactory->add(x11, speedLimit));
+ - + - -
+ - - - -
- - - - +
- ]
401 : 1 : speedLimit.speedLimit = physics::Speed(80.);
402 [ + - + - : 2 : ASSERT_TRUE_NO_LOG(pFactory->add(x11, speedLimit));
+ - + - -
+ - - - -
- - - - +
- ]
403 [ + - - + : 1 : ASSERT_TRUE(pFactory->set(x11, physics::Speed(50.)));
- - - - -
- - - ]
404 : :
405 : 1 : landmark::LandmarkIdList landMarkList;
406 [ + - + - : 2 : ASSERT_FALSE_NO_LOG(pFactory->set(x100, landMarkList));
+ - + - -
+ - - - -
- - - - +
- ]
407 : : }
408 : :
409 : 2 : TEST_F(FactoryTest, TestRestriction)
410 : : {
411 : 1 : restriction::Restriction all_vehicles;
412 : 1 : restriction::VehicleDescriptor vehicle;
413 : :
414 [ + - + - : 2 : EXPECT_THROW_NO_LOG(isAccessOk(all_vehicles, vehicle), std::runtime_error);
+ - + - +
- + - - +
- + - - -
- - - + -
- - ]
415 : :
416 : : all_vehicles.roadUserTypes
417 [ + - ]: 1 : = {restriction::RoadUserType::CAR, restriction::RoadUserType::BUS, restriction::RoadUserType::TRUCK};
418 : 1 : all_vehicles.negated = true;
419 : 1 : vehicle = mVehicle;
420 : 1 : all_vehicles.passengersMin = restriction::PassengerCount(3);
421 [ + - - + : 1 : ASSERT_TRUE(isAccessOk(all_vehicles, vehicle));
- - - - -
- - - ]
422 : 1 : vehicle.passengers = restriction::PassengerCount(4);
423 : 1 : all_vehicles.roadUserTypes.clear();
424 [ + - - + : 1 : ASSERT_FALSE(isAccessOk(all_vehicles, vehicle));
- - - - -
- - - ]
425 : :
426 : 1 : restriction::Restrictions roadRestrictions;
427 [ + - - + : 1 : ASSERT_TRUE(isAccessOk(roadRestrictions, vehicle));
- - - - -
- - - ]
428 : :
429 : 1 : restriction::Restriction pedestrians;
430 [ + - ]: 1 : pedestrians.roadUserTypes = {restriction::RoadUserType::PEDESTRIAN};
431 : 1 : pedestrians.passengersMin = 5.;
432 : 1 : pedestrians.negated = true;
433 [ + - ]: 1 : roadRestrictions.disjunctions.push_back(pedestrians);
434 [ + - - + : 1 : ASSERT_TRUE(isAccessOk(roadRestrictions, vehicle));
- - - - -
- - - ]
435 : :
436 : 1 : restriction::Restriction roadRestriction;
437 : 1 : roadRestriction.negated = false;
438 : 1 : roadRestriction.passengersMin = 4.;
439 : : roadRestriction.roadUserTypes
440 [ + - ]: 1 : = {restriction::RoadUserType::CAR, restriction::RoadUserType::BUS, restriction::RoadUserType::TRUCK};
441 [ + - ]: 1 : roadRestrictions.conjunctions.push_back(roadRestriction);
442 : 1 : restriction::PassengerCount ret(5.);
443 [ + - + - : 1 : ASSERT_EQ(getHOV(roadRestrictions), ret);
- + - - -
- - - ]
444 [ + - ]: 1 : mStorePtr->removePartition(access::PartitionId(0));
445 [ + - - + : 1 : ASSERT_TRUE(mStorePtr->empty());
- - - - -
- - - ]
446 : : }
447 : :
448 : 2 : TEST_F(FactoryTest, Store)
449 : : {
450 [ + - - + : 1 : ASSERT_FALSE(mStorePtr->empty());
- - - - -
- - - ]
451 [ + - ]: 1 : auto laneIdList = mStorePtr->getLanes(access::PartitionId(0));
452 [ + - - + : 1 : ASSERT_EQ(laneIdList.size(), 3u);
- - - - -
- ]
453 [ + - - + : 1 : ASSERT_EQ(laneIdList[0], lane::LaneId(11));
- - - - -
- ]
454 [ + - - + : 1 : ASSERT_EQ(laneIdList[1], lane::LaneId(12));
- - - - -
- ]
455 [ + - - + : 1 : ASSERT_EQ(laneIdList[2], lane::LaneId(13));
- - - - -
- ]
456 : :
457 [ + - ]: 1 : auto laneMarkIdList = mStorePtr->getLandmarks(access::PartitionId(0));
458 [ + - - + : 1 : ASSERT_EQ(laneMarkIdList.size(), 1u);
- - - - -
- ]
459 [ + - - + : 1 : ASSERT_EQ(laneMarkIdList[0], landmark::LandmarkId(1234));
- - - - -
- ]
460 : : }
461 : 2 : TEST_F(FactoryTest, StoreLaneLength)
462 : : {
463 [ + - ]: 1 : access::cleanup();
464 [ + - + - : 1 : mStorePtr.reset(new access::Store());
+ - ]
465 [ + - + - ]: 1 : pFactory.reset(new access::Factory(*mStorePtr));
466 : :
467 : 1 : point::Geometry geo1, geo2;
468 : 1 : point::ECEFEdge leftPoints;
469 [ + - ]: 1 : point::ECEFPoint basePoint = randECEFPoint();
470 [ + - ]: 1 : leftPoints.push_back(basePoint);
471 [ + - + - ]: 1 : leftPoints.push_back(basePoint + point::createECEFPoint(70., 0., 0.));
472 [ + - ]: 1 : geo1 = point::createGeometry(leftPoints, false);
473 : 1 : point::ECEFEdge rightPoints;
474 [ + - + - ]: 1 : rightPoints.push_back(basePoint + point::createECEFPoint(0., -10, 0.));
475 [ + - + - ]: 1 : rightPoints.push_back(basePoint + point::createECEFPoint(70., -10, 0.));
476 [ + - ]: 1 : geo2 = point::createGeometry(rightPoints, false);
477 [ + - ]: 1 : pFactory->set(access::TrafficType::RIGHT_HAND_TRAFFIC);
478 : :
479 [ + - ]: 1 : pFactory->add(access::PartitionId(0), lane::LaneId(11), lane::LaneType::NORMAL, lane::LaneDirection::POSITIVE);
480 : :
481 [ + - ]: 1 : pFactory->set(lane::LaneId(11), geo1, geo2);
482 [ + - ]: 1 : access::init(mStorePtr);
483 [ + - ]: 1 : calcBoundingSphere(geo1, geo2);
484 [ + - ]: 1 : auto ret = mStorePtr->getCumulativeLaneLength();
485 [ + - - + : 1 : ASSERT_DOUBLE_EQ(static_cast<double>(ret), 70.0);
- - - - -
- ]
486 : :
487 : 1 : lane::LaneIdList laneIdList;
488 [ + - + - ]: 1 : laneIdList = mStorePtr->getLanes(std::string("abc"), false);
489 [ + - - + : 1 : ASSERT_EQ(laneIdList.size(), 0u);
- - - - -
- ]
490 [ + - + - ]: 1 : laneIdList = mStorePtr->getLanes(std::string("::ad::map::lane::LaneType::NORMAL"), false);
491 [ + - - + : 1 : ASSERT_EQ(laneIdList.size(), 1u);
- - - - -
- ]
492 : :
493 [ + - + - ]: 1 : laneIdList = mStorePtr->getLanes(access::PartitionId(0), std::string("abc"), false);
494 [ + - - + : 1 : ASSERT_EQ(laneIdList.size(), 0u);
- - - - -
- ]
495 [ + - + - ]: 1 : laneIdList = mStorePtr->getLanes(access::PartitionId(0), std::string("::ad::map::lane::LaneType::NORMAL"), false);
496 [ + - - + : 1 : ASSERT_EQ(laneIdList.size(), 1u);
- - - - -
- ]
497 : : }
|