Apollo  6.0
Open source self driving car software
topo_graph.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_map>
22 #include <unordered_set>
23 #include <vector>
24 
25 #include "cyber/common/log.h"
27 
28 namespace apollo {
29 namespace routing {
30 
31 class TopoGraph {
32  public:
33  TopoGraph() = default;
34  ~TopoGraph() = default;
35 
36  bool LoadGraph(const Graph& filename);
37 
38  const std::string& MapVersion() const;
39  const std::string& MapDistrict() const;
40  const TopoNode* GetNode(const std::string& id) const;
41  void GetNodesByRoadId(
42  const std::string& road_id,
43  std::unordered_set<const TopoNode*>* const node_in_road) const;
44 
45  private:
46  void Clear();
47  bool LoadNodes(const Graph& graph);
48  bool LoadEdges(const Graph& graph);
49 
50  private:
51  std::string map_version_;
52  std::string map_district_;
53  std::vector<std::shared_ptr<TopoNode> > topo_nodes_;
54  std::vector<std::shared_ptr<TopoEdge> > topo_edges_;
55  std::unordered_map<std::string, int> node_index_map_;
56  std::unordered_map<std::string, std::unordered_set<const TopoNode*> >
57  road_node_map_;
58 };
59 
60 } // namespace routing
61 } // namespace apollo
const std::string & MapDistrict() const
Definition: topo_node.h:32
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
const std::string & MapVersion() const
const TopoNode * GetNode(const std::string &id) const
bool LoadGraph(const Graph &filename)
Definition: topo_graph.h:31
void GetNodesByRoadId(const std::string &road_id, std::unordered_set< const TopoNode *> *const node_in_road) const