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 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <iostream>
26 #include <utils/geom/Position.h>
28 #include "../NIImporter_Vissim.h"
29 #include "../tempstructs/NIVissimNodeParticipatingEdge.h"
30 #include "../tempstructs/NIVissimNodeParticipatingEdgeVector.h"
31 #include "../tempstructs/NIVissimNodeDef_Edges.h"
32 #include "../tempstructs/NIVissimNodeDef_Poly.h"
33 #include "../tempstructs/NIVissimNodeDef.h"
35 
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
41  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
42 
43 
45 
46 
47 bool
49  //
50  int id;
51  from >> id;
52  //
53  std::string tag;
54  from >> tag;
55  std::string name = readName(from);
56  //
57  tag = overrideOptionalLabel(from);
58  //
59  while (tag != "netzausschnitt") {
60  tag = myRead(from);
61  }
62  //
63  tag = myRead(from);
64  if (tag == "strecke") {
66  while (tag == "strecke") {
67  int edgeid;
68  double from_pos, to_pos;
69  from_pos = to_pos = -1.0;
70  from >> edgeid;
71  tag = readEndSecure(from, "strecke");
72  if (tag == "von") {
73  from >> from_pos; // type-checking is missing!
74  from >> tag;
75  from >> to_pos; // type-checking is missing!
76  tag = readEndSecure(from, "strecke");
77  }
78  edges.push_back(new NIVissimNodeParticipatingEdge(edgeid, from_pos, to_pos));
79  }
80  NIVissimNodeDef_Edges::dictionary(id, name, edges);
81  } else {
82  int no = StringUtils::toInt(tag);
83  PositionVector poly;
84  for (int i = 0; i < no; i++) {
85  poly.push_back(getPosition(from));
86  }
87  poly.closePolygon();
88  NIVissimNodeDef_Poly::dictionary(id, name, poly);
89  }
90  return true;
91 }
92 
93 
94 
95 /****************************************************************************/
96 
NIVissimNodeParticipatingEdgeVector
std::vector< NIVissimNodeParticipatingEdge * > NIVissimNodeParticipatingEdgeVector
Definition: NIVissimNodeParticipatingEdgeVector.h:29
NIVissimSingleTypeParser_Knotendefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Knotendefinition.cpp:48
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:797
NIImporter_Vissim
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIImporter_Vissim::VissimSingleTypeParser::getPosition
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
Definition: NIImporter_Vissim.cpp:748
PositionVector
A list of positions.
Definition: PositionVector.h:45
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:679
PositionVector::closePolygon
void closePolygon()
ensures that the last position equals the first
Definition: PositionVector.cpp:1231
NIVissimSingleTypeParser_Knotendefinition::NIVissimSingleTypeParser_Knotendefinition
NIVissimSingleTypeParser_Knotendefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Knotendefinition.cpp:40
NIVissimNodeDef_Edges::dictionary
static bool dictionary(int id, const std::string &name, const NIVissimNodeParticipatingEdgeVector &edges)
Definition: NIVissimNodeDef_Edges.cpp:56
NIVissimNodeParticipatingEdge
Definition: NIVissimNodeParticipatingEdge.h:36
NIVissimSingleTypeParser_Knotendefinition::~NIVissimSingleTypeParser_Knotendefinition
~NIVissimSingleTypeParser_Knotendefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Knotendefinition.cpp:44
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:278
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:727
config.h
NIVissimNodeDef_Poly::dictionary
static bool dictionary(int id, const std::string &name, const PositionVector &poly)
Definition: NIVissimNodeDef_Poly.cpp:51
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:670
PositionVector.h
NIVissimSingleTypeParser_Knotendefinition.h