SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RORoute.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // A complete router's route
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2013 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 <string>
33 #include <iostream>
34 #include <utils/common/Named.h>
36 #include <utils/common/StdDefs.h>
37 #include "ROEdge.h"
38 #include "RORoute.h"
39 #include "ROHelper.h"
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 RORoute::RORoute(const std::string& id, SUMOReal costs, SUMOReal prop,
51  const std::vector<const ROEdge*>& route,
52  const RGBColor* const color,
53  const std::vector<SUMOVehicleParameter::Stop>& stops)
54  : Named(StringUtils::convertUmlaute(id)), myCosts(costs),
55  myProbability(prop), myRoute(route), myColor(color), myStops(stops) {}
56 
57 
59  : Named(src.myID), myCosts(src.myCosts),
60  myProbability(src.myProbability), myRoute(src.myRoute), myColor(0) {
61  if (src.myColor != 0) {
62  myColor = new RGBColor(*src.myColor);
63  }
64 }
65 
66 
68  delete myColor;
69 }
70 
71 
72 void
74  myCosts = costs;
75 }
76 
77 
78 void
80  myProbability = prob;
81 }
82 
83 
84 void
87 }
88 
89 void
91  myProbability += prob;
92 }
93 
94 
97  const bool withCosts,
98  const bool withExitTimes) const {
100  if (withCosts) {
102  dev.setPrecision(8);
104  dev.setPrecision();
105  }
106  if (myColor != 0) {
108  }
109  if (!myRoute.empty() && myRoute.front()->getType() == ROEdge::ET_DISTRICT) {
110  std::vector<const ROEdge*> temp(myRoute.begin() + 1, myRoute.end() - 1);
111  dev.writeAttr(SUMO_ATTR_EDGES, temp);
112  } else {
114  }
115  if (withExitTimes) {
116  std::string exitTimes;
117  SUMOReal time = STEPS2TIME(veh->getDepartureTime());
118  for (std::vector<const ROEdge*>::const_iterator i = myRoute.begin(); i != myRoute.end(); ++i) {
119  if (i != myRoute.begin()) {
120  exitTimes += " ";
121  }
122  time += (*i)->getTravelTime(veh, time);
123  exitTimes += toString(time);
124  }
125  dev.writeAttr("exitTimes", exitTimes);
126  }
127  dev.closeTag();
128  return dev;
129 }
130 
131 
132 /****************************************************************************/
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at.
Definition: ROVehicle.h:110
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withExitTimes) const
Definition: RORoute.cpp:96
Some static methods for string processing.
Definition: StringUtils.h:45
void setProbability(SUMOReal prob)
Sets the probability of the route.
Definition: RORoute.cpp:79
void recheckForLoops()
Checks whether this route contains loops and removes such.
Definition: RORoute.cpp:85
void setPrecision(unsigned int precision=OUTPUT_ACCURACY)
Sets the precison or resets it to default.
void addProbability(SUMOReal prob)
add additional vehicles/probability
Definition: RORoute.cpp:90
RORoute(const std::string &id, SUMOReal costs, SUMOReal prob, const std::vector< const ROEdge * > &route, const RGBColor *const color, const std::vector< SUMOVehicleParameter::Stop > &stops)
Constructor.
Definition: RORoute.cpp:50
A vehicle as used by router.
Definition: ROVehicle.h:58
the edges of a route
SUMOReal myCosts
The costs of the route.
Definition: RORoute.h:187
const RGBColor * myColor
The color of the route.
Definition: RORoute.h:196
std::vector< const ROEdge * > myRoute
The edges the route consists of.
Definition: RORoute.h:193
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
void setCosts(SUMOReal costs)
Sets the costs of the route.
Definition: RORoute.cpp:73
SUMOReal myProbability
The probability the driver will take this route with.
Definition: RORoute.h:190
An edge representing a whole district.
Definition: ROEdge.h:77
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:51
Base class for objects which have an id.
Definition: Named.h:45
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:215
A color information.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
A complete router&#39;s route.
Definition: RORoute.h:59
~RORoute()
Destructor.
Definition: RORoute.cpp:67
void recheckForLoops(std::vector< const ROEdge * > &edges)
Checks whether the given edge list contains loops and removes them.
Definition: ROHelper.cpp:44