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-2013 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  throw ProcessError("The attributes '" + attrs.getName(SUMO_ATTR_PERIOD) +
176  "' and '" + attrs.getName(SUMO_ATTR_REPNUMBER) +
177  "' have to be given both in the definition of '" + id + "'.");
178  }
180  ret->id = id;
181  try {
182  parseCommonAttributes(attrs, ret, "vehicle");
183  } catch (ProcessError&) {
184  delete ret;
185  throw;
186  }
187  if (!skipDepart) {
188  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPART, 0, ok);
189  if (helper == "triggered") {
191  } else {
193  ret->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_DEPART, id.c_str(), ok);
194  if (ok && ret->depart < 0) {
195  errorMsg = "Negative departure time in the definition of '" + id + "'.";
196  ok = false;
197  }
198  }
199  }
200  // parse repetition information
201  if (attrs.hasAttribute(SUMO_ATTR_PERIOD)) {
202  WRITE_WARNING("period and repno are deprecated in vehicle '" + id + "', use flows instead.");
204 #ifdef HAVE_SUBSECOND_TIMESTEPS
205  ret->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok);
206 #else
207  ret->repetitionOffset = attrs.get<SUMOReal>(SUMO_ATTR_PERIOD, id.c_str(), ok);
208 #endif
209  }
210  if (attrs.hasAttribute(SUMO_ATTR_REPNUMBER)) {
212  ret->repetitionNumber = attrs.get<int>(SUMO_ATTR_REPNUMBER, id.c_str(), ok);
213  }
214 
215  if (!ok) {
216  delete ret;
217  throw ProcessError(errorMsg);
218  }
219  return ret;
220 }
221 
222 
223 void
225  SUMOVehicleParameter* ret, std::string element) {
226  //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
227  bool ok = true;
228  // parse route information
229  if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
230  ret->setParameter |= VEHPARS_ROUTE_SET; // !!! needed?
231  ret->routeid = attrs.get<std::string>(SUMO_ATTR_ROUTE, 0, ok);
232  }
233  // parse type information
234  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
235  ret->setParameter |= VEHPARS_VTYPE_SET; // !!! needed?
236  ret->vtypeid = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
237  }
238  // parse line information
239  if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
240  ret->setParameter |= VEHPARS_LINE_SET; // !!! needed?
241  ret->line = attrs.get<std::string>(SUMO_ATTR_LINE, 0, ok);
242  }
243  // parse zone information
246  ret->fromTaz = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, 0, ok);
247  ret->toTaz = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, 0, ok);
248  }
249  // parse reroute information
250  if (attrs.getOpt<bool>(SUMO_ATTR_REROUTE, 0, ok, false)) {
252  }
253 
254  std::string error;
255  // parse depart lane information
256  if (attrs.hasAttribute(SUMO_ATTR_DEPARTLANE)) {
258  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTLANE, 0, ok);
259  if (!SUMOVehicleParameter::parseDepartLane(helper, element, ret->id, ret->departLane, ret->departLaneProcedure, error)) {
260  throw ProcessError(error);
261  }
262  }
263  // parse depart position information
264  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
266  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS, 0, ok);
267  if (!SUMOVehicleParameter::parseDepartPos(helper, element, ret->id, ret->departPos, ret->departPosProcedure, error)) {
268  throw ProcessError(error);
269  }
270  }
271  // parse depart speed information
272  if (attrs.hasAttribute(SUMO_ATTR_DEPARTSPEED)) {
274  std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPARTSPEED, 0, ok);
275  if (!SUMOVehicleParameter::parseDepartSpeed(helper, element, ret->id, ret->departSpeed, ret->departSpeedProcedure, error)) {
276  throw ProcessError(error);
277  }
278  }
279 
280  // parse arrival lane information
281  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALLANE)) {
283  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALLANE, 0, ok);
284  if (!SUMOVehicleParameter::parseArrivalLane(helper, element, ret->id, ret->arrivalLane, ret->arrivalLaneProcedure, error)) {
285  throw ProcessError(error);
286  }
287  }
288  // parse arrival position information
289  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
291  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, 0, ok);
292  if (!SUMOVehicleParameter::parseArrivalPos(helper, element, ret->id, ret->arrivalPos, ret->arrivalPosProcedure, error)) {
293  throw ProcessError(error);
294  }
295  }
296  // parse arrival speed information
299  std::string helper = attrs.get<std::string>(SUMO_ATTR_ARRIVALSPEED, 0, ok);
300  if (!SUMOVehicleParameter::parseArrivalSpeed(helper, element, ret->id, ret->arrivalSpeed, ret->arrivalSpeedProcedure, error)) {
301  throw ProcessError(error);
302  }
303  }
304 
305  // parse color
306  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
308  ret->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, ret->id.c_str(), ok);
309  } else {
311  }
312  // parse person number
315  ret->personNumber = attrs.get<int>(SUMO_ATTR_PERSON_NUMBER, 0, ok);
316  }
317  // parse person capacity
320  ret->personCapacity = attrs.get<int>(SUMO_ATTR_PERSON_CAPACITY, 0, ok);
321  }
322 }
323 
324 
326 SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const std::string& file) {
327  SUMOVTypeParameter* vtype = new SUMOVTypeParameter();
328  bool ok = true;
329  vtype->id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
330  if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
331  vtype->length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, vtype->id.c_str(), ok);
333  }
334  if (attrs.hasAttribute(SUMO_ATTR_MINGAP)) {
335  vtype->minGap = attrs.get<SUMOReal>(SUMO_ATTR_MINGAP, vtype->id.c_str(), ok);
337  }
338  if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
339  vtype->maxSpeed = attrs.get<SUMOReal>(SUMO_ATTR_MAXSPEED, vtype->id.c_str(), ok);
341  }
342  if (attrs.hasAttribute(SUMO_ATTR_SPEEDFACTOR)) {
343  vtype->speedFactor = attrs.get<SUMOReal>(SUMO_ATTR_SPEEDFACTOR, vtype->id.c_str(), ok);
345  }
346  if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
347  vtype->speedDev = attrs.get<SUMOReal>(SUMO_ATTR_SPEEDDEV, vtype->id.c_str(), ok);
349  }
351  vtype->emissionClass = parseEmissionClass(attrs, vtype->id);
353  }
354  if (attrs.hasAttribute(SUMO_ATTR_IMPATIENCE)) {
355  if (attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vtype->id.c_str(), ok) == "off") {
357  } else {
358  vtype->impatience = attrs.get<SUMOReal>(SUMO_ATTR_IMPATIENCE, vtype->id.c_str(), ok);
359  }
361  }
362  if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
363  vtype->vehicleClass = parseVehicleClass(attrs, vtype->id);
365  }
366  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
367  vtype->width = attrs.get<SUMOReal>(SUMO_ATTR_WIDTH, vtype->id.c_str(), ok);
369  }
370  if (attrs.hasAttribute(SUMO_ATTR_HEIGHT)) {
371  vtype->height = attrs.get<SUMOReal>(SUMO_ATTR_HEIGHT, vtype->id.c_str(), ok);
373  }
374  if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
375  vtype->shape = parseGuiShape(attrs, vtype->id);
377  }
378  if (attrs.hasAttribute(SUMO_ATTR_OSGFILE)) {
379  vtype->osgFile = attrs.get<std::string>(SUMO_ATTR_OSGFILE, vtype->id.c_str(), ok);
381  }
382  if (attrs.hasAttribute(SUMO_ATTR_IMGFILE)) {
383  vtype->imgFile = attrs.get<std::string>(SUMO_ATTR_IMGFILE, vtype->id.c_str(), ok);
384  if (vtype->imgFile != "" && !FileHelpers::isAbsolute(vtype->imgFile)) {
386  }
388  }
389  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
390  vtype->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, vtype->id.c_str(), ok);
392  } else {
393  vtype->color = RGBColor::YELLOW;
394  }
395  if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
396  vtype->defaultProbability = attrs.get<SUMOReal>(SUMO_ATTR_PROB, vtype->id.c_str(), ok);
398  }
399  try {
400  parseVTypeEmbedded(*vtype, SUMO_TAG_CF_KRAUSS, attrs, true);
401  } catch (ProcessError&) {
402  throw;
403  }
404  if (!ok) {
405  delete vtype;
406  throw ProcessError();
407  }
408  return vtype;
409 }
410 
411 
412 void
414  int element, const SUMOSAXAttributes& attrs,
415  bool fromVType) {
416  const CFAttrMap& allowedAttrs = getAllowedCFModelAttrs();
417  CFAttrMap::const_iterator cf_it;
418  for (cf_it = allowedAttrs.begin(); cf_it != allowedAttrs.end(); cf_it++) {
419  if (cf_it->first == element) {
420  break;
421  }
422  }
423  if (cf_it == allowedAttrs.end()) {
424  if (SUMOXMLDefinitions::Tags.has(element)) {
425  WRITE_ERROR("Unknown cfmodel " + toString((SumoXMLTag)element) + " when parsing vtype '" + into.id + "'");
426  } else {
427  WRITE_ERROR("Unknown cfmodel when parsing vtype '" + into.id + "'");
428  }
429  throw ProcessError();
430  return;
431  }
432  if (!fromVType) {
433  into.cfModel = cf_it->first;
434  }
435  bool ok = true;
436  for (std::set<SumoXMLAttr>::const_iterator it = cf_it->second.begin(); it != cf_it->second.end(); it++) {
437  if (attrs.hasAttribute(*it)) {
438  into.cfParameter[*it] = attrs.get<SUMOReal>(*it, into.id.c_str(), ok);
439  if (*it == SUMO_ATTR_TAU && TIME2STEPS(into.cfParameter[*it]) < DELTA_T) {
440  WRITE_WARNING("Value of tau=" + toString(into.cfParameter[*it])
441  + " in car following model '" + toString(into.cfModel) + "' lower than simulation step size may cause collisions");
442  }
443  }
444  }
445  if (!ok) {
446  throw ProcessError();
447  }
448 }
449 
450 
453  // init on first use
454  if (allowedCFModelAttrs.size() == 0) {
455  std::set<SumoXMLAttr> krausParams;
456  krausParams.insert(SUMO_ATTR_ACCEL);
457  krausParams.insert(SUMO_ATTR_DECEL);
458  krausParams.insert(SUMO_ATTR_SIGMA);
459  krausParams.insert(SUMO_ATTR_TAU);
463 
464  std::set<SumoXMLAttr> smartSKParams;
465  smartSKParams.insert(SUMO_ATTR_ACCEL);
466  smartSKParams.insert(SUMO_ATTR_DECEL);
467  smartSKParams.insert(SUMO_ATTR_SIGMA);
468  smartSKParams.insert(SUMO_ATTR_TAU);
469  smartSKParams.insert(SUMO_ATTR_TMP1);
470  smartSKParams.insert(SUMO_ATTR_TMP2);
471  smartSKParams.insert(SUMO_ATTR_TMP3);
472  smartSKParams.insert(SUMO_ATTR_TMP4);
473  smartSKParams.insert(SUMO_ATTR_TMP5);
474  allowedCFModelAttrs[SUMO_TAG_CF_SMART_SK] = smartSKParams;
475 
476  std::set<SumoXMLAttr> daniel1Params;
477  daniel1Params.insert(SUMO_ATTR_ACCEL);
478  daniel1Params.insert(SUMO_ATTR_DECEL);
479  daniel1Params.insert(SUMO_ATTR_SIGMA);
480  daniel1Params.insert(SUMO_ATTR_TAU);
481  daniel1Params.insert(SUMO_ATTR_TMP1);
482  daniel1Params.insert(SUMO_ATTR_TMP2);
483  daniel1Params.insert(SUMO_ATTR_TMP3);
484  daniel1Params.insert(SUMO_ATTR_TMP4);
485  daniel1Params.insert(SUMO_ATTR_TMP5);
486  allowedCFModelAttrs[SUMO_TAG_CF_DANIEL1] = daniel1Params;
487 
488  std::set<SumoXMLAttr> pwagParams;
489  pwagParams.insert(SUMO_ATTR_ACCEL);
490  pwagParams.insert(SUMO_ATTR_DECEL);
491  pwagParams.insert(SUMO_ATTR_SIGMA);
492  pwagParams.insert(SUMO_ATTR_TAU);
493  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_TAULAST);
494  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_APPROB);
496 
497  std::set<SumoXMLAttr> idmParams;
498  idmParams.insert(SUMO_ATTR_ACCEL);
499  idmParams.insert(SUMO_ATTR_DECEL);
500  idmParams.insert(SUMO_ATTR_TAU);
501  idmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
502  idmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
504 
505  std::set<SumoXMLAttr> idmmParams;
506  idmmParams.insert(SUMO_ATTR_ACCEL);
507  idmmParams.insert(SUMO_ATTR_DECEL);
508  idmmParams.insert(SUMO_ATTR_TAU);
509  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_FACTOR);
510  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_TIME);
511  idmmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
513 
514  std::set<SumoXMLAttr> bkernerParams;
515  bkernerParams.insert(SUMO_ATTR_ACCEL);
516  bkernerParams.insert(SUMO_ATTR_DECEL);
517  bkernerParams.insert(SUMO_ATTR_TAU);
518  bkernerParams.insert(SUMO_ATTR_K);
519  bkernerParams.insert(SUMO_ATTR_CF_KERNER_PHI);
520  allowedCFModelAttrs[SUMO_TAG_CF_BKERNER] = bkernerParams;
521 
522  std::set<SumoXMLAttr> wiedemannParams;
523  wiedemannParams.insert(SUMO_ATTR_ACCEL);
524  wiedemannParams.insert(SUMO_ATTR_DECEL);
525  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_SECURITY);
526  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_ESTIMATION);
527  allowedCFModelAttrs[SUMO_TAG_CF_WIEDEMANN] = wiedemannParams;
528  }
529  return allowedCFModelAttrs;
530 }
531 
532 
535  const std::string& id) {
536  SUMOVehicleClass vclass = SVC_UNKNOWN;
537  try {
538  bool ok = true;
539  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_VCLASS, id.c_str(), ok, "");
540  if (vclassS == "") {
541  return vclass;
542  }
543  return getVehicleClassID(vclassS);
544  } catch (...) {
545  WRITE_ERROR("The class for " + attrs.getObjectType() + " '" + id + "' is not known.");
546  }
547  return vclass;
548 }
549 
550 
553  try {
554  bool ok = true;
555  std::string eClassS = attrs.getOpt<std::string>(SUMO_ATTR_EMISSIONCLASS, id.c_str(), ok, "");
556  return getVehicleEmissionTypeID(eClassS);
557  } catch (...) {
558  WRITE_ERROR("The emission class for " + attrs.getObjectType() + " '" + id + "' is not known.");
559  return SVE_UNKNOWN;
560  }
561 }
562 
563 
565 SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id) {
566  bool ok = true;
567  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_GUISHAPE, id.c_str(), ok, "");
568  if (SumoVehicleShapeStrings.hasString(vclassS)) {
569  return SumoVehicleShapeStrings.get(vclassS);
570  } else {
571  WRITE_ERROR("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
572  return SVS_UNKNOWN;
573  }
574 }
575 
576 
577 void
579  stop.setParameter = 0;
580  if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
581  stop.setParameter |= STOP_END_SET;
582  }
583  if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
585  }
586  if (attrs.hasAttribute(SUMO_ATTR_TRIGGERED)) {
588  }
589  if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
591  }
592  if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
594  }
595  // don't like this (dkrajzew)
596 }
597 
598 /****************************************************************************/
599 
The departure is person triggered.
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&#39;s color.
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, bool optionalID=false, bool skipDepart=false)
Parses a vehicle&#39;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
The time is given.
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&#39;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&#39; 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&#39;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&#39;s class.
const int VEHPARS_PERIODNUM_SET
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&#39; width.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;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&#39;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...
const int STOP_START_SET
#define max(a, b)
Definition: polyfonts.c:61
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SVS_UNKNOWN)
std::string routeid
The vehicle&#39;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&#39;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&#39;s departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
const int VEHPARS_ROUTE_SET
std::string fromTaz
The vehicle&#39;s origin zone (district)
const int STOP_EXPECTED_SET
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:51
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&#39;s line (mainly for public transport)
const int VTYPEPARS_SPEEDFACTOR_SET
const int STOP_END_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&#39;s maximum speed [m/s].
const int VEHPARS_ARRIVALPOS_SET
const int STOP_PARKING_SET
int setParameter
Information for the router which parameter were set.
static const RGBColor YELLOW
Definition: RGBColor.h:191
const int STOP_TRIGGER_SET
Structure representing possible vehicle parameter.
SUMOReal impatience
The vehicle&#39;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
static void parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs)
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
Definition of vehicle stop (position and duration)
RGBColor color
The color.
const int VEHPARS_DEPARTLANE_SET
int setParameter
Information for the output which parameter were set.
std::string id
The vehicle type&#39;s id.
SUMOReal departPos
(optional) The position the vehicle shall depart from
const int VEHPARS_TAZ_SET
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:221
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
SUMOReal height
This class&#39; 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
SUMOEmissionClass emissionClass
The emission class of this vehicle.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string id
The vehicle&#39;s id.
const int VTYPEPARS_IMPATIENCE_SET
SUMOReal minGap
This class&#39; 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.