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 /****************************************************************************/
11 // Class containing all information of a given trip (car, bus)
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2010-2014 DLR (http://www.dlr.de/) and contributors
15 // activitygen module
16 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
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 "AGTrip.h"
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 bool
44 AGTrip::operator <(const AGTrip& trip) const {
45  if (getDay() < trip.getDay()) {
46  return true;
47  }
48  if (getDay() == trip.getDay())
49  if (getTime() < trip.getTime()) {
50  return true;
51  }
52  return false;
53 }
54 
55 void
57  std::cout << "Trip: " << std::endl;
58  std::cout << "\t-From= ";
59  myFrom.print();
60  std::cout << "\t-To= ";
61  myTo.print();
62  std::cout << "\t-At= " << myDepTime << " -Day= " << myDay << std::endl;
63  std::cout << "\t-Vehicle= " << myVehicle << std::endl;
64  std::cout << "\t-type= " << myType << std::endl;
65 }
66 
67 void
69  myPassBy.push_back(by);
70 }
71 
72 void
74  std::list<AGPosition>::iterator it;
75  for (it = trip.myPassBy.begin(); it != trip.myPassBy.end(); ++it) {
76  myPassBy.push_back(*it);
77  }
78  myPassBy.push_back(trip.myTo);
79 }
80 
81 void
83  std::list<AGPosition>::iterator it;
84  for (it = trip.myPassBy.begin(); it != trip.myPassBy.end(); ++it) {
85  myPassBy.push_back(*it);
86  }
87 }
88 
89 std::list<AGPosition>*
91  return &myPassBy;
92 }
93 
94 const std::string&
95 AGTrip::getType() const {
96  return myType;
97 }
98 
99 void
100 AGTrip::setType(std::string type) {
101  myType = type;
102 }
103 
105 AGTrip::getDep() const {
106  return myFrom;
107 }
108 
110 AGTrip::getArr() const {
111  return myTo;
112 }
113 
114 int
116  return myDepTime;
117 }
118 
119 int
121  SUMOReal dist = 0;
122  std::list<AGPosition> positions;
123  positions.push_back(myFrom);
124  std::list<AGPosition>::iterator it;
125  for (it = myPassBy.begin(); it != myPassBy.end(); ++it) {
126  positions.push_back(*it);
127  }
128  positions.push_back(myTo);
129 
130  AGPosition* temp = &positions.front();
131  for (it = positions.begin(), ++it; it != positions.end(); ++it) {
132  dist += temp->distanceTo(*it);
133  temp = &*it;
134  }
135  return (int)(secPerKm * (dist / 1000.0));
136 }
137 
138 int
140  return myDepTime + getTimeTrip(secPerKm);
141 }
142 
143 int
145  return getArrTime(secPerKm) + (int)(secPerKm * myTo.distanceTo(myFrom) / 1000.0);
146 }
147 
148 void
150  myDepTime = time;
151 }
152 
153 int
154 AGTrip::estimateDepTime(int arrTime, SUMOReal secPerKm) {
155  return arrTime - getTimeTrip(secPerKm);
156 }
157 
158 const std::string&
160  return myVehicle;
161 }
162 
163 void
164 AGTrip::setVehicleName(std::string name) {
165  myVehicle = name;
166 }
167 
168 void
170  myTo = *new AGPosition(arrival.getStreet(), arrival.getPosition());
171 }
172 
173 void
175  myFrom = *new AGPosition(departure.getStreet(), departure.getPosition());
176 }
177 
178 bool
180  return (myDay == 0);
181 }
182 
183 int
184 AGTrip::getDay() const {
185  return myDay;
186 }
187 
188 void
190  myDay = d;
191 }
192 
193 /****************************************************************************/