LCOV - code coverage report
Current view: top level - src/utils/vehicle - SUMOVTypeParameter.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 89.1 % 644 574
Test Date: 2025-11-13 15:38:19 Functions: 89.7 % 29 26

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

Generated by: LCOV version 2.0-1