Eclipse 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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Importer for networks stored in Vissim format
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <string>
27 #include <map>
28 #include <vector>
29 #include <utils/common/RGBColor.h>
30 #include <utils/geom/Position.h>
32 #include "NIVissimElements.h"
37 
40 #include <list>
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class OptionsCont;
46 class NBNetBuilder;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
57 public:
69  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
70 
71 
72 
73 private:
74 
75  typedef std::map<std::string, std::list<std::string> > nodeMap;
77 
83  public:
87  //NIVissimXMLHandler_Streckendefinition(std::map<int, VissimXMLEdge>& toFill);
89 
90 
93 
94  protected:
96 
97 
105  void myStartElement(int element, const SUMOSAXAttributes& attrs);
107 
108  void myEndElement(int element);
110 
111  private:
112 
113  //std::map<int, VissimXMLEdge> myToFill;
115 
118 
121 
124 
127 
130  };
131 
132 
133 private:
139  public:
143 
144 
147 
148  protected:
150 
151 
159  void myStartElement(int element, const SUMOSAXAttributes& attrs);
161 
162 
163  private:
164 
165 
166 
169 
172  };
173 
174 
175 private:
181  public:
185 
186 
189 
190  protected:
192 
193 
201  void myStartElement(int element, const SUMOSAXAttributes& attrs);
203 
204 
205  private:
206 
207 
208 
211 
214  };
215 
216 
217 private:
223  public:
229 
230 
233 
234  protected:
236 
237 
245  void myStartElement(int element, const SUMOSAXAttributes& attrs);
247 
248  void myEndElement(int element);
250 
251  private:
252 
253  //std::map<int, VissimXMLEdge> myToFill;
255 
258 
261 
264 
267  };
268 
269 private:
275  public:
281 
282 
285 
286  protected:
288 
289 
297  void myStartElement(int element, const SUMOSAXAttributes& attrs);
299 
300  void myEndElement(int element);
302 
303  private:
304 
305  //std::map<int, VissimXMLEdge> myToFill;
307 
310 
313 
316 
319  };
320 
321 
322 
323 
324 private:
330  public:
336 
337 
340 
341  protected:
343 
344 
352  void myStartElement(int element, const SUMOSAXAttributes& attrs);
354 
355  void myEndElement(int element);
357 
358  private:
359 
360  //std::map<int, VissimXMLEdge> myToFill;
362 
365 
368 
371 
374  };
375 
376 
377 private:
383  public:
389 
390 
393 
394  protected:
396 
397 
405  void myStartElement(int element, const SUMOSAXAttributes& attrs);
407 
408  void myEndElement(int element);
410 
411  private:
412 
413  //std::map<int, VissimXMLEdge> myToFill;
415 
418 
421 
424 
427  };
428 
429 
430 private:
436  public:
440 
441 
444 
445 
446  protected:
448 
449 
457  void myStartElement(int element, const SUMOSAXAttributes& attrs);
459 
460 
461  private:
462 
463 
466 
469  };
470 
471 
472 protected:
475 
478 
480  void load(const OptionsCont& options);
481 
482  bool admitContinue(const std::string& tag);
483 
484 public:
486  public:
489 
491  virtual ~VissimSingleTypeParser();
492 
495  virtual bool parse(std::istream& from) = 0;
496 
497  protected:
499  std::string myRead(std::istream& from);
500 
502  std::string readEndSecure(std::istream& from,
503  const std::string& excl = "");
504 
505  std::string readEndSecure(std::istream& from,
506  const std::vector<std::string>& excl);
507 
509  std::string overrideOptionalLabel(std::istream& from,
510  const std::string& tag = "");
511 
513  Position getPosition(std::istream& from);
514 
517  std::vector<int> parseAssignedVehicleTypes(std::istream& from,
518  const std::string& next);
519 
521 
525  std::string readName(std::istream& from);
526 
529  bool skipOverreading(std::istream& from, const std::string& name = "");
530 
532  void readUntil(std::istream& from, const std::string& name);
533 
534  private:
536 
537  private:
540 
541  };
542 
543 
545  typedef std::map<std::string, RGBColor> ColorMap;
546 
547 private:
548  bool readContents(std::istream& strm);
549  void postLoadBuild(double offset);
550 
551 
553  void insertKnownElements();
554 
556  void buildParsers();
557 
558 private:
560  typedef std::map<std::string, NIVissimElement> ToElemIDMap;
561 
564 
566  typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap;
567 
570 
573 
574  std::string myLastSecure;
575 
577 
578 private:
581 
584 
585 
586 
615  };
616 
617 
648  };
649 
652 
655 
656 
657 };
A handler which converts occurring elements and attributes into enums.
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NIVissimXMLHandler_ConflictArea(const NIVissimXMLHandler_ConflictArea &c)
invalidated copy constructor
NIVissimXMLHandler_ConflictArea & operator=(const NIVissimXMLHandler_ConflictArea &c)
invalidated assignment operator
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
NIVissimXMLHandler_Fahrzeugklassendefinition(const NIVissimXMLHandler_Fahrzeugklassendefinition &f)
invalidated copy constructor
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
NIVissimXMLHandler_Fahrzeugklassendefinition & operator=(const NIVissimXMLHandler_Fahrzeugklassendefinition &f)
invalidated assignment operator
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition & operator=(const NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition &vW)
invalidated assignment operator
NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition(const NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition &vW)
invalidated copy constructor
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NIVissimXMLHandler_Parkplatzdefinition(const NIVissimXMLHandler_Parkplatzdefinition &z)
invalidated copy constructor
NIVissimXMLHandler_Parkplatzdefinition & operator=(const NIVissimXMLHandler_Parkplatzdefinition &z)
invalidated assignment operator
A class which extracts VISSIM-Routes from a parsed VISSIM-file.
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
NIVissimXMLHandler_Routenentscheidungsdefinition & operator=(const NIVissimXMLHandler_Routenentscheidungsdefinition &r)
invalidated assignment operator
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
NIVissimXMLHandler_Routenentscheidungsdefinition(const NIVissimXMLHandler_Routenentscheidungsdefinition &r)
invalidated copy constructor
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
NIVissimXMLHandler_Streckendefinition(nodeMap &elemData)
Constructor.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
NIVissimXMLHandler_Streckendefinition & operator=(const NIVissimXMLHandler_Streckendefinition &s)
invalidated assignment operator
NIVissimXMLHandler_Streckendefinition(const NIVissimXMLHandler_Streckendefinition &s)
invalidated copy constructor
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NIVissimXMLHandler_VWunschentscheidungsdefinition(const NIVissimXMLHandler_VWunschentscheidungsdefinition &vW)
invalidated copy constructor
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NIVissimXMLHandler_VWunschentscheidungsdefinition & operator=(const NIVissimXMLHandler_VWunschentscheidungsdefinition &vW)
invalidated assignment operator
NIVissimXMLHandler_Zuflussdefinition & operator=(const NIVissimXMLHandler_Zuflussdefinition &z)
invalidated assignment operator
NIVissimXMLHandler_Zuflussdefinition(const NIVissimXMLHandler_Zuflussdefinition &z)
invalidated copy constructor
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
VissimSingleTypeParser(NIImporter_Vissim &parent)
Constructor.
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream &from)
std::vector< int > parseAssignedVehicleTypes(std::istream &from, const std::string &next)
parses a listof vehicle types assigned to the current data field One should remeber,...
VissimSingleTypeParser & operator=(const VissimSingleTypeParser &)
Invalidated assignment operator.
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
virtual bool parse(std::istream &from)=0
Parses a single data type. Returns whether no error occurred.
void readUntil(std::istream &from, const std::string &name)
Reads from the stream until the keywor occurs.
bool skipOverreading(std::istream &from, const std::string &name="")
Overreads the named parameter (if) given and skips the rest until "DATAEND".
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Importer for networks stored in Vissim format.
std::map< std::string, NIVissimElement > ToElemIDMap
Definition of a map from element names to their numerical representation.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder.
~NIImporter_Vissim()
destructor
static SequentialStringBijection::Entry vissimAttrs[]
The names of VISSIM-XML attributes (for passing to GenericSAXHandler)
std::map< std::string, std::list< std::string > > nodeMap
void buildParsers()
adds id-to-parser - relationships of elements to parse into myParsers
static SequentialStringBijection::Entry vissimTags[]
The names of VISSIM-XML elements (for passing to GenericSAXHandler)
VissimXMLAttr
Numbers representing VISSIM-XML - attributes.
NIImporter_Vissim & operator=(const NIImporter_Vissim &)
Invalidated assignment operator.
bool admitContinue(const std::string &tag)
ColorMap myColorMap
a map from color names to color definitions
VissimXMLTag
Numbers representing VISSIM-XML - element names.
ToElemIDMap myKnownElements
Map from element names to their numerical representation.
void postLoadBuild(double offset)
std::map< std::string, RGBColor > ColorMap
definition of a map from color names to color definitions
void insertKnownElements()
adds name-to-id - relationships of known elements into myKnownElements
std::string myLastSecure
bool readContents(std::istream &strm)
ToParserMap myParsers
Parsers by element id.
NIImporter_Vissim(NBNetBuilder &nb)
constructor
NBNetBuilder & myNetBuilder
std::map< NIVissimElement, VissimSingleTypeParser * > ToParserMap
Definition of a map from an element's numerical id to his parser.
NIImporter_Vissim(const NIImporter_Vissim &)
Invalidated copy constructor.
void load(const OptionsCont &options)
loads the vissim file
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Encapsulated SAX-Attributes.