LCOV - code coverage report
Current view: top level - include/ad/map/route - Route.hpp (source / functions) Hit Total Coverage
Test: ad_map_access Lines: 11 15 73.3 %
Date: 2022-10-04 09:48:07 Functions: 6 7 85.7 %
Branches: 0 0 -

           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                 :            :  * @file
      10                 :            :  */
      11                 :            : 
      12                 :            : #pragma once
      13                 :            : 
      14                 :            : #include <ad/physics/Distance.hpp>
      15                 :            : #include <ad/physics/Duration.hpp>
      16                 :            : #include <vector>
      17                 :            : #include "ad/map/point/ParaPointList.hpp"
      18                 :            : #include "ad/map/route/Routing.hpp"
      19                 :            : 
      20                 :            : /** @brief namespace ad */
      21                 :            : namespace ad {
      22                 :            : /** @brief namespace map */
      23                 :            : namespace map {
      24                 :            : /** @brief namespace route */
      25                 :            : namespace route {
      26                 :            : /**
      27                 :            :  * @brief provides route planning capabilities on the road network of the map
      28                 :            :  */
      29                 :            : namespace planning {
      30                 :            : 
      31                 :            : /**
      32                 :            :  * @brief Implements routing on the lane network.
      33                 :            :  */
      34                 :            : class Route
      35                 :            : {
      36                 :            : public:
      37                 :            :   /**
      38                 :            :    * @brief Basic route description.
      39                 :            :    */
      40                 :            :   struct RawRoute
      41                 :            :   {
      42                 :            :     /** @brief the list of ParaPoints that contain the route planning output
      43                 :            :      */
      44                 :            :     point::ParaPointList paraPointList;
      45                 :            :     /** @brief the distance covered by the route */
      46                 :            :     physics::Distance routeDistance{0.};
      47                 :            :     /** @brief the duration required by the route */
      48                 :            :     physics::Duration routeDuration{0.};
      49                 :            :   };
      50                 :            : 
      51                 :            :   /**
      52                 :            :    * @brief Basic route description.
      53                 :            :    */
      54                 :            :   typedef std::vector<point::ParaPointList> BasicRoute;
      55                 :            : 
      56                 :            :   /**
      57                 :            :    * @brief Routing type.
      58                 :            :    */
      59                 :            :   enum class Type
      60                 :            :   {
      61                 :            :     INVALID,                   ///< Invalid value.
      62                 :            :     SHORTEST,                  ///< Shortest route by distance.
      63                 :            :     SHORTEST_IGNORE_DIRECTION, ///< Shortest route by distance, allow to drive also in lanes with other direction
      64                 :            :   };
      65                 :            : 
      66                 :            :   /**
      67                 :            :    * @brief Constructor. Calculates route between two points.
      68                 :            :    * @param[in] start Start point.
      69                 :            :    * @param[in] dest  Destination point.
      70                 :            :    * @param[in] maxDistance maximum route search distance.
      71                 :            :    * @param[in] maxDuration maximum route search duration.
      72                 :            :    * @param[in] routingType   Type of the route to be calculated.
      73                 :            :    */
      74                 :            :   Route(const RoutingParaPoint &start,
      75                 :            :         const RoutingParaPoint &dest,
      76                 :            :         physics::Distance const &maxDistance,
      77                 :            :         physics::Duration const &maxDuration,
      78                 :            :         Type const &routingType);
      79                 :            : 
      80                 :            :   Route(Route const &) = delete;
      81                 :            :   Route(Route const &&) = delete;
      82                 :            :   Route &operator=(Route const &) = delete;
      83                 :            :   Route &operator=(Route &&) = delete;
      84                 :            : 
      85                 :            :   /**
      86                 :            :    * @brief Destructor.
      87                 :            :    */
      88                 :       2763 :   virtual ~Route() = default;
      89                 :            : 
      90                 :            :   /** @returns Start point as ParaPoint. */
      91                 :            :   const point::ParaPoint &getStart() const
      92                 :            :   {
      93                 :            :     return mStart.point;
      94                 :            :   }
      95                 :            : 
      96                 :            :   /** @returns Start point as RoutingParaPoint. */
      97                 :        120 :   const RoutingParaPoint &getRoutingStart() const
      98                 :            :   {
      99                 :        120 :     return mStart;
     100                 :            :   }
     101                 :            : 
     102                 :            :   /** @returns Destination point as ParaPoint. */
     103                 :      70509 :   const point::ParaPoint &getDest() const
     104                 :            :   {
     105                 :      70509 :     return mDest.point;
     106                 :            :   }
     107                 :            : 
     108                 :            :   /** @returns Destination point as RoutingParaPoint. */
     109                 :       2763 :   const RoutingParaPoint &getRoutingDest() const
     110                 :            :   {
     111                 :       2763 :     return mDest;
     112                 :            :   }
     113                 :            : 
     114                 :            :   /** @returns Type of the route to be calculated. */
     115                 :            :   Type getType() const
     116                 :            :   {
     117                 :            :     return mType;
     118                 :            :   }
     119                 :            : 
     120                 :            :   /**
     121                 :            :    * @returns true if route calculation ignores lane direction.
     122                 :            :    */
     123                 :            :   bool laneDirectionIsIgnored() const;
     124                 :            : 
     125                 :            :   /**
     126                 :            :    * @brief Performs the routing.
     127                 :            :    * @returns true if routing succeeded.
     128                 :            :    */
     129                 :            :   virtual bool calculate() = 0;
     130                 :            : 
     131                 :            :   /**
     132                 :            :    * @returns true if calculated route is valid.
     133                 :            :    */
     134                 :         40 :   bool isValid() const
     135                 :            :   {
     136                 :         40 :     return mValid;
     137                 :            :   }
     138                 :            : 
     139                 :            :   /** @returns Raw calculated route. */
     140                 :            :   const RawRoute &getRawRoute(size_t const routeIndex = 0u) const;
     141                 :            : 
     142                 :            :   /** @returns Raw calculated route. */
     143                 :         39 :   const std::vector<RawRoute> &getRawRoutes() const
     144                 :            :   {
     145                 :         39 :     return mRawRoutes;
     146                 :            :   }
     147                 :            : 
     148                 :            :   /** @returns Calculated base route. */
     149                 :            :   BasicRoute getBasicRoute(size_t const routeIndex = 0u) const;
     150                 :            : 
     151                 :            :   /** @returns All calculated basic routes. */
     152                 :            :   std::vector<BasicRoute> getBasicRoutes() const;
     153                 :            : 
     154                 :            : protected:
     155                 :            :   //! Start point.
     156                 :            :   RoutingParaPoint mStart;
     157                 :            :   //! Destination point.
     158                 :            :   RoutingParaPoint mDest;
     159                 :            :   //! prediction distance to be used
     160                 :            :   physics::Distance const mMaxDistance;
     161                 :            :   //! prediction duration to be used
     162                 :            :   physics::Duration const mMaxDuration;
     163                 :            :   //! Type of the route to be calculated.
     164                 :            :   Type mType;
     165                 :            :   //! Indicates if calculation was successful.
     166                 :            :   bool mValid;
     167                 :            :   ///< Calculated routes.
     168                 :            :   std::vector<RawRoute> mRawRoutes;
     169                 :            : };
     170                 :            : 
     171                 :          0 : inline std::ostream &operator<<(std::ostream &os, Route::RawRoute const &value)
     172                 :            : {
     173                 :            :   os << "Route::RawRoute("
     174                 :          0 :      << " routeDistance:" << value.routeDistance << " routeDuration:" << value.routeDuration
     175                 :          0 :      << " paraPoints:" << value.paraPointList << ")";
     176                 :          0 :   return os;
     177                 :            : }
     178                 :            : 
     179                 :            : } // namespace planning
     180                 :            : } // namespace route
     181                 :            : } // namespace map
     182                 :            : } // namespace ad

Generated by: LCOV version 1.14