SUMO - Simulation of Urban MObility
NIImporter_Vissim.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Importer for networks stored in Vissim format
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef NIImporter_Vissim_h
24 #define NIImporter_Vissim_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <map>
38 #include <vector>
39 #include <utils/common/RGBColor.h>
40 #include <utils/geom/Position.h>
42 #include "NIVissimElements.h"
47 
50 #include <list>
51 
52 // ===========================================================================
53 // class declarations
54 // ===========================================================================
55 class OptionsCont;
56 class NBNetBuilder;
57 
58 
59 // ===========================================================================
60 // class definitions
61 // ===========================================================================
67 public:
79  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
80 
81 
82 
83 private:
84 
85  typedef std::map<std::string, std::list<std::string> > nodeMap;
86  nodeMap elementData;
87 
93  public:
97  //NIVissimXMLHandler_Streckendefinition(std::map<int, VissimXMLEdge>& toFill);
98  NIVissimXMLHandler_Streckendefinition(nodeMap& elemData);
99 
100 
103 
104  protected:
106 
107 
115  void myStartElement(int element, const SUMOSAXAttributes& attrs);
117 
118  void myEndElement(int element);
120 
121  private:
122 
123  //std::map<int, VissimXMLEdge> myToFill;
124  nodeMap& myElemData;
125 
128 
131 
134 
137 
140  };
141 
142 
143 private:
149  public:
153 
154 
157 
158  protected:
160 
161 
169  void myStartElement(int element, const SUMOSAXAttributes& attrs);
171 
172 
173  private:
174 
175 
176 
179 
182  };
183 
184 
185 private:
191  public:
195 
196 
199 
200  protected:
202 
203 
211  void myStartElement(int element, const SUMOSAXAttributes& attrs);
213 
214 
215  private:
216 
217 
218 
221 
224  };
225 
226 
227 private:
233  public:
239 
240 
243 
244  protected:
246 
247 
255  void myStartElement(int element, const SUMOSAXAttributes& attrs);
257 
258  void myEndElement(int element);
260 
261  private:
262 
263  //std::map<int, VissimXMLEdge> myToFill;
264  nodeMap& myElemData;
265 
268 
271 
274 
277  };
278 
279 private:
285  public:
291 
292 
295 
296  protected:
298 
299 
307  void myStartElement(int element, const SUMOSAXAttributes& attrs);
309 
310  void myEndElement(int element);
312 
313  private:
314 
315  //std::map<int, VissimXMLEdge> myToFill;
316  nodeMap& myElemData;
317 
320 
323 
326 
329  };
330 
331 
332 
333 
334 private:
340  public:
346 
347 
350 
351  protected:
353 
354 
362  void myStartElement(int element, const SUMOSAXAttributes& attrs);
364 
365  void myEndElement(int element);
367 
368  private:
369 
370  //std::map<int, VissimXMLEdge> myToFill;
371  nodeMap& myElemData;
372 
375 
378 
381 
384  };
385 
386 
387 private:
393  public:
399 
400 
403 
404  protected:
406 
407 
415  void myStartElement(int element, const SUMOSAXAttributes& attrs);
417 
418  void myEndElement(int element);
420 
421  private:
422 
423  //std::map<int, VissimXMLEdge> myToFill;
424  nodeMap& myElemData;
425 
428 
431 
434 
437  };
438 
439 
440 private:
446  public:
450 
451 
454 
455 
456  protected:
458 
459 
467  void myStartElement(int element, const SUMOSAXAttributes& attrs);
469 
470 
471  private:
472 
473 
476 
479  };
480 
481 
482 protected:
484  NIImporter_Vissim(NBNetBuilder& nb, const std::string& file);
485 
488 
490  void load(const OptionsCont& options);
491 
492  void loadXML(const OptionsCont& options, NBNetBuilder& nb);
493 
494  bool admitContinue(const std::string& tag);
495 
496 public:
498  public:
501 
503  virtual ~VissimSingleTypeParser();
504 
507  virtual bool parse(std::istream& from) = 0;
508 
509  protected:
511  std::string myRead(std::istream& from);
512 
514  std::string readEndSecure(std::istream& from,
515  const std::string& excl = "");
516 
517  std::string readEndSecure(std::istream& from,
518  const std::vector<std::string>& excl);
519 
521  std::string overrideOptionalLabel(std::istream& from,
522  const std::string& tag = "");
523 
525  Position getPosition(std::istream& from);
526 
529  std::vector<int> parseAssignedVehicleTypes(std::istream& from,
530  const std::string& next);
531 
532  NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream& from);
533 
537  std::string readName(std::istream& from);
538 
541  bool skipOverreading(std::istream& from, const std::string& name = "");
542 
544  void readUntil(std::istream& from, const std::string& name);
545 
546  private:
548 
549  private:
552 
553  };
554 
555 
557  typedef std::map<std::string, RGBColor> ColorMap;
558 
559 private:
560  bool readContents(std::istream& strm);
561  void postLoadBuild(SUMOReal offset);
562 
563 
565  void insertKnownElements();
566 
568  void buildParsers();
569 
570 private:
572  typedef std::map<std::string, NIVissimElement> ToElemIDMap;
573 
575  ToElemIDMap myKnownElements;
576 
578  typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap;
579 
581  ToParserMap myParsers;
582 
584  ColorMap myColorMap;
585 
586  std::string myLastSecure;
587 
589 
591 
592 private:
595 
598 
599 
600 
627  };
628 
629 
660  };
661 
664 
667 
668 
669 };
670 
671 
672 #endif
673 
674 /****************************************************************************/
675 
NIVissimXMLHandler_Streckendefinition(nodeMap &elemData)
Constructor.
~NIImporter_Vissim()
destructor
static StringBijection< int >::Entry vissimAttrs[]
The names of VISSIM-XML attributes (for passing to GenericSAXHandler)
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
Importer for networks stored in Vissim format.
std::map< std::string, NIVissimElement > ToElemIDMap
Definition of a map from element names to their numerical representation.
bool readContents(std::istream &strm)
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
void loadXML(const OptionsCont &options, NBNetBuilder &nb)
ToParserMap myParsers
Parsers by element id.
void insertKnownElements()
adds name-to-id - relationships of known elements into myKnownElements
ToElemIDMap myKnownElements
Map from element names to their numerical representation.
A handler which converts occuring elements and attributes into enums.
Encapsulated SAX-Attributes.
void load(const OptionsCont &options)
loads the vissim file
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
static StringBijection< int >::Entry vissimTags[]
The names of VISSIM-XML elements (for passing to GenericSAXHandler)
ColorMap myColorMap
a map from color names to color definitions
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
VissimXMLTag
Numbers representing VISSIM-XML - element names.
void postLoadBuild(SUMOReal offset)
void buildParsers()
adds id-to-parser - relationships of elements to parse into myParsers
std::map< std::string, RGBColor > ColorMap
definition of a map from color names to color definitions
NIVissimXMLHandler_Streckendefinition & operator=(const NIVissimXMLHandler_Streckendefinition &s)
invalidated assignment operator
std::map< std::string, std::list< std::string > > nodeMap
NIImporter_Vissim(NBNetBuilder &nb, const std::string &file)
constructor
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
A storage for options typed value containers)
Definition: OptionsCont.h:108
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder...
VissimXMLAttr
Numbers representing VISSIM-XML - attributes.
#define SUMOReal
Definition: config.h:213
std::map< NIVissimElement, VissimSingleTypeParser * > ToParserMap
Definition of a map from an element&#39;s numerical id to his parser.
NBNetBuilder & myNetBuilder
std::string myLastSecure
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
bool admitContinue(const std::string &tag)
A class which extracts VISSIM-Routes from a parsed VISSIM-file.