Eclipse SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Laengenverteilungsdefinition.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>
27 #include "../NIImporter_Vissim.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
37  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
38 
39 
41 
42 
43 bool
45  // id
46  std::string id;
47  from >> id;
48  // list of points
49  Distribution_Points* points = new Distribution_Points(id);
50  std::string tag;
51  do {
52  tag = readEndSecure(from);
53  if (tag != "DATAEND") {
54  double p1 = StringUtils::toDouble(tag);
55  from >> tag;
56  double p2 = StringUtils::toDouble(tag);
57  points->add(p1, p2);
58  }
59  } while (tag != "DATAEND");
60  DistributionCont::dictionary("length", id, points);
61  return true;
62 }
63 
64 
65 
66 /****************************************************************************/
67 
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
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
Importer for networks stored in Vissim format.
Definition: NIImporter_Vissim.h:58
NIVissimSingleTypeParser_Laengenverteilungsdefinition::~NIVissimSingleTypeParser_Laengenverteilungsdefinition
~NIVissimSingleTypeParser_Laengenverteilungsdefinition()
Destructor.
Definition: NIVissimSingleTypeParser_Laengenverteilungsdefinition.cpp:40
NIVissimSingleTypeParser_Laengenverteilungsdefinition::NIVissimSingleTypeParser_Laengenverteilungsdefinition
NIVissimSingleTypeParser_Laengenverteilungsdefinition(NIImporter_Vissim &parent)
Constructor.
Definition: NIVissimSingleTypeParser_Laengenverteilungsdefinition.cpp:36
NIVissimSingleTypeParser_Laengenverteilungsdefinition::parse
bool parse(std::istream &from)
Parses the data type from the given stream.
Definition: NIVissimSingleTypeParser_Laengenverteilungsdefinition.cpp:44
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
StringUtils.h
Distribution_Points
Definition: Distribution_Points.h:39
NIVissimSingleTypeParser_Laengenverteilungsdefinition.h
Distribution_Points.h
config.h
PositionVector.h
DistributionCont.h