SUMO - Simulation of Urban MObility
NIImporter_Vissim.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 /****************************************************************************/
20 // Importer for networks stored in Vissim format
21 /****************************************************************************/
22 #ifndef NIImporter_Vissim_h
23 #define NIImporter_Vissim_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <map>
37 #include <vector>
38 #include <utils/common/RGBColor.h>
39 #include <utils/geom/Position.h>
41 #include "NIVissimElements.h"
46 
49 #include <list>
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class OptionsCont;
55 class NBNetBuilder;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
66 public:
78  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
79 
80 
81 
82 private:
83 
84  typedef std::map<std::string, std::list<std::string> > nodeMap;
85  nodeMap elementData;
86 
92  public:
96  //NIVissimXMLHandler_Streckendefinition(std::map<int, VissimXMLEdge>& toFill);
97  NIVissimXMLHandler_Streckendefinition(nodeMap& elemData);
98 
99 
102 
103  protected:
105 
106 
114  void myStartElement(int element, const SUMOSAXAttributes& attrs);
116 
117  void myEndElement(int element);
119 
120  private:
121 
122  //std::map<int, VissimXMLEdge> myToFill;
123  nodeMap& myElemData;
124 
127 
130 
133 
136 
139  };
140 
141 
142 private:
148  public:
152 
153 
156 
157  protected:
159 
160 
168  void myStartElement(int element, const SUMOSAXAttributes& attrs);
170 
171 
172  private:
173 
174 
175 
178 
181  };
182 
183 
184 private:
190  public:
194 
195 
198 
199  protected:
201 
202 
210  void myStartElement(int element, const SUMOSAXAttributes& attrs);
212 
213 
214  private:
215 
216 
217 
220 
223  };
224 
225 
226 private:
232  public:
238 
239 
242 
243  protected:
245 
246 
254  void myStartElement(int element, const SUMOSAXAttributes& attrs);
256 
257  void myEndElement(int element);
259 
260  private:
261 
262  //std::map<int, VissimXMLEdge> myToFill;
263  nodeMap& myElemData;
264 
267 
270 
273 
276  };
277 
278 private:
284  public:
290 
291 
294 
295  protected:
297 
298 
306  void myStartElement(int element, const SUMOSAXAttributes& attrs);
308 
309  void myEndElement(int element);
311 
312  private:
313 
314  //std::map<int, VissimXMLEdge> myToFill;
315  nodeMap& myElemData;
316 
319 
322 
325 
328  };
329 
330 
331 
332 
333 private:
339  public:
345 
346 
349 
350  protected:
352 
353 
361  void myStartElement(int element, const SUMOSAXAttributes& attrs);
363 
364  void myEndElement(int element);
366 
367  private:
368 
369  //std::map<int, VissimXMLEdge> myToFill;
370  nodeMap& myElemData;
371 
374 
377 
380 
383  };
384 
385 
386 private:
392  public:
398 
399 
402 
403  protected:
405 
406 
414  void myStartElement(int element, const SUMOSAXAttributes& attrs);
416 
417  void myEndElement(int element);
419 
420  private:
421 
422  //std::map<int, VissimXMLEdge> myToFill;
423  nodeMap& myElemData;
424 
427 
430 
433 
436  };
437 
438 
439 private:
445  public:
449 
450 
453 
454 
455  protected:
457 
458 
466  void myStartElement(int element, const SUMOSAXAttributes& attrs);
468 
469 
470  private:
471 
472 
475 
478  };
479 
480 
481 protected:
483  NIImporter_Vissim(NBNetBuilder& nb, const std::string& file);
484 
487 
489  void load(const OptionsCont& options);
490 
491  void loadXML(const OptionsCont& options, NBNetBuilder& nb);
492 
493  bool admitContinue(const std::string& tag);
494 
495 public:
497  public:
500 
502  virtual ~VissimSingleTypeParser();
503 
506  virtual bool parse(std::istream& from) = 0;
507 
508  protected:
510  std::string myRead(std::istream& from);
511 
513  std::string readEndSecure(std::istream& from,
514  const std::string& excl = "");
515 
516  std::string readEndSecure(std::istream& from,
517  const std::vector<std::string>& excl);
518 
520  std::string overrideOptionalLabel(std::istream& from,
521  const std::string& tag = "");
522 
524  Position getPosition(std::istream& from);
525 
528  std::vector<int> parseAssignedVehicleTypes(std::istream& from,
529  const std::string& next);
530 
531  NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream& from);
532 
536  std::string readName(std::istream& from);
537 
540  bool skipOverreading(std::istream& from, const std::string& name = "");
541 
543  void readUntil(std::istream& from, const std::string& name);
544 
545  private:
547 
548  private:
551 
552  };
553 
554 
556  typedef std::map<std::string, RGBColor> ColorMap;
557 
558 private:
559  bool readContents(std::istream& strm);
560  void postLoadBuild(double offset);
561 
562 
564  void insertKnownElements();
565 
567  void buildParsers();
568 
569 private:
571  typedef std::map<std::string, NIVissimElement> ToElemIDMap;
572 
574  ToElemIDMap myKnownElements;
575 
577  typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap;
578 
580  ToParserMap myParsers;
581 
583  ColorMap myColorMap;
584 
585  std::string myLastSecure;
586 
588 
590 
591 private:
594 
597 
598 
599 
626  };
627 
628 
659  };
660 
663 
666 
667 
668 };
669 
670 
671 #endif
672 
673 /****************************************************************************/
674 
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:45
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 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:115
A storage for options typed value containers)
Definition: OptionsCont.h:98
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder...
void postLoadBuild(double offset)
VissimXMLAttr
Numbers representing VISSIM-XML - attributes.
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.