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 SUMOVTypeParameter.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @date 10.09.2009
19 : ///
20 : // Structure representing possible vehicle parameter
21 : /****************************************************************************/
22 : #include <config.h>
23 :
24 : #include <algorithm>
25 : #include <utils/vehicle/SUMOVTypeParameter.h>
26 : #include <utils/common/ToString.h>
27 : #include <utils/common/StringUtils.h>
28 : #include <utils/common/MsgHandler.h>
29 : #include <utils/iodevices/OutputDevice.h>
30 : #include <utils/options/OptionsCont.h>
31 : #include <utils/xml/SUMOXMLDefinitions.h>
32 : #include <utils/emissions/PollutantsInterface.h>
33 :
34 : #define EMPREFIX std::string("HBEFA3/")
35 : #define TTT_UNSET SUMOTime_MIN
36 :
37 : // ===========================================================================
38 : // static value definitions
39 : // ===========================================================================
40 : std::set<SumoXMLAttr> SUMOVTypeParameter::AllowedJMAttrs({
41 : SUMO_ATTR_JM_CROSSING_GAP,
42 : SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME,
43 : SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME,
44 : SUMO_ATTR_JM_DRIVE_RED_SPEED,
45 : SUMO_ATTR_JM_IGNORE_KEEPCLEAR_TIME,
46 : SUMO_ATTR_JM_IGNORE_FOE_SPEED,
47 : SUMO_ATTR_JM_IGNORE_FOE_PROB,
48 : SUMO_ATTR_JM_IGNORE_JUNCTION_FOE_PROB,
49 : SUMO_ATTR_JM_SIGMA_MINOR,
50 : SUMO_ATTR_JM_STOPLINE_GAP,
51 : SUMO_ATTR_JM_STOPLINE_GAP_MINOR,
52 : SUMO_ATTR_JM_TIMEGAP_MINOR,
53 : SUMO_ATTR_JM_EXTRA_GAP,
54 : SUMO_ATTR_JM_ADVANCE,
55 : SUMO_ATTR_JM_STOPSIGN_WAIT,
56 : SUMO_ATTR_JM_ALLWAYSTOP_WAIT,
57 : });
58 :
59 :
60 : // ===========================================================================
61 : // member method definitions
62 : // ===========================================================================
63 :
64 402870 : SUMOVTypeParameter::VClassDefaultValues::VClassDefaultValues(SUMOVehicleClass vclass) :
65 402870 : length(getDefaultVehicleLength(vclass)),
66 402870 : minGap(2.5),
67 402870 : minGapLat(0.6),
68 402870 : maxSpeed(200. / 3.6),
69 402870 : desiredMaxSpeed(10000 / 3.6), // backward-compatibility: do not influence speeds by default
70 402870 : width(DEFAULT_VEH_WIDTH),
71 402870 : height(DEFAULT_VEH_HEIGHT),
72 402870 : shape(SUMOVehicleShape::UNKNOWN),
73 805740 : emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)),
74 402870 : mass(DEFAULT_VEH_MASS),
75 402870 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
76 402870 : personCapacity(4),
77 402870 : containerCapacity(0),
78 402870 : osgFile("car-normal-citrus.obj"),
79 402870 : carriageLength(-1),
80 402870 : locomotiveLength(-1),
81 402870 : carriageDoors(2),
82 402870 : latAlignmentProcedure(LatAlignmentDefinition::CENTER) {
83 : // update default values
84 402870 : switch (vclass) {
85 105933 : case SVC_PEDESTRIAN:
86 105933 : minGap = 0.25;
87 105933 : maxSpeed = 37.58 / 3.6; // Usain Bolt
88 105933 : desiredMaxSpeed = DEFAULT_PEDESTRIAN_SPEED;
89 105933 : width = 0.478;
90 105933 : height = 1.719;
91 105933 : shape = SUMOVehicleShape::PEDESTRIAN;
92 : osgFile = "humanResting.obj";
93 211866 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
94 105933 : mass = 70.; // https://en.wikipedia.org/wiki/Human_body_weight for Europe
95 105933 : speedFactor.getParameter()[1] = 0.1;
96 105933 : break;
97 24 : case SVC_WHEELCHAIR:
98 24 : minGap = 0.5;
99 24 : maxSpeed = 30.0 / 3.6; // https://en.wikipedia.org/wiki/Wheelchair_racing
100 24 : desiredMaxSpeed = DEFAULT_PEDESTRIAN_SPEED;
101 24 : width = 0.8;
102 24 : height = 1.5;
103 24 : shape = SUMOVehicleShape::PEDESTRIAN;
104 : osgFile = "humanResting.obj";
105 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
106 24 : mass = 90.; //
107 24 : speedFactor.getParameter()[1] = 0.1;
108 24 : break;
109 54094 : case SVC_BICYCLE:
110 54094 : minGap = 0.5;
111 54094 : minGapLat = 0.35;
112 54094 : maxSpeed = 50. / 3.6;
113 54094 : desiredMaxSpeed = DEFAULT_BICYCLE_SPEED;
114 54094 : width = 0.65;
115 54094 : height = 1.7;
116 54094 : shape = SUMOVehicleShape::BICYCLE;
117 54094 : personCapacity = 1;
118 108188 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
119 54094 : mass = 10.;
120 54094 : speedFactor.getParameter()[1] = 0.1;
121 54094 : latAlignmentProcedure = LatAlignmentDefinition::RIGHT;
122 54094 : break;
123 24 : case SVC_SCOOTER:
124 24 : minGap = 0.5;
125 24 : minGapLat = 0.35;
126 24 : maxSpeed = 25 / 3.6;
127 24 : desiredMaxSpeed = DEFAULT_BICYCLE_SPEED;
128 24 : width = 0.5;
129 24 : height = 1.7;
130 24 : shape = SUMOVehicleShape::SCOOTER;
131 24 : personCapacity = 1;
132 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
133 24 : mass = 10.;
134 24 : speedFactor.getParameter()[1] = 0.1;
135 24 : latAlignmentProcedure = LatAlignmentDefinition::RIGHT;
136 24 : break;
137 118 : case SVC_MOPED:
138 118 : maxSpeed = 60. / 3.6;
139 118 : width = 0.78;
140 118 : height = 1.7;
141 118 : shape = SUMOVehicleShape::MOPED;
142 118 : personCapacity = 1;
143 236 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LDV_G_EU6", vclass);
144 118 : mass = 80.;
145 118 : speedFactor.getParameter()[1] = 0.1;
146 118 : break;
147 139 : case SVC_MOTORCYCLE:
148 139 : width = 0.9;
149 139 : height = 1.5;
150 139 : shape = SUMOVehicleShape::MOTORCYCLE;
151 139 : personCapacity = 1;
152 278 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LDV_G_EU6", vclass);
153 139 : mass = 200.;
154 139 : speedFactor.getParameter()[1] = 0.1;
155 139 : break;
156 486 : case SVC_TRUCK:
157 486 : maxSpeed = 130. / 3.6;
158 486 : width = 2.4;
159 486 : height = 2.4;
160 486 : shape = SUMOVehicleShape::TRUCK;
161 : osgFile = "car-microcargo-citrus.obj";
162 486 : personCapacity = 2;
163 486 : containerCapacity = 1;
164 972 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "HDV", vclass);
165 486 : mass = 12000.;
166 486 : speedFactor.getParameter()[1] = 0.05;
167 486 : break;
168 58 : case SVC_TRAILER:
169 58 : maxSpeed = 130. / 3.6;
170 58 : width = 2.55;
171 58 : height = 4.;
172 58 : shape = SUMOVehicleShape::TRUCK_1TRAILER;
173 : osgFile = "car-microcargo-citrus.obj";
174 58 : personCapacity = 2;
175 58 : containerCapacity = 2;
176 116 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "HDV", vclass);
177 58 : mass = 15000.;
178 58 : speedFactor.getParameter()[1] = 0.05;
179 58 : break;
180 1002 : case SVC_BUS:
181 1002 : maxSpeed = 100. / 3.6;
182 1002 : width = 2.5;
183 1002 : height = 3.4;
184 1002 : shape = SUMOVehicleShape::BUS;
185 : osgFile = "car-minibus-citrus.obj";
186 1002 : personCapacity = 85;
187 2004 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "Bus", vclass);
188 1002 : mass = 7500.;
189 1002 : break;
190 41 : case SVC_COACH:
191 41 : maxSpeed = 100. / 3.6;
192 41 : width = 2.6;
193 41 : height = 4.;
194 41 : shape = SUMOVehicleShape::BUS_COACH;
195 : osgFile = "car-minibus-citrus.obj";
196 41 : personCapacity = 70;
197 82 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "Coach", vclass);
198 41 : mass = 12000.;
199 41 : speedFactor.getParameter()[1] = 0.05;
200 41 : break;
201 185 : case SVC_TRAM:
202 185 : maxSpeed = 80. / 3.6;
203 185 : width = 2.4;
204 185 : height = 3.2;
205 185 : shape = SUMOVehicleShape::RAIL_CAR;
206 : osgFile = "tram.obj";
207 185 : personCapacity = 120;
208 370 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
209 185 : mass = 37900.;
210 185 : break;
211 579 : case SVC_RAIL_URBAN:
212 : case SVC_SUBWAY:
213 579 : maxSpeed = 100. / 3.6;
214 579 : minGap = 5;
215 579 : width = 3.0;
216 579 : height = 3.6;
217 579 : shape = SUMOVehicleShape::RAIL_CAR;
218 579 : personCapacity = 300;
219 1158 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
220 579 : mass = 59000.;
221 579 : break;
222 55310 : case SVC_RAIL:
223 55310 : maxSpeed = 160. / 3.6;
224 55310 : minGap = 5;
225 55310 : width = 2.84;
226 55310 : height = 3.75;
227 55310 : shape = SUMOVehicleShape::RAIL;
228 55310 : personCapacity = 434;
229 : // slight understatement (-:
230 110620 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "HDV_D_EU0", vclass);
231 55310 : mass = 79500.; // only locomotive
232 55310 : break;
233 24 : case SVC_RAIL_ELECTRIC:
234 24 : maxSpeed = 220. / 3.6;
235 24 : minGap = 5;
236 24 : width = 2.95;
237 24 : height = 3.89;
238 24 : shape = SUMOVehicleShape::RAIL;
239 24 : personCapacity = 425;
240 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
241 24 : mass = 83000.; // only locomotive
242 24 : break;
243 24 : case SVC_RAIL_FAST:
244 24 : maxSpeed = 330. / 3.6;
245 24 : minGap = 5;
246 24 : width = 2.95;
247 24 : height = 3.89;
248 24 : shape = SUMOVehicleShape::RAIL;
249 24 : personCapacity = 425;
250 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
251 24 : mass = 409000.;
252 24 : break;
253 99 : case SVC_DELIVERY:
254 99 : width = 2.16;
255 99 : height = 2.86;
256 99 : shape = SUMOVehicleShape::DELIVERY;
257 99 : personCapacity = 2;
258 198 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LDV", vclass);
259 99 : mass = 5000.;
260 99 : speedFactor.getParameter()[1] = 0.05;
261 99 : break;
262 231 : case SVC_EMERGENCY:
263 231 : width = 2.16;
264 231 : height = 2.86;
265 231 : shape = SUMOVehicleShape::DELIVERY;
266 231 : personCapacity = 2;
267 462 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "LDV", vclass);
268 231 : mass = 5000.;
269 231 : break;
270 80874 : case SVC_PRIVATE:
271 : case SVC_VIP:
272 : case SVC_PASSENGER:
273 : case SVC_HOV:
274 : case SVC_CUSTOM1:
275 : case SVC_CUSTOM2:
276 80874 : shape = SUMOVehicleShape::PASSENGER;
277 80874 : speedFactor.getParameter()[1] = 0.1;
278 80874 : break;
279 54142 : case SVC_TAXI:
280 54142 : shape = SUMOVehicleShape::TAXI;
281 54142 : speedFactor.getParameter()[1] = 0.05;
282 54142 : break;
283 24 : case SVC_E_VEHICLE:
284 24 : shape = SUMOVehicleShape::E_VEHICLE;
285 48 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "zero", vclass);
286 24 : speedFactor.getParameter()[1] = 0.1;
287 24 : break;
288 43457 : case SVC_CONTAINER:
289 43457 : width = 2.5908;
290 43457 : break;
291 24 : case SVC_DRONE:
292 24 : width = 0.5;
293 24 : break;
294 24 : case SVC_AIRCRAFT:
295 : // Airbus A380
296 24 : shape = SUMOVehicleShape::AIRCRAFT;
297 24 : width = 79.8;
298 24 : break;
299 299 : case SVC_SHIP:
300 299 : width = 4;
301 299 : maxSpeed = 8 / 1.94; // 8 knots
302 299 : height = 4;
303 299 : shape = SUMOVehicleShape::SHIP;
304 : // slight understatement (-:
305 598 : emissionClass = PollutantsInterface::getClassByName(EMPREFIX + "HDV_D_EU0", vclass);
306 299 : mass = 100000.;
307 299 : speedFactor.getParameter()[1] = 0.1;
308 299 : break;
309 : default:
310 : break;
311 : }
312 402870 : }
313 :
314 :
315 0 : SUMOVTypeParameter::VClassDefaultValues::VClassDefaultValues() :
316 0 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0) {}
317 :
318 376994 : SUMOVTypeParameter::SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vclass)
319 376994 : : id(vtid),
320 376994 : actionStepLength(0),
321 376994 : defaultProbability(DEFAULT_VEH_PROB),
322 376994 : speedFactor("normc", 1.0, 0.0, 0.2, 2.0),
323 753988 : emissionClass(PollutantsInterface::getClassByName(EMPREFIX + "PC_G_EU4", vclass)),
324 376994 : color(RGBColor::DEFAULT_COLOR),
325 376994 : vehicleClass(vclass),
326 376994 : impatience(0.0),
327 376994 : personCapacity(4),
328 376994 : containerCapacity(0),
329 376994 : boardingDuration(500),
330 376994 : loadingDuration(90000),
331 376994 : scale(1),
332 376994 : width(1.8),
333 376994 : height(1.5),
334 376994 : shape(SUMOVehicleShape::UNKNOWN),
335 376994 : osgFile("car-normal-citrus.obj"),
336 376994 : cfModel(SUMO_TAG_CF_KRAUSS),
337 376994 : lcModel(LaneChangeModel::DEFAULT),
338 376994 : maxSpeedLat(1.0),
339 376994 : latAlignmentOffset(0.0),
340 376994 : latAlignmentProcedure(LatAlignmentDefinition::CENTER),
341 376994 : carriageLength(-1),
342 376994 : locomotiveLength(-1),
343 376994 : carriageGap(1),
344 376994 : carriageDoors(2),
345 376994 : timeToTeleport(TTT_UNSET),
346 376994 : timeToTeleportBidi(TTT_UNSET),
347 376994 : speedFactorPremature(-1),
348 376994 : frontSeatPos(1.7),
349 376994 : seatingWidth(-1),
350 376994 : boardingFactor(1),
351 376994 : parametersSet(0),
352 376994 : saved(false),
353 376994 : onlyReferenced(false) {
354 376994 : const OptionsCont& oc = OptionsCont::getOptions();
355 753988 : if (oc.exists("carfollow.model")) {
356 : // check for valid value has been performed in MSFrame
357 649810 : cfModel = SUMOXMLDefinitions::CarFollowModels.get(oc.getString("carfollow.model"));
358 : }
359 : // obtain default values depending of vclass
360 376994 : VClassDefaultValues defaultValues(vclass);
361 : // overwrite SUMOVTypeParameter with VClassDefaultValues
362 376994 : length = defaultValues.length;
363 376994 : minGap = defaultValues.minGap;
364 376994 : minGapLat = defaultValues.minGapLat;
365 376994 : maxSpeed = defaultValues.maxSpeed;
366 376994 : desiredMaxSpeed = defaultValues.desiredMaxSpeed;
367 376994 : width = defaultValues.width;
368 376994 : height = defaultValues.height;
369 376994 : shape = defaultValues.shape;
370 376994 : emissionClass = defaultValues.emissionClass;
371 376994 : mass = defaultValues.mass;
372 : speedFactor = defaultValues.speedFactor;
373 376994 : personCapacity = defaultValues.personCapacity;
374 376994 : containerCapacity = defaultValues.containerCapacity;
375 : osgFile = defaultValues.osgFile;
376 376994 : carriageLength = defaultValues.carriageLength;
377 376994 : locomotiveLength = defaultValues.locomotiveLength;
378 376994 : carriageDoors = defaultValues.carriageDoors;
379 376994 : latAlignmentProcedure = defaultValues.latAlignmentProcedure;
380 : // check if default speeddev was defined
381 753988 : if (oc.exists("default.speeddev")) {
382 324905 : const double defaultSpeedDev = oc.getFloat("default.speeddev");
383 324905 : if (defaultSpeedDev >= 0) {
384 202929 : speedFactor.getParameter()[1] = defaultSpeedDev;
385 : }
386 : } else {
387 52089 : speedFactor.getParameter()[1] = -1;
388 : }
389 376994 : setManoeuverAngleTimes(vclass);
390 376994 : }
391 :
392 : void
393 376994 : SUMOVTypeParameter::setManoeuverAngleTimes(const SUMOVehicleClass vclass) {
394 :
395 : myManoeuverAngleTimes.clear();
396 : /**
397 : * Defaults assume: approaching at angles between 0-10 and 171-180 (will never be > 180) are approaching a space roughly parallel to the road
398 : * approaching at angles between 11-80 are approaching an acute angled space that is easiest to drive straight in
399 : * approaching at angles between 81-110 are approaching a space at approximately right angles to the road so the driver has a choice
400 : * approaching at angles between 111 and 170 are approaching an obtuse angled space that is easiest to drive past and reverse in
401 : * More (or less) granular angle ranges can be used - configurable as a vType parameter
402 : */
403 376994 : switch (vclass) {
404 134784 : case SVC_PASSENGER:
405 : case SVC_HOV:
406 : case SVC_TAXI:
407 : case SVC_E_VEHICLE:
408 134784 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
409 134784 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
410 134784 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
411 134784 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
412 134784 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
413 134784 : break;
414 1686 : case SVC_TRUCK:
415 : case SVC_TRAILER:
416 : case SVC_BUS:
417 : case SVC_COACH:
418 : case SVC_DELIVERY:
419 1686 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
420 1686 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(2000, 21000))); // straight in
421 1686 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(21000, 2000))); // optional forwards/backwards
422 1686 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(14000, 5000))); // backwards into obtuse space
423 1686 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(6000, 8000))); // straight in but potentially needing parallel parking
424 1686 : break;
425 134269 : case SVC_PEDESTRIAN:
426 : case SVC_MOPED:
427 : case SVC_BICYCLE:
428 134269 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(1000, 1000))); // no dependence on angle
429 134269 : break;
430 106255 : default:
431 106255 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(10, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
432 106255 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(80, std::pair< SUMOTime, SUMOTime>(1000, 11000))); // straight in
433 106255 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(110, std::pair< SUMOTime, SUMOTime>(11000, 2000))); // optional forwards/backwards
434 106255 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(170, std::pair< SUMOTime, SUMOTime>(8000, 3000))); // backwards into obtuse space
435 106255 : myManoeuverAngleTimes.insert(std::pair<int, std::pair<SUMOTime, SUMOTime>>(181, std::pair< SUMOTime, SUMOTime>(3000, 4000))); // straight in but potentially needing parallel parking
436 106255 : break;
437 : }
438 376994 : }
439 :
440 : void
441 13472 : SUMOVTypeParameter::write(OutputDevice& dev) const {
442 : // first check if vehicle type can be written
443 13472 : if (onlyReferenced) {
444 : return;
445 : }
446 : // open vehicle tag
447 2835 : dev.openTag(SUMO_TAG_VTYPE);
448 : // write ID (always needed)
449 2835 : dev.writeAttr(SUMO_ATTR_ID, id);
450 : // write parameters depending if is set
451 2835 : if (wasSet(VTYPEPARS_LENGTH_SET)) {
452 784 : dev.writeAttr(SUMO_ATTR_LENGTH, length);
453 : }
454 2835 : if (wasSet(VTYPEPARS_MINGAP_SET)) {
455 677 : dev.writeAttr(SUMO_ATTR_MINGAP, minGap);
456 : }
457 2835 : if (wasSet(VTYPEPARS_MAXSPEED_SET)) {
458 717 : dev.writeAttr(SUMO_ATTR_MAXSPEED, maxSpeed);
459 : }
460 2835 : if (wasSet(VTYPEPARS_DESIRED_MAXSPEED_SET)) {
461 0 : dev.writeAttr(SUMO_ATTR_DESIRED_MAXSPEED, desiredMaxSpeed);
462 : }
463 2835 : if (wasSet(VTYPEPARS_PROBABILITY_SET)) {
464 92 : dev.writeAttr(SUMO_ATTR_PROB, defaultProbability);
465 : }
466 2835 : if (wasSet(VTYPEPARS_SPEEDFACTOR_SET)) {
467 440 : dev.writeAttr(SUMO_ATTR_SPEEDFACTOR, speedFactor);
468 : }
469 2835 : if (wasSet(VTYPEPARS_ACTIONSTEPLENGTH_SET)) {
470 : // Note: action step length is only exposed in seconds to the user
471 210 : dev.writeAttr(SUMO_ATTR_ACTIONSTEPLENGTH, STEPS2TIME(actionStepLength));
472 : }
473 2835 : if (wasSet(VTYPEPARS_VEHICLECLASS_SET)) {
474 948 : dev.writeAttr(SUMO_ATTR_VCLASS, toString(vehicleClass));
475 : }
476 2835 : if (wasSet(VTYPEPARS_EMISSIONCLASS_SET)) {
477 116 : dev.writeAttr(SUMO_ATTR_EMISSIONCLASS, PollutantsInterface::getName(emissionClass));
478 : }
479 2835 : if (wasSet(VTYPEPARS_MASS_SET)) {
480 10 : dev.writeAttr(SUMO_ATTR_MASS, mass);
481 : }
482 2835 : if (wasSet(VTYPEPARS_IMPATIENCE_SET)) {
483 32 : if (impatience == -std::numeric_limits<double>::max()) {
484 : dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
485 : } else {
486 32 : dev.writeAttr(SUMO_ATTR_IMPATIENCE, impatience);
487 : }
488 : }
489 2835 : if (wasSet(VTYPEPARS_SHAPE_SET)) {
490 102 : dev.writeAttr(SUMO_ATTR_GUISHAPE, getVehicleShapeName(shape));
491 : }
492 2835 : if (wasSet(VTYPEPARS_WIDTH_SET)) {
493 40 : dev.writeAttr(SUMO_ATTR_WIDTH, width);
494 : }
495 2835 : if (wasSet(VTYPEPARS_HEIGHT_SET)) {
496 0 : dev.writeAttr(SUMO_ATTR_HEIGHT, height);
497 : }
498 2835 : if (wasSet(VTYPEPARS_COLOR_SET)) {
499 396 : dev.writeAttr(SUMO_ATTR_COLOR, color);
500 : }
501 2835 : if (wasSet(VTYPEPARS_OSGFILE_SET)) {
502 0 : dev.writeAttr(SUMO_ATTR_OSGFILE, osgFile);
503 : }
504 2835 : if (wasSet(VTYPEPARS_IMGFILE_SET)) {
505 0 : dev.writeAttr(SUMO_ATTR_IMGFILE, imgFile);
506 : }
507 2835 : if (wasSet(VTYPEPARS_PERSON_CAPACITY)) {
508 0 : dev.writeAttr(SUMO_ATTR_PERSON_CAPACITY, personCapacity);
509 : }
510 2835 : if (wasSet(VTYPEPARS_CONTAINER_CAPACITY)) {
511 0 : dev.writeAttr(SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity);
512 : }
513 2835 : if (wasSet(VTYPEPARS_BOARDING_DURATION)) {
514 16 : dev.writeAttr(SUMO_ATTR_BOARDING_DURATION, time2string(boardingDuration));
515 : }
516 2835 : if (wasSet(VTYPEPARS_LOADING_DURATION)) {
517 16 : dev.writeAttr(SUMO_ATTR_LOADING_DURATION, time2string(loadingDuration));
518 : }
519 2835 : if (wasSet(VTYPEPARS_MAXSPEED_LAT_SET)) {
520 8 : dev.writeAttr(SUMO_ATTR_MAXSPEED_LAT, maxSpeedLat);
521 : }
522 2835 : if (wasSet(VTYPEPARS_LATALIGNMENT_SET)) {
523 8 : switch (latAlignmentProcedure) {
524 0 : case LatAlignmentDefinition::GIVEN:
525 0 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, latAlignmentOffset);
526 : break;
527 : case LatAlignmentDefinition::RIGHT:
528 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "right");
529 : break;
530 : case LatAlignmentDefinition::CENTER:
531 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "center");
532 : break;
533 : case LatAlignmentDefinition::ARBITRARY:
534 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "arbitrary");
535 : break;
536 : case LatAlignmentDefinition::NICE:
537 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "nice");
538 : break;
539 : case LatAlignmentDefinition::COMPACT:
540 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "compact");
541 : break;
542 : case LatAlignmentDefinition::LEFT:
543 : dev.writeAttr(SUMO_ATTR_LATALIGNMENT, "left");
544 : break;
545 : case LatAlignmentDefinition::DEFAULT:
546 : default:
547 : break;
548 : }
549 : }
550 2835 : if (wasSet(VTYPEPARS_MINGAP_LAT_SET)) {
551 8 : dev.writeAttr(SUMO_ATTR_MINGAP_LAT, minGapLat);
552 : }
553 2835 : if (wasSet(VTYPEPARS_MANEUVER_ANGLE_TIMES_SET)) {
554 0 : dev.writeAttr(SUMO_ATTR_MANEUVER_ANGLE_TIMES, getManoeuverAngleTimesS());
555 : }
556 2835 : if (wasSet(VTYPEPARS_SCALE_SET)) {
557 0 : dev.writeAttr(SUMO_ATTR_SCALE, scale);
558 : }
559 2835 : if (wasSet(VTYPEPARS_TTT_SET)) {
560 16 : dev.writeAttr(SUMO_ATTR_TIME_TO_TELEPORT, time2string(timeToTeleport));
561 : }
562 2835 : if (wasSet(VTYPEPARS_TTT_BIDI_SET)) {
563 0 : dev.writeAttr(SUMO_ATTR_TIME_TO_TELEPORT_BIDI, time2string(timeToTeleportBidi));
564 : }
565 2835 : if (wasSet(VTYPEPARS_SPEEDFACTOR_PREMATURE_SET)) {
566 0 : dev.writeAttr(SUMO_ATTR_SPEEDFACTOR_PREMATURE, speedFactorPremature);
567 : }
568 2835 : if (wasSet(VTYPEPARS_BOARDING_FACTOR_SET)) {
569 0 : dev.writeAttr(SUMO_ATTR_BOARDING_FACTOR, boardingFactor);
570 : }
571 2835 : if (wasSet(VTYPEPARS_LANE_CHANGE_MODEL_SET)) {
572 0 : dev.writeAttr(SUMO_ATTR_LANE_CHANGE_MODEL, lcModel);
573 : }
574 : // Write Lane Change Model parameters
575 2835 : for (const auto& lcParam : lcParameter) {
576 0 : dev.writeAttr(lcParam.first, lcParam.second);
577 : }
578 : // Write Junction Model parameter
579 2835 : for (const auto& jmParam : jmParameter) {
580 0 : dev.writeAttr(jmParam.first, jmParam.second);
581 : }
582 2835 : if (wasSet(VTYPEPARS_CAR_FOLLOW_MODEL)) {
583 52 : dev.writeAttr(SUMO_ATTR_CAR_FOLLOW_MODEL, SUMOXMLDefinitions::CarFollowModels.getString(cfModel));
584 : }
585 : // Write Car Following Model parameters
586 6125 : for (const auto& cfParam : cfParameter) {
587 3290 : dev.writeAttr(cfParam.first, cfParam.second);
588 : }
589 : // Write carriage length
590 2835 : if (wasSet(VTYPEPARS_CARRIAGE_LENGTH_SET)) {
591 0 : dev.openTag(SUMO_TAG_PARAM);
592 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_CARRIAGE_LENGTH));
593 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(carriageLength));
594 0 : dev.closeTag();
595 : }
596 : // Write locomotive length
597 2835 : if (wasSet(VTYPEPARS_LOCOMOTIVE_LENGTH_SET)) {
598 0 : dev.openTag(SUMO_TAG_PARAM);
599 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_LOCOMOTIVE_LENGTH));
600 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(locomotiveLength));
601 0 : dev.closeTag();
602 : }
603 : // Write carriage gap
604 2835 : if (wasSet(VTYPEPARS_CARRIAGE_GAP_SET)) {
605 0 : dev.openTag(SUMO_TAG_PARAM);
606 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_CARRIAGE_GAP));
607 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(carriageGap));
608 0 : dev.closeTag();
609 : }
610 : // Write carriage doors
611 2835 : if (wasSet(VTYPEPARS_CARRIAGE_DOORS_SET)) {
612 0 : dev.openTag(SUMO_TAG_PARAM);
613 0 : dev.writeAttr(SUMO_ATTR_KEY, toString(SUMO_ATTR_CARRIAGE_DOORS));
614 0 : dev.writeAttr(SUMO_ATTR_VALUE, toString(carriageDoors));
615 0 : dev.closeTag();
616 : }
617 : // Write rest of parameters
618 2835 : writeParams(dev);
619 : // close tag
620 5670 : dev.closeTag();
621 : }
622 :
623 :
624 : double
625 4507074 : SUMOVTypeParameter::getCFParam(const SumoXMLAttr attr, const double defaultValue) const {
626 : if (cfParameter.count(attr)) {
627 52721 : return StringUtils::toDouble(cfParameter.find(attr)->second);
628 : } else {
629 : return defaultValue;
630 : }
631 : }
632 :
633 :
634 : std::string
635 1352 : SUMOVTypeParameter::getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
636 : if (cfParameter.count(attr)) {
637 : return cfParameter.find(attr)->second;
638 : } else {
639 : return defaultValue;
640 : }
641 : }
642 :
643 :
644 : double
645 98824664 : SUMOVTypeParameter::getLCParam(const SumoXMLAttr attr, const double defaultValue) const {
646 : if (lcParameter.count(attr)) {
647 332916 : return StringUtils::toDouble(lcParameter.find(attr)->second);
648 : } else {
649 : return defaultValue;
650 : }
651 : }
652 :
653 :
654 : std::string
655 99212 : SUMOVTypeParameter::getLCParamString(const SumoXMLAttr attr, const std::string& defaultValue) const {
656 : if (lcParameter.count(attr)) {
657 : return lcParameter.find(attr)->second;
658 : } else {
659 : return defaultValue;
660 : }
661 : }
662 :
663 :
664 : const SUMOVTypeParameter::SubParams&
665 140429 : SUMOVTypeParameter::getLCParams() const {
666 140429 : return lcParameter;
667 : }
668 :
669 :
670 : double
671 2786048827 : SUMOVTypeParameter::getJMParam(const SumoXMLAttr attr, const double defaultValue) const {
672 : if (jmParameter.count(attr)) {
673 18389219 : return StringUtils::toDouble(jmParameter.find(attr)->second);
674 : } else {
675 : return defaultValue;
676 : }
677 : }
678 :
679 :
680 : std::string
681 0 : SUMOVTypeParameter::getJMParamString(const SumoXMLAttr attr, const std::string defaultValue) const {
682 : if (jmParameter.count(attr)) {
683 : return jmParameter.find(attr)->second;
684 : } else {
685 : return defaultValue;
686 : }
687 : }
688 :
689 : SUMOTime
690 30 : SUMOVTypeParameter::getEntryManoeuvreTime(const int angle) const {
691 : SUMOTime last = 0;
692 90 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
693 90 : if (angle <= angleTime.first) {
694 : return (angleTime.second.first);
695 : } else {
696 : last = angleTime.second.first;
697 : }
698 : }
699 0 : return (last);
700 : }
701 :
702 : SUMOTime
703 30 : SUMOVTypeParameter::getExitManoeuvreTime(const int angle) const {
704 : SUMOTime last = 0;
705 90 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
706 90 : if (angle <= angleTime.first) {
707 : return (angleTime.second.second);
708 : } else {
709 : last = angleTime.second.second;
710 : }
711 : }
712 0 : return (last);
713 : }
714 :
715 : std::string
716 0 : SUMOVTypeParameter::getManoeuverAngleTimesS() const {
717 0 : std::stringstream stream;
718 :
719 : stream << std::fixed << std::setprecision(1);
720 : int count = 0;
721 0 : for (std::pair<int, std::pair<SUMOTime, SUMOTime>> angleTime : myManoeuverAngleTimes) {
722 0 : if (count++ > 0) {
723 0 : stream << ",";
724 : }
725 0 : stream << toString(angleTime.first) + " " << STEPS2TIME(angleTime.second.first) << " " << STEPS2TIME(angleTime.second.second);
726 : }
727 : std::string triplets = stream.str();
728 0 : return triplets;
729 0 : }
730 :
731 :
732 : void
733 12 : SUMOVTypeParameter::cacheParamRestrictions(const std::vector<std::string>& restrictionKeys) {
734 24 : for (const std::string& key : restrictionKeys) {
735 24 : paramRestrictions.push_back(StringUtils::toDouble(getParameter(key, "0")));
736 : }
737 12 : }
738 :
739 :
740 : void
741 319410 : SUMOVTypeParameter::initRailVisualizationParameters() {
742 638820 : if (hasParameter("carriageLength")) {
743 114 : carriageLength = StringUtils::toDouble(getParameter("carriageLength"));
744 57 : parametersSet |= VTYPEPARS_CARRIAGE_LENGTH_SET;
745 : } else {
746 319353 : switch (shape) {
747 6 : case SUMOVehicleShape::BUS_FLEXIBLE:
748 6 : carriageLength = 8.25; // 16.5 overall, 2 modules http://de.wikipedia.org/wiki/Ikarus_180
749 6 : carriageGap = 0;
750 6 : break;
751 45155 : case SUMOVehicleShape::RAIL:
752 45155 : if (vehicleClass == SVC_RAIL_ELECTRIC) {
753 24 : carriageLength = 24.5;
754 24 : locomotiveLength = 19.100; // https://en.wikipedia.org/wiki/DB_Class_101
755 45131 : } else if (vehicleClass == SVC_RAIL_FAST) {
756 24 : carriageLength = 24.775; // http://de.wikipedia.org/wiki/ICE_3
757 24 : locomotiveLength = 25.835;
758 : } else {
759 45107 : carriageLength = 24.5; // http://de.wikipedia.org/wiki/UIC-Y-Wagen_%28DR%29
760 45107 : locomotiveLength = 16.4; // https://en.wikipedia.org/wiki/DB_Class_218
761 : }
762 : break;
763 542 : case SUMOVehicleShape::RAIL_CAR:
764 542 : if (vehicleClass == SVC_TRAM) {
765 129 : carriageLength = 5.71; // http://de.wikipedia.org/wiki/Bombardier_Flexity_Berlin
766 129 : locomotiveLength = 5.71;
767 413 : } else if (vehicleClass == SVC_RAIL_URBAN) {
768 365 : carriageLength = 18.4; // https://en.wikipedia.org/wiki/DBAG_Class_481
769 365 : locomotiveLength = 18.4;
770 : } else {
771 48 : carriageLength = 16.85; // 67.4m overall, 4 carriages http://de.wikipedia.org/wiki/DB-Baureihe_423
772 : }
773 : break;
774 8 : case SUMOVehicleShape::RAIL_CARGO:
775 8 : carriageLength = 13.86; // UIC 571-1 http://de.wikipedia.org/wiki/Flachwagen
776 8 : break;
777 7 : case SUMOVehicleShape::TRUCK_SEMITRAILER:
778 7 : carriageLength = 13.5;
779 7 : locomotiveLength = 2.5;
780 7 : carriageGap = 0.5;
781 7 : break;
782 81 : case SUMOVehicleShape::TRUCK_1TRAILER:
783 81 : carriageLength = 6.75;
784 81 : locomotiveLength = 2.5 + 6.75;
785 81 : carriageGap = 0.5;
786 81 : break;
787 : default:
788 : break;
789 : }
790 : }
791 638820 : if (hasParameter("locomotiveLength")) {
792 58 : locomotiveLength = StringUtils::toDouble(getParameter("locomotiveLength"));
793 29 : parametersSet |= VTYPEPARS_LOCOMOTIVE_LENGTH_SET;
794 319381 : } else if (locomotiveLength < 0) {
795 273644 : locomotiveLength = carriageLength;
796 : }
797 638820 : if (hasParameter("carriageGap")) {
798 8 : carriageGap = StringUtils::toDouble(getParameter("carriageGap"));
799 4 : parametersSet |= VTYPEPARS_CARRIAGE_GAP_SET;
800 : }
801 638820 : if (hasParameter("carriageDoors")) {
802 24 : carriageDoors = StringUtils::toInt(getParameter("carriageDoors"));
803 12 : parametersSet |= VTYPEPARS_CARRIAGE_DOORS_SET;
804 : }
805 638820 : if (hasParameter("frontSeatPos")) {
806 30 : frontSeatPos = StringUtils::toDouble(getParameter("frontSeatPos"));
807 15 : parametersSet |= VTYPEPARS_FRONT_SEAT_POS_SET;
808 : } else {
809 319395 : switch (shape) {
810 227 : case SUMOVehicleShape::SHIP:
811 227 : frontSeatPos = 5;
812 227 : break;
813 200 : case SUMOVehicleShape::DELIVERY:
814 200 : frontSeatPos = 1.2;
815 200 : break;
816 44060 : case SUMOVehicleShape::BICYCLE:
817 44060 : frontSeatPos = 0.6;
818 44060 : break;
819 262 : case SUMOVehicleShape::MOPED:
820 : case SUMOVehicleShape::MOTORCYCLE:
821 262 : frontSeatPos = 0.9;
822 262 : break;
823 929 : case SUMOVehicleShape::BUS:
824 : case SUMOVehicleShape::BUS_COACH:
825 : case SUMOVehicleShape::BUS_FLEXIBLE:
826 : case SUMOVehicleShape::BUS_TROLLEY:
827 929 : frontSeatPos = 0.5;
828 929 : break;
829 605 : case SUMOVehicleShape::TRUCK:
830 : case SUMOVehicleShape::TRUCK_1TRAILER:
831 : case SUMOVehicleShape::TRUCK_SEMITRAILER:
832 605 : frontSeatPos = 0.8;
833 605 : break;
834 : default:
835 : break;
836 : }
837 : }
838 :
839 638820 : if (hasParameter("seatingWidth")) {
840 14 : seatingWidth = StringUtils::toDouble(getParameter("seatingWidth"));
841 7 : parametersSet |= VTYPEPARS_SEATING_WIDTH_SET;
842 : }
843 319410 : }
844 :
845 :
846 : double
847 321199 : SUMOVTypeParameter::getDefaultAccel(const SUMOVehicleClass vc) {
848 321199 : switch (vc) {
849 : case SVC_PEDESTRIAN:
850 : case SVC_WHEELCHAIR:
851 : return 1.5;
852 : case SVC_BICYCLE:
853 : case SVC_SCOOTER:
854 : return 1.2;
855 139 : case SVC_MOTORCYCLE:
856 139 : return 6.;
857 : case SVC_MOPED:
858 : return 1.1;
859 498 : case SVC_TRUCK:
860 498 : return 1.3;
861 : case SVC_TRAILER:
862 : return 1.1;
863 : case SVC_BUS:
864 : return 1.2;
865 41 : case SVC_COACH:
866 41 : return 2.;
867 : case SVC_TRAM:
868 : return 1.;
869 : case SVC_RAIL_URBAN:
870 : return 1.;
871 45249 : case SVC_RAIL:
872 45249 : return 0.25;
873 48 : case SVC_RAIL_ELECTRIC:
874 : case SVC_RAIL_FAST:
875 48 : return 0.5;
876 227 : case SVC_SHIP:
877 227 : return 0.1;
878 159262 : default:
879 159262 : return 2.6;//2.9;
880 : }
881 : }
882 :
883 :
884 : double
885 727201 : SUMOVTypeParameter::getDefaultDecel(const SUMOVehicleClass vc) {
886 727201 : switch (vc) {
887 : case SVC_PEDESTRIAN:
888 : case SVC_WHEELCHAIR:
889 : return 2.;
890 : case SVC_BICYCLE:
891 : case SVC_SCOOTER:
892 : return 3.;
893 236 : case SVC_MOPED:
894 236 : return 7.;
895 278 : case SVC_MOTORCYCLE:
896 278 : return 10.;
897 2768 : case SVC_TRUCK:
898 : case SVC_TRAILER:
899 : case SVC_BUS:
900 : case SVC_COACH:
901 2768 : return 4.;
902 : case SVC_TRAM:
903 : case SVC_RAIL_URBAN:
904 : return 3.;
905 133738 : case SVC_RAIL:
906 : case SVC_RAIL_ELECTRIC:
907 : case SVC_RAIL_FAST:
908 133738 : return 1.3;
909 454 : case SVC_SHIP:
910 454 : return 0.15;
911 360355 : default:
912 360355 : return 4.5;//7.5;
913 : }
914 : }
915 :
916 :
917 : double
918 640533 : SUMOVTypeParameter::getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption) {
919 640533 : if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT) {
920 : double vcDecel;
921 635125 : switch (vc) {
922 : case SVC_PEDESTRIAN:
923 : case SVC_WHEELCHAIR:
924 : vcDecel = 5.;
925 : break;
926 : case SVC_BICYCLE:
927 : case SVC_SCOOTER:
928 : vcDecel = 7.;
929 : break;
930 514 : case SVC_MOPED:
931 : case SVC_MOTORCYCLE:
932 : vcDecel = 10.;
933 514 : break;
934 : case SVC_TRUCK:
935 : case SVC_TRAILER:
936 : case SVC_BUS:
937 : case SVC_COACH:
938 : case SVC_TRAM:
939 : case SVC_RAIL_URBAN:
940 : vcDecel = 7.;
941 : break;
942 : case SVC_RAIL:
943 : case SVC_RAIL_ELECTRIC:
944 : case SVC_RAIL_FAST:
945 : vcDecel = 5.;
946 : break;
947 454 : case SVC_SHIP:
948 : vcDecel = 1.;
949 454 : break;
950 313733 : default:
951 : vcDecel = 9.;
952 : }
953 : return MAX2(decel, vcDecel);
954 5408 : } else if (defaultOption == VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL) {
955 : return decel;
956 : } else {
957 : // value already checked in MSFrame::checkOptions
958 : return MAX2(decel, defaultOption);
959 : }
960 : }
961 :
962 :
963 :
964 : double
965 310695 : SUMOVTypeParameter::getDefaultImperfection(const SUMOVehicleClass vc) {
966 310695 : switch (vc) {
967 : case SVC_TRAM:
968 : case SVC_RAIL_URBAN:
969 : case SVC_RAIL:
970 : case SVC_RAIL_ELECTRIC:
971 : case SVC_RAIL_FAST:
972 : case SVC_SHIP:
973 : return 0.;
974 266224 : default:
975 266224 : return 0.5;
976 : }
977 : }
978 :
979 : const SUMOVTypeParameter&
980 16323488 : SUMOVTypeParameter::getDefault() {
981 16328953 : static SUMOVTypeParameter defaultParams("");
982 16323488 : return defaultParams;
983 : }
984 :
985 : bool
986 1719 : SUMOVTypeParameter::parseLatAlignment(const std::string& val, double& lao, LatAlignmentDefinition& lad) {
987 : bool ok = true;
988 1719 : lao = 0.0;
989 1719 : lad = LatAlignmentDefinition::GIVEN;
990 1719 : if (val == "right") {
991 315 : lad = LatAlignmentDefinition::RIGHT;
992 1404 : } else if (val == "center") {
993 677 : lad = LatAlignmentDefinition::CENTER;
994 727 : } else if (val == "arbitrary") {
995 336 : lad = LatAlignmentDefinition::ARBITRARY;
996 391 : } else if (val == "nice") {
997 46 : lad = LatAlignmentDefinition::NICE;
998 345 : } else if (val == "compact") {
999 244 : lad = LatAlignmentDefinition::COMPACT;
1000 101 : } else if (val == "left") {
1001 86 : lad = LatAlignmentDefinition::LEFT;
1002 : } else {
1003 : try {
1004 15 : lao = StringUtils::toDouble(val);
1005 0 : } catch (...) {
1006 : ok = false;
1007 0 : }
1008 : }
1009 1719 : return ok;
1010 : }
1011 :
1012 :
1013 : SUMOTime
1014 69562872 : SUMOVTypeParameter::getTimeToTeleport(SUMOTime defaultValue) const {
1015 69562872 : return timeToTeleport == TTT_UNSET ? defaultValue : timeToTeleport;
1016 : }
1017 :
1018 : SUMOTime
1019 69562872 : SUMOVTypeParameter::getTimeToTeleportBidi(SUMOTime defaultValue) const {
1020 69562872 : return timeToTeleportBidi == TTT_UNSET ? defaultValue : timeToTeleportBidi;
1021 : }
1022 :
1023 : /****************************************************************************/
|