Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition.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>
25 #include <utils/geom/Position.h>
28 #include <utils/common/ToString.h>
31 #include "../NIImporter_Vissim.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
39  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
40 
41 
43 
44 
45 bool
47  // id
48  std::string id;
49  from >> id;
50  // list of points
51  Distribution_Points* points = new Distribution_Points(id);
52  std::string tag;
53  do {
54  tag = readEndSecure(from);
55  if (tag == "name") {
56  readName(from);
57  tag = readEndSecure(from);
58  }
59  if (tag != "DATAEND") {
60  const double p1 = StringUtils::toDouble(tag);
61  from >> tag;
62  const double p2 = StringUtils::toDouble(tag);
63  points->add(p1, p2);
64  }
65  } while (tag != "DATAEND");
66  DistributionCont::dictionary("speed", id, points);
67  return true;
68 }
69 
70 
71 
72 /****************************************************************************/
73 
RandomDistributor::add
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
Definition: RandomDistributor.h:70
ToString.h
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition.cpp:38
DistributionCont::dictionary
static bool dictionary(const std::string &type, const std::string &id, Distribution *d)
Adds a distribution of the given type and name to the container.
Definition: DistributionCont.cpp:34
StringUtils::toDouble
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
Definition: StringUtils.cpp:345
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
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition.cpp: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:679
Position.h
StringUtils.h
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::~NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition
~NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition.cpp:42
Distribution_Points
Definition: Distribution_Points.h:40
Distribution_Points.h
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition.h
config.h
PositionVector.h
DistributionCont.h