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 "ad/map/access/MapMetaDataValidInputRange.hpp" 16 : : #include "ad/map/access/Store.hpp" 17 : : #include "ad/map/config/PointOfInterest.hpp" 18 : : #include "ad/map/intersection/IntersectionType.hpp" 19 : : #include "ad/map/lane/Types.hpp" 20 : : #include "ad/map/route/Types.hpp" 21 : : 22 : : /** @brief namespace ad */ 23 : : namespace ad { 24 : : /** @brief namespace map */ 25 : : namespace map { 26 : : 27 : : namespace point { 28 : : class CoordinateTransform; 29 : : } // namespace point 30 : : 31 : : /** @brief namespace access */ 32 : : namespace access { 33 : : 34 : : /** 35 : : * @brief checks if the given MapMetaData is valid 36 : : * 37 : : * The metaData is valid if it's within valid input range. 38 : : */ 39 : 31 : inline bool isValid(MapMetaData const &metaData, bool const logErrors = true) 40 : : { 41 [ + + + + ]: 31 : bool isValidInputRange = withinValidInputRange(metaData, logErrors) && (metaData.trafficType != TrafficType::INVALID); 42 [ + + + + ]: 31 : if (!isValidInputRange && logErrors) 43 : : { 44 [ + - ]: 1 : spdlog::error("withinValidInputRange(::ad::map::access::MapMetaData)>> {} not valid", metaData); 45 : : } 46 : 31 : return isValidInputRange; 47 : : } 48 : : 49 : : /** 50 : : * @brief get the coordinate transformation object 51 : : */ 52 : : std::shared_ptr<point::CoordinateTransform> getCoordinateTransform(); 53 : : 54 : : /** 55 : : * @brief initialize singleton with given configuration file 56 : : * 57 : : * The configuration file specifies all available maps, see ConfigFileHandler for details of the semantics 58 : : * @return true if initialization was successful (i.e. config file exists or singleton was already initialized) 59 : : * @return false if config file doesn't exist or the singleton was already initialized with a different config file 60 : : */ 61 : : bool init(std::string const &configFileName); 62 : : 63 : : /** 64 : : * @brief initialize singleton with OpenDRIVE content 65 : : * 66 : : * @return true if initialization was successful (i.e. map content was valid or singleton was already initialized) 67 : : * @return false if map content was invalid or the singleton was already initialized with a different config file 68 : : */ 69 : : bool initFromOpenDriveContent(std::string const &openDriveContent, 70 : : double const overlapMargin, 71 : : intersection::IntersectionType const defaultIntersectionType, 72 : : landmark::TrafficLightType const defaultTrafficLightType 73 : : = landmark::TrafficLightType::SOLID_RED_YELLOW_GREEN); 74 : : /** 75 : : * @brief initialize singleton with given store 76 : : * 77 : : * No map files will be read. The store has to be filled by other means. 78 : : */ 79 : : bool init(Store::Ptr store); 80 : : 81 : : /** 82 : : * @brief remove all loaded maps and configuration 83 : : */ 84 : : void cleanup(); 85 : : 86 : : /** 87 : : * @brief set the current ENU reference point 88 : : * 89 : : * @param[in] point the geo point defining the reference point 90 : : */ 91 : : void setENUReferencePoint(point::GeoPoint const &point); 92 : : 93 : : /** 94 : : * @brief get the current ENU reference point set in the map 95 : : * 96 : : * @returns Set ENU reference point in Geo coordinates 97 : : */ 98 : : point::GeoPoint getENUReferencePoint(); 99 : : 100 : : /** 101 : : * @brief check if ENU Reference Point is set 102 : : */ 103 : : bool isENUReferencePointSet(); 104 : : 105 : : /** 106 : : * @brief get points of interest in the surrounding of a given geoPoint 107 : : * 108 : : * @param[in] geoPoint GeoPoint to be used to query the POIs 109 : : * @param[in] radius radius to be use for the query 110 : : * 111 : : * @returns the list with the PointOfInterest within the queried region. 112 : : */ 113 : : std::vector<config::PointOfInterest> getPointsOfInterest(point::GeoPoint const &geoPoint, 114 : : physics::Distance const &radius); 115 : : 116 : : /** 117 : : * @brief get all points of interest 118 : : * 119 : : * @returns the complete list of PointOfInterest currently available 120 : : */ 121 : : std::vector<config::PointOfInterest> const &getPointsOfInterest(); 122 : : 123 : : /** 124 : : * @brief get a certain point of interest if exists 125 : : * 126 : : * Calls getPointsOfInterest() and searches for the point with the given name. 127 : : * 128 : : * @param[in] name the name of the POI to query 129 : : * @param[out] poi the found PointOfInterest 130 : : * 131 : : * @returns \c true if the PointOfInterest with the given \a name if exits 132 : : */ 133 : : bool getPointOfInterest(std::string const &name, config::PointOfInterest &poi); 134 : : 135 : : /** 136 : : * @returns \c true if the map is a left hand traffic map 137 : : */ 138 : : bool isLeftHandedTraffic(); 139 : : 140 : : /** 141 : : * @returns \c true if the map is a left hand traffic map 142 : : */ 143 : : bool isRightHandedTraffic(); 144 : : 145 : : /** 146 : : * @returns reference to the map store object 147 : : */ 148 : : Store &getStore(); 149 : : 150 : : } // namespace access 151 : : } // namespace map 152 : : } // namespace ad