SUMO - Simulation of Urban MObility
NIImporter_VISUM.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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A VISUM network importer
19 /****************************************************************************/
20 #ifndef NIImporter_VISUM_h
21 #define NIImporter_VISUM_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <map>
35 #include <vector>
40 #include "NIVisumTL.h"
41 
42 
43 // ===========================================================================
44 // class declaration
45 // ===========================================================================
46 class OptionsCont;
47 class NBNetBuilder;
48 class NBNodeCont;
49 class NBEdgeCont;
50 class NBNode;
51 class NBEdge;
52 
53 
54 // ===========================================================================
55 // class declaration
56 // ===========================================================================
76 public:
88  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
89 
90 
91 protected:
102  NIImporter_VISUM(NBNetBuilder& nb, const std::string& file,
103  NBCapacity2Lanes capacity2Lanes, bool useVisumPrio);
104 
105 
108 
109 
120  void load();
121 
122 private:
131  double getNamedFloat(const std::string& fieldName);
132 
142  double getNamedFloat(const std::string& fieldName1, const std::string& fieldName2);
143 
144 
151  double getNamedFloat(const std::string& fieldName, double defaultValue);
152 
160  double getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
161  double defaultValue);
162 
163 
174  std::string getNamedString(const std::string& fieldName);
175 
185  std::string getNamedString(const std::string& fieldName1, const std::string& fieldName2);
186 
187 
197  double getWeightedFloat(const std::string& name);
198 
199 
209  bool getWeightedBool(const std::string& name);
210 
211 
224  NBNode* getNamedNode(const std::string& fieldName);
225 
235  NBNode* getNamedNode(const std::string& fieldName1, const std::string& fieldName2);
236 
237 
250  NBEdge* getNamedEdge(const std::string& fieldName);
251 
261  NBEdge* getNamedEdge(const std::string& fieldName1, const std::string& fieldName2);
262 
263 
278  NBEdge* getNamedEdgeContinuating(const std::string& fieldName, NBNode* node);
279 
290  NBEdge* getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
291  NBNode* node);
292 
300 
301 
308  NBEdge* getEdge(NBNode* FromNode, NBNode* ToNode);
309 
310 
322 
323 
336  NBNode* buildDistrictNode(const std::string& id, NBNode* dest, bool isSource);
337 
338 
347  bool checkNodes(NBNode* from, NBNode* to);
348 
349 
350 private:
357  typedef void (NIImporter_VISUM::*ParsingFunction)();
358 
363  struct TypeParser {
367  std::string name;
368 
372  ParsingFunction function;
373 
378  long position;
379 
383  std::string pattern;
384 
385  };
386 
387 
388 
390  void parse_VSysTypes();
391 
393  void parse_Types();
394 
396  void parse_Nodes();
397 
399  void parse_Districts();
400 
402  void parse_Point();
403 
404 
406  void parse_Edges();
407 
409  void parse_PartOfArea();
410 
412  void parse_Kante();
413 
414 
416  void parse_Connectors();
417 
419  void parse_Turns();
420 
422  void parse_EdgePolys();
423 
425  void parse_Lanes();
426 
428  void parse_TrafficLights();
429 
432 
434  void parse_SignalGroups();
435 
438 
441 
443  void parse_Phases();
444 
447 
449  void parse_LanesConnections();
450 
451 
457  void addParser(const std::string& name, ParsingFunction function);
458 
459 
460 private:
463 
465  std::string myFileName;
466 
469 
474 
477 
479  typedef std::map<std::string, std::string> VSysTypeNames;
481  VSysTypeNames myVSysTypes;
482 
484  typedef std::vector<TypeParser> ParserVector;
486  ParserVector mySingleDataParsers;
487 
489  typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map;
491  NIVisumTL_Map myTLS;
492 
494  std::vector<std::string > myTouchedEdges;
495 
498 
500  std::string myCurrentID;
501 
502 
504  std::map<long long int, Position> myPoints;
505 
507  std::map<long long int, std::pair<long long int, long long int> > myEdges;
508 
510  std::map<long long int, NBDistrict*> myShapeDistrictMap;
511 
513  std::map<long long int, std::vector<long long int> > mySubPartsAreas;
514 
516  std::map<NBDistrict*, PositionVector> myDistrictShapes;
517 
518 
519 };
520 
521 
522 #endif
523 
524 /****************************************************************************/
525 
long position
Position of the according db within the file.
void parse_NodesToTrafficLights()
Parses KNOTENZULSA/SIGNALANLAGEZUKNOTEN.
std::vector< TypeParser > ParserVector
Definition of the list of known parsers.
void parse_Kante()
Parses FLAECHENELEMENT.
bool myUseVisumPrio
Information whether VISUM priority information shall be used.
void load()
Parses the VISUM-network file storing the parsed structures within myNetBuilder.
std::map< NBDistrict *, PositionVector > myDistrictShapes
A temporary storage for district shapes as they are filled incrementally.
LineReader myLineReader
The line reader to use to read from the file.
std::vector< std::string > myTouchedEdges
Already read edges.
NBEdge * getNamedEdgeContinuating(const std::string &fieldName, NBNode *node)
Tries to get the edge which name is stored in the given field continuating the search for a subedge t...
std::string myCurrentID
The name of the currently parsed item used for error reporting.
void parse_Turns()
Parses ABBIEGEBEZIEHUNG/ABBIEGER.
Retrieves a file linewise and reports the lines to a handler.
Definition: LineReader.h:57
VSysTypeNames myVSysTypes
The used vsystypes.
NBNode * getNamedNode(const std::string &fieldName)
Tries to get the node which name is stored in the given field.
void parse_TrafficLights()
Parses LSA/SIGNALANLAGE.
A helper class which computes the lane number from given capacity.
The representation of a single edge during network building.
Definition: NBEdge.h:70
double getWeightedFloat(const std::string &name)
tries to get a double which is possibly assigned to a certain modality
void parse_PartOfArea()
Parses FLAECHENELEMENT.
void parse_SignalGroupsToPhases()
Parses LSASIGNALGRUPPEZULSAPHASE.
NIImporter_VISUM(NBNetBuilder &nb, const std::string &file, NBCapacity2Lanes capacity2Lanes, bool useVisumPrio)
constructor
void parse_EdgePolys()
Parses STRECKENPOLY.
void parse_Phases()
Parses LSAPHASE/PHASE.
std::string myFileName
The name of the parsed file, for error reporting.
void parse_AreaSubPartElement()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
std::map< std::string, std::string > VSysTypeNames
Definition of a storage for vsystypes.
NBEdge * getReversedContinuating(NBEdge *edge, NBNode *node)
Returns the opposite direction of the given edge.
void parse_SignalGroups()
Parses LSASIGNALGRUPPE/SIGNALGRUPPE.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder...
A VISUM network importer.
void parse_TurnsToSignalGroups()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
std::string pattern
The column names.
std::string getNamedString(const std::string &fieldName)
Returns the value from the named column as a normalised string.
double getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
std::map< long long int, std::pair< long long int, long long int > > myEdges
A map of edge (not road, but "edge" in this case) ids to from/to-points.
A complete call description for parsing a single db.
NIVisumTL_Map myTLS
List of visum traffic lights.
void parse_Connectors()
Parses ANBINDUNG.
std::map< long long int, std::vector< long long int > > mySubPartsAreas
A map from area parts to area ids.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
void parse_Districts()
Parses BEZIRK.
void addParser(const std::string &name, ParsingFunction function)
Adds a parser into the sorted list of parsers to use.
ParserVector mySingleDataParsers
List of known parsers.
std::map< long long int, Position > myPoints
A map of point ids to positions.
void parse_Point()
Parses PUNKT.
void(NIImporter_VISUM::* ParsingFunction)()
Definition of a function for parsing a single line from a certain db.
NBEdge * getEdge(NBNode *FromNode, NBNode *ToNode)
Returns the edge that connects both nodes.
std::map< std::string, NIVisumTL * > NIVisumTL_Map
Definition of a map for loaded traffic lights (id->tls)
void parse_VSysTypes()
Parses VSYS.
void parse_Types()
Parses STRECKENTYP.
void parse_Nodes()
Parses KNOTEN.
void parse_Lanes()
Parses FAHRSTREIFEN.
~NIImporter_VISUM()
destructor
Instance responsible for building networks.
Definition: NBNetBuilder.h:115
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
std::map< long long int, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
A storage for options typed value containers)
Definition: OptionsCont.h:98
std::string name
The name of the db.
NBNode * buildDistrictNode(const std::string &id, NBNode *dest, bool isSource)
Builds a node for the given district and returns it.
Represents a single node (junction) during network building.
Definition: NBNode.h:74
bool getWeightedBool(const std::string &name)
tries to get a bool which is possibly assigned to a certain modality
A parser to retrieve information from a table with known columns.
void parse_Edges()
Parses STRECKE/STRECKEN.
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:66
bool checkNodes(NBNode *from, NBNode *to)
Returns whether both nodes are a valid combination of from/to-nodes.
NBEdge * getNamedEdge(const std::string &fieldName)
Tries to get the edge which name is stored in the given field.
NBCapacity2Lanes myCapacity2Lanes
The converter to compute the lane number of edges from their capacity.
void parse_LanesConnections()
Parses FAHRSTREIFENABBIEGER.