Eclipse SUMO - Simulation of Urban MObility
NIImporter_ITSUMO.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Importer for networks stored in ITSUMO format
16 /****************************************************************************/
17 #ifndef NIImporter_ITSUMO_h
18 #define NIImporter_ITSUMO_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <map>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class NBEdge;
37 class NBEdgeCont;
38 class NBNetBuilder;
39 class NBNode;
40 class NBNodeCont;
42 class NBTypeCont;
43 class OptionsCont;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
55 public:
67  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
68 
69 
70 private:
75  class Handler : public GenericSAXHandler {
76  public:
80  Handler(NBNetBuilder& toFill);
81 
82 
84  ~Handler();
85 
86 
87  protected:
89 
90 
98  void myStartElement(int element, const SUMOSAXAttributes& attrs);
99 
100 
109  void myCharacters(int element, const std::string& chars);
110 
111 
118  void myEndElement(int element);
120 
121 
122  private:
125 
127  std::map<std::string, std::string> myParameter;
128 
129 
130  struct Lane {
131  public:
132  Lane(const std::string& _id, int _idx, double _v)
133  : id(_id), index(_idx), v(_v) {}
134  std::string id;
135  int index;
136  double v;
137  };
138 
139  std::vector<Lane> myCurrentLanes;
140 
141  struct LaneSet {
142  public:
143  LaneSet(const std::string& _id, const std::vector<Lane>& _lanes, double _v, int _pos, NBNode* _from, NBNode* _to)
144  : id(_id), lanes(_lanes), v(_v), position(_pos), from(_from), to(_to) {}
145  std::string id;
146  std::vector<Lane> lanes;
147  double v;
148  int position;
151  };
152 
153  std::map<std::string, LaneSet*> myLaneSets;
154  std::vector<LaneSet*> myCurrentLaneSets;
155 
156  struct Section {
157  public:
158  Section(const std::string& _id, const std::vector<LaneSet*>& _laneSets)
159  : id(_id), laneSets(_laneSets) {}
160  std::string id;
161  std::vector<LaneSet*> laneSets;
162  };
163 
164  std::vector<Section*> mySections;
165 
166 
167  private:
169  Handler(const Handler& s);
170 
172  Handler& operator=(const Handler& s);
173 
174  };
175 
176 
177 
223  };
224 
225 
233  };
234 
237 
240 
241 
242 };
243 
244 
245 #endif
246 
247 /****************************************************************************/
248 
Lane(const std::string &_id, int _idx, double _v)
std::vector< Section * > mySections
A container for traffic light definitions and built programs.
std::vector< Lane > myCurrentLanes
The representation of a single edge during network building.
Definition: NBEdge.h:86
Handler & operator=(const Handler &s)
invalidated assignment operator
LaneSet(const std::string &_id, const std::vector< Lane > &_lanes, double _v, int _pos, NBNode *_from, NBNode *_to)
std::vector< LaneSet * > myCurrentLaneSets
static StringBijection< int >::Entry itsumoAttrs[]
The names of MATSIM-XML attributes (for passing to GenericSAXHandler)
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
A handler which converts occuring elements and attributes into enums.
ItsumoXMLTag
Numbers representing ITSUMO-XML - element names.
static StringBijection< int >::Entry itsumoTags[]
The names of MATSIM-XML elements (for passing to GenericSAXHandler)
Section(const std::string &_id, const std::vector< LaneSet *> &_laneSets)
Encapsulated SAX-Attributes.
void myCharacters(int element, const std::string &chars)
Callback method for characters to implement by derived classes.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
std::map< std::string, std::string > myParameter
A temporary parameter map.
Importer for networks stored in ITSUMO format.
Instance responsible for building networks.
Definition: NBNetBuilder.h:110
A storage for options typed value containers)
Definition: OptionsCont.h:90
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given ITSUMO network files.
Represents a single node (junction) during network building.
Definition: NBNode.h:68
ItsumoXMLAttr
Numbers representing MATSIM-XML - attributes.
NBNetBuilder & myNetBuilder
The container to fill.
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
std::map< std::string, LaneSet * > myLaneSets
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Handler(NBNetBuilder &toFill)
Contructor.
A storage for available types of edges.
Definition: NBTypeCont.h:55