Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMOVehicleParserHelper.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2008-2023 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
48
49
50// ===========================================================================
51// method definitions
52// ===========================================================================
53
55SUMOVehicleParserHelper::parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes& attrs, const bool hardFail, const bool needID,
56 const SUMOTime beginDefault, const SUMOTime endDefault) {
57 // first parse ID
58 const std::string id = attrs.hasAttribute(SUMO_ATTR_ID) ? parseID(attrs, tag) : "";
59 // check if ID is valid
60 if (!needID || !id.empty()) {
61 if (needID && !SUMOXMLDefinitions::isValidVehicleID(id)) {
62 return handleVehicleError(hardFail, nullptr, "Invalid flow id '" + id + "'.");
63 }
64 // declare flags
65 const bool hasPeriod = attrs.hasAttribute(SUMO_ATTR_PERIOD);
66 const bool hasVPH = attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR);
67 const bool hasPPH = attrs.hasAttribute(SUMO_ATTR_PERSONSPERHOUR);
68 const bool hasCPH = attrs.hasAttribute(SUMO_ATTR_CONTAINERSPERHOUR);
69 const bool hasPH = attrs.hasAttribute(SUMO_ATTR_PERHOUR);
70 const bool hasXPH = hasVPH || hasPPH || hasCPH || hasPH;
71 const bool hasProb = attrs.hasAttribute(SUMO_ATTR_PROB);
72 const bool hasNumber = attrs.hasAttribute(SUMO_ATTR_NUMBER);
73 const bool hasBegin = attrs.hasAttribute(SUMO_ATTR_BEGIN);
74 const bool hasEnd = attrs.hasAttribute(SUMO_ATTR_END);
76 if (hasVPH) {
77 PERHOUR = SUMO_ATTR_VEHSPERHOUR;
78 }
79 if (hasPPH) {
81 }
82 if (hasCPH) {
84 }
85 if (hasXPH && !(hasVPH ^ hasPPH ^ hasCPH ^ hasPH)) {
86 return handleVehicleError(hardFail, nullptr,
87 "At most one of '" + attrs.getName(SUMO_ATTR_PERHOUR) +
88 "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
89 "', '" + attrs.getName(SUMO_ATTR_PERSONSPERHOUR) +
90 "' and '" + attrs.getName(SUMO_ATTR_CONTAINERSPERHOUR) +
91 "' has to be given in the definition of " + toString(tag) + " '" + id + "'.");
92 }
93 if (hasPeriod && hasXPH) {
94 return handleVehicleError(hardFail, nullptr,
95 "At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
96 "' and '" + attrs.getName(PERHOUR) +
97 "' has to be given in the definition of "
98 + toString(tag) + " '" + id + "'.");
99 }
100 if (hasPeriod && hasProb) {
101 return handleVehicleError(hardFail, nullptr,
102 "At most one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
103 "' and '" + attrs.getName(SUMO_ATTR_PROB) +
104 "' has to be given in the definition of "
105 + toString(tag) + " '" + id + "'.");
106 }
107 if (hasProb && hasXPH) {
108 return handleVehicleError(hardFail, nullptr,
109 "At most one of '" + attrs.getName(SUMO_ATTR_PROB) +
110 "' and '" + attrs.getName(PERHOUR) +
111 "' has to be given in the definition of "
112 + toString(tag) + " '" + id + "'.");
113 }
114 if (hasPeriod || hasXPH || hasProb) {
115 if (hasEnd && hasNumber) {
116 return handleVehicleError(hardFail, nullptr,
117 "If '" + attrs.getName(SUMO_ATTR_PERIOD) +
118 "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
119 "', '" + attrs.getName(SUMO_ATTR_PERSONSPERHOUR) +
120 "', '" + attrs.getName(SUMO_ATTR_CONTAINERSPERHOUR) +
121 "', '" + attrs.getName(SUMO_ATTR_PERHOUR) +
122 "' or '" + attrs.getName(SUMO_ATTR_PROB) +
123 "' are given at most one of '" + attrs.getName(SUMO_ATTR_END) +
124 "' and '" + attrs.getName(SUMO_ATTR_NUMBER) +
125 "' are allowed in "
126 + toString(tag) + " '" + id + "'.");
127 }
128 } else {
129 if (!hasNumber) {
130 return handleVehicleError(hardFail, nullptr,
131 "At least one of '" + attrs.getName(SUMO_ATTR_PERIOD) +
132 "', '" + attrs.getName(SUMO_ATTR_VEHSPERHOUR) +
133 "', '" + attrs.getName(SUMO_ATTR_PERSONSPERHOUR) +
134 "', '" + attrs.getName(SUMO_ATTR_CONTAINERSPERHOUR) +
135 "', '" + attrs.getName(SUMO_ATTR_PERHOUR) +
136 "', '" + attrs.getName(SUMO_ATTR_PROB) +
137 "', and '" + attrs.getName(SUMO_ATTR_NUMBER) +
138 "' is needed in "
139 + toString(tag) + " '" + id + "'.");
140 }
141 }
142 // declare flow
143 SUMOVehicleParameter* flowParameter = new SUMOVehicleParameter();
144 // set tag
145 flowParameter->tag = tag;
146 // set id
147 flowParameter->id = id;
148 if (tag == SUMO_TAG_PERSONFLOW) {
149 flowParameter->vtypeid = DEFAULT_PEDTYPE_ID;
150 }
151 if (tag == SUMO_TAG_CONTAINERFLOW) {
152 flowParameter->vtypeid = DEFAULT_CONTAINERTYPE_ID;
153 }
154 // parse common vehicle attributes
155 try {
156 parseCommonAttributes(attrs, flowParameter, tag);
157 } catch (ProcessError& attributeError) {
158 // check if continue handling another vehicles or stop handling
159 if (hardFail) {
160 throw ProcessError(attributeError.what());
161 } else {
162 return nullptr;
163 }
164 }
165 // parse period
166 bool poissonFlow = false;
167 if (hasPeriod) {
168 bool ok = true;
169 const std::string description = attrs.get<std::string>(SUMO_ATTR_PERIOD, id.c_str(), ok);
170 const std::string distName = description.substr(0, description.find('('));
171 if (distName == "exp") {
172 // declare rate
173 double rate = -1;
174 // parse rate
175 try {
176 rate = StringUtils::toDouble(description.substr(distName.size() + 1, description.size() - distName.size() - 2));
177 } catch (ProcessError& attributeError) {
178 // check if continue handling another vehicles or stop handling
179 if (hardFail) {
180 throw ProcessError(attributeError.what());
181 } else {
182 return nullptr;
183 }
184 }
185 if (rate <= 0) {
186 return handleVehicleError(hardFail, flowParameter, "Invalid rate parameter for exponentially distributed period in the definition of " + toString(tag) + " '" + id + "'.");
187 }
188 flowParameter->repetitionOffset = -TIME2STEPS(rate);
189 poissonFlow = true;
190 } else {
191 flowParameter->repetitionOffset = attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok);
192 }
193 if (!ok) {
194 return handleVehicleError(hardFail, flowParameter);
195 } else {
196 flowParameter->parametersSet |= VEHPARS_PERIOD_SET;
197 }
198 }
199 // parse vehicle/person/container/etc per hour
200 if (hasXPH) {
201 bool ok = true;
202 const double vph = attrs.get<double>(PERHOUR, id.c_str(), ok);
203 if (!ok) {
204 return handleVehicleError(hardFail, flowParameter);
205 } else if (vph <= 0) {
206 return handleVehicleError(hardFail, flowParameter, "Invalid repetition rate in the definition of " + toString(tag) + " '" + id + "'.");
207 } else {
208 if (vph != 0) {
209 flowParameter->repetitionOffset = TIME2STEPS(3600. / vph);
210 }
211 flowParameter->parametersSet |= VEHPARS_VPH_SET;
212 }
213 }
214 // parse probability
215 if (hasProb) {
216 bool ok = true;
217 flowParameter->repetitionProbability = attrs.get<double>(SUMO_ATTR_PROB, id.c_str(), ok);
218 if (!ok) {
219 return handleVehicleError(hardFail, flowParameter);
220 } else if (flowParameter->repetitionProbability <= 0 || flowParameter->repetitionProbability > 1) {
221 return handleVehicleError(hardFail, flowParameter, "Invalid repetition probability in the definition of " + toString(tag) + " '" + id + "'.");
222 } else {
223 flowParameter->parametersSet |= VEHPARS_PROB_SET;
224 }
225 }
226 // set default begin
227 flowParameter->depart = beginDefault;
228 // parse begin
229 if (hasBegin) {
230 // first get begin
231 bool ok = true;
232 const std::string begin = attrs.get<std::string>(SUMO_ATTR_BEGIN, id.c_str(), ok);
233 if (!ok) {
234 return handleVehicleError(hardFail, flowParameter);
235 } else {
236 // parse begin
237 std::string errorMsg;
238 if (!SUMOVehicleParameter::parseDepart(begin, toString(tag), id, flowParameter->depart, flowParameter->departProcedure, errorMsg, "begin")) {
239 return handleVehicleError(hardFail, flowParameter, errorMsg);
240 }
241 }
242 }
243 if (flowParameter->depart < 0) {
244 return handleVehicleError(hardFail, flowParameter, "Negative begin time in the definition of " + toString(tag) + " '" + id + "'.");
245 }
246 // set default end
247 flowParameter->repetitionEnd = endDefault;
248 if (flowParameter->repetitionEnd < 0) {
249 flowParameter->repetitionEnd = SUMOTime_MAX;
250 }
251 // parse end
252 if (hasEnd) {
253 bool ok = true;
254 flowParameter->repetitionEnd = attrs.getSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok);
255 if (!ok) {
256 return handleVehicleError(hardFail, flowParameter);
257 } else {
258 flowParameter->parametersSet |= VEHPARS_END_SET;
259 }
260 } else if (flowParameter->departProcedure == DepartDefinition::TRIGGERED) {
261 if (!hasNumber) {
262 return handleVehicleError(hardFail, flowParameter, toString(tag) + " '" + id + "' with triggered begin must define 'number'.");
263 } else {
264 flowParameter->repetitionEnd = flowParameter->depart;
265 }
266 } else if ((endDefault == SUMOTime_MAX || endDefault < 0) && (!hasNumber || (!hasProb && !hasPeriod && !hasXPH))) {
267 WRITE_WARNINGF(TL("Undefined end for % '%', defaulting to 24hour duration."), toString(tag), id);
268 flowParameter->repetitionEnd = flowParameter->depart + TIME2STEPS(24 * 3600);
269 }
270 if (flowParameter->repetitionEnd < flowParameter->depart) {
271 std::string flow = toString(tag);
272 flow[0] = (char)::toupper((char)flow[0]);
273 return handleVehicleError(hardFail, flowParameter, flow + " '" + id + "' ends before its begin time.");
274 }
275 // parse number
276 if (hasNumber) {
277 bool ok = true;
278 flowParameter->repetitionNumber = attrs.get<int>(SUMO_ATTR_NUMBER, id.c_str(), ok);
279 if (!ok) {
280 return handleVehicleError(hardFail, flowParameter);
281 } else {
282 flowParameter->parametersSet |= VEHPARS_NUMBER_SET;
283 if (flowParameter->repetitionNumber == 0) {
284 std::string flow = toString(tag);
285 flow[0] = (char)::toupper((char)flow[0]);
286 WRITE_WARNING(flow + " '" + id + "' has no instances; will skip it.");
287 flowParameter->repetitionEnd = flowParameter->depart;
288 } else {
289 if (flowParameter->repetitionNumber < 0) {
290 return handleVehicleError(hardFail, flowParameter, "Negative repetition number in the definition of " + toString(tag) + " '" + id + "'.");
291 }
292 if (flowParameter->repetitionOffset < 0 && !hasProb) {
293 if (poissonFlow) {
294 flowParameter->repetitionEnd = SUMOTime_MAX;
295 } else {
296 flowParameter->repetitionOffset = (flowParameter->repetitionEnd - flowParameter->depart) / flowParameter->repetitionNumber;
297 }
298 }
299 }
300 }
301 } else {
302 // interpret repetitionNumber
303 if (flowParameter->repetitionProbability > 0) {
304 flowParameter->repetitionNumber = std::numeric_limits<int>::max();
305 } else {
306 if (flowParameter->repetitionOffset <= 0) {
307 if (poissonFlow) {
308 // number is random but flow has a fixed end time
309 flowParameter->repetitionNumber = std::numeric_limits<int>::max();
310 } else {
311 return handleVehicleError(hardFail, flowParameter, "Invalid repetition rate in the definition of " + toString(tag) + " '" + id + "'.");
312 }
313 } else {
314 if (flowParameter->repetitionEnd == SUMOTime_MAX) {
315 flowParameter->repetitionNumber = std::numeric_limits<int>::max();
316 } else {
317 const SUMOTime repLength = flowParameter->repetitionEnd - flowParameter->depart;
318 flowParameter->repetitionNumber = (int)ceil((double)repLength / (double)flowParameter->repetitionOffset);
319 }
320 }
321 }
322 }
323 // all ok, then return flow parameter
324 return flowParameter;
325 } else {
326 return handleVehicleError(hardFail, nullptr, toString(tag) + " cannot be created");
327 }
328}
329
330
332SUMOVehicleParserHelper::parseVehicleAttributes(int element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID, const bool skipDepart) {
333 // declare vehicle ID
334 std::string id;
335 // for certain vehicles, ID can be optional
336 if (optionalID) {
337 bool ok = true;
338 id = attrs.getOpt<std::string>(SUMO_ATTR_ID, nullptr, ok, "");
339 if (!ok) {
340 return handleVehicleError(hardFail, nullptr);
341 }
342 } else {
343 // parse ID
344 id = parseID(attrs, (SumoXMLTag)element);
345 }
346 // only continue if id is valid, or if is optional
347 if (optionalID || !id.empty()) {
348 // declare vehicle parameter
349 SUMOVehicleParameter* vehicleParameter = new SUMOVehicleParameter();
350 vehicleParameter->id = id;
351 if (element == SUMO_TAG_PERSON) {
352 vehicleParameter->vtypeid = DEFAULT_PEDTYPE_ID;
353 } else if (element == SUMO_TAG_CONTAINER) {
354 vehicleParameter->vtypeid = DEFAULT_CONTAINERTYPE_ID;
355 }
356 // parse common attributes
357 try {
358 parseCommonAttributes(attrs, vehicleParameter, (SumoXMLTag)element);
359 } catch (ProcessError& attributeError) {
360 // check if continue handling another vehicles or stop handling
361 if (hardFail) {
362 throw ProcessError(attributeError.what());
363 } else {
364 return nullptr;
365 }
366 }
367 // check depart
368 if (!skipDepart) {
369 bool ok = true;
370 const std::string helper = attrs.get<std::string>(SUMO_ATTR_DEPART, vehicleParameter->id.c_str(), ok);
371 if (!ok) {
372 return handleVehicleError(hardFail, vehicleParameter);
373 }
374 // now parse depart
375 std::string departErrorMsg;
376 if (!SUMOVehicleParameter::parseDepart(helper, "vehicle", vehicleParameter->id, vehicleParameter->depart, vehicleParameter->departProcedure, departErrorMsg)) {
377 return handleVehicleError(hardFail, vehicleParameter, departErrorMsg);
378 }
379 }
380 // set tag
381 vehicleParameter->tag = (SumoXMLTag)element;
382 // all ok, then return vehicleParameter
383 return vehicleParameter;
384 } else {
385 return handleVehicleError(hardFail, nullptr, toString((SumoXMLTag)element) + " cannot be created");
386 }
387}
388
389
390std::string
392 bool ok = true;
393 std::string id;
394 // first check if attrs contain an ID
395 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
396 id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
398 return id;
399 } else if (id.empty()) {
400 // add extra information for empty IDs
401 WRITE_ERRORF(TL("Invalid % id '%'."), toString(element), id);
402 } else {
403 WRITE_ERRORF(TL("Invalid % id '%'. Contains invalid characters."), toString(element), id);
404 }
405 } else {
406 WRITE_ERROR("Attribute '" + toString(SUMO_ATTR_ID) + "' is missing in definition of " + toString(element));
407 }
408 // return empty (invalid) ID
409 return "";
410}
411
412
413void
415 const std::string element = toString(tag);
416 //ret->refid = attrs.getStringSecure(SUMO_ATTR_REFID, "");
417 // parse route information
418 if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
419 bool ok = true;
420 ret->routeid = attrs.get<std::string>(SUMO_ATTR_ROUTE, ret->id.c_str(), ok);
421 if (ok) {
422 ret->parametersSet |= VEHPARS_ROUTE_SET; // !!! needed?
423 } else {
424 handleVehicleError(true, ret);
425 }
426 }
427 // parse type information
428 if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
429 bool ok = true;
430 ret->vtypeid = attrs.get<std::string>(SUMO_ATTR_TYPE, ret->id.c_str(), ok);
431 if (ok) {
432 ret->parametersSet |= VEHPARS_VTYPE_SET; // !!! needed?
433 } else {
434 handleVehicleError(true, ret);
435 }
436 }
437 // parse line information
438 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
439 bool ok = true;
440 ret->line = attrs.get<std::string>(SUMO_ATTR_LINE, ret->id.c_str(), ok);
441 if (ok) {
442 ret->parametersSet |= VEHPARS_LINE_SET; // !!! needed?
443 } else {
444 handleVehicleError(true, ret);
445 }
446 }
447 // parse zone information
448 if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ)) {
449 bool ok = true;
450 ret->fromTaz = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, ret->id.c_str(), ok);
451 if (ok) {
453 } else {
454 handleVehicleError(true, ret);
455 }
456 }
457 if (attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
458 bool ok = true;
459 ret->toTaz = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, ret->id.c_str(), ok);
460 if (ok) {
462 } else {
463 handleVehicleError(true, ret);
464 }
465 }
466 // parse reroute information
467 if (attrs.hasAttribute(SUMO_ATTR_REROUTE)) {
468 bool ok = true;
469 if (attrs.get<bool>(SUMO_ATTR_REROUTE, ret->id.c_str(), ok)) {
470 if (ok) {
472 } else {
473 handleVehicleError(true, ret);
474 }
475 }
476 }
477 // parse depart lane information
479 bool ok = true;
480 const std::string departLaneStr = attrs.get<std::string>(SUMO_ATTR_DEPARTLANE, ret->id.c_str(), ok);
481 int lane;
483 std::string error;
484 if (SUMOVehicleParameter::parseDepartLane(departLaneStr, element, ret->id, lane, dld, error)) {
486 ret->departLane = lane;
487 ret->departLaneProcedure = dld;
488 } else {
489 handleVehicleError(true, ret, error);
490 }
491 }
492 // parse depart position information
494 bool ok = true;
495 const std::string departPosStr = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS, ret->id.c_str(), ok);
496 double pos;
498 std::string error;
499 if (SUMOVehicleParameter::parseDepartPos(departPosStr, element, ret->id, pos, dpd, error)) {
501 ret->departPos = pos;
502 ret->departPosProcedure = dpd;
503 } else {
504 handleVehicleError(true, ret, error);
505 }
506 }
507 // parse lateral depart position information
509 bool ok = true;
510 const std::string departPosLatStr = attrs.get<std::string>(SUMO_ATTR_DEPARTPOS_LAT, ret->id.c_str(), ok);
511 double pos;
513 std::string error;
514 if (SUMOVehicleParameter::parseDepartPosLat(departPosLatStr, element, ret->id, pos, dpd, error)) {
516 ret->departPosLat = pos;
517 ret->departPosLatProcedure = dpd;
518 } else {
519 handleVehicleError(true, ret, error);
520 }
521 }
522 // parse depart speed information
524 bool ok = true;
525 const std::string departSpeed = attrs.get<std::string>(SUMO_ATTR_DEPARTSPEED, ret->id.c_str(), ok);
526 double speed;
528 std::string error;
529 if (SUMOVehicleParameter::parseDepartSpeed(departSpeed, element, ret->id, speed, dsd, error)) {
531 ret->departSpeed = speed;
532 ret->departSpeedProcedure = dsd;
533 } else {
534 handleVehicleError(true, ret, error);
535 }
536 }
537 // parse depart edge information
539 bool ok = true;
540 const std::string departEdgeStr = attrs.get<std::string>(SUMO_ATTR_DEPARTEDGE, ret->id.c_str(), ok);
541 int edgeIndex;
543 std::string error;
544 if (SUMOVehicleParameter::parseRouteIndex(departEdgeStr, element, ret->id, SUMO_ATTR_DEPARTEDGE, edgeIndex, rid, error)) {
546 ret->departEdge = edgeIndex;
547 ret->departEdgeProcedure = rid;
548 } else {
549 handleVehicleError(true, ret, error);
550 }
551 }
552 // parse arrival lane information
554 bool ok = true;
555 const std::string arrivalLaneStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALLANE, ret->id.c_str(), ok);
556 int lane;
558 std::string error;
559 if (SUMOVehicleParameter::parseArrivalLane(arrivalLaneStr, element, ret->id, lane, ald, error)) {
561 ret->arrivalLane = lane;
562 ret->arrivalLaneProcedure = ald;
563 } else {
564 handleVehicleError(true, ret, error);
565 }
566 }
567 // parse arrival position information
569 bool ok = true;
570 const std::string arrivalPosStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, ret->id.c_str(), ok);
571 double pos;
573 std::string error;
574 if (SUMOVehicleParameter::parseArrivalPos(arrivalPosStr, element, ret->id, pos, apd, error)) {
576 ret->arrivalPos = pos;
577 ret->arrivalPosProcedure = apd;
578 } else {
579 handleVehicleError(true, ret, error);
580 }
581 }
582 // parse lateral arrival position information
584 bool ok = true;
585 const std::string arrivalPosLatStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS_LAT, ret->id.c_str(), ok);
586 double pos;
588 std::string error;
589 if (SUMOVehicleParameter::parseArrivalPosLat(arrivalPosLatStr, element, ret->id, pos, apd, error)) {
591 ret->arrivalPosLat = pos;
592 ret->arrivalPosLatProcedure = apd;
593 } else {
594 handleVehicleError(true, ret, error);
595 }
596 }
597 // parse arrival speed information
599 bool ok = true;
600 std::string arrivalSpeedStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALSPEED, ret->id.c_str(), ok);
601 double speed;
603 std::string error;
604 if (SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeedStr, element, ret->id, speed, asd, error)) {
606 ret->arrivalSpeed = speed;
607 ret->arrivalSpeedProcedure = asd;
608 } else {
609 handleVehicleError(true, ret, error);
610 }
611 }
612 // parse arrival edge information
614 bool ok = true;
615 std::string arrivalEdgeStr = attrs.get<std::string>(SUMO_ATTR_ARRIVALEDGE, ret->id.c_str(), ok);
616 int edgeIndex;
618 std::string error;
619 if (SUMOVehicleParameter::parseRouteIndex(arrivalEdgeStr, element, ret->id, SUMO_ATTR_ARRIVALEDGE, edgeIndex, rid, error)) {
621 ret->arrivalEdge = edgeIndex;
622 ret->arrivalEdgeProcedure = rid;
623 } else {
624 handleVehicleError(true, ret, error);
625 }
626 }
627 // parse color
628 if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
629 bool ok = true;
630 ret->color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, ret->id.c_str(), ok);
631 if (ok) {
633 } else {
634 handleVehicleError(true, ret, "Invalid RGBColor format");
635 }
636 } else {
638 }
639 // parse person number
641 bool ok = true;
642 int personNumber = attrs.get<int>(SUMO_ATTR_PERSON_NUMBER, ret->id.c_str(), ok);
643 if (!ok) {
644 handleVehicleError(true, ret);
645 } else if (personNumber >= 0) {
647 ret->personNumber = personNumber;
648 } else {
649 handleVehicleError(true, ret, toString(SUMO_ATTR_PERSON_NUMBER) + " cannot be negative");
650 }
651 }
652 // parse container number
654 bool ok = true;
655 int containerNumber = attrs.get<int>(SUMO_ATTR_CONTAINER_NUMBER, ret->id.c_str(), ok);
656 if (!ok) {
657 handleVehicleError(true, ret);
658 } else if (containerNumber >= 0) {
660 ret->containerNumber = containerNumber;
661 } else {
662 handleVehicleError(true, ret, toString(SUMO_ATTR_CONTAINER_NUMBER) + " cannot be negative");
663 }
664 }
665 // parse individual speedFactor
667 bool ok = true;
668 double speedFactor = attrs.get<double>(SUMO_ATTR_SPEEDFACTOR, ret->id.c_str(), ok);
669 if (!ok) {
670 handleVehicleError(true, ret);
671 } else if (speedFactor > 0) {
673 ret->speedFactor = speedFactor;
674 } else {
675 handleVehicleError(true, ret, toString(SUMO_ATTR_SPEEDFACTOR) + " must be positive");
676 }
677 }
678 // parse insertion checks
680 ret->insertionChecks = 0;
681 bool ok = true;
682 std::vector<std::string> checks = attrs.get<std::vector<std::string> >(SUMO_ATTR_INSERTIONCHECKS, ret->id.c_str(), ok);
683 if (!ok) {
684 handleVehicleError(true, ret);
685 } else {
686 for (std::string check : checks) {
687 if (!SUMOXMLDefinitions::InsertionChecks.hasString(check)) {
688 handleVehicleError(true, ret, "Unknown value '" + check + "' in " + toString(SUMO_ATTR_INSERTIONCHECKS));
689 }
691 }
692 }
693 }
694 // parse speed (only used by calibrators flow)
695 // also used by vehicle in saved state but this is parsed elsewhere
696 if (tag == SUMO_TAG_FLOW && attrs.hasAttribute(SUMO_ATTR_SPEED)) {
697 bool ok = true;
698 double calibratorSpeed = attrs.get<double>(SUMO_ATTR_SPEED, ret->id.c_str(), ok);
699 if (!ok) {
700 handleVehicleError(true, ret);
701 } else if (calibratorSpeed >= 0 || calibratorSpeed == -1) {
703 ret->calibratorSpeed = calibratorSpeed;
704 } else {
705 handleVehicleError(true, ret, toString(SUMO_ATTR_SPEED) + " may not be negative");
706 }
707 }
708 /*/ parse via
709 if (attrs.hasAttribute(SUMO_ATTR_VIA)) {
710 ret->setParameter |= VEHPARS_VIA_SET;
711 SUMOSAXAttributes::parseStringVector(attrs.get<std::string>(SUMO_ATTR_VIA, ret->id.c_str(), ok), ret->via);
712 }
713 */
714}
715
716
718SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file) {
719 // first obtain ID
720 std::string id = parseID(attrs, SUMO_TAG_VTYPE);
721 // check if ID is valid
722 if (!id.empty()) {
724 if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
725 vClass = parseVehicleClass(attrs, id);
726 }
727 // create vType
728 SUMOVTypeParameter* vType = new SUMOVTypeParameter(id, vClass);
729 // parse attributes
730 if (attrs.hasAttribute(SUMO_ATTR_VCLASS)) {
732 }
733 if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
734 bool ok = true;
735 const double length = attrs.get<double>(SUMO_ATTR_LENGTH, vType->id.c_str(), ok);
736 if (!ok) {
737 return handleVehicleTypeError(hardFail, vType);
738 } else if (length <= 0) {
739 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_LENGTH) + " must be greater than 0");
740 } else {
741 vType->length = length;
743 }
744 }
745 if (attrs.hasAttribute(SUMO_ATTR_MINGAP)) {
746 bool ok = true;
747 const double minGap = attrs.get<double>(SUMO_ATTR_MINGAP, vType->id.c_str(), ok);
748 if (!ok) {
749 return handleVehicleTypeError(hardFail, vType);
750 } else if (minGap < 0) {
751 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MINGAP) + " must be equal or greater than 0");
752 } else {
753 vType->minGap = minGap;
755 }
756 }
757 if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
758 bool ok = true;
759 const double maxSpeed = attrs.get<double>(SUMO_ATTR_MAXSPEED, vType->id.c_str(), ok);
760 if (!ok) {
761 return handleVehicleTypeError(hardFail, vType);
762 } else if (maxSpeed <= 0) {
763 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MAXSPEED) + " must be greater than 0");
764 } else {
765 vType->maxSpeed = maxSpeed;
767 }
768 }
770 bool ok = true;
771 const double desiredMaxSpeed = attrs.get<double>(SUMO_ATTR_DESIRED_MAXSPEED, vType->id.c_str(), ok);
772 if (!ok) {
773 return handleVehicleTypeError(hardFail, vType);
774 } else if (desiredMaxSpeed <= 0) {
775 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_DESIRED_MAXSPEED) + " must be greater than 0");
776 } else {
777 vType->desiredMaxSpeed = desiredMaxSpeed;
779 }
780 } else if (attrs.hasAttribute(SUMO_ATTR_MAXSPEED)) {
781 if (vClass == SVC_PEDESTRIAN) {
782 // backward compatibility because pedestrian maxSpeed was subject to speedFactor up to 1.14.1
783 vType->desiredMaxSpeed = vType->maxSpeed;;
785 } else if (vClass == SVC_BICYCLE) {
786 // backward compatibility because default desired speed did not exist up to 1.14.1
787 vType->desiredMaxSpeed = MAX2(vType->maxSpeed, vType->desiredMaxSpeed);
788 }
789 }
790
792 bool ok = true;
793 vType->speedFactor.parse(attrs.get<std::string>(SUMO_ATTR_SPEEDFACTOR, vType->id.c_str(), ok), hardFail);
794 if (!ok) {
795 return handleVehicleTypeError(hardFail, vType);
796 } else {
798 }
799 }
800 if (attrs.hasAttribute(SUMO_ATTR_SPEEDDEV)) {
801 bool ok = true;
802 const double speedDev = attrs.get<double>(SUMO_ATTR_SPEEDDEV, vType->id.c_str(), ok);
803 if (!ok) {
804 return handleVehicleTypeError(hardFail, vType);
805 } else if (speedDev < 0) {
806 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_SPEEDDEV) + " must be equal or greater than 0");
807 } else {
808 vType->speedFactor.getParameter()[1] = speedDev;
810 }
811 }
812 // validate speed distribution
813 std::string error;
814 if (!vType->speedFactor.isValid(error)) {
815 return handleVehicleTypeError(hardFail, vType, "Invalid speed distribution when parsing vType '" + vType->id + "' (" + error + ")");
816 }
818 bool ok = true;
819 const double actionStepLengthSecs = attrs.get<double>(SUMO_ATTR_ACTIONSTEPLENGTH, vType->id.c_str(), ok);
820 if (!ok) {
821 return handleVehicleTypeError(hardFail, vType);
822 } else {
823 // processActionStepLength(...) function includes warnings
824 vType->actionStepLength = processActionStepLength(actionStepLengthSecs);
826 }
827 }
829 bool ok = true;
830 const std::string parsedEmissionClass = attrs.getOpt<std::string>(SUMO_ATTR_EMISSIONCLASS, id.c_str(), ok, "");
831 // check if emission class is correct
832 try {
833 vType->emissionClass = PollutantsInterface::getClassByName(parsedEmissionClass);
835 } catch (...) {
836 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_EMISSIONCLASS) + " with name '" + parsedEmissionClass + "' doesn't exist.");
837 }
838 }
840 bool ok = true;
841 const std::string impatienceStr = attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
842 if (!ok) {
843 return handleVehicleTypeError(hardFail, vType);
844 } else if (impatienceStr == "off") {
845 vType->impatience = -std::numeric_limits<double>::max();
846 } else {
847 const double impatienceDouble = attrs.get<double>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
848 if (!ok) {
849 return handleVehicleTypeError(hardFail, vType);
850 } else {
851 vType->impatience = impatienceDouble;
853 }
854 }
855 }
856 if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
857 bool ok = true;
858 const double width = attrs.get<double>(SUMO_ATTR_WIDTH, vType->id.c_str(), ok);
859 if (!ok) {
860 return handleVehicleTypeError(hardFail, vType);
861 } else if (width <= 0) {
862 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_WIDTH) + " must be greater than 0");
863 } else {
864 vType->width = width;
866 if (vClass == SVC_PEDESTRIAN
867 && OptionsCont::getOptions().exists("pedestrian.striping.stripe-width")
868 && OptionsCont::getOptions().getString("pedestrian.model") == "striping"
869 && OptionsCont::getOptions().getFloat("pedestrian.striping.stripe-width") < vType->width) {
870 WRITE_WARNINGF(TL("Pedestrian vType '%' width % is larger than pedestrian.striping.stripe-width and this may cause collisions with vehicles."), id, vType->width);
871 }
872 }
873 }
874 if (attrs.hasAttribute(SUMO_ATTR_HEIGHT)) {
875 bool ok = true;
876 const double height = attrs.get<double>(SUMO_ATTR_HEIGHT, vType->id.c_str(), ok);
877 if (!ok) {
878 return handleVehicleTypeError(hardFail, vType);
879 } else if (height < 0) {
880 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_HEIGHT) + " must be equal or greater than 0");
881 } else {
882 vType->height = height;
884 }
885 }
886 if (attrs.hasAttribute(SUMO_ATTR_GUISHAPE)) {
887 vType->shape = parseGuiShape(attrs, vType->id);
888 if (vType->shape != SUMOVehicleShape::UNKNOWN) {
890 }
891 }
892 if (attrs.hasAttribute(SUMO_ATTR_OSGFILE)) {
893 bool ok = true;
894 const std::string osgFile = attrs.get<std::string>(SUMO_ATTR_OSGFILE, vType->id.c_str(), ok);
895 if (!ok) {
896 return handleVehicleTypeError(hardFail, vType);
897 } else {
898 vType->osgFile = osgFile;
900 }
901 }
902 if (attrs.hasAttribute(SUMO_ATTR_IMGFILE)) {
903 bool ok = true;
904 std::string imgFile = attrs.get<std::string>(SUMO_ATTR_IMGFILE, vType->id.c_str(), ok);
905 if (!ok) {
906 return handleVehicleTypeError(hardFail, vType);
907 } else {
908 // check relative path
909 if ((imgFile != "") && !FileHelpers::isAbsolute(imgFile)) {
910 imgFile = FileHelpers::getConfigurationRelative(file, imgFile);
911 }
912 vType->imgFile = imgFile;
914 }
915 }
916 if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
917 bool ok = true;
918 const RGBColor color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, vType->id.c_str(), ok);
919 if (!ok) {
920 return handleVehicleTypeError(hardFail, vType);
921 } else {
922 vType->color = color;
924 }
925 } else {
926 vType->color = RGBColor::YELLOW;
927 }
928 if (attrs.hasAttribute(SUMO_ATTR_PROB)) {
929 bool ok = true;
930 const double defaultProbability = attrs.get<double>(SUMO_ATTR_PROB, vType->id.c_str(), ok);
931 if (!ok) {
932 return handleVehicleTypeError(hardFail, vType);
933 } else if (defaultProbability < 0) {
934 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_PROB) + " must be equal or greater than 0");
935 } else {
936 vType->defaultProbability = defaultProbability;
938 }
939 }
941 bool ok = true;
942 std::string lcmS = attrs.get<std::string>(SUMO_ATTR_LANE_CHANGE_MODEL, vType->id.c_str(), ok);
943 if (!ok) {
944 return handleVehicleTypeError(hardFail, vType);
945 } else if (lcmS == "JE2013") {
946 WRITE_WARNING(TL("Lane change model 'JE2013' is deprecated. Using default model instead."));
947 lcmS = "default";
948 }
949 if (SUMOXMLDefinitions::LaneChangeModels.hasString(lcmS)) {
952 } else {
953 return handleVehicleTypeError(hardFail, vType, "Unknown lane change model '" + lcmS + "' when parsing vType '" + vType->id + "'");
954 }
955 }
957 bool ok = true;
958 const std::string cfmValue = attrs.get<std::string>(SUMO_ATTR_CAR_FOLLOW_MODEL, vType->id.c_str(), ok);
959 if (!ok) {
960 return handleVehicleTypeError(hardFail, vType);
961 } else if (SUMOXMLDefinitions::CarFollowModels.hasString(cfmValue)) {
964 } else {
965 return handleVehicleTypeError(hardFail, vType, "Unknown car following model '" + cfmValue + "' when parsing vType '" + vType->id + "'");
966 }
967 }
969 bool ok = true;
970 const int personCapacity = attrs.get<int>(SUMO_ATTR_PERSON_CAPACITY, vType->id.c_str(), ok);
971 if (!ok) {
972 return handleVehicleTypeError(hardFail, vType);
973 } else if (personCapacity < 0) {
974 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_PERSON_CAPACITY) + " must be equal or greater than 0");
975 } else {
976 vType->personCapacity = personCapacity;
978 }
979 }
981 bool ok = true;
982 const int containerCapacity = attrs.get<int>(SUMO_ATTR_CONTAINER_CAPACITY, vType->id.c_str(), ok);
983 if (!ok) {
984 return handleVehicleTypeError(hardFail, vType);
985 } else if (containerCapacity < 0) {
986 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_CONTAINER_CAPACITY) + " must be equal or greater than 0");
987 } else {
988 vType->containerCapacity = containerCapacity;
990 }
991 }
993 bool ok = true;
994 const SUMOTime boardingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_BOARDING_DURATION, vType->id.c_str(), ok);
995 if (!ok) {
996 return handleVehicleTypeError(hardFail, vType);
997 } else if (boardingDuration < 0) {
998 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_BOARDING_DURATION) + " must be equal or greater than 0");
999 } else {
1000 vType->boardingDuration = boardingDuration;
1002 }
1003 }
1005 bool ok = true;
1006 const SUMOTime loadingDuration = attrs.getSUMOTimeReporting(SUMO_ATTR_LOADING_DURATION, vType->id.c_str(), ok);
1007 if (!ok) {
1008 return handleVehicleTypeError(hardFail, vType);
1009 } else if (loadingDuration < 0) {
1010 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_LOADING_DURATION) + " must be equal or greater than 0");
1011 } else {
1012 vType->loadingDuration = loadingDuration;
1014 }
1015 }
1016 if (attrs.hasAttribute(SUMO_ATTR_SCALE)) {
1017 bool ok = true;
1018 const double scale = attrs.get<double>(SUMO_ATTR_SCALE, id.c_str(), ok);
1019 if (!ok) {
1020 return handleVehicleTypeError(hardFail, vType);
1021 } else if (scale < 0) {
1022 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_SCALE) + " may be not be negative");
1023 } else {
1024 vType->scale = scale;
1026 }
1027 }
1029 bool ok = true;
1030 const SUMOTime ttt = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME_TO_TELEPORT, vType->id.c_str(), ok);
1031 if (!ok) {
1032 return handleVehicleTypeError(hardFail, vType);
1033 } else {
1034 vType->timeToTeleport = ttt;
1036 }
1037 }
1039 bool ok = true;
1040 const SUMOTime tttb = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME_TO_TELEPORT_BIDI, vType->id.c_str(), ok);
1041 if (!ok) {
1042 return handleVehicleTypeError(hardFail, vType);
1043 } else {
1044 vType->timeToTeleportBidi = tttb;
1046 }
1047 }
1049 bool ok = true;
1050 const double sfp = attrs.get<double>(SUMO_ATTR_SPEEDFACTOR_PREMATURE, id.c_str(), ok);
1051 if (!ok) {
1052 return handleVehicleTypeError(hardFail, vType);
1053 } else {
1054 vType->speedFactorPremature = sfp;
1056 }
1057 }
1059 bool ok = true;
1060 const double maxSpeedLat = attrs.get<double>(SUMO_ATTR_MAXSPEED_LAT, vType->id.c_str(), ok);
1061 if (!ok) {
1062 return handleVehicleTypeError(hardFail, vType);
1063 } else if (maxSpeedLat <= 0) {
1064 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MAXSPEED_LAT) + " must be greater than 0");
1065 } else {
1066 vType->maxSpeedLat = maxSpeedLat;
1068 }
1069 }
1071 bool ok = true;
1072 const double minGapLat = attrs.get<double>(SUMO_ATTR_MINGAP_LAT, vType->id.c_str(), ok);
1073 if (!ok) {
1074 return handleVehicleTypeError(hardFail, vType);
1075 } else if (minGapLat < 0) {
1076 return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MINGAP_LAT) + " must be equal or greater than 0");
1077 } else {
1078 vType->minGapLat = minGapLat;
1080 }
1081 }
1083 bool ok = true;
1084 const std::string alignS = attrs.get<std::string>(SUMO_ATTR_LATALIGNMENT, vType->id.c_str(), ok);
1085 if (!ok) {
1086 return handleVehicleTypeError(hardFail, vType);
1087 } else {
1088 double lao;
1090 if (SUMOVTypeParameter::parseLatAlignment(alignS, lao, lad)) {
1091 vType->latAlignmentOffset = lao;
1092 vType->latAlignmentProcedure = lad;
1094 } else {
1095 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)");
1096 }
1097 }
1098 }
1100 bool ok = true;
1101 const std::string angleTimesS = attrs.get<std::string>(SUMO_ATTR_MANEUVER_ANGLE_TIMES, vType->id.c_str(), ok);
1102 if (!ok) {
1103 return handleVehicleTypeError(hardFail, vType);
1104 } else if (parseAngleTimesMap(vType, angleTimesS)) {
1106 } else {
1107 return handleVehicleTypeError(hardFail, vType, "Invalid manoeuver angle times map for vType '" + vType->id + "'");
1108 }
1109 }
1110 // try to parse Car Following Model params
1111 if (!parseCFMParams(vType, vType->cfModel, attrs, false)) {
1112 return handleVehicleTypeError(hardFail, vType, "Invalid parsing embedded VType");
1113 }
1114 // try to parse Lane Change Model params
1115 if (!parseLCParams(vType, vType->lcModel, attrs)) {
1116 return handleVehicleTypeError(hardFail, vType, "Invalid Lane Change Model Parameters");
1117 }
1118 // try to Junction Model params
1119 if (!parseJMParams(vType, attrs)) {
1120 return handleVehicleTypeError(hardFail, vType, "Invalid Junction Model Parameters");
1121 }
1122 // all ok, then return vType
1123 return vType;
1124 } else {
1125 return handleVehicleTypeError(hardFail, nullptr, "VType cannot be created");
1126 }
1127}
1128
1129
1130bool
1132 StringTokenizer st(atm, ",");
1133 std::map<int, std::pair<SUMOTime, SUMOTime>> angleTimesMap;
1134 int tripletCount = 0;
1135 while (st.hasNext()) {
1136 StringTokenizer pos(st.next());
1137 if (pos.size() != 3) {
1138 WRITE_ERRORF(TL("maneuverAngleTimes format for vType '%' % contains an invalid triplet."), vtype->id, atm);
1139 return false;
1140 } else {
1141 try {
1142 const int angle = StringUtils::toInt(pos.next());
1143 const SUMOTime t1 = string2time(pos.next());
1144 const SUMOTime t2 = string2time(pos.next());
1145 angleTimesMap[angle] = std::make_pair(t1, t2);
1146 } catch (...) {
1147 WRITE_ERRORF(TL("Triplet '%' for vType '%' maneuverAngleTimes cannot be parsed as 'int double double'"), st.get(tripletCount), vtype->id);
1148 return false;
1149 }
1150 tripletCount++;
1151 }
1152 }
1153 if (angleTimesMap.size() > 0) {
1154 vtype->myManoeuverAngleTimes.clear();
1155 for (const auto& angleTime : angleTimesMap) {
1156 vtype->myManoeuverAngleTimes.insert(angleTime);
1157 }
1158 angleTimesMap.clear();
1159 return true;
1160 } else {
1161 return false;
1162 }
1163}
1164
1165
1166bool
1167SUMOVehicleParserHelper::parseCFMParams(SUMOVTypeParameter* into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool nestedCFM) {
1168 const CFAttrMap& allowedCFM = getAllowedCFModelAttrs();
1169 CFAttrMap::const_iterator cf_it = allowedCFM.find(element);
1170 // check if given CFM is allowed
1171 if (cf_it == allowedCFM.end()) {
1172 if (SUMOXMLDefinitions::Tags.has((int)element)) {
1173 WRITE_ERRORF(TL("Unknown car-following model % when parsing vType '%'"), toString(element), into->id);
1174 } else {
1175 WRITE_ERRORF(TL("Unknown car-following model when parsing vType '%'"), into->id);
1176 }
1177 return false;
1178 }
1179 // check if we're parsing a nested CFM
1180 if (nestedCFM) {
1181 into->cfModel = cf_it->first;
1183 }
1184 // set CFM values
1185 for (const auto& it : cf_it->second) {
1186 if (attrs.hasAttribute(it)) {
1187 // first obtain CFM attribute in string format
1188 bool ok = true;
1189 std::string parsedCFMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1190 // check CFM Attribute
1191 if (!ok) {
1192 return false;
1193 } else if (it == SUMO_ATTR_TRAIN_TYPE) {
1194 // check if train value is valid
1195 if (!SUMOXMLDefinitions::TrainTypes.hasString(parsedCFMAttribute)) {
1196 WRITE_ERROR("Invalid train type '" + parsedCFMAttribute + "' used in Car-Following-Attribute " + toString(it));
1197 return false;
1198 }
1199 // add parsedCFMAttribute to cfParameter
1200 into->cfParameter[it] = parsedCFMAttribute;
1201 } else if (it == SUMO_ATTR_CF_IDM_STEPPING) {
1202 // declare a int in wich save CFM int attribute
1203 double CFMDoubleAttribute = -1;
1204 try {
1205 // obtain CFM attribute in int format
1206 CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
1207 } catch (...) {
1208 WRITE_ERRORF(TL("Invalid Car-Following-Model Attribute %. Cannot be parsed to float"), toString(it));
1209 return false;
1210 }
1211 if (CFMDoubleAttribute <= 0) {
1212 WRITE_ERRORF(TL("Invalid Car-Following-Model Attribute %. Must be greater than 0"), toString(it));
1213 return false;
1214 }
1215 // add parsedCFMAttribute to cfParameter
1216 into->cfParameter[it] = parsedCFMAttribute;
1217 } else {
1218 // declare a double in wich save CFM float attribute
1219 double CFMDoubleAttribute = -1;
1220 try {
1221 // obtain CFM attribute in double format
1222 CFMDoubleAttribute = StringUtils::toDouble(parsedCFMAttribute);
1223 } catch (...) {
1224 WRITE_ERRORF(TL("Invalid Car-Following-Model Attribute %. Cannot be parsed to float"), toString(it));
1225 return false;
1226 }
1227 // check attributes of type "positiveFloatType" (> 0)
1228 switch (it) {
1229 case SUMO_ATTR_ACCEL:
1230 case SUMO_ATTR_DECEL:
1233 case SUMO_ATTR_TAU:
1234 if (CFMDoubleAttribute <= 0) {
1235 WRITE_ERRORF(TL("Invalid Car-Following-Model Attribute %. Must be greater than 0"), toString(it));
1236 return false;
1237 }
1238 break;
1239 default:
1240 break;
1241 }
1242 // check attributes restricted to [0-1]
1243 switch (it) {
1244 case SUMO_ATTR_SIGMA:
1245 if ((CFMDoubleAttribute < 0) || (CFMDoubleAttribute > 1)) {
1246 WRITE_ERRORF(TL("Invalid Car-Following-Model Attribute %. Only values between [0-1] are allowed"), toString(it));
1247 return false;
1248 }
1249 break;
1250 default:
1251 break;
1252 }
1253 // add parsedCFMAttribute to cfParameter
1254 into->cfParameter[it] = parsedCFMAttribute;
1255 }
1256 }
1257 }
1258 // all CFM successfully parsed, then return true
1259 return true;
1260}
1261
1262
1265 // init on first use
1266 if (allowedCFModelAttrs.size() == 0) {
1267 std::set<SumoXMLAttr> genericParams;
1268 genericParams.insert(SUMO_ATTR_TAU);
1269 genericParams.insert(SUMO_ATTR_ACCEL);
1270 genericParams.insert(SUMO_ATTR_DECEL);
1271 genericParams.insert(SUMO_ATTR_APPARENTDECEL);
1272 genericParams.insert(SUMO_ATTR_EMERGENCYDECEL);
1273 genericParams.insert(SUMO_ATTR_COLLISION_MINGAP_FACTOR);
1274 genericParams.insert(SUMO_ATTR_STARTUP_DELAY);
1275 // Krauss
1276 std::set<SumoXMLAttr> kraussParams(genericParams);
1277 kraussParams.insert(SUMO_ATTR_SIGMA);
1278 kraussParams.insert(SUMO_ATTR_SIGMA_STEP);
1282 std::set<SumoXMLAttr> allParams(kraussParams);
1283 // KraussX
1284 std::set<SumoXMLAttr> kraussXParams(kraussParams);
1285 kraussXParams.insert(SUMO_ATTR_TMP1);
1286 kraussXParams.insert(SUMO_ATTR_TMP2);
1287 kraussXParams.insert(SUMO_ATTR_TMP3);
1288 kraussXParams.insert(SUMO_ATTR_TMP4);
1289 kraussXParams.insert(SUMO_ATTR_TMP5);
1291 allParams.insert(kraussXParams.begin(), kraussXParams.end());
1292 // SmartSK
1293 std::set<SumoXMLAttr> smartSKParams(genericParams);
1294 smartSKParams.insert(SUMO_ATTR_SIGMA);
1295 smartSKParams.insert(SUMO_ATTR_TMP1);
1296 smartSKParams.insert(SUMO_ATTR_TMP2);
1297 smartSKParams.insert(SUMO_ATTR_TMP3);
1298 smartSKParams.insert(SUMO_ATTR_TMP4);
1299 smartSKParams.insert(SUMO_ATTR_TMP5);
1301 allParams.insert(smartSKParams.begin(), smartSKParams.end());
1302 // Daniel
1303 std::set<SumoXMLAttr> daniel1Params(genericParams);
1304 daniel1Params.insert(SUMO_ATTR_SIGMA);
1305 daniel1Params.insert(SUMO_ATTR_TMP1);
1306 daniel1Params.insert(SUMO_ATTR_TMP2);
1307 daniel1Params.insert(SUMO_ATTR_TMP3);
1308 daniel1Params.insert(SUMO_ATTR_TMP4);
1309 daniel1Params.insert(SUMO_ATTR_TMP5);
1311 allParams.insert(daniel1Params.begin(), daniel1Params.end());
1312 // Peter Wagner
1313 std::set<SumoXMLAttr> pwagParams(genericParams);
1314 pwagParams.insert(SUMO_ATTR_SIGMA);
1315 pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_TAULAST);
1316 pwagParams.insert(SUMO_ATTR_CF_PWAGNER2009_APPROB);
1318 allParams.insert(pwagParams.begin(), pwagParams.end());
1319 // IDM params
1320 std::set<SumoXMLAttr> idmParams(genericParams);
1321 idmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1322 idmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1324 allParams.insert(idmParams.begin(), idmParams.end());
1325 // EIDM
1326 std::set<SumoXMLAttr> eidmParams(genericParams);
1327 eidmParams.insert(SUMO_ATTR_CF_IDM_DELTA);
1328 eidmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1329 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_LOOK_AHEAD);
1330 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_PERSISTENCE_DRIVE);
1331 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_REACTION);
1333 eidmParams.insert(SUMO_ATTR_CF_EIDM_C_COOLNESS);
1334 eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_LEADER);
1335 eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_GAP);
1336 eidmParams.insert(SUMO_ATTR_CF_EIDM_SIG_ERROR);
1337 eidmParams.insert(SUMO_ATTR_CF_EIDM_JERK_MAX);
1338 eidmParams.insert(SUMO_ATTR_CF_EIDM_EPSILON_ACC);
1339 eidmParams.insert(SUMO_ATTR_CF_EIDM_T_ACC_MAX);
1340 eidmParams.insert(SUMO_ATTR_CF_EIDM_M_FLATNESS);
1341 eidmParams.insert(SUMO_ATTR_CF_EIDM_M_BEGIN);
1342 eidmParams.insert(SUMO_ATTR_CF_EIDM_USEVEHDYNAMICS);
1343 eidmParams.insert(SUMO_ATTR_CF_EIDM_MAX_VEH_PREVIEW);
1345 allParams.insert(eidmParams.begin(), eidmParams.end());
1346 // IDMM
1347 std::set<SumoXMLAttr> idmmParams(genericParams);
1348 idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_FACTOR);
1349 idmmParams.insert(SUMO_ATTR_CF_IDMM_ADAPT_TIME);
1350 idmmParams.insert(SUMO_ATTR_CF_IDM_STEPPING);
1352 allParams.insert(idmmParams.begin(), idmmParams.end());
1353 // Bieker
1354 std::set<SumoXMLAttr> bkernerParams(genericParams);
1355 bkernerParams.insert(SUMO_ATTR_K);
1356 bkernerParams.insert(SUMO_ATTR_CF_KERNER_PHI);
1358 allParams.insert(bkernerParams.begin(), bkernerParams.end());
1359 // Wiedemann
1360 std::set<SumoXMLAttr> wiedemannParams(genericParams);
1361 wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_SECURITY);
1362 wiedemannParams.insert(SUMO_ATTR_CF_WIEDEMANN_ESTIMATION);
1363 allowedCFModelAttrs[SUMO_TAG_CF_WIEDEMANN] = wiedemannParams;
1364 allParams.insert(wiedemannParams.begin(), wiedemannParams.end());
1365 // W99
1366 std::set<SumoXMLAttr> w99Params(genericParams);
1367 w99Params.insert(SUMO_ATTR_CF_W99_CC1);
1368 w99Params.insert(SUMO_ATTR_CF_W99_CC2);
1369 w99Params.insert(SUMO_ATTR_CF_W99_CC3);
1370 w99Params.insert(SUMO_ATTR_CF_W99_CC4);
1371 w99Params.insert(SUMO_ATTR_CF_W99_CC5);
1372 w99Params.insert(SUMO_ATTR_CF_W99_CC6);
1373 w99Params.insert(SUMO_ATTR_CF_W99_CC7);
1374 w99Params.insert(SUMO_ATTR_CF_W99_CC8);
1375 w99Params.insert(SUMO_ATTR_CF_W99_CC9);
1377 allParams.insert(w99Params.begin(), w99Params.end());
1378 // Rail
1379 std::set<SumoXMLAttr> railParams(genericParams);
1380 railParams.insert(SUMO_ATTR_TRAIN_TYPE);
1382 allParams.insert(railParams.begin(), railParams.end());
1383 // ACC
1384 std::set<SumoXMLAttr> ACCParams(genericParams);
1385 ACCParams.insert(SUMO_ATTR_SC_GAIN);
1386 ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1387 ACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1388 ACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1389 ACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1390 ACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1391 ACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1392 ACCParams.insert(SUMO_ATTR_CA_OVERRIDE);
1393 ACCParams.insert(SUMO_ATTR_APPLYDRIVERSTATE);
1395 allParams.insert(ACCParams.begin(), ACCParams.end());
1396 // CACC
1397 std::set<SumoXMLAttr> CACCParams(genericParams);
1398 CACCParams.insert(SUMO_ATTR_SC_GAIN_CACC);
1399 CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_CACC);
1400 CACCParams.insert(SUMO_ATTR_GCC_GAIN_GAP_DOT_CACC);
1401 CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_CACC);
1402 CACCParams.insert(SUMO_ATTR_GC_GAIN_GAP_DOT_CACC);
1403 CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_CACC);
1404 CACCParams.insert(SUMO_ATTR_CA_GAIN_GAP_DOT_CACC);
1405 CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPEED);
1406 CACCParams.insert(SUMO_ATTR_GCC_GAIN_SPACE);
1407 CACCParams.insert(SUMO_ATTR_GC_GAIN_SPEED);
1408 CACCParams.insert(SUMO_ATTR_GC_GAIN_SPACE);
1409 CACCParams.insert(SUMO_ATTR_CA_GAIN_SPEED);
1410 CACCParams.insert(SUMO_ATTR_CA_GAIN_SPACE);
1411 CACCParams.insert(SUMO_ATTR_CA_OVERRIDE);
1412 CACCParams.insert(SUMO_ATTR_HEADWAY_TIME_CACC_TO_ACC);
1413 CACCParams.insert(SUMO_ATTR_APPLYDRIVERSTATE);
1414 CACCParams.insert(SUMO_ATTR_SC_MIN_GAP);
1416 allParams.insert(CACCParams.begin(), CACCParams.end());
1417 // CC
1418 std::set<SumoXMLAttr> ccParams(genericParams);
1419 ccParams.insert(SUMO_ATTR_CF_CC_C1);
1420 ccParams.insert(SUMO_ATTR_CF_CC_CCDECEL);
1421 ccParams.insert(SUMO_ATTR_CF_CC_CONSTSPACING);
1422 ccParams.insert(SUMO_ATTR_CF_CC_KP);
1423 ccParams.insert(SUMO_ATTR_CF_CC_LAMBDA);
1424 ccParams.insert(SUMO_ATTR_CF_CC_OMEGAN);
1425 ccParams.insert(SUMO_ATTR_CF_CC_TAU);
1426 ccParams.insert(SUMO_ATTR_CF_CC_XI);
1427 ccParams.insert(SUMO_ATTR_CF_CC_LANES_COUNT);
1428 ccParams.insert(SUMO_ATTR_CF_CC_CCACCEL);
1429 ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KP);
1430 ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_KD);
1431 ccParams.insert(SUMO_ATTR_CF_CC_PLOEG_H);
1432 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KA);
1433 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KV);
1434 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_KP);
1435 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_D);
1436 ccParams.insert(SUMO_ATTR_CF_CC_FLATBED_H);
1438 allParams.insert(ccParams.begin(), ccParams.end());
1439 // last element
1441 }
1442 return allowedCFModelAttrs;
1443}
1444
1445
1446bool
1448 if (allowedLCModelAttrs.size() == 0) {
1449 // lc2013
1450 std::set<SumoXMLAttr> lc2013Params;
1451 lc2013Params.insert(SUMO_ATTR_LCA_STRATEGIC_PARAM);
1452 lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_PARAM);
1453 lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_PARAM);
1454 lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_PARAM);
1455 lc2013Params.insert(SUMO_ATTR_LCA_OPPOSITE_PARAM);
1456 lc2013Params.insert(SUMO_ATTR_LCA_LOOKAHEADLEFT);
1457 lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAINRIGHT);
1458 lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATSTANDING);
1459 lc2013Params.insert(SUMO_ATTR_LCA_MAXSPEEDLATFACTOR);
1460 lc2013Params.insert(SUMO_ATTR_LCA_MAXDISTLATSTANDING);
1461 lc2013Params.insert(SUMO_ATTR_LCA_ASSERTIVE);
1462 lc2013Params.insert(SUMO_ATTR_LCA_SPEEDGAIN_LOOKAHEAD);
1463 lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_ROUNDABOUT);
1464 lc2013Params.insert(SUMO_ATTR_LCA_COOPERATIVE_SPEED);
1465 lc2013Params.insert(SUMO_ATTR_LCA_OVERTAKE_RIGHT);
1466 lc2013Params.insert(SUMO_ATTR_LCA_SIGMA);
1467 lc2013Params.insert(SUMO_ATTR_LCA_KEEPRIGHT_ACCEPTANCE_TIME);
1468 lc2013Params.insert(SUMO_ATTR_LCA_OVERTAKE_DELTASPEED_FACTOR);
1469 lc2013Params.insert(SUMO_ATTR_LCA_EXPERIMENTAL1);
1471 // sl2015 (extension of lc2013)
1472 std::set<SumoXMLAttr> sl2015Params = lc2013Params;
1473 sl2015Params.insert(SUMO_ATTR_LCA_PUSHY);
1474 sl2015Params.insert(SUMO_ATTR_LCA_PUSHYGAP);
1475 sl2015Params.insert(SUMO_ATTR_LCA_SUBLANE_PARAM);
1476 sl2015Params.insert(SUMO_ATTR_LCA_IMPATIENCE);
1477 sl2015Params.insert(SUMO_ATTR_LCA_TIME_TO_IMPATIENCE);
1478 sl2015Params.insert(SUMO_ATTR_LCA_ACCEL_LAT);
1479 sl2015Params.insert(SUMO_ATTR_LCA_TURN_ALIGNMENT_DISTANCE);
1480 sl2015Params.insert(SUMO_ATTR_LCA_LANE_DISCIPLINE);
1482 // DK2008
1483 std::set<SumoXMLAttr> noParams;
1485 // default model may be either LC2013 or SL2015
1486 // we allow both sets (sl2015 is a superset of lc2013Params)
1488 }
1489 std::set<SumoXMLAttr> allowed = allowedLCModelAttrs[model];
1490 // iterate over LCM attributes
1491 for (const auto& it : allowed) {
1492 if (attrs.hasAttribute(it)) {
1493 // first obtain CFM attribute in string format
1494 bool ok = true;
1495 std::string parsedLCMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1496 if (!ok) {
1497 return false;
1498 }
1499 // declare a double in wich save CFM attribute
1500 double LCMAttribute = -1;
1501 try {
1502 // obtain CFM attribute in double format
1503 LCMAttribute = StringUtils::toDouble(parsedLCMAttribute);
1504 } catch (...) {
1505 WRITE_ERRORF(TL("Invalid Lane-Change-Model Attribute %. Cannot be parsed to float"), toString(it));
1506 return false;
1507 }
1508 // check attributes of type "nonNegativeFloatType" (>= 0)
1509 switch (it) {
1521 if (LCMAttribute < 0) {
1522 WRITE_ERRORF(TL("Invalid Lane-Change-Model Attribute %. Must be equal or greater than 0"), toString(it));
1523 return false;
1524 }
1525 break;
1526 default:
1527 break;
1528 }
1529 // check attributes of type "positiveFloatType" (> 0)
1530 switch (it) {
1532 if (LCMAttribute <= 0) {
1533 WRITE_ERRORF(TL("Invalid Lane-Change-Model Attribute %. Must be greater than 0"), toString(it));
1534 return false;
1535 }
1536 break;
1537 default:
1538 break;
1539 }
1540 // check limits of attributes
1541 switch (it) {
1543 if (LCMAttribute < -1 || LCMAttribute > 1) {
1544 WRITE_ERRORF(TL("Invalid Lane-Change-Model Attribute %. Must be between -1 and 1"), toString(it));
1545 return false;
1546 }
1547 break;
1548 default:
1549 break;
1550 }
1551 // add parsedLCMAttribute to cfParameter
1552 into->lcParameter[it] = parsedLCMAttribute;
1553 }
1554 }
1555 // all LCM parsed ok, then return true
1556 return true;
1557}
1558
1559
1560bool
1562 for (const auto& it : SUMOVTypeParameter::AllowedJMAttrs) {
1563 if (attrs.hasAttribute(it)) {
1564 // first obtain CFM attribute in string format
1565 bool ok = true;
1566 std::string parsedJMAttribute = attrs.get<std::string>(it, into->id.c_str(), ok);
1567 if (!ok) {
1568 return false;
1569 }
1570 // declare a double in wich save CFM attribute
1571 double JMAttribute = -1;
1572 try {
1573 // obtain CFM attribute in double format
1574 JMAttribute = StringUtils::toDouble(parsedJMAttribute);
1575 } catch (...) {
1576 WRITE_ERRORF(TL("Invalid Junction-Model Attribute %. Cannot be parsed to float"), toString(it));
1577 return false;
1578 }
1579 // now continue checking other properties (-1 is the default value)
1580 if (JMAttribute != -1) {
1581 // special case for sigma minor
1582 if (it == SUMO_ATTR_JM_SIGMA_MINOR) {
1583 // check attributes sigma minor
1584 if ((JMAttribute < 0) || (JMAttribute > 1)) {
1585 WRITE_ERRORF(TL("Invalid Junction-Model Attribute %. Only values between [0-1] are allowed"), toString(it));
1586 return false;
1587 }
1588 } else {
1589 // check attributes of type "nonNegativeFloatType" (>= 0)
1590 if (JMAttribute < 0) {
1591 WRITE_ERRORF(TL("Invalid Junction-Model Attribute %. Must be equal or greater than 0"), toString(it));
1592 return false;
1593 }
1594 }
1595 // add parsedJMAttribute to cfParameter
1596 into->jmParameter[it] = parsedJMAttribute;
1597 }
1598 }
1599 }
1600 // all JM parameters successfully parsed, then return true
1601 return true;
1602}
1603
1604
1608 bool ok = true;
1609 std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_VCLASS, id.c_str(), ok, "");
1610 if (vclassS == "") {
1611 return vclass;
1612 }
1613 try {
1614 const SUMOVehicleClass result = getVehicleClassID(vclassS);
1615 const std::string& realName = SumoVehicleClassStrings.getString(result);
1616 if (realName != vclassS) {
1617 WRITE_WARNING("The vehicle class '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1618 }
1619 return result;
1620 } catch (...) {
1621 WRITE_ERRORF(TL("The vehicle class '%' for % '%' is not known."), vclassS, attrs.getObjectType(), id);
1622 }
1623 return vclass;
1624}
1625
1626
1628SUMOVehicleParserHelper::parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id) {
1629 bool ok = true;
1630 std::string vclassS = attrs.getOpt<std::string>(SUMO_ATTR_GUISHAPE, id.c_str(), ok, "");
1631 if (SumoVehicleShapeStrings.hasString(vclassS)) {
1632 const SUMOVehicleShape result = SumoVehicleShapeStrings.get(vclassS);
1633 const std::string& realName = SumoVehicleShapeStrings.getString(result);
1634 if (realName != vclassS) {
1635 WRITE_WARNING("The shape '" + vclassS + "' for " + attrs.getObjectType() + " '" + id + "' is deprecated, use '" + realName + "' instead.");
1636 }
1637 return result;
1638 } else {
1639 WRITE_ERRORF(TL("The shape '%' for % '%' is not known."), vclassS, attrs.getObjectType(), id);
1641 }
1642}
1643
1644
1645double
1646SUMOVehicleParserHelper::parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, SumoRNG* rng) {
1647 double result;
1648 std::string error;
1650 // only supports 'random' and 'max'
1651 if (!SUMOVehicleParameter::parseArrivalPos(val, toString(SUMO_TAG_WALK), id, result, proc, error)) {
1652 handleVehicleError(hardFail, nullptr, error);
1653 }
1654 if (proc == ArrivalPosDefinition::RANDOM) {
1655 result = RandHelper::rand(maxPos, rng);
1656 } else if (proc == ArrivalPosDefinition::CENTER) {
1657 result = maxPos / 2.;
1658 } else if (proc == ArrivalPosDefinition::MAX) {
1659 result = maxPos;
1660 }
1661 return SUMOVehicleParameter::interpretEdgePos(result, maxPos, attr, id);
1662}
1663
1664
1667 const std::string defaultError = "The parameter action-step-length must be a non-negative multiple of the simulation step-length. ";
1668 SUMOTime result = TIME2STEPS(given);
1669 if (result <= 0) {
1670 if (result < 0) {
1671 WRITE_WARNING(defaultError + "Ignoring given value (=" + toString(STEPS2TIME(result)) + " s.)");
1672 }
1673 result = DELTA_T;
1674 } else if (result % DELTA_T != 0) {
1675 result = (SUMOTime)((double)DELTA_T * floor(double(result) / double(DELTA_T)));
1676 result = MAX2(DELTA_T, result);
1677 if (fabs(given * 1000. - double(result)) > NUMERICAL_EPS) {
1678 WRITE_WARNING(defaultError + "Parsing given value (" + toString(given) + " s.) to the adjusted value " + toString(STEPS2TIME(result)) + " s.");
1679 }
1680 }
1681 return result;
1682}
1683
1684
1686SUMOVehicleParserHelper::handleVehicleError(const bool hardFail, SUMOVehicleParameter* vehicleParameter, const std::string message) {
1687 if (vehicleParameter) {
1688 delete vehicleParameter;
1689 }
1690 if (hardFail) {
1691 throw ProcessError(message);
1692 } else if (message.size() > 0) {
1693 WRITE_ERROR(message);
1694 }
1695 return nullptr;
1696}
1697
1698
1700SUMOVehicleParserHelper::handleVehicleTypeError(const bool hardFail, SUMOVTypeParameter* vehicleTypeParameter, const std::string message) {
1701 if (vehicleTypeParameter) {
1702 delete vehicleTypeParameter;
1703 }
1704 if (hardFail) {
1705 throw ProcessError(message);
1706 } else if (message.size() > 0) {
1707 WRITE_ERROR(message);
1708 }
1709 return nullptr;
1710}
1711
1712/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:271
#define WRITE_ERRORF(...)
Definition MsgHandler.h:280
#define WRITE_ERROR(msg)
Definition MsgHandler.h:279
#define WRITE_WARNING(msg)
Definition MsgHandler.h:270
#define TL(string)
Definition MsgHandler.h:287
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define SUMOTime_MAX
Definition SUMOTime.h:34
#define TIME2STEPS(x)
Definition SUMOTime.h:57
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_PREMATURE_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 definition using from and to edges or a route
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_PERSON
@ SUMO_TAG_CF_IDMM
@ SUMO_TAG_CF_DANIEL1
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_CF_ACC
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_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_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_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_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 maneuvering 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_LCA_KEEPRIGHT_PARAM
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_DESIRED_MAXSPEED
@ SUMO_ATTR_REROUTE
@ 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_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_SPEEDFACTOR_PREMATURE
@ 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_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_LCA_TIME_TO_IMPATIENCE
@ 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:82
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.
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)
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
static std::set< SumoXMLAttr > AllowedJMAttrs
allowed attrs for the junction model
double length
The physical vehicle length.
double maxSpeedLat
The vehicle type's maximum lateral speed [m/s].
double speedFactorPremature
the possible speed reduction when a train is ahead of schedule
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 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,...
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)