Path: blob/main/src/utils/handlers/AdditionalHandler.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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(const std::string& filename) :37CommonHandler(filename) {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_EFFICIENCY),326obj->getBoolAttribute(SUMO_ATTR_CHARGEINTRANSIT),327obj->getTimeAttribute(SUMO_ATTR_CHARGEDELAY),328obj->getStringAttribute(SUMO_ATTR_CHARGETYPE),329obj->getTimeAttribute(SUMO_ATTR_WAITINGTIME),330obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),331obj->getStringAttribute(SUMO_ATTR_PARKING_AREA),332obj->getParameters())) {333obj->markAsCreated();334}335break;336case SUMO_TAG_PARKING_AREA:337if (buildParkingArea(obj,338obj->getStringAttribute(SUMO_ATTR_ID),339obj->getStringAttribute(SUMO_ATTR_LANE),340obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),341obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),342obj->getStringAttribute(SUMO_ATTR_DEPARTPOS),343obj->getStringAttribute(SUMO_ATTR_NAME),344obj->getStringListAttribute(SUMO_ATTR_ACCEPTED_BADGES),345obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),346obj->getIntAttribute(SUMO_ATTR_ROADSIDE_CAPACITY),347obj->getBoolAttribute(SUMO_ATTR_ONROAD),348obj->getDoubleAttribute(SUMO_ATTR_WIDTH),349obj->getDoubleAttribute(SUMO_ATTR_LENGTH),350obj->getDoubleAttribute(SUMO_ATTR_ANGLE),351obj->getBoolAttribute(SUMO_ATTR_LEFTHAND),352obj->getParameters())) {353obj->markAsCreated();354}355break;356case SUMO_TAG_PARKING_SPACE:357if (buildParkingSpace(obj,358obj->getDoubleAttribute(SUMO_ATTR_X),359obj->getDoubleAttribute(SUMO_ATTR_Y),360obj->getDoubleAttribute(SUMO_ATTR_Z),361obj->getStringAttribute(SUMO_ATTR_NAME),362obj->getStringAttribute(SUMO_ATTR_WIDTH),363obj->getStringAttribute(SUMO_ATTR_LENGTH),364obj->getStringAttribute(SUMO_ATTR_ANGLE),365obj->getDoubleAttribute(SUMO_ATTR_SLOPE),366obj->getParameters())) {367obj->markAsCreated();368}369break;370// Detectors371case SUMO_TAG_E1DETECTOR:372case SUMO_TAG_INDUCTION_LOOP:373// build E1374if (buildE1Detector(obj,375obj->getStringAttribute(SUMO_ATTR_ID),376obj->getStringAttribute(SUMO_ATTR_LANE),377obj->getDoubleAttribute(SUMO_ATTR_POSITION),378obj->getPeriodAttribute(),379obj->getStringAttribute(SUMO_ATTR_FILE),380obj->getStringListAttribute(SUMO_ATTR_VTYPES),381obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),382obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),383obj->getStringAttribute(SUMO_ATTR_NAME),384obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),385obj->getParameters())) {386obj->markAsCreated();387}388break;389case SUMO_TAG_E2DETECTOR:390case SUMO_TAG_LANE_AREA_DETECTOR:391if (obj->hasStringAttribute(SUMO_ATTR_LANE)) {392if (buildSingleLaneDetectorE2(obj,393obj->getStringAttribute(SUMO_ATTR_ID),394obj->getStringAttribute(SUMO_ATTR_LANE),395obj->getDoubleAttribute(SUMO_ATTR_POSITION),396obj->getDoubleAttribute(SUMO_ATTR_LENGTH),397obj->getPeriodAttribute(),398obj->getStringAttribute(SUMO_ATTR_TLID),399obj->getStringAttribute(SUMO_ATTR_FILE),400obj->getStringListAttribute(SUMO_ATTR_VTYPES),401obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),402obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),403obj->getStringAttribute(SUMO_ATTR_NAME),404obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),405obj->getDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD),406obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),407obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),408obj->getBoolAttribute(SUMO_ATTR_SHOW_DETECTOR),409obj->getParameters())) {410obj->markAsCreated();411}412} else {413if (buildMultiLaneDetectorE2(obj,414obj->getStringAttribute(SUMO_ATTR_ID),415obj->getStringListAttribute(SUMO_ATTR_LANES),416obj->getDoubleAttribute(SUMO_ATTR_POSITION),417obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),418obj->getPeriodAttribute(),419obj->getStringAttribute(SUMO_ATTR_TLID),420obj->getStringAttribute(SUMO_ATTR_FILE),421obj->getStringListAttribute(SUMO_ATTR_VTYPES),422obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),423obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),424obj->getStringAttribute(SUMO_ATTR_NAME),425obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),426obj->getDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD),427obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),428obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),429obj->getBoolAttribute(SUMO_ATTR_SHOW_DETECTOR),430obj->getParameters())) {431obj->markAsCreated();432}433}434break;435case SUMO_TAG_E3DETECTOR:436case SUMO_TAG_ENTRY_EXIT_DETECTOR:437if (buildDetectorE3(obj,438obj->getStringAttribute(SUMO_ATTR_ID),439obj->getPositionAttribute(SUMO_ATTR_POSITION),440obj->getPeriodAttribute(),441obj->getStringAttribute(SUMO_ATTR_FILE),442obj->getStringListAttribute(SUMO_ATTR_VTYPES),443obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),444obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),445obj->getStringAttribute(SUMO_ATTR_NAME),446obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),447obj->getDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD),448obj->getBoolAttribute(SUMO_ATTR_OPEN_ENTRY),449obj->getBoolAttribute(SUMO_ATTR_EXPECT_ARRIVAL),450obj->getParameters())) {451obj->markAsCreated();452}453break;454case SUMO_TAG_DET_ENTRY:455if (buildDetectorEntry(obj,456obj->getStringAttribute(SUMO_ATTR_LANE),457obj->getDoubleAttribute(SUMO_ATTR_POSITION),458obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),459obj->getParameters())) {460obj->markAsCreated();461}462break;463case SUMO_TAG_DET_EXIT:464if (buildDetectorExit(obj,465obj->getStringAttribute(SUMO_ATTR_LANE),466obj->getDoubleAttribute(SUMO_ATTR_POSITION),467obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),468obj->getParameters())) {469obj->markAsCreated();470}471break;472case SUMO_TAG_INSTANT_INDUCTION_LOOP:473if (buildDetectorE1Instant(obj,474obj->getStringAttribute(SUMO_ATTR_ID),475obj->getStringAttribute(SUMO_ATTR_LANE),476obj->getDoubleAttribute(SUMO_ATTR_POSITION),477obj->getStringAttribute(SUMO_ATTR_FILE),478obj->getStringListAttribute(SUMO_ATTR_VTYPES),479obj->getStringListAttribute(SUMO_ATTR_NEXT_EDGES),480obj->getStringAttribute(SUMO_ATTR_DETECT_PERSONS),481obj->getStringAttribute(SUMO_ATTR_NAME),482obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),483obj->getParameters())) {484obj->markAsCreated();485}486break;487// TAZs488case SUMO_TAG_TAZ:489if (buildTAZ(obj,490obj->getStringAttribute(SUMO_ATTR_ID),491obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),492obj->getPositionAttribute(SUMO_ATTR_CENTER),493obj->getBoolAttribute(SUMO_ATTR_FILL),494obj->getColorAttribute(SUMO_ATTR_COLOR),495obj->getStringListAttribute(SUMO_ATTR_EDGES),496obj->getStringAttribute(SUMO_ATTR_NAME),497obj->getParameters())) {498obj->markAsCreated();499}500break;501case SUMO_TAG_TAZSOURCE:502if (buildTAZSource(obj,503obj->getStringAttribute(SUMO_ATTR_ID),504obj->getDoubleAttribute(SUMO_ATTR_WEIGHT))) {505obj->markAsCreated();506}507break;508case SUMO_TAG_TAZSINK:509if (buildTAZSink(obj,510obj->getStringAttribute(SUMO_ATTR_ID),511obj->getDoubleAttribute(SUMO_ATTR_WEIGHT))) {512obj->markAsCreated();513}514break;515// Variable Speed Sign516case SUMO_TAG_VSS:517if (buildVariableSpeedSign(obj,518obj->getStringAttribute(SUMO_ATTR_ID),519obj->getPositionAttribute(SUMO_ATTR_POSITION),520obj->getStringListAttribute(SUMO_ATTR_LANES),521obj->getStringAttribute(SUMO_ATTR_NAME),522obj->getStringListAttribute(SUMO_ATTR_VTYPES),523obj->getParameters())) {524obj->markAsCreated();525}526break;527case SUMO_TAG_STEP:528if (buildVariableSpeedSignStep(obj,529obj->getTimeAttribute(SUMO_ATTR_TIME),530obj->getDoubleAttribute(SUMO_ATTR_SPEED))) {531obj->markAsCreated();532}533break;534// Calibrator535case SUMO_TAG_CALIBRATOR:536if (buildEdgeCalibrator(obj,537obj->getStringAttribute(SUMO_ATTR_ID),538obj->getStringAttribute(SUMO_ATTR_EDGE),539obj->getDoubleAttribute(SUMO_ATTR_POSITION),540obj->getStringAttribute(SUMO_ATTR_NAME),541obj->getStringAttribute(SUMO_ATTR_OUTPUT),542obj->getPeriodAttribute(),543obj->getStringAttribute(SUMO_ATTR_ROUTEPROBE),544obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),545obj->getStringListAttribute(SUMO_ATTR_VTYPES),546obj->getParameters())) {547obj->markAsCreated();548}549break;550case GNE_TAG_CALIBRATOR_LANE:551if (buildLaneCalibrator(obj,552obj->getStringAttribute(SUMO_ATTR_ID),553obj->getStringAttribute(SUMO_ATTR_LANE),554obj->getDoubleAttribute(SUMO_ATTR_POSITION),555obj->getStringAttribute(SUMO_ATTR_NAME),556obj->getStringAttribute(SUMO_ATTR_OUTPUT),557obj->getPeriodAttribute(),558obj->getStringAttribute(SUMO_ATTR_ROUTEPROBE),559obj->getDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD),560obj->getStringListAttribute(SUMO_ATTR_VTYPES),561obj->getParameters())) {562obj->markAsCreated();563}564break;565case SUMO_TAG_FLOW:566if (buildCalibratorFlow(obj,567obj->getVehicleParameter())) {568obj->markAsCreated();569}570break;571// Rerouter572case SUMO_TAG_REROUTER:573if (buildRerouter(obj,574obj->getStringAttribute(SUMO_ATTR_ID),575obj->getPositionAttribute(SUMO_ATTR_POSITION),576obj->getStringListAttribute(SUMO_ATTR_EDGES),577obj->getDoubleAttribute(SUMO_ATTR_PROB),578obj->getStringAttribute(SUMO_ATTR_NAME),579obj->getBoolAttribute(SUMO_ATTR_OFF),580obj->getBoolAttribute(SUMO_ATTR_OPTIONAL),581obj->getTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD),582obj->getStringListAttribute(SUMO_ATTR_VTYPES),583obj->getParameters())) {584obj->markAsCreated();585}586break;587case SUMO_TAG_CLOSING_LANE_REROUTE:588if (buildClosingLaneReroute(obj,589obj->getStringAttribute(SUMO_ATTR_ID),590parseVehicleClasses(obj->getStringAttribute(SUMO_ATTR_ALLOW),591obj->getStringAttribute(SUMO_ATTR_DISALLOW)))) {592obj->markAsCreated();593}594break;595case SUMO_TAG_CLOSING_REROUTE:596if (buildClosingReroute(obj,597obj->getStringAttribute(SUMO_ATTR_ID),598parseVehicleClasses(obj->getStringAttribute(SUMO_ATTR_ALLOW),599obj->getStringAttribute(SUMO_ATTR_DISALLOW)))) {600obj->markAsCreated();601}602break;603case SUMO_TAG_DEST_PROB_REROUTE:604if (buildDestProbReroute(obj,605obj->getStringAttribute(SUMO_ATTR_ID),606obj->getDoubleAttribute(SUMO_ATTR_PROB))) {607obj->markAsCreated();608}609break;610case SUMO_TAG_PARKING_AREA_REROUTE:611if (buildParkingAreaReroute(obj,612obj->getStringAttribute(SUMO_ATTR_ID),613obj->getDoubleAttribute(SUMO_ATTR_PROB),614obj->getBoolAttribute(SUMO_ATTR_VISIBLE))) {615obj->markAsCreated();616}617break;618case SUMO_TAG_ROUTE_PROB_REROUTE:619if (buildRouteProbReroute(obj,620obj->getStringAttribute(SUMO_ATTR_ID),621obj->getDoubleAttribute(SUMO_ATTR_PROB))) {622obj->markAsCreated();623}624break;625case SUMO_TAG_INTERVAL:626// check if is aREROUTER interval627if (obj->getParentSumoBaseObject()->getTag() == SUMO_TAG_REROUTER) {628if (buildRerouterInterval(obj,629obj->getTimeAttribute(SUMO_ATTR_BEGIN),630obj->getTimeAttribute(SUMO_ATTR_END))) {631obj->markAsCreated();632}633}634break;635// Route probe636case SUMO_TAG_ROUTEPROBE:637if (buildRouteProbe(obj,638obj->getStringAttribute(SUMO_ATTR_ID),639obj->getStringAttribute(SUMO_ATTR_EDGE),640obj->getPeriodAttribute(),641obj->getStringAttribute(SUMO_ATTR_NAME),642obj->getStringAttribute(SUMO_ATTR_FILE),643obj->getTimeAttribute(SUMO_ATTR_BEGIN),644obj->getStringListAttribute(SUMO_ATTR_VTYPES),645obj->getParameters())) {646obj->markAsCreated();647}648break;649// Vaporizer (deprecated)650case SUMO_TAG_VAPORIZER:651if (buildVaporizer(obj,652obj->getStringAttribute(SUMO_ATTR_EDGE),653obj->getTimeAttribute(SUMO_ATTR_BEGIN),654obj->getTimeAttribute(SUMO_ATTR_END),655obj->getStringAttribute(SUMO_ATTR_NAME),656obj->getParameters())) {657obj->markAsCreated();658}659break;660// wire elements661case SUMO_TAG_TRACTION_SUBSTATION:662if (buildTractionSubstation(obj,663obj->getStringAttribute(SUMO_ATTR_ID),664obj->getPositionAttribute(SUMO_ATTR_POSITION),665obj->getDoubleAttribute(SUMO_ATTR_VOLTAGE),666obj->getDoubleAttribute(SUMO_ATTR_CURRENTLIMIT),667obj->getParameters())) {668obj->markAsCreated();669}670break;671case SUMO_TAG_OVERHEAD_WIRE_SECTION:672if (buildOverheadWire(obj,673obj->getStringAttribute(SUMO_ATTR_ID),674obj->getStringAttribute(SUMO_ATTR_SUBSTATIONID),675obj->getStringListAttribute(SUMO_ATTR_LANES),676obj->getDoubleAttribute(SUMO_ATTR_STARTPOS),677obj->getDoubleAttribute(SUMO_ATTR_ENDPOS),678obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),679obj->getStringListAttribute(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN),680obj->getParameters())) {681obj->markAsCreated();682}683break;684case SUMO_TAG_OVERHEAD_WIRE_CLAMP:685if (buildOverheadWireClamp(obj,686obj->getStringAttribute(SUMO_ATTR_ID),687obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_START),688obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANESTART),689obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_END),690obj->getStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANEEND),691obj->getParameters())) {692obj->markAsCreated();693}694break;695// Polygon696case SUMO_TAG_POLY:697if (buildPolygon(obj,698obj->getStringAttribute(SUMO_ATTR_ID),699obj->getStringAttribute(SUMO_ATTR_TYPE),700obj->getColorAttribute(SUMO_ATTR_COLOR),701obj->getDoubleAttribute(SUMO_ATTR_LAYER),702obj->getDoubleAttribute(SUMO_ATTR_ANGLE),703obj->getStringAttribute(SUMO_ATTR_IMGFILE),704obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),705obj->getBoolAttribute(SUMO_ATTR_GEO),706obj->getBoolAttribute(SUMO_ATTR_FILL),707obj->getDoubleAttribute(SUMO_ATTR_LINEWIDTH),708obj->getStringAttribute(SUMO_ATTR_NAME),709obj->getParameters())) {710obj->markAsCreated();711}712break;713// POI714case SUMO_TAG_POI:715// check if we want to create a POI, POILane or POIGEO716if (obj->hasDoubleAttribute(SUMO_ATTR_X)) {717// build POI over view718if (buildPOI(obj,719obj->getStringAttribute(SUMO_ATTR_ID),720obj->getStringAttribute(SUMO_ATTR_TYPE),721obj->getColorAttribute(SUMO_ATTR_COLOR),722obj->getDoubleAttribute(SUMO_ATTR_X),723obj->getDoubleAttribute(SUMO_ATTR_Y),724obj->getStringAttribute(SUMO_ATTR_ICON),725obj->getDoubleAttribute(SUMO_ATTR_LAYER),726obj->getDoubleAttribute(SUMO_ATTR_ANGLE),727obj->getStringAttribute(SUMO_ATTR_IMGFILE),728obj->getDoubleAttribute(SUMO_ATTR_WIDTH),729obj->getDoubleAttribute(SUMO_ATTR_HEIGHT),730obj->getStringAttribute(SUMO_ATTR_NAME),731obj->getParameters())) {732obj->markAsCreated();733}734} else if (obj->hasStringAttribute(SUMO_ATTR_LANE)) {735// build POI over Lane736if (buildPOILane(obj,737obj->getStringAttribute(SUMO_ATTR_ID),738obj->getStringAttribute(SUMO_ATTR_TYPE),739obj->getColorAttribute(SUMO_ATTR_COLOR),740obj->getStringAttribute(SUMO_ATTR_LANE),741obj->getDoubleAttribute(SUMO_ATTR_POSITION),742obj->getBoolAttribute(SUMO_ATTR_FRIENDLY_POS),743obj->getDoubleAttribute(SUMO_ATTR_POSITION_LAT),744obj->getStringAttribute(SUMO_ATTR_ICON),745obj->getDoubleAttribute(SUMO_ATTR_LAYER),746obj->getDoubleAttribute(SUMO_ATTR_ANGLE),747obj->getStringAttribute(SUMO_ATTR_IMGFILE),748obj->getDoubleAttribute(SUMO_ATTR_WIDTH),749obj->getDoubleAttribute(SUMO_ATTR_HEIGHT),750obj->getStringAttribute(SUMO_ATTR_NAME),751obj->getParameters())) {752obj->markAsCreated();753}754} else {755// build POIGEO over view756if (buildPOIGeo(obj,757obj->getStringAttribute(SUMO_ATTR_ID),758obj->getStringAttribute(SUMO_ATTR_TYPE),759obj->getColorAttribute(SUMO_ATTR_COLOR),760obj->getDoubleAttribute(SUMO_ATTR_LON),761obj->getDoubleAttribute(SUMO_ATTR_LAT),762obj->getStringAttribute(SUMO_ATTR_ICON),763obj->getDoubleAttribute(SUMO_ATTR_LAYER),764obj->getDoubleAttribute(SUMO_ATTR_ANGLE),765obj->getStringAttribute(SUMO_ATTR_IMGFILE),766obj->getDoubleAttribute(SUMO_ATTR_WIDTH),767obj->getDoubleAttribute(SUMO_ATTR_HEIGHT),768obj->getStringAttribute(SUMO_ATTR_NAME),769obj->getParameters())) {770obj->markAsCreated();771}772}773break;774// Jps WalkableArea775case GNE_TAG_JPS_WALKABLEAREA:776if (buildJpsWalkableArea(obj,777obj->getStringAttribute(SUMO_ATTR_ID),778obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),779obj->getBoolAttribute(SUMO_ATTR_GEO),780obj->getStringAttribute(SUMO_ATTR_NAME),781obj->getParameters())) {782obj->markAsCreated();783}784break;785// Jps Obstacle786case GNE_TAG_JPS_OBSTACLE:787if (buildJpsObstacle(obj,788obj->getStringAttribute(SUMO_ATTR_ID),789obj->getPositionVectorAttribute(SUMO_ATTR_SHAPE),790obj->getBoolAttribute(SUMO_ATTR_GEO),791obj->getStringAttribute(SUMO_ATTR_NAME),792obj->getParameters())) {793obj->markAsCreated();794}795break;796default:797break;798}799// now iterate over childrens800for (const auto& child : obj->getSumoBaseObjectChildren()) {801// call this function recursively802parseSumoBaseObject(child);803}804}805}806807808void809AdditionalHandler::parseBusStopAttributes(const SUMOSAXAttributes& attrs) {810// declare Ok Flag811bool parsedOk = true;812// needed attributes813const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);814const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);815// optional attributes816const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);817const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);818const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");819const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());820const int personCapacity = attrs.getOpt<int>(SUMO_ATTR_PERSON_CAPACITY, id.c_str(), parsedOk, 6);821const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), parsedOk, 0);822const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);823const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);824const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);825// continue if flag is ok826if (parsedOk) {827// set tag828myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_BUS_STOP);829// add all attributes830myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);831myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);832myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);833myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);834myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);835myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);836myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_PERSON_CAPACITY, personCapacity);837myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PARKING_LENGTH, parkingLength);838myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);839myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);840myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);841} else {842myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);843}844}845846847void848AdditionalHandler::parseTrainStopAttributes(const SUMOSAXAttributes& attrs) {849// declare Ok Flag850bool parsedOk = true;851// needed attributes852const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);853const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);854// optional attributes855const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);856const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);857const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");858const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());859const int personCapacity = attrs.getOpt<int>(SUMO_ATTR_PERSON_CAPACITY, id.c_str(), parsedOk, 6);860const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), parsedOk, 0);861const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);862const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);863const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);864// continue if flag is ok865if (parsedOk) {866// set tag867myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TRAIN_STOP);868// add all attributes869myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);870myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);871myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);872myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);873myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);874myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);875myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_PERSON_CAPACITY, personCapacity);876myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PARKING_LENGTH, parkingLength);877myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);878myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);879myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);880} else {881myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);882}883}884885886void887AdditionalHandler::parseAccessAttributes(const SUMOSAXAttributes& attrs) {888// declare Ok Flag889bool parsedOk = true;890// needed attributes891const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, "", parsedOk);892const std::string position = attrs.get<std::string>(SUMO_ATTR_POSITION, "", parsedOk);893// optional attributes894const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "", parsedOk, -1.00, false); /* in future updates, INVALID_DOUBLE */895const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "", parsedOk, false);896// check parent897checkParsedParent(SUMO_TAG_ACCESS, {SUMO_TAG_BUS_STOP, SUMO_TAG_TRAIN_STOP, SUMO_TAG_CONTAINER_STOP}, parsedOk);898// continue if flag is ok899if (parsedOk) {900// set tag901myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ACCESS);902// add all attributes903myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);904myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_POSITION, position);905myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);906myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);907} else {908myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);909}910}911912913void914AdditionalHandler::parseContainerStopAttributes(const SUMOSAXAttributes& attrs) {915// declare Ok Flag916bool parsedOk = true;917// needed attributes918const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);919const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);920// optional attributes921const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);922const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);923const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");924const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());925const int containerCapacity = attrs.getOpt<int>(SUMO_ATTR_CONTAINER_CAPACITY, id.c_str(), parsedOk, 6);926const double parkingLength = attrs.getOpt<double>(SUMO_ATTR_PARKING_LENGTH, id.c_str(), parsedOk, 0);927const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);928const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);929const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);930// continue if flag is ok931if (parsedOk) {932// set tag933myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CONTAINER_STOP);934// add all attributes935myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);936myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);937myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);938myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);939myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);940myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);941myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity);942myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PARKING_LENGTH, parkingLength);943myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);944myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);945myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);946} else {947myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);948}949}950951952void953AdditionalHandler::parseChargingStationAttributes(const SUMOSAXAttributes& attrs) {954// declare Ok Flag955bool parsedOk = true;956// needed attributes957const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);958const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);959// optional attributes960const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);961const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);962const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");963const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, id.c_str(), parsedOk, std::vector<std::string>());964const double chargingPower = attrs.getOpt<double>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), parsedOk, 22000);965const double efficiency = attrs.getOpt<double>(SUMO_ATTR_EFFICIENCY, id.c_str(), parsedOk, 0.95);966const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), parsedOk, 0);967const SUMOTime chargeDelay = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CHARGEDELAY, id.c_str(), parsedOk, 0);968const std::string chargeType = attrs.getOpt<std::string>(SUMO_ATTR_CHARGETYPE, id.c_str(), parsedOk, SUMOXMLDefinitions::ChargeTypes.getString(ChargeType::NORMAL));969const SUMOTime waitingTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_WAITINGTIME, id.c_str(), parsedOk, TIME2STEPS(900));970const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);971const std::string parkingAreaID = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, id.c_str(), parsedOk, "");972// check charge type973if ((chargeType != "normal") && (chargeType != "battery-exchange") && (chargeType != "fuel")) {974writeError(TLF("Invalid charge type '%' defined in chargingStation '%'.", chargeType, id));975parsedOk = false;976}977// continue if flag is ok978if (parsedOk) {979// set tag980myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CHARGING_STATION);981// add all attributes982myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);983myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);984myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);985myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);986myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);987myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LINES, lines);988myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_CHARGINGPOWER, chargingPower);989myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_EFFICIENCY, efficiency);990myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_CHARGEINTRANSIT, chargeInTransit);991myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_CHARGEDELAY, chargeDelay);992myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_CHARGETYPE, chargeType);993myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_WAITINGTIME, waitingTime);994myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);995myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_PARKING_AREA, parkingAreaID);996} else {997myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);998}999}100010011002void1003AdditionalHandler::parseParkingAreaAttributes(const SUMOSAXAttributes& attrs) {1004// declare Ok Flag1005bool parsedOk = true;1006// needed attributes1007const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1008const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);1009// optional attributes1010const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, INVALID_DOUBLE);1011const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);1012const std::string departPos = attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, id.c_str(), parsedOk, "");1013const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1014const std::vector<std::string> badges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ACCEPTED_BADGES, id.c_str(), parsedOk, std::vector<std::string>());1015const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1016const int roadSideCapacity = attrs.getOpt<int>(SUMO_ATTR_ROADSIDE_CAPACITY, id.c_str(), parsedOk, 0);1017const bool onRoad = attrs.getOpt<bool>(SUMO_ATTR_ONROAD, id.c_str(), parsedOk, false);1018const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), parsedOk, 0);1019const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), parsedOk, 0);1020const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, 0);1021const bool lefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, id.c_str(), parsedOk, false);1022// continue if flag is ok1023if (parsedOk) {1024// set tag1025myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_PARKING_AREA);1026// add all attributes1027myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1028myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1029myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);1030myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);1031myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DEPARTPOS, departPos);1032myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1033myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_ACCEPTED_BADGES, badges);1034myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1035myCommonXMLStructure.getCurrentSumoBaseObject()->addIntAttribute(SUMO_ATTR_ROADSIDE_CAPACITY, roadSideCapacity);1036myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_ONROAD, onRoad);1037myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WIDTH, width);1038myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);1039myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);1040myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_LEFTHAND, lefthand);1041} else {1042myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1043}1044}104510461047void1048AdditionalHandler::parseParkingSpaceAttributes(const SUMOSAXAttributes& attrs) {1049// declare Ok Flag1050bool parsedOk = true;1051// needed attributes1052const double x = attrs.get<double>(SUMO_ATTR_X, "", parsedOk);1053const double y = attrs.get<double>(SUMO_ATTR_Y, "", parsedOk);1054// optional attributes1055const double z = attrs.getOpt<double>(SUMO_ATTR_Z, "", parsedOk, 0);1056const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, "", parsedOk, "");1057const std::string width = attrs.getOpt<std::string>(SUMO_ATTR_WIDTH, "", parsedOk, "");1058const std::string length = attrs.getOpt<std::string>(SUMO_ATTR_LENGTH, "", parsedOk, "");1059const std::string angle = attrs.getOpt<std::string>(SUMO_ATTR_ANGLE, "", parsedOk, "");1060const double slope = attrs.getOpt<double>(SUMO_ATTR_SLOPE, "", parsedOk, 0);1061// check parent1062checkParsedParent(SUMO_TAG_PARKING_SPACE, {SUMO_TAG_PARKING_AREA}, parsedOk);1063// continue if flag is ok1064if (parsedOk) {1065// set tag1066myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_PARKING_SPACE);1067// add all attributes1068myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_X, x);1069myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_Y, y);1070myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_Z, z);1071myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1072myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_WIDTH, width);1073myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LENGTH, length);1074myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ANGLE, angle);1075myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_SLOPE, slope);1076} else {1077myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1078}1079}108010811082void1083AdditionalHandler::parseE1Attributes(const SUMOSAXAttributes& attrs) {1084// declare Ok Flag1085bool parsedOk = true;1086// needed attributes1087const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1088const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);1089const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk);1090const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1091const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1092// optional attributes1093const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1094const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1095const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1096const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1097const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1098// continue if flag is ok1099if (parsedOk && checkDetectPersons(SUMO_TAG_E1DETECTOR, id, detectPersons)) {1100// set tag1101myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_E1DETECTOR);1102// add all attributes1103myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1104myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1105myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1106myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1107myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1108myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1109myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1110myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1111myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1112myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1113} else {1114myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1115}1116}111711181119void1120AdditionalHandler::parseE2Attributes(const SUMOSAXAttributes& attrs) {1121// declare Ok Flag1122bool parsedOk = true;1123const int positionDef = attrs.hasAttribute(SUMO_ATTR_POSITION) ? 1 : 0;1124const int endPosDef = attrs.hasAttribute(SUMO_ATTR_ENDPOS) ? 1 : 0;1125const int lengthDef = attrs.hasAttribute(SUMO_ATTR_LENGTH) ? 1 : 0;1126// check attributes1127if (attrs.hasAttribute(SUMO_ATTR_LANE) && ((positionDef + endPosDef + lengthDef) > 2)) {1128writeError(TL("'pos', 'endPos' and 'length' cannot be defined together in a single lane area detector."));1129myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1130} else if (attrs.hasAttribute(SUMO_ATTR_LANE) && ((positionDef + endPosDef + lengthDef) < 2)) {1131writeError(TL("A single lane area detector requires two parameters of those 'pos', 'endPos' and 'length'."));1132myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1133} else {1134// needed attributes1135const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1136const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1137// special attributes1138const std::string laneId = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk, "");1139const std::vector<std::string> laneIds = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), parsedOk, std::vector<std::string>());1140const double position = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, 0);1141const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, 0);1142const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), parsedOk, 0);1143// optional attributes1144const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1145const std::string trafficLight = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), parsedOk, "");1146const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1147const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), parsedOk, TIME2STEPS(1));1148const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), parsedOk, 1.39);1149const double jamDistThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), parsedOk, 10);1150const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1151const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1152const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1153const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1154const bool show = attrs.getOpt<bool>(SUMO_ATTR_SHOW_DETECTOR, id.c_str(), parsedOk, true);1155// continue if flag is ok1156if (parsedOk && checkDetectPersons(SUMO_TAG_E2DETECTOR, id, detectPersons)) {1157// set tag1158myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_E2DETECTOR);1159// add attributes depending of Lane/Lanes1160if (attrs.hasAttribute(SUMO_ATTR_LANE)) {1161myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1162if (positionDef == 0) {1163myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, endPos - length);1164myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);1165} else if (endPosDef == 0) {1166myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1167myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, length);1168} else if (lengthDef == 0) {1169myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1170myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LENGTH, endPos - position);1171}1172} else {1173myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LANES, laneIds);1174myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1175myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);1176}1177// add all attributes1178myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1179myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1180myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_TLID, trafficLight);1181myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1182myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1183myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1184myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1185myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1186myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD, haltingTimeThreshold);1187myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD, haltingSpeedThreshold);1188myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD, jamDistThreshold);1189myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1190myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_SHOW_DETECTOR, show);1191} else {1192myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1193}1194}1195}119611971198void1199AdditionalHandler::parseE3Attributes(const SUMOSAXAttributes& attrs) {1200// declare Ok Flag1201bool parsedOk = true;1202// needed attributes1203const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1204const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1205const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1206// optional attributes1207const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position());1208const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1209const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1210const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1211const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1212const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), parsedOk, TIME2STEPS(1));1213const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), parsedOk, 1.39);1214const bool openEntry = attrs.getOpt<bool>(SUMO_ATTR_OPEN_ENTRY, id.c_str(), parsedOk, false);1215const bool expectedArrival = attrs.getOpt<bool>(SUMO_ATTR_EXPECT_ARRIVAL, id.c_str(), parsedOk, false);1216// continue if flag is ok1217if (parsedOk && checkDetectPersons(SUMO_TAG_E3DETECTOR, id, detectPersons)) {1218// set tag1219myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_E3DETECTOR);1220// add all attributes1221myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1222myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1223myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1224myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1225myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1226myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1227myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1228myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1229myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD, haltingTimeThreshold);1230myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_HALTING_SPEED_THRESHOLD, haltingSpeedThreshold);1231myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_OPEN_ENTRY, openEntry);1232myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_EXPECT_ARRIVAL, expectedArrival);1233} else {1234myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1235}1236}123712381239void1240AdditionalHandler::parseEntryAttributes(const SUMOSAXAttributes& attrs) {1241// declare Ok Flag1242bool parsedOk = true;1243// needed attributes1244const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, "", parsedOk);1245const double position = attrs.get<double>(SUMO_ATTR_POSITION, "", parsedOk);1246// optional attributes1247const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "", parsedOk, false);1248// check parent1249checkParsedParent(SUMO_TAG_DET_ENTRY, {SUMO_TAG_E3DETECTOR}, parsedOk);1250// continue if flag is ok1251if (parsedOk) {1252// set tag1253myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_DET_ENTRY);1254// add all attributes1255myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1256myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1257myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1258} else {1259myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1260}1261}126212631264void1265AdditionalHandler::parseExitAttributes(const SUMOSAXAttributes& attrs) {1266// declare Ok Flag1267bool parsedOk = true;1268// needed attributes1269const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, "", parsedOk);1270const double position = attrs.get<double>(SUMO_ATTR_POSITION, "", parsedOk);1271// optional attributes1272const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "", parsedOk, false);1273// check parent1274checkParsedParent(SUMO_TAG_DET_EXIT, {SUMO_TAG_E3DETECTOR}, parsedOk);1275// continue if flag is ok1276if (parsedOk) {1277// set tag1278myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_DET_EXIT);1279// add all attributes1280myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1281myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1282myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1283} else {1284myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1285}1286}128712881289void1290AdditionalHandler::parseE1InstantAttributes(const SUMOSAXAttributes& attrs) {1291// declare Ok Flag1292bool parsedOk = true;1293// needed attributes1294const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1295const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk);1296const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk);1297const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1298// optional attributes1299const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1300const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1301const std::vector<std::string> nextEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_NEXT_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1302const std::string detectPersons = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, "", parsedOk);1303const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1304// continue if flag is ok1305if (parsedOk && checkDetectPersons(SUMO_TAG_INSTANT_INDUCTION_LOOP, id, detectPersons)) {1306// set tag1307myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_INSTANT_INDUCTION_LOOP);1308// add all attributes1309myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1310myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, laneId);1311myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, position);1312myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1313myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1314myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_NEXT_EDGES, nextEdges);1315myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DETECT_PERSONS, detectPersons);1316myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1317myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1318} else {1319myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1320}1321}132213231324void1325AdditionalHandler::parseTAZAttributes(const SUMOSAXAttributes& attrs) {1326// declare Ok Flag1327bool parsedOk = true;1328// needed attributes1329const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1330// optional attributes1331const PositionVector shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk, PositionVector());1332const Position center = attrs.getOpt<Position>(SUMO_ATTR_CENTER, id.c_str(), parsedOk, shape.size() > 0 ? shape.getCentroid() : Position::INVALID);1333const bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, id.c_str(), parsedOk, false);1334const std::vector<std::string> edges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk, std::vector<std::string>());1335const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::RED);1336const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1337// continue if flag is ok1338if (parsedOk) {1339// set tag1340myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TAZ);1341// add all attributes1342myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1343myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shape);1344myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_CENTER, center);1345myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FILL, fill);1346myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_EDGES, edges);1347myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);1348myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1349} else {1350myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1351}1352}135313541355void1356AdditionalHandler::parseTAZSourceAttributes(const SUMOSAXAttributes& attrs) {1357// declare Ok Flag1358bool parsedOk = true;1359// needed attributes1360const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1361const double weight = attrs.get<double>(SUMO_ATTR_WEIGHT, edgeID.c_str(), parsedOk);1362// check parent1363checkParsedParent(SUMO_TAG_TAZSOURCE, {SUMO_TAG_TAZ}, parsedOk);1364// continue if flag is ok1365if (parsedOk) {1366// set tag1367myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TAZSOURCE);1368// add all attributes1369myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1370myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WEIGHT, weight);1371} else {1372myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1373}1374}137513761377void1378AdditionalHandler::parseTAZSinkAttributes(const SUMOSAXAttributes& attrs) {1379// declare Ok Flag1380bool parsedOk = true;1381// needed attributes1382const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1383const double weight = attrs.get<double>(SUMO_ATTR_WEIGHT, edgeID.c_str(), parsedOk);1384// check parent1385checkParsedParent(SUMO_TAG_TAZSINK, {SUMO_TAG_TAZ}, parsedOk);1386// continue if flag is ok1387if (parsedOk) {1388// set tag1389myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TAZSINK);1390// add all attributes1391myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1392myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WEIGHT, weight);1393} else {1394myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1395}1396}139713981399void1400AdditionalHandler::parseVariableSpeedSignAttributes(const SUMOSAXAttributes& attrs) {1401// declare Ok Flag1402bool parsedOk = true;1403// needed attributes1404const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1405const std::vector<std::string> lanes = attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), parsedOk);1406// optional attributes1407const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position());1408const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1409const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1410// continue if flag is ok1411if (parsedOk) {1412// set tag1413myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_VSS);1414// add all attributes1415myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1416myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LANES, lanes);1417myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1418myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1419myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1420} else {1421myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1422}1423}142414251426void1427AdditionalHandler::parseVariableSpeedSignStepAttributes(const SUMOSAXAttributes& attrs) {1428// declare Ok Flag1429bool parsedOk = true;1430// needed attributes1431const SUMOTime time = attrs.getSUMOTimeReporting(SUMO_ATTR_TIME, "", parsedOk);1432// optional attributes1433const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, OptionsCont::getOptions().getFloat("default.speed"));1434// check parent1435checkParsedParent(SUMO_TAG_STEP, {SUMO_TAG_VSS}, parsedOk);1436// continue if flag is ok1437if (parsedOk) {1438// set tag1439myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_STEP);1440// add all attributes1441myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_TIME, time);1442myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_SPEED, speed);1443} else {1444myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1445}1446}144714481449void1450AdditionalHandler::parseCalibratorAttributes(const SUMOSAXAttributes& attrs) {1451// declare Ok Flag1452bool parsedOk = true;1453// check that frecuency and trafficLight aren't defined together1454if ((attrs.hasAttribute(SUMO_ATTR_EDGE) && attrs.hasAttribute(SUMO_ATTR_LANE)) ||1455(!attrs.hasAttribute(SUMO_ATTR_EDGE) && !attrs.hasAttribute(SUMO_ATTR_LANE))) {1456writeError(TL("Calibrators need either an edge or a lane"));1457parsedOk = false;1458}1459// needed attributes1460const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1461const double pos = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk);1462// special attributes1463const std::string edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, id.c_str(), parsedOk, "");1464const std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), parsedOk, "");1465// optional attributes1466const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1467const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, DELTA_T);1468const std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), parsedOk, "");1469const double jamThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), parsedOk, 0.5);1470const std::string output = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), parsedOk, "");1471const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1472// continue if flag is ok1473if (parsedOk) {1474// set tag depending of edge/lane1475if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {1476myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CALIBRATOR);1477myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_EDGE, edge);1478} else {1479myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(GNE_TAG_CALIBRATOR_LANE);1480myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, lane);1481}1482myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1483myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, pos);1484myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1485myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1486myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ROUTEPROBE, routeProbe);1487myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold);1488myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OUTPUT, output);1489myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1490} else {1491myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1492}1493}149414951496void1497AdditionalHandler::parseCalibratorFlowAttributes(const SUMOSAXAttributes& attrs) {1498// declare Ok Flag1499bool parsedOk = true;1500// check parent1501if (checkCalibratorFlowParents()) {1502// check that frecuency and trafficLight aren't defined together1503if (!attrs.hasAttribute(SUMO_ATTR_TYPE) && !attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR) && !attrs.hasAttribute(SUMO_ATTR_SPEED)) {1504writeError(TL("CalibratorFlows need either the attribute vehsPerHour or speed or type (or any combination of these)"));1505myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1506} else {1507SUMOVehicleParameter* flowParameter = SUMOVehicleParserHelper::parseVehicleAttributes(SUMO_TAG_FLOW, attrs, false, true, true);1508if (flowParameter) {1509// set VPH and speed1510if (attrs.hasAttribute(SUMO_ATTR_VEHSPERHOUR)) {1511flowParameter->repetitionOffset = TIME2STEPS(3600. / attrs.get<double>(SUMO_ATTR_VEHSPERHOUR, "", parsedOk));1512flowParameter->parametersSet |= VEHPARS_VPH_SET;1513}1514if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {1515flowParameter->calibratorSpeed = attrs.get<double>(SUMO_ATTR_SPEED, "", parsedOk);1516flowParameter->parametersSet |= VEHPARS_CALIBRATORSPEED_SET;1517}1518// set begin and end1519flowParameter->depart = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, "", parsedOk);1520flowParameter->repetitionEnd = attrs.getSUMOTimeReporting(SUMO_ATTR_END, "", parsedOk);1521if (parsedOk) {1522// set tag1523myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_FLOW);1524// set vehicle parameters1525myCommonXMLStructure.getCurrentSumoBaseObject()->setVehicleParameter(flowParameter);1526// delete flow parameter (because in XMLStructure we have a copy)1527delete flowParameter;1528} else {1529myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1530}1531} else {1532myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1533}1534}1535} else {1536myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1537}1538}153915401541void1542AdditionalHandler::parseRerouterAttributes(const SUMOSAXAttributes& attrs) {1543// declare Ok Flag1544bool parsedOk = true;1545// needed attributes1546const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1547const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);1548// optional attributes1549const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position::INVALID);1550const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1551const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 1);1552SUMOTime timeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), parsedOk, 0);1553const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1554const bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), parsedOk, false);1555const bool optional = attrs.getOpt<bool>(SUMO_ATTR_OPTIONAL, id.c_str(), parsedOk, false);1556// check attributes1557if (!checkNegative(SUMO_TAG_REROUTER, id, SUMO_ATTR_PROB, probability, true)) {1558parsedOk = false;1559}1560// continue if flag is ok1561if (parsedOk) {1562// set tag1563myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_REROUTER);1564// add all attributes1565myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1566myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_EDGES, edges);1567myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1568myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1569myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1570myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold);1571myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1572myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_OFF, off);1573myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_OPTIONAL, optional);1574} else {1575myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1576}1577}157815791580void1581AdditionalHandler::parseRerouterIntervalAttributes(const SUMOSAXAttributes& attrs) {1582// declare Ok Flag1583bool parsedOk = true;1584// needed attributes1585const SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, "", parsedOk);1586const SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, "", parsedOk);1587// check parent1588checkParsedParent(SUMO_TAG_INTERVAL, {SUMO_TAG_REROUTER}, parsedOk);1589// continue if flag is ok1590if (parsedOk) {1591// set tag1592myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_INTERVAL);1593// add all attributes1594myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_BEGIN, begin);1595myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_END, end);1596} else {1597myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1598}1599}160016011602void1603AdditionalHandler::parseClosingLaneRerouteAttributes(const SUMOSAXAttributes& attrs) {1604// declare Ok Flag1605bool parsedOk = true;1606// needed attributes1607const std::string laneID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1608// optional attributes1609const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, "", parsedOk, "");1610const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, "", parsedOk, !disallow.size() ? "authority" : "");1611// check parent1612checkParsedParent(SUMO_TAG_CLOSING_LANE_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1613// continue if flag is ok1614if (parsedOk) {1615// set tag1616myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CLOSING_LANE_REROUTE);1617// add all attributes1618myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, laneID);1619myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ALLOW, allow);1620myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DISALLOW, disallow);1621} else {1622myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1623}1624}162516261627void1628AdditionalHandler::parseClosingRerouteAttributes(const SUMOSAXAttributes& attrs) {1629// declare Ok Flag1630bool parsedOk = true;1631// needed attributes1632const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1633// optional attributes1634const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, "", parsedOk, "");1635const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, "", parsedOk, !disallow.size() ? "authority" : "");1636// check parent1637checkParsedParent(SUMO_TAG_CLOSING_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1638// continue if flag is ok1639if (parsedOk) {1640// set tag1641myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_CLOSING_REROUTE);1642// add all attributes1643myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1644myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ALLOW, allow);1645myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_DISALLOW, disallow);1646} else {1647myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1648}1649}165016511652void1653AdditionalHandler::parseDestProbRerouteAttributes(const SUMOSAXAttributes& attrs) {1654// declare Ok Flag1655bool parsedOk = true;1656// needed attributes1657const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1658const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, "", parsedOk, 1);1659// check attributes1660if (!checkNegative(SUMO_TAG_DEST_PROB_REROUTE, edgeID, SUMO_ATTR_PROB, probability, true)) {1661parsedOk = false;1662}1663// check parent1664checkParsedParent(SUMO_TAG_DEST_PROB_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1665// continue if flag is ok1666if (parsedOk) {1667// set tag1668myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_DEST_PROB_REROUTE);1669// add all attributes1670myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, edgeID);1671myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1672} else {1673myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1674}1675}167616771678void1679AdditionalHandler::parseParkingAreaRerouteAttributes(const SUMOSAXAttributes& attrs) {1680// declare Ok Flag1681bool parsedOk = true;1682// needed attributes1683const std::string parkingAreaID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1684const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, "", parsedOk, 1);1685// check attributes1686if (!checkNegative(SUMO_TAG_PARKING_AREA_REROUTE, parkingAreaID, SUMO_ATTR_PROB, probability, true)) {1687parsedOk = false;1688}1689// optional attributes1690const bool visible = attrs.getOpt<bool>(SUMO_ATTR_VISIBLE, "", parsedOk, false);1691// check parent1692checkParsedParent(SUMO_TAG_PARKING_AREA_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1693// continue if flag is ok1694if (parsedOk) {1695// set tag1696myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_PARKING_AREA_REROUTE);1697// add all attributes1698myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, parkingAreaID);1699myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1700myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_VISIBLE, visible);1701} else {1702myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1703}1704}170517061707void1708AdditionalHandler::parseRouteProbRerouteAttributes(const SUMOSAXAttributes& attrs) {1709// declare Ok Flag1710bool parsedOk = true;1711// needed attributes1712const std::string routeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1713const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, "", parsedOk, 1);1714// check attributes1715if (!checkNegative(SUMO_TAG_ROUTE_PROB_REROUTE, routeID, SUMO_ATTR_PROB, probability, true)) {1716parsedOk = false;1717}1718// check parent1719checkParsedParent(SUMO_TAG_ROUTE_PROB_REROUTE, {SUMO_TAG_INTERVAL}, parsedOk);1720// continue if flag is ok1721if (parsedOk) {1722// set tag1723myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ROUTE_PROB_REROUTE);1724// add all attributes1725myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, routeID);1726myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_PROB, probability);1727} else {1728myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1729}1730}173117321733void1734AdditionalHandler::parseRouteProbeAttributes(const SUMOSAXAttributes& attrs) {1735// declare Ok Flag1736bool parsedOk = true;1737// needed attributes1738const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1739const std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), parsedOk);1740const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), parsedOk);1741const SUMOTime period = attrs.getOptPeriod(id.c_str(), parsedOk, SUMOTime_MAX_PERIOD);1742const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), parsedOk, -1);1743// optional attributes1744const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1745const std::vector<std::string> vehicleTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk, std::vector<std::string>());1746// continue if flag is ok1747if (parsedOk) {1748// set tag1749myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ROUTEPROBE);1750// add all attributes1751myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1752myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_EDGE, edge);1753myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_FILE, file);1754myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_PERIOD, period);1755myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1756myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_BEGIN, begin);1757myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_VTYPES, vehicleTypes);1758} else {1759myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1760}1761}176217631764void1765AdditionalHandler::parseVaporizerAttributes(const SUMOSAXAttributes& attrs) {1766// declare Ok Flag1767bool parsedOk = true;1768// needed attributes1769const std::string edgeID = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1770SUMOTime begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);1771SUMOTime end = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);1772// optional attributes1773const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, edgeID.c_str(), parsedOk, "");1774// continue if flag is ok1775if (parsedOk) {1776// set tag1777myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_VAPORIZER);1778// add all attributes1779myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_EDGE, edgeID);1780myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_BEGIN, begin);1781myCommonXMLStructure.getCurrentSumoBaseObject()->addTimeAttribute(SUMO_ATTR_END, end);1782myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1783} else {1784myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1785}1786}178717881789void1790AdditionalHandler::parseTractionSubstation(const SUMOSAXAttributes& attrs) {1791// declare Ok Flag1792bool parsedOk = true;1793// needed attributes1794const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1795// optional attributes1796const Position pos = attrs.getOpt<Position>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, Position::INVALID);1797const double voltage = attrs.getOpt<double>(SUMO_ATTR_VOLTAGE, id.c_str(), parsedOk, 600);1798const double currentLimit = attrs.getOpt<double>(SUMO_ATTR_CURRENTLIMIT, id.c_str(), parsedOk, 400);1799// continue if flag is ok1800if (parsedOk) {1801// set tag1802myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_TRACTION_SUBSTATION);1803// add all attributes1804myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1805myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionAttribute(SUMO_ATTR_POSITION, pos);1806myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_VOLTAGE, voltage);1807myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_CURRENTLIMIT, currentLimit);1808} else {1809myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1810}1811}181218131814void1815AdditionalHandler::parseOverheadWire(const SUMOSAXAttributes& attrs) {1816// declare Ok Flag1817bool parsedOk = true;1818// needed attributes1819const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1820const std::string substationID = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, id.c_str(), parsedOk);1821const std::vector<std::string> laneIDs = attrs.get<std::vector<std::string> >(SUMO_ATTR_LANES, id.c_str(), parsedOk);1822// optional attributes1823const double startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), parsedOk, 0);1824const double endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), parsedOk, INVALID_DOUBLE);1825const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1826const std::vector<std::string> forbiddenInnerLanes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN, "", parsedOk);1827// continue if flag is ok1828if (parsedOk) {1829// set tag1830myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_OVERHEAD_WIRE_SECTION);1831// add all attributes1832myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1833myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_SUBSTATIONID, substationID);1834myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_LANES, laneIDs);1835myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_STARTPOS, startPos);1836myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ENDPOS, endPos);1837myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1838myCommonXMLStructure.getCurrentSumoBaseObject()->addStringListAttribute(SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN, forbiddenInnerLanes);1839} else {1840myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1841}1842}184318441845void1846AdditionalHandler::parseOverheadWireClamp(const SUMOSAXAttributes& attrs) {1847// declare Ok Flag1848bool parsedOk = true;1849// needed attributes1850const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1851const std::string substationId = attrs.get<std::string>(SUMO_ATTR_SUBSTATIONID, id.c_str(), parsedOk);1852const std::string wireClampStart = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_START, id.c_str(), parsedOk);1853const std::string wireClampLaneStart = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANESTART, id.c_str(), parsedOk);1854const std::string wireClampEnd = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_END, id.c_str(), parsedOk);1855const std::string wireClampLaneEnd = attrs.get<std::string>(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANEEND, id.c_str(), parsedOk);1856// continue if flag is ok1857if (parsedOk) {1858// set tag1859myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_OVERHEAD_WIRE_CLAMP);1860// add all attributes1861myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1862myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_SUBSTATIONID, substationId);1863myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_START, wireClampStart);1864myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANESTART, wireClampLaneStart);1865myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_END, wireClampEnd);1866myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_OVERHEAD_WIRECLAMP_LANEEND, wireClampLaneEnd);1867} else {1868myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1869}1870}187118721873void1874AdditionalHandler::parsePolyAttributes(const SUMOSAXAttributes& attrs) {1875// declare Ok Flag1876bool parsedOk = true;1877// needed attributes1878const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1879const PositionVector shapeStr = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk);1880// optional attributes1881const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::RED);1882const bool geo = attrs.getOpt<bool>(SUMO_ATTR_GEO, id.c_str(), parsedOk, false);1883const bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, id.c_str(), parsedOk, false);1884const double lineWidth = attrs.getOpt<double>(SUMO_ATTR_LINEWIDTH, id.c_str(), parsedOk, Shape::DEFAULT_LINEWIDTH);1885const double layer = attrs.getOpt<double>(SUMO_ATTR_LAYER, id.c_str(), parsedOk, Shape::DEFAULT_LAYER);1886const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), parsedOk, Shape::DEFAULT_TYPE);1887const std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), parsedOk, Shape::DEFAULT_IMG_FILE);1888const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, Shape::DEFAULT_ANGLE);1889const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1890// continue if flag is ok1891if (parsedOk) {1892// set tag1893myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_POLY);1894// add all attributes1895myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1896myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shapeStr);1897myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);1898myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_GEO, geo);1899myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FILL, fill);1900myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LINEWIDTH, lineWidth);1901myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LAYER, layer);1902myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_TYPE, type);1903myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_IMGFILE, imgFile);1904myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);1905myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1906} else {1907myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1908}1909}191019111912void1913AdditionalHandler::parsePOIAttributes(const SUMOSAXAttributes& attrs) {1914// declare Ok Flag1915bool parsedOk = true;1916// check that x and y are defined together1917if ((attrs.hasAttribute(SUMO_ATTR_X) && !attrs.hasAttribute(SUMO_ATTR_Y)) ||1918(!attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y))) {1919writeError(TL("X and Y must be be defined together in POIs"));1920parsedOk = false;1921}1922// check that lane and pos are defined together1923if ((attrs.hasAttribute(SUMO_ATTR_LANE) && !attrs.hasAttribute(SUMO_ATTR_POSITION)) ||1924(!attrs.hasAttribute(SUMO_ATTR_LANE) && attrs.hasAttribute(SUMO_ATTR_POSITION))) {1925writeError(TL("lane and position must be defined together in POIs"));1926parsedOk = false;1927}1928// check that lon and lat are defined together1929if ((attrs.hasAttribute(SUMO_ATTR_LON) && !attrs.hasAttribute(SUMO_ATTR_LAT)) ||1930(!attrs.hasAttribute(SUMO_ATTR_LON) && attrs.hasAttribute(SUMO_ATTR_LAT))) {1931writeError(TL("lon and lat must be be defined together in POIs"));1932parsedOk = false;1933}1934// needed attributes1935const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);1936// special attributes1937const double x = attrs.getOpt<double>(SUMO_ATTR_X, id.c_str(), parsedOk, 0);1938const double y = attrs.getOpt<double>(SUMO_ATTR_Y, id.c_str(), parsedOk, 0);1939const std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, "", parsedOk, "");1940const double pos = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), parsedOk, 0);1941const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), parsedOk, false);1942const double posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, id.c_str(), parsedOk, 0);1943const double lon = attrs.getOpt<double>(SUMO_ATTR_LON, id.c_str(), parsedOk, 0);1944const double lat = attrs.getOpt<double>(SUMO_ATTR_LAT, id.c_str(), parsedOk, 0);1945// optional attributes1946const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::RED);1947const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, "", parsedOk, Shape::DEFAULT_TYPE);1948std::string icon = attrs.getOpt<std::string>(SUMO_ATTR_ICON, "", parsedOk, SUMOXMLDefinitions::POIIcons.getString(POIIcon::NONE));1949const double layer = attrs.getOpt<double>(SUMO_ATTR_LAYER, id.c_str(), parsedOk, Shape::DEFAULT_LAYER_POI);1950const std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, "", parsedOk, Shape::DEFAULT_IMG_FILE);1951const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), parsedOk, Shape::DEFAULT_IMG_WIDTH);1952const double height = attrs.getOpt<double>(SUMO_ATTR_HEIGHT, id.c_str(), parsedOk, Shape::DEFAULT_IMG_HEIGHT);1953const double angle = attrs.getOpt<double>(SUMO_ATTR_ANGLE, id.c_str(), parsedOk, Shape::DEFAULT_ANGLE);1954const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");1955// check icon1956if (!SUMOXMLDefinitions::POIIcons.hasString(icon)) {1957WRITE_WARNING(TLF("Invalid icon % for POI '%', using default", icon, id));1958icon = "none";1959}1960// continue if flag is ok1961if (parsedOk) {1962// set tag1963myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_POI);1964// add attributes depending of Lane/Lanes1965if (attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y)) {1966myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_X, x);1967myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_Y, y);1968} else if (attrs.hasAttribute(SUMO_ATTR_LANE) && attrs.hasAttribute(SUMO_ATTR_POSITION)) {1969myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_LANE, lane);1970myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION, pos);1971myCommonXMLStructure.getCurrentSumoBaseObject()->addBoolAttribute(SUMO_ATTR_FRIENDLY_POS, friendlyPos);1972myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_POSITION_LAT, posLat);1973} else {1974myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LON, lon);1975myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LAT, lat);1976}1977// add rest attributes1978myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);1979myCommonXMLStructure.getCurrentSumoBaseObject()->addColorAttribute(SUMO_ATTR_COLOR, color);1980myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_TYPE, type);1981myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ICON, icon);1982myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_LAYER, layer);1983myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_IMGFILE, imgFile);1984myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_WIDTH, width);1985myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_HEIGHT, height);1986myCommonXMLStructure.getCurrentSumoBaseObject()->addDoubleAttribute(SUMO_ATTR_ANGLE, angle);1987myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);1988} else {1989myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);1990}1991}199219931994void1995AdditionalHandler::parseJpsWalkableAreaAttributes(const SUMOSAXAttributes& attrs) {1996// declare Ok Flag1997bool parsedOk = true;1998// needed attributes1999const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);2000const PositionVector shapeStr = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk);2001// optional attributes2002const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");2003// continue if flag is ok2004if (parsedOk) {2005// set tag2006myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(GNE_TAG_JPS_WALKABLEAREA);2007// add all attributes2008myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);2009myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shapeStr);2010myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);2011} else {2012myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);2013}2014}201520162017void2018AdditionalHandler::parseJpsObstacleAttributes(const SUMOSAXAttributes& attrs) {2019// declare Ok Flag2020bool parsedOk = true;2021// needed attributes2022const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);2023const PositionVector shapeStr = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), parsedOk);2024// optional attributes2025const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), parsedOk, "");2026// continue if flag is ok2027if (parsedOk) {2028// set tag2029myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(GNE_TAG_JPS_OBSTACLE);2030// add all attributes2031myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_ID, id);2032myCommonXMLStructure.getCurrentSumoBaseObject()->addPositionVectorAttribute(SUMO_ATTR_SHAPE, shapeStr);2033myCommonXMLStructure.getCurrentSumoBaseObject()->addStringAttribute(SUMO_ATTR_NAME, name);2034} else {2035myCommonXMLStructure.getCurrentSumoBaseObject()->setTag(SUMO_TAG_ERROR);2036}2037}203820392040bool2041AdditionalHandler::checkCalibratorFlowParents() {2042const auto parentCalibrator = myCommonXMLStructure.getCurrentSumoBaseObject()->getParentSumoBaseObject();2043if (parentCalibrator == nullptr) {2044return false;2045}2046const auto parentRootFile = parentCalibrator->getParentSumoBaseObject();2047if (parentRootFile != nullptr) {2048return false;2049}2050if ((parentCalibrator->getTag() == SUMO_TAG_CALIBRATOR) || (parentCalibrator->getTag() == GNE_TAG_CALIBRATOR_LANE)) {2051return true;2052} else {2053return writeError(TLF("Calibrator Flows have to be defined within a %.", toString(SUMO_TAG_CALIBRATOR)));2054}2055}205620572058bool2059AdditionalHandler::checkDetectPersons(const SumoXMLTag currentTag, const std::string& id, const std::string& detectPersons) {2060if (detectPersons.empty() || SUMOXMLDefinitions::PersonModeValues.hasString(detectPersons)) {2061return true;2062} else {2063writeError(TLF("Attribute '%' defined in % with id '%' doesn't have a valid value (given '%').", toString(SUMO_ATTR_DETECT_PERSONS), toString(currentTag), id, detectPersons));2064return false;2065}2066}20672068/****************************************************************************/206920702071