Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Zeitenverteilungsdefinition.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 "../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 == "mittelwert") {
56  double mean, deviation;
57  from >> mean;
58  from >> tag;
59  from >> deviation;
60  delete points;
61  return DistributionCont::dictionary("times", id,
62  new Distribution_Parameterized(id, mean, deviation));
63  }
64  if (tag != "DATAEND") {
65  double p1 = StringUtils::toDouble(tag);
66  from >> tag;
67  double p2 = StringUtils::toDouble(tag);
68  points->add(p1, p2);
69  }
70  } while (tag != "DATAEND");
71  return DistributionCont::dictionary("times", id, points);
72 }
73 
74 
75 /****************************************************************************/
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
Distribution_Parameterized
Definition: Distribution_Parameterized.h:42
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
NIVissimSingleTypeParser_Zeitenverteilungsdefinition::NIVissimSingleTypeParser_Zeitenverteilungsdefinition
NIVissimSingleTypeParser_Zeitenverteilungsdefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Zeitenverteilungsdefinition.cpp:38
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
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIVissimSingleTypeParser_Zeitenverteilungsdefinition.h
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
NIVissimSingleTypeParser_Zeitenverteilungsdefinition::~NIVissimSingleTypeParser_Zeitenverteilungsdefinition
~NIVissimSingleTypeParser_Zeitenverteilungsdefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Zeitenverteilungsdefinition.cpp:42
Distribution_Parameterized.h
Position.h
StringUtils.h
Distribution_Points
Definition: Distribution_Points.h:40
Distribution_Points.h
config.h
PositionVector.h
DistributionCont.h
NIVissimSingleTypeParser_Zeitenverteilungsdefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Zeitenverteilungsdefinition.cpp:46