SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Knotendefinition.cpp
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 /****************************************************************************/
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <iostream>
33 #include <utils/geom/Position.h>
35 #include "../NIImporter_Vissim.h"
36 #include "../tempstructs/NIVissimNodeParticipatingEdge.h"
37 #include "../tempstructs/NIVissimNodeParticipatingEdgeVector.h"
38 #include "../tempstructs/NIVissimNodeDef_Edges.h"
39 #include "../tempstructs/NIVissimNodeDef_Poly.h"
40 #include "../tempstructs/NIVissimNodeDef.h"
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
48  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
49 
50 
52 
53 
54 bool
56  //
57  int id;
58  from >> id;
59  //
60  std::string tag;
61  from >> tag;
62  std::string name = readName(from);
63  //
64  tag = overrideOptionalLabel(from);
65  //
66  while (tag != "netzausschnitt") {
67  tag = myRead(from);
68  }
69  //
70  tag = myRead(from);
71  if (tag == "strecke") {
73  while (tag == "strecke") {
74  int edgeid;
75  double from_pos, to_pos;
76  from_pos = to_pos = -1.0;
77  from >> edgeid;
78  tag = readEndSecure(from, "strecke");
79  if (tag == "von") {
80  from >> from_pos; // type-checking is missing!
81  from >> tag;
82  from >> to_pos; // type-checking is missing!
83  tag = readEndSecure(from, "strecke");
84  }
85  edges.push_back(new NIVissimNodeParticipatingEdge(edgeid, from_pos, to_pos));
86  }
87  NIVissimNodeDef_Edges::dictionary(id, name, edges);
88  } else {
89  int no = TplConvert::_2int(tag.c_str());
90  PositionVector poly;
91  for (int i = 0; i < no; i++) {
92  poly.push_back(getPosition(from));
93  }
94  poly.closePolygon();
95  NIVissimNodeDef_Poly::dictionary(id, name, poly);
96  }
97  return true;
98 }
99 
100 
101 
102 /****************************************************************************/
103 
NIVissimSingleTypeParser_Knotendefinition(NIImporter_Vissim &parent)
Constructor.
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Importer for networks stored in Vissim format.
static bool dictionary(int id, const std::string &name, const NIVissimNodeParticipatingEdgeVector &edges)
bool parse(std::istream &from)
Parses the data type from the given stream.
A list of positions.
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
std::vector< NIVissimNodeParticipatingEdge * > NIVissimNodeParticipatingEdgeVector
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:155
void closePolygon()
ensures that the last position equals the first
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure ...
static bool dictionary(int id, const std::string &name, const PositionVector &poly)