LCOV - code coverage report
Current view: top level - tests/opendrive - OpenDriveAccessTests.cpp (source / functions) Hit Total Coverage
Test: ad_map_access Lines: 282 298 94.6 %
Date: 2022-10-04 09:48:07 Functions: 35 35 100.0 %
Branches: 490 1772 27.7 %

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2020-2021 Intel Corporation
       4                 :            : //
       5                 :            : // SPDX-License-Identifier: MIT
       6                 :            : //
       7                 :            : // ----------------- END LICENSE BLOCK -----------------------------------
       8                 :            : 
       9                 :            : #include <../src/opendrive/DataTypeConversion.hpp>
      10                 :            : #include <ad/map/access/Operation.hpp>
      11                 :            : #include <ad/map/access/Store.hpp>
      12                 :            : #include <ad/map/config/MapConfigFileHandler.hpp>
      13                 :            : #include <ad/map/intersection/Intersection.hpp>
      14                 :            : #include <ad/map/landmark/LandmarkOperation.hpp>
      15                 :            : #include <ad/map/lane/LaneOperation.hpp>
      16                 :            : #include <ad/map/match/AdMapMatching.hpp>
      17                 :            : #include <ad/map/opendrive/AdMapFactory.hpp>
      18                 :            : #include <ad/map/point/Operation.hpp>
      19                 :            : #include <ad/map/serialize/SerializerFileCRC32.hpp>
      20                 :            : #include <gtest/gtest.h>
      21                 :            : 
      22                 :            : #include <fstream>
      23                 :            : #include <streambuf>
      24                 :            : #include <string>
      25                 :            : 
      26                 :            : using namespace ::ad;
      27                 :            : using namespace ::ad::map;
      28                 :            : using namespace ::ad::map::opendrive;
      29                 :            : using namespace ::ad::map::landmark;
      30                 :            : 
      31                 :            : struct OpenDriveAccessTests : ::testing::Test
      32                 :            : {
      33                 :         15 :   virtual void SetUp()
      34                 :            :   {
      35                 :         15 :     access::cleanup();
      36                 :         15 :   }
      37                 :         15 :   virtual void TearDown()
      38                 :            :   {
      39                 :         15 :     access::cleanup();
      40                 :         15 :   }
      41                 :            : 
      42                 :       5590 :   void checkEdgePoints(lane::LaneId laneId, point::ECEFEdge const &edge)
      43                 :            :   {
      44   [ +  -  -  +  :       5590 :     EXPECT_GE(edge.size(), 2u) << static_cast<uint64_t>(laneId);
          -  -  -  -  -  
                -  -  - ]
      45         [ +  + ]:       5590 :     if (edge.size() > 2u)
      46                 :            :     {
      47         [ +  + ]:      59385 :       for (auto pointIter = edge.begin(); pointIter != edge.end(); pointIter++)
      48                 :            :       {
      49                 :      55883 :         auto nextPointIter = pointIter + 1;
      50         [ +  + ]:      55883 :         if (nextPointIter != edge.end())
      51                 :            :         {
      52         [ +  - ]:      52381 :           auto deltaPoints = *pointIter - *nextPointIter;
      53         [ +  - ]:      52381 :           auto pointDistance = vectorLength(deltaPoints);
      54   [ +  -  -  +  :      52381 :           EXPECT_NE(pointDistance, physics::Distance(0.)) << static_cast<uint64_t>(laneId) << " num: " << edge.size();
          -  -  -  -  -  
          -  -  -  -  -  
                   -  - ]
      55                 :            :         }
      56                 :            :       }
      57                 :            :     }
      58                 :       5590 :     physics::ParametricRange trange;
      59                 :       5590 :     trange.minimum = physics::ParametricValue(0.);
      60                 :       5590 :     trange.maximum = physics::ParametricValue(1.);
      61         [ +  - ]:      11180 :     auto ecefs = point::getParametricRange(edge, trange);
      62   [ +  -  -  +  :       5590 :     EXPECT_EQ(edge.size(), ecefs.size()) << static_cast<uint64_t>(laneId);
          -  -  -  -  -  
                -  -  - ]
      63                 :       5590 :   }
      64                 :            : 
      65                 :       2795 :   void checkEdgeContacts(lane::Lane const &lane)
      66                 :            :   {
      67         [ +  + ]:       2795 :     if (lane::isRouteable(lane))
      68                 :            :     {
      69   [ +  -  +  +  :       2462 :       for (auto successorContact : lane::getContactLanes(lane, lane::ContactLocation::SUCCESSOR))
                   +  - ]
      70                 :            :       {
      71   [ +  -  +  - ]:       2892 :         auto successorLane = lane::getLane(successorContact.toLane);
      72         [ +  + ]:       1446 :         if (successorLane.direction == lane.direction)
      73                 :            :         {
      74   [ +  -  -  +  :       1199 :           EXPECT_EQ(lane.edgeLeft.ecefEdge.back(), successorLane.edgeLeft.ecefEdge.front())
          -  -  -  -  -  
                      - ]
      75   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " succ: " << static_cast<uint64_t>(successorLane.id);
                   #  # ]
      76   [ +  -  -  +  :       1199 :           EXPECT_EQ(lane.edgeRight.ecefEdge.back(), successorLane.edgeRight.ecefEdge.front())
          -  -  -  -  -  
                      - ]
      77   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " succ: " << static_cast<uint64_t>(successorLane.id);
                   #  # ]
      78                 :            :         }
      79                 :            :         else
      80                 :            :         {
      81   [ +  -  -  +  :        247 :           EXPECT_EQ(lane.edgeLeft.ecefEdge.back(), successorLane.edgeRight.ecefEdge.back())
          -  -  -  -  -  
                      - ]
      82   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " succ: " << static_cast<uint64_t>(successorLane.id);
                   #  # ]
      83   [ +  -  -  +  :        247 :           EXPECT_EQ(lane.edgeRight.ecefEdge.back(), successorLane.edgeLeft.ecefEdge.back())
          -  -  -  -  -  
                      - ]
      84   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " succ: " << static_cast<uint64_t>(successorLane.id);
                   #  # ]
      85                 :            :         }
      86                 :            :       }
      87   [ +  -  +  +  :       2461 :       for (auto predecessorContact : lane::getContactLanes(lane, lane::ContactLocation::PREDECESSOR))
                   +  - ]
      88                 :            :       {
      89   [ +  -  +  - ]:       2890 :         auto predecessorLane = lane::getLane(predecessorContact.toLane);
      90         [ +  + ]:       1445 :         if (predecessorLane.direction == lane.direction)
      91                 :            :         {
      92   [ +  -  -  +  :       1207 :           EXPECT_EQ(lane.edgeLeft.ecefEdge.front(), predecessorLane.edgeLeft.ecefEdge.back())
          -  -  -  -  -  
                      - ]
      93   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " pre: " << static_cast<uint64_t>(predecessorLane.id);
                   #  # ]
      94   [ +  -  -  +  :       1207 :           EXPECT_EQ(lane.edgeRight.ecefEdge.front(), predecessorLane.edgeRight.ecefEdge.back())
          -  -  -  -  -  
                      - ]
      95   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " pre: " << static_cast<uint64_t>(predecessorLane.id);
                   #  # ]
      96                 :            :         }
      97                 :            :         else
      98                 :            :         {
      99   [ +  -  -  +  :        238 :           EXPECT_EQ(lane.edgeLeft.ecefEdge.front(), predecessorLane.edgeRight.ecefEdge.front())
          -  -  -  -  -  
                      - ]
     100   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " pre: " << static_cast<uint64_t>(predecessorLane.id);
                   #  # ]
     101   [ +  -  -  +  :        238 :           EXPECT_EQ(lane.edgeRight.ecefEdge.front(), predecessorLane.edgeLeft.ecefEdge.front())
          -  -  -  -  -  
                      - ]
     102   [ #  #  #  #  :          0 :             << static_cast<uint64_t>(lane.id) << " pre: " << static_cast<uint64_t>(predecessorLane.id);
                   #  # ]
     103                 :            :         }
     104                 :            :       }
     105   [ +  -  +  +  :       1856 :       for (auto leftContact : lane::getContactLanes(lane, lane::ContactLocation::LEFT))
                   +  - ]
     106                 :            :       {
     107   [ +  -  +  - ]:       1680 :         auto leftLane = lane::getLane(leftContact.toLane);
     108   [ +  -  -  +  :        840 :         EXPECT_EQ(lane.edgeLeft.ecefEdge.front(), leftLane.edgeRight.ecefEdge.front())
          -  -  -  -  -  
                      - ]
     109   [ #  #  #  #  :          0 :           << static_cast<uint64_t>(lane.id) << " left: " << static_cast<uint64_t>(leftLane.id);
                   #  # ]
     110   [ +  -  -  +  :        840 :         EXPECT_EQ(lane.edgeLeft.ecefEdge.back(), leftLane.edgeRight.ecefEdge.back())
          -  -  -  -  -  
                      - ]
     111   [ #  #  #  #  :          0 :           << static_cast<uint64_t>(lane.id) << " left: " << static_cast<uint64_t>(leftLane.id);
                   #  # ]
     112                 :            :       }
     113   [ +  -  +  +  :       1860 :       for (auto rightContact : lane::getContactLanes(lane, lane::ContactLocation::RIGHT))
                   +  - ]
     114                 :            :       {
     115   [ +  -  +  - ]:       1688 :         auto rightLane = lane::getLane(rightContact.toLane);
     116   [ +  -  -  +  :        844 :         EXPECT_EQ(lane.edgeRight.ecefEdge.front(), rightLane.edgeLeft.ecefEdge.front())
          -  -  -  -  -  
                      - ]
     117   [ #  #  #  #  :          0 :           << static_cast<uint64_t>(lane.id) << " right: " << static_cast<uint64_t>(rightLane.id);
                   #  # ]
     118   [ +  -  -  +  :        844 :         EXPECT_EQ(lane.edgeRight.ecefEdge.back(), rightLane.edgeLeft.ecefEdge.back())
          -  -  -  -  -  
                      - ]
     119   [ #  #  #  #  :          0 :           << static_cast<uint64_t>(lane.id) << " right: " << static_cast<uint64_t>(rightLane.id);
                   #  # ]
     120                 :            :       }
     121                 :            :     }
     122                 :       2795 :   }
     123                 :            : 
     124                 :       1156 :   void checkAreaMapMatching(lane::LaneIdSet const &lanesToTest, lane::LaneIdSet const &lanesTestArea)
     125                 :            :   {
     126         [ +  - ]:       2312 :     match::AdMapMatching mapMatching;
     127         [ +  - ]:       1156 :     mapMatching.setRelevantLanes(lanesTestArea);
     128                 :            : 
     129         [ +  + ]:       1456 :     for (auto laneId : lanesToTest)
     130                 :            :     {
     131   [ +  -  +  - ]:        600 :       auto lane = lane::getLane(laneId);
     132         [ +  - ]:        300 :       auto ecefPoint0 = lane::getParametricPoint(lane, physics::ParametricValue(0.), physics::ParametricValue(.5));
     133         [ +  - ]:        300 :       auto enuPoint0 = point::toENU(ecefPoint0);
     134                 :            :       auto mapMatchedPositions0
     135         [ +  - ]:        600 :         = mapMatching.getMapMatchedPositions(enuPoint0, physics::Distance(5.), physics::Probability(0.));
     136         [ +  - ]:        300 :       auto ecefPoint1 = lane::getParametricPoint(lane, physics::ParametricValue(1.), physics::ParametricValue(.5));
     137         [ +  - ]:        300 :       auto enuPoint1 = point::toENU(ecefPoint1);
     138                 :            :       auto mapMatchedPositions1
     139         [ +  - ]:        600 :         = mapMatching.getMapMatchedPositions(enuPoint1, physics::Distance(5.), physics::Probability(0.));
     140                 :            :       auto contactLanes = lane::getContactLanes(lane,
     141                 :            :                                                 {lane::ContactLocation::LEFT,
     142                 :            :                                                  lane::ContactLocation::RIGHT,
     143                 :            :                                                  lane::ContactLocation::SUCCESSOR,
     144   [ +  -  +  - ]:        900 :                                                  lane::ContactLocation::PREDECESSOR});
     145                 :        600 :       lane::LaneIdSet expectedLanes;
     146         [ +  - ]:        300 :       expectedLanes.insert(lane.id);
     147   [ +  +  +  - ]:       1664 :       for (auto contactLane : contactLanes)
     148                 :            :       {
     149   [ +  -  +  + ]:       1364 :         if (lanesTestArea.find(contactLane.toLane) != lanesTestArea.end())
     150                 :            :         {
     151         [ +  - ]:        883 :           expectedLanes.insert(contactLane.toLane);
     152                 :            :         }
     153                 :            :       }
     154   [ +  -  -  +  :        300 :       EXPECT_NE(expectedLanes.size(), 0u);
          -  -  -  -  -  
                      - ]
     155         [ +  + ]:       2349 :       for (auto const matchedPosition : mapMatchedPositions0)
     156                 :            :       {
     157   [ +  -  -  +  :       2049 :         EXPECT_TRUE(lanesTestArea.find(matchedPosition.lanePoint.paraPoint.laneId) != lanesTestArea.end());
          -  -  -  -  -  
                -  -  - ]
     158         [ +  - ]:       2049 :         expectedLanes.erase(matchedPosition.lanePoint.paraPoint.laneId);
     159                 :            :       }
     160         [ +  + ]:       2161 :       for (auto const matchedPosition : mapMatchedPositions1)
     161                 :            :       {
     162   [ +  -  -  +  :       1861 :         EXPECT_TRUE(lanesTestArea.find(matchedPosition.lanePoint.paraPoint.laneId) != lanesTestArea.end());
          -  -  -  -  -  
                -  -  - ]
     163         [ +  - ]:       1861 :         expectedLanes.erase(matchedPosition.lanePoint.paraPoint.laneId);
     164                 :            :       }
     165                 :            : 
     166   [ +  -  -  +  :        300 :       EXPECT_EQ(expectedLanes.size(), 0u)
          -  -  -  -  -  
                      - ]
     167   [ #  #  #  #  :          0 :         << "LaneID: " << lane.id << " expectedLanes: " << expectedLanes << " testArea: " << lanesTestArea
          #  #  #  #  #  
                #  #  # ]
     168   [ #  #  #  #  :          0 :         << " pos0: " << mapMatchedPositions0 << " pos1: " << mapMatchedPositions1 << " contact: " << contactLanes;
          #  #  #  #  #  
                #  #  # ]
     169                 :            : 
     170   [ +  -  +  -  :        300 :       mapMatching.addHeadingHint(point::createENUHeading(0.), access::getENUReferencePoint());
                   +  - ]
     171   [ +  -  +  + ]:       3600 :       for (auto paramLon = physics::ParametricValue(0.); paramLon <= physics::ParametricValue(1.);
     172         [ +  - ]:       3300 :            paramLon += physics::ParametricValue(0.1))
     173                 :            :       {
     174   [ +  -  +  + ]:      23100 :         for (auto paramLat = physics::ParametricValue(0.); paramLat <= physics::ParametricValue(1.);
     175         [ +  - ]:      19800 :              paramLat += physics::ParametricValue(0.2))
     176                 :            :         {
     177         [ +  - ]:      19800 :           auto ecefPoint = lane::getParametricPoint(lane, paramLon, paramLat);
     178         [ +  - ]:      19800 :           auto enuPoint = point::toENU(ecefPoint);
     179   [ +  -  +  -  :      19800 :           EXPECT_NO_THROW(auto mapMatchedPositions = mapMatching.getMapMatchedPositions(
          +  -  +  -  +  
          -  -  -  -  -  
             -  -  -  - ]
     180                 :            :                             enuPoint, physics::Distance(5.), physics::Probability(0.)));
     181                 :            :         }
     182                 :            :       }
     183                 :            :     }
     184                 :       1156 :   }
     185                 :            : };
     186                 :            : 
     187                 :          2 : TEST_F(OpenDriveAccessTests, read_config)
     188                 :            : {
     189                 :          1 :   config::MapConfigFileHandler configHandler{};
     190   [ +  -  +  -  :          1 :   ASSERT_TRUE(configHandler.readConfig("test_files/Town01.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     191   [ +  -  -  +  :          1 :   ASSERT_TRUE(configHandler.isInitialized());
          -  -  -  -  -  
                -  -  - ]
     192                 :            : }
     193                 :            : 
     194                 :          2 : TEST_F(OpenDriveAccessTests, read_map)
     195                 :            : {
     196   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town01.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     197                 :            : 
     198                 :          1 :   point::Longitude validLon(8.00);
     199                 :          1 :   point::Latitude validLat(49.00);
     200                 :          1 :   point::Altitude validAlt(0.);
     201                 :            : 
     202                 :          1 :   auto p = point::createGeoPoint(validLon, validLat, validAlt);
     203         [ +  - ]:          1 :   access::setENUReferencePoint(p);
     204                 :            : 
     205         [ +  - ]:          1 :   auto lanes = lane::getLanes();
     206   [ +  -  -  +  :          1 :   ASSERT_GT(lanes.size(), 0u);
          -  -  -  -  -  
                      - ]
     207                 :            : 
     208                 :            :   // write map for convenience
     209         [ +  - ]:          2 :   serialize::SerializerFileCRC32 serializer(true);
     210                 :          1 :   size_t versionMajorWrite = ::ad::map::serialize::SerializerFileCRC32::VERSION_MAJOR;
     211                 :          1 :   size_t versionMinorWrite = ::ad::map::serialize::SerializerFileCRC32::VERSION_MINOR;
     212   [ +  -  +  - ]:          1 :   serializer.open("test_files/Town01.adm", versionMajorWrite, versionMinorWrite);
     213   [ +  -  +  - ]:          1 :   access::getStore().save(serializer);
     214         [ +  - ]:          1 :   serializer.close();
     215                 :            : }
     216                 :            : 
     217                 :          2 : TEST_F(OpenDriveAccessTests, read_written_map)
     218                 :            : {
     219   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town01.adm.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     220                 :            : 
     221                 :          1 :   point::Longitude validLon(8.00);
     222                 :          1 :   point::Latitude validLat(49.00);
     223                 :          1 :   point::Altitude validAlt(0.);
     224                 :            : 
     225                 :          1 :   auto p = point::createGeoPoint(validLon, validLat, validAlt);
     226                 :            : 
     227         [ +  - ]:          1 :   access::setENUReferencePoint(p);
     228                 :            : 
     229         [ +  - ]:          1 :   auto lanes = lane::getLanes();
     230   [ +  -  -  +  :          1 :   ASSERT_GT(lanes.size(), 0u);
          -  -  -  -  -  
                      - ]
     231                 :            : }
     232                 :            : 
     233                 :          2 : TEST_F(OpenDriveAccessTests, lane_points_town01)
     234                 :            : {
     235   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town01.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     236                 :            : 
     237   [ +  -  +  + ]:        301 :   for (auto laneId : lane::getLanes())
     238                 :            :   {
     239   [ +  -  +  - ]:        600 :     auto lane = lane::getLane(laneId);
     240         [ +  - ]:        300 :     checkEdgePoints(lane.id, lane.edgeLeft.ecefEdge);
     241         [ +  - ]:        300 :     checkEdgePoints(lane.id, lane.edgeRight.ecefEdge);
     242                 :            :   }
     243                 :            : }
     244                 :            : 
     245                 :          2 : TEST_F(OpenDriveAccessTests, lane_contact_points_town01)
     246                 :            : {
     247   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town01.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     248                 :            : 
     249   [ +  -  +  + ]:        301 :   for (auto laneId : lane::getLanes())
     250                 :            :   {
     251   [ +  -  +  - ]:        600 :     auto lane = lane::getLane(laneId);
     252         [ +  - ]:        300 :     checkEdgeContacts(lane);
     253                 :            :   }
     254                 :            : }
     255                 :            : 
     256                 :          2 : TEST_F(OpenDriveAccessTests, lane_points_town03)
     257                 :            : {
     258   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town03.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     259                 :            : 
     260   [ +  -  +  + ]:       1572 :   for (auto laneId : lane::getLanes())
     261                 :            :   {
     262   [ +  -  +  - ]:       3142 :     auto lane = lane::getLane(laneId);
     263         [ +  - ]:       1571 :     checkEdgePoints(lane.id, lane.edgeLeft.ecefEdge);
     264         [ +  - ]:       1571 :     checkEdgePoints(lane.id, lane.edgeRight.ecefEdge);
     265                 :            :   }
     266                 :            : }
     267                 :            : 
     268                 :          2 : TEST_F(OpenDriveAccessTests, lane_contact_points_town03)
     269                 :            : {
     270   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town03.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     271                 :            : 
     272   [ +  -  +  + ]:       1572 :   for (auto laneId : lane::getLanes())
     273                 :            :   {
     274   [ +  -  +  - ]:       3142 :     auto lane = lane::getLane(laneId);
     275         [ +  - ]:       1571 :     checkEdgeContacts(lane);
     276                 :            :   }
     277                 :            : }
     278                 :            : 
     279                 :          2 : TEST_F(OpenDriveAccessTests, lane_points_town04)
     280                 :            : {
     281   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town04.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     282                 :            : 
     283   [ +  -  +  + ]:        925 :   for (auto laneId : lane::getLanes())
     284                 :            :   {
     285   [ +  -  +  - ]:       1848 :     auto lane = lane::getLane(laneId);
     286         [ +  - ]:        924 :     checkEdgePoints(lane.id, lane.edgeLeft.ecefEdge);
     287         [ +  - ]:        924 :     checkEdgePoints(lane.id, lane.edgeRight.ecefEdge);
     288                 :            :   }
     289                 :            : }
     290                 :            : 
     291                 :          2 : TEST_F(OpenDriveAccessTests, lane_contact_points_town04)
     292                 :            : {
     293   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town04.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     294                 :            : 
     295   [ +  -  +  + ]:        925 :   for (auto laneId : lane::getLanes())
     296                 :            :   {
     297   [ +  -  +  - ]:       1848 :     auto lane = lane::getLane(laneId);
     298         [ +  - ]:        924 :     checkEdgeContacts(lane);
     299                 :            :   }
     300                 :            : }
     301                 :            : 
     302                 :          2 : TEST_F(OpenDriveAccessTests, map_matching_town01_relevant_lanes_map_area)
     303                 :            : {
     304   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town01.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     305                 :            : 
     306                 :          1 :   std::vector<point::BoundingSphere> boundingSpheres;
     307                 :          1 :   auto tileRadius = physics::Distance(10);
     308   [ +  -  +  + ]:         35 :   for (auto xCoordinate = point::ENUCoordinate(-double(tileRadius)); xCoordinate < point::ENUCoordinate(500.);
     309         [ +  - ]:         34 :        xCoordinate += point::ENUCoordinate(1.5 * double(tileRadius)))
     310                 :            :   {
     311   [ +  -  +  -  :       1190 :     for (auto yCoordinate = point::ENUCoordinate(double(tileRadius)); yCoordinate > -point::ENUCoordinate(500.);
                   +  + ]
     312         [ +  - ]:       1156 :          yCoordinate -= point::ENUCoordinate(1.5 * double(tileRadius)))
     313                 :            :     {
     314                 :       1156 :       point::BoundingSphere boundingSphere;
     315         [ +  - ]:       1156 :       boundingSphere.center = point::toECEF(point::createENUPoint(xCoordinate, yCoordinate, point::ENUCoordinate(0.)));
     316                 :       1156 :       boundingSphere.radius = tileRadius;
     317         [ +  - ]:       1156 :       boundingSpheres.push_back(boundingSphere);
     318                 :            :     }
     319                 :            :   }
     320                 :            : 
     321                 :          1 :   std::vector<lane::LaneIdSet> boundingSphereLanesToTest;
     322                 :          1 :   std::vector<lane::LaneIdSet> boundingSphereLanesTestArea;
     323         [ +  - ]:          1 :   boundingSphereLanesToTest.resize(boundingSpheres.size());
     324         [ +  - ]:          1 :   boundingSphereLanesTestArea.resize(boundingSpheres.size());
     325   [ +  -  +  + ]:        301 :   for (auto laneId : lane::getLanes())
     326                 :            :   {
     327   [ +  -  +  - ]:        600 :     auto lane = lane::getLane(laneId);
     328                 :        300 :     bool laneConsidered = false;
     329         [ +  + ]:     347100 :     for (auto i = 0u; i < boundingSpheres.size(); i++)
     330                 :            :     {
     331         [ +  - ]:     346800 :       auto const laneDistance = point::distance(lane.boundingSphere, boundingSpheres[i]);
     332   [ +  +  +  -  :     346800 :       if (!laneConsidered && (laneDistance == physics::Distance(0.)))
             +  +  +  + ]
     333                 :            :       {
     334         [ +  - ]:        300 :         boundingSphereLanesToTest[i].insert(laneId);
     335                 :        300 :         laneConsidered = true;
     336                 :            :       }
     337   [ +  -  +  + ]:     346800 :       if (laneDistance <= physics::Distance(5.))
     338                 :            :       {
     339         [ +  - ]:      12253 :         boundingSphereLanesTestArea[i].insert(laneId);
     340                 :            :       }
     341                 :            :     }
     342         [ -  + ]:        300 :     if (!laneConsidered)
     343                 :            :     {
     344   [ #  #  #  #  :          0 :       EXPECT_TRUE(false) << laneId << " " << point::toENU(lane.boundingSphere.center);
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
     345                 :            :     }
     346                 :            :   }
     347                 :            : 
     348                 :          1 :   size_t testedLanesCount = 0u;
     349         [ +  + ]:       1157 :   for (auto i = 0u; i < boundingSpheres.size(); i++)
     350                 :            :   {
     351                 :       1156 :     testedLanesCount += boundingSphereLanesToTest[i].size();
     352         [ +  - ]:       1156 :     checkAreaMapMatching(boundingSphereLanesToTest[i], boundingSphereLanesTestArea[i]);
     353                 :            :   }
     354   [ +  -  +  -  :          1 :   ASSERT_EQ(testedLanesCount, lane::getLanes().size());
          -  +  -  -  -  
                -  -  - ]
     355                 :            : }
     356                 :            : 
     357                 :          2 : TEST_F(OpenDriveAccessTests, TrafficSignTest)
     358                 :            : {
     359   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copy.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     360                 :          1 :   LandmarkIdList idList;
     361         [ +  - ]:          1 :   idList = getLandmarks();
     362   [ +  -  -  +  :          1 :   ASSERT_EQ(idList.size(), 3u);
          -  -  -  -  -  
                      - ]
     363                 :            : }
     364                 :            : 
     365                 :          2 : TEST_F(OpenDriveAccessTests, defaultIntersectionType)
     366                 :            : {
     367   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyAllWayStop.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     368                 :          1 :   access::cleanup();
     369   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyCrosswalk.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     370                 :          1 :   access::cleanup();
     371   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyHasWay.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     372                 :          1 :   access::cleanup();
     373   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyPriorityToRight.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     374                 :          1 :   access::cleanup();
     375   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyPriorityToRightAndStraight.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     376                 :          1 :   access::cleanup();
     377   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyStop.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     378                 :          1 :   access::cleanup();
     379   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyTrafficLight.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     380                 :          1 :   access::cleanup();
     381   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyUnknown.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     382                 :          1 :   access::cleanup();
     383   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/bad/Town01copyYield.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     384                 :          1 :   access::cleanup();
     385   [ +  -  +  -  :          1 :   ASSERT_FALSE(access::init("test_files/bad/Town01copyNotValid.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     386                 :          1 :   access::cleanup();
     387                 :            : }
     388                 :            : 
     389                 :          2 : TEST_F(OpenDriveAccessTests, branch)
     390                 :            : {
     391                 :          0 :   access::Store::Ptr mStorePtr;
     392   [ +  -  +  -  :          1 :   mStorePtr.reset(new access::Store());
                   +  - ]
     393         [ +  - ]:          1 :   ad::map::opendrive::AdMapFactory factory(*mStorePtr);
     394   [ +  -  +  -  :          1 :   ASSERT_FALSE(
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     395                 :            :     factory.createAdMap(std::string("test_files/bad/NoneExists.xodr"), 2.0, intersection::IntersectionType::HasWay));
     396                 :            : 
     397         [ +  - ]:          1 :   access::cleanup();
     398   [ +  -  +  -  :          1 :   ASSERT_FALSE(
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     399                 :            :     factory.createAdMap(std::string("test_files/bad/TownEmpty.xodr"), 2.0, intersection::IntersectionType::HasWay));
     400                 :            : }
     401                 :            : 
     402                 :          2 : TEST_F(OpenDriveAccessTests, DataTypeConversion)
     403                 :            : {
     404   [ +  -  +  -  :          1 :   ASSERT_TRUE(access::init("test_files/Town01.txt"));
          -  +  -  -  -  
             -  -  -  -  
                      - ]
     405   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::LandmarkType::TRAFFIC_LIGHT, toLandmarkType(1000001));
          -  +  -  -  -  
                -  -  - ]
     406   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::LandmarkType::OTHER, toLandmarkType(1000003));
          -  +  -  -  -  
                -  -  - ]
     407   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::LandmarkType::TRAFFIC_SIGN, toLandmarkType(101));
          -  +  -  -  -  
                -  -  - ]
     408   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::LandmarkType::UNKNOWN, toLandmarkType(99));
          -  +  -  -  -  
                -  -  - ]
     409                 :            : 
     410   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::DANGER, toTrafficSignType(101, 0));
          -  +  -  -  -  
                -  -  - ]
     411   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::DANGER, toTrafficSignType(102, 0));
          -  +  -  -  -  
                -  -  - ]
     412                 :            : 
     413   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::LANES_MERGING, toTrafficSignType(120, 0));
          -  +  -  -  -  
                -  -  - ]
     414                 :            : 
     415   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::CAUTION_PEDESTRIAN, toTrafficSignType(133, 0));
          -  +  -  -  -  
                -  -  - ]
     416                 :            : 
     417   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::CAUTION_BICYCLE, toTrafficSignType(138, 0));
          -  +  -  -  -  
                -  -  - ]
     418   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::YIELD, toTrafficSignType(205, 0));
          -  +  -  -  -  
                -  -  - ]
     419   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::STOP, toTrafficSignType(206, 0));
          -  +  -  -  -  
                -  -  - ]
     420                 :            : 
     421   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ROUNDABOUT, toTrafficSignType(215, 0));
          -  +  -  -  -  
                -  -  - ]
     422   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::PASS_RIGHT, toTrafficSignType(222, 0));
          -  +  -  -  -  
                -  -  - ]
     423                 :            : 
     424   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN, toTrafficSignType(250, 0));
          -  +  -  -  -  
                -  -  - ]
     425   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_MOTORVEHICLES, toTrafficSignType(251, 0));
          -  +  -  -  -  
                -  -  - ]
     426   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_TRUCKS, toTrafficSignType(253, 0));
          -  +  -  -  -  
                -  -  - ]
     427   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_BICYCLE, toTrafficSignType(254, 0));
          -  +  -  -  -  
                -  -  - ]
     428   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_WEIGHT, toTrafficSignType(263, 0));
          -  +  -  -  -  
                -  -  - ]
     429   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_WIDTH, toTrafficSignType(264, 0));
          -  +  -  -  -  
                -  -  - ]
     430   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_HEIGHT, toTrafficSignType(265, 0));
          -  +  -  -  -  
                -  -  - ]
     431   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::ACCESS_FORBIDDEN_WRONG_DIR, toTrafficSignType(267, 0));
          -  +  -  -  -  
                -  -  - ]
     432                 :            : 
     433   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::MAX_SPEED, toTrafficSignType(274, -1));
          -  +  -  -  -  
                -  -  - ]
     434   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::SPEED_ZONE_30_BEGIN, toTrafficSignType(274, 1));
          -  +  -  -  -  
                -  -  - ]
     435   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::SPEED_ZONE_30_END, toTrafficSignType(274, 2));
          -  +  -  -  -  
                -  -  - ]
     436   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::MAX_SPEED, toTrafficSignType(274, 3));
          -  +  -  -  -  
                -  -  - ]
     437                 :            : 
     438   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::HAS_WAY_NEXT_INTERSECTION, toTrafficSignType(301, 0));
          -  +  -  -  -  
                -  -  - ]
     439   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::PRIORITY_WAY, toTrafficSignType(306, 0));
          -  +  -  -  -  
                -  -  - ]
     440   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::CITY_BEGIN, toTrafficSignType(310, 0));
          -  +  -  -  -  
                -  -  - ]
     441   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::CITY_END, toTrafficSignType(311, 0));
          -  +  -  -  -  
                -  -  - ]
     442   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::MOTORVEHICLE_BEGIN, toTrafficSignType(331, 0));
          -  +  -  -  -  
                -  -  - ]
     443   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficSignType::UNKNOWN, toTrafficSignType(332, 0));
          -  +  -  -  -  
                -  -  - ]
     444                 :            : 
     445   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactType::YIELD, toContactType(205));
          -  +  -  -  -  
                -  -  - ]
     446   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactType::STOP, toContactType(206));
          -  +  -  -  -  
                -  -  - ]
     447   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactType::RIGHT_OF_WAY, toContactType(301));
          -  +  -  -  -  
                -  -  - ]
     448   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactType::RIGHT_OF_WAY, toContactType(306));
          -  +  -  -  -  
                -  -  - ]
     449   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactType::TRAFFIC_LIGHT, toContactType(1000001));
          -  +  -  -  -  
                -  -  - ]
     450   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactType::UNKNOWN, toContactType(1100001));
          -  +  -  -  -  
                -  -  - ]
     451                 :            : 
     452   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::SOLID_RED_YELLOW_GREEN, toTrafficLightType(1000001, 0));
          -  +  -  -  -  
                -  -  - ]
     453   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::PEDESTRIAN_RED_GREEN, toTrafficLightType(1000002, 0));
          -  +  -  -  -  
                -  -  - ]
     454   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::BIKE_PEDESTRIAN_RED_GREEN, toTrafficLightType(1000007, 0));
          -  +  -  -  -  
                -  -  - ]
     455   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000008, 0));
          -  +  -  -  -  
                -  -  - ]
     456   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::SOLID_RED_YELLOW, toTrafficLightType(1000009, 0));
          -  +  -  -  -  
                -  -  - ]
     457   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000010, 0));
          -  +  -  -  -  
                -  -  - ]
     458   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::LEFT_RED_YELLOW_GREEN, toTrafficLightType(1000011, 10));
          -  +  -  -  -  
                -  -  - ]
     459   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::RIGHT_RED_YELLOW_GREEN, toTrafficLightType(1000011, 20));
          -  +  -  -  -  
                -  -  - ]
     460   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::STRAIGHT_RED_YELLOW_GREEN, toTrafficLightType(1000011, 30));
          -  +  -  -  -  
                -  -  - ]
     461   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::LEFT_STRAIGHT_RED_YELLOW_GREEN, toTrafficLightType(1000011, 40));
          -  +  -  -  -  
                -  -  - ]
     462   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::RIGHT_STRAIGHT_RED_YELLOW_GREEN, toTrafficLightType(1000011, 50));
          -  +  -  -  -  
                -  -  - ]
     463   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000011, 60));
          -  +  -  -  -  
                -  -  - ]
     464   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000012, 0));
          -  +  -  -  -  
                -  -  - ]
     465   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::BIKE_RED_GREEN, toTrafficLightType(1000013, 0));
          -  +  -  -  -  
                -  -  - ]
     466   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000014, 0));
          -  +  -  -  -  
                -  -  - ]
     467   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000015, 0));
          -  +  -  -  -  
                -  -  - ]
     468   [ +  -  +  -  :          1 :   ASSERT_EQ(landmark::TrafficLightType::UNKNOWN, toTrafficLightType(1000016, 0));
          -  +  -  -  -  
                -  -  - ]
     469                 :            : 
     470         [ +  - ]:          1 :   ::opendrive::SignalReference signalReference;
     471                 :          1 :   signalReference.parametricPosition = 0.5;
     472   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactLocation::SUCCESSOR, toContactLocation(signalReference, true));
          -  +  -  -  -  
                -  -  - ]
     473                 :          1 :   signalReference.parametricPosition = 0.4;
     474   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactLocation::PREDECESSOR, toContactLocation(signalReference, true));
          -  +  -  -  -  
                -  -  - ]
     475                 :          1 :   signalReference.inLaneOrientation = true;
     476   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactLocation::SUCCESSOR, toContactLocation(signalReference, false));
          -  +  -  -  -  
                -  -  - ]
     477                 :          1 :   signalReference.inLaneOrientation = false;
     478   [ +  -  +  -  :          1 :   ASSERT_EQ(lane::ContactLocation::PREDECESSOR, toContactLocation(signalReference, false));
          -  +  -  -  -  
                -  -  - ]
     479   [ +  -  -  +  :          1 :   ASSERT_EQ(landmark::LandmarkId(100), toLandmarkId((int)100));
          -  -  -  -  -  
                      - ]
     480                 :            : }
     481                 :            : 
     482                 :          2 : TEST_F(OpenDriveAccessTests, read_karlsruhe_map_with_other_proj_string)
     483                 :            : {
     484         [ +  - ]:          1 :   access::cleanup();
     485         [ +  - ]:          1 :   std::ifstream mapFile("test_files/Karlsruhe.xodr");
     486         [ +  - ]:          1 :   std::stringstream openDriveContentStream;
     487                 :            : 
     488   [ +  -  +  - ]:          1 :   openDriveContentStream << mapFile.rdbuf();
     489         [ +  - ]:          1 :   std::string openDriveContent = openDriveContentStream.str();
     490   [ +  -  -  +  :          1 :   ASSERT_TRUE(access::initFromOpenDriveContent(openDriveContent, 0.2, intersection::IntersectionType::TrafficLight));
          -  -  -  -  -  
                -  -  - ]
     491   [ +  -  -  +  :          1 :   ASSERT_TRUE(access::isENUReferencePointSet());
          -  -  -  -  -  
                -  -  - ]
     492         [ +  - ]:          1 :   const auto refPoint = access::getENUReferencePoint();
     493   [ +  -  -  +  :          1 :   ASSERT_EQ(refPoint.latitude, ad::map::point::Latitude(49.02067835));
          -  -  -  -  -  
                      - ]
     494   [ +  -  -  +  :          1 :   ASSERT_EQ(refPoint.longitude, ad::map::point::Longitude(8.43531364));
          -  -  -  -  -  
                      - ]
     495                 :            : }

Generated by: LCOV version 1.14