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 /****************************************************************************/
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 <utils/common/ToString.h>
32 #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 == "name") {
57  readName(from);
58  tag = readEndSecure(from);
59  }
60  if (tag != "DATAEND") {
61  const double p1 = StringUtils::toDouble(tag);
62  from >> tag;
63  const double p2 = StringUtils::toDouble(tag);
64  points->add(p1, p2);
65  }
66  } while (tag != "DATAEND");
67  DistributionCont::dictionary("speed", id, points);
68  return true;
69 }
70 
71 
72 
73 /****************************************************************************/
74 
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 ...
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.