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-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 /****************************************************************************/
16 //
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <iostream>
27 #include <utils/geom/Position.h>
29 #include "../NIImporter_Vissim.h"
30 #include "../tempstructs/NIVissimNodeParticipatingEdge.h"
31 #include "../tempstructs/NIVissimNodeParticipatingEdgeVector.h"
32 #include "../tempstructs/NIVissimNodeDef_Edges.h"
33 #include "../tempstructs/NIVissimNodeDef_Poly.h"
34 #include "../tempstructs/NIVissimNodeDef.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
42  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
43 
44 
46 
47 
48 bool
50  //
51  int id;
52  from >> id;
53  //
54  std::string tag;
55  from >> tag;
56  std::string name = readName(from);
57  //
58  tag = overrideOptionalLabel(from);
59  //
60  while (tag != "netzausschnitt") {
61  tag = myRead(from);
62  }
63  //
64  tag = myRead(from);
65  if (tag == "strecke") {
67  while (tag == "strecke") {
68  int edgeid;
69  double from_pos, to_pos;
70  from_pos = to_pos = -1.0;
71  from >> edgeid;
72  tag = readEndSecure(from, "strecke");
73  if (tag == "von") {
74  from >> from_pos; // type-checking is missing!
75  from >> tag;
76  from >> to_pos; // type-checking is missing!
77  tag = readEndSecure(from, "strecke");
78  }
79  edges.push_back(new NIVissimNodeParticipatingEdge(edgeid, from_pos, to_pos));
80  }
81  NIVissimNodeDef_Edges::dictionary(id, name, edges);
82  } else {
83  int no = StringUtils::toInt(tag);
84  PositionVector poly;
85  for (int i = 0; i < no; i++) {
86  poly.push_back(getPosition(from));
87  }
88  poly.closePolygon();
89  NIVissimNodeDef_Poly::dictionary(id, name, poly);
90  }
91  return true;
92 }
93 
94 
95 
96 /****************************************************************************/
97 
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
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
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
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)