Eclipse SUMO - Simulation of Urban MObility
SUMOVehicleParserHelper.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2008-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
22 // Helper methods for parsing vehicle attributes
23 /****************************************************************************/
24 #include <config.h>
25 
31 #include <utils/common/ToString.h>
38 
40 
41 
42 // ===========================================================================
43 // static members
44 // ===========================================================================
45 
48 std::set<SumoXMLAttr> SUMOVehicleParserHelper::allowedJMAttrs;
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 
56 SUMOVehicleParserHelper::parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes& attrs, const bool hardFail, const bool needID,
57  const SUMOTime beginDefault, const SUMOTime endDefault) {
58  // first parse ID
59  const std::string id = attrs.hasAttribute(SUMO_ATTR_ID) ? parseID(attrs, tag) : "";
60  // check if ID is valid
61  if (!needID || !id.empty()) {
62  if (needID && !SUMOXMLDefinitions::isValidVehicleID(id)) {
63  return handleVehicleError(hardFail, nullptr, "Invalid flow id '" + id + "'.");
64  }
65  // declare flags
66  const bool hasPeriod = attrs.hasAttribute(SUMO_ATTR_PERIOD);
67  const bool hasVPH = attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR);
68  const bool hasPPH = attrs.hasAttribute(SUMO_ATTR_PERSONSPERHOUR);
69  const bool hasCPH = attrs.hasAttribute(SUMO_ATTR_CONTAINERSPERHOUR);
70  const bool hasPH = attrs.hasAttribute(SUMO_ATTR_PERHOUR);
71  const bool hasXPH = hasVPH || hasPPH || hasCPH || hasPH;
72  const bool hasProb = attrs.hasAttribute(SUMO_ATTR_PROB);
73  const bool hasNumber = attrs.hasAttribute(SUMO_ATTR_NUMBER);
74  const bool hasBegin = attrs.hasAttribute(SUMO_ATTR_BEGIN);
75  const bool hasEnd = attrs.hasAttribute(SUMO_ATTR_END);
77  if (hasVPH) {
78  PERHOUR = SUMO_ATTR_VEHSPERHOUR;
79  }
80  if (hasPPH) {
81  PERHOUR = SUMO_ATTR_PERSONSPERHOUR;
82  }
83  if (hasCPH) {
85  }
86  if (hasXPH && !(hasVPH ^ hasPPH ^ hasCPH ^ hasPH)) {
87  return handleVehicleError(hardFail, nullptr,
88  "At most one of '" + attrs.getName(SUMO_ATTR_PERHOUR) +
89  "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
90  "', '" + attrs.getName(SUMO_ATTR_PERSONSPERHOUR) +
91  "' and '" + attrs.getName(SUMO_ATTR_CONTAINERSPERHOUR) +
92  "' has to be given in the definition of " + toString(tag) + " '" + id + "'.");
93  }
94  if (hasPeriod && hasXPH) {
95  return handleVehicleError(hardFail, nullptr,
96  "At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
97  "' and '" + attrs.getName(PERHOUR) +
98  "' has to be given in the definition of "
99  + toString(tag) + " '" + id + "'.");
100  }
101  if (hasPeriod && hasProb) {
102  return handleVehicleError(hardFail, nullptr,
103  "At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
104  "' and '" + attrs.getName(SUMO_ATTR_PROB) +
105  "' has to be given in the definition of "
106  + toString(tag) + " '" + id + "'.");
107  }
108  if (hasProb && hasXPH) {
109  return handleVehicleError(hardFail, nullptr,
110  "At most one of '" + attrs.getName(SUMO_ATTR_PROB) +
111  "' and '" + attrs.getName(PERHOUR) +
112  "' has to be given in the definition of "
113  + toString(tag) + " '" + id + "'.");
114  }
115  if (hasPeriod || hasXPH || hasProb) {
116  if (hasEnd && hasNumber) {
117  return handleVehicleError(hardFail, nullptr,
118  "If '" + attrs.getName(SUMO_ATTR_PERIOD) +
119  "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
120  "', '" + attrs.getName(SUMO_ATTR_PERSONSPERHOUR) +
121  "', '" + attrs.getName(SUMO_ATTR_CONTAINERSPERHOUR) +
122  "', '" + attrs.getName(SUMO_ATTR_PERHOUR) +
123  "' or '" + attrs.getName(SUMO_ATTR_PROB) +
124  "' are given at most one of '" + attrs.getName(SUMO_ATTR_END) +
125  "' and '" + attrs.getName(SUMO_ATTR_NUMBER) +
126  "' are allowed in "
127  + toString(tag) + " '" + id + "'.");
128  }
129  } else {
130  if (!hasNumber) {
131  return handleVehicleError(hardFail, nullptr,
132  "At least one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
133  "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
134  "', '" + attrs.getName(SUMO_ATTR_PERSONSPERHOUR) +
135  "', '" + attrs.getName(SUMO_ATTR_CONTAINERSPERHOUR) +
136  "', '" + attrs.getName(SUMO_ATTR_PERHOUR) +
137  "', '" + attrs.getName(SUMO_ATTR_PROB) +
138  "', and '" + attrs.getName(SUMO_ATTR_NUMBER) +
139  "' is needed in "
140  + toString(tag) + " '" + id + "'.");
141  }
142  }
143  // declare flow
144  SUMOVehicleParameter* flowParameter = new SUMOVehicleParameter();
145  // set tag
146  flowParameter->tag = tag;
147  // set id
148  flowParameter->id = id;
149  if (tag == SUMO_TAG_PERSONFLOW) {
150  flowParameter->vtypeid = DEFAULT_PEDTYPE_ID;
151  }
152  if (tag == SUMO_TAG_CONTAINERFLOW) {
153  flowParameter->vtypeid = DEFAULT_CONTAINERTYPE_ID;
154  }
155  // parse common vehicle attributes
156  try {
157  parseCommonAttributes(attrs, flowParameter, tag);
158  } catch (ProcessError& attributeError) {
159  // check if continue handling another vehicles or stop handling
160  if (hardFail) {
161  throw ProcessError(attributeError.what());
162  } else {
163  return nullptr;
164  }
165  }
166  // parse period
167  if (hasPeriod) {
168  bool ok = true;
169  flowParameter->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok);
170  if (!ok) {
171  return handleVehicleError(hardFail, flowParameter);
172  } else {
173  flowParameter->parametersSet |= VEHPARS_PERIOD_SET;
174  }
175  }
176  // parse vehicle/person/container/etc per hour
177  if (hasXPH) {
178  bool ok = true;
179  const double vph = attrs.get<double>(PERHOUR, id.c_str(), ok);
180  if (!ok) {
181  return handleVehicleError(hardFail, flowParameter);
182  } else if (vph <= 0) {
183  return handleVehicleError(hardFail, flowParameter, "Invalid repetition rate in the definition of " + toString(tag) + " '" + id + "'.");
184  } else {
185  if (vph != 0) {
186  flowParameter->repetitionOffset = TIME2STEPS(3600. / vph);
187  }
188  flowParameter->parametersSet |= VEHPARS_VPH_SET;
189  }
190  }
191  // parse probability
192  if (hasProb) {
193  bool ok = true;
194  flowParameter->repetitionProbability = attrs.get<double>(SUMO_ATTR_PROB, id.c_str(), ok);
195  if (!ok) {
196  return handleVehicleError(hardFail, flowParameter);
197  } else if (flowParameter->repetitionProbability <= 0 || flowParameter->repetitionProbability > 1) {
198  return handleVehicleError(hardFail, flowParameter, "Invalid repetition probability in the definition of " + toString(tag) + " '" + id + "'.");
199  } else {
200  flowParameter->parametersSet |= VEHPARS_PROB_SET;
201  }
202  }
203  // set default begin
204  flowParameter->depart = beginDefault;
205  // parse begin
206  if (hasBegin) {
207  // first get begin
208  bool ok = true;
209  const std::string begin = attrs.get<std::string>(SUMO_ATTR_BEGIN, id.c_str(), ok);
210  if (!ok) {
211  return handleVehicleError(hardFail, flowParameter);
212  } else {
213  // parse begin
214  std::string errorMsg;
215  if (!SUMOVehicleParameter::parseDepart(begin, toString(tag), id, flowParameter->depart, flowParameter->departProcedure, errorMsg, "begin")) {
216  return handleVehicleError(hardFail, flowParameter, errorMsg);
217  }
218  }
219  }
220  if (flowParameter->depart < 0) {
221  return handleVehicleError(hardFail, flowParameter, "Negative begin time in the definition of " + toString(tag) + " '" + id + "'.");
222  }
223  // set default end
224  flowParameter->repetitionEnd = endDefault;
225  if (flowParameter->repetitionEnd < 0) {
226  flowParameter->repetitionEnd = SUMOTime_MAX;
227  }
228  // parse end
229  if (hasEnd) {
230  bool ok = true;
231  flowParameter->repetitionEnd = attrs.getSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok);
232  if (!ok) {
233  return handleVehicleError(hardFail, flowParameter);
234  } else {
235  flowParameter->parametersSet |= VEHPARS_END_SET;
236  }
237  } else if (flowParameter->departProcedure == DEPART_TRIGGERED) {
238  if (!hasNumber) {
239  return handleVehicleError(hardFail, flowParameter, toString(tag) + " '" + id + "' with triggered begin must define 'number'.");
240  } else {
241  flowParameter->repetitionEnd = flowParameter->depart;
242  }
243  } else if ((endDefault == SUMOTime_MAX || endDefault < 0) && (!hasNumber || (!hasProb && !hasPeriod && !hasXPH))) {
244  WRITE_WARNING("Undefined end for " + toString(tag) + " '" + id + "', defaulting to 24hour duration.");
245  flowParameter->repetitionEnd = flowParameter->depart + TIME2STEPS(24 * 3600);
246  }
247  if (flowParameter->repetitionEnd < flowParameter->depart) {
248  std::string flow = toString(tag);
249  flow[0] = (char)::toupper((char)flow[0]);
250  return handleVehicleError(hardFail, flowParameter, flow + " '" + id + "' ends before its begin time.");
251  }
252  // parse number
253  if (hasNumber) {
254  bool ok = true;
255  flowParameter->repetitionNumber = attrs.get<int>(SUMO_ATTR_NUMBER, id.c_str(), ok);
256  if (!ok) {
257  return handleVehicleError(hardFail, flowParameter);
258  } else {
259  flowParameter->parametersSet |= VEHPARS_NUMBER_SET;
260  if (flowParameter->repetitionNumber == 0) {
261  std::string flow = toString(tag);
262  flow[0] = (char)::toupper((char)flow[0]);
263  WRITE_WARNING(flow + " '" + id + "' has no instances; will skip it.");
264  } else {
265  if (flowParameter->repetitionNumber < 0) {
266  return handleVehicleError(hardFail, flowParameter, "Negative repetition number in the definition of " + toString(tag) + " '" + id + "'.");
267  }
268  if (flowParameter->repetitionOffset < 0) {
269  flowParameter->repetitionOffset = (flowParameter->repetitionEnd - flowParameter->depart) / flowParameter->repetitionNumber;
270  }
271  }
272  flowParameter->repetitionEnd = flowParameter->depart + flowParameter->repetitionNumber * flowParameter->repetitionOffset;
273  }
274  } else {
275  // interpret repetitionNumber
276  if (flowParameter->repetitionProbability > 0) {
277  flowParameter->repetitionNumber = std::numeric_limits<int>::max();
278  } else {
279  if (flowParameter->repetitionOffset <= 0) {
280  return handleVehicleError(hardFail, flowParameter, "Invalid repetition rate in the definition of " + toString(tag) + " '" + id + "'.");
281  }
282  if (flowParameter->repetitionEnd == SUMOTime_MAX) {
283  flowParameter->repetitionNumber = std::numeric_limits<int>::max();
284  } else {
285  const double repLength = (double)(flowParameter->repetitionEnd - flowParameter->depart);
286  flowParameter->repetitionNumber = (int)ceil(repLength / flowParameter->repetitionOffset);
287  }
288  }
289  }
290  // all ok, then return flow parameter
291  return flowParameter;
292  } else {
293  return handleVehicleError(hardFail, nullptr, toString(tag) + " cannot be created");
294  }
295 }
296 
297 
299 SUMOVehicleParserHelper::parseVehicleAttributes(int element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID, const bool skipDepart) {
300  // declare vehicle ID
301  std::string id;
302  // for certain vehicles, ID can be optional
303  if (optionalID) {
304  bool ok = true;
305  id = attrs.getOpt<std::string>(SUMO_ATTR_ID, nullptr, ok, "");
306  if (!ok) {
307  return handleVehicleError(hardFail, nullptr);
308  }
309  } else {
310  // parse ID
311  id = parseID(attrs, (SumoXMLTag)element);
312  }
313  // only continue if id is valid, or if is optional
314  if (optionalID || !id.empty()) {
315  // declare vehicle parameter
316  SUMOVehicleParameter* vehicleParameter = new SUMOVehicleParameter();
317  vehicleParameter->id = id;
318  if (element == SUMO_TAG_PERSON) {
319  vehicleParameter->vtypeid = DEFAULT_PEDTYPE_ID;
320  } else if (element == SUMO_TAG_CONTAINER) {
321  vehicleParameter->vtypeid = DEFAULT_CONTAINERTYPE_ID;
322  }
323  // parse common attributes
324  try {
325  parseCommonAttributes(attrs, vehicleParameter, (SumoXMLTag)element);
326  } catch (ProcessError& attributeError) {
327  // check if continue handling another vehicles or stop handling
328  if (hardFail) {
329  throw ProcessError(attributeError.what());
330  } else {
331  return nullptr;
332  }
333  }
334  // check depart
335  if (!skipDepart) {
336  bool ok = true;
337  const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPART, vehicleParameter->id.c_str(), ok);
338  if (!ok) {
339  return handleVehicleError(hardFail, vehicleParameter);
340  }
341  // now parse depart
342  std::string departErrorMsg;
343  if (!SUMOVehicleParameter::parseDepart(helper, "vehicle", vehicleParameter->id, vehicleParameter->depart, vehicleParameter->departProcedure, departErrorMsg)) {
344  return handleVehicleError(hardFail, vehicleParameter, departErrorMsg);
345  }
346  }
347  // set tag
348  vehicleParameter->tag = (SumoXMLTag)element;
349  // all ok, then return vehicleParameter
350  return vehicleParameter;
351  } else {
352  return handleVehicleError(hardFail, nullptr, toString((SumoXMLTag)element) + " cannot be created");
353  }
354 }
355 
356 
357 std::string
359  bool ok = true;
360  std::string id;
361  // first check if attrs contain an ID
362  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
363  id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
365  return id;
366  } else if (id.empty()) {
367  // add extra information for empty IDs
368  WRITE_ERROR("Invalid " + toString(element) + " id '" + id + "'.");
369  } else {
370  WRITE_ERROR("Invalid " + toString(element) + " id '" + id + "'. Contains invalid characters.");
371  }
372  } else {
373  WRITE_ERROR("Attribute '" + toString(SUMO_ATTR_ID) + "' is missing in definition of " + toString(element));
374  }
375  // return empty (invalid) ID
376  return "";
377 }
378 
379 
380 void
382  const std::string element = toString(tag);
383  //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
384  // parse route information
385  if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
386  bool ok = true;
387  ret->routeid = attrs.get<std::string>(SUMO_ATTR_ROUTE, ret->id.c_str(), ok);
388  if (ok) {
389  ret->parametersSet |= VEHPARS_ROUTE_SET; // !!! needed?
390  } else {
391  handleVehicleError(true, ret);
392  }
393  }
394  // parse type information
395  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
396  bool ok = true;
397  ret->vtypeid = attrs.get<std::string>(SUMO_ATTR_TYPE, ret->id.c_str(), ok);
398  if (ok) {
399  ret->parametersSet |= VEHPARS_VTYPE_SET; // !!! needed?
400  } else {
401  handleVehicleError(true, ret);
402  }
403  }
404  // parse line information
405  if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
406  bool ok = true;
407  ret->line = attrs.get<std::string>(SUMO_ATTR_LINE, ret->id.c_str(), ok);
408  if (ok) {
409  ret->parametersSet |= VEHPARS_LINE_SET; // !!! needed?
410  } else {
411  handleVehicleError(true, ret);
412  }
413  }
414  // parse zone information
415  if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ)) {
416  bool ok = true;
417  ret->fromTaz = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, ret->id.c_str(), ok);
418  if (ok) {
420  } else {
421  handleVehicleError(true, ret);
422  }
423  }
424  if (attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
425  bool ok = true;
426  ret->toTaz = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, ret->id.c_str(), ok);
427  if (ok) {
429  } else {
430  handleVehicleError(true, ret);
431  }
432  }
433  // parse reroute information
434  if (attrs.hasAttribute(SUMO_ATTR_REROUTE)) {
435  bool ok = true;
436  if (attrs.get<bool>(SUMO_ATTR_REROUTE, ret->id.c_str(), ok)) {
437  if (ok) {
439  } else {
440  handleVehicleError(true, ret);
441  }
442  }
443  }
444  // parse depart lane information
445  if (attrs.hasAttribute(SUMO_ATTR_DEPARTLANE)) {
446  bool ok = true;
447  const std::string departLaneStr = attrs.get<std::string>(SUMO_ATTR_DEPARTLANE, ret->id.c_str(), ok);
448  int lane;
450  std::string error;
451  if (SUMOVehicleParameter::parseDepartLane(departLaneStr, element, ret->id, lane, dld, error)) {
453  ret->departLane = lane;
454  ret->departLaneProcedure = dld;
455  } else {
456  handleVehicleError(true, ret, error);
457  }
458  }
459  // parse depart position information
460  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
461  bool ok = true;
462  const std::string departPosStr = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS, ret->id.c_str(), ok);
463  double pos;
465  std::string error;
466  if (SUMOVehicleParameter::parseDepartPos(departPosStr, element, ret->id, pos, dpd, error)) {
468  ret->departPos = pos;
469  ret->departPosProcedure = dpd;
470  } else {
471  handleVehicleError(true, ret, error);
472  }
473  }
474  // parse lateral depart position information
476  bool ok = true;
477  const std::string departPosLatStr = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS_LAT, ret->id.c_str(), ok);
478  double pos;
480  std::string error;
481  if (SUMOVehicleParameter::parseDepartPosLat(departPosLatStr, element, ret->id, pos, dpd, error)) {
483  ret->departPosLat = pos;
484  ret->departPosLatProcedure = dpd;
485  } else {
486  handleVehicleError(true, ret, error);
487  }
488  }
489  // parse depart speed information
490  if (attrs.hasAttribute(SUMO_ATTR_DEPARTSPEED)) {
491  bool ok = true;
492  const std::string departSpeed = attrs.get<std::string>(SUMO_ATTR_DEPARTSPEED, ret->id.c_str(), ok);
493  double speed;
495  std::string error;
496  if (SUMOVehicleParameter::parseDepartSpeed(departSpeed, element, ret->id, speed, dsd, error)) {
498  ret->departSpeed = speed;
499  ret->departSpeedProcedure = dsd;
500  } else {
501  handleVehicleError(true, ret, error);
502  }
503  }
504  // parse depart edge information
505  if (attrs.hasAttribute(SUMO_ATTR_DEPARTEDGE)) {
506  bool ok = true;
507  const std::string departEdgeStr = attrs.get<std::string>(SUMO_ATTR_DEPARTEDGE, ret->id.c_str(), ok);
508  int edgeIndex;
510  std::string error;
511  if (SUMOVehicleParameter::parseRouteIndex(departEdgeStr, element, ret->id, SUMO_ATTR_DEPARTEDGE, edgeIndex, rid, error)) {
513  ret->departEdge = edgeIndex;
514  ret->departEdgeProcedure = rid;
515  } else {
516  handleVehicleError(true, ret, error);
517  }
518  }
519  // parse arrival lane information
520  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALLANE)) {
521  bool ok = true;
522  const std::string arrivalLaneStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALLANE, ret->id.c_str(), ok);
523  int lane;
525  std::string error;
526  if (SUMOVehicleParameter::parseArrivalLane(arrivalLaneStr, element, ret->id, lane, ald, error)) {
528  ret->arrivalLane = lane;
529  ret->arrivalLaneProcedure = ald;
530  } else {
531  handleVehicleError(true, ret, error);
532  }
533  }
534  // parse arrival position information
535  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
536  bool ok = true;
537  const std::string arrivalPosStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, ret->id.c_str(), ok);
538  double pos;
540  std::string error;
541  if (SUMOVehicleParameter::parseArrivalPos(arrivalPosStr, element, ret->id, pos, apd, error)) {
543  ret->arrivalPos = pos;
544  ret->arrivalPosProcedure = apd;
545  } else {
546  handleVehicleError(true, ret, error);
547  }
548  }
549  // parse lateral arrival position information
551  bool ok = true;
552  const std::string arrivalPosLatStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS_LAT, ret->id.c_str(), ok);
553  double pos;
555  std::string error;
556  if (SUMOVehicleParameter::parseArrivalPosLat(arrivalPosLatStr, element, ret->id, pos, apd, error)) {
558  ret->arrivalPosLat = pos;
559  ret->arrivalPosLatProcedure = apd;
560  } else {
561  handleVehicleError(true, ret, error);
562  }
563  }
564  // parse arrival speed information
566  bool ok = true;
567  std::string arrivalSpeedStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALSPEED, ret->id.c_str(), ok);
568  double speed;
570  std::string error;
571  if (SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeedStr, element, ret->id, speed, asd, error)) {
573  ret->arrivalSpeed = speed;
574  ret->arrivalSpeedProcedure = asd;
575  } else {
576  handleVehicleError(true, ret, error);
577  }
578  }
579  // parse arrival edge information
580  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALEDGE)) {
581  bool ok = true;
582  std::string arrivalEdgeStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALEDGE, ret->id.c_str(), ok);
583  int edgeIndex;
585  std::string error;
586  if (SUMOVehicleParameter::parseRouteIndex(arrivalEdgeStr, element, ret->id, SUMO_ATTR_ARRIVALEDGE, edgeIndex, rid, error)) {
588  ret->arrivalEdge = edgeIndex;
589  ret->arrivalEdgeProcedure = rid;
590  } else {
591  handleVehicleError(true, ret, error);
592  }
593  }
594  // parse color
595  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
596  bool ok = true;
597  ret->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, ret->id.c_str(), ok);
598  if (ok) {
600  } else {
601  handleVehicleError(true, ret, "Invalid RGBColor format");
602  }
603  } else {
605  }
606  // parse person number
608  bool ok = true;
609  int personNumber = attrs.get<int>(SUMO_ATTR_PERSON_NUMBER, ret->id.c_str(), ok);
610  if (!ok) {
611  handleVehicleError(true, ret);
612  } else if (personNumber >= 0) {
614  ret->personNumber = personNumber;
615  } else {
616  handleVehicleError(true, ret, toString(SUMO_ATTR_PERSON_NUMBER) + " cannot be negative");
617  }
618  }
619  // parse container number
621  bool ok = true;
622  int containerNumber = attrs.get<int>(SUMO_ATTR_CONTAINER_NUMBER, ret->id.c_str(), ok);
623  if (!ok) {
624  handleVehicleError(true, ret);
625  } else if (containerNumber >= 0) {
627  ret->containerNumber = containerNumber;
628  } else {
629  handleVehicleError(true, ret, toString(SUMO_ATTR_CONTAINER_NUMBER) + " cannot be negative");
630  }
631  }
632  // parse individual speedFactor
633  if (attrs.hasAttribute(SUMO_ATTR_SPEEDFACTOR)) {
634  bool ok = true;
635  double speedFactor = attrs.get<double>(SUMO_ATTR_SPEEDFACTOR, ret->id.c_str(), ok);
636  if (!ok) {
637  handleVehicleError(true, ret);
638  } else if (speedFactor > 0) {
640  ret->speedFactor = speedFactor;
641  } else {
642  handleVehicleError(true, ret, toString(SUMO_ATTR_SPEEDFACTOR) + " must be positive");
643  }
644  }
645  // parse speed (only used by calibrators flow)
646  // also used by vehicle in saved state but this is parsed elsewhere
647  if (tag == SUMO_TAG_FLOW && attrs.hasAttribute(SUMO_ATTR_SPEED)) {
648  bool ok = true;
649  double calibratorSpeed = attrs.get<double>(SUMO_ATTR_SPEED, ret->id.c_str(), ok);
650  if (!ok) {
651  handleVehicleError(true, ret);
652  } else if (calibratorSpeed >= 0 || calibratorSpeed == -1) {
654  ret->calibratorSpeed = calibratorSpeed;
655  } else {
656  handleVehicleError(true, ret, toString(SUMO_ATTR_SPEED) + " may not be negative");
657  }
658  }
659  /*/ parse via
660  if (attrs.hasAttribute(SUMO_ATTR_VIA)) {
661  ret->setParameter |= VEHPARS_VIA_SET;
662  SUMOSAXAttributes::parseStringVector(attrs.get<std::string>(SUMO_ATTR_VIA, ret->id.c_str(), ok), ret->via);
663  }
664  */
665 }
666 
667 
669 SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file) {
670  // first obtain ID
671  std::string id = parseID(attrs, SUMO_TAG_VTYPE);
672  // check if ID is valid
673  if (!id.empty()) {
675  if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
676  vClass = parseVehicleClass(attrs, id);
677  }
678  // create vType
679  SUMOVTypeParameter* vType = new SUMOVTypeParameter(id, vClass);
680  // parse attributes
681  if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
683  }
684  if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
685  bool ok = true;
686  const double length = attrs.get<double>(SUMO_ATTR_LENGTH, vType->id.c_str(), ok);
687  if (!ok) {
688  return handleVehicleTypeError(hardFail, vType);
689  } else if (length <= 0) {
690  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_LENGTH) + " must be greater than 0");
691  } else {
692  vType->length = length;
694  }
695  }
696  if (attrs.hasAttribute(SUMO_ATTR_MINGAP)) {
697  bool ok = true;
698  const double minGap = attrs.get<double>(SUMO_ATTR_MINGAP, vType->id.c_str(), ok);
699  if (!ok) {
700  return handleVehicleTypeError(hardFail, vType);
701  } else if (minGap < 0) {
702  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MINGAP) + " must be equal or greater than 0");
703  } else {
704  vType->minGap = minGap;
706  }
707  }
708  if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
709  bool ok = true;
710  const double maxSpeed = attrs.get<double>(SUMO_ATTR_MAXSPEED, vType->id.c_str(), ok);
711  if (!ok) {
712  return handleVehicleTypeError(hardFail, vType);
713  } else if (maxSpeed <= 0) {
714  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MAXSPEED) + " must be greater than 0");
715  } else {
716  vType->maxSpeed = maxSpeed;
718  }
719  }
720  if (attrs.hasAttribute(SUMO_ATTR_SPEEDFACTOR)) {
721  bool ok = true;
722  vType->speedFactor.parse(attrs.get<std::string>(SUMO_ATTR_SPEEDFACTOR, vType->id.c_str(), ok), hardFail);
723  if (!ok) {
724  return handleVehicleTypeError(hardFail, vType);
725  } else {
727  }
728  }
729  if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
730  bool ok = true;
731  const double speedDev = attrs.get<double>(SUMO_ATTR_SPEEDDEV, vType->id.c_str(), ok);
732  if (!ok) {
733  return handleVehicleTypeError(hardFail, vType);
734  } else if (speedDev < 0) {
735  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_SPEEDDEV) + " must be equal or greater than 0");
736  } else {
737  vType->speedFactor.getParameter()[1] = speedDev;
739  }
740  }
741  // validate speed distribution
742  std::string error;
743  if (!vType->speedFactor.isValid(error)) {
744  return handleVehicleTypeError(hardFail, vType, "Invalid speed distribution when parsing vType '" + vType->id + "' (" + error + ")");
745  }
747  bool ok = true;
748  const double actionStepLengthSecs = attrs.get<double>(SUMO_ATTR_ACTIONSTEPLENGTH, vType->id.c_str(), ok);
749  if (!ok) {
750  return handleVehicleTypeError(hardFail, vType);
751  } else {
752  // processActionStepLength(...) function includes warnings
753  vType->actionStepLength = processActionStepLength(actionStepLengthSecs);
755  }
756  }
758  bool ok = true;
759  const std::string parsedEmissionClass = attrs.getOpt<std::string>(SUMO_ATTR_EMISSIONCLASS, id.c_str(), ok, "");
760  // check if emission class is correct
761  try {
762  vType->emissionClass = PollutantsInterface::getClassByName(parsedEmissionClass);
764  } catch (...) {
765  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_EMISSIONCLASS) + " with name '" + parsedEmissionClass + "' doesn't exist.");
766  }
767  }
768  if (attrs.hasAttribute(SUMO_ATTR_IMPATIENCE)) {
769  bool ok = true;
770  const std::string impatienceStr = attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
771  if (!ok) {
772  return handleVehicleTypeError(hardFail, vType);
773  } else if (impatienceStr == "off") {
774  vType->impatience = -std::numeric_limits<double>::max();
775  } else {
776  const double impatienceDouble = attrs.get<double>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
777  if (!ok) {
778  return handleVehicleTypeError(hardFail, vType);
779  } else {
780  vType->impatience = impatienceDouble;
782  }
783  }
784  }
785  if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
786  bool ok = true;
787  const double width = attrs.get<double>(SUMO_ATTR_WIDTH, vType->id.c_str(), ok);
788  if (!ok) {
789  return handleVehicleTypeError(hardFail, vType);
790  } else if (width <= 0) {
791  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_WIDTH) + " must be greater than 0");
792  } else {
793  vType->width = width;
795  if (vClass == SVC_PEDESTRIAN
796  && OptionsCont::getOptions().exists("pedestrian.striping.stripe-width")
797  && OptionsCont::getOptions().getString("pedestrian.model") == "striping"
798  && OptionsCont::getOptions().getFloat("pedestrian.striping.stripe-width") < vType->width) {
799  WRITE_WARNINGF("Pedestrian vType '%' width % is larger than pedestrian.striping.stripe-width and this may cause collisions with vehicles.", id, vType->width);
800  }
801  }
802  }
803  if (attrs.hasAttribute(SUMO_ATTR_HEIGHT)) {
804  bool ok = true;
805  const double height = attrs.get<double>(SUMO_ATTR_HEIGHT, vType->id.c_str(), ok);
806  if (!ok) {
807  return handleVehicleTypeError(hardFail, vType);
808  } else if (height < 0) {
809  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_HEIGHT) + " must be equal or greater than 0");
810  } else {
811  vType->height = height;
813  }
814  }
815  if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
816  vType->shape = parseGuiShape(attrs, vType->id);
817  if (vType->shape != SUMOVehicleShape::UNKNOWN) {
819  }
820  }
821  if (attrs.hasAttribute(SUMO_ATTR_OSGFILE)) {
822  bool ok = true;
823  const std::string osgFile = attrs.get<std::string>(SUMO_ATTR_OSGFILE, vType->id.c_str(), ok);
824  if (!ok) {
825  return handleVehicleTypeError(hardFail, vType);
826  } else {
827  vType->osgFile = osgFile;
829  }
830  }
831  if (attrs.hasAttribute(SUMO_ATTR_IMGFILE)) {
832  bool ok = true;
833  std::string imgFile = attrs.get<std::string>(SUMO_ATTR_IMGFILE, vType->id.c_str(), ok);
834  if (!ok) {
835  return handleVehicleTypeError(hardFail, vType);
836  } else {
837  // check relative path
838  if ((imgFile != "") && !FileHelpers::isAbsolute(imgFile)) {
839  imgFile = FileHelpers::getConfigurationRelative(file, imgFile);
840  }
841  vType->imgFile = imgFile;
843  }
844  }
845  if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
846  bool ok = true;
847  const RGBColor color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, vType->id.c_str(), ok);
848  if (!ok) {
849  return handleVehicleTypeError(hardFail, vType);
850  } else {
851  vType->color = color;
853  }
854  } else {
855  vType->color = RGBColor::YELLOW;
856  }
857  if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
858  bool ok = true;
859  const double defaultProbability = attrs.get<double>(SUMO_ATTR_PROB, vType->id.c_str(), ok);
860  if (!ok) {
861  return handleVehicleTypeError(hardFail, vType);
862  } else if (defaultProbability < 0) {
863  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_PROB) + " must be equal or greater than 0");
864  } else {
865  vType->defaultProbability = defaultProbability;
867  }
868  }
870  bool ok = true;
871  std::string lcmS = attrs.get<std::string>(SUMO_ATTR_LANE_CHANGE_MODEL, vType->id.c_str(), ok);
872  if (!ok) {
873  return handleVehicleTypeError(hardFail, vType);
874  } else if (lcmS == "JE2013") {
875  WRITE_WARNING("Lane change model 'JE2013' is deprecated. Using default model instead.");
876  lcmS = "default";
877  }
878  if (SUMOXMLDefinitions::LaneChangeModels.hasString(lcmS)) {
881  } else {
882  return handleVehicleTypeError(hardFail, vType, "Unknown lane change model '" + lcmS + "' when parsing vType '" + vType->id + "'");
883  }
884  }
886  bool ok = true;
887  const std::string cfmValue = attrs.get<std::string>(SUMO_ATTR_CAR_FOLLOW_MODEL, vType->id.c_str(), ok);
888  if (!ok) {
889  return handleVehicleTypeError(hardFail, vType);
890  } else if (SUMOXMLDefinitions::CarFollowModels.hasString(cfmValue)) {
893  } else {
894  return handleVehicleTypeError(hardFail, vType, "Unknown car following model '" + cfmValue + "' when parsing vType '" + vType->id + "'");
895  }
896  }
898  bool ok = true;
899  const int personCapacity = attrs.get<int>(SUMO_ATTR_PERSON_CAPACITY, vType->id.c_str(), ok);
900  if (!ok) {
901  return handleVehicleTypeError(hardFail, vType);
902  } else if (personCapacity < 0) {
903  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_PERSON_CAPACITY) + " must be equal or greater than 0");
904  } else {
905  vType->personCapacity = personCapacity;
907  }
908  }
910  bool ok = true;
911  const int containerCapacity = attrs.get<int>(SUMO_ATTR_CONTAINER_CAPACITY, vType->id.c_str(), ok);
912  if (!ok) {
913  return handleVehicleTypeError(hardFail, vType);
914  } else if (containerCapacity < 0) {
915  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_CONTAINER_CAPACITY) + " must be equal or greater than 0");
916  } else {
917  vType->containerCapacity = containerCapacity;
919  }
920  }
922  bool ok = true;
923  const SUMOTime boardingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_BOARDING_DURATION, vType->id.c_str(), ok);
924  if (!ok) {
925  return handleVehicleTypeError(hardFail, vType);
926  } else if (boardingDuration < 0) {
927  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_BOARDING_DURATION) + " must be equal or greater than 0");
928  } else {
929  vType->boardingDuration = boardingDuration;
931  }
932  }
934  bool ok = true;
935  const SUMOTime loadingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_LOADING_DURATION, vType->id.c_str(), ok);
936  if (!ok) {
937  return handleVehicleTypeError(hardFail, vType);
938  } else if (loadingDuration < 0) {
939  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_LOADING_DURATION) + " must be equal or greater than 0");
940  } else {
941  vType->loadingDuration = loadingDuration;
943  }
944  }
946  bool ok = true;
947  const double maxSpeedLat = attrs.get<double>(SUMO_ATTR_MAXSPEED_LAT, vType->id.c_str(), ok);
948  if (!ok) {
949  return handleVehicleTypeError(hardFail, vType);
950  } else if (maxSpeedLat <= 0) {
951  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MAXSPEED_LAT) + " must be greater than 0");
952  } else {
953  vType->maxSpeedLat = maxSpeedLat;
955  }
956  }
957  if (attrs.hasAttribute(SUMO_ATTR_MINGAP_LAT)) {
958  bool ok = true;
959  const double minGapLat = attrs.get<double>(SUMO_ATTR_MINGAP_LAT, vType->id.c_str(), ok);
960  if (!ok) {
961  return handleVehicleTypeError(hardFail, vType);
962  } else if (minGapLat < 0) {
963  return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MINGAP_LAT) + " must be equal or greater than 0");
964  } else {
965  vType->minGapLat = minGapLat;
967  }
968  }
970  bool ok = true;
971  const std::string alignS = attrs.get<std::string>(SUMO_ATTR_LATALIGNMENT, vType->id.c_str(), ok);
972  if (!ok) {
973  return handleVehicleTypeError(hardFail, vType);
974  } else {
975  double lao;
977  if (SUMOVTypeParameter::parseLatAlignment(alignS, lao, lad)) {
978  vType->latAlignmentOffset = lao;
979  vType->latAlignmentProcedure = lad;
981  } else {
982  return handleVehicleTypeError(hardFail, vType, "Unknown lateral alignment '" + alignS + "' when parsing vType '" + vType->id + "';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
983  }
984  }
985  }
987  bool ok = true;
988  const std::string angleTimesS = attrs.get<std::string>(SUMO_ATTR_MANEUVER_ANGLE_TIMES, vType->id.c_str(), ok);
989  if (!ok) {
990  return handleVehicleTypeError(hardFail, vType);
991  } else if (parseAngleTimesMap(vType, angleTimesS)) {
993  } else {
994  return handleVehicleTypeError(hardFail, vType, "Invalid manoeuver angle times map for vType '" + vType->id + "'");
995  }
996  }
997  // try to parse Car Following Model params
998  if (!parseCFMParams(vType, vType->cfModel, attrs, false)) {
999  return handleVehicleTypeError(hardFail, vType, "Invalid parsing embedded VType");
1000  }
1001  // try to parse Lane Change Model params
1002  if (!parseLCParams(vType, vType->lcModel, attrs)) {
1003  return handleVehicleTypeError(hardFail, vType, "Invalid Lane Change Model Parameters");
1004  }
1005  // try to Junction Model params
1006  if (!parseJMParams(vType, attrs)) {
1007  return handleVehicleTypeError(hardFail, vType, "Invalid Junction Model Parameters");
1008  }
1009  // all ok, then return vType
1010  return vType;
1011  } else {
1012  return handleVehicleTypeError(hardFail, nullptr, "VType cannot be created");
1013  }
1014 }
1015 
1016 
1017 bool
1019  StringTokenizer st(atm, ",");
1020  std::map<int, std::pair<SUMOTime, SUMOTime>> angleTimesMap;
1021  int tripletCount = 0;
1022  while (st.hasNext()) {
1023  StringTokenizer pos(st.next());
1024  if (pos.size() != 3) {
1025  WRITE_ERROR("manoeuverAngleTimes format for vType '" + vtype->id + "' " + atm + " contains an invalid triplet.");
1026  return false;
1027  } else {
1028  try {
1029  const int angle = StringUtils::toInt(pos.next());
1030  const SUMOTime t1 = static_cast<SUMOTime>(StringUtils::toDouble(pos.next()));
1031  const SUMOTime steps1 = TIME2STEPS(t1);
1032  const SUMOTime t2 = static_cast<SUMOTime>(StringUtils::toDouble(pos.next()));
1033  const SUMOTime steps2 = TIME2STEPS(t2);
1034  angleTimesMap.insert((std::pair<int, std::pair<SUMOTime, SUMOTime>>(angle, std::pair< SUMOTime, SUMOTime>(steps1, steps2))));
1035  } catch (...) {
1036  WRITE_ERROR("Triplet '" + st.get(tripletCount) + "' for vType '" + vtype->id + "' manoeuverAngleTimes cannot be parsed as 'int double double'");
1037  return false;
1038  }
1039  tripletCount++;
1040  }
1041  }
1042  if (angleTimesMap.size() > 0) {
1043  vtype->myManoeuverAngleTimes.clear();
1044  for (const auto& angleTime : angleTimesMap) {
1045  vtype->myManoeuverAngleTimes.insert(angleTime);
1046  }
1047  angleTimesMap.clear();
1048  return true;
1049  } else {
1050  return false;
1051  }
1052 }
1053 
1054 
1055 bool
1056 SUMOVehicleParserHelper::parseCFMParams(SUMOVTypeParameter* into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool nestedCFM) {
1057  const CFAttrMap& allowedCFM = getAllowedCFModelAttrs();
1058  CFAttrMap::const_iterator cf_it = allowedCFM.find(element);
1059  // check if given CFM is allowed
1060  if (cf_it == allowedCFM.end()) {
1061  if (SUMOXMLDefinitions::Tags.has((int)element)) {
1062  WRITE_ERROR("Unknown car following model " + toString(element) + " when parsing vType '" + into->id + "'");
1063  } else {
1064  WRITE_ERROR("Unknown car following model when parsing vType '" + into->id + "'");
1065  }
1066  return false;
1067  }
1068  // check if we're parsing a nested CFM
1069  if (nestedCFM) {
1070  into->cfModel = cf_it->first;
1072  }
1073  // set CFM values
1074  for (const auto& it : cf_it->second) {
1075  if (attrs.hasAttribute(it)) {
1076  // first obtain CFM attribute in string format
1077  bool ok = true;
1078  std::string parsedCFMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1079  // check CFM Attribute
1080  if (!ok) {
1081  return false;
1082  } else if (it == SUMO_ATTR_TRAIN_TYPE) {
1083  // check if train value is valid
1084  if (!SUMOXMLDefinitions::TrainTypes.hasString(parsedCFMAttribute)) {
1085  WRITE_ERROR("Invalid train type '" + parsedCFMAttribute + "' used in Car-Following-Attribute " + toString(it));
1086  return false;
1087  }
1088  // add parsedCFMAttribute to cfParameter
1089  into->cfParameter[it] = parsedCFMAttribute;
1090  } else if (it == SUMO_ATTR_CF_IDM_STEPPING) {
1091  // declare a int in wich save CFM int attribute
1092  double CFMDoubleAttribute = -1;
1093  try {
1094  // obtain CFM attribute in int format
1095  CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
1096  } catch (...) {
1097  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1098  return false;
1099  }
1100  if (CFMDoubleAttribute <= 0) {
1101  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
1102  return false;
1103  }
1104  // add parsedCFMAttribute to cfParameter
1105  into->cfParameter[it] = parsedCFMAttribute;
1106  } else {
1107  // declare a double in wich save CFM float attribute
1108  double CFMDoubleAttribute = -1;
1109  try {
1110  // obtain CFM attribute in double format
1111  CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
1112  } catch (...) {
1113  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1114  return false;
1115  }
1116  // check attributes of type "positiveFloatType" (> 0)
1117  switch (it) {
1118  case SUMO_ATTR_ACCEL:
1119  case SUMO_ATTR_DECEL:
1122  case SUMO_ATTR_TAU:
1123  if (CFMDoubleAttribute <= 0) {
1124  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
1125  return false;
1126  }
1127  break;
1128  default:
1129  break;
1130  }
1131  // check attributes restricted to [0-1]
1132  switch (it) {
1133  case SUMO_ATTR_SIGMA:
1134  if ((CFMDoubleAttribute < 0) || (CFMDoubleAttribute > 1)) {
1135  WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
1136  return false;
1137  }
1138  break;
1139  default:
1140  break;
1141  }
1142  // add parsedCFMAttribute to cfParameter
1143  into->cfParameter[it] = parsedCFMAttribute;
1144  }
1145  }
1146  }
1147  // all CFM sucesfully parsed, then return true
1148  return true;
1149 }
1150 
1151 
1154  // init on first use
1155  if (allowedCFModelAttrs.size() == 0) {
1156  // Krauss
1157  std::set<SumoXMLAttr> kraussParams;
1158  kraussParams.insert(SUMO_ATTR_ACCEL);
1159  kraussParams.insert(SUMO_ATTR_DECEL);
1160  kraussParams.insert(SUMO_ATTR_APPARENTDECEL);
1161  kraussParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1162  kraussParams.insert(SUMO_ATTR_SIGMA);
1163  kraussParams.insert(SUMO_ATTR_TAU);
1164  allowedCFModelAttrs[SUMO_TAG_CF_KRAUSS] = kraussParams;
1167  std::set<SumoXMLAttr> allParams(kraussParams);
1168  // KraussX
1169  std::set<SumoXMLAttr> kraussXParams(kraussParams);
1170  kraussXParams.insert(SUMO_ATTR_TMP1);
1171  kraussXParams.insert(SUMO_ATTR_TMP2);
1172  kraussXParams.insert(SUMO_ATTR_TMP3);
1173  kraussXParams.insert(SUMO_ATTR_TMP4);
1174  kraussXParams.insert(SUMO_ATTR_TMP5);
1175  allowedCFModelAttrs[SUMO_TAG_CF_KRAUSSX] = kraussXParams;
1176  allParams.insert(kraussXParams.begin(), kraussXParams.end());
1177  // SmartSK
1178  std::set<SumoXMLAttr> smartSKParams;
1179  smartSKParams.insert(SUMO_ATTR_ACCEL);
1180  smartSKParams.insert(SUMO_ATTR_DECEL);
1181  smartSKParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1182  smartSKParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1183  smartSKParams.insert(SUMO_ATTR_SIGMA);
1184  smartSKParams.insert(SUMO_ATTR_TAU);
1185  smartSKParams.insert(SUMO_ATTR_TMP1);
1186  smartSKParams.insert(SUMO_ATTR_TMP2);
1187  smartSKParams.insert(SUMO_ATTR_TMP3);
1188  smartSKParams.insert(SUMO_ATTR_TMP4);
1189  smartSKParams.insert(SUMO_ATTR_TMP5);
1190  allowedCFModelAttrs[SUMO_TAG_CF_SMART_SK] = smartSKParams;
1191  allParams.insert(smartSKParams.begin(), smartSKParams.end());
1192  // Daniel
1193  std::set<SumoXMLAttr> daniel1Params;
1194  daniel1Params.insert(SUMO_ATTR_ACCEL);
1195  daniel1Params.insert(SUMO_ATTR_DECEL);
1196  daniel1Params.insert(SUMO_ATTR_EMERGENCYDECEL);
1197  daniel1Params.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1198  daniel1Params.insert(SUMO_ATTR_SIGMA);
1199  daniel1Params.insert(SUMO_ATTR_TAU);
1200  daniel1Params.insert(SUMO_ATTR_TMP1);
1201  daniel1Params.insert(SUMO_ATTR_TMP2);
1202  daniel1Params.insert(SUMO_ATTR_TMP3);
1203  daniel1Params.insert(SUMO_ATTR_TMP4);
1204  daniel1Params.insert(SUMO_ATTR_TMP5);
1205  allowedCFModelAttrs[SUMO_TAG_CF_DANIEL1] = daniel1Params;
1206  allParams.insert(daniel1Params.begin(), daniel1Params.end());
1207  // Peter Wagner
1208  std::set<SumoXMLAttr> pwagParams;
1209  pwagParams.insert(SUMO_ATTR_ACCEL);
1210  pwagParams.insert(SUMO_ATTR_DECEL);
1211  pwagParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1212  pwagParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1213  pwagParams.insert(SUMO_ATTR_SIGMA);
1214  pwagParams.insert(SUMO_ATTR_TAU);
1215  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_TAULAST);
1216  pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_APPROB);
1218  allParams.insert(pwagParams.begin(), pwagParams.end());
1219  // IDM params
1220  std::set<SumoXMLAttr> idmParams;
1221  idmParams.insert(SUMO_ATTR_ACCEL);
1222  idmParams.insert(SUMO_ATTR_DECEL);
1223  idmParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1224  idmParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1225  idmParams.insert(SUMO_ATTR_TAU);
1226  idmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1227  idmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1228  allowedCFModelAttrs[SUMO_TAG_CF_IDM] = idmParams;
1229  allParams.insert(idmParams.begin(), idmParams.end());
1230  // EIDM
1231  std::set<SumoXMLAttr> eidmParams;
1232  eidmParams.insert(SUMO_ATTR_ACCEL);
1233  eidmParams.insert(SUMO_ATTR_DECEL);
1234  eidmParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1235  eidmParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1236  eidmParams.insert(SUMO_ATTR_TAU);
1237  eidmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1238  eidmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1239  eidmParams.insert(SUMO_ATTR_CF_EIDM_T_LOOK_AHEAD);
1240  eidmParams.insert(SUMO_ATTR_CF_EIDM_T_PERSISTENCE_DRIVE);
1241  eidmParams.insert(SUMO_ATTR_CF_EIDM_T_REACTION);
1242  eidmParams.insert(SUMO_ATTR_CF_EIDM_T_PERSISTENCE_ESTIMATE);
1243  eidmParams.insert(SUMO_ATTR_CF_EIDM_C_COOLNESS);
1244  eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_LEADER);
1245  eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_GAP);
1246  eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_ERROR);
1247  eidmParams.insert(SUMO_ATTR_CF_EIDM_JERK_MAX);
1248  eidmParams.insert(SUMO_ATTR_CF_EIDM_EPSILON_ACC);
1249  eidmParams.insert(SUMO_ATTR_CF_EIDM_T_ACC_MAX);
1250  eidmParams.insert(SUMO_ATTR_CF_EIDM_M_FLATNESS);
1251  eidmParams.insert(SUMO_ATTR_CF_EIDM_M_BEGIN);
1252  eidmParams.insert(SUMO_ATTR_CF_EIDM_USEVEHDYNAMICS);
1253  eidmParams.insert(SUMO_ATTR_CF_EIDM_MAX_VEH_PREVIEW);
1254  allowedCFModelAttrs[SUMO_TAG_CF_EIDM] = eidmParams;
1255  allParams.insert(eidmParams.begin(), eidmParams.end());
1256  // IDMM
1257  std::set<SumoXMLAttr> idmmParams;
1258  idmmParams.insert(SUMO_ATTR_ACCEL);
1259  idmmParams.insert(SUMO_ATTR_DECEL);
1260  idmmParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1261  idmmParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1262  idmmParams.insert(SUMO_ATTR_TAU);
1263  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_FACTOR);
1264  idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_TIME);
1265  idmmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1266  allowedCFModelAttrs[SUMO_TAG_CF_IDMM] = idmmParams;
1267  allParams.insert(idmmParams.begin(), idmmParams.end());
1268  // Bieker
1269  std::set<SumoXMLAttr> bkernerParams;
1270  bkernerParams.insert(SUMO_ATTR_ACCEL);
1271  bkernerParams.insert(SUMO_ATTR_DECEL);
1272  bkernerParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1273  bkernerParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1274  bkernerParams.insert(SUMO_ATTR_TAU);
1275  bkernerParams.insert(SUMO_ATTR_K);
1276  bkernerParams.insert(SUMO_ATTR_CF_KERNER_PHI);
1277  allowedCFModelAttrs[SUMO_TAG_CF_BKERNER] = bkernerParams;
1278  allParams.insert(bkernerParams.begin(), bkernerParams.end());
1279  // Wiedemann
1280  std::set<SumoXMLAttr> wiedemannParams;
1281  wiedemannParams.insert(SUMO_ATTR_ACCEL);
1282  wiedemannParams.insert(SUMO_ATTR_DECEL);
1283  wiedemannParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1284  wiedemannParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1285  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_SECURITY);
1286  wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_ESTIMATION);
1287  allowedCFModelAttrs[SUMO_TAG_CF_WIEDEMANN] = wiedemannParams;
1288  allParams.insert(wiedemannParams.begin(), wiedemannParams.end());
1289  // W99
1290  std::set<SumoXMLAttr> w99Params;
1291  w99Params.insert(SUMO_ATTR_DECEL); // used when patching speed during lane-changing
1292  w99Params.insert(SUMO_ATTR_EMERGENCYDECEL);
1293  w99Params.insert(SUMO_ATTR_CF_W99_CC1);
1294  w99Params.insert(SUMO_ATTR_CF_W99_CC2);
1295  w99Params.insert(SUMO_ATTR_CF_W99_CC3);
1296  w99Params.insert(SUMO_ATTR_CF_W99_CC4);
1297  w99Params.insert(SUMO_ATTR_CF_W99_CC5);
1298  w99Params.insert(SUMO_ATTR_CF_W99_CC6);
1299  w99Params.insert(SUMO_ATTR_CF_W99_CC7);
1300  w99Params.insert(SUMO_ATTR_CF_W99_CC8);
1301  w99Params.insert(SUMO_ATTR_CF_W99_CC9);
1302  allowedCFModelAttrs[SUMO_TAG_CF_W99] = w99Params;
1303  allParams.insert(w99Params.begin(), w99Params.end());
1304  // Rail
1305  std::set<SumoXMLAttr> railParams;
1306  railParams.insert(SUMO_ATTR_TRAIN_TYPE);
1307  railParams.insert(SUMO_ATTR_ACCEL);
1308  railParams.insert(SUMO_ATTR_DECEL);
1309  railParams.insert(SUMO_ATTR_APPARENTDECEL);
1310  railParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1311  railParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1312  allowedCFModelAttrs[SUMO_TAG_CF_RAIL] = railParams;
1313  allParams.insert(railParams.begin(), railParams.end());
1314  // ACC
1315  std::set<SumoXMLAttr> ACCParams;
1316  ACCParams.insert(SUMO_ATTR_ACCEL);
1317  ACCParams.insert(SUMO_ATTR_DECEL);
1318  ACCParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1319  ACCParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1320  ACCParams.insert(SUMO_ATTR_TAU);
1321  ACCParams.insert(SUMO_ATTR_SC_GAIN);
1322  ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1323  ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1324  ACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1325  ACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1326  ACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1327  ACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1328  ACCParams.insert(SUMO_ATTR_APPLYDRIVERSTATE);
1329  allowedCFModelAttrs[SUMO_TAG_CF_ACC] = ACCParams;
1330  allParams.insert(ACCParams.begin(), ACCParams.end());
1331  // CACC
1332  std::set<SumoXMLAttr> CACCParams;
1333  CACCParams.insert(SUMO_ATTR_ACCEL);
1334  CACCParams.insert(SUMO_ATTR_DECEL);
1335  CACCParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1336  CACCParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1337  CACCParams.insert(SUMO_ATTR_TAU);
1338  CACCParams.insert(SUMO_ATTR_SC_GAIN_CACC);
1339  CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_CACC);
1340  CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_DOT_CACC);
1341  CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_CACC);
1342  CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_DOT_CACC);
1343  CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_CACC);
1344  CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_DOT_CACC);
1345  CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1346  CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1347  CACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1348  CACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1349  CACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1350  CACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1351  CACCParams.insert(SUMO_ATTR_HEADWAY_TIME_CACC_TO_ACC);
1352  CACCParams.insert(SUMO_ATTR_APPLYDRIVERSTATE);
1353  allowedCFModelAttrs[SUMO_TAG_CF_CACC] = CACCParams;
1354  allParams.insert(CACCParams.begin(), CACCParams.end());
1355  // CC
1356  std::set<SumoXMLAttr> ccParams;
1357  ccParams.insert(SUMO_ATTR_ACCEL);
1358  ccParams.insert(SUMO_ATTR_DECEL);
1359  ccParams.insert(SUMO_ATTR_TAU);
1360  ccParams.insert(SUMO_ATTR_CF_CC_C1);
1361  ccParams.insert(SUMO_ATTR_CF_CC_CCDECEL);
1362  ccParams.insert(SUMO_ATTR_CF_CC_CONSTSPACING);
1363  ccParams.insert(SUMO_ATTR_CF_CC_KP);
1364  ccParams.insert(SUMO_ATTR_CF_CC_LAMBDA);
1365  ccParams.insert(SUMO_ATTR_CF_CC_OMEGAN);
1366  ccParams.insert(SUMO_ATTR_CF_CC_TAU);
1367  ccParams.insert(SUMO_ATTR_CF_CC_XI);
1368  ccParams.insert(SUMO_ATTR_CF_CC_LANES_COUNT);
1369  ccParams.insert(SUMO_ATTR_CF_CC_CCACCEL);
1370  ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KP);
1371  ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KD);
1372  ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_H);
1373  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KA);
1374  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KV);
1375  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KP);
1376  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_D);
1377  ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_H);
1378  allowedCFModelAttrs[SUMO_TAG_CF_CC] = ccParams;
1379  allParams.insert(ccParams.begin(), ccParams.end());
1380  // last element
1382  }
1383  return allowedCFModelAttrs;
1384 }
1385 
1386 
1387 bool
1389  if (allowedLCModelAttrs.size() == 0) {
1390  // lc2013
1391  std::set<SumoXMLAttr> lc2013Params;
1392  lc2013Params.insert(SUMO_ATTR_LCA_STRATEGIC_PARAM);
1393  lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_PARAM);
1394  lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_PARAM);
1395  lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_PARAM);
1396  lc2013Params.insert(SUMO_ATTR_LCA_OPPOSITE_PARAM);
1397  lc2013Params.insert(SUMO_ATTR_LCA_LOOKAHEADLEFT);
1398  lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAINRIGHT);
1399  lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING);
1400  lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR);
1401  lc2013Params.insert(SUMO_ATTR_LCA_MAXDISTLATSTANDING);
1402  lc2013Params.insert(SUMO_ATTR_LCA_ASSERTIVE);
1403  lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD);
1404  lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_ROUNDABOUT);
1405  lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_SPEED);
1406  lc2013Params.insert(SUMO_ATTR_LCA_OVERTAKE_RIGHT);
1407  lc2013Params.insert(SUMO_ATTR_LCA_SIGMA);
1408  lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_ACCEPTANCE_TIME);
1409  lc2013Params.insert(SUMO_ATTR_LCA_EXPERIMENTAL1);
1411  // sl2015 (extension of lc2013)
1412  std::set<SumoXMLAttr> sl2015Params = lc2013Params;
1413  sl2015Params.insert(SUMO_ATTR_LCA_PUSHY);
1414  sl2015Params.insert(SUMO_ATTR_LCA_PUSHYGAP);
1415  sl2015Params.insert(SUMO_ATTR_LCA_SUBLANE_PARAM);
1416  sl2015Params.insert(SUMO_ATTR_LCA_IMPATIENCE);
1417  sl2015Params.insert(SUMO_ATTR_LCA_TIME_TO_IMPATIENCE);
1418  sl2015Params.insert(SUMO_ATTR_LCA_ACCEL_LAT);
1419  sl2015Params.insert(SUMO_ATTR_LCA_TURN_ALIGNMENT_DISTANCE);
1420  sl2015Params.insert(SUMO_ATTR_LCA_LANE_DISCIPLINE);
1422  // DK2008
1423  std::set<SumoXMLAttr> noParams;
1425  // default model may be either LC2013 or SL2015
1426  // we allow both sets (sl2015 is a superset of lc2013Params)
1428  }
1429  std::set<SumoXMLAttr> allowed = allowedLCModelAttrs[model];
1430  // iterate over LCM attributes
1431  for (const auto& it : allowed) {
1432  if (attrs.hasAttribute(it)) {
1433  // first obtain CFM attribute in string format
1434  bool ok = true;
1435  std::string parsedLCMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1436  if (!ok) {
1437  return false;
1438  }
1439  // declare a double in wich save CFM attribute
1440  double LCMAttribute = -1;
1441  try {
1442  // obtain CFM attribute in double format
1443  LCMAttribute = StringUtils::toDouble(parsedLCMAttribute);
1444  } catch (...) {
1445  WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1446  return false;
1447  }
1448  // check attributes of type "nonNegativeFloatType" (>= 0)
1449  switch (it) {
1460  case SUMO_ATTR_LCA_SIGMA:
1461  if (LCMAttribute < 0) {
1462  WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1463  return false;
1464  }
1465  break;
1466  default:
1467  break;
1468  }
1469  // check attributes of type "positiveFloatType" (> 0)
1470  switch (it) {
1472  if (LCMAttribute <= 0) {
1473  WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be greater than 0");
1474  return false;
1475  }
1476  break;
1477  default:
1478  break;
1479  }
1480  // add parsedLCMAttribute to cfParameter
1481  into->lcParameter[it] = parsedLCMAttribute;
1482  }
1483  }
1484  // all LCM parsed ok, then return true
1485  return true;
1486 }
1487 
1488 
1489 bool
1491  if (allowedJMAttrs.size() == 0) {
1492  // init static set (there is only one model)
1504  }
1505  for (const auto& it : allowedJMAttrs) {
1506  if (attrs.hasAttribute(it)) {
1507  // first obtain CFM attribute in string format
1508  bool ok = true;
1509  std::string parsedJMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1510  if (!ok) {
1511  return false;
1512  }
1513  // declare a double in wich save CFM attribute
1514  double JMAttribute = -1;
1515  try {
1516  // obtain CFM attribute in double format
1517  JMAttribute = StringUtils::toDouble(parsedJMAttribute);
1518  } catch (...) {
1519  WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1520  return false;
1521  }
1522  // now continue checking other properties (-1 is the default value)
1523  if (JMAttribute != -1) {
1524  // special case for sigma minor
1525  if (it == SUMO_ATTR_JM_SIGMA_MINOR) {
1526  // check attributes sigma minor
1527  if ((JMAttribute < 0) || (JMAttribute > 1)) {
1528  WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
1529  return false;
1530  }
1531  } else {
1532  // check attributes of type "nonNegativeFloatType" (>= 0)
1533  if (JMAttribute < 0) {
1534  WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1535  return false;
1536  }
1537  }
1538  // add parsedJMAttribute to cfParameter
1539  into->jmParameter[it] = parsedJMAttribute;
1540  }
1541  }
1542  }
1543  // all JM parameters sucesfully parsed, then return true
1544  return true;
1545 }
1546 
1547 
1550  SUMOVehicleClass vclass = SVC_IGNORING;
1551  bool ok = true;
1552  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_VCLASS, id.c_str(), ok, "");
1553  if (vclassS == "") {
1554  return vclass;
1555  }
1556  try {
1557  const SUMOVehicleClass result = getVehicleClassID(vclassS);
1558  const std::string& realName = SumoVehicleClassStrings.getString(result);
1559  if (realName != vclassS) {
1560  WRITE_WARNING("The vehicle class '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1561  }
1562  return result;
1563  } catch (...) {
1564  WRITE_ERROR("The vehicle class '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
1565  }
1566  return vclass;
1567 }
1568 
1569 
1571 SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id) {
1572  bool ok = true;
1573  std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_GUISHAPE, id.c_str(), ok, "");
1574  if (SumoVehicleShapeStrings.hasString(vclassS)) {
1575  const SUMOVehicleShape result = SumoVehicleShapeStrings.get(vclassS);
1576  const std::string& realName = SumoVehicleShapeStrings.getString(result);
1577  if (realName != vclassS) {
1578  WRITE_WARNING("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1579  }
1580  return result;
1581  } else {
1582  WRITE_ERROR("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
1584  }
1585 }
1586 
1587 
1588 double
1589 SUMOVehicleParserHelper::parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, SumoRNG* rng) {
1590  double result;
1591  std::string error;
1593  // only supports 'random' and 'max'
1594  if (!SUMOVehicleParameter::parseArrivalPos(val, toString(SUMO_TAG_WALK), id, result, proc, error)) {
1595  handleVehicleError(hardFail, nullptr, error);
1596  }
1597  if (proc == ArrivalPosDefinition::RANDOM) {
1598  result = RandHelper::rand(maxPos, rng);
1599  } else if (proc == ArrivalPosDefinition::CENTER) {
1600  result = maxPos / 2.;
1601  } else if (proc == ArrivalPosDefinition::MAX) {
1602  result = maxPos;
1603  }
1604  return SUMOVehicleParameter::interpretEdgePos(result, maxPos, attr, id);
1605 }
1606 
1607 
1608 SUMOTime
1610  const std::string defaultError = "The parameter action-step-length must be a non-negative multiple of the simulation step-length. ";
1611  SUMOTime result = TIME2STEPS(given);
1612  if (result <= 0) {
1613  if (result < 0) {
1614  WRITE_WARNING(defaultError + "Ignoring given value (=" + toString(STEPS2TIME(result)) + " s.)");
1615  }
1616  result = DELTA_T;
1617  } else if (result % DELTA_T != 0) {
1618  result = (SUMOTime)(DELTA_T * floor(double(result) / double(DELTA_T)));
1619  result = MAX2(DELTA_T, result);
1620  if (fabs(given * 1000. - double(result)) > NUMERICAL_EPS) {
1621  WRITE_WARNING(defaultError + "Parsing given value (" + toString(given) + " s.) to the adjusted value " + toString(STEPS2TIME(result)) + " s.");
1622  }
1623  }
1624  return result;
1625 }
1626 
1627 
1629 SUMOVehicleParserHelper::handleVehicleError(const bool hardFail, SUMOVehicleParameter* vehicleParameter, const std::string message) {
1630  if (vehicleParameter) {
1631  delete vehicleParameter;
1632  }
1633  if (hardFail) {
1634  throw ProcessError(message);
1635  } else if (message.size() > 0) {
1636  WRITE_ERROR(message);
1637  }
1638  return nullptr;
1639 }
1640 
1641 
1643 SUMOVehicleParserHelper::handleVehicleTypeError(const bool hardFail, SUMOVTypeParameter* vehicleTypeParameter, const std::string message) {
1644  if (vehicleTypeParameter) {
1645  delete vehicleTypeParameter;
1646  }
1647  if (hardFail) {
1648  throw ProcessError(message);
1649  } else if (message.size() > 0) {
1650  WRITE_ERROR(message);
1651  }
1652  return nullptr;
1653 }
1654 
1655 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:281
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SUMOTime_MAX
Definition: SUMOTime.h:33
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
const int VTYPEPARS_MAXSPEED_SET
const int VTYPEPARS_MANEUVER_ANGLE_TIMES_SET
const int VTYPEPARS_PERSON_CAPACITY
const int VTYPEPARS_HEIGHT_SET
const int VTYPEPARS_VEHICLECLASS_SET
const int VTYPEPARS_COLOR_SET
const int VTYPEPARS_SPEEDFACTOR_SET
const int VTYPEPARS_BOARDING_DURATION
const int VTYPEPARS_IMPATIENCE_SET
const int VTYPEPARS_LATALIGNMENT_SET
const int VTYPEPARS_LENGTH_SET
const int VTYPEPARS_OSGFILE_SET
const int VTYPEPARS_LANE_CHANGE_MODEL_SET
const int VTYPEPARS_MINGAP_SET
const int VTYPEPARS_IMGFILE_SET
const int VTYPEPARS_SHAPE_SET
const int VTYPEPARS_ACTIONSTEPLENGTH_SET
const int VTYPEPARS_LOADING_DURATION
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
const int VTYPEPARS_CONTAINER_CAPACITY
const int VTYPEPARS_MAXSPEED_LAT_SET
const int VTYPEPARS_EMISSIONCLASS_SET
const int VTYPEPARS_PROBABILITY_SET
const int VTYPEPARS_CAR_FOLLOW_MODEL
const int VTYPEPARS_MINGAP_LAT_SET
const int VTYPEPARS_WIDTH_SET
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SUMOVehicleShape::UNKNOWN, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_PEDTYPE_ID
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
@ UNKNOWN
not defined
const std::string DEFAULT_CONTAINERTYPE_ID
const int VEHPARS_DEPARTEDGE_SET
const int VEHPARS_ARRIVALEDGE_SET
const int VEHPARS_PROB_SET
RouteIndexDefinition
Possible ways to choose the departure and arrival edge.
const int VEHPARS_VPH_SET
const int VEHPARS_END_SET
const int VEHPARS_ROUTE_SET
const int VEHPARS_COLOR_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
const int VEHPARS_TO_TAZ_SET
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
DepartPosLatDefinition
Possible ways to choose the lateral departure position.
DepartPosDefinition
Possible ways to choose the departure position.
const int VEHPARS_SPEEDFACTOR_SET
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int VEHPARS_ARRIVALLANE_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_ARRIVALPOSLAT_SET
const int VEHPARS_FROM_TAZ_SET
const int VEHPARS_NUMBER_SET
const int VEHPARS_ARRIVALSPEED_SET
const int VEHPARS_CALIBRATORSPEED_SET
const int VEHPARS_FORCE_REROUTE
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ RANDOM
The arrival position is chosen randomly.
@ MAX
The maximum arrival position is used.
@ DEFAULT
No information given; use default.
@ CENTER
Half the road length.
const int VEHPARS_LINE_SET
const int VEHPARS_PERSON_NUMBER_SET
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_PERIOD_SET
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const int VEHPARS_VTYPE_SET
const int VEHPARS_ARRIVALPOS_SET
@ DEPART_TRIGGERED
The departure is person triggered.
const int VEHPARS_DEPARTPOSLAT_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_CF_KRAUSS
@ SUMO_TAG_CF_BKERNER
@ SUMO_TAG_CF_KRAUSSX
@ SUMO_TAG_CF_CACC
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_WALK
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_CF_CC
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_CF_KRAUSS_PLUS_SLOPE
@ SUMO_TAG_CF_IDM
@ SUMO_TAG_CF_W99
@ SUMO_TAG_CF_RAIL
@ SUMO_TAG_CF_SMART_SK
@ SUMO_TAG_CF_EIDM
@ SUMO_TAG_CF_PWAGNER2009
@ SUMO_TAG_CF_KRAUSS_ORIG1
@ SUMO_TAG_CF_WIEDEMANN
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_PERSON
@ SUMO_TAG_CF_IDMM
@ SUMO_TAG_CF_DANIEL1
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_CF_ACC
LaneChangeModel
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_TMP4
@ SUMO_ATTR_CF_W99_CC9
@ SUMO_ATTR_GCC_GAIN_GAP_DOT_CACC
@ SUMO_ATTR_CF_EIDM_T_ACC_MAX
@ SUMO_ATTR_CF_EIDM_EPSILON_ACC
@ SUMO_ATTR_CF_W99_CC5
@ SUMO_ATTR_LCA_PUSHY
@ SUMO_ATTR_CF_CC_FLATBED_KP
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_GCC_GAIN_SPEED
@ SUMO_ATTR_EMISSIONCLASS
@ SUMO_ATTR_JM_IGNORE_FOE_SPEED
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_CF_CC_LAMBDA
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_CF_CC_FLATBED_D
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_JM_IGNORE_KEEPCLEAR_TIME
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_LCA_COOPERATIVE_SPEED
@ SUMO_ATTR_CF_EIDM_T_LOOK_AHEAD
@ SUMO_ATTR_CF_CC_FLATBED_KA
@ SUMO_ATTR_CF_CC_PLOEG_KP
@ SUMO_ATTR_CF_WIEDEMANN_SECURITY
@ SUMO_ATTR_LCA_ASSERTIVE
@ SUMO_ATTR_LCA_LANE_DISCIPLINE
@ SUMO_ATTR_TRAIN_TYPE
@ SUMO_ATTR_CF_EIDM_USEVEHDYNAMICS
@ SUMO_ATTR_CF_IDMM_ADAPT_TIME
@ SUMO_ATTR_LANE_CHANGE_MODEL
@ SUMO_ATTR_CF_KERNER_PHI
@ SUMO_ATTR_LCA_TURN_ALIGNMENT_DISTANCE
@ SUMO_ATTR_GC_GAIN_SPACE
@ SUMO_ATTR_JM_STOPLINE_GAP
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_CF_EIDM_C_COOLNESS
@ SUMO_ATTR_CF_EIDM_SIG_ERROR
@ SUMO_ATTR_LCA_PUSHYGAP
@ SUMO_ATTR_CA_GAIN_GAP_CACC
@ SUMO_ATTR_LCA_LOOKAHEADLEFT
@ SUMO_ATTR_APPARENTDECEL
@ SUMO_ATTR_MAXSPEED_LAT
@ SUMO_ATTR_GC_GAIN_GAP_DOT_CACC
@ SUMO_ATTR_LCA_SPEEDGAIN_PARAM
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_TMP3
@ SUMO_ATTR_ACTIONSTEPLENGTH
@ SUMO_ATTR_CF_CC_PLOEG_H
@ SUMO_ATTR_LCA_MAXDISTLATSTANDING
@ SUMO_ATTR_LCA_IMPATIENCE
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_MINGAP
@ SUMO_ATTR_LCA_COOPERATIVE_ROUNDABOUT
@ SUMO_ATTR_CA_GAIN_GAP_DOT_CACC
@ SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME
@ SUMO_ATTR_HEADWAY_TIME_CACC_TO_ACC
@ SUMO_ATTR_CF_CC_OMEGAN
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_CF_CC_C1
@ SUMO_ATTR_TMP2
@ SUMO_ATTR_CF_W99_CC8
@ SUMO_ATTR_CA_GAIN_SPACE
@ SUMO_ATTR_LINE
@ SUMO_ATTR_LOADING_DURATION
@ SUMO_ATTR_CF_IDM_DELTA
@ SUMO_ATTR_CF_EIDM_MAX_VEH_PREVIEW
@ SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD
@ SUMO_ATTR_LCA_MAXSPEEDLATFACTOR
@ SUMO_ATTR_MANEUVER_ANGLE_TIMES
Class specific timing values for vehicle manoeuvering through angle ranges.
@ SUMO_ATTR_CF_CC_CCACCEL
@ SUMO_ATTR_CONTAINERSPERHOUR
@ SUMO_ATTR_CF_EIDM_T_REACTION
@ SUMO_ATTR_CF_EIDM_T_PERSISTENCE_ESTIMATE
@ SUMO_ATTR_CF_PWAGNER2009_TAULAST
@ SUMO_ATTR_CF_CC_PLOEG_KD
@ SUMO_ATTR_CF_CC_TAU
@ SUMO_ATTR_GC_GAIN_GAP_CACC
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_CF_EIDM_SIG_GAP
@ SUMO_ATTR_CAR_FOLLOW_MODEL
@ SUMO_ATTR_CF_EIDM_JERK_MAX
@ SUMO_ATTR_DECEL
@ SUMO_ATTR_LCA_MAXSPEEDLATSTANDING
@ SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME
@ SUMO_ATTR_LCA_KEEPRIGHT_PARAM
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_JM_IGNORE_FOE_PROB
@ SUMO_ATTR_PERHOUR
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_CF_CC_XI
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_LCA_COOPERATIVE_PARAM
@ SUMO_ATTR_LCA_OPPOSITE_PARAM
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_CF_CC_CCDECEL
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_GCC_GAIN_SPACE
@ SUMO_ATTR_MINGAP_LAT
@ SUMO_ATTR_EMERGENCYDECEL
@ SUMO_ATTR_CF_CC_FLATBED_H
@ SUMO_ATTR_CF_W99_CC3
@ SUMO_ATTR_CF_CC_LANES_COUNT
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_LCA_SUBLANE_PARAM
@ SUMO_ATTR_JM_CROSSING_GAP
@ SUMO_ATTR_LCA_SIGMA
@ SUMO_ATTR_LATALIGNMENT
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_CF_IDM_STEPPING
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_CF_IDMM_ADAPT_FACTOR
@ SUMO_ATTR_IMPATIENCE
@ SUMO_ATTR_COLLISION_MINGAP_FACTOR
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_ACCEL
@ SUMO_ATTR_BOARDING_DURATION
@ SUMO_ATTR_CF_CC_CONSTSPACING
@ SUMO_ATTR_CF_EIDM_M_FLATNESS
@ SUMO_ATTR_CF_W99_CC2
@ SUMO_ATTR_CF_W99_CC4
@ SUMO_ATTR_JM_SIGMA_MINOR
@ SUMO_ATTR_CF_W99_CC6
@ SUMO_ATTR_PROB
@ SUMO_ATTR_CF_EIDM_M_BEGIN
@ SUMO_ATTR_CF_EIDM_T_PERSISTENCE_DRIVE
@ SUMO_ATTR_SPEEDFACTOR
@ SUMO_ATTR_CA_GAIN_SPEED
@ SUMO_ATTR_CF_EIDM_SIG_LEADER
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_CF_CC_KP
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_APPLYDRIVERSTATE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_CF_PWAGNER2009_APPROB
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_SIGMA
@ SUMO_ATTR_K
@ SUMO_ATTR_TMP1
@ SUMO_ATTR_OSGFILE
@ SUMO_ATTR_LCA_OVERTAKE_RIGHT
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_LCA_ACCEL_LAT
@ SUMO_ATTR_CF_W99_CC7
@ SUMO_ATTR_LCA_STRATEGIC_PARAM
@ SUMO_ATTR_CF_W99_CC1
@ SUMO_ATTR_TAU
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_JM_IGNORE_JUNCTION_FOE_PROB
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_GC_GAIN_SPEED
@ SUMO_ATTR_GCC_GAIN_GAP_CACC
@ SUMO_ATTR_LCA_KEEPRIGHT_ACCEPTANCE_TIME
@ SUMO_ATTR_LCA_EXPERIMENTAL1
@ SUMO_ATTR_SC_GAIN
@ SUMO_ATTR_TMP5
@ SUMO_ATTR_SC_GAIN_CACC
@ SUMO_ATTR_JM_DRIVE_RED_SPEED
@ SUMO_ATTR_LCA_TIME_TO_IMPATIENCE
@ SUMO_ATTR_JM_TIMEGAP_MINOR
@ SUMO_ATTR_CF_CC_FLATBED_KV
@ SUMO_ATTR_SPEEDDEV
@ SUMO_ATTR_CF_WIEDEMANN_ESTIMATION
@ SUMO_ATTR_PERSONSPERHOUR
@ SUMO_ATTR_LCA_SPEEDGAINRIGHT
T MAX2(T a, T b)
Definition: StdDefs.h:80
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
void parse(const std::string &description, const bool hardFail)
Overwrite by parsable distribution description.
std::vector< double > & getParameter()
Returns the parameters of this distribution.
bool isValid(std::string &error)
check whether the distribution is valid
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
static const RGBColor YELLOW
Definition: RGBColor.h:188
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:199
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:119
Encapsulated SAX-Attributes.
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 std::string & getObjectType() const
return the objecttype to which these attributes belong
virtual std::string getName(int attr) const =0
Converts the given attribute id into a man readable string.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
Structure representing possible vehicle parameter.
double width
This class' width.
SubParams cfParameter
Car-following parameter.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
SUMOTime actionStepLength
The vehicle type's default actionStepLength [ms], i.e. the interval between two control actions....
double height
This class' height.
SUMOEmissionClass emissionClass
The emission class of this vehicle.
double latAlignmentOffset
(optional) The vehicle's desired lateral alignment as offset in m from center line
double length
The physical vehicle length.
double maxSpeedLat
The vehicle type's maximum lateral speed [m/s].
RGBColor color
The color.
double minGap
This class' free space in front of the vehicle itself.
std::string imgFile
Image file for this class.
SUMOVehicleShape shape
This class' shape.
int personCapacity
The person capacity of the vehicle.
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
std::string osgFile
3D model file for this class
double maxSpeed
The vehicle type's maximum speed [m/s].
int parametersSet
Information for the router which parameter were set.
int containerCapacity
The container capacity of the vehicle.
SUMOTime boardingDuration
The time a person needs to board the vehicle.
double minGapLat
The vehicle type's minimum lateral gap [m].
SUMOTime loadingDuration
The time a container needs to get loaded on the vehicle.
std::string id
The vehicle type's id.
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
SubParams lcParameter
Lane-changing parameter.
LatAlignmentDefinition latAlignmentProcedure
Information on how the vehicle shall choose the lateral alignment.
SubParams jmParameter
Junction-model parameter.
double impatience
The vehicle's impatience (willingness to obstruct others)
std::map< int, std::pair< SUMOTime, SUMOTime > > myManoeuverAngleTimes
Map of manoeuver angles versus the times (entry, exit) to execute the manoeuver.
LaneChangeModel lcModel
The lane-change model to use.
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
double repetitionProbability
The probability for emitting a vehicle per second.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
double speedFactor
individual speedFactor (overriding distribution from vType)
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.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
double calibratorSpeed
speed (used by calibrator flows
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.
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
int departEdge
(optional) The initial edge within the route of the vehicle
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseRouteIndex(const std::string &val, const std::string &element, const std::string &id, const SumoXMLAttr attr, int &edgeIndex, RouteIndexDefinition &rid, std::string &error)
Validates a given departEdge or arrivalEdge value.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
static const CFAttrMap & getAllowedCFModelAttrs()
returns allowed attrs for each known CF-model (init on first use)
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
static bool parseLCParams(SUMOVTypeParameter *into, LaneChangeModel model, const SUMOSAXAttributes &attrs)
Parses lane change model attributes.
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Car-Following attributes map.
static std::string parseID(const SUMOSAXAttributes &attrs, const SumoXMLTag element)
parse ID
static bool parseCFMParams(SUMOVTypeParameter *into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool nestedCFM)
Parses Car Following Mode params.
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
Lane-Change-Model attributes map.
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, SUMOVehicleParameter *ret, SumoXMLTag tag)
Parses attributes common to vehicles and flows.
static SUMOVTypeParameter * handleVehicleTypeError(const bool hardFail, SUMOVTypeParameter *vehicleTypeParameter, const std::string message="")
handle error loading SUMOVTypeParameter
static SUMOVehicleParameter * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const bool needID, const SUMOTime beginDefault, const SUMOTime endDefault)
Parses a flow's attributes.
static bool parseAngleTimesMap(SUMOVTypeParameter *vtype, const std::string)
Parse string containing AngleTimes triplets (angle, entry time, exit time)
static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static std::set< SumoXMLAttr > allowedJMAttrs
allowed attrs for the junction model
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, SumoRNG *rng=0)
parse departPos or arrivalPos for a walk
static LCAttrMap allowedLCModelAttrs
allowed attrs for each known LC-model
static SUMOVehicleParameter * handleVehicleError(const bool hardFail, SUMOVehicleParameter *vehicleParameter, const std::string message="")
handle error loading SUMOVehicleParameter
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false)
Parses a vehicle's attributes.
static CFAttrMap allowedCFModelAttrs
allowed attrs for each known CF-model
static bool parseJMParams(SUMOVTypeParameter *into, const SUMOSAXAttributes &attrs)
Parses junction model attributes.
static StringBijection< SumoXMLTag > CarFollowModels
car following models
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static StringBijection< TrainType > TrainTypes
train types
static StringBijection< int > Tags
The names of SUMO-XML elements for use in netbuild.
static StringBijection< LaneChangeModel > LaneChangeModels
lane change models
T get(const std::string &str) const
int size() const
returns the number of existing substrings
std::string get(int pos) const
returns the item at the given position
bool hasNext()
returns the information whether further substrings exist
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...