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 /****************************************************************************/
16 //
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <iostream>
26 #include <utils/geom/Position.h>
29 #include "../NIImporter_Vissim.h"
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
40  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
41 
42 
44 
45 
46 bool
48  // id
49  std::string id;
50  from >> id;
51  // list of points
52  Distribution_Points* points = new Distribution_Points(id);
53  std::string tag;
54  do {
55  tag = readEndSecure(from);
56  if (tag == "mittelwert") {
57  double mean, deviation;
58  from >> mean;
59  from >> tag;
60  from >> deviation;
61  delete points;
62  return DistributionCont::dictionary("times", id,
63  new Distribution_Parameterized(id, mean, deviation));
64  }
65  if (tag != "DATAEND") {
66  double p1 = StringUtils::toDouble(tag);
67  from >> tag;
68  double p2 = StringUtils::toDouble(tag);
69  points->add(p1, p2);
70  }
71  } while (tag != "DATAEND");
72  return DistributionCont::dictionary("times", id, points);
73 }
74 
75 
76 /****************************************************************************/
bool parse(std::istream &from)
Parses the data type from the given stream.
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(const std::string &type, const std::string &id, Distribution *d)
Adds a distribution of the given type and name to the container.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.