SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 //
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
33 #include <utils/geom/Position.h>
36 #include <utils/common/ToString.h>
39 #include "../NIImporter_Vissim.h"
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
48 
49 
51 
52 
53 bool
55  // id
56  std::string id;
57  from >> id;
58  // list of points
59  Distribution_Points* points = new Distribution_Points(id);
60  std::string tag;
61  do {
62  tag = readEndSecure(from);
63  if (tag == "name") {
64  readName(from);
65  tag = readEndSecure(from);
66  }
67  if (tag != "DATAEND") {
68  const double p1 = TplConvert::_2double(tag.c_str());
69  from >> tag;
70  const double p2 = TplConvert::_2double(tag.c_str());
71  points->add(p1, p2);
72  }
73  } while (tag != "DATAEND");
74  DistributionCont::dictionary("speed", id, points);
75  return true;
76 }
77 
78 
79 
80 /****************************************************************************/
81 
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.
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
static double _2double(const E *const data)
converts a char-type array into the double value described by it
Definition: TplConvert.h:297
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.