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,
189  double departPos = std::numeric_limits<double>::infinity(),
190  double arrivalPos = std::numeric_limits<double>::infinity(),
191  const std::string& _destStop = "")
192  : edges(_edges), dur(-1), v(-1), dep(departPos), arr(arrivalPos), destStop(_destStop) {}
193  Walk(const ConstROEdgeVector& edges, const double duration, const double speed,
194  const double departPos, const double arrivalPos, const std::string& _destStop)
195  : edges(edges), dur(duration), v(speed), dep(departPos), arr(arrivalPos), destStop(_destStop) {}
196  const ROEdge* getOrigin() const {
197  return edges.front();
198  }
199  const ROEdge* getDestination() const {
200  return edges.back();
201  }
202  void saveAsXML(OutputDevice& os) const;
203 
204  private:
206  const double dur, v, dep, arr;
207  const std::string destStop;
208 
209  private:
211  Walk& operator=(const Walk& src);
212 
213  };
214 
219  class PersonTrip : public PlanItem {
220  public:
222  : from(0), to(0), modes(SVC_PEDESTRIAN), dep(0), arr(0), busStop(""), walkFactor(1.0) {}
223  PersonTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
224  const double departPos, const double arrivalPos, const std::string& busStop, double _walkFactor)
225  : from(from), to(to), modes(modeSet), dep(departPos), arr(arrivalPos), busStop(busStop), walkFactor(_walkFactor) {}
227  virtual ~PersonTrip() {
228  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
229  delete *it;
230  }
231  for (std::vector<ROVehicle*>::const_iterator it = myVehicles.begin(); it != myVehicles.end(); ++it) {
232  delete(*it)->getRouteDefinition();
233  delete *it;
234  }
235  }
236 
237  virtual void addTripItem(TripItem* tripIt) {
238  myTripItems.push_back(tripIt);
239  }
240  void addVehicle(ROVehicle* veh) {
241  myVehicles.push_back(veh);
242  }
243  std::vector<ROVehicle*>& getVehicles() {
244  return myVehicles;
245  }
246  const ROEdge* getOrigin() const {
247  return from != 0 ? from : myTripItems.front()->getOrigin();
248  }
249  const ROEdge* getDestination() const {
250  return to != 0 ? to : myTripItems.back()->getDestination();
251  }
252  double getDepartPos(bool replaceDefault = true) const {
253  return dep == std::numeric_limits<double>::infinity() && replaceDefault ? 0 : dep;
254  }
255  double getArrivalPos(bool replaceDefault = true) const {
256  return arr == std::numeric_limits<double>::infinity() && replaceDefault ? -POSITION_EPS : arr;
257  }
259  return modes;
260  }
261  bool hasBusStopDest() const {
262  return busStop != "";
263  }
264  virtual bool needsRouting() const {
265  return myTripItems.empty();
266  }
267  void saveVehicles(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
268  void saveAsXML(OutputDevice& os) const {
269  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
270  (*it)->saveAsXML(os);
271  }
272  }
273  double getWalkFactor() const {
274  return walkFactor;
275  }
276 
277  private:
278  const ROEdge* from;
279  const ROEdge* to;
281  const double dep, arr;
282  const std::string busStop;
284  std::vector<TripItem*> myTripItems;
286  std::vector<ROVehicle*> myVehicles;
288  double walkFactor;
289 
290  private:
292  PersonTrip& operator=(const PersonTrip& src);
293 
294  };
295 
296 
301  const ROEdge* getDepartEdge() const {
302  return myPlan.front()->getOrigin();
303  }
304 
305 
306  void computeRoute(const RORouterProvider& provider,
307  const bool removeLoops, MsgHandler* errorHandler);
308 
309 
320  void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
321 
322  std::vector<PlanItem*>& getPlan() {
323  return myPlan;
324  }
325 
326 private:
327  bool computeIntermodal(const RORouterProvider& provider, PersonTrip* const trip, const ROVehicle* const veh, MsgHandler* const errorHandler);
328 
329 private:
333  std::vector<PlanItem*> myPlan;
334 
335 
336 private:
338  ROPerson(const ROPerson& src);
339 
341  ROPerson& operator=(const ROPerson& src);
342 
343 };
344 
345 #endif
346 
347 /****************************************************************************/
348 
const ROEdge * getOrigin() const
Definition: ROPerson.h:196
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:121
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, const std::string &destStop)
Definition: ROPerson.cpp:94
bool hasBusStopDest() const
Definition: ROPerson.h:261
is a pedestrian
const std::string lines
Definition: ROPerson.h:173
const ROEdge *const edge
Definition: ROPerson.h:130
bool isStop() const
Definition: ROPerson.h:124
void addVehicle(ROVehicle *veh)
Definition: ROPerson.h:240
virtual const ROEdge * getDestination() const =0
Structure representing possible vehicle parameter.
virtual bool needsRouting() const
Definition: ROPerson.h:264
const SVCPermissions modes
Definition: ROPerson.h:280
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:286
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:223
const ROEdge * getDestination() const
Definition: ROPerson.h:249
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:63
virtual bool needsRouting() const
Definition: ROPerson.h:102
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:87
const ROEdge * getDestination() const
Definition: ROPerson.h:199
A planItem can be a Trip which contains multiple tripItems.
Definition: ROPerson.h:219
double getArrivalPos(bool replaceDefault=true) const
Definition: ROPerson.h:255
virtual ~PlanItem()
Destructor.
Definition: ROPerson.h:90
Walk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &_destStop)
Definition: ROPerson.h:193
A routable thing such as a vehicle or person.
Definition: RORoutable.h:62
A ride is part of a trip, e.g., go from here to here by car or bus.
Definition: ROPerson.h:156
A vehicle as used by router.
Definition: ROVehicle.h:60
ROPerson & operator=(const ROPerson &src)
Invalidated assignment operator.
const ROEdge * from
Definition: ROPerson.h:278
std::vector< PlanItem * > myPlan
The plan of the person.
Definition: ROPerson.h:333
SUMOVehicleParameter::Stop stopDesc
Definition: ROPerson.h:129
std::vector< PlanItem * > & getPlan()
Definition: ROPerson.h:322
const ROEdge * getDestination() const
Definition: ROPerson.h:165
double getDepartPos(bool replaceDefault=true) const
Definition: ROPerson.h:252
Walk(const ConstROEdgeVector &_edges, double departPos=std::numeric_limits< double >::infinity(), double arrivalPos=std::numeric_limits< double >::infinity(), const std::string &_destStop="")
Definition: ROPerson.h:188
virtual void addTripItem(TripItem *)
Definition: ROPerson.h:92
virtual bool isStop() const
Definition: ROPerson.h:99
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition: ROPerson.cpp:112
const ROEdge * getOrigin() const
Definition: ROPerson.h:246
const ROEdge * getOrigin() const
Definition: ROPerson.h:115
A person as used by router.
Definition: ROPerson.h:58
#define POSITION_EPS
Definition: config.h:176
const double dep
Definition: ROPerson.h:281
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:268
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:78
virtual ~ROPerson()
Destructor.
Definition: ROPerson.cpp:59
std::vector< TripItem * > myTripItems
the fully specified trips
Definition: ROPerson.h:284
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
const ROEdge * getDestination() const
Definition: ROPerson.h:118
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition: ROPerson.cpp:54
const double v
Definition: ROPerson.h:206
virtual ~PersonTrip()
Destructor.
Definition: ROPerson.h:227
SVCPermissions getModes() const
Definition: ROPerson.h:258
const ROEdge * getOrigin() const
Definition: ROPerson.h:162
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
Definition: ROPerson.cpp:197
virtual void saveAsXML(OutputDevice &os) const =0
Structure representing possible vehicle parameter.
const std::string destStop
Definition: ROPerson.h:207
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)
virtual const ROEdge * getOrigin() const =0
A storage for options typed value containers)
Definition: OptionsCont.h:99
virtual void saveVehicles(OutputDevice &, OutputDevice *const , bool, OptionsCont &) const
Definition: ROPerson.h:97
const std::string destStop
Definition: ROPerson.h:174
const ROEdge * to
Definition: ROPerson.h:279
double getWalkFactor() const
Definition: ROPerson.h:273
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
const ConstROEdgeVector edges
Definition: ROPerson.h:205
std::vector< ROVehicle * > & getVehicles()
Definition: ROPerson.h:243
virtual void addTripItem(TripItem *tripIt)
Definition: ROPerson.h:237
const ROEdge * getDepartEdge() const
Returns the first edge the person takes.
Definition: ROPerson.h:301
Stop(const SUMOVehicleParameter::Stop &stop, const ROEdge *const stopEdge)
Definition: ROPerson.h:113
double walkFactor
walking speed factor
Definition: ROPerson.h:288
const ROEdge *const to
Definition: ROPerson.h:172
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:282