Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 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 : /****************************************************************************/
14 : /// @file SUMOVehicleClass.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @author Walter Bamberger
19 : /// @author Laura Bieker-Walz
20 : /// @date 2006-01-24
21 : ///
22 : // Definitions of SUMO vehicle classes and helper functions
23 : /****************************************************************************/
24 : #include <config.h>
25 :
26 : #include <string>
27 : #include <map>
28 : #include "SUMOVehicleClass.h"
29 : #include <utils/common/StringUtils.h>
30 : #include <utils/common/ToString.h>
31 : #include <utils/common/MsgHandler.h>
32 : #include <utils/common/StringTokenizer.h>
33 : #include <utils/iodevices/OutputDevice.h>
34 : #include <utils/xml/SUMOSAXAttributes.h>
35 :
36 :
37 : // ===========================================================================
38 : // static members
39 : // ===========================================================================
40 :
41 : static StringBijection<SUMOVehicleClass>::Entry sumoVehicleClassStringInitializer[] = {
42 : {"ignoring", SVC_IGNORING},
43 : {"private", SVC_PRIVATE},
44 : {"public_emergency", SVC_EMERGENCY}, // !!! deprecated
45 : {"emergency", SVC_EMERGENCY},
46 : {"public_authority", SVC_AUTHORITY}, // !!! deprecated
47 : {"authority", SVC_AUTHORITY},
48 : {"public_army", SVC_ARMY}, // !!! deprecated
49 : {"army", SVC_ARMY},
50 : {"vip", SVC_VIP},
51 : {"passenger", SVC_PASSENGER},
52 : {"hov", SVC_HOV},
53 : {"taxi", SVC_TAXI},
54 : {"public_transport", SVC_BUS}, // !!! deprecated
55 : {"bus", SVC_BUS},
56 : {"coach", SVC_COACH},
57 : {"delivery", SVC_DELIVERY},
58 : {"transport", SVC_TRUCK}, // !!! deprecated
59 : {"truck", SVC_TRUCK},
60 : {"trailer", SVC_TRAILER},
61 : {"lightrail", SVC_TRAM}, // !!! deprecated
62 : {"tram", SVC_TRAM},
63 : {"cityrail", SVC_RAIL_URBAN}, // !!! deprecated
64 : {"rail_urban", SVC_RAIL_URBAN},
65 : {"rail_slow", SVC_RAIL}, // !!! deprecated
66 : {"rail", SVC_RAIL},
67 : {"rail_fast", SVC_RAIL_FAST},
68 : {"rail_electric", SVC_RAIL_ELECTRIC},
69 : {"motorcycle", SVC_MOTORCYCLE},
70 : {"moped", SVC_MOPED},
71 : {"bicycle", SVC_BICYCLE},
72 : {"pedestrian", SVC_PEDESTRIAN},
73 : {"evehicle", SVC_E_VEHICLE},
74 : {"ship", SVC_SHIP},
75 : {"container", SVC_CONTAINER},
76 : {"cable_car", SVC_CABLE_CAR},
77 : {"subway", SVC_SUBWAY},
78 : {"aircraft", SVC_AIRCRAFT},
79 : {"wheelchair", SVC_WHEELCHAIR},
80 : {"scooter", SVC_SCOOTER},
81 : {"drone", SVC_DRONE},
82 : {"custom1", SVC_CUSTOM1},
83 : {"custom2", SVC_CUSTOM2}
84 : };
85 :
86 :
87 : StringBijection<SUMOVehicleClass> SumoVehicleClassStrings(
88 : sumoVehicleClassStringInitializer, SVC_CUSTOM2, false);
89 :
90 : // count only non-deprecated classes
91 : const int NUM_VCLASSES = SumoVehicleClassStrings.size() - 8;
92 :
93 : std::set<std::string> deprecatedVehicleClassesSeen;
94 :
95 :
96 : static StringBijection<SUMOVehicleShape>::Entry sumoVehicleShapeStringInitializer[] = {
97 : {"pedestrian", SUMOVehicleShape::PEDESTRIAN},
98 : {"bicycle", SUMOVehicleShape::BICYCLE},
99 : {"moped", SUMOVehicleShape::MOPED},
100 : {"motorcycle", SUMOVehicleShape::MOTORCYCLE},
101 : {"passenger", SUMOVehicleShape::PASSENGER},
102 : {"passenger/sedan", SUMOVehicleShape::PASSENGER_SEDAN},
103 : {"passenger/hatchback", SUMOVehicleShape::PASSENGER_HATCHBACK},
104 : {"passenger/wagon", SUMOVehicleShape::PASSENGER_WAGON},
105 : {"passenger/van", SUMOVehicleShape::PASSENGER_VAN},
106 : {"taxi", SUMOVehicleShape::TAXI},
107 : {"delivery", SUMOVehicleShape::DELIVERY},
108 : {"transport", SUMOVehicleShape::TRUCK}, // !!! deprecated
109 : {"truck", SUMOVehicleShape::TRUCK},
110 : {"transport/semitrailer", SUMOVehicleShape::TRUCK_SEMITRAILER}, // !!! deprecated
111 : {"truck/semitrailer", SUMOVehicleShape::TRUCK_SEMITRAILER},
112 : {"transport/trailer", SUMOVehicleShape::TRUCK_1TRAILER}, // !!! deprecated
113 : {"truck/trailer", SUMOVehicleShape::TRUCK_1TRAILER},
114 : {"bus/city", SUMOVehicleShape::BUS}, // !!! deprecated
115 : {"bus", SUMOVehicleShape::BUS},
116 : {"bus/overland", SUMOVehicleShape::BUS_COACH}, // !!! deprecated
117 : {"bus/coach", SUMOVehicleShape::BUS_COACH},
118 : {"bus/flexible", SUMOVehicleShape::BUS_FLEXIBLE},
119 : {"bus/trolley", SUMOVehicleShape::BUS_TROLLEY},
120 : {"rail/slow", SUMOVehicleShape::RAIL}, // !!! deprecated
121 : {"rail/fast", SUMOVehicleShape::RAIL}, // !!! deprecated
122 : {"rail", SUMOVehicleShape::RAIL},
123 : {"rail/light", SUMOVehicleShape::RAIL_CAR}, // !!! deprecated
124 : {"rail/city", SUMOVehicleShape::RAIL_CAR}, // !!! deprecated
125 : {"rail/railcar", SUMOVehicleShape::RAIL_CAR},
126 : {"rail/cargo", SUMOVehicleShape::RAIL_CARGO},
127 : {"evehicle", SUMOVehicleShape::E_VEHICLE},
128 : {"ant", SUMOVehicleShape::ANT},
129 : {"ship", SUMOVehicleShape::SHIP},
130 : {"emergency", SUMOVehicleShape::EMERGENCY},
131 : {"firebrigade", SUMOVehicleShape::FIREBRIGADE},
132 : {"police", SUMOVehicleShape::POLICE},
133 : {"rickshaw", SUMOVehicleShape::RICKSHAW },
134 : {"scooter", SUMOVehicleShape::SCOOTER},
135 : {"aircraft", SUMOVehicleShape::AIRCRAFT},
136 : {"", SUMOVehicleShape::UNKNOWN}
137 : };
138 :
139 :
140 : StringBijection<SUMOVehicleShape> SumoVehicleShapeStrings(
141 : sumoVehicleShapeStringInitializer, SUMOVehicleShape::UNKNOWN, false);
142 :
143 : // ===========================================================================
144 : // static values used for cached
145 : // ===========================================================================
146 :
147 : static std::map<SVCPermissions, std::vector<std::string> > vehicleClassNamesListCached;
148 : static std::map<std::string, SVCPermissions> parseVehicleClassesCached;
149 : static std::map<SVCPermissions, std::string> getVehicleClassNamesCached;
150 : static std::string VehicleClassNameAll = "all";
151 :
152 : // ===========================================================================
153 : // additional constants
154 : // ===========================================================================
155 :
156 : const SUMOVehicleClass SUMOVehicleClass_MAX = SVC_CUSTOM2;
157 :
158 : const SVCPermissions SVCAll = 2 * (long long int)SUMOVehicleClass_MAX - 1; // all relevant bits set to 1
159 :
160 : const SVCPermissions SVC_UNSPECIFIED = -1;
161 :
162 : const SUMOEmissionClass EMISSION_CLASS_UNSPECIFIED = -1;
163 :
164 : const std::string DEFAULT_VTYPE_ID("DEFAULT_VEHTYPE");
165 : const std::string DEFAULT_PEDTYPE_ID("DEFAULT_PEDTYPE");
166 : const std::string DEFAULT_BIKETYPE_ID("DEFAULT_BIKETYPE");
167 : const std::string DEFAULT_CONTAINERTYPE_ID("DEFAULT_CONTAINERTYPE");
168 : const std::string DEFAULT_TAXITYPE_ID("DEFAULT_TAXITYPE");
169 : const std::string DEFAULT_RAILTYPE_ID("DEFAULT_RAILTYPE");
170 :
171 : const std::set<std::string> DEFAULT_VTYPES({DEFAULT_VTYPE_ID, DEFAULT_PEDTYPE_ID, DEFAULT_BIKETYPE_ID, DEFAULT_CONTAINERTYPE_ID, DEFAULT_TAXITYPE_ID, DEFAULT_RAILTYPE_ID});
172 :
173 : const double DEFAULT_VEH_PROB(1.);
174 : const double DEFAULT_VEH_MASS(1500.);
175 : const double DEFAULT_VEH_WIDTH(1.8);
176 : const double DEFAULT_VEH_HEIGHT(1.5);
177 : const double DEFAULT_VEH_SHUT_OFF_STOP(300.);
178 :
179 : const double DEFAULT_PEDESTRIAN_SPEED(5. / 3.6);
180 :
181 : const double DEFAULT_BICYCLE_SPEED(20. / 3.6);
182 :
183 : const double DEFAULT_CONTAINER_TRANSHIP_SPEED(5. / 3.6);
184 :
185 :
186 : // ===========================================================================
187 : // method definitions
188 : // ===========================================================================
189 :
190 : // Stop Offset
191 :
192 2649946 : StopOffset::StopOffset() :
193 2649946 : myPermissions(SVCAll),
194 2649946 : myOffset(0) {
195 2649946 : }
196 :
197 :
198 2229 : StopOffset::StopOffset(const SUMOSAXAttributes& attrs, bool& ok) :
199 2229 : myPermissions(SVC_IGNORING),
200 2229 : myOffset(0) {
201 : // first check conditions
202 2229 : if (attrs.hasAttribute(SUMO_ATTR_VCLASSES) && attrs.hasAttribute(SUMO_ATTR_EXCEPTIONS)) {
203 0 : WRITE_ERROR(TL("Simultaneous specification of vClasses and exceptions is not allowed"));
204 0 : ok = false;
205 : }
206 2229 : if (!attrs.hasAttribute(SUMO_ATTR_VALUE)) {
207 2 : WRITE_ERROR(TL("StopOffset requires an offset value"));
208 2 : ok = false;
209 : }
210 : // parse elements
211 2229 : const std::string vClasses = attrs.getOpt<std::string>(SUMO_ATTR_VCLASSES, nullptr, ok, "");
212 2229 : const std::string exceptions = attrs.getOpt<std::string>(SUMO_ATTR_EXCEPTIONS, nullptr, ok, "");
213 : // parse permissions
214 2229 : if (attrs.hasAttribute(SUMO_ATTR_VCLASSES)) {
215 1212 : myPermissions = parseVehicleClasses(vClasses);
216 1017 : } else if (attrs.hasAttribute(SUMO_ATTR_EXCEPTIONS)) {
217 1001 : myPermissions = ~parseVehicleClasses(exceptions);
218 : } else {
219 : // no vClasses specified, thus apply to all
220 16 : myPermissions = parseVehicleClasses("all");
221 : }
222 : // parse offset
223 2229 : myOffset = attrs.getOpt<double>(SUMO_ATTR_VALUE, nullptr, ok, 0);
224 2229 : }
225 :
226 :
227 : bool
228 2178206375 : StopOffset::isDefined() const {
229 2178206375 : return myOffset != 0;
230 : }
231 :
232 :
233 : void
234 1745727 : StopOffset::reset() {
235 1745727 : myPermissions = SVC_IGNORING;
236 1745727 : myOffset = 0;
237 1745727 : }
238 :
239 :
240 : SVCPermissions
241 88360 : StopOffset::getPermissions() const {
242 88360 : return myPermissions;
243 : }
244 :
245 :
246 : std::string
247 0 : StopOffset::getExceptions() const {
248 0 : return getVehicleClassNames(~myPermissions);
249 : }
250 :
251 :
252 : double
253 83771 : StopOffset::getOffset() const {
254 83771 : return myOffset;
255 : }
256 :
257 :
258 : void
259 0 : StopOffset::setPermissions(const SVCPermissions permissions) {
260 0 : myPermissions = permissions;
261 0 : }
262 :
263 :
264 : void
265 0 : StopOffset::setExceptions(const std::string permissions) {
266 0 : myPermissions = ~parseVehicleClasses(permissions);
267 0 : }
268 :
269 :
270 : void
271 0 : StopOffset::setOffset(const double offset) {
272 0 : myOffset = offset;
273 0 : }
274 :
275 :
276 : bool
277 0 : StopOffset::operator==(StopOffset const& other) const {
278 0 : return ((myPermissions == other.myPermissions) &&
279 0 : (myOffset == other.myOffset));
280 : }
281 :
282 :
283 : bool
284 115006 : StopOffset::operator!=(StopOffset const& other) const {
285 115006 : return ((myPermissions != other.myPermissions) ||
286 114983 : (myOffset != other.myOffset));
287 : }
288 :
289 : // Conversion of SUMOVehicleClass
290 :
291 : const std::string&
292 136770 : getVehicleClassNames(SVCPermissions permissions, bool expand) {
293 136770 : if ((permissions & SVCAll) == SVCAll && !expand) {
294 : return VehicleClassNameAll;
295 : }
296 : // check if previously was cached
297 : if (getVehicleClassNamesCached.count(permissions) == 0) {
298 4372 : getVehicleClassNamesCached[permissions] = joinToString(getVehicleClassNamesList(permissions), ' ');
299 : }
300 136766 : return getVehicleClassNamesCached.at(permissions);
301 : }
302 :
303 :
304 : const std::vector<std::string>&
305 2355 : getVehicleClassNamesList(SVCPermissions permissions) {
306 : // first check if it's cached
307 : if (vehicleClassNamesListCached.count(permissions) == 0) {
308 2324 : const std::vector<std::string> classNames = SumoVehicleClassStrings.getStrings();
309 : std::vector<std::string> result;
310 81340 : for (std::vector<std::string>::const_iterator it = classNames.begin(); it != classNames.end(); it++) {
311 79016 : const SVCPermissions svc = (SVCPermissions)SumoVehicleClassStrings.get(*it);
312 79016 : if ((svc & permissions) == svc && svc != SVC_IGNORING) {
313 9668 : result.push_back(*it);
314 : }
315 : }
316 : // add it into vehicleClassNamesListCached
317 2324 : vehicleClassNamesListCached[permissions] = result;
318 2324 : }
319 2355 : return vehicleClassNamesListCached.at(permissions);
320 : }
321 :
322 :
323 : SUMOVehicleClass
324 184165 : getVehicleClassID(const std::string& name) {
325 : if (SumoVehicleClassStrings.hasString(name)) {
326 184150 : return SumoVehicleClassStrings.get(name);
327 : }
328 30 : throw InvalidArgument("Unknown vehicle class '" + name + "'.");
329 : }
330 :
331 :
332 : SVCPermissions
333 0 : getVehicleClassCompoundID(const std::string& name) {
334 : SVCPermissions ret = SVC_IGNORING;
335 0 : const std::vector<std::string> names = SumoVehicleClassStrings.getStrings();
336 0 : for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
337 0 : if (name.find(*it) != std::string::npos) {
338 0 : ret = ret | (SVCPermissions) SumoVehicleClassStrings.get(*it);
339 : }
340 : }
341 0 : return ret;
342 0 : }
343 :
344 :
345 : SVCPermissions
346 944077 : parseVehicleClasses(const std::string& allowedS) {
347 944077 : if (allowedS == VehicleClassNameAll) {
348 : return SVCAll;
349 : }
350 : // check if allowedS was previously cached
351 : if (parseVehicleClassesCached.count(allowedS) == 0) {
352 : SVCPermissions result = 0;
353 126708 : StringTokenizer sta(allowedS, " ");
354 140480 : while (sta.hasNext()) {
355 98244 : const std::string s = sta.next();
356 98244 : if (!SumoVehicleClassStrings.hasString(s)) {
357 16 : if (gIgnoreUnknownVClass) {
358 27 : WRITE_WARNINGF(TL("Unknown vehicle class '%' ignored."), s);
359 : } else {
360 21 : WRITE_ERRORF(TL("Unknown vehicle class '%' encountered."), s);
361 : }
362 : } else {
363 98228 : const SUMOVehicleClass vc = getVehicleClassID(s);
364 98228 : const std::string& realName = SumoVehicleClassStrings.getString(vc);
365 98228 : if (realName != s) {
366 : deprecatedVehicleClassesSeen.insert(s);
367 : }
368 98228 : result |= vc;
369 : }
370 : }
371 : // save parsed vehicle class cached
372 42236 : parseVehicleClassesCached[allowedS] = result;
373 42236 : }
374 931914 : return parseVehicleClassesCached.at(allowedS);
375 : }
376 :
377 :
378 : bool
379 0 : canParseVehicleClasses(const std::string& classes) {
380 0 : if (classes == VehicleClassNameAll) {
381 : return true;
382 : }
383 : // check if was previously cached
384 : if (parseVehicleClassesCached.count(classes) != 0) {
385 0 : return true;
386 : }
387 0 : StringTokenizer sta(classes, " ");
388 0 : while (sta.hasNext()) {
389 0 : if (!SumoVehicleClassStrings.hasString(sta.next())) {
390 : return false;
391 : }
392 : }
393 : return true;
394 0 : }
395 :
396 :
397 : SVCPermissions
398 7226204 : parseVehicleClasses(const std::string& allowedS, const std::string& disallowedS, const MMVersion& networkVersion) {
399 7226204 : if (allowedS.size() == 0 && disallowedS.size() == 0) {
400 : return SVCAll;
401 941846 : } else if (allowedS.size() > 0 && disallowedS.size() > 0) {
402 1 : WRITE_WARNING(TL("SVCPermissions must be specified either via 'allow' or 'disallow'. Ignoring 'disallow'"));
403 1 : return parseVehicleClasses(allowedS);
404 941845 : } else if (allowedS.size() > 0) {
405 552903 : return parseVehicleClasses(allowedS);
406 : } else {
407 388942 : return invertPermissions(extraDisallowed(parseVehicleClasses(disallowedS), networkVersion));
408 : }
409 : }
410 :
411 : SVCPermissions
412 388942 : extraDisallowed(SVCPermissions disallowed, const MMVersion& networkVersion) {
413 : if (networkVersion < MMVersion(1, 3)) {
414 28372 : disallowed |= SVC_RAIL_FAST;
415 : }
416 : if (networkVersion < MMVersion(1, 20)) {
417 192683 : if ((disallowed & SVC_RAIL_URBAN) != 0) {
418 : disallowed |= SVC_SUBWAY;
419 36936 : disallowed |= SVC_CABLE_CAR;
420 : }
421 : }
422 388942 : return disallowed;
423 : }
424 :
425 :
426 : SVCPermissions
427 389021 : invertPermissions(SVCPermissions permissions) {
428 389021 : return SVCAll & ~permissions;
429 : }
430 :
431 :
432 : SVCPermissions
433 12489 : parseVehicleClasses(const std::vector<std::string>& allowedS) {
434 : SVCPermissions result = 0;
435 12489 : if (std::find(allowedS.begin(), allowedS.end(), VehicleClassNameAll) != allowedS.end()) {
436 : return SVCAll;
437 : }
438 37325 : for (std::vector<std::string>::const_iterator i = allowedS.begin(); i != allowedS.end(); ++i) {
439 24844 : const SUMOVehicleClass vc = getVehicleClassID(*i);
440 24837 : const std::string& realName = SumoVehicleClassStrings.getString(vc);
441 24837 : if (realName != *i) {
442 0 : WRITE_WARNINGF(TL("The vehicle class '%' is deprecated, use '%' instead."), (*i), realName);
443 : }
444 24837 : result |= getVehicleClassID(*i);
445 : }
446 : return result;
447 : }
448 :
449 :
450 : void
451 233274 : writePermissions(OutputDevice& into, SVCPermissions permissions) {
452 233274 : if (permissions == SVCAll) {
453 : return;
454 136588 : } else if (permissions == 0) {
455 : into.writeAttr(SUMO_ATTR_DISALLOW, VehicleClassNameAll);
456 918 : return;
457 : } else {
458 : int num_allowed = 0;
459 4612780 : for (SVCPermissions mask = 1; mask <= SUMOVehicleClass_MAX; mask = mask << 1) {
460 4477110 : if ((mask & permissions) == mask) {
461 1524405 : ++num_allowed;
462 : }
463 : }
464 135670 : if (num_allowed <= (NUM_VCLASSES - num_allowed) && num_allowed > 0) {
465 74874 : into.writeAttr(SUMO_ATTR_ALLOW, getVehicleClassNames(permissions));
466 : } else {
467 60796 : into.writeAttr(SUMO_ATTR_DISALLOW, getVehicleClassNames(~permissions));
468 : }
469 : }
470 : }
471 :
472 :
473 : void
474 230457 : writePreferences(OutputDevice& into, SVCPermissions preferred) {
475 230457 : if (preferred == SVCAll || preferred == 0) {
476 : return;
477 : } else {
478 116 : into.writeAttr(SUMO_ATTR_PREFER, getVehicleClassNames(preferred));
479 : }
480 : }
481 :
482 :
483 : SUMOVehicleShape
484 16 : getVehicleShapeID(const std::string& name) {
485 : if (SumoVehicleShapeStrings.hasString(name)) {
486 16 : return SumoVehicleShapeStrings.get(name);
487 : } else {
488 0 : throw InvalidArgument("Unknown vehicle shape '" + name + "'.");
489 : }
490 : }
491 :
492 :
493 : bool
494 0 : canParseVehicleShape(const std::string& shape) {
495 0 : return SumoVehicleShapeStrings.hasString(shape);
496 : }
497 :
498 :
499 : std::string
500 147 : getVehicleShapeName(SUMOVehicleShape id) {
501 147 : return SumoVehicleShapeStrings.getString(id);
502 : }
503 :
504 :
505 5388680620 : bool isRailway(SVCPermissions permissions) {
506 5388680620 : return (permissions & SVC_RAIL_CLASSES) > 0 && (permissions & SVC_PASSENGER) == 0;
507 : }
508 :
509 2340 : bool isTram(SVCPermissions permissions) {
510 2340 : return (permissions & SVC_RAIL_CLASSES) == SVC_TRAM && (permissions & SVC_PASSENGER) == 0;
511 : }
512 :
513 108943 : bool isBikepath(SVCPermissions permissions) {
514 108943 : return (permissions & SVC_BICYCLE) == SVC_BICYCLE && (permissions & SVC_PASSENGER) == 0;
515 : }
516 :
517 :
518 : bool
519 27057695 : isWaterway(SVCPermissions permissions) {
520 27057695 : return permissions == SVC_SHIP;
521 : }
522 :
523 : bool
524 2653438 : isAirway(SVCPermissions permissions) {
525 2653438 : return permissions == SVC_AIRCRAFT || permissions == SVC_DRONE;
526 : }
527 :
528 : bool
529 185391 : isForbidden(SVCPermissions permissions) {
530 185391 : return (permissions & SVCAll) == 0;
531 : }
532 :
533 :
534 : bool
535 101146 : isSidewalk(SVCPermissions permissions) {
536 101146 : return (permissions & SVCAll) == SVC_PEDESTRIAN;
537 : }
538 :
539 :
540 : bool
541 1914 : isForVulnerableModes(SVCPermissions permissions) {
542 1914 : return ((permissions & SVC_VULNERABLE) != 0 && (permissions & ~SVC_VULNERABLE) == 0);
543 : }
544 :
545 :
546 : bool
547 10709 : noVehicles(SVCPermissions permissions) {
548 10709 : return isForbidden(permissions) || isSidewalk(permissions);
549 : }
550 :
551 :
552 : double
553 404030 : getDefaultVehicleLength(const SUMOVehicleClass vc) {
554 404030 : switch (vc) {
555 : case SVC_PEDESTRIAN:
556 : return 0.215;
557 : case SVC_WHEELCHAIR:
558 : return 0.5;
559 54380 : case SVC_BICYCLE:
560 54380 : return 1.6;
561 24 : case SVC_SCOOTER:
562 24 : return 1.2;
563 118 : case SVC_MOPED:
564 118 : return 2.1;
565 139 : case SVC_MOTORCYCLE:
566 139 : return 2.2;
567 485 : case SVC_TRUCK:
568 485 : return 7.1;
569 58 : case SVC_TRAILER:
570 58 : return 16.5;
571 1199 : case SVC_BUS:
572 1199 : return 12.;
573 41 : case SVC_COACH:
574 41 : return 14.;
575 326 : case SVC_TRAM:
576 326 : return 22.;
577 977 : case SVC_RAIL_URBAN:
578 : case SVC_SUBWAY:
579 977 : return 36.5 * 3;
580 55360 : case SVC_RAIL:
581 55360 : return 67.5 * 2;
582 48 : case SVC_RAIL_ELECTRIC:
583 : case SVC_RAIL_FAST:
584 48 : return 25. * 8;
585 332 : case SVC_DELIVERY:
586 : case SVC_EMERGENCY:
587 332 : return 6.5;
588 301 : case SVC_SHIP:
589 301 : return 17;
590 43472 : case SVC_CONTAINER:
591 43472 : return 6.096;
592 : case SVC_DRONE:
593 : return 0.5;
594 24 : case SVC_AIRCRAFT:
595 24 : return 72.7;
596 140750 : default:
597 140750 : return 5; /*4.3*/
598 : }
599 : }
600 :
601 :
602 :
603 : /****************************************************************************/
|