Eclipse 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-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 // A VISUM network importer
16 /****************************************************************************/
17 #ifndef NIImporter_VISUM_h
18 #define NIImporter_VISUM_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <map>
28 #include <vector>
33 #include "NIVisumTL.h"
34 
35 
36 // ===========================================================================
37 // class declaration
38 // ===========================================================================
39 class OptionsCont;
40 class NBNetBuilder;
41 class NBNodeCont;
42 class NBEdgeCont;
43 class NBNode;
44 class NBEdge;
45 
46 
47 // ===========================================================================
48 // class declaration
49 // ===========================================================================
69 public:
81  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
82 
83 
84 protected:
95  NIImporter_VISUM(NBNetBuilder& nb, const std::string& file,
96  NBCapacity2Lanes capacity2Lanes, bool useVisumPrio,
97  const std::string& languageFile);
98 
99 
102 
103 
114  void load();
115 
116 private:
125  double getNamedFloat(const std::string& fieldName);
126 
136  double getNamedFloat(const std::string& fieldName1, const std::string& fieldName2);
137 
138 
145  double getNamedFloat(const std::string& fieldName, double defaultValue);
146 
154  double getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
155  double defaultValue);
156 
157 
168  std::string getNamedString(const std::string& fieldName);
169 
179  std::string getNamedString(const std::string& fieldName1, const std::string& fieldName2);
180 
181 
191  double getWeightedFloat(const std::string& name, const std::string& suffix);
192 
194  double getWeightedFloat2(const std::string& name, const std::string& name2, const std::string& suffix);
195 
197  SVCPermissions getPermissions(const std::string& name, bool warn = false, SVCPermissions unknown = SVCAll);
198 
208  bool getWeightedBool(const std::string& name);
209 
210 
223  NBNode* getNamedNode(const std::string& fieldName);
224  NBNode* getNamedNodeSecure(const std::string& fieldName, NBNode* fallback = 0);
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();
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 private:
461 
463  static bool isSplitEdge(NBEdge* edge, NBNode* node);
464 
465 
466 private:
469 
471  std::string myFileName;
472 
475 
480 
483 
485  typedef std::map<std::string, std::string> VSysTypeNames;
488 
490  typedef std::vector<TypeParser> ParserVector;
493 
495  typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map;
498 
500  std::vector<std::string > myTouchedEdges;
501 
504 
506  std::string myCurrentID;
507 
508 
510  std::map<long long int, Position> myPoints;
511 
513  std::map<long long int, std::pair<long long int, long long int> > myEdges;
514 
516  std::map<long long int, NBDistrict*> myShapeDistrictMap;
517 
519  std::map<long long int, std::vector<long long int> > mySubPartsAreas;
520 
522  std::map<NBDistrict*, PositionVector> myDistrictShapes;
523 
524 protected:
529  enum VISUM_KEY {
567  VISUM_NO // must be the last one
568  };
569 
572 
575 
576  void loadLanguage(const std::string& file);
577 };
578 
579 
580 #endif
581 
582 /****************************************************************************/
NIImporter_VISUM::getNamedString
std::string getNamedString(const std::string &fieldName)
Returns the value from the named column as a normalised string.
Definition: NIImporter_VISUM.cpp:1427
NIImporter_VISUM::parse_VSysTypes
void parse_VSysTypes()
Parses VSYS.
Definition: NIImporter_VISUM.cpp:267
NIImporter_VISUM::getEdge
NBEdge * getEdge(NBNode *FromNode, NBNode *ToNode)
Returns the edge that connects both nodes.
Definition: NIImporter_VISUM.cpp:1373
NIImporter_VISUM::getWeightedBool
bool getWeightedBool(const std::string &name)
tries to get a bool which is possibly assigned to a certain modality
Definition: NIImporter_VISUM.cpp:1180
LineReader.h
NIImporter_VISUM::parse_Connectors
void parse_Connectors()
Parses ANBINDUNG.
Definition: NIImporter_VISUM.cpp:494
NBEdgeCont
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:60
NBNetBuilder
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
NIImporter_VISUM::VISUM_FROMPOINTID
@ VISUM_FROMPOINTID
Definition: NIImporter_VISUM.h:554
NIImporter_VISUM::parse_LanesConnections
void parse_LanesConnections()
Parses FAHRSTREIFENABBIEGER.
Definition: NIImporter_VISUM.cpp:1047
NIImporter_VISUM::KEYS_DE
static StringBijection< VISUM_KEY >::Entry KEYS_DE[]
Strings for the keywords.
Definition: NIImporter_VISUM.h:571
NIImporter_VISUM::getWeightedFloat2
double getWeightedFloat2(const std::string &name, const std::string &name2, const std::string &suffix)
as above but with two alternative names
Definition: NIImporter_VISUM.cpp:1170
NIImporter_VISUM::VISUM_TOPOINTID
@ VISUM_TOPOINTID
Definition: NIImporter_VISUM.h:555
NIImporter_VISUM::mySubPartsAreas
std::map< long long int, std::vector< long long int > > mySubPartsAreas
A map from area parts to area ids.
Definition: NIImporter_VISUM.h:519
NIImporter_VISUM::myNetBuilder
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
Definition: NIImporter_VISUM.h:468
NIImporter_VISUM::parse_Districts
void parse_Districts()
Parses BEZIRK.
Definition: NIImporter_VISUM.cpp:322
NIImporter_VISUM::VISUM_SOURCE_DISTRICT
@ VISUM_SOURCE_DISTRICT
Definition: NIImporter_VISUM.h:549
NIImporter_VISUM::VISUM_CAPACITY
@ VISUM_CAPACITY
Definition: NIImporter_VISUM.h:539
NIImporter_VISUM::VISUM_ORIGIN
@ VISUM_ORIGIN
Definition: NIImporter_VISUM.h:565
NIImporter_VISUM::myUseVisumPrio
bool myUseVisumPrio
Information whether VISUM priority information shall be used.
Definition: NIImporter_VISUM.h:503
NIImporter_VISUM::parse_Lanes
void parse_Lanes()
Parses FAHRSTREIFEN.
Definition: NIImporter_VISUM.cpp:718
NIImporter_VISUM::ParsingFunction
void(NIImporter_VISUM::* ParsingFunction)()
Definition of a function for parsing a single line from a certain db.
Definition: NIImporter_VISUM.h:357
NIImporter_VISUM::parse_SignalGroups
void parse_SignalGroups()
Parses LSASIGNALGRUPPE/SIGNALGRUPPE.
Definition: NIImporter_VISUM.cpp:900
NIImporter_VISUM::VISUM_YCOORD
@ VISUM_YCOORD
Definition: NIImporter_VISUM.h:541
NIImporter_VISUM::VISUM_FACEID
@ VISUM_FACEID
Definition: NIImporter_VISUM.h:553
NIImporter_VISUM::getPermissions
SVCPermissions getPermissions(const std::string &name, bool warn=false, SVCPermissions unknown=SVCAll)
parse permissions
Definition: NIImporter_VISUM.cpp:1191
NIImporter_VISUM::VISUM_TYPES
@ VISUM_TYPES
Definition: NIImporter_VISUM.h:537
NIImporter_VISUM::TypeParser::pattern
std::string pattern
The column names.
Definition: NIImporter_VISUM.h:383
NIImporter_VISUM::buildDistrictNode
NBNode * buildDistrictNode(const std::string &id, NBNode *dest, bool isSource)
Builds a node for the given district and returns it.
Definition: NIImporter_VISUM.cpp:1448
NIImporter_VISUM::NIVisumTL_Map
std::map< std::string, NIVisumTL * > NIVisumTL_Map
Definition of a map for loaded traffic lights (id->tls)
Definition: NIImporter_VISUM.h:495
NIImporter_VISUM::getNamedNodeSecure
NBNode * getNamedNodeSecure(const std::string &fieldName, NBNode *fallback=0)
Definition: NIImporter_VISUM.cpp:1232
NBNodeCont
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:59
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
NIImporter_VISUM::KEYS
static StringBijection< VISUM_KEY > KEYS
link directions
Definition: NIImporter_VISUM.h:574
NIImporter_VISUM::TypeParser::position
long position
Position of the according db within the file.
Definition: NIImporter_VISUM.h:378
NIImporter_VISUM::myShapeDistrictMap
std::map< long long int, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
Definition: NIImporter_VISUM.h:516
NIImporter_VISUM::parse_NodesToTrafficLights
void parse_NodesToTrafficLights()
Parses KNOTENZULSA/SIGNALANLAGEZUKNOTEN.
Definition: NIImporter_VISUM.cpp:880
NIImporter_VISUM::VISUM_DESTINATION
@ VISUM_DESTINATION
Definition: NIImporter_VISUM.h:566
NIImporter_VISUM::VISUM_FACEITEM
@ VISUM_FACEITEM
Definition: NIImporter_VISUM.h:563
NIImporter_VISUM::VISUM_FROMNODENO
@ VISUM_FROMNODENO
Definition: NIImporter_VISUM.h:550
NIImporter_VISUM::VISUM_NODE
@ VISUM_NODE
Definition: NIImporter_VISUM.h:532
NIImporter_VISUM::~NIImporter_VISUM
~NIImporter_VISUM()
destructor
Definition: NIImporter_VISUM.cpp:176
NamedColumnsParser.h
StringBijection
Definition: StringBijection.h:43
NIImporter_VISUM::myFileName
std::string myFileName
The name of the parsed file, for error reporting.
Definition: NIImporter_VISUM.h:471
NIImporter_VISUM::parse_Connectors_legacy
void parse_Connectors_legacy()
Definition: NIImporter_VISUM.cpp:529
NIImporter_VISUM::VISUM_CODE
@ VISUM_CODE
Definition: NIImporter_VISUM.h:547
NIImporter_VISUM::VISUM_EDGEID
@ VISUM_EDGEID
Definition: NIImporter_VISUM.h:564
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
NIImporter_VISUM::isSplitEdge
static bool isSplitEdge(NBEdge *edge, NBNode *node)
whether the edge id ends with _nodeID
Definition: NIImporter_VISUM.cpp:1485
NIImporter_VISUM::myCapacity2Lanes
NBCapacity2Lanes myCapacity2Lanes
The converter to compute the lane number of edges from their capacity.
Definition: NIImporter_VISUM.h:482
NIImporter_VISUM::NIImporter_VISUM
NIImporter_VISUM(NBNetBuilder &nb, const std::string &file, NBCapacity2Lanes capacity2Lanes, bool useVisumPrio, const std::string &languageFile)
constructor
Definition: NIImporter_VISUM.cpp:110
NIVisumTL.h
NIImporter_VISUM::VISUM_POINT
@ VISUM_POINT
Definition: NIImporter_VISUM.h:534
NIImporter_VISUM::VISUM_FROMNODE
@ VISUM_FROMNODE
Definition: NIImporter_VISUM.h:542
NIImporter_VISUM::parse_Turns
void parse_Turns()
Parses ABBIEGEBEZIEHUNG/ABBIEGER.
Definition: NIImporter_VISUM.cpp:633
NIImporter_VISUM::getNamedNode
NBNode * getNamedNode(const std::string &fieldName)
Tries to get the node which name is stored in the given field.
Definition: NIImporter_VISUM.cpp:1222
NIImporter_VISUM::TypeParser
A complete call description for parsing a single db.
Definition: NIImporter_VISUM.h:363
NIImporter_VISUM::load
void load()
Parses the VISUM-network file storing the parsed structures within myNetBuilder.
Definition: NIImporter_VISUM.cpp:194
NIImporter_VISUM::parse_PartOfArea
void parse_PartOfArea()
Parses FLAECHENELEMENT.
Definition: NIImporter_VISUM.cpp:483
NBCapacity2Lanes.h
NIImporter_VISUM::VISUM_XCOORD
@ VISUM_XCOORD
Definition: NIImporter_VISUM.h:540
NIImporter_VISUM::VISUM_TURN
@ VISUM_TURN
Definition: NIImporter_VISUM.h:559
NIImporter_VISUM::VISUM_KEY
VISUM_KEY
Definition: NIImporter_VISUM.h:529
NIImporter_VISUM::myLineParser
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
Definition: NIImporter_VISUM.h:479
NIImporter_VISUM::VISUM_LINKPOLY
@ VISUM_LINKPOLY
Definition: NIImporter_VISUM.h:561
NIImporter_VISUM::getNamedEdgeContinuating
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...
Definition: NIImporter_VISUM.cpp:1351
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NIImporter_VISUM
A VISUM network importer.
Definition: NIImporter_VISUM.h:68
NIImporter_VISUM::VISUM_VIANODENO
@ VISUM_VIANODENO
Definition: NIImporter_VISUM.h:557
NIImporter_VISUM::myEdges
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.
Definition: NIImporter_VISUM.h:513
NIImporter_VISUM::VISUM_SURFACEID
@ VISUM_SURFACEID
Definition: NIImporter_VISUM.h:552
NIImporter_VISUM::myDistrictShapes
std::map< NBDistrict *, PositionVector > myDistrictShapes
A temporary storage for district shapes as they are filled incrementally.
Definition: NIImporter_VISUM.h:522
LineReader
Retrieves a file linewise and reports the lines to a handler.
Definition: LineReader.h:50
NIImporter_VISUM::VISUM_ID
@ VISUM_ID
Definition: NIImporter_VISUM.h:546
NIImporter_VISUM::checkNodes
bool checkNodes(NBNode *from, NBNode *to)
Returns whether both nodes are a valid combination of from/to-nodes.
Definition: NIImporter_VISUM.cpp:1471
NIImporter_VISUM::VISUM_NUMLANES
@ VISUM_NUMLANES
Definition: NIImporter_VISUM.h:558
LineHandler.h
NBCapacity2Lanes
A helper class which computes the lane number from given capacity.
Definition: NBCapacity2Lanes.h:39
NIImporter_VISUM::parse_Edges
void parse_Edges()
Parses STRECKE/STRECKEN.
Definition: NIImporter_VISUM.cpp:366
NIImporter_VISUM::ParserVector
std::vector< TypeParser > ParserVector
Definition of the list of known parsers.
Definition: NIImporter_VISUM.h:490
NIImporter_VISUM::TypeParser::name
std::string name
The name of the db.
Definition: NIImporter_VISUM.h:367
NIImporter_VISUM::getReversedContinuating
NBEdge * getReversedContinuating(NBEdge *edge, NBNode *node)
Returns the opposite direction of the given edge.
Definition: NIImporter_VISUM.cpp:1275
NIImporter_VISUM::parse_TrafficLights
void parse_TrafficLights()
Parses LSA/SIGNALANLAGE.
Definition: NIImporter_VISUM.cpp:866
NIImporter_VISUM::VISUM_SURFACEITEM
@ VISUM_SURFACEITEM
Definition: NIImporter_VISUM.h:562
NIImporter_VISUM::VISUM_LINKTYPE
@ VISUM_LINKTYPE
Definition: NIImporter_VISUM.h:531
NIImporter_VISUM::VISUM_EDGE
@ VISUM_EDGE
Definition: NIImporter_VISUM.h:556
NIImporter_VISUM::addParser
void addParser(const std::string &name, ParsingFunction function)
Adds a parser into the sorted list of parsers to use.
Definition: NIImporter_VISUM.cpp:184
NIImporter_VISUM::VISUM_V0
@ VISUM_V0
Definition: NIImporter_VISUM.h:536
NIImporter_VISUM::myPoints
std::map< long long int, Position > myPoints
A map of point ids to positions.
Definition: NIImporter_VISUM.h:510
NIImporter_VISUM::VISUM_DISTRICT_CONNECTION
@ VISUM_DISTRICT_CONNECTION
Definition: NIImporter_VISUM.h:548
NIImporter_VISUM::parse_SignalGroupsToPhases
void parse_SignalGroupsToPhases()
Parses LSASIGNALGRUPPEZULSAPHASE.
Definition: NIImporter_VISUM.cpp:1034
NIImporter_VISUM::loadLanguage
void loadLanguage(const std::string &file)
Definition: NIImporter_VISUM.cpp:1491
SVCAll
const SVCPermissions SVCAll
all VClasses are allowed
Definition: SUMOVehicleClass.cpp:146
NIImporter_VISUM::parse_Kante
void parse_Kante()
Parses FLAECHENELEMENT.
Definition: NIImporter_VISUM.cpp:474
NIImporter_VISUM::VISUM_RANK
@ VISUM_RANK
Definition: NIImporter_VISUM.h:538
NIImporter_VISUM::parse_TurnsToSignalGroups
void parse_TurnsToSignalGroups()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
Definition: NIImporter_VISUM.cpp:916
NIImporter_VISUM::parse_Types
void parse_Types()
Parses STRECKENTYP.
Definition: NIImporter_VISUM.cpp:275
NIImporter_VISUM::parse_Nodes
void parse_Nodes()
Parses KNOTEN.
Definition: NIImporter_VISUM.cpp:303
NIImporter_VISUM::getNamedEdge
NBEdge * getNamedEdge(const std::string &fieldName)
Tries to get the edge which name is stored in the given field.
Definition: NIImporter_VISUM.cpp:1253
NIImporter_VISUM::VISUM_TYP
@ VISUM_TYP
Definition: NIImporter_VISUM.h:545
config.h
NIImporter_VISUM::myVSysTypes
VSysTypeNames myVSysTypes
The used vsystypes.
Definition: NIImporter_VISUM.h:487
NIImporter_VISUM::VISUM_NO
@ VISUM_NO
Definition: NIImporter_VISUM.h:567
NIImporter_VISUM::parse_Point
void parse_Point()
Parses PUNKT.
Definition: NIImporter_VISUM.cpp:352
NIImporter_VISUM::loadNetwork
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder.
Definition: NIImporter_VISUM.cpp:92
NIImporter_VISUM::VISUM_DISTRICT
@ VISUM_DISTRICT
Definition: NIImporter_VISUM.h:533
NIImporter_VISUM::myLineReader
LineReader myLineReader
The line reader to use to read from the file.
Definition: NIImporter_VISUM.h:474
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
NIImporter_VISUM::myTouchedEdges
std::vector< std::string > myTouchedEdges
Already read edges.
Definition: NIImporter_VISUM.h:500
NIImporter_VISUM::VISUM_LINK
@ VISUM_LINK
Definition: NIImporter_VISUM.h:535
NIImporter_VISUM::myTLS
NIVisumTL_Map myTLS
List of visum traffic lights.
Definition: NIImporter_VISUM.h:497
NIImporter_VISUM::getWeightedFloat
double getWeightedFloat(const std::string &name, const std::string &suffix)
tries to get a double which is possibly assigned to a certain modality
Definition: NIImporter_VISUM.cpp:1157
NIImporter_VISUM::myCurrentID
std::string myCurrentID
The name of the currently parsed item used for error reporting.
Definition: NIImporter_VISUM.h:506
NIImporter_VISUM::VISUM_DIRECTION
@ VISUM_DIRECTION
Definition: NIImporter_VISUM.h:551
NIImporter_VISUM::VSysTypeNames
std::map< std::string, std::string > VSysTypeNames
Definition of a storage for vsystypes.
Definition: NIImporter_VISUM.h:485
NIImporter_VISUM::VISUM_INDEX
@ VISUM_INDEX
Definition: NIImporter_VISUM.h:560
NIImporter_VISUM::parse_EdgePolys
void parse_EdgePolys()
Parses STRECKENPOLY.
Definition: NIImporter_VISUM.cpp:674
NIImporter_VISUM::getNamedFloat
double getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
Definition: NIImporter_VISUM.cpp:1386
NIImporter_VISUM::VISUM_SYS
@ VISUM_SYS
Definition: NIImporter_VISUM.h:530
NIImporter_VISUM::parse_Phases
void parse_Phases()
Parses LSAPHASE/PHASE.
Definition: NIImporter_VISUM.cpp:1023
NIImporter_VISUM::VISUM_TYPE
@ VISUM_TYPE
Definition: NIImporter_VISUM.h:544
NIImporter_VISUM::VISUM_TONODE
@ VISUM_TONODE
Definition: NIImporter_VISUM.h:543
NamedColumnsParser
A parser to retrieve information from a table with known columns.
Definition: NamedColumnsParser.h:50
NIImporter_VISUM::mySingleDataParsers
ParserVector mySingleDataParsers
List of known parsers.
Definition: NIImporter_VISUM.h:492
NIImporter_VISUM::parse_AreaSubPartElement
void parse_AreaSubPartElement()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
Definition: NIImporter_VISUM.cpp:974