LCOV - code coverage report
Current view: top level - include/ad/map/config - MapConfigFileHandler.hpp (source / functions) Hit Total Coverage
Test: ad_map_access Lines: 1 1 100.0 %
Date: 2022-10-04 09:48:07 Functions: 1 1 100.0 %
Branches: 0 4 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 <vector>
      15                 :            : #include "ad/map/config/MapEntry.hpp"
      16                 :            : #include "ad/map/config/PointOfInterest.hpp"
      17                 :            : #include "ad/map/point/GeoPoint.hpp"
      18                 :            : 
      19                 :            : /** @brief namespace ad */
      20                 :            : namespace ad {
      21                 :            : /** @brief namespace map */
      22                 :            : namespace map {
      23                 :            : /** @brief namespace config */
      24                 :            : namespace config {
      25                 :            : 
      26                 :            : /**
      27                 :            :  * @class MapConfigFileHandler
      28                 :            :  * @brief Parse config file that specifies all known maps
      29                 :            :  *
      30                 :            :  * The config file specifies which maps to use by the AdMapAccess class.
      31                 :            :  * It has three sections:
      32                 :            :  * - ADMap
      33                 :            :  * - POI
      34                 :            :  * - ENUReference
      35                 :            :  *
      36                 :            :  * ADMap specifies a map and optional parameters for loading. An entry is given with
      37                 :            :  * - map (mandatory): filename of the adm or OpenDrive map file, relative path below in the directory of the config file
      38                 :            :  * itself. The filename must not have blanks.
      39                 :            :  * - openDriveOverlapMargin (optional): OpenDrive Map reader margin for overlap calculation
      40                 :            :  * - openDriveDefaultIntersectionType (optional): OpenDrive Map default intersection type
      41                 :            :  *
      42                 :            :  * The positions define the covered area of the file. Example:
      43                 :            :  * [ADMap]
      44                 :            :  * map=filename
      45                 :            :  *
      46                 :            :  * POI specifies a [list of] point[s] of interest. An entry can provide one or more POI descriptions.
      47                 :            :  * Whereas a POI is given with:
      48                 :            :  * - a name of the poi
      49                 :            :  * - latitude, longitude and altitude values of the POI
      50                 :            :  *
      51                 :            :  * Example:
      52                 :            :  * [POI]
      53                 :            :  * poi=One 49.0189305 8.4399515 0.
      54                 :            :  * poi=Two 49.0191653 8.4401407 0.
      55                 :            :  * poi=Three 49.0192038 8.4401582 0.
      56                 :            :  * poi=Four 49.0192092 8.4401439 0.
      57                 :            :  *
      58                 :            :  * All values are given in decimal degrees, e.g. 48.405
      59                 :            :  *
      60                 :            :  * In addition there is the possibility to provide a default ENUReference point to be set automatically when loading the
      61                 :            :  * map file.
      62                 :            :  * The default ENU Reference point is given by:
      63                 :            :  * - latitude, longitude and altitude values of the reference point
      64                 :            :  *
      65                 :            :  * Example
      66                 :            :  * [ENUReference]
      67                 :            :  * default=49.0192671 8.4421163 0
      68                 :            :  *
      69                 :            :  * When parsing the config file, the existance/correctness of the map file itself will not be checked.
      70                 :            :  */
      71                 :            : class MapConfigFileHandler
      72                 :            : {
      73                 :            : public:
      74   [ #  #  #  # ]:         10 :   MapConfigFileHandler() = default;
      75                 :            : 
      76                 :            :   // Copy operators and constructors are deleted to avoid accidential copies
      77                 :            :   MapConfigFileHandler(MapConfigFileHandler const &) = delete;
      78                 :            :   MapConfigFileHandler(MapConfigFileHandler &&) = delete;
      79                 :            :   MapConfigFileHandler &operator=(MapConfigFileHandler &&) = delete;
      80                 :            :   MapConfigFileHandler &operator=(MapConfigFileHandler const &) = delete;
      81                 :            : 
      82                 :            :   /**
      83                 :            :    * @brief read configuration from given configFileName
      84                 :            :    *
      85                 :            :    * @return true on successful completion
      86                 :            :    * @return false if configFileName cannot be opened or has invalid syntax
      87                 :            :    */
      88                 :            :   bool readConfig(std::string const &configFileName);
      89                 :            : 
      90                 :            :   //! @return true if a valid configuration was read
      91                 :            :   bool isInitialized() const;
      92                 :            : 
      93                 :            :   //! @return true if configuration was done with given file name
      94                 :            :   bool isInitializedWithFilename(std::string const &configFileName) const;
      95                 :            : 
      96                 :            :   //! @return name of loaded config file
      97                 :            :   std::string const &configFileName() const;
      98                 :            : 
      99                 :            :   //! @return configured MapEntry
     100                 :            :   MapEntry const &adMapEntry() const;
     101                 :            : 
     102                 :            :   //! @return list of POIs
     103                 :            :   std::vector<PointOfInterest> const &pointsOfInterest() const;
     104                 :            : 
     105                 :            :   //! @return the default Enu reference point
     106                 :            :   point::GeoPoint defaultEnuReference() const;
     107                 :            : 
     108                 :            :   //! @return \c 'true' if the default Enu reference point is existing
     109                 :            :   bool defaultEnuReferenceAvailable() const;
     110                 :            : 
     111                 :            :   void reset();
     112                 :            : 
     113                 :            : private:
     114                 :            :   std::string mConfigFileName{}; //!< name of the loaded config file
     115                 :            :   std::string mBaseDir{};        //!< name of directory where config file is located
     116                 :            : 
     117                 :            :   MapEntry mAdMapEntry;
     118                 :            :   std::vector<PointOfInterest> mPointsOfInterest;
     119                 :            :   point::GeoPoint mDefaultEnuReference;
     120                 :            : 
     121                 :            :   void updateFilenameAndPath(std::string const &configFileName);
     122                 :            :   bool parseConfigFile(std::string const &configFileName);
     123                 :            :   bool parsePointOfIntereset(std::string const &entry);
     124                 :            :   bool parseENUReference(std::string const &entry);
     125                 :            : };
     126                 :            : 
     127                 :            : } // namespace config
     128                 :            : } // namespace map
     129                 :            : } // namespace ad

Generated by: LCOV version 1.14