SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMOVehicleParserHelper.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // Helper methods for parsing vehicle attributes
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 
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 <utils/common/ToString.h>
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // static members
49 // ===========================================================================
51 
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
58 SUMOVehicleParserHelper::parseFlowAttributes(const SUMOSAXAttributes& attrs, const SUMOTime beginDefault, const SUMOTime endDefault) {
59  bool ok = true;
60  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
62  throw ProcessError("At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
63  "' and '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
64  "' has to be given in the definition of flow '" + id + "'.");
65  }
68  throw ProcessError("If '" + attrs.getName(SUMO_ATTR_PERIOD) +
69  "' or '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
70  "' are given at most one of '" + attrs.getName(SUMO_ATTR_END) +
71  "' and '" + attrs.getName(SUMO_ATTR_NUMBER) +
72  "' are allowed in flow '" + id + "'.");
73  }
74  } else {
75  if (!attrs.hasAttribute(SUMO_ATTR_NUMBER)) {
76  throw ProcessError("At least one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
77  "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
78  "', and '" + attrs.getName(SUMO_ATTR_NUMBER) +
79  "' is needed in flow '" + id + "'.");
80  }
81  }
83  ret->id = id;
84  try {
85  parseCommonAttributes(attrs, ret, "flow");
86  } catch (ProcessError&) {
87  delete ret;
88  throw;
89  }
90 
91  // parse repetition information
92  if (attrs.hasAttribute(SUMO_ATTR_PERIOD)) {
94 #ifdef HAVE_SUBSECOND_TIMESTEPS
95  ret->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok);
96 #else
97  ret->repetitionOffset = attrs.get<SUMOReal>(SUMO_ATTR_PERIOD, id.c_str(), ok);
98 #endif
99  }
100  if (attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {
102  const SUMOReal vph = attrs.get<SUMOReal>(SUMO_ATTR_VEHSPERHOUR, id.c_str(), ok);
103  if (ok && vph <= 0) {
104  delete ret;
105  throw ProcessError("Invalid repetition rate in the definition of flow '" + id + "'.");
106  }
107  if (ok && vph != 0) {
108  ret->repetitionOffset = TIME2STEPS(3600. / vph);
109  }
110  }
111 
112  ret->depart = beginDefault;
113  if (attrs.hasAttribute(SUMO_ATTR_BEGIN)) {
114  ret->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok);
115  }
116  if (ok && ret->depart < 0) {
117  delete ret;
118  throw ProcessError("Negative begin time in the definition of flow '" + id + "'.");
119  }
120  SUMOTime end = endDefault;
121  if (end < 0) {
122  end = SUMOTime_MAX;
123  }
124  if (attrs.hasAttribute(SUMO_ATTR_END)) {
125  end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok);
126  }
127  if (ok && end <= ret->depart) {
128  delete ret;
129  throw ProcessError("Flow '" + id + "' ends before or at its begin time.");
130  }
131  if (attrs.hasAttribute(SUMO_ATTR_NUMBER)) {
132  ret->repetitionNumber = attrs.get<int>(SUMO_ATTR_NUMBER, id.c_str(), ok);
134  if (ret->repetitionNumber == 0) {
135  WRITE_WARNING("Flow '" + id + "' has 0 vehicles; will skip it.");
136  } else {
137  if (ok && ret->repetitionNumber < 0) {
138  delete ret;
139  throw ProcessError("Negative repetition number in the definition of flow '" + id + "'.");
140  }
141  if (ok && ret->repetitionOffset < 0) {
142  ret->repetitionOffset = (end - ret->depart) / ret->repetitionNumber;
143  }
144  }
145  } else {
146  if (ok && ret->repetitionOffset <= 0) {
147  delete ret;
148  throw ProcessError("Invalid repetition rate in the definition of flow '" + id + "'.");
149  }
150  if (end == SUMOTime_MAX) {
151  ret->repetitionNumber = INT_MAX;
152  } else {
153  ret->repetitionNumber = static_cast<int>(static_cast<SUMOReal>(end - ret->depart) / ret->repetitionOffset + 0.5);
154  }
155  }
156  if (!ok) {
157  delete ret;
158  throw ProcessError();
159  }
160  return ret;
161 }
162 
163 
166  bool optionalID, bool skipDepart) {
167  bool ok = true;
168  std::string id, errorMsg;
169  if (optionalID) {
170  id = attrs.getOpt<std::string>(SUMO_ATTR_ID, 0, ok, "");
171  } else {
172  id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
173  }
175  ret->id = id;
176  try {
177  parseCommonAttributes(attrs, ret, "vehicle");
178  if (!skipDepart) {
179  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPART, ret->id.c_str(), ok);
180  if (!ok || !SUMOVehicleParameter::parseDepart(helper, "vehicle", ret->id, ret->depart, ret->departProcedure, errorMsg)) {
181  throw ProcessError(errorMsg);
182  }
183  }
184  } catch (ProcessError&) {
185  delete ret;
186  throw;
187  }
188  return ret;
189 }
190 
191 
192 void
194  SUMOVehicleParameter* ret, std::string element) {
195  //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
196  bool ok = true;
197  // parse route information
198  if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
199  ret->setParameter |= VEHPARS_ROUTE_SET; // !!! needed?
200  ret->routeid = attrs.get<std::string>(SUMO_ATTR_ROUTE, ret->id.c_str(), ok);
201  }
202  // parse type information
203  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
204  ret->setParameter |= VEHPARS_VTYPE_SET; // !!! needed?
205  ret->vtypeid = attrs.get<std::string>(SUMO_ATTR_TYPE, ret->id.c_str(), ok);
206  }
207  // parse line information
208  if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
209  ret->setParameter |= VEHPARS_LINE_SET; // !!! needed?
210  ret->line = attrs.get<std::string>(SUMO_ATTR_LINE, ret->id.c_str(), ok);
211  }
212  // parse zone information
215  ret->fromTaz = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, ret->id.c_str(), ok);
216  ret->toTaz = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, ret->id.c_str(), ok);
217  }
218  // parse reroute information
219  if (attrs.getOpt<bool>(SUMO_ATTR_REROUTE, 0, ok, false)) {
221  }
222 
223  std::string error;
224  // parse depart lane information
225  if (attrs.hasAttribute(SUMO_ATTR_DEPARTLANE)) {
227  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTLANE, ret->id.c_str(), ok);
228  if (!SUMOVehicleParameter::parseDepartLane(helper, element, ret->id, ret->departLane, ret->departLaneProcedure, error)) {
229  throw ProcessError(error);
230  }
231  }
232  // parse depart position information
233  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
235  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS, ret->id.c_str(), ok);
236  if (!SUMOVehicleParameter::parseDepartPos(helper, element, ret->id, ret->departPos, ret->departPosProcedure, error)) {
237  throw ProcessError(error);
238  }
239  }
240  // parse depart speed information
241  if (attrs.hasAttribute(SUMO_ATTR_DEPARTSPEED)) {
243  std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTSPEED, ret->id.c_str(), ok);
244  if (!SUMOVehicleParameter::parseDepartSpeed(helper, element, ret->id, ret->departSpeed, ret->departSpeedProcedure, error)) {
245  throw ProcessError(error);
246  }
247  }
248 
249  // parse arrival lane information
250  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALLANE)) {
252  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALLANE, ret->id.c_str(), ok);
253  if (!SUMOVehicleParameter::parseArrivalLane(helper, element, ret->id, ret->arrivalLane, ret->arrivalLaneProcedure, error)) {
254  throw ProcessError(error);
255  }
256  }
257  // parse arrival position information
258  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
260  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, ret->id.c_str(), ok);
261  if (!SUMOVehicleParameter::parseArrivalPos(helper, element, ret->id, ret->arrivalPos, ret->arrivalPosProcedure, error)) {
262  throw ProcessError(error);
263  }
264  }
265  // parse arrival speed information
268  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALSPEED, ret->id.c_str(), ok);
269  if (!SUMOVehicleParameter::parseArrivalSpeed(helper, element, ret->id, ret->arrivalSpeed, ret->arrivalSpeedProcedure, error)) {
270  throw ProcessError(error);
271  }
272  }
273 
274  // parse color
275  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
277  ret->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, ret->id.c_str(), ok);
278  } else {
280  }
281  // parse person capacity
284  ret->personCapacity = attrs.get<int>(SUMO_ATTR_PERSON_CAPACITY, ret->id.c_str(), ok);
285  }
286  // parse person number
289  ret->personNumber = attrs.get<int>(SUMO_ATTR_PERSON_NUMBER, ret->id.c_str(), ok);
290  }
291 }
292 
293 
295 SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const std::string& file) {
296  SUMOVTypeParameter* vtype = new SUMOVTypeParameter();
297  bool ok = true;
298  vtype->id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
299  if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
300  vtype->length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, vtype->id.c_str(), ok);
302  }
303  if (attrs.hasAttribute(SUMO_ATTR_MINGAP)) {
304  vtype->minGap = attrs.get<SUMOReal>(SUMO_ATTR_MINGAP, vtype->id.c_str(), ok);
306  }
307  if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
308  vtype->maxSpeed = attrs.get<SUMOReal>(SUMO_ATTR_MAXSPEED, vtype->id.c_str(), ok);
310  }
311  if (attrs.hasAttribute(SUMO_ATTR_SPEEDFACTOR)) {
312  vtype->speedFactor = attrs.get<SUMOReal>(SUMO_ATTR_SPEEDFACTOR, vtype->id.c_str(), ok);
314  }
315  if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
316  vtype->speedDev = attrs.get<SUMOReal>(SUMO_ATTR_SPEEDDEV, vtype->id.c_str(), ok);
318  }
320  vtype->emissionClass = parseEmissionClass(attrs, vtype->id);
322  }
323  if (attrs.hasAttribute(SUMO_ATTR_IMPATIENCE)) {
324  if (attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vtype->id.c_str(), ok) == "off") {
326  } else {
327  vtype->impatience = attrs.get<SUMOReal>(SUMO_ATTR_IMPATIENCE, vtype->id.c_str(), ok);
328  }
330  }
331  if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
332  vtype->vehicleClass = parseVehicleClass(attrs, vtype->id);
334  }
335  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
336  vtype->width = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, vtype->id.c_str(), ok);
338  }
339  if (attrs.hasAttribute(SUMO_ATTR_HEIGHT)) {
340  vtype->height = attrs.get<SUMOReal>(SUMO_ATTR_HEIGHT, vtype->id.c_str(), ok);
342  }
343  if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
344  vtype->shape = parseGuiShape(attrs, vtype->id);
346  }
347  if (attrs.hasAttribute(SUMO_ATTR_OSGFILE)) {
348  vtype->osgFile = attrs.get<std::string>(SUMO_ATTR_OSGFILE, vtype->id.c_str(), ok);
350  }
351  if (attrs.hasAttribute(SUMO_ATTR_IMGFILE)) {
352  vtype->imgFile = attrs.get<std::string>(SUMO_ATTR_IMGFILE, vtype->id.c_str(), ok);
353  if (vtype->imgFile != "" && !FileHelpers::isAbsolute(vtype->imgFile)) {
355  }
357  }
358  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
359  vtype->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, vtype->id.c_str(), ok);
361  } else {
362  vtype->color = RGBColor::YELLOW;
363  }
364  if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
365  vtype->defaultProbability = attrs.get<SUMOReal>(SUMO_ATTR_PROB, vtype->id.c_str(), ok);
367  }
369  const std::string lcmS = attrs.get<std::string>(SUMO_ATTR_LANE_CHANGE_MODEL, vtype->id.c_str(), ok);
370  if (SUMOXMLDefinitions::LaneChangeModels.hasString(lcmS)) {
373  } else {
374  WRITE_ERROR("Unknown lane change model '" + lcmS + "' when parsing vtype '" + vtype->id + "'");
375  throw ProcessError();
376  }
377  }
378  try {
379  parseVTypeEmbedded(*vtype, SUMO_TAG_CF_KRAUSS, attrs, true);
380  } catch (ProcessError&) {
381  throw;
382  }
383  if (!ok) {
384  delete vtype;
385  throw ProcessError();
386  }
387  return vtype;
388 }
389 
390 
391 void
393  int element, const SUMOSAXAttributes& attrs,
394  bool fromVType) {
395  const CFAttrMap& allowedAttrs = getAllowedCFModelAttrs();
396  CFAttrMap::const_iterator cf_it;
397  for (cf_it = allowedAttrs.begin(); cf_it != allowedAttrs.end(); cf_it++) {
398  if (cf_it->first == element) {
399  break;
400  }
401  }
402  if (cf_it == allowedAttrs.end()) {
403  if (SUMOXMLDefinitions::Tags.has(element)) {
404  WRITE_ERROR("Unknown cfmodel " + toString((SumoXMLTag)element) + " when parsing vtype '" + into.id + "'");
405  } else {
406  WRITE_ERROR("Unknown cfmodel when parsing vtype '" + into.id + "'");
407  }
408  throw ProcessError();
409  return;
410  }
411  if (!fromVType) {
412  into.cfModel = cf_it->first;
413  }
414  bool ok = true;
415  for (std::set<SumoXMLAttr>::const_iterator it = cf_it->second.begin(); it != cf_it->second.end(); it++) {
416  if (attrs.hasAttribute(*it)) {
417  into.cfParameter[*it] = attrs.get<SUMOReal>(*it, into.id.c_str(), ok);
418  if (*it == SUMO_ATTR_TAU && TIME2STEPS(into.cfParameter[*it]) < DELTA_T) {
419  WRITE_WARNING("Value of tau=" + toString(into.cfParameter[*it])
420  + " in car following model '" + toString(into.cfModel) + "' lower than simulation step size may cause collisions");
421  }
422  }
423  }
424  if (!ok) {
425  throw ProcessError();
426  }
427 }
428 
429 
432  // init on first use
433  if (allowedCFModelAttrs.size() == 0) {
434  std::set<SumoXMLAttr> krausParams;
435  krausParams.insert(SUMO_ATTR_ACCEL);
436  krausParams.insert(SUMO_ATTR_DECEL);
437  krausParams.insert(SUMO_ATTR_SIGMA);
438  krausParams.insert(SUMO_ATTR_TAU);
442 
443  std::set<SumoXMLAttr> smartSKParams;
444  smartSKParams.insert(SUMO_ATTR_ACCEL);
445  smartSKParams.insert(SUMO_ATTR_DECEL);
446  smartSKParams.insert(SUMO_ATTR_SIGMA);
447  smartSKParams.insert(SUMO_ATTR_TAU);
448  smartSKParams.insert(SUMO_ATTR_TMP1);
449  smartSKParams.insert(SUMO_ATTR_TMP2);
450  smartSKParams.insert(SUMO_ATTR_TMP3);
451  smartSKParams.insert(SUMO_ATTR_TMP4);
452  smartSKParams.insert(SUMO_ATTR_TMP5);
453  allowedCFModelAttrs[SUMO_TAG_CF_SMART_SK] = smartSKParams;
454 
455  std::set<SumoXMLAttr> daniel1Params;
456  daniel1Params.insert(SUMO_ATTR_ACCEL);
457  daniel1Params.insert(SUMO_ATTR_DECEL);
458  daniel1Params.insert(SUMO_ATTR_SIGMA);
459  daniel1Params.insert(SUMO_ATTR_TAU);
460  daniel1Params.insert(SUMO_ATTR_TMP1);
461  daniel1Params.insert(SUMO_ATTR_TMP2);
462  daniel1Params.insert(SUMO_ATTR_TMP3);
463  daniel1Params.insert(SUMO_ATTR_TMP4);
464  daniel1Params.insert(SUMO_ATTR_TMP5);
465  allowedCFModelAttrs[SUMO_TAG_CF_DANIEL1] = daniel1Params;
466 
467  std::set<SumoXMLAttr> pwagParams;
468  pwagParams.insert(SUMO_ATTR_ACCEL);
469  pwagParams.insert(SUMO_ATTR_DECEL);
470  pwagParams.insert(SUMO_ATTR_SIGMA);
471  pwagParams.insert(SUMO_ATTR_TAU);
472  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_TAULAST);
473  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_APPROB);
475 
476  std::set<SumoXMLAttr> idmParams;
477  idmParams.insert(SUMO_ATTR_ACCEL);
478  idmParams.insert(SUMO_ATTR_DECEL);
479  idmParams.insert(SUMO_ATTR_TAU);
480  idmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
481  idmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
483 
484  std::set<SumoXMLAttr> idmmParams;
485  idmmParams.insert(SUMO_ATTR_ACCEL);
486  idmmParams.insert(SUMO_ATTR_DECEL);
487  idmmParams.insert(SUMO_ATTR_TAU);
488  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_FACTOR);
489  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_TIME);
490  idmmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
492 
493  std::set<SumoXMLAttr> bkernerParams;
494  bkernerParams.insert(SUMO_ATTR_ACCEL);
495  bkernerParams.insert(SUMO_ATTR_DECEL);
496  bkernerParams.insert(SUMO_ATTR_TAU);
497  bkernerParams.insert(SUMO_ATTR_K);
498  bkernerParams.insert(SUMO_ATTR_CF_KERNER_PHI);
499  allowedCFModelAttrs[SUMO_TAG_CF_BKERNER] = bkernerParams;
500 
501  std::set<SumoXMLAttr> wiedemannParams;
502  wiedemannParams.insert(SUMO_ATTR_ACCEL);
503  wiedemannParams.insert(SUMO_ATTR_DECEL);
504  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_SECURITY);
505  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_ESTIMATION);
506  allowedCFModelAttrs[SUMO_TAG_CF_WIEDEMANN] = wiedemannParams;
507  }
508  return allowedCFModelAttrs;
509 }
510 
511 
514  const std::string& id) {
515  SUMOVehicleClass vclass = SVC_UNKNOWN;
516  try {
517  bool ok = true;
518  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_VCLASS, id.c_str(), ok, "");
519  if (vclassS == "") {
520  return vclass;
521  }
522  return getVehicleClassID(vclassS);
523  } catch (...) {
524  WRITE_ERROR("The class for " + attrs.getObjectType() + " '" + id + "' is not known.");
525  }
526  return vclass;
527 }
528 
529 
532  try {
533  bool ok = true;
534  std::string eClassS = attrs.getOpt<std::string>(SUMO_ATTR_EMISSIONCLASS, id.c_str(), ok, "");
535  return getVehicleEmissionTypeID(eClassS);
536  } catch (...) {
537  WRITE_ERROR("The emission class for " + attrs.getObjectType() + " '" + id + "' is not known.");
538  return SVE_UNKNOWN;
539  }
540 }
541 
542 
544 SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id) {
545  bool ok = true;
546  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_GUISHAPE, id.c_str(), ok, "");
547  if (SumoVehicleShapeStrings.hasString(vclassS)) {
548  return SumoVehicleShapeStrings.get(vclassS);
549  } else {
550  WRITE_ERROR("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
551  return SVS_UNKNOWN;
552  }
553 }
554 
555 /****************************************************************************/
556 
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
const int VTYPEPARS_MAXSPEED_SET
SUMOEmissionClass getVehicleEmissionTypeID(const std::string &name)
Returns the class id of the emission class given by its name.
const int VTYPEPARS_MINGAP_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
RGBColor color
The vehicle's color.
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, bool optionalID=false, bool skipDepart=false)
Parses a vehicle's attributes.
const int VEHPARS_FORCE_REROUTE
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
Definition: FileHelpers.cpp:85
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, SUMOReal &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::string vtypeid
The vehicle's type id.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static void parseVTypeEmbedded(SUMOVTypeParameter &into, int element, const SUMOSAXAttributes &attrs, bool fromVType=false)
Parses an element embedded in vtype definition.
virtual std::string getName(int attr) const =0
Converts the given attribute id into a man readable string.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
SUMOVehicleShape shape
This class' shape.
Structure representing possible vehicle parameter.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
SUMOReal speedDev
The standard deviation for speed variations.
unsigned int personCapacity
The vehicle's capacity (persons)
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
SUMOReal length
The physical vehicle length.
SUMOVehicleClass vehicleClass
The vehicle's class.
SUMOReal arrivalPos
(optional) The position the vehicle shall arrive on
const int VEHPARS_ARRIVALLANE_SET
unsigned int personNumber
The number of persons in the vehicle.
SUMOReal width
This class' width.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
const int VTYPEPARS_OSGFILE_SET
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
const int VTYPEPARS_PROBABILITY_SET
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:196
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
const std::string & getObjectType() const
return the objecttype to which these attributes belong
std::string toTaz
The vehicle's destination zone (district)
const int VEHPARS_ARRIVALSPEED_SET
SUMOEmissionClass
Definition of vehicle emission classes.
static const CFAttrMap & getAllowedCFModelAttrs()
SUMOReal speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
#define max(a, b)
Definition: polyfonts.c:61
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SVS_UNKNOWN)
std::string routeid
The vehicle's route id.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Encapsulated SAX-Attributes.
static SUMOVehicleParameter * parseFlowAttributes(const SUMOSAXAttributes &attrs, const SUMOTime beginDefault, const SUMOTime endDefault)
Parses a flow's attributes.
const int VEHPARS_DEPARTSPEED_SET
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
std::string osgFile
3D model file for this class
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, SUMOVehicleParameter *ret, std::string element)
Parses attributes common to vehicles and flows.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:198
not defined
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
std::string imgFile
Image file for this class.
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
const int VEHPARS_ROUTE_SET
std::string fromTaz
The vehicle's origin zone (district)
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
const int VTYPEPARS_SPEEDDEVIATION_SET
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:52
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
const int VEHPARS_COLOR_SET
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::string line
The vehicle's line (mainly for public transport)
const int VTYPEPARS_SPEEDFACTOR_SET
const int VEHPARS_LINE_SET
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, SUMOReal &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:201
SUMOReal maxSpeed
The vehicle type's maximum speed [m/s].
const int VEHPARS_ARRIVALPOS_SET
int setParameter
Information for the router which parameter were set.
static const RGBColor YELLOW
Definition: RGBColor.h:191
Structure representing possible vehicle parameter.
SUMOReal impatience
The vehicle's impatience (willingness to obstruct others)
#define SUMOTime_MAX
Definition: SUMOTime.h:44
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
const int VEHPARS_PERIODFREQ_SET
int setParameter
Information for the router which parameter were set.
SUMOReal defaultProbability
The probability when being added to a distribution without an explicit probability.
const int VTYPEPARS_IMGFILE_SET
RGBColor color
The color.
const int VEHPARS_DEPARTLANE_SET
std::string id
The vehicle type's id.
SUMOReal departPos
(optional) The position the vehicle shall depart from
const int VTYPEPARS_LCM_SET
const int VEHPARS_TAZ_SET
T get(const std::string &str) const
const int VEHPARS_VTYPE_SET
const int VTYPEPARS_HEIGHT_SET
static SUMOEmissionClass parseEmissionClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle emission class.
#define SUMOReal
Definition: config.h:215
const int VTYPEPARS_WIDTH_SET
#define DELTA_T
Definition: SUMOTime.h:50
static StringBijection< int > Tags
The names of SUMO-XML elements for use in netbuild.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
const int VEHPARS_DEPARTPOS_SET
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
const int VEHPARS_PERSON_NUMBER_SET
LaneChangeModel lcModel
The lane-change model to use.
SUMOReal height
This class' height.
const int VTYPEPARS_LENGTH_SET
const int VTYPEPARS_VEHICLECLASS_SET
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const std::string &file)
Starts to parse a vehicle type.
A color information.
const int VTYPEPARS_EMISSIONCLASS_SET
const int VTYPEPARS_COLOR_SET
const int VTYPEPARS_SHAPE_SET
const int VEHPARS_PERSON_CAPACITY_SET
static StringBijection< LaneChangeModel > LaneChangeModels
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
SUMOEmissionClass emissionClass
The emission class of this vehicle.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string id
The vehicle's id.
const int VTYPEPARS_IMPATIENCE_SET
SUMOReal minGap
This class' free space in front of the vehicle itself.
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.