Path: blob/main/src/utils/handlers/AdditionalHandler.cpp
193828 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file AdditionalHandler.cpp14/// @author Pablo Alvarez Lopez15/// @date Jun 202116///17// The XML-Handler for additionals loading18/****************************************************************************/19#include <config.h>2021#include <utils/common/MsgHandler.h>22#include <utils/xml/SUMOSAXHandler.h>23#include <utils/shapes/Shape.h>24#include <utils/shapes/PointOfInterest.h>25#include <utils/options/OptionsCont.h>26#include <utils/vehicle/SUMOVehicleParserHelper.h>27#include <utils/xml/SUMOXMLDefinitions.h>2829#include "AdditionalHandler.h"303132// ===========================================================================33// method definitions34// ===========================================================================3536AdditionalHandler::AdditionalHandler(FileBucket* fileBucket) :37CommonHandler(fileBucket) {38}394041AdditionalHandler::~AdditionalHandler() {}424344bool45AdditionalHandler::beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes& attrs) {46// open SUMOBaseOBject47myCommonXMLStructure.openSUMOBaseOBject();48// check tag49try {50switch (tag) {51// Stopping Places52case SUMO_TAG_BUS_STOP:53parseBusStopAttributes(attrs);54break;55case SUMO_TAG_TRAIN_STOP:56parseTrainStopAttributes(attrs);57break;58case SUMO_TAG_ACCESS:59parseAccessAttributes(attrs);60break;61case SUMO_TAG_CONTAINER_STOP:62parseContainerStopAttributes(attrs);63break;64case SUMO_TAG_CHARGING_STATION:65parseChargingStationAttributes(attrs);66break;67case SUMO_TAG_PARKING_AREA:68parseParkingAreaAttributes(attrs);69break;70case SUMO_TAG_PARKING_SPACE:71parseParkingSpaceAttributes(attrs);72break;73// Detectors74case SUMO_TAG_E1DETECTOR:75case SUMO_TAG_INDUCTION_LOOP:76parseE1Attributes(attrs);77break;78case SUMO_TAG_E2DETECTOR:79case SUMO_TAG_LANE_AREA_DETECTOR:80parseE2Attributes(attrs);81break;82case SUMO_TAG_E3DETECTOR:83case SUMO_TAG_ENTRY_EXIT_DETECTOR:84parseE3Attributes(attrs);85break;86case SUMO_TAG_DET_ENTRY:87parseEntryAttributes(attrs);88break;89case SUMO_TAG_DET_EXIT:90parseExitAttributes(attrs);91break;92case SUMO_TAG_INSTANT_INDUCTION_LOOP:93parseE1InstantAttributes(attrs);94break;95// TAZs96case SUMO_TAG_TAZ:97parseTAZAttributes(attrs);98break;99case SUMO_TAG_TAZSOURCE:100parseTAZSourceAttributes(attrs);101break;102case SUMO_TAG_TAZSINK:103parseTAZSinkAttributes(attrs);104break;105// Variable Speed Sign106case SUMO_TAG_VSS:107parseVariableSpeedSignAttributes(attrs);108break;109case SUMO_TAG_STEP:110parseVariableSpeedSignStepAttributes(attrs);111break;112// Calibrator113case SUMO_TAG_CALIBRATOR:114case GNE_TAG_CALIBRATOR_LANE:115parseCalibratorAttributes(attrs);116break;117// flow (calibrator)118case SUMO_TAG_FLOW:119parseCalibratorFlowAttributes(attrs);120break;121// Rerouter122case SUMO_TAG_REROUTER:123parseRerouterAttributes(attrs);124break;125case SUMO_TAG_INTERVAL:126parseRerouterIntervalAttributes(attrs);127break;128case SUMO_TAG_CLOSING_LANE_REROUTE:129parseClosingLaneRerouteAttributes(attrs);130break;131case SUMO_TAG_CLOSING_REROUTE:132parseClosingRerouteAttributes(attrs);133break;134case SUMO_TAG_DEST_PROB_REROUTE:135parseDestProbRerouteAttributes(attrs);136break;137case SUMO_TAG_PARKING_AREA_REROUTE:138parseParkingAreaRerouteAttributes(attrs);139break;140case SUMO_TAG_ROUTE_PROB_REROUTE:141parseRouteProbRerouteAttributes(attrs);142break;143// Route probe144case SUMO_TAG_ROUTEPROBE:145parseRouteProbeAttributes(attrs);146break;147// Vaporizer (deprecated)148case SUMO_TAG_VAPORIZER:149parseVaporizerAttributes(attrs);150break;151// wires152case SUMO_TAG_TRACTION_SUBSTATION:153parseTractionSubstation(attrs);154break;155case SUMO_TAG_OVERHEAD_WIRE_CLAMP:156parseOverheadWireClamp(attrs);157break;158case SUMO_TAG_OVERHEAD_WIRE_SECTION:159parseOverheadWire(attrs);160break;161// Poly162case SUMO_TAG_POLY:163parsePolyAttributes(attrs);164break;165case SUMO_TAG_POI:166parsePOIAttributes(attrs);167break;168// JuPedSim169case GNE_TAG_JPS_WALKABLEAREA:170parseJpsWalkableAreaAttributes(attrs);171break;172case GNE_TAG_JPS_OBSTACLE:173parseJpsObstacleAttributes(attrs);174break;175// parameters176case SUMO_TAG_PARAM:177parseParameters(attrs);178break;179default:180// tag cannot be parsed in AdditionalHandler181myCommonXMLStructure.abortSUMOBaseOBject();182return false;183}184} catch (InvalidArgument& e) {185writeError(e.what());186}187return true;188}189190191void192AdditionalHandler::endParseAttributes() {193// get last inserted object194CommonXMLStructure::SumoBaseObject* obj = myCommonXMLStructure.getCurrentSumoBaseObject();195if (obj) {196// close SUMOBaseOBject197myCommonXMLStructure.closeSUMOBaseOBject();198// check tag199switch (obj->getTag()) {200// Stopping Places201case SUMO_TAG_BUS_STOP:202case SUMO_TAG_TRAIN_STOP:203case SUMO_TAG_CONTAINER_STOP:204case SUMO_TAG_CHARGING_STATION:205case SUMO_TAG_PARKING_AREA:206// detectors207case SUMO_TAG_E1DETECTOR:208case SUMO_TAG_INDUCTION_LOOP:209case SUMO_TAG_E2DETECTOR:210case SUMO_TAG_LANE_AREA_DETECTOR:211case SUMO_TAG_E3DETECTOR:212case SUMO_TAG_ENTRY_EXIT_DETECTOR:213case SUMO_TAG_INSTANT_INDUCTION_LOOP:214// TAZs215case SUMO_TAG_TAZ:216// Variable Speed Sign217case SUMO_TAG_VSS:218// Calibrator219case SUMO_TAG_CALIBRATOR:220case GNE_TAG_CALIBRATOR_LANE:221// Rerouter222case SUMO_TAG_REROUTER:223// Route probe224case SUMO_TAG_ROUTEPROBE:225// Vaporizer (deprecated)226case SUMO_TAG_VAPORIZER:227// wires228case SUMO_TAG_TRACTION_SUBSTATION:229case SUMO_TAG_OVERHEAD_WIRE_SECTION:230case SUMO_TAG_OVERHEAD_WIRE_CLAMP:231// Shapes232case SUMO_TAG_POLY:233case SUMO_TAG_POI:234// JuPedSim235case GNE_TAG_JPS_WALKABLEAREA:236case GNE_TAG_JPS_OBSTACLE:237// parse object and all their childrens238parseSumoBaseObject(obj);239// delete object (and all of their childrens)240delete obj;241break;242default:243break;244}245}246}247248249void250AdditionalHandler::parseSumoBaseObject(CommonXMLStructure::SumoBaseObject* obj) {251// check if loading was aborted252if (!myAbortLoading) {253// switch tag254switch (obj->getTag()) {255// Stopping Places256case SUMO_TAG_BUS_STOP:257if (buildBusStop(obj,258obj->getStringAttribute(SUMO_ATTR_ID),259obj->getStringAttribute(SUMO_ATTR_LANE),260obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),261obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),262obj->getStringAttribute(SUMO_ATTR_NAME),263obj->getStringListAttribute(SUMO_ATTR_LINES),264obj->getIntAttribute(SUMO_ATTR_PERSON_CAPACITY),265obj->getDoubleAttribute(SUMO_ATTR_PARKING_LENGTH),266obj->getColorAttribute(SUMO_ATTR_COLOR),267obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),268obj->getDoubleAttribute(SUMO_ATTR_ANGLE),269obj->getParameters())) {270obj->markAsCreated();271}272break;273case SUMO_TAG_TRAIN_STOP:274if (buildTrainStop(obj,275obj->getStringAttribute(SUMO_ATTR_ID),276obj->getStringAttribute(SUMO_ATTR_LANE),277obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),278obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),279obj->getStringAttribute(SUMO_ATTR_NAME),280obj->getStringListAttribute(SUMO_ATTR_LINES),281obj->getIntAttribute(SUMO_ATTR_PERSON_CAPACITY),282obj->getDoubleAttribute(SUMO_ATTR_PARKING_LENGTH),283obj->getColorAttribute(SUMO_ATTR_COLOR),284obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),285obj->getDoubleAttribute(SUMO_ATTR_ANGLE),286obj->getParameters())) {287obj->markAsCreated();288}289break;290case SUMO_TAG_ACCESS:291if (buildAccess(obj,292obj->getStringAttribute(SUMO_ATTR_LANE),293obj->getStringAttribute(SUMO_ATTR_POSITION),294obj->getDoubleAttribute(SUMO_ATTR_LENGTH),295obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),296obj->getParameters())) {297obj->markAsCreated();298}299break;300case SUMO_TAG_CONTAINER_STOP:301if (buildContainerStop(obj,302obj->getStringAttribute(SUMO_ATTR_ID),303obj->getStringAttribute(SUMO_ATTR_LANE),304obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),305obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),306obj->getStringAttribute(SUMO_ATTR_NAME),307obj->getStringListAttribute(SUMO_ATTR_LINES),308obj->getIntAttribute(SUMO_ATTR_CONTAINER_CAPACITY),309obj->getDoubleAttribute(SUMO_ATTR_PARKING_LENGTH),310obj->getColorAttribute(SUMO_ATTR_COLOR),311obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),312obj->getDoubleAttribute(SUMO_ATTR_ANGLE),313obj->getParameters())) {314obj->markAsCreated();315}316break;317case SUMO_TAG_CHARGING_STATION:318if (buildChargingStation(obj,319obj->getStringAttribute(SUMO_ATTR_ID),320obj->getStringAttribute(SUMO_ATTR_LANE),321obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),322obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),323obj->getStringAttribute(SUMO_ATTR_NAME),324obj->getDoubleAttribute(SUMO_ATTR_CHARGINGPOWER),325obj->getDoubleAttribute(SUMO_ATTR_TOTALPOWER),326obj->getDoubleAttribute(SUMO_ATTR_EFFICIENCY),327obj->getBoolAttribute(SUMO_ATTR_CHARGEINTRANSIT),328obj->getTimeAttribute(SUMO_ATTR_CHARGEDELAY),329obj->getStringAttribute(SUMO_ATTR_CHARGETYPE),330obj->getTimeAttribute(SUMO_ATTR_WAITINGTIME),331obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),332obj->getStringAttribute(SUMO_ATTR_PARKING_AREA),333obj->getParameters())) {334obj->markAsCreated();335}336break;337case SUMO_TAG_PARKING_AREA:338if (buildParkingArea(obj,339obj->getStringAttribute(SUMO_ATTR_ID),340obj->getStringAttribute(SUMO_ATTR_LANE),341obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),342obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),343obj->getStringAttribute(SUMO_ATTR_DEPARTPOS),344obj->getStringAttribute(SUMO_ATTR_NAME),345obj->getStringListAttribute(SUMO_ATTR_ACCEPTED_BADGES),346obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),347obj->getIntAttribute(SUMO_ATTR_ROADSIDE_CAPACITY),348obj->getBoolAttribute(SUMO_ATTR_ONROAD),349obj->getDoubleAttribute(SUMO_ATTR_WIDTH),350obj->getDoubleAttribute(SUMO_ATTR_LENGTH),351obj->getDoubleAttribute(SUMO_ATTR_ANGLE),352obj->getBoolAttribute(SUMO_ATTR_LEFTHAND),353obj->getParameters())) {354obj->markAsCreated();355}356break;357case SUMO_TAG_PARKING_SPACE:358if (buildParkingSpace(obj,359obj->getDoubleAttribute(SUMO_ATTR_X),360obj->getDoubleAttribute(SUMO_ATTR_Y),361obj->getDoubleAttribute(SUMO_ATTR_Z),362obj->getStringAttribute(SUMO_ATTR_NAME),363obj->getStringAttribute(SUMO_ATTR_WIDTH),364obj->getStringAttribute(SUMO_ATTR_LENGTH),365obj->getStringAttribute(SUMO_ATTR_ANGLE),366obj->getDoubleAttribute(SUMO_ATTR_SLOPE),367obj->getParameters())) {368obj->markAsCreated();369}370break;371// Detectors372case SUMO_TAG_E1DETECTOR:373case SUMO_TAG_INDUCTION_LOOP:374// build E1375if (buildE1Detector(obj,376obj->getStringAttribute(SUMO_ATTR_ID),377obj->getStringAttribute(SUMO_ATTR_LANE),378obj->getDoubleAttribute(SUMO_ATTR_POSITION),379obj->getPeriodAttribute(),380obj->getStringAttribute(SUMO_ATTR_FILE),381obj->getStringListAttribute(SUMO_ATTR_VTYPES),382obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),383obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),384obj->getStringAttribute(SUMO_ATTR_NAME),385obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),386obj->getParameters())) {387obj->markAsCreated();388}389break;390case SUMO_TAG_E2DETECTOR:391case SUMO_TAG_LANE_AREA_DETECTOR:392if (obj->hasStringAttribute(SUMO_ATTR_LANE)) {393if (buildSingleLaneDetectorE2(obj,394obj->getStringAttribute(SUMO_ATTR_ID),395obj->getStringAttribute(SUMO_ATTR_LANE),396obj->getDoubleAttribute(SUMO_ATTR_POSITION),397obj->getDoubleAttribute(SUMO_ATTR_LENGTH),398obj->getPeriodAttribute(),399obj->getStringAttribute(SUMO_ATTR_TLID),400obj->getStringAttribute(SUMO_ATTR_FILE),401obj->getStringListAttribute(SUMO_ATTR_VTYPES),402obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),403obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),404obj->getStringAttribute(SUMO_ATTR_NAME),405obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),406obj->getDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD),407obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),408obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),409obj->getBoolAttribute(SUMO_ATTR_SHOW_DETECTOR),410obj->getParameters())) {411obj->markAsCreated();412}413} else {414if (buildMultiLaneDetectorE2(obj,415obj->getStringAttribute(SUMO_ATTR_ID),416obj->getStringListAttribute(SUMO_ATTR_LANES),417obj->getDoubleAttribute(SUMO_ATTR_POSITION),418obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),419obj->getPeriodAttribute(),420obj->getStringAttribute(SUMO_ATTR_TLID),421obj->getStringAttribute(SUMO_ATTR_FILE),422obj->getStringListAttribute(SUMO_ATTR_VTYPES),423obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),424obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),425obj->getStringAttribute(SUMO_ATTR_NAME),426obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),427obj->getDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD),428obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),429obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),430obj->getBoolAttribute(SUMO_ATTR_SHOW_DETECTOR),431obj->getParameters())) {432obj->markAsCreated();433}434}435break;436case SUMO_TAG_E3DETECTOR:437case SUMO_TAG_ENTRY_EXIT_DETECTOR:438if (buildDetectorE3(obj,439obj->getStringAttribute(SUMO_ATTR_ID),440obj->getPositionAttribute(SUMO_ATTR_POSITION),441obj->getPeriodAttribute(),442obj->getStringAttribute(SUMO_ATTR_FILE),443obj->getStringListAttribute(SUMO_ATTR_VTYPES),444obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),445obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),446obj->getStringAttribute(SUMO_ATTR_NAME),447obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),448obj->getDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD),449obj->getBoolAttribute(SUMO_ATTR_OPEN_ENTRY),450obj->getBoolAttribute(SUMO_ATTR_EXPECT_ARRIVAL),451obj->getParameters())) {452obj->markAsCreated();453}454break;455case SUMO_TAG_DET_ENTRY:456if (buildDetectorEntry(obj,457obj->getStringAttribute(SUMO_ATTR_LANE),458obj->getDoubleAttribute(SUMO_ATTR_POSITION),459obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),460obj->getParameters())) {461obj->markAsCreated();462}463break;464case SUMO_TAG_DET_EXIT:465if (buildDetectorExit(obj,466obj->getStringAttribute(SUMO_ATTR_LANE),467obj->getDoubleAttribute(SUMO_ATTR_POSITION),468obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),469obj->getParameters())) {470obj->markAsCreated();471}472break;473case SUMO_TAG_INSTANT_INDUCTION_LOOP:474if (buildDetectorE1Instant(obj,475obj->getStringAttribute(SUMO_ATTR_ID),476obj->getStringAttribute(SUMO_ATTR_LANE),477obj->getDoubleAttribute(SUMO_ATTR_POSITION),478obj->getStringAttribute(SUMO_ATTR_FILE),479obj->getStringListAttribute(SUMO_ATTR_VTYPES),480obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),481obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),482obj->getStringAttribute(SUMO_ATTR_NAME),483obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),484obj->getParameters())) {485obj->markAsCreated();486}487break;488// TAZs489case SUMO_TAG_TAZ:490if (buildTAZ(obj,491obj->getStringAttribute(SUMO_ATTR_ID),492obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),493obj->getPositionAttribute(SUMO_ATTR_CENTER),494obj->getBoolAttribute(SUMO_ATTR_FILL),495obj->getColorAttribute(SUMO_ATTR_COLOR),496obj->getStringListAttribute(SUMO_ATTR_EDGES),497obj->getStringAttribute(SUMO_ATTR_NAME),498obj->getParameters())) {499obj->markAsCreated();500}501break;502case SUMO_TAG_TAZSOURCE:503if (buildTAZSource(obj,504obj->getStringAttribute(SUMO_ATTR_ID),505obj->getDoubleAttribute(SUMO_ATTR_WEIGHT))) {506obj->markAsCreated();507}508break;509case SUMO_TAG_TAZSINK:510if (buildTAZSink(obj,511obj->getStringAttribute(SUMO_ATTR_ID),512obj->getDoubleAttribute(SUMO_ATTR_WEIGHT))) {513obj->markAsCreated();514}515break;516// Variable Speed Sign517case SUMO_TAG_VSS:518if (buildVariableSpeedSign(obj,519obj->getStringAttribute(SUMO_ATTR_ID),520obj->getPositionAttribute(SUMO_ATTR_POSITION),521obj->getStringListAttribute(SUMO_ATTR_LANES),522obj->getStringAttribute(SUMO_ATTR_NAME),523obj->getStringListAttribute(SUMO_ATTR_VTYPES),524obj->getParameters())) {525obj->markAsCreated();526}527break;528case SUMO_TAG_STEP:529if (buildVariableSpeedSignStep(obj,530obj->getTimeAttribute(SUMO_ATTR_TIME),531obj->getDoubleAttribute(SUMO_ATTR_SPEED))) {532obj->markAsCreated();533}534break;535// Calibrator536case SUMO_TAG_CALIBRATOR:537if (buildEdgeCalibrator(obj,538obj->getStringAttribute(SUMO_ATTR_ID),539obj->getStringAttribute(SUMO_ATTR_EDGE),540obj->getDoubleAttribute(SUMO_ATTR_POSITION),541obj->getStringAttribute(SUMO_ATTR_NAME),542obj->getStringAttribute(SUMO_ATTR_OUTPUT),543obj->getPeriodAttribute(),544obj->getStringAttribute(SUMO_ATTR_ROUTEPROBE),545obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),546obj->getStringListAttribute(SUMO_ATTR_VTYPES),547obj->getParameters())) {548obj->markAsCreated();549}550break;551case GNE_TAG_CALIBRATOR_LANE:552if (buildLaneCalibrator(obj,553obj->getStringAttribute(SUMO_ATTR_ID),554obj->getStringAttribute(SUMO_ATTR_LANE),555obj->getDoubleAttribute(SUMO_ATTR_POSITION),556obj->getStringAttribute(SUMO_ATTR_NAME),557obj->getStringAttribute(SUMO_ATTR_OUTPUT),558obj->getPeriodAttribute(),559obj->getStringAttribute(SUMO_ATTR_ROUTEPROBE),560obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),561obj->getStringListAttribute(SUMO_ATTR_VTYPES),562obj->getParameters())) {563obj->markAsCreated();564}565break;566case SUMO_TAG_FLOW:567if (buildCalibratorFlow(obj,568obj->getVehicleParameter())) {569obj->markAsCreated();570}571break;572// Rerouter573case SUMO_TAG_REROUTER:574if (buildRerouter(obj,575obj->getStringAttribute(SUMO_ATTR_ID),576obj->getPositionAttribute(SUMO_ATTR_POSITION),577obj->getStringListAttribute(SUMO_ATTR_EDGES),578obj->getDoubleAttribute(SUMO_ATTR_PROB),579obj->getStringAttribute(SUMO_ATTR_NAME),580obj->getBoolAttribute(SUMO_ATTR_OFF),581obj->getBoolAttribute(SUMO_ATTR_OPTIONAL),582obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),583obj->getStringListAttribute(SUMO_ATTR_VTYPES),584obj->getParameters())) {585obj->markAsCreated();586}587break;588case SUMO_TAG_CLOSING_LANE_REROUTE:589if (buildClosingLaneReroute(obj,590obj->getStringAttribute(SUMO_ATTR_ID),591parseVehicleClasses(obj->getStringAttribute(SUMO_ATTR_ALLOW),592obj->getStringAttribute(SUMO_ATTR_DISALLOW)))) {593obj->markAsCreated();594}595break;596case SUMO_TAG_CLOSING_REROUTE:597if (buildClosingReroute(obj,598obj->getStringAttribute(SUMO_ATTR_ID),599parseVehicleClasses(obj->getStringAttribute(SUMO_ATTR_ALLOW),600obj->getStringAttribute(SUMO_ATTR_DISALLOW)))) {601obj->markAsCreated();602}603break;604case SUMO_TAG_DEST_PROB_REROUTE:605if (buildDestProbReroute(obj,606obj->getStringAttribute(SUMO_ATTR_ID),607obj->getDoubleAttribute(SUMO_ATTR_PROB))) {608obj->markAsCreated();609}610break;611case SUMO_TAG_PARKING_AREA_REROUTE:612if (buildParkingAreaReroute(obj,613obj->getStringAttribute(SUMO_ATTR_ID),614obj->getDoubleAttribute(SUMO_ATTR_PROB),615obj->getBoolAttribute(SUMO_ATTR_VISIBLE))) {616obj->markAsCreated();617}618break;619case SUMO_TAG_ROUTE_PROB_REROUTE:620if (buildRouteProbReroute(obj,621obj->getStringAttribute(SUMO_ATTR_ID),622obj->getDoubleAttribute(SUMO_ATTR_PROB))) {623obj->markAsCreated();624}625break;626case SUMO_TAG_INTERVAL:627// check if is aREROUTER interval628if (obj->getParentSumoBaseObject()->getTag() == SUMO_TAG_REROUTER) {629if (buildRerouterInterval(obj,630obj->getTimeAttribute(SUMO_ATTR_BEGIN),631obj->getTimeAttribute(SUMO_ATTR_END))) {632obj->markAsCreated();633}634}635break;636// Route probe637case SUMO_TAG_ROUTEPROBE:638if (buildRouteProbe(obj,639obj->getStringAttribute(SUMO_ATTR_ID),640obj->getStringAttribute(SUMO_ATTR_EDGE),641obj->getPeriodAttribute(),642obj->getStringAttribute(SUMO_ATTR_NAME),643obj->getStringAttribute(SUMO_ATTR_FILE),644obj->getTimeAttribute(SUMO_ATTR_BEGIN),645obj->getStringListAttribute(SUMO_ATTR_VTYPES),646obj->getParameters())) {647obj->markAsCreated();648}649break;650// Vaporizer (deprecated)651case SUMO_TAG_VAPORIZER:652if (buildVaporizer(obj,653obj->getStringAttribute(SUMO_ATTR_EDGE),654obj->getTimeAttribute(SUMO_ATTR_BEGIN),655obj->getTimeAttribute(SUMO_ATTR_END),656obj->getStringAttribute(SUMO_ATTR_NAME),657obj->getParameters())) {658obj->markAsCreated();659}660break;661// wire elements662case SUMO_TAG_TRACTION_SUBSTATION:663if (buildTractionSubstation(obj,664obj->getStringAttribute(SUMO_ATTR_ID),665obj->getPositionAttribute(SUMO_ATTR_POSITION),666obj->getDoubleAttribute(SUMO_ATTR_VOLTAGE),667obj->getDoubleAttribute(SUMO_ATTR_CURRENTLIMIT),668obj->getParameters())) {669obj->markAsCreated();670}671break;672case SUMO_TAG_OVERHEAD_WIRE_SECTION:673if (buildOverheadWire(obj,674obj->getStringAttribute(SUMO_ATTR_ID),675obj->getStringAttribute(SUMO_ATTR_SUBSTATIONID),676obj->getStringListAttribute(SUMO_ATTR_LANES),677obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),678obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),679obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),680obj->getStringListAttribute(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN),681obj->getParameters())) {682obj->markAsCreated();683}684break;685case SUMO_TAG_OVERHEAD_WIRE_CLAMP:686if (buildOverheadWireClamp(obj,687obj->getStringAttribute(SUMO_ATTR_ID),688obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_START),689obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANESTART),690obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_END),691obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANEEND),692obj->getParameters())) {693obj->markAsCreated();694}695break;696// Polygon697case SUMO_TAG_POLY:698if (buildPolygon(obj,699obj->getStringAttribute(SUMO_ATTR_ID),700obj->getStringAttribute(SUMO_ATTR_TYPE),701obj->getColorAttribute(SUMO_ATTR_COLOR),702obj->getDoubleAttribute(SUMO_ATTR_LAYER),703obj->getDoubleAttribute(SUMO_ATTR_ANGLE),704obj->getStringAttribute(SUMO_ATTR_IMGFILE),705obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),706obj->getBoolAttribute(SUMO_ATTR_GEO),707obj->getBoolAttribute(SUMO_ATTR_FILL),708obj->getDoubleAttribute(SUMO_ATTR_LINEWIDTH),709obj->getStringAttribute(SUMO_ATTR_NAME),710obj->getParameters())) {711obj->markAsCreated();712}713break;714// POI715case SUMO_TAG_POI:716// check if we want to create a POI, POILane or POIGEO717if (obj->hasDoubleAttribute(SUMO_ATTR_X)) {718// build POI over view719if (buildPOI(obj,720obj->getStringAttribute(SUMO_ATTR_ID),721obj->getStringAttribute(SUMO_ATTR_TYPE),722obj->getColorAttribute(SUMO_ATTR_COLOR),723obj->getDoubleAttribute(SUMO_ATTR_X),724obj->getDoubleAttribute(SUMO_ATTR_Y),725obj->getStringAttribute(SUMO_ATTR_ICON),726obj->getDoubleAttribute(SUMO_ATTR_LAYER),727obj->getDoubleAttribute(SUMO_ATTR_ANGLE),728obj->getStringAttribute(SUMO_ATTR_IMGFILE),729obj->getDoubleAttribute(SUMO_ATTR_WIDTH),730obj->getDoubleAttribute(SUMO_ATTR_HEIGHT),731obj->getStringAttribute(SUMO_ATTR_NAME),732obj->getParameters())) {733obj->markAsCreated();734}735} else if (obj->hasStringAttribute(SUMO_ATTR_LANE)) {736// build POI over Lane737if (buildPOILane(obj,738obj->getStringAttribute(SUMO_ATTR_ID),739obj->getStringAttribute(SUMO_ATTR_TYPE),740obj->getColorAttribute(SUMO_ATTR_COLOR),741obj->getStringAttribute(SUMO_ATTR_LANE),742obj->getDoubleAttribute(SUMO_ATTR_POSITION),743obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),744obj->getDoubleAttribute(SUMO_ATTR_POSITION_LAT),745obj->getStringAttribute(SUMO_ATTR_ICON),746obj->getDoubleAttribute(SUMO_ATTR_LAYER),747obj->getDoubleAttribute(SUMO_ATTR_ANGLE),748obj->getStringAttribute(SUMO_ATTR_IMGFILE),749obj->getDoubleAttribute(SUMO_ATTR_WIDTH),750obj->getDoubleAttribute(SUMO_ATTR_HEIGHT),751obj->getStringAttribute(SUMO_ATTR_NAME),752obj->getParameters())) {753obj->markAsCreated();754}755} else {756// build POIGEO over view757if (buildPOIGeo(obj,758obj->getStringAttribute(SUMO_ATTR_ID),759obj->getStringAttribute(SUMO_ATTR_TYPE),760obj->getColorAttribute(SUMO_ATTR_COLOR),761obj->getDoubleAttribute(SUMO_ATTR_LON),762obj->getDoubleAttribute(SUMO_ATTR_LAT),763obj->getStringAttribute(SUMO_ATTR_ICON),764obj->getDoubleAttribute(SUMO_ATTR_LAYER),765obj->getDoubleAttribute(SUMO_ATTR_ANGLE),766obj->getStringAttribute(SUMO_ATTR_IMGFILE),767obj->getDoubleAttribute(SUMO_ATTR_WIDTH),768obj->getDoubleAttribute(SUMO_ATTR_HEIGHT),769obj->getStringAttribute(SUMO_ATTR_NAME),770obj->getParameters())) {771obj->markAsCreated();772}773}774break;775// Jps WalkableArea776case GNE_TAG_JPS_WALKABLEAREA:777if (buildJpsWalkableArea(obj,778obj->getStringAttribute(SUMO_ATTR_ID),779obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),780obj->getBoolAttribute(SUMO_ATTR_GEO),781obj->getStringAttribute(SUMO_ATTR_NAME),782obj->getParameters())) {783obj->markAsCreated();784}785break;786// Jps Obstacle787case GNE_TAG_JPS_OBSTACLE:788if (buildJpsObstacle(obj,789obj->getStringAttribute(SUMO_ATTR_ID),790obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),791obj->getBoolAttribute(SUMO_ATTR_GEO),792obj->getStringAttribute(SUMO_ATTR_NAME),793obj->getParameters())) {794obj->markAsCreated();795}796break;797default:798break;799}800// now iterate over childrens801for (const auto& child : obj->getSumoBaseObjectChildren()) {802// call this function recursively803parseSumoBaseObject(child);804}805}806}807808809void810AdditionalHandler::parseBusStopAttributes(const SUMOSAXAttributes& attrs) {811// declare Ok Flag812bool parsedOk = true;813// needed attributes814const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);815const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);816// optional attributes817const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);818const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);819const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");820const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());821const int personCapacity = attrs.getOpt<int>(SUMO_ATTR_PERSON_CAPACITY, id.c_str(), parsedOk, 6);822const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), parsedOk, 0);823const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);824const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);825const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);826// continue if flag is ok827if (parsedOk) {828// set tag829myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_BUS_STOP);830// add all attributes831myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);832myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);833myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);834myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);835myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);836myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);837myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_PERSON_CAPACITY, personCapacity);838myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PARKING_LENGTH, parkingLength);839myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);840myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);841myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);842} else {843myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);844}845}846847848void849AdditionalHandler::parseTrainStopAttributes(const SUMOSAXAttributes& attrs) {850// declare Ok Flag851bool parsedOk = true;852// needed attributes853const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);854const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);855// optional attributes856const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);857const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);858const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");859const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());860const int personCapacity = attrs.getOpt<int>(SUMO_ATTR_PERSON_CAPACITY, id.c_str(), parsedOk, 6);861const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), parsedOk, 0);862const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);863const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);864const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);865// continue if flag is ok866if (parsedOk) {867// set tag868myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TRAIN_STOP);869// add all attributes870myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);871myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);872myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);873myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);874myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);875myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);876myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_PERSON_CAPACITY, personCapacity);877myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PARKING_LENGTH, parkingLength);878myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);879myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);880myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);881} else {882myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);883}884}885886887void888AdditionalHandler::parseAccessAttributes(const SUMOSAXAttributes& attrs) {889// declare Ok Flag890bool parsedOk = true;891// needed attributes892const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, "", parsedOk);893const std::string position = attrs.get<std::string>(SUMO_ATTR_POSITION, "", parsedOk);894// optional attributes895const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "", parsedOk, -1.00, false); /* in future updates, INVALID_DOUBLE */896const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "", parsedOk, false);897// check parent898checkParsedParent(SUMO_TAG_ACCESS, {SUMO_TAG_BUS_STOP, SUMO_TAG_TRAIN_STOP, SUMO_TAG_CONTAINER_STOP}, parsedOk);899// continue if flag is ok900if (parsedOk) {901// set tag902myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ACCESS);903// add all attributes904myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);905myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_POSITION, position);906myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);907myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);908} else {909myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);910}911}912913914void915AdditionalHandler::parseContainerStopAttributes(const SUMOSAXAttributes& attrs) {916// declare Ok Flag917bool parsedOk = true;918// needed attributes919const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);920const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);921// optional attributes922const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);923const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);924const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");925const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());926const int containerCapacity = attrs.getOpt<int>(SUMO_ATTR_CONTAINER_CAPACITY, id.c_str(), parsedOk, 6);927const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), parsedOk, 0);928const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);929const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);930const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);931// continue if flag is ok932if (parsedOk) {933// set tag934myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CONTAINER_STOP);935// add all attributes936myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);937myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);938myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);939myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);940myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);941myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);942myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity);943myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PARKING_LENGTH, parkingLength);944myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);945myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);946myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);947} else {948myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);949}950}951952953void954AdditionalHandler::parseChargingStationAttributes(const SUMOSAXAttributes& attrs) {955// declare Ok Flag956bool parsedOk = true;957// needed attributes958const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);959const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);960// optional attributes961const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);962const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);963const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");964const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());965const double chargingPower = attrs.getOpt<double>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), parsedOk, 22000);966const double totalPower = attrs.getOpt<double>(SUMO_ATTR_TOTALPOWER, id.c_str(), parsedOk, 0);967const double efficiency = attrs.getOpt<double>(SUMO_ATTR_EFFICIENCY, id.c_str(), parsedOk, 0.95);968const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), parsedOk, 0);969const SUMOTime chargeDelay = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CHARGEDELAY, id.c_str(), parsedOk, 0);970const std::string chargeType = attrs.getOpt<std::string>(SUMO_ATTR_CHARGETYPE, id.c_str(), parsedOk, SUMOXMLDefinitions::ChargeTypes.getString(ChargeType::NORMAL));971const SUMOTime waitingTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_WAITINGTIME, id.c_str(), parsedOk, TIME2STEPS(900));972const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);973const std::string parkingAreaID = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, id.c_str(), parsedOk, "");974// check charge type975if ((chargeType != "normal") && (chargeType != "battery-exchange") && (chargeType != "fuel")) {976writeError(TLF("Invalid charge type '%' defined in chargingStation '%'.", chargeType, id));977parsedOk = false;978}979// continue if flag is ok980if (parsedOk) {981// set tag982myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CHARGING_STATION);983// add all attributes984myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);985myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);986myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);987myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);988myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);989myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);990myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_CHARGINGPOWER, chargingPower);991myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_TOTALPOWER, totalPower);992myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_EFFICIENCY, efficiency);993myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_CHARGEINTRANSIT, chargeInTransit);994myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_CHARGEDELAY, chargeDelay);995myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_CHARGETYPE, chargeType);996myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_WAITINGTIME, waitingTime);997myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);998myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_PARKING_AREA, parkingAreaID);999} else {1000myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1001}1002}100310041005void1006AdditionalHandler::parseParkingAreaAttributes(const SUMOSAXAttributes& attrs) {1007// declare Ok Flag1008bool parsedOk = true;1009// needed attributes1010const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1011const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);1012// optional attributes1013const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);1014const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);1015const std::string departPos = attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, id.c_str(), parsedOk, "");1016const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1017const std::vector<std::string> badges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ACCEPTED_BADGES, id.c_str(), parsedOk, std::vector<std::string>());1018const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1019const int roadSideCapacity = attrs.getOpt<int>(SUMO_ATTR_ROADSIDE_CAPACITY, id.c_str(), parsedOk, 0);1020const bool onRoad = attrs.getOpt<bool>(SUMO_ATTR_ONROAD, id.c_str(), parsedOk, false);1021const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), parsedOk, 0);1022const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), parsedOk, 0);1023const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);1024const bool lefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, id.c_str(), parsedOk, false);1025// continue if flag is ok1026if (parsedOk) {1027// set tag1028myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_PARKING_AREA);1029// add all attributes1030myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1031myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1032myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);1033myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);1034myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DEPARTPOS, departPos);1035myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1036myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_ACCEPTED_BADGES, badges);1037myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1038myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_ROADSIDE_CAPACITY, roadSideCapacity);1039myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_ONROAD, onRoad);1040myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WIDTH, width);1041myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);1042myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);1043myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_LEFTHAND, lefthand);1044} else {1045myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1046}1047}104810491050void1051AdditionalHandler::parseParkingSpaceAttributes(const SUMOSAXAttributes& attrs) {1052// declare Ok Flag1053bool parsedOk = true;1054// needed attributes1055const double x = attrs.get<double>(SUMO_ATTR_X, "", parsedOk);1056const double y = attrs.get<double>(SUMO_ATTR_Y, "", parsedOk);1057// optional attributes1058const double z = attrs.getOpt<double>(SUMO_ATTR_Z, "", parsedOk, 0);1059const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, "", parsedOk, "");1060const std::string width = attrs.getOpt<std::string>(SUMO_ATTR_WIDTH, "", parsedOk, "");1061const std::string length = attrs.getOpt<std::string>(SUMO_ATTR_LENGTH, "", parsedOk, "");1062const std::string angle = attrs.getOpt<std::string>(SUMO_ATTR_ANGLE, "", parsedOk, "");1063const double slope = attrs.getOpt<double>(SUMO_ATTR_SLOPE, "", parsedOk, 0);1064// check parent1065checkParsedParent(SUMO_TAG_PARKING_SPACE, {SUMO_TAG_PARKING_AREA}, parsedOk);1066// continue if flag is ok1067if (parsedOk) {1068// set tag1069myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_PARKING_SPACE);1070// add all attributes1071myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_X, x);1072myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_Y, y);1073myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_Z, z);1074myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1075myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_WIDTH, width);1076myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LENGTH, length);1077myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ANGLE, angle);1078myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_SLOPE, slope);1079} else {1080myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1081}1082}108310841085void1086AdditionalHandler::parseE1Attributes(const SUMOSAXAttributes& attrs) {1087// declare Ok Flag1088bool parsedOk = true;1089// needed attributes1090const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1091const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);1092const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk);1093const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1094const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1095// optional attributes1096const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1097const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1098const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1099const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1100const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1101// continue if flag is ok1102if (parsedOk && checkDetectPersons(SUMO_TAG_E1DETECTOR, id, detectPersons)) {1103// set tag1104myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_E1DETECTOR);1105// add all attributes1106myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1107myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1108myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1109myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1110myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1111myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1112myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1113myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1114myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1115myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1116} else {1117myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1118}1119}112011211122void1123AdditionalHandler::parseE2Attributes(const SUMOSAXAttributes& attrs) {1124// declare Ok Flag1125bool parsedOk = true;1126const int positionDef = attrs.hasAttribute(SUMO_ATTR_POSITION) ? 1 : 0;1127const int endPosDef = attrs.hasAttribute(SUMO_ATTR_ENDPOS) ? 1 : 0;1128const int lengthDef = attrs.hasAttribute(SUMO_ATTR_LENGTH) ? 1 : 0;1129// check attributes1130if (attrs.hasAttribute(SUMO_ATTR_LANE) && ((positionDef + endPosDef + lengthDef) > 2)) {1131writeError(TL("'pos', 'endPos' and 'length' cannot be defined together in a single lane area detector."));1132myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1133} else if (attrs.hasAttribute(SUMO_ATTR_LANE) && ((positionDef + endPosDef + lengthDef) < 2)) {1134writeError(TL("A single lane area detector requires two parameters of those 'pos', 'endPos' and 'length'."));1135myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1136} else {1137// needed attributes1138const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1139const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1140// special attributes1141const std::string laneId = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk, "");1142const std::vector<std::string> laneIds = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), parsedOk, std::vector<std::string>());1143const double position = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, 0);1144const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, 0);1145const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), parsedOk, 0);1146// optional attributes1147const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1148const std::string trafficLight = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), parsedOk, "");1149const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1150const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), parsedOk, TIME2STEPS(1));1151const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), parsedOk, 1.39);1152const double jamDistThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), parsedOk, 10);1153const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1154const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1155const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1156const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1157const bool show = attrs.getOpt<bool>(SUMO_ATTR_SHOW_DETECTOR, id.c_str(), parsedOk, true);1158// continue if flag is ok1159if (parsedOk && checkDetectPersons(SUMO_TAG_E2DETECTOR, id, detectPersons)) {1160// set tag1161myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_E2DETECTOR);1162// add attributes depending of Lane/Lanes1163if (attrs.hasAttribute(SUMO_ATTR_LANE)) {1164myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1165if (positionDef == 0) {1166myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, endPos - length);1167myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);1168} else if (endPosDef == 0) {1169myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1170myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);1171} else if (lengthDef == 0) {1172myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1173myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, endPos - position);1174}1175} else {1176myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LANES, laneIds);1177myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1178myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);1179}1180// add all attributes1181myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1182myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1183myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_TLID, trafficLight);1184myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1185myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1186myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1187myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1188myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1189myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD, haltingTimeThreshold);1190myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD, haltingSpeedThreshold);1191myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD, jamDistThreshold);1192myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1193myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_SHOW_DETECTOR, show);1194} else {1195myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1196}1197}1198}119912001201void1202AdditionalHandler::parseE3Attributes(const SUMOSAXAttributes& attrs) {1203// declare Ok Flag1204bool parsedOk = true;1205// needed attributes1206const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1207const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1208const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1209// optional attributes1210const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position());1211const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1212const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1213const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1214const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1215const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), parsedOk, TIME2STEPS(1));1216const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), parsedOk, 1.39);1217const bool openEntry = attrs.getOpt<bool>(SUMO_ATTR_OPEN_ENTRY, id.c_str(), parsedOk, false);1218const bool expectedArrival = attrs.getOpt<bool>(SUMO_ATTR_EXPECT_ARRIVAL, id.c_str(), parsedOk, false);1219// continue if flag is ok1220if (parsedOk && checkDetectPersons(SUMO_TAG_E3DETECTOR, id, detectPersons)) {1221// set tag1222myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_E3DETECTOR);1223// add all attributes1224myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1225myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1226myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1227myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1228myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1229myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1230myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1231myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1232myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD, haltingTimeThreshold);1233myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD, haltingSpeedThreshold);1234myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_OPEN_ENTRY, openEntry);1235myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_EXPECT_ARRIVAL, expectedArrival);1236} else {1237myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1238}1239}124012411242void1243AdditionalHandler::parseEntryAttributes(const SUMOSAXAttributes& attrs) {1244// declare Ok Flag1245bool parsedOk = true;1246// needed attributes1247const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, "", parsedOk);1248const double position = attrs.get<double>(SUMO_ATTR_POSITION, "", parsedOk);1249// optional attributes1250const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "", parsedOk, false);1251// check parent1252checkParsedParent(SUMO_TAG_DET_ENTRY, {SUMO_TAG_E3DETECTOR}, parsedOk);1253// continue if flag is ok1254if (parsedOk) {1255// set tag1256myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_DET_ENTRY);1257// add all attributes1258myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1259myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1260myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1261} else {1262myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1263}1264}126512661267void1268AdditionalHandler::parseExitAttributes(const SUMOSAXAttributes& attrs) {1269// declare Ok Flag1270bool parsedOk = true;1271// needed attributes1272const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, "", parsedOk);1273const double position = attrs.get<double>(SUMO_ATTR_POSITION, "", parsedOk);1274// optional attributes1275const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "", parsedOk, false);1276// check parent1277checkParsedParent(SUMO_TAG_DET_EXIT, {SUMO_TAG_E3DETECTOR}, parsedOk);1278// continue if flag is ok1279if (parsedOk) {1280// set tag1281myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_DET_EXIT);1282// add all attributes1283myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1284myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1285myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1286} else {1287myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1288}1289}129012911292void1293AdditionalHandler::parseE1InstantAttributes(const SUMOSAXAttributes& attrs) {1294// declare Ok Flag1295bool parsedOk = true;1296// needed attributes1297const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1298const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);1299const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk);1300const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1301// optional attributes1302const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1303const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1304const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1305const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1306const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1307// continue if flag is ok1308if (parsedOk && checkDetectPersons(SUMO_TAG_INSTANT_INDUCTION_LOOP, id, detectPersons)) {1309// set tag1310myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_INSTANT_INDUCTION_LOOP);1311// add all attributes1312myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1313myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1314myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1315myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1316myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1317myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1318myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1319myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1320myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1321} else {1322myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1323}1324}132513261327void1328AdditionalHandler::parseTAZAttributes(const SUMOSAXAttributes& attrs) {1329// declare Ok Flag1330bool parsedOk = true;1331// needed attributes1332const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1333// optional attributes1334const PositionVector shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk, PositionVector());1335const Position center = attrs.getOpt<Position>(SUMO_ATTR_CENTER, id.c_str(), parsedOk, shape.size() > 0 ? shape.getCentroid() : Position::INVALID);1336const bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, id.c_str(), parsedOk, false);1337const std::vector<std::string> edges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1338const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::RED);1339const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1340// continue if flag is ok1341if (parsedOk) {1342// set tag1343myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TAZ);1344// add all attributes1345myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1346myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shape);1347myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_CENTER, center);1348myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FILL, fill);1349myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_EDGES, edges);1350myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);1351myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1352} else {1353myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1354}1355}135613571358void1359AdditionalHandler::parseTAZSourceAttributes(const SUMOSAXAttributes& attrs) {1360// declare Ok Flag1361bool parsedOk = true;1362// needed attributes1363const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1364const double weight = attrs.get<double>(SUMO_ATTR_WEIGHT, edgeID.c_str(), parsedOk);1365// check parent1366checkParsedParent(SUMO_TAG_TAZSOURCE, {SUMO_TAG_TAZ}, parsedOk);1367// continue if flag is ok1368if (parsedOk) {1369// set tag1370myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TAZSOURCE);1371// add all attributes1372myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1373myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WEIGHT, weight);1374} else {1375myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1376}1377}137813791380void1381AdditionalHandler::parseTAZSinkAttributes(const SUMOSAXAttributes& attrs) {1382// declare Ok Flag1383bool parsedOk = true;1384// needed attributes1385const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1386const double weight = attrs.get<double>(SUMO_ATTR_WEIGHT, edgeID.c_str(), parsedOk);1387// check parent1388checkParsedParent(SUMO_TAG_TAZSINK, {SUMO_TAG_TAZ}, parsedOk);1389// continue if flag is ok1390if (parsedOk) {1391// set tag1392myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TAZSINK);1393// add all attributes1394myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1395myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WEIGHT, weight);1396} else {1397myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1398}1399}140014011402void1403AdditionalHandler::parseVariableSpeedSignAttributes(const SUMOSAXAttributes& attrs) {1404// declare Ok Flag1405bool parsedOk = true;1406// needed attributes1407const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1408const std::vector<std::string> lanes = attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), parsedOk);1409// optional attributes1410const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position());1411const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1412const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1413// continue if flag is ok1414if (parsedOk) {1415// set tag1416myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_VSS);1417// add all attributes1418myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1419myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LANES, lanes);1420myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1421myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1422myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1423} else {1424myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1425}1426}142714281429void1430AdditionalHandler::parseVariableSpeedSignStepAttributes(const SUMOSAXAttributes& attrs) {1431// declare Ok Flag1432bool parsedOk = true;1433// needed attributes1434const SUMOTime time = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME, "", parsedOk);1435// optional attributes1436const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, OptionsCont::getOptions().getFloat("default.speed"));1437// check parent1438checkParsedParent(SUMO_TAG_STEP, {SUMO_TAG_VSS}, parsedOk);1439// continue if flag is ok1440if (parsedOk) {1441// set tag1442myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_STEP);1443// add all attributes1444myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_TIME, time);1445myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_SPEED, speed);1446} else {1447myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1448}1449}145014511452void1453AdditionalHandler::parseCalibratorAttributes(const SUMOSAXAttributes& attrs) {1454// declare Ok Flag1455bool parsedOk = true;1456// check that frecuency and trafficLight aren't defined together1457if ((attrs.hasAttribute(SUMO_ATTR_EDGE) && attrs.hasAttribute(SUMO_ATTR_LANE)) ||1458(!attrs.hasAttribute(SUMO_ATTR_EDGE) && !attrs.hasAttribute(SUMO_ATTR_LANE))) {1459writeError(TL("Calibrators need either an edge or a lane"));1460parsedOk = false;1461}1462// needed attributes1463const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1464const double pos = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk);1465// special attributes1466const std::string edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, id.c_str(), parsedOk, "");1467const std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk, "");1468// optional attributes1469const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1470const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, DELTA_T);1471const std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), parsedOk, "");1472const double jamThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), parsedOk, 0.5);1473const std::string output = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), parsedOk, "");1474const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1475// continue if flag is ok1476if (parsedOk) {1477// set tag depending of edge/lane1478if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {1479myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CALIBRATOR);1480myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_EDGE, edge);1481} else {1482myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(GNE_TAG_CALIBRATOR_LANE);1483myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, lane);1484}1485myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1486myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, pos);1487myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1488myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1489myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ROUTEPROBE, routeProbe);1490myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold);1491myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OUTPUT, output);1492myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1493} else {1494myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1495}1496}149714981499void1500AdditionalHandler::parseCalibratorFlowAttributes(const SUMOSAXAttributes& attrs) {1501// declare Ok Flag1502bool parsedOk = true;1503// check parent1504if (checkCalibratorFlowParents()) {1505// check that frecuency and trafficLight aren't defined together1506if (!attrs.hasAttribute(SUMO_ATTR_TYPE) && !attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR) && !attrs.hasAttribute(SUMO_ATTR_SPEED)) {1507writeError(TL("CalibratorFlows need either the attribute vehsPerHour or speed or type (or any combination of these)"));1508myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1509} else {1510SUMOVehicleParameter* flowParameter = SUMOVehicleParserHelper::parseVehicleAttributes(SUMO_TAG_FLOW, attrs, false, true, true);1511if (flowParameter) {1512// set VPH and speed1513if (attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {1514flowParameter->repetitionOffset = TIME2STEPS(3600. / attrs.get<double>(SUMO_ATTR_VEHSPERHOUR, "", parsedOk));1515flowParameter->parametersSet |= VEHPARS_VPH_SET;1516}1517if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {1518flowParameter->calibratorSpeed = attrs.get<double>(SUMO_ATTR_SPEED, "", parsedOk);1519flowParameter->parametersSet |= VEHPARS_CALIBRATORSPEED_SET;1520}1521// set begin and end1522flowParameter->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, "", parsedOk);1523flowParameter->repetitionEnd = attrs.getSUMOTimeReporting(SUMO_ATTR_END, "", parsedOk);1524if (parsedOk) {1525// set tag1526myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_FLOW);1527// set vehicle parameters1528myCommonXMLStructure.getCurrentSumoBaseObject()->setVehicleParameter(flowParameter);1529// delete flow parameter (because in XMLStructure we have a copy)1530delete flowParameter;1531} else {1532myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1533}1534} else {1535myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1536}1537}1538} else {1539myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1540}1541}154215431544void1545AdditionalHandler::parseRerouterAttributes(const SUMOSAXAttributes& attrs) {1546// declare Ok Flag1547bool parsedOk = true;1548// needed attributes1549const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1550const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);1551// optional attributes1552const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position::INVALID);1553const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1554const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 1);1555SUMOTime timeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), parsedOk, 0);1556const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1557const bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), parsedOk, false);1558const bool optional = attrs.getOpt<bool>(SUMO_ATTR_OPTIONAL, id.c_str(), parsedOk, false);1559// check attributes1560if (!checkNegative(SUMO_TAG_REROUTER, id, SUMO_ATTR_PROB, probability, true)) {1561parsedOk = false;1562}1563// continue if flag is ok1564if (parsedOk) {1565// set tag1566myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_REROUTER);1567// add all attributes1568myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1569myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_EDGES, edges);1570myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1571myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1572myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1573myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold);1574myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1575myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_OFF, off);1576myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_OPTIONAL, optional);1577} else {1578myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1579}1580}158115821583void1584AdditionalHandler::parseRerouterIntervalAttributes(const SUMOSAXAttributes& attrs) {1585// declare Ok Flag1586bool parsedOk = true;1587// needed attributes1588const SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, "", parsedOk);1589const SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, "", parsedOk);1590// check parent1591checkParsedParent(SUMO_TAG_INTERVAL, {SUMO_TAG_REROUTER}, parsedOk);1592// continue if flag is ok1593if (parsedOk) {1594// set tag1595myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_INTERVAL);1596// add all attributes1597myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_BEGIN, begin);1598myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_END, end);1599} else {1600myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1601}1602}160316041605void1606AdditionalHandler::parseClosingLaneRerouteAttributes(const SUMOSAXAttributes& attrs) {1607// declare Ok Flag1608bool parsedOk = true;1609// needed attributes1610const std::string laneID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1611// optional attributes1612const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, "", parsedOk, "");1613const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, "", parsedOk, !disallow.size() ? "authority" : "");1614// check parent1615checkParsedParent(SUMO_TAG_CLOSING_LANE_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1616// continue if flag is ok1617if (parsedOk) {1618// set tag1619myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CLOSING_LANE_REROUTE);1620// add all attributes1621myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, laneID);1622myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ALLOW, allow);1623myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DISALLOW, disallow);1624} else {1625myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1626}1627}162816291630void1631AdditionalHandler::parseClosingRerouteAttributes(const SUMOSAXAttributes& attrs) {1632// declare Ok Flag1633bool parsedOk = true;1634// needed attributes1635const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1636// optional attributes1637const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, "", parsedOk, "");1638const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, "", parsedOk, "");1639// check parent1640checkParsedParent(SUMO_TAG_CLOSING_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1641// continue if flag is ok1642if (parsedOk) {1643// set tag1644myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CLOSING_REROUTE);1645// add all attributes1646myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1647myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ALLOW, allow);1648myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DISALLOW, disallow);1649} else {1650myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1651}1652}165316541655void1656AdditionalHandler::parseDestProbRerouteAttributes(const SUMOSAXAttributes& attrs) {1657// declare Ok Flag1658bool parsedOk = true;1659// needed attributes1660const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1661const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, "", parsedOk, 1);1662// check attributes1663if (!checkNegative(SUMO_TAG_DEST_PROB_REROUTE, edgeID, SUMO_ATTR_PROB, probability, true)) {1664parsedOk = false;1665}1666// check parent1667checkParsedParent(SUMO_TAG_DEST_PROB_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1668// continue if flag is ok1669if (parsedOk) {1670// set tag1671myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_DEST_PROB_REROUTE);1672// add all attributes1673myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1674myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1675} else {1676myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1677}1678}167916801681void1682AdditionalHandler::parseParkingAreaRerouteAttributes(const SUMOSAXAttributes& attrs) {1683// declare Ok Flag1684bool parsedOk = true;1685// needed attributes1686const std::string parkingAreaID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1687const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, "", parsedOk, 1);1688// check attributes1689if (!checkNegative(SUMO_TAG_PARKING_AREA_REROUTE, parkingAreaID, SUMO_ATTR_PROB, probability, true)) {1690parsedOk = false;1691}1692// optional attributes1693const bool visible = attrs.getOpt<bool>(SUMO_ATTR_VISIBLE, "", parsedOk, false);1694// check parent1695checkParsedParent(SUMO_TAG_PARKING_AREA_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1696// continue if flag is ok1697if (parsedOk) {1698// set tag1699myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_PARKING_AREA_REROUTE);1700// add all attributes1701myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, parkingAreaID);1702myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1703myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_VISIBLE, visible);1704} else {1705myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1706}1707}170817091710void1711AdditionalHandler::parseRouteProbRerouteAttributes(const SUMOSAXAttributes& attrs) {1712// declare Ok Flag1713bool parsedOk = true;1714// needed attributes1715const std::string routeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1716const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, "", parsedOk, 1);1717// check attributes1718if (!checkNegative(SUMO_TAG_ROUTE_PROB_REROUTE, routeID, SUMO_ATTR_PROB, probability, true)) {1719parsedOk = false;1720}1721// check parent1722checkParsedParent(SUMO_TAG_ROUTE_PROB_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1723// continue if flag is ok1724if (parsedOk) {1725// set tag1726myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ROUTE_PROB_REROUTE);1727// add all attributes1728myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, routeID);1729myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1730} else {1731myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1732}1733}173417351736void1737AdditionalHandler::parseRouteProbeAttributes(const SUMOSAXAttributes& attrs) {1738// declare Ok Flag1739bool parsedOk = true;1740// needed attributes1741const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1742const std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), parsedOk);1743const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1744const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1745const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), parsedOk, -1);1746// optional attributes1747const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1748const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1749// continue if flag is ok1750if (parsedOk) {1751// set tag1752myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ROUTEPROBE);1753// add all attributes1754myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1755myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_EDGE, edge);1756myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1757myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1758myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1759myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_BEGIN, begin);1760myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1761} else {1762myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1763}1764}176517661767void1768AdditionalHandler::parseVaporizerAttributes(const SUMOSAXAttributes& attrs) {1769// declare Ok Flag1770bool parsedOk = true;1771// needed attributes1772const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1773SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);1774SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);1775// optional attributes1776const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, edgeID.c_str(), parsedOk, "");1777// continue if flag is ok1778if (parsedOk) {1779// set tag1780myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_VAPORIZER);1781// add all attributes1782myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_EDGE, edgeID);1783myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_BEGIN, begin);1784myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_END, end);1785myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1786} else {1787myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1788}1789}179017911792void1793AdditionalHandler::parseTractionSubstation(const SUMOSAXAttributes& attrs) {1794// declare Ok Flag1795bool parsedOk = true;1796// needed attributes1797const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1798// optional attributes1799const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position::INVALID);1800const double voltage = attrs.getOpt<double>(SUMO_ATTR_VOLTAGE, id.c_str(), parsedOk, 600);1801const double currentLimit = attrs.getOpt<double>(SUMO_ATTR_CURRENTLIMIT, id.c_str(), parsedOk, 400);1802// continue if flag is ok1803if (parsedOk) {1804// set tag1805myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TRACTION_SUBSTATION);1806// add all attributes1807myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1808myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1809myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_VOLTAGE, voltage);1810myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_CURRENTLIMIT, currentLimit);1811} else {1812myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1813}1814}181518161817void1818AdditionalHandler::parseOverheadWire(const SUMOSAXAttributes& attrs) {1819// declare Ok Flag1820bool parsedOk = true;1821// needed attributes1822const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1823const std::string substationID = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, id.c_str(), parsedOk);1824const std::vector<std::string> laneIDs = attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), parsedOk);1825// optional attributes1826const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, 0);1827const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);1828const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1829const std::vector<std::string> forbiddenInnerLanes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN, "", parsedOk);1830// continue if flag is ok1831if (parsedOk) {1832// set tag1833myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_OVERHEAD_WIRE_SECTION);1834// add all attributes1835myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1836myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_SUBSTATIONID, substationID);1837myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LANES, laneIDs);1838myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);1839myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);1840myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1841myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN, forbiddenInnerLanes);1842} else {1843myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1844}1845}184618471848void1849AdditionalHandler::parseOverheadWireClamp(const SUMOSAXAttributes& attrs) {1850// declare Ok Flag1851bool parsedOk = true;1852// needed attributes1853const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1854const std::string substationId = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, id.c_str(), parsedOk);1855const std::string wireClampStart = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_START, id.c_str(), parsedOk);1856const std::string wireClampLaneStart = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANESTART, id.c_str(), parsedOk);1857const std::string wireClampEnd = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_END, id.c_str(), parsedOk);1858const std::string wireClampLaneEnd = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANEEND, id.c_str(), parsedOk);1859// continue if flag is ok1860if (parsedOk) {1861// set tag1862myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_OVERHEAD_WIRE_CLAMP);1863// add all attributes1864myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1865myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_SUBSTATIONID, substationId);1866myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_START, wireClampStart);1867myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANESTART, wireClampLaneStart);1868myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_END, wireClampEnd);1869myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANEEND, wireClampLaneEnd);1870} else {1871myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1872}1873}187418751876void1877AdditionalHandler::parsePolyAttributes(const SUMOSAXAttributes& attrs) {1878// declare Ok Flag1879bool parsedOk = true;1880// needed attributes1881const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1882const PositionVector shapeStr = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk);1883// optional attributes1884const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::RED);1885const bool geo = attrs.getOpt<bool>(SUMO_ATTR_GEO, id.c_str(), parsedOk, false);1886const bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, id.c_str(), parsedOk, false);1887const double lineWidth = attrs.getOpt<double>(SUMO_ATTR_LINEWIDTH, id.c_str(), parsedOk, Shape::DEFAULT_LINEWIDTH);1888const double layer = attrs.getOpt<double>(SUMO_ATTR_LAYER, id.c_str(), parsedOk, Shape::DEFAULT_LAYER);1889const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), parsedOk, Shape::DEFAULT_TYPE);1890const std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), parsedOk, Shape::DEFAULT_IMG_FILE);1891const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, Shape::DEFAULT_ANGLE);1892const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1893// continue if flag is ok1894if (parsedOk) {1895// set tag1896myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_POLY);1897// add all attributes1898myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1899myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shapeStr);1900myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);1901myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_GEO, geo);1902myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FILL, fill);1903myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LINEWIDTH, lineWidth);1904myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LAYER, layer);1905myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_TYPE, type);1906myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_IMGFILE, imgFile);1907myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);1908myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1909} else {1910myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1911}1912}191319141915void1916AdditionalHandler::parsePOIAttributes(const SUMOSAXAttributes& attrs) {1917// declare Ok Flag1918bool parsedOk = true;1919// check that x and y are defined together1920if ((attrs.hasAttribute(SUMO_ATTR_X) && !attrs.hasAttribute(SUMO_ATTR_Y)) ||1921(!attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y))) {1922writeError(TL("X and Y must be be defined together in POIs"));1923parsedOk = false;1924}1925// check that lane and pos are defined together1926if ((attrs.hasAttribute(SUMO_ATTR_LANE) && !attrs.hasAttribute(SUMO_ATTR_POSITION)) ||1927(!attrs.hasAttribute(SUMO_ATTR_LANE) && attrs.hasAttribute(SUMO_ATTR_POSITION))) {1928writeError(TL("lane and position must be defined together in POIs"));1929parsedOk = false;1930}1931// check that lon and lat are defined together1932if ((attrs.hasAttribute(SUMO_ATTR_LON) && !attrs.hasAttribute(SUMO_ATTR_LAT)) ||1933(!attrs.hasAttribute(SUMO_ATTR_LON) && attrs.hasAttribute(SUMO_ATTR_LAT))) {1934writeError(TL("lon and lat must be be defined together in POIs"));1935parsedOk = false;1936}1937// needed attributes1938const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1939// special attributes1940const double x = attrs.getOpt<double>(SUMO_ATTR_X, id.c_str(), parsedOk, 0);1941const double y = attrs.getOpt<double>(SUMO_ATTR_Y, id.c_str(), parsedOk, 0);1942const std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, "", parsedOk, "");1943const double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, 0);1944const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1945const double posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, id.c_str(), parsedOk, 0);1946const double lon = attrs.getOpt<double>(SUMO_ATTR_LON, id.c_str(), parsedOk, 0);1947const double lat = attrs.getOpt<double>(SUMO_ATTR_LAT, id.c_str(), parsedOk, 0);1948// optional attributes1949const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::RED);1950const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, "", parsedOk, Shape::DEFAULT_TYPE);1951std::string icon = attrs.getOpt<std::string>(SUMO_ATTR_ICON, "", parsedOk, SUMOXMLDefinitions::POIIcons.getString(POIIcon::NONE));1952const double layer = attrs.getOpt<double>(SUMO_ATTR_LAYER, id.c_str(), parsedOk, Shape::DEFAULT_LAYER_POI);1953const std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, "", parsedOk, Shape::DEFAULT_IMG_FILE);1954const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), parsedOk, Shape::DEFAULT_IMG_WIDTH);1955const double height = attrs.getOpt<double>(SUMO_ATTR_HEIGHT, id.c_str(), parsedOk, Shape::DEFAULT_IMG_HEIGHT);1956const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, Shape::DEFAULT_ANGLE);1957const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1958// check icon1959if (!SUMOXMLDefinitions::POIIcons.hasString(icon)) {1960WRITE_WARNING(TLF("Invalid icon % for POI '%', using default", icon, id));1961icon = "none";1962}1963// continue if flag is ok1964if (parsedOk) {1965// set tag1966myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_POI);1967// add attributes depending of Lane/Lanes1968if (attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y)) {1969myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_X, x);1970myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_Y, y);1971} else if (attrs.hasAttribute(SUMO_ATTR_LANE) && attrs.hasAttribute(SUMO_ATTR_POSITION)) {1972myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, lane);1973myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, pos);1974myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1975myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION_LAT, posLat);1976} else {1977myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LON, lon);1978myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LAT, lat);1979}1980// add rest attributes1981myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1982myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);1983myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_TYPE, type);1984myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ICON, icon);1985myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LAYER, layer);1986myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_IMGFILE, imgFile);1987myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WIDTH, width);1988myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_HEIGHT, height);1989myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);1990myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1991} else {1992myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1993}1994}199519961997void1998AdditionalHandler::parseJpsWalkableAreaAttributes(const SUMOSAXAttributes& attrs) {1999// declare Ok Flag2000bool parsedOk = true;2001// needed attributes2002const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);2003const PositionVector shapeStr = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk);2004// optional attributes2005const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");2006// continue if flag is ok2007if (parsedOk) {2008// set tag2009myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(GNE_TAG_JPS_WALKABLEAREA);2010// add all attributes2011myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);2012myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shapeStr);2013myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);2014} else {2015myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);2016}2017}201820192020void2021AdditionalHandler::parseJpsObstacleAttributes(const SUMOSAXAttributes& attrs) {2022// declare Ok Flag2023bool parsedOk = true;2024// needed attributes2025const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);2026const PositionVector shapeStr = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk);2027// optional attributes2028const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");2029// continue if flag is ok2030if (parsedOk) {2031// set tag2032myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(GNE_TAG_JPS_OBSTACLE);2033// add all attributes2034myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);2035myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shapeStr);2036myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);2037} else {2038myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);2039}2040}204120422043bool2044AdditionalHandler::checkCalibratorFlowParents() {2045const auto parentCalibrator = myCommonXMLStructure.getCurrentSumoBaseObject()->getParentSumoBaseObject();2046if (parentCalibrator == nullptr) {2047return false;2048}2049const auto parentRootFile = parentCalibrator->getParentSumoBaseObject();2050if (parentRootFile != nullptr) {2051return false;2052}2053if ((parentCalibrator->getTag() == SUMO_TAG_CALIBRATOR) || (parentCalibrator->getTag() == GNE_TAG_CALIBRATOR_LANE)) {2054return true;2055} else {2056return writeError(TLF("Calibrator Flows have to be defined within a %.", toString(SUMO_TAG_CALIBRATOR)));2057}2058}205920602061bool2062AdditionalHandler::checkDetectPersons(const SumoXMLTag currentTag, const std::string& id, const std::string& detectPersons) {2063if (detectPersons.empty() || SUMOXMLDefinitions::PersonModeValues.hasString(detectPersons)) {2064return true;2065} else {2066writeError(TLF("Attribute '%' defined in % with id '%' doesn't have a valid value (given '%').", toString(SUMO_ATTR_DETECT_PERSONS), toString(currentTag), id, detectPersons));2067return false;2068}2069}20702071/****************************************************************************/207220732074