SUMO - Simulation of Urban MObility
NIImporter_VISUM.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A VISUM network importer
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef NIImporter_VISUM_h
22 #define NIImporter_VISUM_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <vector>
41 #include "NIVisumTL.h"
42 
43 
44 // ===========================================================================
45 // class declaration
46 // ===========================================================================
47 class OptionsCont;
48 class NBNetBuilder;
49 class NBNodeCont;
50 class NBEdgeCont;
51 class NBNode;
52 class NBEdge;
53 
54 
55 // ===========================================================================
56 // class declaration
57 // ===========================================================================
77 public:
89  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
90 
91 
92 protected:
103  NIImporter_VISUM(NBNetBuilder& nb, const std::string& file,
104  NBCapacity2Lanes capacity2Lanes, bool useVisumPrio);
105 
106 
109 
110 
121  void load();
122 
123 private:
132  SUMOReal getNamedFloat(const std::string& fieldName);
133 
143  SUMOReal getNamedFloat(const std::string& fieldName1, const std::string& fieldName2);
144 
145 
152  SUMOReal getNamedFloat(const std::string& fieldName, SUMOReal defaultValue);
153 
161  SUMOReal getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
162  SUMOReal defaultValue);
163 
164 
175  std::string getNamedString(const std::string& fieldName);
176 
186  std::string getNamedString(const std::string& fieldName1, const std::string& fieldName2);
187 
188 
198  SUMOReal getWeightedFloat(const std::string& name);
199 
200 
210  bool getWeightedBool(const std::string& name);
211 
212 
225  NBNode* getNamedNode(const std::string& fieldName);
226 
236  NBNode* getNamedNode(const std::string& fieldName1, const std::string& fieldName2);
237 
238 
251  NBEdge* getNamedEdge(const std::string& fieldName);
252 
262  NBEdge* getNamedEdge(const std::string& fieldName1, const std::string& fieldName2);
263 
264 
279  NBEdge* getNamedEdgeContinuating(const std::string& fieldName, NBNode* node);
280 
291  NBEdge* getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
292  NBNode* node);
293 
301 
302 
309  NBEdge* getEdge(NBNode* FromNode, NBNode* ToNode);
310 
311 
323 
324 
337  NBNode* buildDistrictNode(const std::string& id, NBNode* dest, bool isSource);
338 
339 
348  bool checkNodes(NBNode* from, NBNode* to);
349 
350 
351 private:
358  typedef void (NIImporter_VISUM::*ParsingFunction)();
359 
364  struct TypeParser {
368  std::string name;
369 
373  ParsingFunction function;
374 
379  long position;
380 
384  std::string pattern;
385 
386  };
387 
388 
389 
391  void parse_VSysTypes();
392 
394  void parse_Types();
395 
397  void parse_Nodes();
398 
400  void parse_Districts();
401 
403  void parse_Point();
404 
405 
407  void parse_Edges();
408 
410  void parse_PartOfArea();
411 
413  void parse_Kante();
414 
415 
417  void parse_Connectors();
418 
420  void parse_Turns();
421 
423  void parse_EdgePolys();
424 
426  void parse_Lanes();
427 
429  void parse_TrafficLights();
430 
433 
435  void parse_SignalGroups();
436 
439 
442 
444  void parse_Phases();
445 
448 
450  void parse_LanesConnections();
451 
452 
458  void addParser(const std::string& name, ParsingFunction function);
459 
460 
461 private:
464 
466  std::string myFileName;
467 
470 
475 
478 
480  typedef std::map<std::string, std::string> VSysTypeNames;
482  VSysTypeNames myVSysTypes;
483 
485  typedef std::vector<TypeParser> ParserVector;
487  ParserVector mySingleDataParsers;
488 
490  typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map;
492  NIVisumTL_Map myTLS;
493 
495  std::vector<std::string > myTouchedEdges;
496 
499 
501  std::string myCurrentID;
502 
503 
505  std::map<SUMOLong, Position> myPoints;
506 
508  std::map<SUMOLong, std::pair<SUMOLong, SUMOLong> > myEdges;
509 
511  std::map<SUMOLong, NBDistrict*> myShapeDistrictMap;
512 
514  std::map<SUMOLong, std::vector<SUMOLong> > mySubPartsAreas;
515 
517  std::map<NBDistrict*, PositionVector> myDistrictShapes;
518 
519 
520 };
521 
522 
523 #endif
524 
525 /****************************************************************************/
526 
std::map< SUMOLong, Position > myPoints
A map of point ids to positions.
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:58
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:71
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.
SUMOReal getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
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.
SUMOReal getWeightedFloat(const std::string &name)
tries to get a SUMOReal which is possibly assigned to a certain modality
std::string getNamedString(const std::string &fieldName)
Returns the value from the named column as a normalised string.
A complete call description for parsing a single db.
NIVisumTL_Map myTLS
List of visum traffic lights.
void parse_Connectors()
Parses ANBINDUNG.
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.
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.
std::map< SUMOLong, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
std::map< SUMOLong, std::vector< SUMOLong > > mySubPartsAreas
A map from area parts to area ids.
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:113
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
A storage for options typed value containers)
Definition: OptionsCont.h:108
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:75
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.
std::map< SUMOLong, std::pair< SUMOLong, SUMOLong > > myEdges
A map of edge (not road, but "edge" in this case) ids to from/to-points.
void parse_Edges()
Parses STRECKE/STRECKEN.
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
#define SUMOReal
Definition: config.h:215
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:64
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.