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
38
40
41
42// ===========================================================================
43// static members
44// ===========================================================================
45
48std::set<SumoXMLAttr> SUMOVehicleParserHelper::allowedJMAttrs;
49
50
51// ===========================================================================
52// method definitions
53// ===========================================================================
54
56SUMOVehicleParserHelper::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) {
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 bool poissonFlow = false;
168 if (hasPeriod) {
169 bool ok = true;
170 const std::string description = attrs.get<std::string>(SUMO_ATTR_PERIOD, id.c_str(), ok);
171 const std::string distName = description.substr(0, description.find('('));
172 if (distName == "exp") {
173 // declare rate
174 double rate = -1;
175 // parse rate
176 try {
177 rate = StringUtils::toDouble(description.substr(distName.size() + 1, description.size() - distName.size() - 2));
178 } catch (ProcessError& attributeError) {
179 // check if continue handling another vehicles or stop handling
180 if (hardFail) {
181 throw ProcessError(attributeError.what());
182 } else {
183 return nullptr;
184 }
185 }
186 if (rate <= 0) {
187 return handleVehicleError(hardFail, flowParameter, "Invalid rate parameter for exponentially distributed period in the definition of " + toString(tag) + " '" + id + "'.");
188 }
189 flowParameter->repetitionOffset = -TIME2STEPS(rate);
190 poissonFlow = true;
191 } else {
192 flowParameter->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok);
193 }
194 if (!ok) {
195 return handleVehicleError(hardFail, flowParameter);
196 } else {
197 flowParameter->parametersSet |= VEHPARS_PERIOD_SET;
198 }
199 }
200 // parse vehicle/person/container/etc per hour
201 if (hasXPH) {
202 bool ok = true;
203 const double vph = attrs.get<double>(PERHOUR, id.c_str(), ok);
204 if (!ok) {
205 return handleVehicleError(hardFail, flowParameter);
206 } else if (vph <= 0) {
207 return handleVehicleError(hardFail, flowParameter, "Invalid repetition rate in the definition of " + toString(tag) + " '" + id + "'.");
208 } else {
209 if (vph != 0) {
210 flowParameter->repetitionOffset = TIME2STEPS(3600. / vph);
211 }
212 flowParameter->parametersSet |= VEHPARS_VPH_SET;
213 }
214 }
215 // parse probability
216 if (hasProb) {
217 bool ok = true;
218 flowParameter->repetitionProbability = attrs.get<double>(SUMO_ATTR_PROB, id.c_str(), ok);
219 if (!ok) {
220 return handleVehicleError(hardFail, flowParameter);
221 } else if (flowParameter->repetitionProbability <= 0 || flowParameter->repetitionProbability > 1) {
222 return handleVehicleError(hardFail, flowParameter, "Invalid repetition probability in the definition of " + toString(tag) + " '" + id + "'.");
223 } else {
224 flowParameter->parametersSet |= VEHPARS_PROB_SET;
225 }
226 }
227 // set default begin
228 flowParameter->depart = beginDefault;
229 // parse begin
230 if (hasBegin) {
231 // first get begin
232 bool ok = true;
233 const std::string begin = attrs.get<std::string>(SUMO_ATTR_BEGIN, id.c_str(), ok);
234 if (!ok) {
235 return handleVehicleError(hardFail, flowParameter);
236 } else {
237 // parse begin
238 std::string errorMsg;
239 if (!SUMOVehicleParameter::parseDepart(begin, toString(tag), id, flowParameter->depart, flowParameter->departProcedure, errorMsg, "begin")) {
240 return handleVehicleError(hardFail, flowParameter, errorMsg);
241 }
242 }
243 }
244 if (flowParameter->depart < 0) {
245 return handleVehicleError(hardFail, flowParameter, "Negative begin time in the definition of " + toString(tag) + " '" + id + "'.");
246 }
247 // set default end
248 flowParameter->repetitionEnd = endDefault;
249 if (flowParameter->repetitionEnd < 0) {
250 flowParameter->repetitionEnd = SUMOTime_MAX;
251 }
252 // parse end
253 if (hasEnd) {
254 bool ok = true;
255 flowParameter->repetitionEnd = attrs.getSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok);
256 if (!ok) {
257 return handleVehicleError(hardFail, flowParameter);
258 } else {
259 flowParameter->parametersSet |= VEHPARS_END_SET;
260 }
261 } else if (flowParameter->departProcedure == DepartDefinition::TRIGGERED) {
262 if (!hasNumber) {
263 return handleVehicleError(hardFail, flowParameter, toString(tag) + " '" + id + "' with triggered begin must define 'number'.");
264 } else {
265 flowParameter->repetitionEnd = flowParameter->depart;
266 }
267 } else if ((endDefault == SUMOTime_MAX || endDefault < 0) && (!hasNumber || (!hasProb && !hasPeriod && !hasXPH))) {
268 WRITE_WARNING("Undefined end for " + toString(tag) + " '" + id + "', defaulting to 24hour duration.");
269 flowParameter->repetitionEnd = flowParameter->depart + TIME2STEPS(24 * 3600);
270 }
271 if (flowParameter->repetitionEnd < flowParameter->depart) {
272 std::string flow = toString(tag);
273 flow[0] = (char)::toupper((char)flow[0]);
274 return handleVehicleError(hardFail, flowParameter, flow + " '" + id + "' ends before its begin time.");
275 }
276 // parse number
277 if (hasNumber) {
278 bool ok = true;
279 flowParameter->repetitionNumber = attrs.get<int>(SUMO_ATTR_NUMBER, id.c_str(), ok);
280 if (!ok) {
281 return handleVehicleError(hardFail, flowParameter);
282 } else {
283 flowParameter->parametersSet |= VEHPARS_NUMBER_SET;
284 if (flowParameter->repetitionNumber == 0) {
285 std::string flow = toString(tag);
286 flow[0] = (char)::toupper((char)flow[0]);
287 WRITE_WARNING(flow + " '" + id + "' has no instances; will skip it.");
288 flowParameter->repetitionEnd = flowParameter->depart;
289 } else {
290 if (flowParameter->repetitionNumber < 0) {
291 return handleVehicleError(hardFail, flowParameter, "Negative repetition number in the definition of " + toString(tag) + " '" + id + "'.");
292 }
293 if (flowParameter->repetitionOffset < 0 && !hasProb) {
294 if (poissonFlow) {
295 flowParameter->repetitionEnd = SUMOTime_MAX;
296 } else {
297 flowParameter->repetitionOffset = (flowParameter->repetitionEnd - flowParameter->depart) / flowParameter->repetitionNumber;
298 }
299 }
300 }
301 }
302 } else {
303 // interpret repetitionNumber
304 if (flowParameter->repetitionProbability > 0) {
305 flowParameter->repetitionNumber = std::numeric_limits<int>::max();
306 } else {
307 if (flowParameter->repetitionOffset <= 0) {
308 if (poissonFlow) {
309 // number is random but flow has a fixed end time
310 flowParameter->repetitionNumber = std::numeric_limits<int>::max();
311 } else {
312 return handleVehicleError(hardFail, flowParameter, "Invalid repetition rate in the definition of " + toString(tag) + " '" + id + "'.");
313 }
314 } else {
315 if (flowParameter->repetitionEnd == SUMOTime_MAX) {
316 flowParameter->repetitionNumber = std::numeric_limits<int>::max();
317 } else {
318 const SUMOTime repLength = flowParameter->repetitionEnd - flowParameter->depart;
319 flowParameter->repetitionNumber = (int)ceil((double)repLength / (double)flowParameter->repetitionOffset);
320 }
321 }
322 }
323 }
324 // all ok, then return flow parameter
325 return flowParameter;
326 } else {
327 return handleVehicleError(hardFail, nullptr, toString(tag) + " cannot be created");
328 }
329}
330
331
333SUMOVehicleParserHelper::parseVehicleAttributes(int element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID, const bool skipDepart) {
334 // declare vehicle ID
335 std::string id;
336 // for certain vehicles, ID can be optional
337 if (optionalID) {
338 bool ok = true;
339 id = attrs.getOpt<std::string>(SUMO_ATTR_ID, nullptr, ok, "");
340 if (!ok) {
341 return handleVehicleError(hardFail, nullptr);
342 }
343 } else {
344 // parse ID
345 id = parseID(attrs, (SumoXMLTag)element);
346 }
347 // only continue if id is valid, or if is optional
348 if (optionalID || !id.empty()) {
349 // declare vehicle parameter
350 SUMOVehicleParameter* vehicleParameter = new SUMOVehicleParameter();
351 vehicleParameter->id = id;
352 if (element == SUMO_TAG_PERSON) {
353 vehicleParameter->vtypeid = DEFAULT_PEDTYPE_ID;
354 } else if (element == SUMO_TAG_CONTAINER) {
355 vehicleParameter->vtypeid = DEFAULT_CONTAINERTYPE_ID;
356 }
357 // parse common attributes
358 try {
359 parseCommonAttributes(attrs, vehicleParameter, (SumoXMLTag)element);
360 } catch (ProcessError& attributeError) {
361 // check if continue handling another vehicles or stop handling
362 if (hardFail) {
363 throw ProcessError(attributeError.what());
364 } else {
365 return nullptr;
366 }
367 }
368 // check depart
369 if (!skipDepart) {
370 bool ok = true;
371 const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPART, vehicleParameter->id.c_str(), ok);
372 if (!ok) {
373 return handleVehicleError(hardFail, vehicleParameter);
374 }
375 // now parse depart
376 std::string departErrorMsg;
377 if (!SUMOVehicleParameter::parseDepart(helper, "vehicle", vehicleParameter->id, vehicleParameter->depart, vehicleParameter->departProcedure, departErrorMsg)) {
378 return handleVehicleError(hardFail, vehicleParameter, departErrorMsg);
379 }
380 }
381 // set tag
382 vehicleParameter->tag = (SumoXMLTag)element;
383 // all ok, then return vehicleParameter
384 return vehicleParameter;
385 } else {
386 return handleVehicleError(hardFail, nullptr, toString((SumoXMLTag)element) + " cannot be created");
387 }
388}
389
390
391std::string
393 bool ok = true;
394 std::string id;
395 // first check if attrs contain an ID
396 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
397 id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
399 return id;
400 } else if (id.empty()) {
401 // add extra information for empty IDs
402 WRITE_ERROR("Invalid " + toString(element) + " id '" + id + "'.");
403 } else {
404 WRITE_ERROR("Invalid " + toString(element) + " id '" + id + "'. Contains invalid characters.");
405 }
406 } else {
407 WRITE_ERROR("Attribute '" + toString(SUMO_ATTR_ID) + "' is missing in definition of " + toString(element));
408 }
409 // return empty (invalid) ID
410 return "";
411}
412
413
414void
416 const std::string element = toString(tag);
417 //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
418 // parse route information
419 if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
420 bool ok = true;
421 ret->routeid = attrs.get<std::string>(SUMO_ATTR_ROUTE, ret->id.c_str(), ok);
422 if (ok) {
423 ret->parametersSet |= VEHPARS_ROUTE_SET; // !!! needed?
424 } else {
425 handleVehicleError(true, ret);
426 }
427 }
428 // parse type information
429 if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
430 bool ok = true;
431 ret->vtypeid = attrs.get<std::string>(SUMO_ATTR_TYPE, ret->id.c_str(), ok);
432 if (ok) {
433 ret->parametersSet |= VEHPARS_VTYPE_SET; // !!! needed?
434 } else {
435 handleVehicleError(true, ret);
436 }
437 }
438 // parse line information
439 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
440 bool ok = true;
441 ret->line = attrs.get<std::string>(SUMO_ATTR_LINE, ret->id.c_str(), ok);
442 if (ok) {
443 ret->parametersSet |= VEHPARS_LINE_SET; // !!! needed?
444 } else {
445 handleVehicleError(true, ret);
446 }
447 }
448 // parse zone information
449 if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ)) {
450 bool ok = true;
451 ret->fromTaz = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, ret->id.c_str(), ok);
452 if (ok) {
454 } else {
455 handleVehicleError(true, ret);
456 }
457 }
458 if (attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
459 bool ok = true;
460 ret->toTaz = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, ret->id.c_str(), ok);
461 if (ok) {
463 } else {
464 handleVehicleError(true, ret);
465 }
466 }
467 // parse reroute information
468 if (attrs.hasAttribute(SUMO_ATTR_REROUTE)) {
469 bool ok = true;
470 if (attrs.get<bool>(SUMO_ATTR_REROUTE, ret->id.c_str(), ok)) {
471 if (ok) {
473 } else {
474 handleVehicleError(true, ret);
475 }
476 }
477 }
478 // parse depart lane information
480 bool ok = true;
481 const std::string departLaneStr = attrs.get<std::string>(SUMO_ATTR_DEPARTLANE, ret->id.c_str(), ok);
482 int lane;
484 std::string error;
485 if (SUMOVehicleParameter::parseDepartLane(departLaneStr, element, ret->id, lane, dld, error)) {
487 ret->departLane = lane;
488 ret->departLaneProcedure = dld;
489 } else {
490 handleVehicleError(true, ret, error);
491 }
492 }
493 // parse depart position information
495 bool ok = true;
496 const std::string departPosStr = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS, ret->id.c_str(), ok);
497 double pos;
499 std::string error;
500 if (SUMOVehicleParameter::parseDepartPos(departPosStr, element, ret->id, pos, dpd, error)) {
502 ret->departPos = pos;
503 ret->departPosProcedure = dpd;
504 } else {
505 handleVehicleError(true, ret, error);
506 }
507 }
508 // parse lateral depart position information
510 bool ok = true;
511 const std::string departPosLatStr = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS_LAT, ret->id.c_str(), ok);
512 double pos;
514 std::string error;
515 if (SUMOVehicleParameter::parseDepartPosLat(departPosLatStr, element, ret->id, pos, dpd, error)) {
517 ret->departPosLat = pos;
518 ret->departPosLatProcedure = dpd;
519 } else {
520 handleVehicleError(true, ret, error);
521 }
522 }
523 // parse depart speed information
525 bool ok = true;
526 const std::string departSpeed = attrs.get<std::string>(SUMO_ATTR_DEPARTSPEED, ret->id.c_str(), ok);
527 double speed;
529 std::string error;
530 if (SUMOVehicleParameter::parseDepartSpeed(departSpeed, element, ret->id, speed, dsd, error)) {
532 ret->departSpeed = speed;
533 ret->departSpeedProcedure = dsd;
534 } else {
535 handleVehicleError(true, ret, error);
536 }
537 }
538 // parse depart edge information
540 bool ok = true;
541 const std::string departEdgeStr = attrs.get<std::string>(SUMO_ATTR_DEPARTEDGE, ret->id.c_str(), ok);
542 int edgeIndex;
544 std::string error;
545 if (SUMOVehicleParameter::parseRouteIndex(departEdgeStr, element, ret->id, SUMO_ATTR_DEPARTEDGE, edgeIndex, rid, error)) {
547 ret->departEdge = edgeIndex;
548 ret->departEdgeProcedure = rid;
549 } else {
550 handleVehicleError(true, ret, error);
551 }
552 }
553 // parse arrival lane information
555 bool ok = true;
556 const std::string arrivalLaneStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALLANE, ret->id.c_str(), ok);
557 int lane;
559 std::string error;
560 if (SUMOVehicleParameter::parseArrivalLane(arrivalLaneStr, element, ret->id, lane, ald, error)) {
562 ret->arrivalLane = lane;
563 ret->arrivalLaneProcedure = ald;
564 } else {
565 handleVehicleError(true, ret, error);
566 }
567 }
568 // parse arrival position information
570 bool ok = true;
571 const std::string arrivalPosStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, ret->id.c_str(), ok);
572 double pos;
574 std::string error;
575 if (SUMOVehicleParameter::parseArrivalPos(arrivalPosStr, element, ret->id, pos, apd, error)) {
577 ret->arrivalPos = pos;
578 ret->arrivalPosProcedure = apd;
579 } else {
580 handleVehicleError(true, ret, error);
581 }
582 }
583 // parse lateral arrival position information
585 bool ok = true;
586 const std::string arrivalPosLatStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS_LAT, ret->id.c_str(), ok);
587 double pos;
589 std::string error;
590 if (SUMOVehicleParameter::parseArrivalPosLat(arrivalPosLatStr, element, ret->id, pos, apd, error)) {
592 ret->arrivalPosLat = pos;
593 ret->arrivalPosLatProcedure = apd;
594 } else {
595 handleVehicleError(true, ret, error);
596 }
597 }
598 // parse arrival speed information
600 bool ok = true;
601 std::string arrivalSpeedStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALSPEED, ret->id.c_str(), ok);
602 double speed;
604 std::string error;
605 if (SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeedStr, element, ret->id, speed, asd, error)) {
607 ret->arrivalSpeed = speed;
608 ret->arrivalSpeedProcedure = asd;
609 } else {
610 handleVehicleError(true, ret, error);
611 }
612 }
613 // parse arrival edge information
615 bool ok = true;
616 std::string arrivalEdgeStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALEDGE, ret->id.c_str(), ok);
617 int edgeIndex;
619 std::string error;
620 if (SUMOVehicleParameter::parseRouteIndex(arrivalEdgeStr, element, ret->id, SUMO_ATTR_ARRIVALEDGE, edgeIndex, rid, error)) {
622 ret->arrivalEdge = edgeIndex;
623 ret->arrivalEdgeProcedure = rid;
624 } else {
625 handleVehicleError(true, ret, error);
626 }
627 }
628 // parse color
629 if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
630 bool ok = true;
631 ret->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, ret->id.c_str(), ok);
632 if (ok) {
634 } else {
635 handleVehicleError(true, ret, "Invalid RGBColor format");
636 }
637 } else {
639 }
640 // parse person number
642 bool ok = true;
643 int personNumber = attrs.get<int>(SUMO_ATTR_PERSON_NUMBER, ret->id.c_str(), ok);
644 if (!ok) {
645 handleVehicleError(true, ret);
646 } else if (personNumber >= 0) {
648 ret->personNumber = personNumber;
649 } else {
650 handleVehicleError(true, ret, toString(SUMO_ATTR_PERSON_NUMBER) + " cannot be negative");
651 }
652 }
653 // parse container number
655 bool ok = true;
656 int containerNumber = attrs.get<int>(SUMO_ATTR_CONTAINER_NUMBER, ret->id.c_str(), ok);
657 if (!ok) {
658 handleVehicleError(true, ret);
659 } else if (containerNumber >= 0) {
661 ret->containerNumber = containerNumber;
662 } else {
663 handleVehicleError(true, ret, toString(SUMO_ATTR_CONTAINER_NUMBER) + " cannot be negative");
664 }
665 }
666 // parse individual speedFactor
668 bool ok = true;
669 double speedFactor = attrs.get<double>(SUMO_ATTR_SPEEDFACTOR, ret->id.c_str(), ok);
670 if (!ok) {
671 handleVehicleError(true, ret);
672 } else if (speedFactor > 0) {
674 ret->speedFactor = speedFactor;
675 } else {
676 handleVehicleError(true, ret, toString(SUMO_ATTR_SPEEDFACTOR) + " must be positive");
677 }
678 }
679 // parse insertion checks
681 ret->insertionChecks = 0;
682 bool ok = true;
683 std::vector<std::string> checks = attrs.get<std::vector<std::string> >(SUMO_ATTR_INSERTIONCHECKS, ret->id.c_str(), ok);
684 if (!ok) {
685 handleVehicleError(true, ret);
686 } else {
687 for (std::string check : checks) {
688 if (!SUMOXMLDefinitions::InsertionChecks.hasString(check)) {
689 handleVehicleError(true, ret, "Unknown value '" + check + "' in " + toString(SUMO_ATTR_INSERTIONCHECKS));
690 }
692 }
693 }
694 }
695 // parse speed (only used by calibrators flow)
696 // also used by vehicle in saved state but this is parsed elsewhere
697 if (tag == SUMO_TAG_FLOW && attrs.hasAttribute(SUMO_ATTR_SPEED)) {
698 bool ok = true;
699 double calibratorSpeed = attrs.get<double>(SUMO_ATTR_SPEED, ret->id.c_str(), ok);
700 if (!ok) {
701 handleVehicleError(true, ret);
702 } else if (calibratorSpeed >= 0 || calibratorSpeed == -1) {
704 ret->calibratorSpeed = calibratorSpeed;
705 } else {
706 handleVehicleError(true, ret, toString(SUMO_ATTR_SPEED) + " may not be negative");
707 }
708 }
709 /*/ parse via
710 if (attrs.hasAttribute(SUMO_ATTR_VIA)) {
711 ret->setParameter |= VEHPARS_VIA_SET;
712 SUMOSAXAttributes::parseStringVector(attrs.get<std::string>(SUMO_ATTR_VIA, ret->id.c_str(), ok), ret->via);
713 }
714 */
715}
716
717
719SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file) {
720 // first obtain ID
721 std::string id = parseID(attrs, SUMO_TAG_VTYPE);
722 // check if ID is valid
723 if (!id.empty()) {
725 if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
726 vClass = parseVehicleClass(attrs, id);
727 }
728 // create vType
729 SUMOVTypeParameter* vType = new SUMOVTypeParameter(id, vClass);
730 // parse attributes
731 if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
733 }
734 if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
735 bool ok = true;
736 const double length = attrs.get<double>(SUMO_ATTR_LENGTH, vType->id.c_str(), ok);
737 if (!ok) {
738 return handleVehicleTypeError(hardFail, vType);
739 } else if (length <= 0) {
740 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_LENGTH) + " must be greater than 0");
741 } else {
742 vType->length = length;
744 }
745 }
746 if (attrs.hasAttribute(SUMO_ATTR_MINGAP)) {
747 bool ok = true;
748 const double minGap = attrs.get<double>(SUMO_ATTR_MINGAP, vType->id.c_str(), ok);
749 if (!ok) {
750 return handleVehicleTypeError(hardFail, vType);
751 } else if (minGap < 0) {
752 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MINGAP) + " must be equal or greater than 0");
753 } else {
754 vType->minGap = minGap;
756 }
757 }
758 if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
759 bool ok = true;
760 const double maxSpeed = attrs.get<double>(SUMO_ATTR_MAXSPEED, vType->id.c_str(), ok);
761 if (!ok) {
762 return handleVehicleTypeError(hardFail, vType);
763 } else if (maxSpeed <= 0) {
764 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MAXSPEED) + " must be greater than 0");
765 } else {
766 vType->maxSpeed = maxSpeed;
768 }
769 }
771 bool ok = true;
772 const double desiredMaxSpeed = attrs.get<double>(SUMO_ATTR_DESIRED_MAXSPEED, vType->id.c_str(), ok);
773 if (!ok) {
774 return handleVehicleTypeError(hardFail, vType);
775 } else if (desiredMaxSpeed <= 0) {
776 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_DESIRED_MAXSPEED) + " must be greater than 0");
777 } else {
778 vType->desiredMaxSpeed = desiredMaxSpeed;
780 }
781 } else if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
782 if (vClass == SVC_PEDESTRIAN) {
783 // backward compatibility because pedestrian maxSpeed was subject to speedFactor up to 1.14.1
784 vType->desiredMaxSpeed = vType->maxSpeed;;
786 } else if (vClass == SVC_BICYCLE) {
787 // backward compatibility because default desired speed did not exist up to 1.14.1
788 vType->desiredMaxSpeed = MAX2(vType->maxSpeed, vType->desiredMaxSpeed);
789 }
790 }
791
793 bool ok = true;
794 vType->speedFactor.parse(attrs.get<std::string>(SUMO_ATTR_SPEEDFACTOR, vType->id.c_str(), ok), hardFail);
795 if (!ok) {
796 return handleVehicleTypeError(hardFail, vType);
797 } else {
799 }
800 }
801 if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
802 bool ok = true;
803 const double speedDev = attrs.get<double>(SUMO_ATTR_SPEEDDEV, vType->id.c_str(), ok);
804 if (!ok) {
805 return handleVehicleTypeError(hardFail, vType);
806 } else if (speedDev < 0) {
807 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_SPEEDDEV) + " must be equal or greater than 0");
808 } else {
809 vType->speedFactor.getParameter()[1] = speedDev;
811 }
812 }
813 // validate speed distribution
814 std::string error;
815 if (!vType->speedFactor.isValid(error)) {
816 return handleVehicleTypeError(hardFail, vType, "Invalid speed distribution when parsing vType '" + vType->id + "' (" + error + ")");
817 }
819 bool ok = true;
820 const double actionStepLengthSecs = attrs.get<double>(SUMO_ATTR_ACTIONSTEPLENGTH, vType->id.c_str(), ok);
821 if (!ok) {
822 return handleVehicleTypeError(hardFail, vType);
823 } else {
824 // processActionStepLength(...) function includes warnings
825 vType->actionStepLength = processActionStepLength(actionStepLengthSecs);
827 }
828 }
830 bool ok = true;
831 const std::string parsedEmissionClass = attrs.getOpt<std::string>(SUMO_ATTR_EMISSIONCLASS, id.c_str(), ok, "");
832 // check if emission class is correct
833 try {
834 vType->emissionClass = PollutantsInterface::getClassByName(parsedEmissionClass);
836 } catch (...) {
837 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_EMISSIONCLASS) + " with name '" + parsedEmissionClass + "' doesn't exist.");
838 }
839 }
841 bool ok = true;
842 const std::string impatienceStr = attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
843 if (!ok) {
844 return handleVehicleTypeError(hardFail, vType);
845 } else if (impatienceStr == "off") {
846 vType->impatience = -std::numeric_limits<double>::max();
847 } else {
848 const double impatienceDouble = attrs.get<double>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
849 if (!ok) {
850 return handleVehicleTypeError(hardFail, vType);
851 } else {
852 vType->impatience = impatienceDouble;
854 }
855 }
856 }
857 if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
858 bool ok = true;
859 const double width = attrs.get<double>(SUMO_ATTR_WIDTH, vType->id.c_str(), ok);
860 if (!ok) {
861 return handleVehicleTypeError(hardFail, vType);
862 } else if (width <= 0) {
863 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_WIDTH) + " must be greater than 0");
864 } else {
865 vType->width = width;
867 if (vClass == SVC_PEDESTRIAN
868 && OptionsCont::getOptions().exists("pedestrian.striping.stripe-width")
869 && OptionsCont::getOptions().getString("pedestrian.model") == "striping"
870 && OptionsCont::getOptions().getFloat("pedestrian.striping.stripe-width") < vType->width) {
871 WRITE_WARNINGF(TL("Pedestrian vType '%' width % is larger than pedestrian.striping.stripe-width and this may cause collisions with vehicles."), id, vType->width);
872 }
873 }
874 }
875 if (attrs.hasAttribute(SUMO_ATTR_HEIGHT)) {
876 bool ok = true;
877 const double height = attrs.get<double>(SUMO_ATTR_HEIGHT, vType->id.c_str(), ok);
878 if (!ok) {
879 return handleVehicleTypeError(hardFail, vType);
880 } else if (height < 0) {
881 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_HEIGHT) + " must be equal or greater than 0");
882 } else {
883 vType->height = height;
885 }
886 }
887 if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
888 vType->shape = parseGuiShape(attrs, vType->id);
889 if (vType->shape != SUMOVehicleShape::UNKNOWN) {
891 }
892 }
893 if (attrs.hasAttribute(SUMO_ATTR_OSGFILE)) {
894 bool ok = true;
895 const std::string osgFile = attrs.get<std::string>(SUMO_ATTR_OSGFILE, vType->id.c_str(), ok);
896 if (!ok) {
897 return handleVehicleTypeError(hardFail, vType);
898 } else {
899 vType->osgFile = osgFile;
901 }
902 }
903 if (attrs.hasAttribute(SUMO_ATTR_IMGFILE)) {
904 bool ok = true;
905 std::string imgFile = attrs.get<std::string>(SUMO_ATTR_IMGFILE, vType->id.c_str(), ok);
906 if (!ok) {
907 return handleVehicleTypeError(hardFail, vType);
908 } else {
909 // check relative path
910 if ((imgFile != "") && !FileHelpers::isAbsolute(imgFile)) {
911 imgFile = FileHelpers::getConfigurationRelative(file, imgFile);
912 }
913 vType->imgFile = imgFile;
915 }
916 }
917 if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
918 bool ok = true;
919 const RGBColor color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, vType->id.c_str(), ok);
920 if (!ok) {
921 return handleVehicleTypeError(hardFail, vType);
922 } else {
923 vType->color = color;
925 }
926 } else {
927 vType->color = RGBColor::YELLOW;
928 }
929 if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
930 bool ok = true;
931 const double defaultProbability = attrs.get<double>(SUMO_ATTR_PROB, vType->id.c_str(), ok);
932 if (!ok) {
933 return handleVehicleTypeError(hardFail, vType);
934 } else if (defaultProbability < 0) {
935 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_PROB) + " must be equal or greater than 0");
936 } else {
937 vType->defaultProbability = defaultProbability;
939 }
940 }
942 bool ok = true;
943 std::string lcmS = attrs.get<std::string>(SUMO_ATTR_LANE_CHANGE_MODEL, vType->id.c_str(), ok);
944 if (!ok) {
945 return handleVehicleTypeError(hardFail, vType);
946 } else if (lcmS == "JE2013") {
947 WRITE_WARNING(TL("Lane change model 'JE2013' is deprecated. Using default model instead."));
948 lcmS = "default";
949 }
950 if (SUMOXMLDefinitions::LaneChangeModels.hasString(lcmS)) {
953 } else {
954 return handleVehicleTypeError(hardFail, vType, "Unknown lane change model '" + lcmS + "' when parsing vType '" + vType->id + "'");
955 }
956 }
958 bool ok = true;
959 const std::string cfmValue = attrs.get<std::string>(SUMO_ATTR_CAR_FOLLOW_MODEL, vType->id.c_str(), ok);
960 if (!ok) {
961 return handleVehicleTypeError(hardFail, vType);
962 } else if (SUMOXMLDefinitions::CarFollowModels.hasString(cfmValue)) {
965 } else {
966 return handleVehicleTypeError(hardFail, vType, "Unknown car following model '" + cfmValue + "' when parsing vType '" + vType->id + "'");
967 }
968 }
970 bool ok = true;
971 const int personCapacity = attrs.get<int>(SUMO_ATTR_PERSON_CAPACITY, vType->id.c_str(), ok);
972 if (!ok) {
973 return handleVehicleTypeError(hardFail, vType);
974 } else if (personCapacity < 0) {
975 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_PERSON_CAPACITY) + " must be equal or greater than 0");
976 } else {
977 vType->personCapacity = personCapacity;
979 }
980 }
982 bool ok = true;
983 const int containerCapacity = attrs.get<int>(SUMO_ATTR_CONTAINER_CAPACITY, vType->id.c_str(), ok);
984 if (!ok) {
985 return handleVehicleTypeError(hardFail, vType);
986 } else if (containerCapacity < 0) {
987 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_CONTAINER_CAPACITY) + " must be equal or greater than 0");
988 } else {
989 vType->containerCapacity = containerCapacity;
991 }
992 }
994 bool ok = true;
995 const SUMOTime boardingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_BOARDING_DURATION, vType->id.c_str(), ok);
996 if (!ok) {
997 return handleVehicleTypeError(hardFail, vType);
998 } else if (boardingDuration < 0) {
999 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_BOARDING_DURATION) + " must be equal or greater than 0");
1000 } else {
1001 vType->boardingDuration = boardingDuration;
1003 }
1004 }
1006 bool ok = true;
1007 const SUMOTime loadingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_LOADING_DURATION, vType->id.c_str(), ok);
1008 if (!ok) {
1009 return handleVehicleTypeError(hardFail, vType);
1010 } else if (loadingDuration < 0) {
1011 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_LOADING_DURATION) + " must be equal or greater than 0");
1012 } else {
1013 vType->loadingDuration = loadingDuration;
1015 }
1016 }
1017 if (attrs.hasAttribute(SUMO_ATTR_SCALE)) {
1018 bool ok = true;
1019 const double scale = attrs.get<double>(SUMO_ATTR_SCALE, id.c_str(), ok);
1020 if (!ok) {
1021 return handleVehicleTypeError(hardFail, vType);
1022 } else if (scale < 0) {
1023 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_SCALE) + " may be not be negative");
1024 } else {
1025 vType->scale = scale;
1027 }
1028 }
1030 bool ok = true;
1031 const SUMOTime ttt = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME_TO_TELEPORT, vType->id.c_str(), ok);
1032 if (!ok) {
1033 return handleVehicleTypeError(hardFail, vType);
1034 } else {
1035 vType->timeToTeleport = ttt;
1037 }
1038 }
1040 bool ok = true;
1041 const SUMOTime tttb = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME_TO_TELEPORT_BIDI, vType->id.c_str(), ok);
1042 if (!ok) {
1043 return handleVehicleTypeError(hardFail, vType);
1044 } else {
1045 vType->timeToTeleportBidi = tttb;
1047 }
1048 }
1050 bool ok = true;
1051 const double maxSpeedLat = attrs.get<double>(SUMO_ATTR_MAXSPEED_LAT, vType->id.c_str(), ok);
1052 if (!ok) {
1053 return handleVehicleTypeError(hardFail, vType);
1054 } else if (maxSpeedLat <= 0) {
1055 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MAXSPEED_LAT) + " must be greater than 0");
1056 } else {
1057 vType->maxSpeedLat = maxSpeedLat;
1059 }
1060 }
1062 bool ok = true;
1063 const double minGapLat = attrs.get<double>(SUMO_ATTR_MINGAP_LAT, vType->id.c_str(), ok);
1064 if (!ok) {
1065 return handleVehicleTypeError(hardFail, vType);
1066 } else if (minGapLat < 0) {
1067 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MINGAP_LAT) + " must be equal or greater than 0");
1068 } else {
1069 vType->minGapLat = minGapLat;
1071 }
1072 }
1074 bool ok = true;
1075 const std::string alignS = attrs.get<std::string>(SUMO_ATTR_LATALIGNMENT, vType->id.c_str(), ok);
1076 if (!ok) {
1077 return handleVehicleTypeError(hardFail, vType);
1078 } else {
1079 double lao;
1081 if (SUMOVTypeParameter::parseLatAlignment(alignS, lao, lad)) {
1082 vType->latAlignmentOffset = lao;
1083 vType->latAlignmentProcedure = lad;
1085 } else {
1086 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)");
1087 }
1088 }
1089 }
1091 bool ok = true;
1092 const std::string angleTimesS = attrs.get<std::string>(SUMO_ATTR_MANEUVER_ANGLE_TIMES, vType->id.c_str(), ok);
1093 if (!ok) {
1094 return handleVehicleTypeError(hardFail, vType);
1095 } else if (parseAngleTimesMap(vType, angleTimesS)) {
1097 } else {
1098 return handleVehicleTypeError(hardFail, vType, "Invalid manoeuver angle times map for vType '" + vType->id + "'");
1099 }
1100 }
1101 // try to parse Car Following Model params
1102 if (!parseCFMParams(vType, vType->cfModel, attrs, false)) {
1103 return handleVehicleTypeError(hardFail, vType, "Invalid parsing embedded VType");
1104 }
1105 // try to parse Lane Change Model params
1106 if (!parseLCParams(vType, vType->lcModel, attrs)) {
1107 return handleVehicleTypeError(hardFail, vType, "Invalid Lane Change Model Parameters");
1108 }
1109 // try to Junction Model params
1110 if (!parseJMParams(vType, attrs)) {
1111 return handleVehicleTypeError(hardFail, vType, "Invalid Junction Model Parameters");
1112 }
1113 // all ok, then return vType
1114 return vType;
1115 } else {
1116 return handleVehicleTypeError(hardFail, nullptr, "VType cannot be created");
1117 }
1118}
1119
1120
1121bool
1123 StringTokenizer st(atm, ",");
1124 std::map<int, std::pair<SUMOTime, SUMOTime>> angleTimesMap;
1125 int tripletCount = 0;
1126 while (st.hasNext()) {
1127 StringTokenizer pos(st.next());
1128 if (pos.size() != 3) {
1129 WRITE_ERROR("maneuverAngleTimes format for vType '" + vtype->id + "' " + atm + " contains an invalid triplet.");
1130 return false;
1131 } else {
1132 try {
1133 const int angle = StringUtils::toInt(pos.next());
1134 const SUMOTime t1 = string2time(pos.next());
1135 const SUMOTime t2 = string2time(pos.next());
1136 angleTimesMap[angle] = std::make_pair(t1, t2);
1137 } catch (...) {
1138 WRITE_ERROR("Triplet '" + st.get(tripletCount) + "' for vType '" + vtype->id + "' maneuverAngleTimes cannot be parsed as 'int double double'");
1139 return false;
1140 }
1141 tripletCount++;
1142 }
1143 }
1144 if (angleTimesMap.size() > 0) {
1145 vtype->myManoeuverAngleTimes.clear();
1146 for (const auto& angleTime : angleTimesMap) {
1147 vtype->myManoeuverAngleTimes.insert(angleTime);
1148 }
1149 angleTimesMap.clear();
1150 return true;
1151 } else {
1152 return false;
1153 }
1154}
1155
1156
1157bool
1158SUMOVehicleParserHelper::parseCFMParams(SUMOVTypeParameter* into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool nestedCFM) {
1159 const CFAttrMap& allowedCFM = getAllowedCFModelAttrs();
1160 CFAttrMap::const_iterator cf_it = allowedCFM.find(element);
1161 // check if given CFM is allowed
1162 if (cf_it == allowedCFM.end()) {
1163 if (SUMOXMLDefinitions::Tags.has((int)element)) {
1164 WRITE_ERROR("Unknown car following model " + toString(element) + " when parsing vType '" + into->id + "'");
1165 } else {
1166 WRITE_ERROR("Unknown car following model when parsing vType '" + into->id + "'");
1167 }
1168 return false;
1169 }
1170 // check if we're parsing a nested CFM
1171 if (nestedCFM) {
1172 into->cfModel = cf_it->first;
1174 }
1175 // set CFM values
1176 for (const auto& it : cf_it->second) {
1177 if (attrs.hasAttribute(it)) {
1178 // first obtain CFM attribute in string format
1179 bool ok = true;
1180 std::string parsedCFMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1181 // check CFM Attribute
1182 if (!ok) {
1183 return false;
1184 } else if (it == SUMO_ATTR_TRAIN_TYPE) {
1185 // check if train value is valid
1186 if (!SUMOXMLDefinitions::TrainTypes.hasString(parsedCFMAttribute)) {
1187 WRITE_ERROR("Invalid train type '" + parsedCFMAttribute + "' used in Car-Following-Attribute " + toString(it));
1188 return false;
1189 }
1190 // add parsedCFMAttribute to cfParameter
1191 into->cfParameter[it] = parsedCFMAttribute;
1192 } else if (it == SUMO_ATTR_CF_IDM_STEPPING) {
1193 // declare a int in wich save CFM int attribute
1194 double CFMDoubleAttribute = -1;
1195 try {
1196 // obtain CFM attribute in int format
1197 CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
1198 } catch (...) {
1199 WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1200 return false;
1201 }
1202 if (CFMDoubleAttribute <= 0) {
1203 WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
1204 return false;
1205 }
1206 // add parsedCFMAttribute to cfParameter
1207 into->cfParameter[it] = parsedCFMAttribute;
1208 } else {
1209 // declare a double in wich save CFM float attribute
1210 double CFMDoubleAttribute = -1;
1211 try {
1212 // obtain CFM attribute in double format
1213 CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
1214 } catch (...) {
1215 WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1216 return false;
1217 }
1218 // check attributes of type "positiveFloatType" (> 0)
1219 switch (it) {
1220 case SUMO_ATTR_ACCEL:
1221 case SUMO_ATTR_DECEL:
1224 case SUMO_ATTR_TAU:
1225 if (CFMDoubleAttribute <= 0) {
1226 WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Must be greater than 0");
1227 return false;
1228 }
1229 break;
1230 default:
1231 break;
1232 }
1233 // check attributes restricted to [0-1]
1234 switch (it) {
1235 case SUMO_ATTR_SIGMA:
1236 if ((CFMDoubleAttribute < 0) || (CFMDoubleAttribute > 1)) {
1237 WRITE_ERROR("Invalid Car-Following-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
1238 return false;
1239 }
1240 break;
1241 default:
1242 break;
1243 }
1244 // add parsedCFMAttribute to cfParameter
1245 into->cfParameter[it] = parsedCFMAttribute;
1246 }
1247 }
1248 }
1249 // all CFM successfully parsed, then return true
1250 return true;
1251}
1252
1253
1256 // init on first use
1257 if (allowedCFModelAttrs.size() == 0) {
1258 std::set<SumoXMLAttr> genericParams;
1259 genericParams.insert(SUMO_ATTR_TAU);
1260 genericParams.insert(SUMO_ATTR_ACCEL);
1261 genericParams.insert(SUMO_ATTR_DECEL);
1262 genericParams.insert(SUMO_ATTR_APPARENTDECEL);
1263 genericParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1264 genericParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1265 genericParams.insert(SUMO_ATTR_STARTUP_DELAY);
1266 // Krauss
1267 std::set<SumoXMLAttr> kraussParams(genericParams);
1268 kraussParams.insert(SUMO_ATTR_SIGMA);
1269 kraussParams.insert(SUMO_ATTR_SIGMA_STEP);
1273 std::set<SumoXMLAttr> allParams(kraussParams);
1274 // KraussX
1275 std::set<SumoXMLAttr> kraussXParams(kraussParams);
1276 kraussXParams.insert(SUMO_ATTR_TMP1);
1277 kraussXParams.insert(SUMO_ATTR_TMP2);
1278 kraussXParams.insert(SUMO_ATTR_TMP3);
1279 kraussXParams.insert(SUMO_ATTR_TMP4);
1280 kraussXParams.insert(SUMO_ATTR_TMP5);
1282 allParams.insert(kraussXParams.begin(), kraussXParams.end());
1283 // SmartSK
1284 std::set<SumoXMLAttr> smartSKParams(genericParams);
1285 smartSKParams.insert(SUMO_ATTR_SIGMA);
1286 smartSKParams.insert(SUMO_ATTR_TMP1);
1287 smartSKParams.insert(SUMO_ATTR_TMP2);
1288 smartSKParams.insert(SUMO_ATTR_TMP3);
1289 smartSKParams.insert(SUMO_ATTR_TMP4);
1290 smartSKParams.insert(SUMO_ATTR_TMP5);
1292 allParams.insert(smartSKParams.begin(), smartSKParams.end());
1293 // Daniel
1294 std::set<SumoXMLAttr> daniel1Params(genericParams);
1295 daniel1Params.insert(SUMO_ATTR_SIGMA);
1296 daniel1Params.insert(SUMO_ATTR_TMP1);
1297 daniel1Params.insert(SUMO_ATTR_TMP2);
1298 daniel1Params.insert(SUMO_ATTR_TMP3);
1299 daniel1Params.insert(SUMO_ATTR_TMP4);
1300 daniel1Params.insert(SUMO_ATTR_TMP5);
1302 allParams.insert(daniel1Params.begin(), daniel1Params.end());
1303 // Peter Wagner
1304 std::set<SumoXMLAttr> pwagParams(genericParams);
1305 pwagParams.insert(SUMO_ATTR_SIGMA);
1306 pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_TAULAST);
1307 pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_APPROB);
1309 allParams.insert(pwagParams.begin(), pwagParams.end());
1310 // IDM params
1311 std::set<SumoXMLAttr> idmParams(genericParams);
1312 idmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1313 idmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1315 allParams.insert(idmParams.begin(), idmParams.end());
1316 // EIDM
1317 std::set<SumoXMLAttr> eidmParams(genericParams);
1318 eidmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1319 eidmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1320 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_LOOK_AHEAD);
1321 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_PERSISTENCE_DRIVE);
1322 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_REACTION);
1324 eidmParams.insert(SUMO_ATTR_CF_EIDM_C_COOLNESS);
1325 eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_LEADER);
1326 eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_GAP);
1327 eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_ERROR);
1328 eidmParams.insert(SUMO_ATTR_CF_EIDM_JERK_MAX);
1329 eidmParams.insert(SUMO_ATTR_CF_EIDM_EPSILON_ACC);
1330 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_ACC_MAX);
1331 eidmParams.insert(SUMO_ATTR_CF_EIDM_M_FLATNESS);
1332 eidmParams.insert(SUMO_ATTR_CF_EIDM_M_BEGIN);
1333 eidmParams.insert(SUMO_ATTR_CF_EIDM_USEVEHDYNAMICS);
1334 eidmParams.insert(SUMO_ATTR_CF_EIDM_MAX_VEH_PREVIEW);
1336 allParams.insert(eidmParams.begin(), eidmParams.end());
1337 // IDMM
1338 std::set<SumoXMLAttr> idmmParams(genericParams);
1339 idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_FACTOR);
1340 idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_TIME);
1341 idmmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1343 allParams.insert(idmmParams.begin(), idmmParams.end());
1344 // Bieker
1345 std::set<SumoXMLAttr> bkernerParams(genericParams);
1346 bkernerParams.insert(SUMO_ATTR_K);
1347 bkernerParams.insert(SUMO_ATTR_CF_KERNER_PHI);
1349 allParams.insert(bkernerParams.begin(), bkernerParams.end());
1350 // Wiedemann
1351 std::set<SumoXMLAttr> wiedemannParams(genericParams);
1352 wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_SECURITY);
1353 wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_ESTIMATION);
1354 allowedCFModelAttrs[SUMO_TAG_CF_WIEDEMANN] = wiedemannParams;
1355 allParams.insert(wiedemannParams.begin(), wiedemannParams.end());
1356 // W99
1357 std::set<SumoXMLAttr> w99Params(genericParams);
1358 w99Params.insert(SUMO_ATTR_CF_W99_CC1);
1359 w99Params.insert(SUMO_ATTR_CF_W99_CC2);
1360 w99Params.insert(SUMO_ATTR_CF_W99_CC3);
1361 w99Params.insert(SUMO_ATTR_CF_W99_CC4);
1362 w99Params.insert(SUMO_ATTR_CF_W99_CC5);
1363 w99Params.insert(SUMO_ATTR_CF_W99_CC6);
1364 w99Params.insert(SUMO_ATTR_CF_W99_CC7);
1365 w99Params.insert(SUMO_ATTR_CF_W99_CC8);
1366 w99Params.insert(SUMO_ATTR_CF_W99_CC9);
1368 allParams.insert(w99Params.begin(), w99Params.end());
1369 // Rail
1370 std::set<SumoXMLAttr> railParams(genericParams);
1371 railParams.insert(SUMO_ATTR_TRAIN_TYPE);
1373 allParams.insert(railParams.begin(), railParams.end());
1374 // ACC
1375 std::set<SumoXMLAttr> ACCParams(genericParams);
1376 ACCParams.insert(SUMO_ATTR_SC_GAIN);
1377 ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1378 ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1379 ACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1380 ACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1381 ACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1382 ACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1383 ACCParams.insert(SUMO_ATTR_CA_OVERRIDE);
1384 ACCParams.insert(SUMO_ATTR_APPLYDRIVERSTATE);
1386 allParams.insert(ACCParams.begin(), ACCParams.end());
1387 // CACC
1388 std::set<SumoXMLAttr> CACCParams(genericParams);
1389 CACCParams.insert(SUMO_ATTR_SC_GAIN_CACC);
1390 CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_CACC);
1391 CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_DOT_CACC);
1392 CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_CACC);
1393 CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_DOT_CACC);
1394 CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_CACC);
1395 CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_DOT_CACC);
1396 CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1397 CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1398 CACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1399 CACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1400 CACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1401 CACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1402 CACCParams.insert(SUMO_ATTR_CA_OVERRIDE);
1403 CACCParams.insert(SUMO_ATTR_HEADWAY_TIME_CACC_TO_ACC);
1404 CACCParams.insert(SUMO_ATTR_APPLYDRIVERSTATE);
1405 CACCParams.insert(SUMO_ATTR_SC_MIN_GAP);
1407 allParams.insert(CACCParams.begin(), CACCParams.end());
1408 // CC
1409 std::set<SumoXMLAttr> ccParams(genericParams);
1410 ccParams.insert(SUMO_ATTR_CF_CC_C1);
1411 ccParams.insert(SUMO_ATTR_CF_CC_CCDECEL);
1412 ccParams.insert(SUMO_ATTR_CF_CC_CONSTSPACING);
1413 ccParams.insert(SUMO_ATTR_CF_CC_KP);
1414 ccParams.insert(SUMO_ATTR_CF_CC_LAMBDA);
1415 ccParams.insert(SUMO_ATTR_CF_CC_OMEGAN);
1416 ccParams.insert(SUMO_ATTR_CF_CC_TAU);
1417 ccParams.insert(SUMO_ATTR_CF_CC_XI);
1418 ccParams.insert(SUMO_ATTR_CF_CC_LANES_COUNT);
1419 ccParams.insert(SUMO_ATTR_CF_CC_CCACCEL);
1420 ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KP);
1421 ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KD);
1422 ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_H);
1423 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KA);
1424 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KV);
1425 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KP);
1426 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_D);
1427 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_H);
1429 allParams.insert(ccParams.begin(), ccParams.end());
1430 // last element
1432 }
1433 return allowedCFModelAttrs;
1434}
1435
1436
1437bool
1439 if (allowedLCModelAttrs.size() == 0) {
1440 // lc2013
1441 std::set<SumoXMLAttr> lc2013Params;
1442 lc2013Params.insert(SUMO_ATTR_LCA_STRATEGIC_PARAM);
1443 lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_PARAM);
1444 lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_PARAM);
1445 lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_PARAM);
1446 lc2013Params.insert(SUMO_ATTR_LCA_OPPOSITE_PARAM);
1447 lc2013Params.insert(SUMO_ATTR_LCA_LOOKAHEADLEFT);
1448 lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAINRIGHT);
1449 lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING);
1450 lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR);
1451 lc2013Params.insert(SUMO_ATTR_LCA_MAXDISTLATSTANDING);
1452 lc2013Params.insert(SUMO_ATTR_LCA_ASSERTIVE);
1453 lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD);
1454 lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_ROUNDABOUT);
1455 lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_SPEED);
1456 lc2013Params.insert(SUMO_ATTR_LCA_OVERTAKE_RIGHT);
1457 lc2013Params.insert(SUMO_ATTR_LCA_SIGMA);
1458 lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_ACCEPTANCE_TIME);
1459 lc2013Params.insert(SUMO_ATTR_LCA_OVERTAKE_DELTASPEED_FACTOR);
1460 lc2013Params.insert(SUMO_ATTR_LCA_EXPERIMENTAL1);
1462 // sl2015 (extension of lc2013)
1463 std::set<SumoXMLAttr> sl2015Params = lc2013Params;
1464 sl2015Params.insert(SUMO_ATTR_LCA_PUSHY);
1465 sl2015Params.insert(SUMO_ATTR_LCA_PUSHYGAP);
1466 sl2015Params.insert(SUMO_ATTR_LCA_SUBLANE_PARAM);
1467 sl2015Params.insert(SUMO_ATTR_LCA_IMPATIENCE);
1468 sl2015Params.insert(SUMO_ATTR_LCA_TIME_TO_IMPATIENCE);
1469 sl2015Params.insert(SUMO_ATTR_LCA_ACCEL_LAT);
1470 sl2015Params.insert(SUMO_ATTR_LCA_TURN_ALIGNMENT_DISTANCE);
1471 sl2015Params.insert(SUMO_ATTR_LCA_LANE_DISCIPLINE);
1473 // DK2008
1474 std::set<SumoXMLAttr> noParams;
1476 // default model may be either LC2013 or SL2015
1477 // we allow both sets (sl2015 is a superset of lc2013Params)
1479 }
1480 std::set<SumoXMLAttr> allowed = allowedLCModelAttrs[model];
1481 // iterate over LCM attributes
1482 for (const auto& it : allowed) {
1483 if (attrs.hasAttribute(it)) {
1484 // first obtain CFM attribute in string format
1485 bool ok = true;
1486 std::string parsedLCMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1487 if (!ok) {
1488 return false;
1489 }
1490 // declare a double in wich save CFM attribute
1491 double LCMAttribute = -1;
1492 try {
1493 // obtain CFM attribute in double format
1494 LCMAttribute = StringUtils::toDouble(parsedLCMAttribute);
1495 } catch (...) {
1496 WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1497 return false;
1498 }
1499 // check attributes of type "nonNegativeFloatType" (>= 0)
1500 switch (it) {
1512 if (LCMAttribute < 0) {
1513 WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1514 return false;
1515 }
1516 break;
1517 default:
1518 break;
1519 }
1520 // check attributes of type "positiveFloatType" (> 0)
1521 switch (it) {
1523 if (LCMAttribute <= 0) {
1524 WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be greater than 0");
1525 return false;
1526 }
1527 break;
1528 default:
1529 break;
1530 }
1531 // check limits of attributes
1532 switch (it) {
1534 if (LCMAttribute < -1 || LCMAttribute > 1) {
1535 WRITE_ERROR("Invalid Lane-Change-Model Attribute " + toString(it) + ". Must be between -1 and 1");
1536 return false;
1537 }
1538 break;
1539 default:
1540 break;
1541 }
1542 // add parsedLCMAttribute to cfParameter
1543 into->lcParameter[it] = parsedLCMAttribute;
1544 }
1545 }
1546 // all LCM parsed ok, then return true
1547 return true;
1548}
1549
1550
1551bool
1553 if (allowedJMAttrs.size() == 0) {
1554 // init static set (there is only one model)
1566 }
1567 for (const auto& it : allowedJMAttrs) {
1568 if (attrs.hasAttribute(it)) {
1569 // first obtain CFM attribute in string format
1570 bool ok = true;
1571 std::string parsedJMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1572 if (!ok) {
1573 return false;
1574 }
1575 // declare a double in wich save CFM attribute
1576 double JMAttribute = -1;
1577 try {
1578 // obtain CFM attribute in double format
1579 JMAttribute = StringUtils::toDouble(parsedJMAttribute);
1580 } catch (...) {
1581 WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Cannot be parsed to float");
1582 return false;
1583 }
1584 // now continue checking other properties (-1 is the default value)
1585 if (JMAttribute != -1) {
1586 // special case for sigma minor
1587 if (it == SUMO_ATTR_JM_SIGMA_MINOR) {
1588 // check attributes sigma minor
1589 if ((JMAttribute < 0) || (JMAttribute > 1)) {
1590 WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Only values between [0-1] are allowed");
1591 return false;
1592 }
1593 } else {
1594 // check attributes of type "nonNegativeFloatType" (>= 0)
1595 if (JMAttribute < 0) {
1596 WRITE_ERROR("Invalid Junction-Model Attribute " + toString(it) + ". Must be equal or greater than 0");
1597 return false;
1598 }
1599 }
1600 // add parsedJMAttribute to cfParameter
1601 into->jmParameter[it] = parsedJMAttribute;
1602 }
1603 }
1604 }
1605 // all JM parameters successfully parsed, then return true
1606 return true;
1607}
1608
1609
1613 bool ok = true;
1614 std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_VCLASS, id.c_str(), ok, "");
1615 if (vclassS == "") {
1616 return vclass;
1617 }
1618 try {
1619 const SUMOVehicleClass result = getVehicleClassID(vclassS);
1620 const std::string& realName = SumoVehicleClassStrings.getString(result);
1621 if (realName != vclassS) {
1622 WRITE_WARNING("The vehicle class '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1623 }
1624 return result;
1625 } catch (...) {
1626 WRITE_ERROR("The vehicle class '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
1627 }
1628 return vclass;
1629}
1630
1631
1633SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id) {
1634 bool ok = true;
1635 std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_GUISHAPE, id.c_str(), ok, "");
1636 if (SumoVehicleShapeStrings.hasString(vclassS)) {
1637 const SUMOVehicleShape result = SumoVehicleShapeStrings.get(vclassS);
1638 const std::string& realName = SumoVehicleShapeStrings.getString(result);
1639 if (realName != vclassS) {
1640 WRITE_WARNING("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1641 }
1642 return result;
1643 } else {
1644 WRITE_ERROR("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is not known.");
1646 }
1647}
1648
1649
1650double
1651SUMOVehicleParserHelper::parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, SumoRNG* rng) {
1652 double result;
1653 std::string error;
1655 // only supports 'random' and 'max'
1656 if (!SUMOVehicleParameter::parseArrivalPos(val, toString(SUMO_TAG_WALK), id, result, proc, error)) {
1657 handleVehicleError(hardFail, nullptr, error);
1658 }
1659 if (proc == ArrivalPosDefinition::RANDOM) {
1660 result = RandHelper::rand(maxPos, rng);
1661 } else if (proc == ArrivalPosDefinition::CENTER) {
1662 result = maxPos / 2.;
1663 } else if (proc == ArrivalPosDefinition::MAX) {
1664 result = maxPos;
1665 }
1666 return SUMOVehicleParameter::interpretEdgePos(result, maxPos, attr, id);
1667}
1668
1669
1672 const std::string defaultError = "The parameter action-step-length must be a non-negative multiple of the simulation step-length. ";
1673 SUMOTime result = TIME2STEPS(given);
1674 if (result <= 0) {
1675 if (result < 0) {
1676 WRITE_WARNING(defaultError + "Ignoring given value (=" + toString(STEPS2TIME(result)) + " s.)");
1677 }
1678 result = DELTA_T;
1679 } else if (result % DELTA_T != 0) {
1680 result = (SUMOTime)((double)DELTA_T * floor(double(result) / double(DELTA_T)));
1681 result = MAX2(DELTA_T, result);
1682 if (fabs(given * 1000. - double(result)) > NUMERICAL_EPS) {
1683 WRITE_WARNING(defaultError + "Parsing given value (" + toString(given) + " s.) to the adjusted value " + toString(STEPS2TIME(result)) + " s.");
1684 }
1685 }
1686 return result;
1687}
1688
1689
1691SUMOVehicleParserHelper::handleVehicleError(const bool hardFail, SUMOVehicleParameter* vehicleParameter, const std::string message) {
1692 if (vehicleParameter) {
1693 delete vehicleParameter;
1694 }
1695 if (hardFail) {
1696 throw ProcessError(message);
1697 } else if (message.size() > 0) {
1698 WRITE_ERROR(message);
1699 }
1700 return nullptr;
1701}
1702
1703
1705SUMOVehicleParserHelper::handleVehicleTypeError(const bool hardFail, SUMOVTypeParameter* vehicleTypeParameter, const std::string message) {
1706 if (vehicleTypeParameter) {
1707 delete vehicleTypeParameter;
1708 }
1709 if (hardFail) {
1710 throw ProcessError(message);
1711 } else if (message.size() > 0) {
1712 WRITE_ERROR(message);
1713 }
1714 return nullptr;
1715}
1716
1717/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:266
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:54
#define SUMOTime_MAX
Definition: SUMOTime.h:33
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
const long long int VTYPEPARS_TTT_SET
const long long int VTYPEPARS_SHAPE_SET
const long long int VTYPEPARS_LOADING_DURATION
const long long int VTYPEPARS_TTT_BIDI_SET
const long long int VTYPEPARS_SCALE_SET
const long long int VTYPEPARS_PERSON_CAPACITY
const long long int VTYPEPARS_CAR_FOLLOW_MODEL
const long long int VTYPEPARS_WIDTH_SET
const long long int VTYPEPARS_ACTIONSTEPLENGTH_SET
const long long int VTYPEPARS_MAXSPEED_LAT_SET
const long long int VTYPEPARS_MAXSPEED_SET
const long long int VTYPEPARS_EMISSIONCLASS_SET
const long long int VTYPEPARS_LATALIGNMENT_SET
const long long int VTYPEPARS_COLOR_SET
const long long int VTYPEPARS_LANE_CHANGE_MODEL_SET
const long long int VTYPEPARS_DESIRED_MAXSPEED_SET
const long long int VTYPEPARS_OSGFILE_SET
const long long int VTYPEPARS_MANEUVER_ANGLE_TIMES_SET
const long long int VTYPEPARS_SPEEDFACTOR_SET
const long long int VTYPEPARS_MINGAP_SET
const long long int VTYPEPARS_PROBABILITY_SET
const long long int VTYPEPARS_HEIGHT_SET
const long long int VTYPEPARS_BOARDING_DURATION
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
const long long int VTYPEPARS_VEHICLECLASS_SET
const long long int VTYPEPARS_IMPATIENCE_SET
const long long int VTYPEPARS_LENGTH_SET
const long long int VTYPEPARS_IMGFILE_SET
const long long int VTYPEPARS_CONTAINER_CAPACITY
const long long int VTYPEPARS_MINGAP_LAT_SET
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings(sumoVehicleShapeStringInitializer, SUMOVehicleShape::UNKNOWN, false)
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)
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_BICYCLE
vehicle is a bicycle
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_PEDTYPE_ID
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
@ 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
@ 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_STARTUP_DELAY
@ 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_SCALE
@ 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_TIME_TO_TELEPORT_BIDI
@ 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_DESIRED_MAXSPEED
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_JM_IGNORE_FOE_PROB
@ SUMO_ATTR_PERHOUR
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_CF_CC_XI
@ SUMO_ATTR_CA_OVERRIDE
@ 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_LCA_OVERTAKE_DELTASPEED_FACTOR
@ 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_SIGMA_STEP
@ 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_TIME_TO_TELEPORT
@ 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_INSERTIONCHECKS
@ 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_SC_MIN_GAP
@ SUMO_ATTR_SPEEDDEV
@ SUMO_ATTR_CF_WIEDEMANN_ESTIMATION
@ SUMO_ATTR_PERSONSPERHOUR
@ SUMO_ATTR_LCA_SPEEDGAINRIGHT
T MAX2(T a, T b)
Definition: StdDefs.h:77
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:59
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.cpp:94
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
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.
const std::string & getObjectType() const
return the objecttype to which these attributes belong
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.
double desiredMaxSpeed
The vehicle type's desired maximum speed [m/s].
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.
long long int parametersSet
Information for the router which parameter were set.
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.
double scale
individual scaling factor (-1 for undefined)
SUMOTime timeToTeleport
the custom time-to-teleport for this type
std::string osgFile
3D model file for this class
double maxSpeed
The vehicle type's (technical) maximum speed [m/s].
SUMOTime timeToTeleportBidi
the custom time-to-teleport.bidi for this type
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 insertionChecks
bitset of InsertionCheck
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 StringBijection< InsertionCheck > InsertionChecks
traffic light layouts
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,...
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4451
struct for default values that depend of VClass
double maxSpeed
The vehicle type's maximum speed [m/s] (technical limit, not subject to speed deviation)