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-2012 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  from.print();
58  std::cout << "\t-To= ";
59  to.print();
60  std::cout << "\t-At= " << atTime << " -Day= " << day << std::endl;
61  std::cout << "\t-Vehicle= " << vehicle << std::endl;
62  std::cout << "\t-type= " << type << std::endl;
63 }
64 
65 void
67  passBy.push_back(by);
68 }
69 
70 void
72  std::list<AGPosition>::iterator it;
73  for (it = trip.passBy.begin() ; it != trip.passBy.end() ; ++it) {
74  passBy.push_back(*it);
75  }
76  passBy.push_back(trip.to);
77 }
78 
79 void
81  std::list<AGPosition>::iterator it;
82  for (it = trip.passBy.begin() ; it != trip.passBy.end() ; ++it) {
83  passBy.push_back(*it);
84  }
85 }
86 
87 std::list<AGPosition>*
89  return &passBy;
90 }
91 
92 std::string
94  return type;
95 }
96 
97 void
98 AGTrip::setType(std::string type) {
99  this->type = type;
100 }
101 
104  return from;
105 }
106 
109  return to;
110 }
111 
112 int
114  return atTime;
115 }
116 
117 int
119  SUMOReal dist = 0;
120  std::list<AGPosition> positions;
121  positions.push_back(from);
122  std::list<AGPosition>::iterator it;
123  for (it = passBy.begin() ; it != passBy.end() ; ++it) {
124  positions.push_back(*it);
125  }
126  positions.push_back(to);
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  int arrTime = atTime + getTimeTrip(secPerKm);
144  return arrTime;
145 }
146 
147 int
149  int arrAtTime = getArrTime(secPerKm);
150  int time = (int)(secPerKm * to.distanceTo(from) / 1000.0);
151  int arrTime = arrAtTime + time;
152  return arrTime;
153 }
154 
155 void
157  atTime = time;
158 }
159 
160 int
161 AGTrip::estimateDepTime(int arrTime, SUMOReal secPerKm) {
162  int depTime = arrTime - getTimeTrip(secPerKm);
163  return depTime;
164 }
165 
166 std::string
168  return vehicle;
169 }
170 
171 void
172 AGTrip::setVehicleName(std::string name) {
173  vehicle = name;
174 }
175 
176 void
178  to = *new AGPosition(arrival.getStreet(), arrival.getPosition());
179 }
180 
181 void
183  from = *new AGPosition(departure.getStreet(), departure.getPosition());
184 }
185 
186 bool
188  if (day == 0) {
189  return true;
190  } else {
191  return false;
192  }
193 }
194 
195 int
197  return day;
198 }
199 
200 void
202  day = d;
203 }
204 
205 /****************************************************************************/