SUMO - Simulation of Urban MObility
ROPerson.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A person as used by router
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2002-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 #ifndef ROPerson_h
22 #define ROPerson_h
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <iostream>
35 #include <utils/common/StdDefs.h>
36 #include <utils/common/SUMOTime.h>
39 #include "RORoutable.h"
40 #include "RORouteDef.h"
41 #include "ROVehicle.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class OutputDevice;
48 class ROEdge;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class ROPerson : public RORoutable {
59 
60 public:
66  ROPerson(const SUMOVehicleParameter& pars, const SUMOVTypeParameter* type);
67 
69  virtual ~ROPerson();
70 
71  void addTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
72  const std::string& vTypes, const double departPos, const double arrivalPos, const std::string& busStop,
73  double walkFactor);
74 
75  void addRide(const ROEdge* const from, const ROEdge* const to, const std::string& lines, const std::string& destStop);
76 
77  void addWalk(const ConstROEdgeVector& edges, const double duration, const double speed,
78  const double departPos, const double arrivalPos, const std::string& busStop);
79 
80  void addStop(const SUMOVehicleParameter::Stop& stopPar, const ROEdge* const stopEdge);
81 
82  class TripItem;
87  class PlanItem {
88  public:
90  virtual ~PlanItem() {}
91 
92  virtual void addTripItem(TripItem* /* tripIt */) {
93  throw ProcessError();
94  }
95  virtual const ROEdge* getOrigin() const = 0;
96  virtual const ROEdge* getDestination() const = 0;
97  virtual void saveVehicles(OutputDevice& /* os */, OutputDevice* const /* typeos */, bool /* asAlternatives */, OptionsCont& /* options */) const {}
98  virtual void saveAsXML(OutputDevice& os) const = 0;
99  virtual bool isStop() const {
100  return false;
101  }
102  virtual bool needsRouting() const {
103  return false;
104  }
105  };
106 
111  class Stop : public PlanItem {
112  public:
113  Stop(const SUMOVehicleParameter::Stop& stop, const ROEdge* const stopEdge)
114  : stopDesc(stop), edge(stopEdge) {}
115  const ROEdge* getOrigin() const {
116  return edge;
117  }
118  const ROEdge* getDestination() const {
119  return edge;
120  }
121  void saveAsXML(OutputDevice& os) const {
122  stopDesc.write(os);
123  }
124  bool isStop() const {
125  return true;
126  }
127 
128  private:
130  const ROEdge* const edge;
131 
132  private:
134  Stop& operator=(const Stop& src);
135 
136  };
137 
142  class TripItem {
143  public:
145  virtual ~TripItem() {}
146 
147  virtual const ROEdge* getOrigin() const = 0;
148  virtual const ROEdge* getDestination() const = 0;
149  virtual void saveAsXML(OutputDevice& os) const = 0;
150  };
151 
156  class Ride : public TripItem {
157  public:
158  Ride(const ROEdge* const _from, const ROEdge* const _to,
159  const std::string& _lines, const std::string& _destStop = "")
160  : from(_from), to(_to), lines(_lines), destStop(_destStop) {}
161 
162  const ROEdge* getOrigin() const {
163  return from;
164  }
165  const ROEdge* getDestination() const {
166  return to;
167  }
168  void saveAsXML(OutputDevice& os) const;
169 
170  private:
171  const ROEdge* const from;
172  const ROEdge* const to;
173  const std::string lines;
174  const std::string destStop;
175 
176  private:
178  Ride& operator=(const Ride& src);
179 
180  };
181 
186  class Walk : public TripItem {
187  public:
188  Walk(const ConstROEdgeVector& _edges, const std::string& _destStop = "")
189  : edges(_edges), dur(-1), v(-1), dep(std::numeric_limits<double>::infinity()), arr(std::numeric_limits<double>::infinity()), destStop(_destStop) {}
190  Walk(const ConstROEdgeVector& edges, const double duration, const double speed,
191  const double departPos, const double arrivalPos, const std::string& _destStop)
192  : edges(edges), dur(duration), v(speed), dep(departPos), arr(arrivalPos), destStop(_destStop) {}
193  const ROEdge* getOrigin() const {
194  return edges.front();
195  }
196  const ROEdge* getDestination() const {
197  return edges.back();
198  }
199  void saveAsXML(OutputDevice& os) const;
200 
201  private:
203  const double dur, v, dep, arr;
204  const std::string destStop;
205 
206  private:
208  Walk& operator=(const Walk& src);
209 
210  };
211 
216  class PersonTrip : public PlanItem {
217  public:
219  : from(0), to(0), modes(SVC_PEDESTRIAN), dep(0), arr(0), busStop(""), walkFactor(1.0) {}
220  PersonTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
221  const double departPos, const double arrivalPos, const std::string& busStop, double _walkFactor)
222  : from(from), to(to), modes(modeSet), dep(departPos), arr(arrivalPos), busStop(busStop), walkFactor(_walkFactor) {}
224  virtual ~PersonTrip() {
225  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
226  delete *it;
227  }
228  for (std::vector<ROVehicle*>::const_iterator it = myVehicles.begin(); it != myVehicles.end(); ++it) {
229  delete(*it)->getRouteDefinition();
230  delete *it;
231  }
232  }
233 
234  virtual void addTripItem(TripItem* tripIt) {
235  myTripItems.push_back(tripIt);
236  }
237  void addVehicle(ROVehicle* veh) {
238  myVehicles.push_back(veh);
239  }
240  std::vector<ROVehicle*>& getVehicles() {
241  return myVehicles;
242  }
243  const ROEdge* getOrigin() const {
244  return from != 0 ? from : myTripItems.front()->getOrigin();
245  }
246  const ROEdge* getDestination() const {
247  return to != 0 ? to : myTripItems.back()->getDestination();
248  }
249  double getDepartPos() const {
250  return dep;
251  }
252  double getArrivalPos() const {
253  return arr;
254  }
256  return modes;
257  }
258  bool hasBusStopDest() const {
259  return busStop != "";
260  }
261  virtual bool needsRouting() const {
262  return myTripItems.empty();
263  }
264  void saveVehicles(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
265  void saveAsXML(OutputDevice& os) const {
266  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
267  (*it)->saveAsXML(os);
268  }
269  }
270  double getWalkFactor() const {
271  return walkFactor;
272  }
273 
274  private:
275  const ROEdge* from;
276  const ROEdge* to;
278  const double dep, arr;
279  const std::string busStop;
281  std::vector<TripItem*> myTripItems;
283  std::vector<ROVehicle*> myVehicles;
285  double walkFactor;
286 
287  private:
289  PersonTrip& operator=(const PersonTrip& src);
290 
291  };
292 
293 
298  const ROEdge* getDepartEdge() const {
299  return myPlan.front()->getOrigin();
300  }
301 
302 
303  void computeRoute(const RORouterProvider& provider,
304  const bool removeLoops, MsgHandler* errorHandler);
305 
306 
317  void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
318 
319  std::vector<PlanItem*>& getPlan() {
320  return myPlan;
321  }
322 
323 private:
324  bool computeIntermodal(const RORouterProvider& provider, PersonTrip* const trip, const ROVehicle* const veh, MsgHandler* const errorHandler);
325 
326 private:
330  std::vector<PlanItem*> myPlan;
331 
332 
333 private:
335  ROPerson(const ROPerson& src);
336 
338  ROPerson& operator=(const ROPerson& src);
339 
340 };
341 
342 #endif
343 
344 /****************************************************************************/
345 
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, const std::string &destStop)
Definition: ROPerson.cpp:94
is a pedestrian
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:121
const std::string lines
Definition: ROPerson.h:173
SVCPermissions getModes() const
Definition: ROPerson.h:255
const ROEdge *const edge
Definition: ROPerson.h:130
virtual void saveAsXML(OutputDevice &os) const =0
bool hasBusStopDest() const
Definition: ROPerson.h:258
void addVehicle(ROVehicle *veh)
Definition: ROPerson.h:237
Structure representing possible vehicle parameter.
const SVCPermissions modes
Definition: ROPerson.h:277
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
A planItem can be a Stop.
Definition: ROPerson.h:111
std::vector< ROVehicle * > myVehicles
the vehicles which may be used for routing
Definition: ROPerson.h:283
const ROEdge *const from
Definition: ROPerson.h:171
bool computeIntermodal(const RORouterProvider &provider, PersonTrip *const trip, const ROVehicle *const veh, MsgHandler *const errorHandler)
Definition: ROPerson.cpp:166
PersonTrip(const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const double departPos, const double arrivalPos, const std::string &busStop, double _walkFactor)
Definition: ROPerson.h:220
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
const ROEdge * getOrigin() const
Definition: ROPerson.h:115
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:87
A planItem can be a Trip which contains multiple tripItems.
Definition: ROPerson.h:216
virtual ~PlanItem()
Destructor.
Definition: ROPerson.h:90
const ROEdge * getOrigin() const
Definition: ROPerson.h:162
Walk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &_destStop)
Definition: ROPerson.h:190
A routable thing such as a vehicle or person.
Definition: RORoutable.h:62
const ROEdge * getDestination() const
Definition: ROPerson.h:196
A ride is part of a trip, e.g., go from here to here by car or bus.
Definition: ROPerson.h:156
double getDepartPos() const
Definition: ROPerson.h:249
A vehicle as used by router.
Definition: ROVehicle.h:60
ROPerson & operator=(const ROPerson &src)
Invalidated assignment operator.
const ROEdge * getOrigin() const
Definition: ROPerson.h:193
virtual void saveVehicles(OutputDevice &, OutputDevice *const, bool, OptionsCont &) const
Definition: ROPerson.h:97
const ROEdge * from
Definition: ROPerson.h:275
std::vector< PlanItem * > myPlan
The plan of the person.
Definition: ROPerson.h:330
bool isStop() const
Definition: ROPerson.h:124
SUMOVehicleParameter::Stop stopDesc
Definition: ROPerson.h:129
std::vector< PlanItem * > & getPlan()
Definition: ROPerson.h:319
virtual bool needsRouting() const
Definition: ROPerson.h:102
virtual void addTripItem(TripItem *)
Definition: ROPerson.h:92
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition: ROPerson.cpp:112
const ROEdge * getDestination() const
Definition: ROPerson.h:165
A person as used by router.
Definition: ROPerson.h:58
const double dep
Definition: ROPerson.h:278
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:265
A TripItem is part of a trip, e.g., go from here to here by car.
Definition: ROPerson.h:142
A walk is part of a trip, e.g., go from here to here by foot.
Definition: ROPerson.h:186
A basic edge for routing applications.
Definition: ROEdge.h:77
virtual const ROEdge * getDestination() const =0
virtual ~ROPerson()
Destructor.
Definition: ROPerson.cpp:59
std::vector< TripItem * > myTripItems
the fully specified trips
Definition: ROPerson.h:281
void addTrip(const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const std::string &vTypes, const double departPos, const double arrivalPos, const std::string &busStop, double walkFactor)
Definition: ROPerson.cpp:67
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition: ROPerson.cpp:54
const double v
Definition: ROPerson.h:203
virtual ~PersonTrip()
Destructor.
Definition: ROPerson.h:224
double getWalkFactor() const
Definition: ROPerson.h:270
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
Definition: ROPerson.cpp:197
Structure representing possible vehicle parameter.
const std::string destStop
Definition: ROPerson.h:204
virtual bool needsRouting() const
Definition: ROPerson.h:261
void addWalk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
Definition: ROPerson.cpp:103
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
Definition: OptionsCont.h:99
const std::string destStop
Definition: ROPerson.h:174
const ROEdge * to
Definition: ROPerson.h:276
Walk(const ConstROEdgeVector &_edges, const std::string &_destStop="")
Definition: ROPerson.h:188
const ROEdge * getDestination() const
Definition: ROPerson.h:118
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
const ConstROEdgeVector edges
Definition: ROPerson.h:202
std::vector< ROVehicle * > & getVehicles()
Definition: ROPerson.h:240
virtual void addTripItem(TripItem *tripIt)
Definition: ROPerson.h:234
Stop(const SUMOVehicleParameter::Stop &stop, const ROEdge *const stopEdge)
Definition: ROPerson.h:113
virtual const ROEdge * getOrigin() const =0
double walkFactor
walking speed factor
Definition: ROPerson.h:285
const ROEdge * getDepartEdge() const
Returns the first edge the person takes.
Definition: ROPerson.h:298
const ROEdge * getOrigin() const
Definition: ROPerson.h:243
const ROEdge *const to
Definition: ROPerson.h:172
virtual bool isStop() const
Definition: ROPerson.h:99
double getArrivalPos() const
Definition: ROPerson.h:252
Ride(const ROEdge *const _from, const ROEdge *const _to, const std::string &_lines, const std::string &_destStop="")
Definition: ROPerson.h:158
virtual ~TripItem()
Destructor.
Definition: ROPerson.h:145
const std::string busStop
Definition: ROPerson.h:279
const ROEdge * getDestination() const
Definition: ROPerson.h:246