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 : : #include "ad/map/access/Operation.hpp" 10 : : 11 : : #include <boost/filesystem/path.hpp> 12 : : 13 : : #include "AdMapAccess.hpp" 14 : : #include "ad/map/config/MapConfigFileHandler.hpp" 15 : : #include "ad/map/opendrive/AdMapFactory.hpp" 16 : : #include "ad/map/point/Operation.hpp" 17 : : #include "ad/map/point/Transform.hpp" 18 : : 19 : : #include "ad/map/serialize/SerializerFileCRC32.hpp" 20 : : 21 : : namespace ad { 22 : : namespace map { 23 : : namespace access { 24 : : 25 : 201 : void setENUReferencePoint(point::GeoPoint const &point) 26 : : { 27 [ + - ]: 402 : auto coordinateTransform = getCoordinateTransform(); 28 [ + - + + : 201 : if (!coordinateTransform->isENUValid() || (coordinateTransform->getENUReferencePoint() != point)) + - + - + + + + ] 29 : : { 30 [ + - ]: 200 : coordinateTransform->setENUReferencePoint(point); 31 : : } 32 : 201 : } 33 : : 34 : 520821 : std::shared_ptr<point::CoordinateTransform> getCoordinateTransform() 35 : : { 36 : : // coordinate transform (at least without ENURefPoint) can actually used before initialization 37 : : // therefore, return the transform without initialization check 38 : 520821 : return AdMapAccess::getAdMapAccessInstance().mCoordinateTransform; 39 : : } 40 : : 41 : 452 : point::GeoPoint getENUReferencePoint() 42 : : { 43 : 452 : return AdMapAccess::getAdMapAccessInstance().mCoordinateTransform->getENUReferencePoint(); 44 : : } 45 : : 46 : 2 : bool isENUReferencePointSet() 47 : : { 48 : 2 : return AdMapAccess::getAdMapAccessInstance().mCoordinateTransform->isENUValid(); 49 : : } 50 : : 51 : 2 : std::vector<config::PointOfInterest> getPointsOfInterest(point::GeoPoint const &geoPoint, 52 : : physics::Distance const &radius) 53 : : { 54 : 2 : std::vector<config::PointOfInterest> resultVector; 55 [ + - ]: 2 : point::ECEFPoint const geoPointEcef = point::toECEF(geoPoint); 56 [ + - + - : 4 : for (auto const &poi : AdMapAccess::getInitializedInstance().mConfigFileHandler.pointsOfInterest()) + + ] 57 : : { 58 [ + - ]: 2 : point::ECEFPoint const poiPointEcef = point::toECEF(poi.geoPoint); 59 [ + - ]: 2 : physics::Distance const poiDistance = point::distance(poiPointEcef, geoPointEcef); 60 [ + - + + ]: 2 : if (poiDistance <= radius) 61 : : { 62 [ + - ]: 1 : resultVector.push_back(poi); 63 : : } 64 : : } 65 : 4 : return resultVector; 66 : : } 67 : : 68 : 70 : std::vector<config::PointOfInterest> const &getPointsOfInterest() 69 : : { 70 : 70 : return AdMapAccess::getInitializedInstance().mConfigFileHandler.pointsOfInterest(); 71 : : } 72 : : 73 : 4 : bool getPointOfInterest(std::string const &name, config::PointOfInterest &poi) 74 : : { 75 [ + - + - : 4 : for (auto pointOfInterest : getPointsOfInterest()) + - ] 76 : : { 77 [ + - ]: 4 : if (pointOfInterest.name == name) 78 : : { 79 [ + - ]: 4 : poi = pointOfInterest; 80 : 4 : return true; 81 : : } 82 : : } 83 : 0 : return false; 84 : : } 85 : : 86 : 196 : bool init(std::string const &configFileName) 87 : : { 88 : : // initialization has to be performed without initialization check 89 : 196 : return AdMapAccess::getAdMapAccessInstance().initialize(configFileName); 90 : : } 91 : : 92 : 6 : bool initFromOpenDriveContent(std::string const &openDriveContent, 93 : : double const overlapMargin, 94 : : intersection::IntersectionType const defaultIntersectionType, 95 : : landmark::TrafficLightType const defaultTrafficLightType) 96 : : { 97 : 6 : return AdMapAccess::getAdMapAccessInstance().initializeFromOpenDriveContent( 98 : 6 : openDriveContent, overlapMargin, defaultIntersectionType, defaultTrafficLightType); 99 : : } 100 : : 101 : 29 : bool init(Store::Ptr store) 102 : : { 103 : : // initialization has to be performed without initialization check 104 [ + - ]: 29 : return AdMapAccess::getAdMapAccessInstance().initialize(store); 105 : : } 106 : : 107 : 443 : void cleanup() 108 : : { 109 : : // initialization has to be performed without initialization check 110 : 443 : AdMapAccess::getAdMapAccessInstance().reset(); 111 : 443 : } 112 : : 113 : 10 : bool isLeftHandedTraffic() 114 : : { 115 : 10 : return getStore().getMetaData().trafficType == TrafficType::LEFT_HAND_TRAFFIC; 116 : : } 117 : : 118 : 736 : bool isRightHandedTraffic() 119 : : { 120 : 736 : return getStore().getMetaData().trafficType == TrafficType::RIGHT_HAND_TRAFFIC; 121 : : } 122 : : 123 : 900436 : Store &getStore() 124 : : { 125 : 900436 : return *AdMapAccess::getInitializedInstance().mStore; 126 : : } 127 : : 128 : : } // namespace access 129 : : } // namespace map 130 : : } // namespace ad