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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <iostream>
32 #include <utils/geom/Position.h>
35 #include "../NIImporter_Vissim.h"
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
46  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
47 
48 
50 
51 
52 bool
54  // id
55  std::string id;
56  from >> id;
57  // list of points
58  Distribution_Points* points = new Distribution_Points(id);
59  std::string tag;
60  do {
61  tag = readEndSecure(from);
62  if (tag == "mittelwert") {
63  double mean, deviation;
64  from >> mean;
65  from >> tag;
66  from >> deviation;
67  delete points;
68  return DistributionCont::dictionary("times", id,
69  new Distribution_Parameterized(id, mean, deviation));
70  }
71  if (tag != "DATAEND") {
72  double p1 = TplConvert::_2double(tag.c_str());
73  from >> tag;
74  double p2 = TplConvert::_2double(tag.c_str());
75  points->add(p1, p2);
76  }
77  } while (tag != "DATAEND");
78  return DistributionCont::dictionary("times", id, points);
79 }
80 
81 
82 /****************************************************************************/
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 _2double(const E *const data)
converts a char-type array into the double value described by it
Definition: TplConvert.h:311
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.