ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
idtranslation.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Daniel Heß - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 
17 #include <OpenDRIVE_1.4H.h>
18 #include <unordered_map>
20 #include <vector>
21 
22 
23 namespace adore
24 {
25  namespace if_xodr
26  {
27 
32  {
33  public:
34  // typedef long long int TID;//integral data type used for integral ids
35  typedef std::string TID;
38  typedef std::unordered_map<BorderID, TID, BorderIDHasher> BorderID2TID;
39  typedef std::unordered_multimap<TID,BorderID> TID2MultiBorderID;
40  typedef std::unordered_map<TID,TID> TIDmap;
41  typedef std::unordered_multimap<TID,TID> TIDmultimap;
42  typedef TID2MultiBorderID::iterator Iterator;
43  typedef std::pair<Iterator,Iterator> IteratorPair;
44  typedef std::vector<BorderID> BorderIDVector;
45 
46  private:
47  BorderID2TID borderID2roadID_;// borderID -> roadID
48  TID2MultiBorderID roadID2borderID_;// roadID -> {borderID1,...,borderIDn}
49  TIDmap roadID2junctionID_;//roadID -> junctionID (maps to a junctionID, if road is a connection road of a junction)
50  TIDmultimap junctionID2roadID_;//junctionID -> {roadID1,...,roadIDn} (maps from a junctionid to all connecting roads)
52 
53  public:
57  void insert(const BorderID& borderID,TID roadID)
58  {
59  borderID2roadID_.emplace(borderID,roadID);
60  roadID2borderID_.emplace(roadID,borderID);
61  }
65  void insert(TID junctionID,TID roadID)
66  {
67  roadID2junctionID_.emplace(roadID,junctionID);
68  junctionID2roadID_.emplace(junctionID,roadID);
69  }
70 
75  {
76  return std::make_pair(roadID2borderID_.find(roadID),roadID2borderID_.end());
77  }
78 
79 
84  {
85  BorderIDVector borderIDs;
86  for(auto it = junctionID2roadID_.find(junctionID);it!=junctionID2roadID_.end();it++)
87  {
88  for(auto it2 = roadID2borderID_.find(it->second);it2!=roadID2borderID_.end();it2++)
89  {
90  borderIDs.push_back(it2->second);
91  }
92  }
93  return borderIDs;
94  }
95 
99  TID getRoadID(const BorderID& borderID)
100  {
101  auto it = borderID2roadID_.find(borderID);
102  if(it==borderID2roadID_.end())return default_empty_id_;
103  else return it->second;
104  }
105 
109  TID getJunctionID(const BorderID& borderID)
110  {
111  auto it = borderID2roadID_.find(borderID);
112  if(it==borderID2roadID_.end())return default_empty_id_;
113  auto it2 = roadID2junctionID_.find(it->second);
114  if(it2==roadID2junctionID_.end())return default_empty_id_;
115  else return it2->second;
116  }
117 
121  bool isInJunction(TID roadID)
122  {
123  return roadID2junctionID_.find(roadID)!=roadID2junctionID_.end();
124  }
125 
129  bool isInJunction(const BorderID& borderID)
130  {
131  auto it = borderID2roadID_.find(borderID);
132  if(it==borderID2roadID_.end())return false;
133  else return roadID2junctionID_.find(it->second)!=roadID2junctionID_.end();
134  }
135 
136  };
137  }
138 }
BorderIDTranslation is a set of translation tables, which keeps track of road ids,...
Definition: idtranslation.h:32
std::unordered_multimap< TID, TID > TIDmultimap
Definition: idtranslation.h:41
BorderIDVector getBorderIDsOfJunction(TID junctionID)
Definition: idtranslation.h:83
std::unordered_map< TID, TID > TIDmap
Definition: idtranslation.h:40
std::vector< BorderID > BorderIDVector
Definition: idtranslation.h:44
adore::env::BorderBased::BorderID BorderID
Definition: idtranslation.h:36
BorderID2TID borderID2roadID_
Definition: idtranslation.h:47
TIDmap roadID2junctionID_
Definition: idtranslation.h:49
TID2MultiBorderID roadID2borderID_
Definition: idtranslation.h:48
std::unordered_multimap< TID, BorderID > TID2MultiBorderID
Definition: idtranslation.h:39
IteratorPair getBorderIDsOfRoad(TID roadID)
Definition: idtranslation.h:74
adore::env::BorderBased::BorderIDHasher BorderIDHasher
Definition: idtranslation.h:37
TID2MultiBorderID::iterator Iterator
Definition: idtranslation.h:42
void insert(const BorderID &borderID, TID roadID)
Definition: idtranslation.h:57
TID getRoadID(const BorderID &borderID)
Definition: idtranslation.h:99
TID default_empty_id_
Definition: idtranslation.h:51
std::string TID
Definition: idtranslation.h:35
TID getJunctionID(const BorderID &borderID)
Definition: idtranslation.h:109
bool isInJunction(TID roadID)
Definition: idtranslation.h:121
std::pair< Iterator, Iterator > IteratorPair
Definition: idtranslation.h:43
std::unordered_map< BorderID, TID, BorderIDHasher > BorderID2TID
Definition: idtranslation.h:38
void insert(TID junctionID, TID roadID)
Definition: idtranslation.h:65
bool isInJunction(const BorderID &borderID)
Definition: idtranslation.h:129
TIDmultimap junctionID2roadID_
Definition: idtranslation.h:50
Definition: areaofeffectconverter.h:20
a functor, which hashes a BorderID object -> std::unordered_set<BorderID,BorderIDHasher> amap(0);
Definition: borderid.h:176
This struct identifies a Border by the coordinates of the starting and the end point.
Definition: borderid.h:31