SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
12 // A basic edge for routing applications
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
15 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 #ifndef ROEdge_h
26 #define ROEdge_h
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <string>
39 #include <map>
40 #include <vector>
41 #include <algorithm>
42 #include <utils/common/Named.h>
43 #include <utils/common/StdDefs.h>
47 #include "RONode.h"
48 #include "ROVehicle.h"
49 
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class ROLane;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
69 class ROEdge : public Named {
70 public:
75  enum EdgeType {
90  };
91 
92 
100  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, const int priority);
101 
102 
104  virtual ~ROEdge();
105 
106 
108 
109 
118  virtual void addLane(ROLane* lane);
119 
120 
128  virtual void addFollower(ROEdge* s, std::string dir = "");
129 
130 
134  void setType(EdgeType type);
135 
137  inline bool isInternal() const {
138  return myType == ET_INTERNAL;
139  }
140 
142  inline bool isCrossing() const {
143  return myType == ET_CROSSING;
144  }
145 
147  inline bool isWalkingArea() const {
148  return myType == ET_WALKINGAREA;
149  }
150 
160  void buildTimeLines(const std::string& measure);
162 
163 
164 
166 
167 
172  EdgeType getType() const {
173  return myType;
174  }
175 
176 
180  SUMOReal getLength() const {
181  return myLength;
182  }
183 
187  unsigned int getNumericalID() const {
188  return myIndex;
189  }
190 
191 
195  SUMOReal getSpeed() const {
196  return mySpeed;
197  }
198 
199 
203  unsigned int getLaneNo() const {
204  return (unsigned int) myLanes.size();
205  }
206 
207 
211  RONode* getFromNode() const {
212  return myFromNode;
213  }
214 
215 
219  RONode* getToNode() const {
220  return myToNode;
221  }
222 
223 
229  bool isConnectedTo(const ROEdge* const e) const {
230  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
231  }
232 
233 
238  inline bool prohibits(const ROVehicle* const vehicle) const {
239  const SUMOVehicleClass vclass = vehicle->getVClass();
240  return (myCombinedPermissions & vclass) != vclass;
241  }
242 
244  return myCombinedPermissions;
245  }
246 
247 
252  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
254 
255 
256 
258 
259 
266  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
267 
268 
275  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
276 
277 
285  unsigned int getNoFollowing() const;
286 
287 
292  ROEdge* getFollower(unsigned int pos) const {
293  return myFollowingEdges[pos];
294  }
295 
296 
304  unsigned int getNumApproaching() const;
305 
306 
311  ROEdge* getApproaching(unsigned int pos) const {
312  return myApproachingEdges[pos];
313  }
314 
315 
323  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
324 
325 
332  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
333 
334 
340  inline SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const {
341  return myLength / MIN2(veh->getType()->maxSpeed, SUMOReal(2. * veh->getType()->speedDev + 1.) * veh->getType()->speedFactor * mySpeed);
342  }
343 
344 
345  SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const;
346  SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const;
347  SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const;
348  SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const;
349  SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const;
350  SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const;
351  SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const;
353 
354 
356  SUMOReal getDistanceTo(const ROEdge* other) const;
357 
358 
360  static ROEdge* dictionary(size_t index);
361 
363  static size_t dictSize() {
364  return myEdges.size();
365  };
366 
367  static void setTimeLineOptions(
368  bool useBoundariesOnOverrideTT,
369  bool useBoundariesOnOverrideE,
370  bool interpolate) {
371  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
372  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
373  myInterpolate = interpolate;
374  }
375 
377  int getPriority() const {
378  return myPriority;
379  }
380 
381  const RONode* getFromJunction() const {
382  return myFromJunction;
383  }
384 
385  const RONode* getToJunction() const {
386  return myToJunction;
387  }
388 
389 
390  void setJunctions(RONode* from, RONode* to) {
391  myFromJunction = from;
392  myToJunction = to;
393  }
394 
399  const std::vector<ROLane*>& getLanes() const {
400  return myLanes;
401  }
402 protected:
409  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
410 
411 
412 
413 protected:
415  RONode* const myFromNode, * const myToNode;
416 
418  const unsigned int myIndex;
419 
421  const int myPriority;
422 
425 
428 
429 
436 
443 
445  static bool myInterpolate;
446 
448  static bool myHaveEWarned;
450  static bool myHaveTTWarned;
451 
453  std::vector<ROEdge*> myFollowingEdges;
454 
456  std::vector<ROEdge*> myApproachingEdges;
457 
460 
462  std::vector<ROLane*> myLanes;
463 
466 
467  static std::vector<ROEdge*> myEdges;
468 
472 
473 
474 private:
476  ROEdge(const ROEdge& src);
477 
479  ROEdge& operator=(const ROEdge& src);
480 
481 };
482 
483 
484 #endif
485 
486 /****************************************************************************/
487