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-2018 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 /****************************************************************************/
18 // Importer for networks stored in Vissim format
19 /****************************************************************************/
20 #ifndef NIImporter_Vissim_h
21 #define NIImporter_Vissim_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <map>
31 #include <vector>
32 #include <utils/common/RGBColor.h>
33 #include <utils/geom/Position.h>
35 #include "NIVissimElements.h"
40 
43 #include <list>
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class OptionsCont;
49 class NBNetBuilder;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
60 public:
72  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
73 
74 
75 
76 private:
77 
78  typedef std::map<std::string, std::list<std::string> > nodeMap;
79  nodeMap elementData;
80 
86  public:
90  //NIVissimXMLHandler_Streckendefinition(std::map<int, VissimXMLEdge>& toFill);
91  NIVissimXMLHandler_Streckendefinition(nodeMap& elemData);
92 
93 
96 
97  protected:
99 
100 
108  void myStartElement(int element, const SUMOSAXAttributes& attrs);
110 
111  void myEndElement(int element);
113 
114  private:
115 
116  //std::map<int, VissimXMLEdge> myToFill;
117  nodeMap& myElemData;
118 
121 
124 
127 
130 
133  };
134 
135 
136 private:
142  public:
146 
147 
150 
151  protected:
153 
154 
162  void myStartElement(int element, const SUMOSAXAttributes& attrs);
164 
165 
166  private:
167 
168 
169 
172 
175  };
176 
177 
178 private:
184  public:
188 
189 
192 
193  protected:
195 
196 
204  void myStartElement(int element, const SUMOSAXAttributes& attrs);
206 
207 
208  private:
209 
210 
211 
214 
217  };
218 
219 
220 private:
226  public:
232 
233 
236 
237  protected:
239 
240 
248  void myStartElement(int element, const SUMOSAXAttributes& attrs);
250 
251  void myEndElement(int element);
253 
254  private:
255 
256  //std::map<int, VissimXMLEdge> myToFill;
257  nodeMap& myElemData;
258 
261 
264 
267 
270  };
271 
272 private:
278  public:
284 
285 
288 
289  protected:
291 
292 
300  void myStartElement(int element, const SUMOSAXAttributes& attrs);
302 
303  void myEndElement(int element);
305 
306  private:
307 
308  //std::map<int, VissimXMLEdge> myToFill;
309  nodeMap& myElemData;
310 
313 
316 
319 
322  };
323 
324 
325 
326 
327 private:
333  public:
339 
340 
343 
344  protected:
346 
347 
355  void myStartElement(int element, const SUMOSAXAttributes& attrs);
357 
358  void myEndElement(int element);
360 
361  private:
362 
363  //std::map<int, VissimXMLEdge> myToFill;
364  nodeMap& myElemData;
365 
368 
371 
374 
377  };
378 
379 
380 private:
386  public:
392 
393 
396 
397  protected:
399 
400 
408  void myStartElement(int element, const SUMOSAXAttributes& attrs);
410 
411  void myEndElement(int element);
413 
414  private:
415 
416  //std::map<int, VissimXMLEdge> myToFill;
417  nodeMap& myElemData;
418 
421 
424 
427 
430  };
431 
432 
433 private:
439  public:
443 
444 
447 
448 
449  protected:
451 
452 
460  void myStartElement(int element, const SUMOSAXAttributes& attrs);
462 
463 
464  private:
465 
466 
469 
472  };
473 
474 
475 protected:
477  NIImporter_Vissim(NBNetBuilder& nb, const std::string& file);
478 
481 
483  void load(const OptionsCont& options);
484 
485  void loadXML(const OptionsCont& options, NBNetBuilder& nb);
486 
487  bool admitContinue(const std::string& tag);
488 
489 public:
491  public:
494 
496  virtual ~VissimSingleTypeParser();
497 
500  virtual bool parse(std::istream& from) = 0;
501 
502  protected:
504  std::string myRead(std::istream& from);
505 
507  std::string readEndSecure(std::istream& from,
508  const std::string& excl = "");
509 
510  std::string readEndSecure(std::istream& from,
511  const std::vector<std::string>& excl);
512 
514  std::string overrideOptionalLabel(std::istream& from,
515  const std::string& tag = "");
516 
518  Position getPosition(std::istream& from);
519 
522  std::vector<int> parseAssignedVehicleTypes(std::istream& from,
523  const std::string& next);
524 
525  NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream& from);
526 
530  std::string readName(std::istream& from);
531 
534  bool skipOverreading(std::istream& from, const std::string& name = "");
535 
537  void readUntil(std::istream& from, const std::string& name);
538 
539  private:
541 
542  private:
545 
546  };
547 
548 
550  typedef std::map<std::string, RGBColor> ColorMap;
551 
552 private:
553  bool readContents(std::istream& strm);
554  void postLoadBuild(double offset);
555 
556 
558  void insertKnownElements();
559 
561  void buildParsers();
562 
563 private:
565  typedef std::map<std::string, NIVissimElement> ToElemIDMap;
566 
568  ToElemIDMap myKnownElements;
569 
571  typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap;
572 
574  ToParserMap myParsers;
575 
577  ColorMap myColorMap;
578 
579  std::string myLastSecure;
580 
582 
584 
585 private:
588 
591 
592 
593 
620  };
621 
622 
653  };
654 
657 
660 
661 
662 };
663 
664 
665 #endif
666 
667 /****************************************************************************/
668 
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:39
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:109
A storage for options typed value containers)
Definition: OptionsCont.h:92
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.