SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AGTrip.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Class containing all information of a given trip (car, bus)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 // activitygen module
14 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
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 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include "AGTrip.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
41 bool
43  if (getDay() < trip.getDay()) {
44  return true;
45  }
46  if (getDay() == trip.getDay())
47  if (getTime() < trip.getTime()) {
48  return true;
49  }
50  return false;
51 }
52 
53 void
55  std::cout << "Trip: " << std::endl;
56  std::cout << "\t-From= ";
57  myFrom.print();
58  std::cout << "\t-To= ";
59  myTo.print();
60  std::cout << "\t-At= " << myDepTime << " -Day= " << myDay << std::endl;
61  std::cout << "\t-Vehicle= " << myVehicle << std::endl;
62  std::cout << "\t-type= " << myType << std::endl;
63 }
64 
65 void
67  myPassBy.push_back(by);
68 }
69 
70 void
72  std::list<AGPosition>::iterator it;
73  for (it = trip.myPassBy.begin(); it != trip.myPassBy.end(); ++it) {
74  myPassBy.push_back(*it);
75  }
76  myPassBy.push_back(trip.myTo);
77 }
78 
79 void
81  std::list<AGPosition>::iterator it;
82  for (it = trip.myPassBy.begin(); it != trip.myPassBy.end(); ++it) {
83  myPassBy.push_back(*it);
84  }
85 }
86 
87 std::list<AGPosition>*
89  return &myPassBy;
90 }
91 
92 std::string
94  return myType;
95 }
96 
97 void
98 AGTrip::setType(std::string type) {
99  myType = type;
100 }
101 
104  return myFrom;
105 }
106 
109  return myTo;
110 }
111 
112 int
114  return myDepTime;
115 }
116 
117 int
119  SUMOReal dist = 0;
120  std::list<AGPosition> positions;
121  positions.push_back(myFrom);
122  std::list<AGPosition>::iterator it;
123  for (it = myPassBy.begin(); it != myPassBy.end(); ++it) {
124  positions.push_back(*it);
125  }
126  positions.push_back(myTo);
127 
128  bool firstPass = true;
129  AGPosition* temp;
130  for (it = positions.begin(); it != positions.end(); ++it) {
131  if (firstPass) {
132  temp = &*it;
133  continue;
134  }
135  dist += temp->distanceTo(*it);
136  temp = &*it;
137  }
138  return (int)(secPerKm * (dist / 1000.0));
139 }
140 
141 int
143  return myDepTime + getTimeTrip(secPerKm);
144 }
145 
146 int
148  return getArrTime(secPerKm) + (int)(secPerKm * myTo.distanceTo(myFrom) / 1000.0);
149 }
150 
151 void
153  myDepTime = time;
154 }
155 
156 int
157 AGTrip::estimateDepTime(int arrTime, SUMOReal secPerKm) {
158  return arrTime - getTimeTrip(secPerKm);
159 }
160 
161 std::string
163  return myVehicle;
164 }
165 
166 void
167 AGTrip::setVehicleName(std::string name) {
168  myVehicle = name;
169 }
170 
171 void
173  myTo = *new AGPosition(arrival.getStreet(), arrival.getPosition());
174 }
175 
176 void
178  myFrom = *new AGPosition(departure.getStreet(), departure.getPosition());
179 }
180 
181 bool
183  return (myDay == 0);
184 }
185 
186 int
188  return myDay;
189 }
190 
191 void
193  myDay = d;
194 }
195 
196 /****************************************************************************/