LCOV - code coverage report
Current view: top level - include/ad/map/access - Factory.hpp (source / functions) Hit Total Coverage
Test: ad_map_access Lines: 4 4 100.0 %
Date: 2022-10-04 09:48:07 Functions: 2 2 100.0 %
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 <memory>
      15                 :            : #include <string>
      16                 :            : 
      17                 :            : #include "ad/map/access/Types.hpp"
      18                 :            : #include "ad/map/landmark/Types.hpp"
      19                 :            : #include "ad/map/lane/Types.hpp"
      20                 :            : #include "ad/map/point/Types.hpp"
      21                 :            : #include "ad/map/restriction/Types.hpp"
      22                 :            : 
      23                 :            : /** @brief namespace ad */
      24                 :            : namespace ad {
      25                 :            : /** @brief namespace map */
      26                 :            : namespace map {
      27                 :            : /** @brief namespace access */
      28                 :            : namespace access {
      29                 :            : 
      30                 :            : class Store;
      31                 :            : 
      32                 :            : /**
      33                 :            :  * @brief Autonomus Driving Map Factory.
      34                 :            :  *        Contains method to be used to initialize and modify content in the Store.
      35                 :            :  */
      36                 :            : class Factory
      37                 :            : {
      38                 :            : public: // Constructor/Destructor
      39                 :            :   /**
      40                 :            :    * @brief Constructor.
      41                 :            :    * @param[in] store Store on which this Factory will operate.
      42                 :            :    */
      43                 :         68 :   explicit Factory(Store &store)
      44                 :         68 :     : mStore(store)
      45                 :            :   {
      46                 :         68 :   }
      47                 :            : 
      48                 :            :   /**
      49                 :            :    * @brief Destructor.
      50                 :            :    *        Releases all resources.
      51                 :            :    */
      52                 :         90 :   virtual ~Factory() = default;
      53                 :            : 
      54                 :            : public: // Atomic Operations -- Main
      55                 :            :   /**
      56                 :            :    * @brief Adds or modifies new Lane in the Store.
      57                 :            :    * @param[in] part_id     Partition to which this lane belongs.
      58                 :            :    * @param[in] id          Identifier of this lane.
      59                 :            :    * @param[in] type        Type of the lane.
      60                 :            :    * @param[in] direction   Direction of traffic flow of this lane.
      61                 :            :    * @returns true if new Lane is added, false if existing Lane is modified.
      62                 :            :    */
      63                 :            :   bool add(PartitionId part_id, const lane::LaneId &id, lane::LaneType type, lane::LaneDirection direction);
      64                 :            : 
      65                 :            :   /**
      66                 :            :    * @brief Add new lane to the store.
      67                 :            :    * @param[in] part_id   Partition to which this lane belongs.
      68                 :            :    * @param[in] left_geo  Left edge geometry.
      69                 :            :    * @param[in] right_geo Right edge geometry.
      70                 :            :    * @returns New lane identifier. It will be invalid if not successful.
      71                 :            :    * \note Lane Type will be set to NORMAL and Lane Direction to POSITIVE.
      72                 :            :    */
      73                 :            :   lane::LaneId add(PartitionId part_id, const point::GeoEdge &left_geo, const point::GeoEdge &right_geo);
      74                 :            : 
      75                 :            :   /**
      76                 :            :    * @brief Add new intersection lane to the store.
      77                 :            :    * @param[in] part_id   Partition to which this lane belongs.
      78                 :            :    * @param[in] left_ecef  Left edge geometry.
      79                 :            :    * @param[in] right_ecef Right edge geometry.
      80                 :            :    * @param[in] lane_id_0 First connecting lane.
      81                 :            :    * @param[in] lane_id_1 Second connecting lane.
      82                 :            :    * @returns New lane identifier. It will be invalid if not successful.
      83                 :            :    * \note Lane Type will be set to INTERSECTION and Lane Direction to POSITIVE.
      84                 :            :    *            SUCCESSOR/PREDECESSOR contacts will be added to involved lanes.
      85                 :            :    */
      86                 :            :   lane::LaneId add(PartitionId part_id,
      87                 :            :                    const point::ECEFEdge &left_ecef,
      88                 :            :                    const point::ECEFEdge &right_ecef,
      89                 :            :                    const lane::LaneId &lane_id_0,
      90                 :            :                    const lane::LaneId &lane_id_1);
      91                 :            : 
      92                 :            :   /**
      93                 :            :    * @brief Adds or modifies new landmark in the Store.
      94                 :            :    * @param[in] part_id           Partition to which this landmark belongs.
      95                 :            :    * @param[in] id                Identifier of this landmark.
      96                 :            :    * @param[in] type              Type of the landmark.
      97                 :            :    * @param[in] position          Position of the landmark.
      98                 :            :    * @param[in] orientation       Orientation of the landmark.
      99                 :            :    * @param[in] bounding_box      Bounding box of the landmark.
     100                 :            :    * @returns true if new Landmark is added, false if existing Landmark is modified.
     101                 :            :    */
     102                 :            :   bool addLandmark(PartitionId part_id,
     103                 :            :                    const landmark::LandmarkId &id,
     104                 :            :                    const landmark::LandmarkType type,
     105                 :            :                    const point::ECEFPoint &position,
     106                 :            :                    const point::ECEFPoint &orientation,
     107                 :            :                    const point::Geometry &bounding_box);
     108                 :            : 
     109                 :            :   /**
     110                 :            :    * @brief Adds or modifies new traffic light landmark in the Store.
     111                 :            :    * @param[in] part_id           Partition to which this landmark belongs.
     112                 :            :    * @param[in] id                Identifier of this landmark.
     113                 :            :    * @param[in] type              Type of the traffic light landmark.
     114                 :            :    * @param[in] position          Position of the landmark.
     115                 :            :    * @param[in] orientation       Orientation of the landmark.
     116                 :            :    * @param[in] bounding_box      Bounding box of the landmark.
     117                 :            :    * @returns true if new Landmark is added, false if existing Landmark is modified.
     118                 :            :    */
     119                 :            :   bool addTrafficLight(PartitionId part_id,
     120                 :            :                        const landmark::LandmarkId &id,
     121                 :            :                        const landmark::TrafficLightType type,
     122                 :            :                        const point::ECEFPoint &position,
     123                 :            :                        const point::ECEFPoint &orientation,
     124                 :            :                        const point::Geometry &bounding_box);
     125                 :            : 
     126                 :            :   /**
     127                 :            :    * @brief Adds or modifies new traffic sign landmark in the Store.
     128                 :            :    * @param[in] part_id           Partition to which this landmark belongs.
     129                 :            :    * @param[in] id                Identifier of this landmark.
     130                 :            :    * @param[in] type              Type of the traffic sign landmark.
     131                 :            :    * @param[in] position          Position of the landmark.
     132                 :            :    * @param[in] orientation       Orientation of the landmark.
     133                 :            :    * @param[in] bounding_box      Bounding box of the landmark.
     134                 :            :    * @param[in] text              Text of the traffic sign landmark.
     135                 :            :    * @returns true if new Landmark is added, false if existing Landmark is modified.
     136                 :            :    */
     137                 :            :   bool addTrafficSign(PartitionId part_id,
     138                 :            :                       const landmark::LandmarkId &id,
     139                 :            :                       const landmark::TrafficSignType type,
     140                 :            :                       const point::ECEFPoint &position,
     141                 :            :                       const point::ECEFPoint &orientation,
     142                 :            :                       const point::Geometry &bounding_box,
     143                 :            :                       const std::string &text);
     144                 :            : 
     145                 :            : private:
     146                 :            :   /**
     147                 :            :    * @brief Adds or modifies new traffic sign landmark in the Store.
     148                 :            :    * @param[in] part_id               Partition to which this landmark belongs.
     149                 :            :    * @param[in] id                    Identifier of this landmark.
     150                 :            :    * @param[in] type                  Type of the traffic sign landmark.
     151                 :            :    * @param[in] position              Position of the landmark.
     152                 :            :    * @param[in] orientation           Orientation of the landmark.
     153                 :            :    * @param[in] bounding_box          Bounding box of the landmark.
     154                 :            :    * @param[in] traffic_light_type    Type of traffic light of this landmark (may be INVALID).
     155                 :            :    * @param[in] traffic_sign_type     Type of traffic sign of this landmark (may be INVALID).
     156                 :            :    * @param[in] text                  Supplementory text of the landmark.
     157                 :            :    * @returns true if new Landmark is added, false if existing Landmark is modified.
     158                 :            :    */
     159                 :            :   bool add(PartitionId part_id,
     160                 :            :            const landmark::LandmarkId &id,
     161                 :            :            const landmark::LandmarkType type,
     162                 :            :            const point::ECEFPoint &position,
     163                 :            :            const point::ECEFPoint &orientation,
     164                 :            :            const point::Geometry &bounding_box,
     165                 :            :            const landmark::TrafficLightType traffic_light_type,
     166                 :            :            const landmark::TrafficSignType traffic_sign_type,
     167                 :            :            const std::string &text);
     168                 :            : 
     169                 :            : public: // Atomic Operations -- Add Lane Attribute
     170                 :            :   /**
     171                 :            :    * @brief Adds Contact to Lane to the Lane object.
     172                 :            :    * @param[in] id Lane Identifier.
     173                 :            :    * @param[in] contact_lane Contact lane to be added.
     174                 :            :    * @returns true if sucessful (lane exists).
     175                 :            :    */
     176                 :            :   bool add(const lane::LaneId &id, const lane::ContactLane &contact_lane);
     177                 :            : 
     178                 :            :   /**
     179                 :            :    * @brief Adds Contacts to Lane to the Lane object.
     180                 :            :    * @param[in] id Lane Identifier.
     181                 :            :    * @param[in] contact_lanes Contacts to lanes to be added.
     182                 :            :    * @returns true if sucessful (lane exists).
     183                 :            :    */
     184                 :            :   bool add(const lane::LaneId &id, const lane::ContactLaneList &contact_lanes);
     185                 :            : 
     186                 :            :   /**
     187                 :            :    * @brief Add parametic speed limit to the Lane object.
     188                 :            :    * @param[in] id Lane Identifier.
     189                 :            :    * @param[in] para_speed Parametric speed limit restriction.
     190                 :            :    * @returns true if sucessful (lane exists).
     191                 :            :    */
     192                 :            :   bool add(const lane::LaneId &id, const restriction::SpeedLimit &para_speed);
     193                 :            : 
     194                 :            :   /**
     195                 :            :    * @brief Add visible landmark to the Lane object
     196                 :            :    * @param[in] id Lane Identifier.
     197                 :            :    * @param[in] landmark to be added.
     198                 :            :    * @returns true if sucessful (lane exists).
     199                 :            :    */
     200                 :            :   bool add(const lane::LaneId &id, const landmark::LandmarkId &landmark);
     201                 :            : 
     202                 :            :   /**
     203                 :            :    * @brief Add Restriction to the Lane object.
     204                 :            :    * @param[in] id Lane Identifier.
     205                 :            :    * @param[in] restriction Restriction to add set.
     206                 :            :    * @param[in] andx Add restriction to and_ collection.
     207                 :            :    * @returns true if sucessful (lane exists).
     208                 :            :    */
     209                 :            :   bool add(const lane::LaneId &id, const restriction::Restriction &restriction, bool andx);
     210                 :            : 
     211                 :            :   /**
     212                 :            :    * @brief Add Contact to Lane to the Lane object.
     213                 :            :    * @param[in] id_from   From-Lane Identifier.
     214                 :            :    * @param[in] id_to     Identifier of object to which connection is leading.
     215                 :            :    * @param[in] location  Location of the contact.
     216                 :            :    * @param[in] types     Types of the contact.
     217                 :            :    * @param[in] restrs    Legal restrictions for the contact.
     218                 :            :    * @returns true if sucessful (lane exists).
     219                 :            :    */
     220                 :            :   bool add(const lane::LaneId &id_from,
     221                 :            :            const lane::LaneId &id_to,
     222                 :            :            const lane::ContactLocation location,
     223                 :            :            const lane::ContactTypeList &types,
     224                 :            :            const restriction::Restrictions &restrs);
     225                 :            : 
     226                 :            :   /**
     227                 :            :    * @brief Add Contact to Lane to the Lane object.
     228                 :            :    * @param[in] id_from   From-Lane Identifier.
     229                 :            :    * @param[in] id_to     Identifier of object to which connection is leading.
     230                 :            :    * @param[in] location  Location of the contact.
     231                 :            :    * @param[in] types     Types of the contact.
     232                 :            :    * @param[in] restrs    Legal restrictions for the contact.
     233                 :            :    * @param[in] traffic_light  Identifier of the traffic light for this Contact (may be invalid).
     234                 :            :    * @returns true if sucessful (lane exists).
     235                 :            :    */
     236                 :            :   bool add(const lane::LaneId &id_from,
     237                 :            :            const lane::LaneId &id_to,
     238                 :            :            const lane::ContactLocation location,
     239                 :            :            const lane::ContactTypeList &types,
     240                 :            :            const restriction::Restrictions &restrs,
     241                 :            :            const landmark::LandmarkId &traffic_light);
     242                 :            : 
     243                 :            : public: // Atomic Operations -- Set Lane Attribute
     244                 :            :   /**
     245                 :            :    * @brief Sets the lane attribute.
     246                 :            :    * @param[in] id          Identifier of this lane.
     247                 :            :    * @param[in] direction   Direction of traffic flow of this lane.
     248                 :            :    * @returns true if successful (lane exists).
     249                 :            :    */
     250                 :            :   bool set(const lane::LaneId &id, lane::LaneDirection direction);
     251                 :            : 
     252                 :            :   /**
     253                 :            :    * @brief Sets the lane attribute.
     254                 :            :    * @param[in] id          Identifier of this lane.
     255                 :            :    * @param[in] type        Type of the lane.
     256                 :            :    * @returns true if successful (lane exists).
     257                 :            :    */
     258                 :            :   bool set(const lane::LaneId &id, lane::LaneType type);
     259                 :            : 
     260                 :            :   /**
     261                 :            :    * @brief Sets the lane attribute.
     262                 :            :    * @param[in] id              Identifier of this lane.
     263                 :            :    * @param[in] compliance_ver  Data version compliance of this lane.
     264                 :            :    * @returns true if successful (lane exists).
     265                 :            :    */
     266                 :            :   bool set(const lane::LaneId &id, lane::ComplianceVersion compliance_ver);
     267                 :            : 
     268                 :            :   /**
     269                 :            :    * @brief Sets the Lane Edges.
     270                 :            :    * @param[in] id Lane identifier.
     271                 :            :    * @param[in] edge_left Left lane geometry.
     272                 :            :    * @param[in] edge_right Right lane point::Geometry.
     273                 :            :    * @returns true if successful (lane exists).
     274                 :            :    */
     275                 :            :   bool set(const lane::LaneId &id, const point::Geometry &edge_left, const point::Geometry &edge_right);
     276                 :            : 
     277                 :            :   /**
     278                 :            :    * @brief Sets speed limit for the COMPLETE lane.
     279                 :            :    * @param[in] id Lane identifier.
     280                 :            :    * @param[in] speed_limit Speed limit for the COMPLETE lane.
     281                 :            :    * @return true if successful.
     282                 :            :    */
     283                 :            :   bool set(const lane::LaneId &id, const physics::Speed &speed_limit);
     284                 :            : 
     285                 :            :   /**
     286                 :            :    * @brief Set Restrictions to the Lane object.
     287                 :            :    * @param[in] id Lane Identifier.
     288                 :            :    * @param[in] restrictions Restrictions to set.
     289                 :            :    * @returns true if sucessful (lane exists).
     290                 :            :    */
     291                 :            :   bool set(const lane::LaneId &id, const restriction::Restrictions &restrictions);
     292                 :            : 
     293                 :            :   /**
     294                 :            :    * @brief Set visible landmarks to the Lane object.
     295                 :            :    * @param[in] id Lane Identifier.
     296                 :            :    * @param[in] landmarks to set.
     297                 :            :    * @returns true if sucessful (lane exists).
     298                 :            :    */
     299                 :            :   bool set(const lane::LaneId &id, const landmark::LandmarkIdList &landmarks);
     300                 :            : 
     301                 :            : public: // Atomic Operations -- Set Map Meta Data
     302                 :            :   /**
     303                 :            :    * @brief Set traffic type of the map.
     304                 :            :    * @param[in] traffic_type the type of traffic within the map.
     305                 :            :    * @returns true if sucessful.
     306                 :            :    */
     307                 :            :   bool set(const TrafficType &traffic_type);
     308                 :            : 
     309                 :            : public: // Atomic operations -- remove things
     310                 :            :   /**
     311                 :            :    * @brief Method to be called to delete Lane from the Store.
     312                 :            :    * @param[in] id Lane identifier.
     313                 :            :    * @returns true if lane was successfuly deleted.
     314                 :            :    */
     315                 :            :   bool deleteLane(lane::LaneId id);
     316                 :            : 
     317                 :            :   /**
     318                 :            :    * @brief Delete all contacts from one lane to another.
     319                 :            :    * @param[in] from_id Lane identifier.
     320                 :            :    * @param[in] to_id To-lane identifier.
     321                 :            :    * @returns true if contacts were successfuly deleted.
     322                 :            :    */
     323                 :            :   bool deleteContacts(lane::LaneId from_id, lane::LaneId to_id);
     324                 :            : 
     325                 :            :   /**
     326                 :            :    * @brief Method to be called to delete landmark from the Store.
     327                 :            :    * @param[in] id Landmark identifier.
     328                 :            :    * @returns true if landmark was successfuly deleted.
     329                 :            :    */
     330                 :            :   bool deleteLandmark(landmark::LandmarkId id);
     331                 :            : 
     332                 :            : public: // Other methods
     333                 :            :   /**
     334                 :            :    * @brief Creates missing topological contacts from one lane to another.
     335                 :            :    * @param[in] from_lane_id First lane identifer.
     336                 :            :    * @param[in] to_lane_id Second lane identifier.
     337                 :            :    * @returns True if connection is added.
     338                 :            :    * \note Method is limited to SUCCESSOR/PREDECESSOR relationship!
     339                 :            :    */
     340                 :            :   bool autoConnect(lane::LaneId from_lane_id, lane::LaneId to_lane_id);
     341                 :            : 
     342                 :            : private: // Aux Methods
     343                 :            :          /**
     344                 :            :           * @returns Next available lane identifer.
     345                 :            :           */
     346                 :            :   lane::LaneId getNextLaneId() const;
     347                 :            : 
     348                 :            : protected:       // Data Members
     349                 :            :   Store &mStore; ///< Store on which this Factory operates.
     350                 :            : };
     351                 :            : 
     352                 :            : } // namespace access
     353                 :            : } // namespace map
     354                 :            : } // namespace ad

Generated by: LCOV version 1.14