Eclipse 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-2019 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 
NIVissimNodeParticipatingEdgeVector
std::vector< NIVissimNodeParticipatingEdge * > NIVissimNodeParticipatingEdgeVector
Definition: NIVissimNodeParticipatingEdgeVector.h:30
NIVissimSingleTypeParser_Knotendefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Knotendefinition.cpp:49
NIImporter_Vissim::VissimSingleTypeParser::readName
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
Definition: NIImporter_Vissim.cpp:798
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:59
NIImporter_Vissim::VissimSingleTypeParser::getPosition
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
Definition: NIImporter_Vissim.cpp:749
PositionVector
A list of positions.
Definition: PositionVector.h:46
NIImporter_Vissim::VissimSingleTypeParser::readEndSecure
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
Definition: NIImporter_Vissim.cpp:680
PositionVector::closePolygon
void closePolygon()
ensures that the last position equals the first
Definition: PositionVector.cpp:1214
NIVissimSingleTypeParser_Knotendefinition::NIVissimSingleTypeParser_Knotendefinition
NIVissimSingleTypeParser_Knotendefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Knotendefinition.cpp:41
NIVissimNodeDef_Edges::dictionary
static bool dictionary(int id, const std::string &name, const NIVissimNodeParticipatingEdgeVector &edges)
Definition: NIVissimNodeDef_Edges.cpp:57
NIVissimNodeParticipatingEdge
Definition: NIVissimNodeParticipatingEdge.h:37
NIVissimSingleTypeParser_Knotendefinition::~NIVissimSingleTypeParser_Knotendefinition
~NIVissimSingleTypeParser_Knotendefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Knotendefinition.cpp:45
Position.h
StringUtils.h
StringUtils::toInt
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
Definition: StringUtils.cpp:246
NIImporter_Vissim::VissimSingleTypeParser::overrideOptionalLabel
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure
Definition: NIImporter_Vissim.cpp:728
config.h
NIVissimNodeDef_Poly::dictionary
static bool dictionary(int id, const std::string &name, const PositionVector &poly)
Definition: NIVissimNodeDef_Poly.cpp:52
NIImporter_Vissim::VissimSingleTypeParser::myRead
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
Definition: NIImporter_Vissim.cpp:671
PositionVector.h
NIVissimSingleTypeParser_Knotendefinition.h