SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMOVTypeParameter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Structure representing possible vehicle parameter
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <algorithm>
35 #include <utils/common/ToString.h>
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // member method definitions
50 // ===========================================================================
51 SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
52  : id(vtid), length(5./*4.3*/), minGap(2.5), maxSpeed(200. / 3.6),
53  defaultProbability(DEFAULT_VEH_PROB),
54  speedFactor(1.0), speedDev(0.0),
55  emissionClass(PollutantsInterface::getClassByName("unknown", vclass)), color(RGBColor::DEFAULT_COLOR),
56  vehicleClass(vclass), impatience(0.0),
57  width(1.8), height(1.5), shape(SVS_UNKNOWN),
58  cfModel(SUMO_TAG_CF_KRAUSS), lcModel(LCM_LC2013),
59  setParameter(0), saved(false), onlyReferenced(false) {
60  switch (vclass) {
61  case SVC_PEDESTRIAN:
62  length = 0.215;
63  minGap = 0.5;
65  width = 0.478;
66  height = 1.719;
68  break;
69  case SVC_BICYCLE:
70  length = 1.6;
71  minGap = 0.5;
72  maxSpeed = 20. / 3.6;
73  width = 0.65;
74  height = 1.7;
76  break;
77  case SVC_MOPED:
78  length = 2.1;
79  maxSpeed = 60. / 3.6;
80  width = 0.8;
81  height = 1.7;
82  shape = SVS_MOPED;
83  break;
84  case SVC_MOTORCYCLE:
85  length = 2.2;
86  width = 0.9;
87  height = 1.5;
89  break;
90  case SVC_TRUCK:
91  length = 7.1;
92  maxSpeed = 130. / 3.6;
93  width = 2.4;
94  height = 2.4;
95  shape = SVS_TRUCK;
96  break;
97  case SVC_TRAILER:
98  length = 16.5;
99  maxSpeed = 130. / 3.6;
100  width = 2.55;
101  height = 4.;
103  break;
104  case SVC_BUS:
105  length = 12.;
106  maxSpeed = 100. / 3.6;
107  width = 2.5;
108  height = 3.4;
109  shape = SVS_BUS;
110  break;
111  case SVC_COACH:
112  length = 14.;
113  maxSpeed = 100. / 3.6;
114  width = 2.6;
115  height = 4.;
117  break;
118  case SVC_TRAM:
119  length = 22.;
120  maxSpeed = 80. / 3.6;
121  width = 2.4;
122  height = 3.2;
124  break;
125  case SVC_RAIL_URBAN:
126  length = 36.5 * 3;
127  maxSpeed = 100. / 3.6;
128  width = 3.0;
129  height = 3.6;
131  break;
132  case SVC_RAIL:
133  length = 67.5 * 2;
134  maxSpeed = 160. / 3.6;
135  width = 2.84;
136  height = 3.75;
137  shape = SVS_RAIL;
138  break;
139  case SVC_RAIL_ELECTRIC:
140  length = 25. * 8;
141  maxSpeed = 330. / 3.6;
142  width = 2.95;
143  height = 3.89;
144  shape = SVS_RAIL;
145  break;
146  case SVC_DELIVERY:
147  length = 6.5;
148  width = 2.16;
149  height = 2.86;
151  break;
152  case SVC_EMERGENCY:
153  length = 6.5;
154  width = 2.16;
155  height = 2.86;
157  break;
158  case SVC_PASSENGER:
160  break;
161  case SVC_E_VEHICLE:
163  break;
164  default:
165  break;
166  }
167 }
168 
169 
170 void
172  if (onlyReferenced) {
173  return;
174  }
175  dev.openTag(SUMO_TAG_VTYPE);
176  dev.writeAttr(SUMO_ATTR_ID, id);
179  }
182  }
185  }
188  }
191  }
194  }
197  }
200  }
203  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
204  } else {
206  }
207  }
210  }
213  }
216  }
219  }
222  }
225  }
228  }
229 
230  if (cfParameter.size() != 0) {
231  dev.openTag(cfModel);
232  std::vector<SumoXMLAttr> attrs;
233  for (CFParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
234  attrs.push_back(i->first);
235  }
236  std::sort(attrs.begin(), attrs.end());
237  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
238  dev.writeAttr(*i, cfParameter.find(*i)->second);
239  }
240  dev.closeTag();
241  dev.closeTag();
242  } else {
243  dev.closeTag();
244  }
245 }
246 
247 
248 SUMOReal
249 SUMOVTypeParameter::get(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
250  if (cfParameter.count(attr)) {
251  return cfParameter.find(attr)->second;
252  } else {
253  return defaultValue;
254  }
255 }
256 
257 
258 SUMOReal
260  switch (vc) {
261  case SVC_PEDESTRIAN:
262  return 1.5;
263  case SVC_BICYCLE:
264  return 1.2;
265  case SVC_MOTORCYCLE:
266  return 6.;
267  case SVC_MOPED:
268  return 1.1;
269  case SVC_TRUCK:
270  return 1.3;
271  case SVC_TRAILER:
272  return 1.1;
273  case SVC_BUS:
274  return 1.2;
275  case SVC_COACH:
276  return 2.;
277  case SVC_TRAM:
278  return 1.;
279  case SVC_RAIL_URBAN:
280  return 1.;
281  case SVC_RAIL:
282  return 0.25;
283  case SVC_RAIL_ELECTRIC:
284  return 0.5;
285  default:
286  return 2.6;//2.9;
287  }
288 }
289 
290 
291 SUMOReal
293  switch (vc) {
294  case SVC_PEDESTRIAN:
295  return 2.;
296  case SVC_BICYCLE:
297  return 3.;
298  case SVC_MOPED:
299  return 7.;
300  case SVC_MOTORCYCLE:
301  return 10.;
302  case SVC_TRUCK:
303  return 4.;
304  case SVC_TRAILER:
305  return 4.;
306  case SVC_BUS:
307  return 4.;
308  case SVC_COACH:
309  return 4.;
310  case SVC_TRAM:
311  return 3.;
312  case SVC_RAIL_URBAN:
313  return 3.;
314  case SVC_RAIL:
315  return 1.3;
316  case SVC_RAIL_ELECTRIC:
317  return 1.3;
318  default:
319  return 4.5;//7.5;
320  }
321 }
322 
323 
324 SUMOReal
326  switch (vc) {
327  case SVC_TRAM:
328  case SVC_RAIL_URBAN:
329  case SVC_RAIL:
330  case SVC_RAIL_ELECTRIC:
331  return 0.;
332  default:
333  return 0.5;
334  }
335 }
336 
337 
338 const SUMOVTypeParameter&
340  static SUMOVTypeParameter defaultParams("");
341  return defaultParams;
342 }
343 
344 
345 /****************************************************************************/