SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A road/street connecting two junctions
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSEdge_h
25 #define MSEdge_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <vector>
38 #include <map>
39 #include <string>
40 #include <iostream>
41 #include <utils/common/Named.h>
43 #include <utils/common/SUMOTime.h>
48 #include "MSVehicleType.h"
49 
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class MSLaneChanger;
55 class OutputDevice;
56 class SUMOVehicle;
58 class MSVehicle;
59 class MSLane;
60 class MSPerson;
61 class MSJunction;
62 
63 
64 // ===========================================================================
65 // class definitions
66 // ===========================================================================
74 class MSEdge : public Named, public Parameterised {
75 public:
98  };
99 
100 
102  typedef std::map< const MSEdge*, std::vector<MSLane*>* > AllowedLanesCont;
103 
105  typedef std::map< SUMOVehicleClass, AllowedLanesCont > ClassedAllowedLanesCont;
106 
107 
108 public:
120  MSEdge(const std::string& id, int numericalID, const EdgeBasicFunction function, const std::string& streetName = "", const std::string& edgeType = "");
121 
122 
124  virtual ~MSEdge();
125 
126 
132  void initialize(std::vector<MSLane*>* lanes);
133 
134 
136  void closeBuilding();
137 
138 
141 
148  MSLane* leftLane(const MSLane* const lane) const;
149 
150 
157  MSLane* rightLane(const MSLane* const lane) const;
158 
159 
166  MSLane* parallelLane(const MSLane* const lane, int offset) const;
167 
168 
173  const std::vector<MSLane*>& getLanes() const {
174  return *myLanes;
175  }
176 
177 
182  std::vector<MSPerson*> getSortedPersons(SUMOTime timestep) const;
183 
192  const std::vector<MSLane*>* allowedLanes(const MSEdge& destination,
193  SUMOVehicleClass vclass = SVC_IGNORING) const;
194 
195 
203  const std::vector<MSLane*>* allowedLanes(SUMOVehicleClass vclass = SVC_IGNORING) const;
205 
206 
207 
210 
216  return myFunction;
217  }
218 
220  inline bool isInternal() const {
222  }
223 
225  inline bool isCrossing() const {
227  }
228 
230  inline bool isWalkingArea() const {
232  }
233 
237  int getNumericalID() const {
238  return myNumericalID;
239  }
240 
241 
244  const std::string& getStreetName() const {
245  return myStreetName;
246  }
247 
250  const std::string& getEdgeType() const {
251  return myEdgeType;
252  }
254 
255 
256 
259 
263  void addFollower(MSEdge* edge) {
264  mySuccessors.push_back(edge);
265  }
266 
267 
271  const std::vector<MSEdge*>& getIncomingEdges() const {
272  return myPredeccesors;
273  }
274 
275 
279  unsigned int getNoFollowing() const {
280  return (unsigned int) mySuccessors.size();
281  }
282 
283 
288  const MSEdge* getFollower(unsigned int n) const {
289  return mySuccessors[n];
290  }
291 
292 
293  const MSJunction* getFromJunction() const {
294  return myFromJunction;
295  }
296 
297  const MSJunction* getToJunction() const {
298  return myToJunction;
299  }
300 
301 
302  void setJunctions(MSJunction* from, MSJunction* to) {
303  myFromJunction = from;
304  myToJunction = to;
305  }
307 
308 
309 
312 
316  bool isVaporizing() const {
317  return myVaporizationRequests > 0;
318  }
319 
320 
331 
332 
344 
345 
354  SUMOReal getCurrentTravelTime(const SUMOReal minSpeed = 0.00001) const;
355 
356 
358  inline SUMOReal getMinimumTravelTime(const SUMOVehicle* const veh) const {
359  if (veh != 0) {
360  return getLength() / MIN2(veh->getMaxSpeed(), getVehicleMaxSpeed(veh));
361  } else {
362  return getLength() / getSpeedLimit();
363  }
364  }
365 
366 
369 
383  bool insertVehicle(SUMOVehicle& v, SUMOTime time) const;
384 
385 
400  MSLane* getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass) const;
401 
402 
413  MSLane* getDepartLane(const MSVehicle& veh) const;
414 
415 
421  }
422 
423 
427  inline void setLastFailedInsertionTime(SUMOTime time) const {
429  }
431 
432 
434  virtual void changeLanes(SUMOTime t);
435 
436 
437 #ifdef HAVE_INTERNAL_LANES
438 
439  const MSEdge* getInternalFollowingEdge(MSEdge* followerAfterInternal) const;
440 #endif
441 
443  inline bool prohibits(const SUMOVehicle* const vehicle) const {
444  if (vehicle == 0) {
445  return false;
446  }
447  const SUMOVehicleClass svc = vehicle->getVehicleType().getVehicleClass();
448  return (myCombinedPermissions & svc) != svc;
449  }
450 
451  void rebuildAllowedLanes();
452 
453 
458  SUMOReal getDistanceTo(const MSEdge* other) const;
459 
460 
464  SUMOReal getLength() const;
465 
466 
471  SUMOReal getSpeedLimit() const;
472 
473 
481  SUMOReal getVehicleMaxSpeed(const SUMOVehicle* const veh) const;
482 
483  virtual void addPerson(MSPerson* p) const {
484  myPersons.insert(p);
485  }
486 
487  virtual void removePerson(MSPerson* p) const {
488  std::set<MSPerson*>::iterator i = myPersons.find(p);
489  if (i != myPersons.end()) {
490  myPersons.erase(i);
491  }
492  }
493 
494  inline bool isRoundabout() const {
495  return myAmRoundabout;
496  }
497 
499  myAmRoundabout = true;
500  }
501 
503  bool laneChangeAllowed() const;
504 
508  static bool dictionary(const std::string& id, MSEdge* edge);
509 
511  static MSEdge* dictionary(const std::string& id);
512 
514  static MSEdge* dictionary(size_t index);
515 
517  static size_t dictSize();
518 
520  static size_t numericalDictSize();
521 
523  static void clear();
524 
526  static void insertIDs(std::vector<std::string>& into);
527 
528 
529 public:
532 
541  static void parseEdgesList(const std::string& desc, std::vector<const MSEdge*>& into,
542  const std::string& rid);
543 
544 
551  static void parseEdgesList(const std::vector<std::string>& desc, std::vector<const MSEdge*>& into,
552  const std::string& rid);
554 
555 
556 protected:
560  class by_id_sorter {
561  public:
563  explicit by_id_sorter() { }
564 
566  int operator()(const MSEdge* const e1, const MSEdge* const e2) const {
567  return e1->getID() < e2->getID();
568  }
569 
570  };
571 
576  public:
578  explicit person_by_offset_sorter(SUMOTime timestep): myTime(timestep) { }
579 
581  int operator()(const MSPerson* const p1, const MSPerson* const p2) const;
582  private:
584  };
585 
586 
595  const std::vector<MSLane*>* allowedLanes(const MSEdge* destination,
596  SUMOVehicleClass vclass = SVC_IGNORING) const;
597 
598 
600  const std::vector<MSLane*>* getAllowedLanesWithDefault(const AllowedLanesCont& c, const MSEdge* dest) const;
601 
602 protected:
605 
607  std::vector<MSLane*>* myLanes;
608 
611 
614 
617 
620 
622  std::vector<MSEdge*> mySuccessors;
623 
625  std::vector<MSEdge*> myPredeccesors;
626 
630 
632  mutable std::set<MSPerson*> myPersons;
633 
636 
639 
641  // @note: this map is filled on demand
643 
649 
651  std::string myStreetName;
652 
654  std::string myEdgeType;
655 
658 
661 
663  typedef std::map< std::string, MSEdge* > DictType;
664 
668  static DictType myDict;
669 
673  static std::vector<MSEdge*> myEdges;
675 
676 
677 
678 private:
680  MSEdge(const MSEdge&);
681 
683  MSEdge& operator=(const MSEdge&);
684 
685 };
686 
687 
688 #endif
689 
690 /****************************************************************************/
691