SUMO - Simulation of Urban MObility
GNEAdditionalHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Builds trigger objects for netedit
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 #include <utils/xml/XMLSubSys.h>
26 #include <netedit/GNEViewNet.h>
27 #include <netedit/GNEUndoList.h>
28 #include <netedit/GNENet.h>
30 
31 #include "GNEAdditionalHandler.h"
32 #include "GNEBusStop.h"
33 #include "GNEAccess.h"
34 #include "GNECalibrator.h"
35 #include "GNECalibratorFlow.h"
36 #include "GNECalibratorRoute.h"
38 #include "GNEChargingStation.h"
39 #include "GNEClosingLaneReroute.h"
40 #include "GNEClosingReroute.h"
41 #include "GNEContainerStop.h"
42 #include "GNEDestProbReroute.h"
43 #include "GNEDetectorE1.h"
44 #include "GNEDetectorE2.h"
45 #include "GNEDetectorE3.h"
46 #include "GNEDetectorEntry.h"
47 #include "GNEDetectorExit.h"
48 #include "GNEDetectorE1Instant.h"
49 #include "GNEParkingArea.h"
50 #include "GNEParkingSpace.h"
51 #include "GNERerouter.h"
52 #include "GNERerouterInterval.h"
53 #include "GNERouteProbReroute.h"
54 #include "GNEParkingAreaReroute.h"
55 #include "GNERouteProbe.h"
56 #include "GNEVaporizer.h"
57 #include "GNEVariableSpeedSign.h"
59 #include "GNETAZ.h"
60 #include "GNETAZSource.h"
61 #include "GNETAZSink.h"
62 
63 
64 // ===========================================================================
65 // member method definitions
66 // ===========================================================================
67 
68 GNEAdditionalHandler::GNEAdditionalHandler(const std::string& file, GNEViewNet* viewNet, bool undoAdditionals, GNEAdditional* additionalParent) :
69  SUMOSAXHandler(file),
70  myViewNet(viewNet),
71  myUndoAdditionals(undoAdditionals),
72  myAdditionalParent(additionalParent) {
73  if (additionalParent) {
76  }
77 }
78 
79 
81 
82 
83 void
85  // Obtain tag of element
86  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
87  // check if we're parsing a generic parameter
88  if (tag == SUMO_TAG_PARAM) {
89  // push element int stack
91  // parse generic parameter
92  parseGenericParameter(attrs);
93  } else if (tag != SUMO_TAG_NOTHING) {
94  // push element int stack
96  // Call parse and build depending of tag
97  switch (tag) {
98  case SUMO_TAG_BUS_STOP:
99  parseAndBuildBusStop(attrs, tag);
100  break;
101  case SUMO_TAG_TRAIN_STOP:
103  break;
104  case SUMO_TAG_ACCESS:
105  parseAndBuildAccess(attrs, tag);
106  break;
108  parseAndBuildContainerStop(attrs, tag);
109  break;
111  parseAndBuildChargingStation(attrs, tag);
112  break;
113  case SUMO_TAG_E1DETECTOR:
115  parseAndBuildDetectorE1(attrs, tag);
116  break;
117  case SUMO_TAG_E2DETECTOR:
119  parseAndBuildDetectorE2(attrs, tag);
120  break;
121  case SUMO_TAG_E3DETECTOR:
123  parseAndBuildDetectorE3(attrs, tag);
124  break;
125  case SUMO_TAG_DET_ENTRY:
126  parseAndBuildDetectorEntry(attrs, tag);
127  break;
128  case SUMO_TAG_DET_EXIT:
129  parseAndBuildDetectorExit(attrs, tag);
130  break;
132  parseAndBuildDetectorE1Instant(attrs, tag);
133  break;
134  case SUMO_TAG_ROUTEPROBE:
135  parseAndBuildRouteProbe(attrs, tag);
136  break;
137  case SUMO_TAG_VAPORIZER:
138  parseAndBuildVaporizer(attrs, tag);
139  break;
140  case SUMO_TAG_TAZ:
141  parseAndBuildTAZ(attrs, tag);
142  break;
143  case SUMO_TAG_TAZSOURCE:
144  parseAndBuildTAZSource(attrs, tag);
145  break;
146  case SUMO_TAG_TAZSINK:
147  parseAndBuildTAZSink(attrs, tag);
148  break;
149  case SUMO_TAG_VSS:
150  parseAndBuildVariableSpeedSign(attrs, tag);
151  break;
152  case SUMO_TAG_STEP:
154  break;
155  case SUMO_TAG_CALIBRATOR:
156  parseAndBuildCalibrator(attrs, tag);
157  break;
159  parseAndBuildParkingArea(attrs, tag);
160  break;
162  parseAndBuildParkingSpace(attrs, tag);
163  break;
164  case SUMO_TAG_VTYPE:
166  break;
167  case SUMO_TAG_ROUTE:
168  parseAndBuildCalibratorRoute(attrs, tag);
169  break;
170  case SUMO_TAG_FLOW:
171  parseAndBuildCalibratorFlow(attrs, tag);
172  break;
173  case SUMO_TAG_REROUTER:
174  parseAndBuildRerouter(attrs, tag);
175  break;
176  case SUMO_TAG_INTERVAL:
177  parseAndBuildRerouterInterval(attrs, tag);
178  break;
181  break;
184  break;
187  break;
190  break;
193  break;
194  default:
195  break;
196  }
197  }
198 }
199 
200 
201 void
203  // pop last inserted element
205 }
206 
207 
208 void
210  bool abort = false;
211  // parse attributes of Vaporizer
212  const std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
213  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_BEGIN, abort);
214  double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_END, abort);
215  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_NAME, abort);
216  // Continue if all parameters were successfully loaded
217  if (!abort) {
218  // get GNEEdge
219  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
220  // check that all parameters are valid
221  if (edge == nullptr) {
222  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
223  } else if (myViewNet->getNet()->retrieveAdditional(tag, edgeID, false) != nullptr) {
224  WRITE_WARNING("There is already a " + toString(tag) + " in the edge '" + edgeID + "'.");
225  } else if (begin > end) {
226  WRITE_WARNING("Time interval of " + toString(tag) + " isn't valid. Attribute '" + toString(SUMO_ATTR_BEGIN) + "' is greater than attribute '" + toString(SUMO_ATTR_END) + "'.");
227  } else {
228  // build vaporizer
230  }
231  }
232 }
233 
234 
235 void
237  bool abort = false;
238  // parse attributes of Vaporizer
239  const std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
240  const PositionVector shape = GNEAttributeCarrier::parseAttributeFromXML<PositionVector>(attrs, id, tag, SUMO_ATTR_SHAPE, abort);
241  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, id, tag, SUMO_ATTR_COLOR, abort);
242  std::vector<std::string> edgeIDs;
243  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
244  std::string parsedAttribute = attrs.get<std::string>(SUMO_ATTR_EDGES, id.c_str(), abort, false);
245  edgeIDs = GNEAttributeCarrier::parse<std::vector<std::string> >(parsedAttribute);
246  }
247  // check if all edge IDs are valid
248  std::vector<GNEEdge*> edges;
249  for (auto i : edgeIDs) {
250  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(i, false);
251  if (edge == nullptr) {
252  WRITE_WARNING("Invalid " + toString(SUMO_TAG_EDGE) + " with ID = '" + i + "'.");
253  abort = true;
254  } else {
255  edges.push_back(edge);
256  }
257  }
258  // Continue if all parameters were successfully loaded
259  if (!abort) {
260  // check that all parameters are valid
261  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
262  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
263  } else {
264  // save ID of last created element
266  }
267  }
268 }
269 
270 
271 void
273  bool abort = false;
274  // parse attributes of Vaporizer
275  const std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
276  const double departWeight = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, edgeID, tag, SUMO_ATTR_WEIGHT, abort);
277  // Continue if all parameters were successfully loaded
278  if (!abort) {
279  // get edge and TAZ
280  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
282  // check that all parameters are valid
283  if (edge == nullptr) {
284  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
285  } else if (TAZ == nullptr) {
286  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_TAZ) + ".");
287  } else {
288  // save ID of last created element
290  }
291  }
292 }
293 
294 
295 void
297  bool abort = false;
298  // parse attributes of Vaporizer
299  const std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
300  const double arrivalWeight = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, edgeID, tag, SUMO_ATTR_WEIGHT, abort);
301  // Continue if all parameters were successfully loaded
302  if (!abort) {
303  // get edge and TAZ
304  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
306  // check that all parameters are valid
307  if (edge == nullptr) {
308  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
309  } else if (TAZ == nullptr) {
310  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_TAZ) + ".");
311  } else {
312  // save ID of last created element
314  }
315  }
316 }
317 
318 
319 void
321  bool abort = false;
322  // parse attributes of RouteProbe
323  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
324  std::string edgeId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_EDGE, abort);
325  std::string freq = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
326  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
327  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort);
328  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_BEGIN, abort);
329  // Continue if all parameters were sucesfully loaded
330  if (!abort) {
331  // get edge
332  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
333  // check that all elements are valid
334  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
335  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
336  } else if (edge == nullptr) {
337  // Write error if lane isn't valid
338  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
339  } else {
340  // Freq needs an extra check, because it can be empty
341  if (GNEAttributeCarrier::canParse<double>(freq)) {
342  if (GNEAttributeCarrier::parse<double>(freq) < 0) {
343  WRITE_WARNING(toString(SUMO_ATTR_FREQUENCY) + "of " + toString(tag) + "'" + id + "' cannot be negative.");
344  freq = "";
345  }
346  } else {
347  if (freq.empty()) {
348  WRITE_WARNING(toString(SUMO_ATTR_FREQUENCY) + "of " + toString(tag) + "'" + id + "' cannot be parsed to float.");
349  }
350  freq = "";
351  }
352  // save ID of last created element
354  }
355  }
356 }
357 
358 
359 void
361  bool abort = false;
362  // parse attribute of calibrator routes
363  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
364  std::string edgeIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, routeID, tag, SUMO_ATTR_EDGES, abort);
365  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, routeID, tag, SUMO_ATTR_COLOR, abort);
366  // Continue if all parameters were sucesfully loaded
367  if (!abort) {
368  // obtain edges (And show warnings if isn't valid)
369  std::vector<GNEEdge*> edges;
370  if (GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(myViewNet->getNet(), edgeIDs, true)) {
371  edges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(myViewNet->getNet(), edgeIDs);
372  }
373  // check that all elements are valid
374  if (myViewNet->getNet()->retrieveAdditional(SUMO_TAG_ROUTE, routeID, false) != nullptr) {
375  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + routeID + "'.");
376  } else if (edges.size() == 0) {
377  WRITE_WARNING("Routes needs at least one edge.");
378  } else {
379  // save ID of last created element
381  }
382  }
383 }
384 
385 
386 void
388  bool abort = false;
389  // parse attribute of calibrator vehicle types
390  std::string vehicleTypeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
391  double accel = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_ACCEL, abort);
392  double decel = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_DECEL, abort);
393  double sigma = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_SIGMA, abort);
394  double tau = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_TAU, abort);
395  double length = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_LENGTH, abort);
396  double minGap = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MINGAP, abort);
397  double maxSpeed = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MAXSPEED, abort);
398  double speedFactor = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_SPEEDFACTOR, abort);
399  double speedDev = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_SPEEDDEV, abort);
400  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, vehicleTypeID, tag, SUMO_ATTR_COLOR, abort);
401  SUMOVehicleClass vClass = GNEAttributeCarrier::parseAttributeFromXML<SUMOVehicleClass>(attrs, vehicleTypeID, tag, SUMO_ATTR_VCLASS, abort);
402  std::string emissionClass = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_EMISSIONCLASS, abort);
403  SUMOVehicleShape shape = GNEAttributeCarrier::parseAttributeFromXML<SUMOVehicleShape>(attrs, vehicleTypeID, tag, SUMO_ATTR_GUISHAPE, abort);
404  double width = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_WIDTH, abort);
405  std::string filename = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_IMGFILE, abort);
406  double impatience = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_IMPATIENCE, abort);
407  std::string laneChangeModel = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_LANE_CHANGE_MODEL, abort);
408  std::string carFollowModel = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_CAR_FOLLOW_MODEL, abort);
409  int personCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, vehicleTypeID, tag, SUMO_ATTR_PERSON_CAPACITY, abort);
410  int containerCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, vehicleTypeID, tag, SUMO_ATTR_CONTAINER_CAPACITY, abort);
411  double boardingDuration = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_BOARDING_DURATION, abort);
412  double loadingDuration = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_LOADING_DURATION, abort);
413  std::string latAlignment = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_LATALIGNMENT, abort);
414  double minGapLat = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MINGAP_LAT, abort);
415  double maxSpeedLat = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MAXSPEED_LAT, abort);
416  // Continue if all parameters were sucesfully loaded
417  if (!abort) {
418  // check that all elements are valid
419  if (myViewNet->getNet()->retrieveAdditional(SUMO_TAG_VTYPE, vehicleTypeID, false) != nullptr) {
420  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + vehicleTypeID + "'.");
421  } else {
422  // save ID of last created element
423  myHierarchyInsertedAdditionals.commitElementInsertion(buildVehicleType(myViewNet, true, vehicleTypeID, accel, decel, sigma, tau, length, minGap, maxSpeed, speedFactor, speedDev, color, vClass, emissionClass, shape, width,
424  filename, impatience, laneChangeModel, carFollowModel, personCapacity, containerCapacity, boardingDuration, loadingDuration, latAlignment, minGapLat, maxSpeedLat));
425  }
426  }
427 }
428 
429 
430 void
432  bool abort = false;
433  // parse attributes of calibrator flows
434  std::string vehicleTypeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_TYPE, abort);
435  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ROUTE, abort);
436  std::string vehsPerHour = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_VEHSPERHOUR, abort);
437  std::string speed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_SPEED, abort);
438  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, "", tag, SUMO_ATTR_COLOR, abort);
439  std::string departLane = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_DEPARTLANE, abort);
440  std::string departPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_DEPARTPOS, abort);
441  std::string departSpeed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_DEPARTSPEED, abort);
442  std::string arrivalLane = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ARRIVALLANE, abort);
443  std::string arrivalPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ARRIVALPOS, abort);
444  std::string arrivalSpeed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ARRIVALSPEED, abort);
445  std::string line = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LINE, abort);
446  int personNumber = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, "", tag, SUMO_ATTR_PERSON_NUMBER, abort);
447  int containerNumber = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, "", tag, SUMO_ATTR_CONTAINER_NUMBER, abort);
448  bool reroute = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_REROUTE, abort);
449  std::string departPosLat = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_DEPARTPOS_LAT, abort);
450  std::string arrivalPosLat = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ARRIVALPOS_LAT, abort);
451  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_BEGIN, abort);
452  double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_END, abort);
453  // Continue if all parameters were sucesfully loaded
454  if (!abort) {
455  // obtain route, vehicle type and calibrator parent
457  GNEAdditional* route = myViewNet->getNet()->retrieveAdditional(SUMO_TAG_ROUTE, routeID, false);
458  GNEAdditional* vtype = myViewNet->getNet()->retrieveAdditional(SUMO_TAG_VTYPE, vehicleTypeID, false);
459  // check that all elements are valid
460  if (route == nullptr) {
461  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " cannot be created; their " + toString(SUMO_TAG_ROUTE) + " with ID = '" + routeID + "' doesn't exist");
462  abort = true;
463  } else if (vtype == nullptr) {
464  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " cannot be created; their " + toString(SUMO_TAG_VTYPE) + " with ID = '" + vehicleTypeID + "' doesn't exist");
465  abort = true;
466  } else if ((vehsPerHour.empty()) && (speed.empty())) {
467  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " cannot be created; At least parameters " + toString(SUMO_ATTR_VEHSPERHOUR) + " or " + toString(SUMO_ATTR_SPEED) + " has to be defined");
468  abort = true;
469  } else if (calibrator != nullptr) {
470  // save ID of last created element
471  myHierarchyInsertedAdditionals.commitElementInsertion(buildCalibratorFlow(myViewNet, true, calibrator, route, vtype, vehsPerHour, speed, color, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
472  line, personNumber, containerNumber, reroute, departPosLat, arrivalPosLat, begin, end));
473  }
474  }
475 }
476 
477 
478 void
481  // first check if given additional supports generic parameters
483  bool ok = true;
484  std::string key;
485  if (attrs.hasAttribute(SUMO_ATTR_KEY)) {
486  // obtain key
487  key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
488  if (key.empty()) {
489  WRITE_WARNING("Error parsing key from additional generic parameter. Key cannot be empty");
490  ok = false;
491  }
493  WRITE_WARNING("Error parsing key from additional generic parameter. Key contains invalid characters");
494  ok = false;
495  }
496  } else {
497  WRITE_WARNING("Error parsing key from additional generic parameter. Key doesn't exist");
498  ok = false;
499  }
500  // circumventing empty string test
501  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
503  WRITE_WARNING("Error parsing value from additional generic parameter. Value contains invalid characters");
504  ok = false;
505  }
506  // set parameter in last inserted additional
507  if (ok) {
508  WRITE_DEBUG("Inserting generic parameter '" + key + "|" + val + "' into additional " + myHierarchyInsertedAdditionals.getLastInsertedAdditional()->getTagStr() + ".");
510  }
511  } else {
512  WRITE_WARNING("Additionals of type '" + myHierarchyInsertedAdditionals.getLastInsertedAdditional()->getTagStr() + "' doesn't support Generic Parameters");
513  }
514  } else {
515  WRITE_WARNING("Generic Parameters has to be declared within the definition of an additional element");
516  }
517 }
518 
519 
520 void
522  bool abort = false;
523  // parse attributes of VSS
524  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
525  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
526  GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort); // deprecated
527  std::string lanesIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANES, abort);
528  Position pos = GNEAttributeCarrier::parseAttributeFromXML<Position>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
529  // Continue if all parameters were sucesfully loaded
530  if (!abort) {
531  // obtain lanes
532  std::vector<GNELane*> lanes;
533  if (GNEAttributeCarrier::canParse<std::vector<GNELane*> >(myViewNet->getNet(), lanesIDs, true)) {
534  lanes = GNEAttributeCarrier::parse<std::vector<GNELane*> >(myViewNet->getNet(), lanesIDs);
535  }
536  // check that all elements are valid
537  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
538  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
539  } else if (lanes.size() == 0) {
540  WRITE_WARNING("A Variable Speed Sign needs at least one lane.");
541  } else {
542  // save ID of last created element
544  }
545  }
546 }
547 
548 void
550  bool abort = false;
551  // Load step values
552  double time = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_TIME, abort);
553  double speed = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_SPEED, abort);
554  // Continue if all parameters were sucesfully loaded
555  if (!abort) {
556  // get Variable Speed Signal
558  // check that all parameters are valid
559  if (variableSpeedSign != nullptr) {
560  // save ID of last created element
562  }
563  }
564 }
565 
566 
567 void
569  bool abort = false;
570  // parse attributes of Rerouter
571  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
572  std::string edgesIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_EDGES, abort);
573  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
574  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort);
575  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_PROB, abort);
576  bool off = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_OFF, abort);
577  double timeThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), abort, 0);
578  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), abort, "");
579  Position pos = GNEAttributeCarrier::parseAttributeFromXML<Position>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
580  // Continue if all parameters were sucesfully loaded
581  if (!abort) {
582  // obtain edges
583  std::vector<GNEEdge*> edges;
584  if (GNEAttributeCarrier::canParse<std::vector<GNEEdge*> >(myViewNet->getNet(), edgesIDs, true)) {
585  edges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(myViewNet->getNet(), edgesIDs);
586  }
587  // check that all elements are valid
588  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
589  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
590  } else if (edges.size() == 0) {
591  WRITE_WARNING("A rerouter needs at least one Edge");
592  } else {
593  // save ID of last created element
594  myHierarchyInsertedAdditionals.commitElementInsertion(buildRerouter(myViewNet, myUndoAdditionals, id, pos, edges, probability, name, file, off, timeThreshold, vTypes, false));
595  }
596  }
597 }
598 
599 
600 void
602  bool abort = false;
603  // parse attributes of Rerouter
604  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_BEGIN, abort);
605  double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_END, abort);
606  // Continue if all parameters were sucesfully loaded
607  if (!abort) {
608  // obtain rerouter
610  // special case for load multiple intervals in the same rerouter
611  if (rerouter == nullptr) {
613  if (lastInsertedRerouterInterval) {
614  rerouter = lastInsertedRerouterInterval->getFirstAdditionalParent();
615  }
616  }
617  // check that rerouterInterval can be created
618  if (begin >= end) {
619  WRITE_WARNING(toString(tag) + " cannot be created; Attribute " + toString(SUMO_ATTR_END) + " must be greather than " + toString(SUMO_ATTR_BEGIN) + ".");
620  } else if (rerouter != nullptr) {
621  // save ID of last created element
623  }
624  }
625 }
626 
627 
628 void
630  bool abort = false;
631  // parse attributes of Rerouter
632  std::string laneID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
633  std::string allow = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ALLOW, abort);
634  std::string disallow = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_DISALLOW, abort);
635  // Continue if all parameters were sucesfully loaded
636  if (!abort) {
637  // obtain lane and rerouter interval
638  GNELane* lane = myViewNet->getNet()->retrieveLane(laneID, false, true);
640  // check that all elements are valid
641  if (lane == nullptr) {
642  WRITE_WARNING("The lane '" + laneID + "' to use within the " + toString(tag) + " is not known.");
643  } else if (rerouterInterval != nullptr) {
644  // save ID of last created element
646  }
647  }
648 }
649 
650 
651 void
653  bool abort = false;
654  // parse attributes of Rerouter
655  std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
656  std::string allow = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ALLOW, abort);
657  std::string disallow = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_DISALLOW, abort);
658  // Continue if all parameters were sucesfully loaded
659  if (!abort) {
660  // obtain edge and rerouter interval
661  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
663  // check that all elements are valid
664  if (edge == nullptr) {
665  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
666  } else if (rerouterInterval != nullptr) {
667  // save ID of last created element
669  }
670  }
671 }
672 
673 
674 void
676  bool abort = false;
677  // parse attributes of Rerouter
678  std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
679  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_PROB, abort);
680  // Continue if all parameters were sucesfully loaded
681  if (!abort) {
682  // obtain edge and rerouter interval
683  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
685  // check that all elements are valid
686  if (edge == nullptr) {
687  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
688  } else if (rerouterInterval != nullptr) {
689  // save ID of last created element
690  myHierarchyInsertedAdditionals.commitElementInsertion(builDestProbReroute(myViewNet, true, rerouterInterval, edge, probability));
691  }
692  }
693 }
694 
695 
696 void
698  bool abort = false;
699  // parse attributes of Rerouter
700  std::string parkingAreaID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
701  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_PROB, abort);
702  bool visible = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_VISIBLE, abort);
703  // Continue if all parameters were sucesfully loaded
704  if (!abort) {
705  // obtain edge and rerouter interval
706  GNEAdditional* parkingArea = myViewNet->getNet()->retrieveAdditional(SUMO_TAG_PARKING_AREA, parkingAreaID, false);
708  // check that all elements are valid
709  if (parkingArea == nullptr) {
710  WRITE_WARNING("The parkingArea '" + parkingAreaID + "' to use within the " + toString(tag) + " is not known.");
711  } else if (rerouterInterval != nullptr) {
712  // save ID of last created element
713  myHierarchyInsertedAdditionals.commitElementInsertion(builParkingAreaReroute(myViewNet, true, rerouterInterval, parkingArea, probability, visible));
714  }
715  }
716 }
717 
718 
719 void
721  bool abort = false;
722  // parse attributes of Rerouter
723  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
724  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_PROB, abort);
725  // Continue if all parameters were sucesfully loaded
726  if (!abort) {
727  // obtain rerouter interval
729  // check that all elements are valid
730  if (rerouterInterval != nullptr) {
731  // save ID of last created element
732  myHierarchyInsertedAdditionals.commitElementInsertion(buildRouteProbReroute(myViewNet, true, rerouterInterval, routeID, probability));
733  }
734  }
735 }
736 
737 
738 void
740  bool abort = false;
741  // parse attributes of bus stop
742  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
743  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
744  std::string startPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
745  std::string endPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
746  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
747  std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id, tag, SUMO_ATTR_LINES, abort);
748  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
749  // Continue if all parameters were sucesfully loaded
750  if (!abort) {
751  // get pointer to lane
752  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
753  // check that all elements are valid
754  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
755  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
756  } else if (lane == nullptr) {
757  // Write error if lane isn't valid
758  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
759  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getParentEdge().getNBEdge()->getFinalLength(), POSITION_EPS, friendlyPosition)) {
760  // Write error if position isn't valid
761  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
762  } else {
763  // save ID of last created element
764  myHierarchyInsertedAdditionals.commitElementInsertion(buildBusStop(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, lines, friendlyPosition, false));
765  }
766  }
767 }
768 
769 
770 void
772  bool abort = false;
773  // parse attributes of container stop
774  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
775  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
776  std::string startPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
777  std::string endPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
778  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
779  std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id, tag, SUMO_ATTR_LINES, abort);
780  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
781  // Continue if all parameters were sucesfully loaded
782  if (!abort) {
783  // get pointer to lane
784  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
785  // check that all elements are valid
786  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
787  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
788  } else if (lane == nullptr) {
789  // Write error if lane isn't valid
790  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
791  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getParentEdge().getNBEdge()->getFinalLength(), POSITION_EPS, friendlyPosition)) {
792  // write error if position isn't valid
793  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
794  } else {
795  // save ID of last created element
796  myHierarchyInsertedAdditionals.commitElementInsertion(buildContainerStop(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, lines, friendlyPosition, false));
797  }
798  }
799 }
800 
801 
802 void
804  bool abort = false;
805  // parse attributes of Entry
806  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LANE, abort);
807  std::string position = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_POSITION, abort);
808  std::string length = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LENGTH, abort);
809  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_FRIENDLY_POS, abort);
810  // Check if parsing of parameters was correct
811  if (!abort) {
812  double posDouble = GNEAttributeCarrier::parse<double>(position);
813  // get lane and busStop parent
814  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
816  // check that all parameters are valid
817  if (lane == nullptr) {
818  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
819  } else if (busStop == nullptr) {
820  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_BUS_STOP) + ".");
821  } else if (!checkAndFixDetectorPosition(posDouble, lane->getLaneShapeLength(), friendlyPos)) {
822  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
823  } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
824  WRITE_WARNING("Edge '" + lane->getParentEdge().getID() + "' already has an Access for busStop '" + busStop->getID() + "'");
825  } else {
826  // save ID of last created element
827  myHierarchyInsertedAdditionals.commitElementInsertion(buildAccess(myViewNet, myUndoAdditionals, busStop, lane, toString(posDouble), length, friendlyPos, false));
828  }
829  }
830 }
831 
832 
833 void
835  bool abort = false;
836  // parse attributes of charging station
837  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
838  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
839  std::string startPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
840  std::string endPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
841  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
842  double chargingPower = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_CHARGINGPOWER, abort);
843  double efficiency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_EFFICIENCY, abort);
844  bool chargeInTransit = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_CHARGEINTRANSIT, abort);
845  double chargeDelay = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_CHARGEDELAY, abort);
846  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
847  // Continue if all parameters were sucesfully loaded
848  if (!abort) {
849  // get pointer to lane
850  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
851  // check that all elements are valid
852  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
853  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
854  } else if (lane == nullptr) {
855  // Write error if lane isn't valid
856  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
857  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getParentEdge().getNBEdge()->getFinalLength(), POSITION_EPS, friendlyPosition)) {
858  // write error if position isn't valid
859  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
860  } else {
861  // save ID of last created element
862  myHierarchyInsertedAdditionals.commitElementInsertion(buildChargingStation(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition, false));
863  }
864  }
865 }
866 
867 
868 void
870  bool abort = false;
871  // parse attributes of charging station
872  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
873  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
874  std::string startPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
875  std::string endPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
876  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
877  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
878  int roadSideCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, id, tag, SUMO_ATTR_ROADSIDE_CAPACITY, abort);
879  bool onRoad = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_ONROAD, abort);
880  double width = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_WIDTH, abort);
881  std::string length = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LENGTH, abort);
882  double angle = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_ANGLE, abort);
883  // Continue if all parameters were sucesfully loaded
884  if (!abort) {
885  // get pointer to lane
886  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
887  // check that all elements are valid
888  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
889  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
890  } else if (lane == nullptr) {
891  // Write error if lane isn't valid
892  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
893  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getParentEdge().getNBEdge()->getFinalLength(), POSITION_EPS, friendlyPosition)) {
894  // write error if position isn't valid
895  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
896  } else {
897  // save ID of last created element
898  myHierarchyInsertedAdditionals.commitElementInsertion(buildParkingArea(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, friendlyPosition, roadSideCapacity, onRoad, width, length, angle, false));
899  }
900  }
901 }
902 
903 
904 void
906  bool abort = false;
907  // parse attributes of Parking Spaces
908  Position pos = GNEAttributeCarrier::parseAttributeFromXML<Position>(attrs, "", tag, SUMO_ATTR_POSITION, abort);
909  double width = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_WIDTH, abort);
910  double length = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_LENGTH, abort);
911  double angle = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_ANGLE, abort);
912  // Continue if all parameters were sucesfully loaded
913  if (!abort) {
914  // get Parking Area Parent
916  // check that Parking Area Parent exists
917  if (parkingAreaParent != nullptr) {
918  // save ID of last created element
919  myHierarchyInsertedAdditionals.commitElementInsertion(buildParkingSpace(myViewNet, myUndoAdditionals, parkingAreaParent, pos, width, length, angle, false));
920  }
921  }
922 }
923 
924 
925 void
927  bool abort = false;
928  // due there is two differents calibrators, has to be parsed in a different way
929  std::string edgeID, laneId, id;
930  SumoXMLTag typeOfCalibrator = tag;
931  // change tag depending of XML parmeters
932  if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
933  typeOfCalibrator = SUMO_TAG_CALIBRATOR;
934  id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", typeOfCalibrator, SUMO_ATTR_ID, abort);
935  edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_EDGE, abort);
936  std::string outfile = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_OUTPUT, abort);
937  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_POSITION, abort);
938  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
939  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_FREQUENCY, abort);
940  std::string routeProbe = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_ROUTEPROBE, abort);
941  // Continue if all parameters were sucesfully loaded
942  if (!abort) {
943  // get pointer and edge
944  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
945  // check that all elements are valid
946  if (myViewNet->getNet()->retrieveAdditional(typeOfCalibrator, id, false) != nullptr) {
947  WRITE_WARNING("There is another " + toString(typeOfCalibrator) + " with the same ID='" + id + "'.");
948  } else if (edge == nullptr) {
949  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(typeOfCalibrator) + " '" + id + "' is not known.");
950  } else {
951  // save ID of last created element
952  myHierarchyInsertedAdditionals.commitElementInsertion(buildCalibrator(myViewNet, myUndoAdditionals, id, edge, position, name, outfile, freq, routeProbe));
953  }
954  }
955  } else if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
956  typeOfCalibrator = SUMO_TAG_LANECALIBRATOR;
957  id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", typeOfCalibrator, SUMO_ATTR_ID, abort);
958  laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_LANE, abort);
959  std::string outfile = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_OUTPUT, abort);
960  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_POSITION, abort);
961  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
962  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_FREQUENCY, abort);
963  std::string routeProbe = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_ROUTEPROBE, abort);
964  // Continue if all parameters were sucesfully loaded
965  if (!abort) {
966  // get pointer to lane
967  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
968  // check that all elements are valid
969  if (myViewNet->getNet()->retrieveAdditional(typeOfCalibrator, id, false) != nullptr) {
970  WRITE_WARNING("There is another " + toString(typeOfCalibrator) + " with the same ID='" + id + "'.");
971  } else if (lane == nullptr) {
972  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(typeOfCalibrator) + " '" + id + "' is not known.");
973  } else {
974  // save ID of last created element
975  myHierarchyInsertedAdditionals.commitElementInsertion(buildCalibrator(myViewNet, myUndoAdditionals, id, lane, position, name, outfile, freq, routeProbe));
976  }
977  }
978  } else {
979  WRITE_WARNING("additional " + toString(tag) + " must have either a lane or an edge attribute.");
980  }
981 }
982 
983 
984 void
986  bool abort = false;
987  // parse attributes of E1
988  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
989  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
990  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
991  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
992  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort);
993  std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_VTYPES, abort);
994  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
995  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
996  // Continue if all parameters were sucesfully loaded
997  if (!abort) {
998  // get pointer to lane
999  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
1000  // check that all elements are valid
1001  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
1002  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
1003  } else if (lane == nullptr) {
1004  // Write error if lane isn't valid
1005  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
1006  } else if (!checkAndFixDetectorPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
1007  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
1008  } else {
1009  // save ID of last created element
1010  myHierarchyInsertedAdditionals.commitElementInsertion(buildDetectorE1(myViewNet, myUndoAdditionals, id, lane, position, frequency, file, vehicleTypes, name, friendlyPos, false));
1011  }
1012  }
1013 }
1014 
1015 
1016 void
1018  // Tag E2 detectors can build either E2 single lanes or E2 multilanes, depending of attribute "lanes"
1020  bool abort = false;
1021  // start parsing ID
1022  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", E2Tag, SUMO_ATTR_ID, abort);
1023  // parse attributes of E2 SingleLanes
1024  std::string laneId = (E2Tag == SUMO_TAG_E2DETECTOR)?GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, E2Tag, SUMO_ATTR_LANE, abort):"";
1025  double length = (E2Tag == SUMO_TAG_E2DETECTOR)?GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_LENGTH, abort):0;
1026  // parse attributes of E2 Multilanes
1027  std::string laneIds = (E2Tag == SUMO_TAG_E2DETECTOR_MULTILANE)?GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, E2Tag, SUMO_ATTR_LANES, abort):"";
1028  double endPos = (E2Tag == SUMO_TAG_E2DETECTOR_MULTILANE)?GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_ENDPOS, abort):0;
1029  // parse common attributes
1030  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_POSITION, abort);
1031  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_FREQUENCY, abort);
1032  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, E2Tag, SUMO_ATTR_FILE, abort);
1033  std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, E2Tag, SUMO_ATTR_VTYPES, abort);
1034  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, E2Tag, SUMO_ATTR_NAME, abort);
1035  double haltingTimeThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
1036  double haltingSpeedThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
1037  double jamDistThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, E2Tag, SUMO_ATTR_JAM_DIST_THRESHOLD, abort);
1038  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, E2Tag, SUMO_ATTR_FRIENDLY_POS, abort);
1039  // cont attribute is deprecated
1040  GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, E2Tag, SUMO_ATTR_CONT, abort);
1041  // Continue if all parameters were sucesfully loaded
1042  if (!abort) {
1043  // check if at leas lane or laneIDS are defined
1044  if(laneId.empty() && laneIds.empty()) {
1045  WRITE_WARNING("A " + toString(E2Tag) + " needs at least a lane or a list of lanes.");
1046  } else {
1047  // get pointer to lane
1048  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
1049  // get list of lanes
1050  std::vector<GNELane*> lanes;
1051  bool laneConsecutives = true;
1052  if(GNEAttributeCarrier::canParse<std::vector<GNELane*> >(myViewNet->getNet(), laneIds, false)) {
1053  lanes = GNEAttributeCarrier::parse<std::vector<GNELane*> >(myViewNet->getNet(), laneIds);
1054  // check if lanes are consecutives
1055  laneConsecutives = GNEAttributeCarrier::lanesConsecutives(lanes);
1056  }
1057  // check that all elements are valid
1058  if (myViewNet->getNet()->retrieveAdditional(E2Tag, id, false) != nullptr) {
1059  // write error if neither lane nor lane aren't defined
1060  WRITE_WARNING("There is another " + toString(E2Tag) + " with the same ID='" + id + "'.");
1061  } else if (attrs.hasAttribute(SUMO_ATTR_LANE) && (lane == nullptr)) {
1062  // Write error if lane isn't valid
1063  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(E2Tag) + " '" + id + "' is not known.");
1064  } else if (attrs.hasAttribute(SUMO_ATTR_LANES) && lanes.empty()) {
1065  // Write error if lane isn't valid
1066  WRITE_WARNING("The list of lanes cannot be empty.");
1067  } else if (attrs.hasAttribute(SUMO_ATTR_LANES) && lanes.empty()) {
1068  // Write error if lane isn't valid
1069  WRITE_WARNING("The list of lanes '" + laneIds + "' to use within the " + toString(E2Tag) + " '" + id + "' isn't valid.");
1070  } else if (!lanes.empty() && !laneConsecutives) {
1071  WRITE_WARNING("The lanes '" + laneIds + "' to use within the " + toString(E2Tag) + " '" + id + "' aren't consecutives.");
1072  } else if (lane && !fixE2DetectorPosition(position, length, lane->getParentEdge().getNBEdge()->getFinalLength(), friendlyPos)) {
1073  WRITE_WARNING("Invalid position for " + toString(E2Tag) + " with ID = '" + id + "'.");
1074  } else if (!lanes.empty() && !fixE2DetectorPosition(position, length, lanes.front()->getParentEdge().getNBEdge()->getFinalLength(), friendlyPos)) {
1075  WRITE_WARNING("Invalid position for " + toString(E2Tag) + " with ID = '" + id + "'.");
1076  } else if (!lanes.empty() && !fixE2DetectorPosition(endPos, length, lanes.back()->getParentEdge().getNBEdge()->getFinalLength(), friendlyPos)) {
1077  WRITE_WARNING("Invalid end position for " + toString(E2Tag) + " with ID = '" + id + "'.");
1078  } else if (lane) {
1079  // save ID of last created element
1080  myHierarchyInsertedAdditionals.commitElementInsertion(buildSingleLaneDetectorE2(myViewNet, myUndoAdditionals, id, lane, position, length, frequency, file, vehicleTypes, name, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, friendlyPos, false));
1081  } else {
1082  // save ID of last created element
1083  myHierarchyInsertedAdditionals.commitElementInsertion(buildMultiLaneDetectorE2(myViewNet, myUndoAdditionals, id, lanes, position, endPos, frequency, file, vehicleTypes, name, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, friendlyPos, false));
1084  }
1085  }
1086  }
1087 }
1088 
1089 
1090 void
1092  bool abort = false;
1093  // parse attributes of E3
1094  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
1095  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
1096  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort);
1097  std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_VTYPES, abort);
1098  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
1099  double haltingTimeThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
1100  double haltingSpeedThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
1101  Position pos = GNEAttributeCarrier::parseAttributeFromXML<Position>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
1102  // Continue if all parameters were sucesfully loaded
1103  if (!abort) {
1104  // check that all elements are valid
1105  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
1106  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
1107  } else {
1108  // save ID of last created element
1109  myHierarchyInsertedAdditionals.commitElementInsertion(buildDetectorE3(myViewNet, myUndoAdditionals, id, pos, frequency, file, vehicleTypes, name, haltingTimeThreshold, haltingSpeedThreshold, false));
1110  }
1111  }
1112 }
1113 
1114 
1115 void
1117  bool abort = false;
1118  // parse attributes of Entry
1119  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LANE, abort);
1120  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_POSITION, abort);
1121  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_FRIENDLY_POS, abort);
1122  // Check if parsing of parameters was correct
1123  if (!abort) {
1124  // get lane and E3 parent
1125  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
1127  // check that all parameters are valid
1128  if (lane == nullptr) {
1129  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
1130  } else if (!checkAndFixDetectorPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
1131  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
1132  } else if (E3Parent) {
1133  // save ID of last created element
1135  }
1136  }
1137 }
1138 
1139 
1140 void
1142  bool abort = false;
1143  // parse attributes of Exit
1144  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LANE, abort);
1145  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_POSITION, abort);
1146  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_FRIENDLY_POS, abort);
1147  // Check if parsing of parameters was correct
1148  if (!abort) {
1149  // get lane and E3 parent
1150  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
1152  // check that all parameters are valid
1153  if (lane == nullptr) {
1154  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
1155  } else if (!checkAndFixDetectorPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
1156  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
1157  } else if (E3Parent) {
1158  // save ID of last created element
1160  }
1161  }
1162 }
1163 
1164 
1165 void
1167  bool abort = false;
1168  // parse attributes of E1Instant
1169  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
1170  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
1171  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
1172  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort);
1173  std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_VTYPES, abort);
1174  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort);
1175  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
1176  // Continue if all parameters were sucesfully loaded
1177  if (!abort) {
1178  // get pointer to lane
1179  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
1180  // check that all elements are valid
1181  if (myViewNet->getNet()->retrieveAdditional(tag, id, false) != nullptr) {
1182  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
1183  } else if (lane == nullptr) {
1184  // Write error if lane isn't valid
1185  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
1186  } else if (!checkAndFixDetectorPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
1187  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
1188  } else {
1189  // save ID of last created element
1190  myHierarchyInsertedAdditionals.commitElementInsertion(buildDetectorE1Instant(myViewNet, myUndoAdditionals, id, lane, position, file, vehicleTypes, name, friendlyPos, false));
1191  }
1192  }
1193 }
1194 
1195 
1197 GNEAdditionalHandler::buildAdditional(GNEViewNet* viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map<SumoXMLAttr, std::string> values) {
1198  // create additional depending of the tag
1199  switch (tag) {
1200  case SUMO_TAG_BUS_STOP: {
1201  // obtain specify attributes of busStop
1202  std::string id = values[SUMO_ATTR_ID];
1203  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1204  std::string startPos = values[SUMO_ATTR_STARTPOS];
1205  std::string endPos = values[SUMO_ATTR_ENDPOS];
1206  std::string name = values[SUMO_ATTR_NAME];
1207  std::vector<std::string> lines = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LINES]);
1208  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1209  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1210  // Build busStop
1211  if (lane) {
1212  return buildBusStop(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, lines, friendlyPos, blockMovement);
1213  } else {
1214  return nullptr;
1215  }
1216  }
1217  case SUMO_TAG_ACCESS: {
1218  // obtain specify attributes of detector E2
1219  std::string id = values[SUMO_ATTR_ID];
1220  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1221  GNEAdditional* busStop = viewNet->getNet()->retrieveAdditional(SUMO_TAG_BUS_STOP, values[GNE_ATTR_PARENT], false);
1222  std::string pos = values[SUMO_ATTR_POSITION];
1223  std::string length = values[SUMO_ATTR_LENGTH];
1224  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1225  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1226  // Build detector E2
1227  if (lane && busStop) {
1228  if (accessCanBeCreated(busStop, lane->getParentEdge())) {
1229  return buildAccess(viewNet, allowUndoRedo, busStop, lane, pos, length, friendlyPos, blockMovement);
1230  } else {
1231  WRITE_WARNING(toString(SUMO_TAG_BUS_STOP) + "'" + busStop->getID() + "' already owns a Acces in the edge '" + lane->getParentEdge().getID() + "'");
1232  return nullptr;
1233  }
1234  } else {
1235  return nullptr;
1236  }
1237  }
1238  case SUMO_TAG_CONTAINER_STOP: {
1239  // obtain specify attributes of containerStop
1240  std::string id = values[SUMO_ATTR_ID];
1241  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1242  std::string startPos = values[SUMO_ATTR_STARTPOS];
1243  std::string endPos = values[SUMO_ATTR_ENDPOS];
1244  std::string name = values[SUMO_ATTR_NAME];
1245  std::vector<std::string> lines = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LINES]);
1246  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1247  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1248  // Build containerStop
1249  if (lane) {
1250  return buildContainerStop(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, lines, friendlyPos, blockMovement);
1251  } else {
1252  return nullptr;
1253  }
1254  }
1256  // obtain specify attributes of chargingStation
1257  std::string id = values[SUMO_ATTR_ID];
1258  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1259  std::string startPos = values[SUMO_ATTR_STARTPOS];
1260  std::string endPos = values[SUMO_ATTR_ENDPOS];
1261  std::string name = values[SUMO_ATTR_NAME];
1262  double chargingPower = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_CHARGINGPOWER]);
1263  double efficiency = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_EFFICIENCY]);
1264  bool chargeInTransit = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CHARGEINTRANSIT]);
1265  double chargeDelay = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_CHARGEDELAY]);
1266  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1267  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1268  // Build chargingStation
1269  if (lane) {
1270  return buildChargingStation(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPos, blockMovement);
1271  } else {
1272  return nullptr;
1273  }
1274  }
1275  case SUMO_TAG_PARKING_AREA: {
1276  // obtain specify attributes of Parking Area
1277  std::string id = values[SUMO_ATTR_ID];
1278  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1279  std::string startPos = values[SUMO_ATTR_STARTPOS];
1280  std::string endPos = values[SUMO_ATTR_ENDPOS];
1281  std::string name = values[SUMO_ATTR_NAME];
1282  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1283  int roadSideCapacity = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_ROADSIDE_CAPACITY]);
1284  bool onRoad = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_ONROAD]);
1285  double width = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_WIDTH]);
1286  std::string lenght = values[SUMO_ATTR_LENGTH];
1287  double angle = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ANGLE]);
1288  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1289  // Build Parking Area
1290  if (lane) {
1291  return buildParkingArea(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, friendlyPos, roadSideCapacity, onRoad, width, lenght, angle, blockMovement);
1292  } else {
1293  return nullptr;
1294  }
1295  }
1296  case SUMO_TAG_PARKING_SPACE: {
1297  // obtain specify attributes of Parking Space
1298  Position pos = GNEAttributeCarrier::parse<Position>(values[SUMO_ATTR_POSITION]);
1299  double width = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_WIDTH]);
1300  double lenght = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_LENGTH]);
1301  double angle = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ANGLE]);
1302  GNEAdditional* parkingArea = viewNet->getNet()->retrieveAdditional(SUMO_TAG_PARKING_AREA, values[GNE_ATTR_PARENT], false);
1303  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1304  // Build Parking
1305  return buildParkingSpace(viewNet, allowUndoRedo, parkingArea, pos, width, lenght, angle, blockMovement);
1306  }
1307  case SUMO_TAG_E1DETECTOR: {
1308  // obtain specify attributes of detector E1
1309  std::string id = values[SUMO_ATTR_ID];
1310  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1311  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1312  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1313  std::string filename = values[SUMO_ATTR_FILE];
1314  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
1315  std::string name = values[SUMO_ATTR_NAME];
1316  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1317  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1318  // Build detector E1
1319  if (lane) {
1320  return buildDetectorE1(viewNet, allowUndoRedo, id, lane, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement);
1321  } else {
1322  return nullptr;
1323  }
1324  }
1325  case SUMO_TAG_E2DETECTOR: {
1326  // obtain specify attributes of detector E2
1327  std::string id = values[SUMO_ATTR_ID];
1328  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1329  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1330  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1331  double length = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_LENGTH]);
1332  std::string filename = values[SUMO_ATTR_FILE];
1333  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
1334  std::string name = values[SUMO_ATTR_NAME];
1335  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
1336  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
1337  double jamThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_JAM_DIST_THRESHOLD]);
1338  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1339  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1340  // Build detector E2
1341  if (lane) {
1342  return buildSingleLaneDetectorE2(viewNet, allowUndoRedo, id, lane, pos, length, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold, friendlyPos, blockMovement);
1343  } else {
1344  return nullptr;
1345  }
1346  }
1348  // obtain specify attributes of detector E2
1349  std::string id = values[SUMO_ATTR_ID];
1350  std::vector<GNELane*> lanes = GNEAttributeCarrier::parse<std::vector<GNELane*> >(viewNet->getNet(), values[SUMO_ATTR_LANES]);
1351  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1352  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
1353  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1354  std::string filename = values[SUMO_ATTR_FILE];
1355  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
1356  std::string name = values[SUMO_ATTR_NAME];
1357  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
1358  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
1359  double jamThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_JAM_DIST_THRESHOLD]);
1360  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1361  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1362  // Build detector E2
1363  if (lanes.size() > 0) {
1364  return buildMultiLaneDetectorE2(viewNet, allowUndoRedo, id, lanes, pos, endPos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold, friendlyPos, blockMovement);
1365  } else {
1366  return nullptr;
1367  }
1368  }
1369  case SUMO_TAG_E3DETECTOR: {
1370  // obtain specify attributes of detector E3
1371  std::string id = values[SUMO_ATTR_ID];
1372  Position pos = GNEAttributeCarrier::parse<Position>(values[SUMO_ATTR_POSITION]);
1373  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1374  std::string filename = values[SUMO_ATTR_FILE];
1375  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
1376  std::string name = values[SUMO_ATTR_NAME];
1377  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
1378  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
1379  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1380  // Build detector E3
1381  return buildDetectorE3(viewNet, allowUndoRedo, id, pos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, blockMovement);
1382  }
1383  case SUMO_TAG_DET_ENTRY: {
1384  // obtain specify attributes of detector Entry
1385  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1386  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1387  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1388  GNEAdditional* E3 = viewNet->getNet()->retrieveAdditional(SUMO_TAG_E3DETECTOR, values[GNE_ATTR_PARENT], false);
1389  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1390  // Build detector Entry
1391  if (lane && E3) {
1392  return buildDetectorEntry(viewNet, allowUndoRedo, E3, lane, pos, friendlyPos, blockMovement);
1393  } else {
1394  return nullptr;
1395  }
1396  }
1397  case SUMO_TAG_DET_EXIT: {
1398  // obtain specify attributes of Detector Exit
1399  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1400  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1401  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1402  GNEAdditional* E3 = viewNet->getNet()->retrieveAdditional(SUMO_TAG_E3DETECTOR, values[GNE_ATTR_PARENT], false);
1403  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1404  // Build detector Exit
1405  if (lane && E3) {
1406  return buildDetectorExit(viewNet, allowUndoRedo, E3, lane, pos, friendlyPos, blockMovement);
1407  } else {
1408  return nullptr;
1409  }
1410  }
1412  // obtain specify attributes of detector E1Instant
1413  std::string id = values[SUMO_ATTR_ID];
1414  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1415  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1416  std::string filename = values[SUMO_ATTR_FILE];
1417  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
1418  std::string name = values[SUMO_ATTR_NAME];
1419  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
1420  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1421  // Build detector E1Instant
1422  if (lane) {
1423  return buildDetectorE1Instant(viewNet, allowUndoRedo, id, lane, pos, filename, vehicleTypes, name, friendlyPos, blockMovement);
1424  } else {
1425  return nullptr;
1426  }
1427  }
1428  case SUMO_TAG_VSS: {
1429  // obtain specify attributes of variable speed signal
1430  std::string id = values[SUMO_ATTR_ID];
1431  Position pos = GNEAttributeCarrier::parse<Position>(values[SUMO_ATTR_POSITION]);
1432  std::vector<GNELane*> lanes = GNEAttributeCarrier::parse<std::vector<GNELane*> >(viewNet->getNet(), values[SUMO_ATTR_LANES]);
1433  std::string name = values[SUMO_ATTR_NAME];
1434  // get rest of parameters
1435  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1436  // build VSS
1437  return buildVariableSpeedSign(viewNet, allowUndoRedo, id, pos, lanes, name, blockMovement);
1438  }
1439  case SUMO_TAG_CALIBRATOR: {
1440  // obtain specify attributes of calibrator
1441  std::string id = values[SUMO_ATTR_ID];
1442  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1443  // get rest of parameters
1444  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1445  std::string name = values[SUMO_ATTR_NAME];
1446  std::string outfile = values[SUMO_ATTR_OUTPUT];
1447  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1448  std::string routeProbe = values[SUMO_ATTR_ROUTEPROBE];
1449  // Build calibrator edge
1450  if (edge) {
1451  return buildCalibrator(viewNet, allowUndoRedo, id, edge, pos, name, outfile, freq, routeProbe);
1452  } else {
1453  return nullptr;
1454  }
1455  }
1456  case SUMO_TAG_LANECALIBRATOR: {
1457  // obtain specify attributes of calibrator
1458  std::string id = values[SUMO_ATTR_ID];
1459  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1460  // get rest of parameters
1461  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1462  std::string name = values[SUMO_ATTR_NAME];
1463  std::string outfile = values[SUMO_ATTR_OUTPUT];
1464  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1465  std::string routeProbe = values[SUMO_ATTR_ROUTEPROBE];
1466  // Build calibrator lane
1467  if (lane) {
1468  return buildCalibrator(viewNet, allowUndoRedo, id, lane, pos, name, outfile, freq, routeProbe);
1469  } else {
1470  return nullptr;
1471  }
1472  }
1473  case SUMO_TAG_REROUTER: {
1474  // obtain specify attributes of rerouter
1475  std::string id = values[SUMO_ATTR_ID];
1476  Position pos = GNEAttributeCarrier::parse<Position>(values[SUMO_ATTR_POSITION]);
1477  std::vector<GNEEdge*> edges = GNEAttributeCarrier::parse<std::vector<GNEEdge*> >(viewNet->getNet(), values[SUMO_ATTR_EDGES]);
1478  // Get rest of parameters
1479  bool off = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_OFF]);
1480  double prob = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_PROB]);
1481  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
1482  const std::string vTypes = values[SUMO_ATTR_VTYPES];
1483  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1484  std::string name = values[SUMO_ATTR_NAME];
1485  std::string file = values[SUMO_ATTR_FILE];
1486  // Build rerouter
1487  return buildRerouter(viewNet, allowUndoRedo, id, pos, edges, prob, name, file, off, timeThreshold, vTypes, blockMovement);
1488  }
1489  case SUMO_TAG_ROUTEPROBE: {
1490  // obtain specify attributes of RouteProbe
1491  std::string id = values[SUMO_ATTR_ID];
1492  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1493  std::string freq = values[SUMO_ATTR_FREQUENCY];
1494  std::string name = values[SUMO_ATTR_NAME];
1495  std::string filename = values[SUMO_ATTR_FILE];
1496  double begin = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_BEGIN]);
1497  // Build RouteProbe
1498  if (edge) {
1499  return buildRouteProbe(viewNet, allowUndoRedo, id, edge, freq, name, filename, begin);
1500  } else {
1501  return nullptr;
1502  }
1503  }
1504  case SUMO_TAG_VAPORIZER: {
1505  // obtain specify attributes of vaporizer
1506  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1507  double begin = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_BEGIN]);
1508  double end = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_END]);
1509  std::string name = values[SUMO_ATTR_NAME];
1510  // Build Vaporizer
1511  if (edge) {
1512  if (begin > end) {
1513  WRITE_WARNING("Time interval of " + toString(tag) + " isn't valid. Attribute '" + toString(SUMO_ATTR_BEGIN) + "' is greater than attribute '" + toString(SUMO_ATTR_END) + "'.");
1514  } else if (viewNet->getNet()->retrieveAdditional(tag, edge->getID(), false) == nullptr) {
1515  return buildVaporizer(viewNet, allowUndoRedo, edge, begin, end, name);
1516  } else {
1517  WRITE_WARNING("There is already a " + toString(tag) + " in the edge '" + edge->getID() + "'.");
1518  }
1519  }
1520  return nullptr;
1521  }
1522  case SUMO_TAG_TAZ: {
1523  // obtain specify attributes of vaporizer
1524  std::string id = values[SUMO_ATTR_ID];
1525  PositionVector shape = GNEAttributeCarrier::parse<PositionVector>(values[SUMO_ATTR_SHAPE]);
1526  RGBColor color = GNEAttributeCarrier::parse<RGBColor>(values[SUMO_ATTR_COLOR]);
1527  std::vector<std::string> edgeIDs = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_EDGES]);
1528  bool blockMovement = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
1529  // check if all edge IDs are valid
1530  std::vector<GNEEdge*> edges;
1531  for (auto i : edgeIDs) {
1532  GNEEdge* edge = viewNet->getNet()->retrieveEdge(i, false);
1533  if (edge == nullptr) {
1534  WRITE_WARNING("Invalid " + toString(SUMO_TAG_EDGE) + " with ID = '" + i + "'.");
1535  return nullptr;
1536  } else {
1537  edges.push_back(edge);
1538  }
1539  }
1540  // Build TAZ
1541  return buildTAZ(viewNet, allowUndoRedo, id, shape, color, edges, blockMovement);
1542  }
1543  default:
1544  return nullptr;
1545  }
1546 }
1547 
1548 
1550 GNEAdditionalHandler::buildBusStop(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, const std::string& startPos, const std::string& endPos, const std::string& name, const std::vector<std::string>& lines, bool friendlyPosition, bool blockMovement) {
1551  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_BUS_STOP, id, false) == nullptr) {
1552  GNEBusStop* busStop = new GNEBusStop(id, lane, viewNet, startPos, endPos, name, lines, friendlyPosition, blockMovement);
1553  if (allowUndoRedo) {
1554  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_BUS_STOP));
1555  viewNet->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
1556  viewNet->getUndoList()->p_end();
1557  } else {
1558  viewNet->getNet()->insertAdditional(busStop);
1559  lane->addAdditionalChild(busStop);
1560  busStop->incRef("buildBusStop");
1561  }
1562  return busStop;
1563  } else {
1564  throw ProcessError("Could not build " + toString(SUMO_TAG_BUS_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1565  }
1566 }
1567 
1568 
1570 GNEAdditionalHandler::buildAccess(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* busStop, GNELane* lane, const std::string& pos, const std::string& length, bool friendlyPos, bool blockMovement) {
1571  // Check if busStop parent and lane is correct
1572  if (lane == nullptr) {
1573  throw ProcessError("Could not build " + toString(SUMO_TAG_ACCESS) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1574  } else if (busStop == nullptr) {
1575  throw ProcessError("Could not build " + toString(SUMO_TAG_ACCESS) + " in netedit; " + toString(SUMO_TAG_BUS_STOP) + " parent doesn't exist.");
1576  } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
1577  throw ProcessError("Could not build " + toString(SUMO_TAG_ACCESS) + " in netedit; " + toString(SUMO_TAG_BUS_STOP) + " parent already owns a Acces in the edge '" + lane->getParentEdge().getID() + "'");
1578  } else {
1579  GNEAccess* access = new GNEAccess(busStop, lane, viewNet, pos, length, friendlyPos, blockMovement);
1580  if (allowUndoRedo) {
1581  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_ACCESS));
1582  viewNet->getUndoList()->add(new GNEChange_Additional(access, true), true);
1583  viewNet->getUndoList()->p_end();
1584  } else {
1585  viewNet->getNet()->insertAdditional(access);
1586  lane->addAdditionalChild(access);
1587  busStop->addAdditionalChild(access);
1588  access->incRef("buildAccess");
1589  }
1590  return access;
1591  }
1592 }
1593 
1594 
1596 GNEAdditionalHandler::buildContainerStop(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, const std::string& startPos, const std::string& endPos, const std::string& name, const std::vector<std::string>& lines, bool friendlyPosition, bool blockMovement) {
1597  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_CONTAINER_STOP, id, false) == nullptr) {
1598  GNEContainerStop* containerStop = new GNEContainerStop(id, lane, viewNet, startPos, endPos, name, lines, friendlyPosition, blockMovement);
1599  if (allowUndoRedo) {
1600  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CONTAINER_STOP));
1601  viewNet->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
1602  viewNet->getUndoList()->p_end();
1603  } else {
1604  viewNet->getNet()->insertAdditional(containerStop);
1605  lane->addAdditionalChild(containerStop);
1606  containerStop->incRef("buildContainerStop");
1607  }
1608  return containerStop;
1609  } else {
1610  throw ProcessError("Could not build " + toString(SUMO_TAG_CONTAINER_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1611  }
1612 }
1613 
1614 
1616 GNEAdditionalHandler::buildChargingStation(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, const std::string& startPos, const std::string& endPos, const std::string& name,
1617  double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay, bool friendlyPosition, bool blockMovement) {
1618  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_CHARGING_STATION, id, false) == nullptr) {
1619  GNEChargingStation* chargingStation = new GNEChargingStation(id, lane, viewNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition, blockMovement);
1620  if (allowUndoRedo) {
1621  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CHARGING_STATION));
1622  viewNet->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
1623  viewNet->getUndoList()->p_end();
1624  } else {
1625  viewNet->getNet()->insertAdditional(chargingStation);
1626  lane->addAdditionalChild(chargingStation);
1627  chargingStation->incRef("buildChargingStation");
1628  }
1629  return chargingStation;
1630  } else {
1631  throw ProcessError("Could not build " + toString(SUMO_TAG_CHARGING_STATION) + " with ID '" + id + "' in netedit; probably declared twice.");
1632  }
1633 }
1634 
1635 
1637 GNEAdditionalHandler::buildParkingArea(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, const std::string& startPos, const std::string& endPos, const std::string& name,
1638  bool friendlyPosition, int roadSideCapacity, bool onRoad, double width, const std::string& length, double angle, bool blockMovement) {
1639  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_PARKING_AREA, id, false) == nullptr) {
1640  GNEParkingArea* parkingArea = new GNEParkingArea(id, lane, viewNet, startPos, endPos, name, friendlyPosition, roadSideCapacity, onRoad, width, length, angle, blockMovement);
1641  if (allowUndoRedo) {
1642  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_PARKING_AREA));
1643  viewNet->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
1644  viewNet->getUndoList()->p_end();
1645  } else {
1646  viewNet->getNet()->insertAdditional(parkingArea);
1647  lane->addAdditionalChild(parkingArea);
1648  parkingArea->incRef("buildParkingArea");
1649  }
1650  return parkingArea;
1651  } else {
1652  throw ProcessError("Could not build " + toString(SUMO_TAG_PARKING_AREA) + " with ID '" + id + "' in netedit; probably declared twice.");
1653  }
1654 }
1655 
1656 
1658 GNEAdditionalHandler::buildParkingSpace(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* parkingAreaParent, Position pos, double width, double length, double angle, bool blockMovement) {
1659  GNEParkingSpace* parkingSpace = new GNEParkingSpace(viewNet, parkingAreaParent, pos, width, length, angle, blockMovement);
1660  if (allowUndoRedo) {
1661  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_PARKING_SPACE));
1662  viewNet->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
1663  viewNet->getUndoList()->p_end();
1664  } else {
1665  viewNet->getNet()->insertAdditional(parkingSpace);
1666  parkingAreaParent->addAdditionalChild(parkingSpace);
1667  parkingSpace->incRef("buildParkingSpace");
1668  }
1669  return parkingSpace;
1670 }
1671 
1672 
1674 GNEAdditionalHandler::buildDetectorE1(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double freq, const std::string& filename, const std::string& vehicleTypes, const std::string& name, bool friendlyPos, bool blockMovement) {
1675  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_E1DETECTOR, id, false) == nullptr) {
1676  GNEDetectorE1* detectorE1 = new GNEDetectorE1(id, lane, viewNet, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement);
1677  if (allowUndoRedo) {
1678  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E1DETECTOR));
1679  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
1680  viewNet->getUndoList()->p_end();
1681  } else {
1682  viewNet->getNet()->insertAdditional(detectorE1);
1683  lane->addAdditionalChild(detectorE1);
1684  detectorE1->incRef("buildDetectorE1");
1685  }
1686  return detectorE1;
1687  } else {
1688  throw ProcessError("Could not build " + toString(SUMO_TAG_E1DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1689  }
1690 }
1691 
1692 
1694 GNEAdditionalHandler::buildSingleLaneDetectorE2(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double length, double freq, const std::string& filename,
1695  const std::string& vehicleTypes, const std::string& name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) {
1696  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_E2DETECTOR, id, false) == nullptr) {
1697  GNEDetectorE2* detectorE2 = new GNEDetectorE2(id, lane, viewNet, pos, length, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold, friendlyPos, blockMovement);
1698  if (allowUndoRedo) {
1699  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E2DETECTOR));
1700  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
1701  viewNet->getUndoList()->p_end();
1702  } else {
1703  viewNet->getNet()->insertAdditional(detectorE2);
1704  lane->addAdditionalChild(detectorE2);
1705  detectorE2->incRef("buildDetectorE2");
1706  }
1707  return detectorE2;
1708  } else {
1709  throw ProcessError("Could not build " + toString(SUMO_TAG_E2DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1710  }
1711 }
1712 
1713 
1715 GNEAdditionalHandler::buildMultiLaneDetectorE2(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, const std::vector<GNELane*> &lanes, double pos, double endPos, double freq, const std::string& filename,
1716  const std::string& vehicleTypes, const std::string& name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) {
1717  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_E2DETECTOR_MULTILANE, id, false) == nullptr) {
1718  GNEDetectorE2* detectorE2 = new GNEDetectorE2(id, lanes, viewNet, pos, endPos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold, friendlyPos, blockMovement);
1719  if (allowUndoRedo) {
1721  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
1722  viewNet->getUndoList()->p_end();
1723  } else {
1724  viewNet->getNet()->insertAdditional(detectorE2);
1725  for (auto i : lanes) {
1726  i->addAdditionalChild(detectorE2);
1727  }
1728  detectorE2->incRef("buildDetectorE2Multilane");
1729  }
1730  // check E2 integrity
1731  detectorE2->checkE2MultilaneIntegrity();
1732  return detectorE2;
1733  } else {
1734  throw ProcessError("Could not build " + toString(SUMO_TAG_E2DETECTOR_MULTILANE) + " with ID '" + id + "' in netedit; probably declared twice.");
1735  }
1736 }
1737 
1738 
1740 GNEAdditionalHandler::buildDetectorE3(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, double freq, const std::string& filename, const std::string& vehicleTypes,
1741  const std::string& name, const double timeThreshold, double speedThreshold, bool blockMovement) {
1742  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_E3DETECTOR, id, false) == nullptr) {
1743  GNEDetectorE3* detectorE3 = new GNEDetectorE3(id, viewNet, pos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, blockMovement);
1744  if (allowUndoRedo) {
1745  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
1746  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE3, true), true);
1747  viewNet->getUndoList()->p_end();
1748  } else {
1749  viewNet->getNet()->insertAdditional(detectorE3);
1750  detectorE3->incRef("buildDetectorE3");
1751  }
1752  return detectorE3;
1753  } else {
1754  throw ProcessError("Could not build " + toString(SUMO_TAG_E3DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1755  }
1756 }
1757 
1758 
1760 GNEAdditionalHandler::buildDetectorEntry(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* E3Parent, GNELane* lane, double pos, bool friendlyPos, bool blockMovement) {
1761  // Check if Detector E3 parent and lane is correct
1762  if (lane == nullptr) {
1763  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1764  } else if (E3Parent == nullptr) {
1765  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
1766  } else {
1767  GNEDetectorEntry* entry = new GNEDetectorEntry(viewNet, E3Parent, lane, pos, friendlyPos, blockMovement);
1768  if (allowUndoRedo) {
1769  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_ENTRY));
1770  viewNet->getUndoList()->add(new GNEChange_Additional(entry, true), true);
1771  viewNet->getUndoList()->p_end();
1772  } else {
1773  viewNet->getNet()->insertAdditional(entry);
1774  lane->addAdditionalChild(entry);
1775  E3Parent->addAdditionalChild(entry);
1776  entry->incRef("buildDetectorEntry");
1777  }
1778  return entry;
1779  }
1780 }
1781 
1782 
1784 GNEAdditionalHandler::buildDetectorExit(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* E3Parent, GNELane* lane, double pos, bool friendlyPos, bool blockMovement) {
1785  // Check if Detector E3 parent and lane is correct
1786  if (lane == nullptr) {
1787  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1788  } else if (E3Parent == nullptr) {
1789  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
1790  } else {
1791  GNEDetectorExit* exit = new GNEDetectorExit(viewNet, E3Parent, lane, pos, friendlyPos, blockMovement);
1792  if (allowUndoRedo) {
1793  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_EXIT));
1794  viewNet->getUndoList()->add(new GNEChange_Additional(exit, true), true);
1795  viewNet->getUndoList()->p_end();
1796  } else {
1797  viewNet->getNet()->insertAdditional(exit);
1798  lane->addAdditionalChild(exit);
1799  E3Parent->addAdditionalChild(exit);
1800  exit->incRef("buildDetectorExit");
1801  }
1802  return exit;
1803  }
1804 }
1805 
1806 
1808 GNEAdditionalHandler::buildDetectorE1Instant(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, const std::string& filename, const std::string& vehicleTypes, const std::string& name, bool friendlyPos, bool blockMovement) {
1809  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_INSTANT_INDUCTION_LOOP, id, false) == nullptr) {
1810  GNEDetectorE1Instant* detectorE1Instant = new GNEDetectorE1Instant(id, lane, viewNet, pos, filename, vehicleTypes, name, friendlyPos, blockMovement);
1811  if (allowUndoRedo) {
1813  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
1814  viewNet->getUndoList()->p_end();
1815  } else {
1816  viewNet->getNet()->insertAdditional(detectorE1Instant);
1817  lane->addAdditionalChild(detectorE1Instant);
1818  detectorE1Instant->incRef("buildDetectorE1Instant");
1819  }
1820  return detectorE1Instant;
1821  } else {
1822  throw ProcessError("Could not build " + toString(SUMO_TAG_INSTANT_INDUCTION_LOOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1823  }
1824 }
1825 
1826 
1828 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, const std::string& name, const std::string& outfile, const double freq, const std::string& routeprobe) {
1829  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_CALIBRATOR, id, false) == nullptr) {
1830  GNECalibrator* calibrator = new GNECalibrator(id, viewNet, lane, pos, freq, name, outfile, routeprobe);
1831  if (allowUndoRedo) {
1832  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
1833  viewNet->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
1834  viewNet->getUndoList()->p_end();
1835  // center after creation
1836  viewNet->centerTo(calibrator->getGlID(), false);
1837  } else {
1838  viewNet->getNet()->insertAdditional(calibrator);
1839  lane->addAdditionalChild(calibrator);
1840  calibrator->incRef("buildCalibrator");
1841  }
1842  return calibrator;
1843  } else {
1844  throw ProcessError("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1845  }
1846 }
1847 
1848 
1850 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNEEdge* edge, double pos, const std::string& name, const std::string& outfile, const double freq, const std::string& routeprobe) {
1851  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_CALIBRATOR, id, false) == nullptr) {
1852  GNECalibrator* calibrator = new GNECalibrator(id, viewNet, edge, pos, freq, name, outfile, routeprobe);
1853  if (allowUndoRedo) {
1854  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
1855  viewNet->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
1856  viewNet->getUndoList()->p_end();
1857  // center after creation
1858  viewNet->centerTo(calibrator->getGlID(), false);
1859  } else {
1860  viewNet->getNet()->insertAdditional(calibrator);
1861  edge->addAdditionalChild(calibrator);
1862  calibrator->incRef("buildCalibrator");
1863  }
1864  return calibrator;
1865  } else {
1866  throw ProcessError("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1867  }
1868 }
1869 
1870 
1872 GNEAdditionalHandler::buildCalibratorRoute(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& routeID, const std::vector<GNEEdge*>& edges, const RGBColor& color) {
1873  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_ROUTE, routeID, false) == nullptr) {
1874  // create route and add it to calibrator parent
1875  GNECalibratorRoute* route = new GNECalibratorRoute(viewNet, routeID, edges, color);
1876  if (allowUndoRedo) {
1877  viewNet->getUndoList()->p_begin("add " + route->getTagStr());
1878  viewNet->getUndoList()->add(new GNEChange_Additional(route, true), true);
1879  viewNet->getUndoList()->p_end();
1880  } else {
1881  viewNet->getNet()->insertAdditional(route);
1882  route->incRef("buildCalibratorRoute");
1883  }
1884  return route;
1885  } else {
1886  throw ProcessError("Could not build " + toString(SUMO_TAG_ROUTE) + " with ID '" + routeID + "' in netedit; probably declared twice.");
1887  }
1888 
1889 }
1890 
1891 
1893 GNEAdditionalHandler::buildVehicleType(GNEViewNet* viewNet, bool allowUndoRedo, std::string vehicleTypeID,
1894  double accel, double decel, double sigma, double tau, double length, double minGap, double maxSpeed,
1895  double speedFactor, double speedDev, const RGBColor& color, SUMOVehicleClass vClass, const std::string& emissionClass,
1896  SUMOVehicleShape shape, double width, const std::string& filename, double impatience, const std::string& laneChangeModel,
1897  const std::string& carFollowModel, int personCapacity, int containerCapacity, double boardingDuration,
1898  double loadingDuration, const std::string& latAlignment, double minGapLat, double maxSpeedLat) {
1899  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_VTYPE, vehicleTypeID, false) == nullptr) {
1900  // create vehicle type and add it to calibrator parent
1901  GNECalibratorVehicleType* vType = new GNECalibratorVehicleType(viewNet, vehicleTypeID, accel, decel, sigma, tau, length, minGap, maxSpeed,
1902  speedFactor, speedDev, color, vClass, emissionClass, shape, width, filename, impatience,
1903  laneChangeModel, carFollowModel, personCapacity, containerCapacity, boardingDuration,
1904  loadingDuration, latAlignment, minGapLat, maxSpeedLat);
1905  if (allowUndoRedo) {
1906  viewNet->getUndoList()->p_begin("add " + vType->getTagStr());
1907  viewNet->getUndoList()->add(new GNEChange_Additional(vType, true), true);
1908  viewNet->getUndoList()->p_end();
1909  } else {
1910  viewNet->getNet()->insertAdditional(vType);
1911  vType->incRef("buildCalibratorVehicleType");
1912  }
1913  return vType;
1914  } else {
1915  throw ProcessError("Could not build " + toString(SUMO_TAG_VTYPE) + " with ID '" + vehicleTypeID + "' in netedit; probably declared twice.");
1916  }
1917 }
1918 
1919 
1921 GNEAdditionalHandler::buildCalibratorFlow(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* calibratorParent, GNEAdditional* route, GNEAdditional* vtype,
1922  const std::string& vehsPerHour, const std::string& speed, const RGBColor& color, const std::string& departLane, const std::string& departPos,
1923  const std::string& departSpeed, const std::string& arrivalLane, const std::string& arrivalPos, const std::string& arrivalSpeed, const std::string& line,
1924  int personNumber, int containerNumber, bool reroute, const std::string& departPosLat, const std::string& arrivalPosLat, double begin, double end) {
1925 
1926  // create Flow and add it to calibrator parent
1927  GNECalibratorFlow* flow = new GNECalibratorFlow(calibratorParent, vtype, route, vehsPerHour, speed, color, departLane, departPos, departSpeed,
1928  arrivalLane, arrivalPos, arrivalSpeed, line, personNumber, containerNumber, reroute,
1929  departPosLat, arrivalPosLat, begin, end);
1930  if (allowUndoRedo) {
1931  viewNet->getUndoList()->p_begin("add " + flow->getTagStr());
1932  viewNet->getUndoList()->add(new GNEChange_Additional(flow, true), true);
1933  viewNet->getUndoList()->p_end();
1934  } else {
1935  calibratorParent->addAdditionalChild(flow);
1936  flow->incRef("buildCalibratorFlow");
1937  }
1938  return flow;
1939 }
1940 
1941 
1943 GNEAdditionalHandler::buildRerouter(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNEEdge*>& edges, double prob, const std::string& name, const std::string& file, bool off, double timeThreshold, const std::string& vTypes, bool blockMovement) {
1944  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_REROUTER, id, false) == nullptr) {
1945  GNERerouter* rerouter = new GNERerouter(id, viewNet, pos, edges, name, file, prob, off, timeThreshold, vTypes, blockMovement);
1946  if (allowUndoRedo) {
1947  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_REROUTER));
1948  viewNet->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
1949  viewNet->getUndoList()->p_end();
1950  } else {
1951  viewNet->getNet()->insertAdditional(rerouter);
1952  // add this rerouter as parent of all edges
1953  for (auto i : edges) {
1954  i->addAdditionalParent(rerouter);
1955  }
1956  rerouter->incRef("buildRerouter");
1957  }
1958  // parse rerouter childs
1959  if (!file.empty()) {
1960  // we assume that rerouter values files is placed in the same folder as the additional file
1961  std::string currentAdditionalFilename = FileHelpers::getFilePath(OptionsCont::getOptions().getString("sumo-additionals-file"));
1962  // Create additional handler for parse rerouter values
1963  GNEAdditionalHandler rerouterValuesHandler(currentAdditionalFilename + file, viewNet, allowUndoRedo, rerouter);
1964  // disable validation for rerouters
1965  XMLSubSys::setValidation("never", "auto");
1966  // Run parser
1967  if (!XMLSubSys::runParser(rerouterValuesHandler, currentAdditionalFilename + file, false)) {
1968  WRITE_MESSAGE("Loading of " + file + " failed.");
1969  }
1970  // enable validation for rerouters
1971  XMLSubSys::setValidation("auto", "auto");
1972  }
1973  return rerouter;
1974  } else {
1975  throw ProcessError("Could not build " + toString(SUMO_TAG_REROUTER) + " with ID '" + id + "' in netedit; probably declared twice.");
1976  }
1977 }
1978 
1979 
1981 GNEAdditionalHandler::buildRerouterInterval(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* rerouterParent, double begin, double end) {
1982  // check if new interval will produce a overlapping
1983  if (checkOverlappingRerouterIntervals(rerouterParent, begin, end)) {
1984  // create rerouter interval and add it into rerouter parent
1985  GNERerouterInterval* rerouterInterval = new GNERerouterInterval(rerouterParent, begin, end);
1986  if (allowUndoRedo) {
1987  viewNet->getUndoList()->p_begin("add " + rerouterInterval->getTagStr());
1988  viewNet->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
1989  viewNet->getUndoList()->p_end();
1990  } else {
1991  rerouterParent->addAdditionalChild(rerouterInterval);
1992  rerouterInterval->incRef("buildRerouterInterval");
1993  }
1994  return rerouterInterval;
1995  } else {
1996  throw ProcessError("Could not build " + toString(SUMO_TAG_INTERVAL) + " with begin '" + toString(begin) + "' and '" + toString(end) + "' in '" + rerouterParent->getID() + "' due overlapping.");
1997  }
1998 }
1999 
2000 
2002 GNEAdditionalHandler::buildClosingLaneReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) {
2003  // create closing lane reorute
2004  GNEClosingLaneReroute* closingLaneReroute = new GNEClosingLaneReroute(rerouterIntervalParent, closedLane, permissions);
2005  // add it to interval parent depending of allowUndoRedo
2006  if (allowUndoRedo) {
2007  viewNet->getUndoList()->p_begin("add " + closingLaneReroute->getTagStr());
2008  viewNet->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
2009  viewNet->getUndoList()->p_end();
2010  } else {
2011  rerouterIntervalParent->addAdditionalChild(closingLaneReroute);
2012  closingLaneReroute->incRef("buildClosingLaneReroute");
2013  }
2014  return closingLaneReroute;
2015 }
2016 
2017 
2019 GNEAdditionalHandler::buildClosingReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) {
2020  // create closing reroute
2021  GNEClosingReroute* closingReroute = new GNEClosingReroute(rerouterIntervalParent, closedEdge, permissions);
2022  // add it to interval parent depending of allowUndoRedo
2023  if (allowUndoRedo) {
2024  viewNet->getUndoList()->p_begin("add " + closingReroute->getTagStr());
2025  viewNet->getUndoList()->add(new GNEChange_Additional(closingReroute, true), true);
2026  viewNet->getUndoList()->p_end();
2027  } else {
2028  rerouterIntervalParent->addAdditionalChild(closingReroute);
2029  closingReroute->incRef("buildClosingReroute");
2030  }
2031  return closingReroute;
2032 }
2033 
2034 
2036 GNEAdditionalHandler::builDestProbReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* rerouterIntervalParent, GNEEdge* newEdgeDestination, double probability) {
2037  // create dest probability reroute
2038  GNEDestProbReroute* destProbReroute = new GNEDestProbReroute(rerouterIntervalParent, newEdgeDestination, probability);
2039  // add it to interval parent depending of allowUndoRedo
2040  if (allowUndoRedo) {
2041  viewNet->getUndoList()->p_begin("add " + destProbReroute->getTagStr());
2042  viewNet->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
2043  viewNet->getUndoList()->p_end();
2044  } else {
2045  rerouterIntervalParent->addAdditionalChild(destProbReroute);
2046  destProbReroute->incRef("builDestProbReroute");
2047  }
2048  return destProbReroute;
2049 }
2050 
2051 
2053 GNEAdditionalHandler::builParkingAreaReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* rerouterIntervalParent, GNEAdditional* newParkingArea, double probability, bool visible) {
2054  // create dest probability reroute
2055  GNEParkingAreaReroute* parkingAreaReroute = new GNEParkingAreaReroute(rerouterIntervalParent, newParkingArea, probability, visible);
2056  // add it to interval parent depending of allowUndoRedo
2057  if (allowUndoRedo) {
2058  viewNet->getUndoList()->p_begin("add " + parkingAreaReroute->getTagStr());
2059  viewNet->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
2060  viewNet->getUndoList()->p_end();
2061  } else {
2062  rerouterIntervalParent->addAdditionalChild(parkingAreaReroute);
2063  parkingAreaReroute->incRef("builParkingAreaReroute");
2064  }
2065  return parkingAreaReroute;
2066 }
2067 
2068 
2070 GNEAdditionalHandler::buildRouteProbReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* rerouterIntervalParent, const std::string& newRouteId, double probability) {
2071  // create rout prob rereoute
2072  GNERouteProbReroute* routeProbReroute = new GNERouteProbReroute(rerouterIntervalParent, newRouteId, probability);
2073  // add it to interval parent depending of allowUndoRedo
2074  if (allowUndoRedo) {
2075  viewNet->getUndoList()->p_begin("add " + routeProbReroute->getTagStr());
2076  viewNet->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
2077  viewNet->getUndoList()->p_end();
2078  } else {
2079  rerouterIntervalParent->addAdditionalChild(routeProbReroute);
2080  routeProbReroute->incRef("buildRouteProbReroute");
2081  }
2082  return routeProbReroute;
2083 }
2084 
2085 
2087 GNEAdditionalHandler::buildRouteProbe(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNEEdge* edge, const std::string& freq, const std::string& name, const std::string& file, double begin) {
2088  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, id, false) == nullptr) {
2089  GNERouteProbe* routeProbe = new GNERouteProbe(id, viewNet, edge, freq, name, file, begin);
2090  if (allowUndoRedo) {
2091  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_ROUTEPROBE));
2092  viewNet->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
2093  viewNet->getUndoList()->p_end();
2094  // center after creation
2095  viewNet->centerTo(routeProbe->getGlID(), false);
2096  } else {
2097  viewNet->getNet()->insertAdditional(routeProbe);
2098  edge->addAdditionalChild(routeProbe);
2099  routeProbe->incRef("buildRouteProbe");
2100  }
2101  return routeProbe;
2102  } else {
2103  throw ProcessError("Could not build " + toString(SUMO_TAG_ROUTEPROBE) + " with ID '" + id + "' in netedit; probably declared twice.");
2104  }
2105 }
2106 
2107 
2109 GNEAdditionalHandler::buildVariableSpeedSign(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNELane*>& lanes, const std::string& name, bool blockMovement) {
2110  if (viewNet->getNet()->retrieveAdditional(SUMO_TAG_VSS, id, false) == nullptr) {
2111  GNEVariableSpeedSign* variableSpeedSign = new GNEVariableSpeedSign(id, viewNet, pos, lanes, name, blockMovement);
2112  if (allowUndoRedo) {
2113  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VSS));
2114  viewNet->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
2115  viewNet->getUndoList()->p_end();
2116  } else {
2117  viewNet->getNet()->insertAdditional(variableSpeedSign);
2118  // add this VSS as parent of all edges
2119  for (auto i : lanes) {
2120  i->addAdditionalParent(variableSpeedSign);
2121  }
2122  variableSpeedSign->incRef("buildVariableSpeedSign");
2123  }
2124  return variableSpeedSign;
2125  } else {
2126  throw ProcessError("Could not build " + toString(SUMO_TAG_VSS) + " with ID '" + id + "' in netedit; probably declared twice.");
2127  }
2128 }
2129 
2130 
2132 GNEAdditionalHandler::buildVariableSpeedSignStep(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional* VSSParent, double time, double speed) {
2133  // create Variable Speed Sign
2134  GNEVariableSpeedSignStep* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSSParent, time, speed);
2135  // add it depending of allow undoRedo
2136  if (allowUndoRedo) {
2137  viewNet->getUndoList()->p_begin("add " + variableSpeedSignStep->getTagStr());
2138  viewNet->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
2139  viewNet->getUndoList()->p_end();
2140  } else {
2141  VSSParent->addAdditionalChild(variableSpeedSignStep);
2142  variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
2143  }
2144  return variableSpeedSignStep;
2145 }
2146 
2147 
2149 GNEAdditionalHandler::buildVaporizer(GNEViewNet* viewNet, bool allowUndoRedo, GNEEdge* edge, double startTime, double end, const std::string& name) {
2150  GNEVaporizer* vaporizer = new GNEVaporizer(viewNet, edge, startTime, end, name);
2151  if (allowUndoRedo) {
2152  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VAPORIZER));
2153  viewNet->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
2154  viewNet->getUndoList()->p_end();
2155  // center after creation
2156  viewNet->centerTo(vaporizer->getGlID(), false);
2157  } else {
2158  viewNet->getNet()->insertAdditional(vaporizer);
2159  edge->addAdditionalChild(vaporizer);
2160  vaporizer->incRef("buildVaporizer");
2161  }
2162  return vaporizer;
2163 }
2164 
2165 
2166 GNEAdditional*
2167 GNEAdditionalHandler::buildTAZ(GNEViewNet* viewNet, bool allowUndoRedo, const std::string &id, const PositionVector &shape, const RGBColor &color, const std::vector<GNEEdge*> &edges, bool blockMovement) {
2168  GNETAZ* TAZ = new GNETAZ(id, viewNet, shape, color, blockMovement);
2169  if (allowUndoRedo) {
2170  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_TAZ));
2171  viewNet->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
2172  // create TAZEdges
2173  for (auto i : edges) {
2174  // create TAZ Source using GNEChange_Additional
2175  GNETAZSource* TAZSource = new GNETAZSource(TAZ, i, 1);
2176  viewNet->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
2177  // create TAZ Sink using GNEChange_Additional
2178  GNETAZSink* TAZSink = new GNETAZSink(TAZ, i, 1);
2179  viewNet->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
2180  }
2181  viewNet->getUndoList()->p_end();
2182  } else {
2183  viewNet->getNet()->insertAdditional(TAZ);
2184  TAZ->incRef("buildTAZ");
2185  for (auto i : edges) {
2186  // create TAZ Source
2187  GNETAZSource* TAZSource = new GNETAZSource(TAZ, i, 1);
2188  TAZSource->incRef("buildTAZ");
2189  TAZ->addAdditionalChild(TAZSource);
2190  // create TAZ Sink
2191  GNETAZSink* TAZSink = new GNETAZSink(TAZ, i, 1);
2192  TAZSink->incRef("buildTAZ");
2193  TAZ->addAdditionalChild(TAZSink);
2194  }
2195  }
2196  return TAZ;
2197 }
2198 
2199 
2200 GNEAdditional*
2201 GNEAdditionalHandler::buildTAZSource(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional *TAZ, GNEEdge *edge, double departWeight) {
2202  GNEAdditional *TAZSink = nullptr;
2203  // first check if a TAZSink in the same edge for the same TAZ
2204  for (auto i : TAZ->getAdditionalChilds()) {
2205  if((i->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (i->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
2206  TAZSink = i;
2207  }
2208  }
2209  // check if TAZSink has to be created
2210  if(TAZSink == nullptr) {
2211  // Create TAZ with weight 0 (default)
2212  TAZSink = new GNETAZSink(TAZ, edge, 1);
2213  if (allowUndoRedo) {
2214  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_TAZSINK));
2215  viewNet->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
2216  viewNet->getUndoList()->p_end();
2217  } else {
2218  viewNet->getNet()->insertAdditional(TAZSink);
2219  TAZSink->incRef("buildTAZSource");
2220  }
2221  }
2222  // now check check if TAZSource exist
2223  GNEAdditional *TAZSource = nullptr;
2224  // first check if a TAZSink in the same edge for the same TAZ
2225  for (auto i : TAZ->getAdditionalChilds()) {
2226  if((i->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (i->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
2227  TAZSource = i;
2228  }
2229  }
2230  // check if TAZSource has to be created
2231  if(TAZSource == nullptr) {
2232  // Create TAZ only with departWeight
2233  TAZSource = new GNETAZSource(TAZ, edge, departWeight);
2234  if (allowUndoRedo) {
2235  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_TAZSOURCE));
2236  viewNet->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
2237  viewNet->getUndoList()->p_end();
2238  } else {
2239  viewNet->getNet()->insertAdditional(TAZSource);
2240  TAZSource->incRef("buildTAZSource");
2241  }
2242  } else {
2243  // update TAZ Attribute
2244  if (allowUndoRedo) {
2245  viewNet->getUndoList()->p_begin("update " + toString(SUMO_TAG_TAZSOURCE));
2246  TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), viewNet->getUndoList());
2247  viewNet->getUndoList()->p_end();
2248  } else {
2249  TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
2250  TAZSource->incRef("buildTAZSource");
2251  }
2252  }
2253  return TAZSource;
2254 }
2255 
2256 
2257 GNEAdditional*
2258 GNEAdditionalHandler::buildTAZSink(GNEViewNet* viewNet, bool allowUndoRedo, GNEAdditional *TAZ, GNEEdge *edge, double arrivalWeight) {
2259  GNEAdditional *TAZSource = nullptr;
2260  // first check if a TAZSink in the same edge for the same TAZ
2261  for (auto i : TAZ->getAdditionalChilds()) {
2262  if((i->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (i->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
2263  TAZSource = i;
2264  }
2265  }
2266  // check if TAZSource has to be created
2267  if(TAZSource == nullptr) {
2268  // Create TAZ with empty value
2269  TAZSource = new GNETAZSource(TAZ, edge, 1);
2270  if (allowUndoRedo) {
2271  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_TAZSOURCE));
2272  viewNet->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
2273  viewNet->getUndoList()->p_end();
2274  } else {
2275  viewNet->getNet()->insertAdditional(TAZSource);
2276  TAZSource->incRef("buildTAZSink");
2277  }
2278  }
2279  GNEAdditional *TAZSink = nullptr;
2280  // first check if a TAZSink in the same edge for the same TAZ
2281  for (auto i : TAZ->getAdditionalChilds()) {
2282  if((i->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (i->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
2283  TAZSink = i;
2284  }
2285  }
2286  // check if TAZSink has to be created
2287  if(TAZSink == nullptr) {
2288  // Create TAZ only with arrivalWeight
2289  TAZSink = new GNETAZSink(TAZ, edge, arrivalWeight);
2290  if (allowUndoRedo) {
2291  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_TAZSINK));
2292  viewNet->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
2293  viewNet->getUndoList()->p_end();
2294  } else {
2295  viewNet->getNet()->insertAdditional(TAZSink);
2296  TAZSink->incRef("buildTAZSink");
2297  }
2298  } else {
2299  // update TAZ Attribute
2300  if (allowUndoRedo) {
2301  viewNet->getUndoList()->p_begin("update " + toString(SUMO_TAG_TAZSINK));
2302  TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), viewNet->getUndoList());
2303  viewNet->getUndoList()->p_end();
2304  } else {
2305  TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
2306  TAZSink->incRef("buildTAZSink");
2307  }
2308  }
2309  return TAZSink;
2310 }
2311 
2312 
2313 std::string
2314 GNEAdditionalHandler::getFileName(const SUMOSAXAttributes& attrs, const std::string& base, const bool allowEmpty) {
2315  // get the file name to read further definitions from
2316  bool ok = true;
2317  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, nullptr, ok, "");
2318  if (file == "") {
2319  if (allowEmpty) {
2320  return file;
2321  }
2322  WRITE_WARNING("No filename given.");
2323  }
2324  // check whether absolute or relative filenames are given
2325  if (!FileHelpers::isAbsolute(file)) {
2326  return FileHelpers::getConfigurationRelative(base, file);
2327  }
2328  return file;
2329 }
2330 
2331 
2332 double
2333 GNEAdditionalHandler::getPosition(double pos, GNELane& lane, bool friendlyPos , const std::string& additionalID) {
2334  if (pos < 0) {
2335  pos = lane.getLaneShapeLength() + pos;
2336  }
2337  if (pos > lane.getLaneShapeLength()) {
2338  if (friendlyPos) {
2339  pos = lane.getLaneShapeLength() - (double) 0.1;
2340  } else {
2341  WRITE_WARNING("The position of additional '" + additionalID + "' lies beyond the lane's '" + lane.getID() + "' length.");
2342  }
2343  }
2344  return pos;
2345 }
2346 
2347 
2348 bool
2349 GNEAdditionalHandler::fixStoppinPlacePosition(std::string& startPos, std::string& endPos, const double laneLength, const double minLength, const bool friendlyPos) {
2350  // first check if startPos and endPos were defined
2351  if (GNEAttributeCarrier::canParse<double>(startPos) && GNEAttributeCarrier::canParse<double>(endPos)) {
2352  // first parse strings to numerical values
2353  double startPosDouble = GNEAttributeCarrier::parse<double>(startPos);
2354  double endPosDouble = GNEAttributeCarrier::parse<double>(endPos);
2355 
2356  // fix both positions
2357  if (minLength > laneLength) {
2358  return false;
2359  }
2360  if (startPosDouble < 0) {
2361  startPosDouble += laneLength;
2362  }
2363  if (endPosDouble < 0) {
2364  endPosDouble += laneLength;
2365  }
2366  if ((endPosDouble < minLength) || (endPosDouble > laneLength)) {
2367  if (!friendlyPos) {
2368  return false;
2369  }
2370  if (endPosDouble < minLength) {
2371  endPosDouble = minLength;
2372  }
2373  if (endPosDouble > laneLength) {
2374  endPosDouble = laneLength;
2375  }
2376  }
2377  if ((startPosDouble < 0) || (startPosDouble > (endPosDouble - minLength))) {
2378  if (!friendlyPos) {
2379  return false;
2380  }
2381  if (startPosDouble < 0) {
2382  startPosDouble = 0;
2383  }
2384  if (startPosDouble > (endPosDouble - minLength)) {
2385  startPosDouble = (endPosDouble - minLength);
2386  }
2387  }
2388  // Modify original positions
2389  startPos = toString(startPosDouble);
2390  endPos = toString(endPosDouble);
2391  } else if (GNEAttributeCarrier::canParse<double>(startPos)) {
2392  // check that endPosition is valid
2393  if (endPos.empty() || !GNEAttributeCarrier::canParse<double>(endPos)) {
2394  // first parse to double only startPos
2395  double startPosDouble = GNEAttributeCarrier::parse<double>(startPos);
2396  // fix both positions
2397  if (minLength > laneLength) {
2398  return false;
2399  }
2400  if (startPosDouble < 0) {
2401  startPosDouble += laneLength;
2402  }
2403  if ((startPosDouble < 0) || startPosDouble > (laneLength - minLength)) {
2404  if (!friendlyPos) {
2405  return false;
2406  }
2407  if (startPosDouble < 0) {
2408  startPosDouble = 0;
2409  }
2410  if (startPosDouble > (laneLength - minLength)) {
2411  startPosDouble = (laneLength - minLength);
2412  }
2413  }
2414  // Modify only start position
2415  startPos = toString(startPosDouble);
2416  } else {
2417  return false;
2418  }
2419  } else if (GNEAttributeCarrier::canParse<double>(endPos)) {
2420  // check that endPosition is valid
2421  if (startPos.empty() || !GNEAttributeCarrier::canParse<double>(startPos)) {
2422  // first parse to double only endPos
2423  double endPosDouble = GNEAttributeCarrier::parse<double>(endPos);
2424  // fix both positions
2425  if (minLength > laneLength) {
2426  return false;
2427  }
2428  if (endPosDouble < 0) {
2429  endPosDouble += laneLength;
2430  }
2431  if ((endPosDouble < minLength) || (endPosDouble > laneLength)) {
2432  if (!friendlyPos) {
2433  return false;
2434  }
2435  if (endPosDouble < minLength) {
2436  endPosDouble = minLength;
2437  }
2438  if (endPosDouble > laneLength) {
2439  endPosDouble = laneLength;
2440  }
2441  }
2442  if (0 > (endPosDouble - minLength)) {
2443  if (!friendlyPos) {
2444  return false;
2445  }
2446  }
2447  // Modify only end position
2448  endPos = toString(endPosDouble);
2449  } else {
2450  return false;
2451  }
2452  }
2453  return true;
2454 }
2455 
2456 
2457 bool GNEAdditionalHandler::checkAndFixDetectorPosition(double& pos, const double laneLength, const bool friendlyPos) {
2458  if ((pos < 0) || (pos > laneLength)) {
2459  if (!friendlyPos) {
2460  return false;
2461  } else if (pos < 0) {
2462  pos = 0;
2463  } else if (pos > laneLength) {
2464  pos = laneLength - 0.01;
2465  }
2466  }
2467  return true;
2468 }
2469 
2470 
2471 bool GNEAdditionalHandler::fixE2DetectorPosition(double& pos, double& length, const double laneLength, const bool friendlyPos) {
2472  if ((pos < 0) || ((pos + length) > laneLength)) {
2473  if (!friendlyPos) {
2474  return false;
2475  } else if (pos < 0) {
2476  pos = 0;
2477  } else if (pos > laneLength) {
2478  pos = laneLength - 0.01;
2479  length = 0;
2480  } else if ((pos + length) > laneLength) {
2481  length = laneLength - pos - 0.01;
2482  }
2483  }
2484  return true;
2485 }
2486 
2487 
2488 bool
2490  // check that busStopParent is a busStop
2491  assert(busStopParent->getTagProperty().getTag() == SUMO_TAG_BUS_STOP);
2492  // check if exist another acces for the same busStop in the given edge
2493  for (auto i : busStopParent->getAdditionalChilds()) {
2494  for (auto j : edge.getLanes()) {
2495  if (i->getAttribute(SUMO_ATTR_LANE) == j->getID()) {
2496  return false;
2497  }
2498  }
2499  }
2500  return true;
2501 }
2502 
2503 
2504 bool
2506  // check that rerouter is correct
2507  assert(rerouter->getTagProperty().getTag() == SUMO_TAG_REROUTER);
2508  // declare a vector to keep sorted rerouter childs
2509  std::vector<std::pair<double, double>> sortedIntervals;
2510  // iterate over additional childs
2511  for (auto i : rerouter->getAdditionalChilds()) {
2512  sortedIntervals.push_back(std::make_pair(0., 0.));
2513  // set begin and end
2514  sortedIntervals.back().first = GNEAttributeCarrier::parse<double>(i->getAttribute(SUMO_ATTR_BEGIN));
2515  sortedIntervals.back().second = GNEAttributeCarrier::parse<double>(i->getAttribute(SUMO_ATTR_END));
2516  }
2517  // add new intervals
2518  sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
2519  // sort childs
2520  std::sort(sortedIntervals.begin(), sortedIntervals.end());
2521  // check overlapping after sorting
2522  for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
2523  if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
2524  return false;
2525  }
2526  }
2527  return true;
2528 }
2529 
2530 
2531 void
2533  myInsertedElements.push_back(std::make_pair(tag, nullptr));
2534 }
2535 
2536 
2537 void
2539  myInsertedElements.back().second = additional;
2540 }
2541 
2542 
2543 void
2545  if (!myInsertedElements.empty()) {
2546  myInsertedElements.pop_back();
2547  }
2548 }
2549 
2550 
2553  if (myInsertedElements.size() < 2) {
2554  // currently we're finding additional parent in the additional XML root
2555  WRITE_WARNING("A " + toString(myInsertedElements.back().first) + " must be declared within the definition of a " + toString(expectedTag) + ".");
2556  return nullptr;
2557  } else {
2558  if(myInsertedElements.size() < 2) {
2559  // additional was hierarchically bad loaded, then return nullptr
2560  return nullptr;
2561  } else if ((myInsertedElements.end() - 2)->second == nullptr) {
2562  WRITE_WARNING(toString(expectedTag) + " parent of " + toString((myInsertedElements.end() - 1)->first) + " was not loaded sucesfully.");
2563  // additional parent wasn't sucesfully loaded, then return nullptr
2564  return nullptr;
2565  }
2566  GNEAdditional* retrievedAdditional = viewNet->getNet()->retrieveAdditional((myInsertedElements.end() - 2)->first, (myInsertedElements.end() - 2)->second->getID(), false);
2567  if (retrievedAdditional == nullptr) {
2568  // additional doesn't exist
2569  WRITE_WARNING("A " + toString((myInsertedElements.end() - 1)->first) + " must be declared within the definition of a " + toString(expectedTag) + ".");
2570  return nullptr;
2571  } else if (retrievedAdditional->getTagProperty().getTag() != expectedTag) {
2572  // invalid additional parent
2573  WRITE_WARNING("A " + toString((myInsertedElements.end() - 1)->first) + " cannot be declared within the definition of a " + retrievedAdditional->getTagStr() + ".");
2574  return nullptr;
2575  } else {
2576  return retrievedAdditional;
2577  }
2578  }
2579 }
2580 
2581 
2582 GNEAdditional*
2584  // ierate in reverse mode over myInsertedElements to obtain last inserted additional
2585  for (std::vector<std::pair<SumoXMLTag, GNEAdditional*> >::const_reverse_iterator i = myInsertedElements.rbegin(); i != myInsertedElements.rend(); i++) {
2586  // we need to avoid Tag Param because isn't an additional
2587  if (i->first != SUMO_TAG_PARAM) {
2588  return i->second;
2589  }
2590  }
2591  return nullptr;
2592 }
2593 
2594 /****************************************************************************/
static GNEAdditional * buildParkingArea(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, const std::string &startPos, const std::string &endPos, const std::string &name, bool friendlyPosition, int roadSideCapacity, bool onRoad, double width, const std::string &length, double angle, bool blockMovement)
Builds a Parking Area.
void insertAdditional(GNEAdditional *additional)
Insert a additional element int GNENet container.
Definition: GNENet.cpp:2144
GNEAdditional * getLastInsertedAdditional() const
return last additional inserted
SumoXMLTag
Numbers representing SUMO-XML - element names.
vehicle space used by GNEParkingAreas
static GNEAdditional * buildVehicleType(GNEViewNet *viewNet, bool allowUndoRedo, std::string vehicleTypeID, double accel, double decel, double sigma, double tau, double length, double minGap, double maxSpeed, double speedFactor, double speedDev, const RGBColor &color, SUMOVehicleClass vClass, const std::string &emissionClass, SUMOVehicleShape shape, double width, const std::string &filename, double impatience, const std::string &laneChangeModel, const std::string &carFollowModel, int personCapacity, int containerCapacity, double boardingDuration, double loadingDuration, const std::string &latAlignment, double minGapLat, double maxSpeedLat)
a routeprobe detector
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:900
alternative tag for e1 detector
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
Definition: FileHelpers.cpp:75
description of a vehicle type
void parseAndBuildRerouterRouteProbReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Route Prob Reroute.
a source within a district (connection road)
void parseAndBuildRerouterParkingAreaReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a parkingAreaReroute.
static bool fixStoppinPlacePosition(std::string &startPos, std::string &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check if the position of an stoppingPlace over a lane is valid
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name) ...
void parseAndBuildDetectorE1(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a induction loop detector (E1)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void parseAndBuildTAZ(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a TAZ.
begin/end of the description of a single lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
a flow definition (used by router)
static GNEAdditional * buildVariableSpeedSign(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNELane *> &destLanes, const std::string &name, bool blockMovement)
Builds a VariableSpeedSign (lane speed trigger)
A calibrator placed over edge.
an e2 detector over multiple lanes (used by Netedit)
void popElement()
pop last inserted element (used only in function myEndElement)
a traffic assignment zone
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:59
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
lane of a reroute of type closing
Allow/disallow charge in transit in Charging Stations.
void parseAndBuildParkingSpace(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a parking space.
const std::string & getFileName() const
returns the current file name
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
bool myUndoAdditionals
flag to check if created additionals must be undo and redo
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:35
weights: time range begin
void parseAndBuildDetectorExit(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Exit detector.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
static GNEAdditional * buildDetectorE3(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, double freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, const double timeThreshold, double speedThreshold, bool blockMovement)
Builds a multi entry exit detector (E3)
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:73
static GNEAdditional * buildCalibratorRoute(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &routeID, const std::vector< GNEEdge *> &edges, const RGBColor &color)
GNEAdditionalHandler(const std::string &file, GNEViewNet *viewNet, bool undoAdditionals=true, GNEAdditional *additionalParent=nullptr)
Constructor.
SAX-handler base for SUMO-files.
A parking space for a single vehicle within a parking area.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:113
double getPosition(double pos, GNELane &lane, bool friendlyPos, const std::string &additionalID)
extracts the position, checks whether it shall be mirrored and checks whether it is within the lane...
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static GNEAdditional * buildContainerStop(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, const std::string &startPos, const std::string &endPos, const std::string &name, const std::vector< std::string > &lines, bool friendlyPosition, bool blockMovement)
Builds a container stop.
static GNEAdditional * buildClosingReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *rerouterIntervalParent, GNEEdge *closedEdge, SVCPermissions permissions)
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
begin/end of the description of a route
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
void parseAndBuildVariableSpeedSign(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Variable Speed Signal (lane speed trigger)
void parseAndBuildDetectorE2(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a lane area detector (E2)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
an e3 entry point
static GNEAdditional * builDestProbReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *rerouterIntervalParent, GNEEdge *newEdgeDestination, double probability)
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
void commitElementInsertion(GNEAdditional *additionalCreated)
commit element insertion (used to save last correct created element)
GNEAdditional * retrieveAdditionalParent(GNEViewNet *viewNet, SumoXMLTag expectedTag) const
retrieve additional parent correspond to current status of myInsertedElements
static GNEAdditional * buildDetectorE1Instant(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, const std::string &filename, const std::string &vehicleTypes, const std::string &name, bool friendlyPos, bool blockMovement)
Builds a Instant Induction Loop Detector (E1Instant)
static GNEAdditional * buildDetectorEntry(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *E3Parent, GNELane *lane, double pos, bool friendlyPos, bool blockMovement)
Builds a entry detector (E3)
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:1785
static GNEAdditional * buildRouteProbReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *rerouterIntervalParent, const std::string &newRouteId, double probability)
void insertElement(SumoXMLTag tag)
insert new element (called only in function myStartElement)
void parseAndBuildDetectorE1Instant(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Instant induction loop detector (E1Instant)
GNEUndoList * getUndoList() const
get the undoList object
~GNEAdditionalHandler()
Destructor.
HierarchyInsertedAdditionals myHierarchyInsertedAdditionals
HierarchyInsertedAdditionals used for insert childs.
void parseAndBuildCalibratorVehicleType(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses vehicle type values of Calibrators.
static GNEAdditional * buildCalibrator(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, const std::string &name, const std::string &outfile, double freq, const std::string &routeprobe)
builds a microscopic calibrator over a lane
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
A lane area vehicles can park at (netedit-version)
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1260
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
static bool checkOverlappingRerouterIntervals(GNEAdditional *rerouter, double newBegin, double newEnd)
check if an overlapping is produced in rerouter if a interval with certain begin and end is inserted ...
void parseAndBuildRerouterInterval(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Rerouter Interval.
static GNEAdditional * buildChargingStation(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, const std::string &startPos, const std::string &endPos, const std::string &name, double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay, bool friendlyPosition, bool blockMovement)
Builds a charging Station.
Encapsulated SAX-Attributes.
An instantenous induction loop.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
Definition: FileHelpers.cpp:90
void parseAndBuildTAZSource(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a TAZ Source.
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:80
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
parameter associated to a certain key
static bool lanesConsecutives(const std::vector< GNELane *> &lanes)
check if lanes are consecutives
an e3 exit point
static GNEAdditional * buildAccess(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *busStop, GNELane *lane, const std::string &pos, const std::string &length, bool friendlyPos, bool blockMovement)
Builds an Access.
A list of positions.
static GNEAdditional * buildDetectorE1(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, double freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, bool friendlyPos, bool blockMovement)
Builds a induction loop detector (E1)
bool hasGenericParameters() const
return true if Tag correspond to an element that supports generic parameters
void checkE2MultilaneIntegrity()
check if E2 is valid (all of their lanes are connected, it must called after every operation which in...
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
void parseAndBuildRerouter(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a rerouter.
A calibrator placed over lane (used in netedit)
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:35
void parseAndBuildCalibratorRoute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses route values of Calibrators.
block movement of a graphic element
static GNEAdditional * buildRerouterInterval(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *rerouterParent, double begin, double end)
builds a rerouter interval
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:35
Definition: GNETAZ.h:35
#define POSITION_EPS
Definition: config.h:172
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
edge: the shape in xml-definition
probability of route of a reroute
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
probability of destiny of a reroute
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:248
GNEViewNet * myViewNet
pointer to View&#39;s Net
void incRef(const std::string &debugMsg="")
Increarse reference.
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:786
static GNEAdditional * buildMultiLaneDetectorE2(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, const std::vector< GNELane *> &lanes, double pos, double endPos, double freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement)
Builds a multi-lane Area Detector (E2)
static GNEAdditional * buildTAZSource(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *TAZ, GNEEdge *edge, double departWeight)
Builds a TAZSource (Traffic Assignment Zone)
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:3575
static bool accessCanBeCreated(GNEAdditional *busStopParent, GNEEdge &edge)
check if a GNEAccess can be created in a certain Edge
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
static GNEAdditional * buildRerouter(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNEEdge *> &edges, double prob, const std::string &name, const std::string &file, bool off, double timeThreshold, const std::string &vTypes, bool blockMovement)
builds a rerouter
begin/end of the description of an edge
static GNEAdditional * buildSingleLaneDetectorE2(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, double length, double freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement)
Builds a single-lane Area Detector (E2)
static GNEAdditional * buildParkingSpace(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *parkingAreaParent, Position pos, double width, double length, double angle, bool blockMovement)
Builds a Parking Space.
void parseAndBuildRouteProbe(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds routeProbe.
reroute of type closing
GNEAdditional * getFirstAdditionalParent() const
void parseAndBuildRerouterDestProbReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Destiny Prob Reroute.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
void parseAndBuildTAZSink(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a TAZ Sink.
entry for an alternative parking zone
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
void parseAndBuildVariableSpeedSignStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Variable Speed Signal Step.
void parseGenericParameter(const SUMOSAXAttributes &attrs)
Parse generic parameter and insert it in the last created additional.
trigger: the time of the step
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
A train stop (alias for bus stop)
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:873
void parseAndBuildBusStop(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a bus stop.
void parseAndBuildContainerStop(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a container stop.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
a sink within a district (connection road)
static GNEAdditional * builParkingAreaReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *rerouterIntervalParent, GNEAdditional *newParkignArea, double probability, bool visible)
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
static GNEAdditional * buildAdditional(GNEViewNet *viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Build additionals.
void parseAndBuildCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
const std::string & getTagStr() const
get tag assigned to this object in string format
weights: time range end
static GNEAdditional * buildVaporizer(GNEViewNet *viewNet, bool allowUndoRedo, GNEEdge *edge, double startTime, double end, const std::string &name)
Builds a vaporizer (lane speed trigger)
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a Vaporizer.
vaporizer of vehicles
static GNEAdditional * buildTAZSink(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *TAZ, GNEEdge *edge, double arrivalWeight)
Builds a TAZSink (Traffic Assignment Zone)
void parseAndBuildRerouterClosingLaneReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Closing Lane reroute.
GNENet * getNet() const
get the net object
static GNEAdditional * buildRouteProbe(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNEEdge *edge, const std::string &freq, const std::string &name, const std::string &file, double begin)
builds a Route probe
void parseAndBuildParkingArea(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a parking area.
GUIGlID getGlID() const
Returns the numerical id of the object.
an aggreagated-output interval
static GNEAdditional * buildCalibratorFlow(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *calibratorParent, GNEAdditional *route, GNEAdditional *vtype, const std::string &vehsPerHour, const std::string &speed, const RGBColor &color, const std::string &departLane, const std::string &departPos, const std::string &departSpeed, const std::string &arrivalLane, const std::string &arrivalPos, const std::string &arrivalSpeed, const std::string &line, int personNumber, int containerNumber, bool reroute, const std::string &departPosLat, const std::string &arrivalPosLat, double begin, double end)
A variable speed sign.
Eficiency of the charge in Charging Stations.
const TagProperties & getTagProperty() const
get Tag Property assigned to this object
void parseAndBuildAccess(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses values and adds access to the current bus stop.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
Definition: FileHelpers.cpp:65
parent of an additional element
static GNEAdditional * buildBusStop(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, const std::string &startPos, const std::string &endPos, const std::string &name, const std::vector< std::string > &lines, bool friendlyPosition, bool blockMovement)
Builds a bus stop.
void myEndElement(int element)
Called when a closing tag occurs.
static GNEAdditional * buildVariableSpeedSignStep(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *VSSParent, double time, double speed)
Builds a VariableSpeedSign Step.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
Delay in the charge of charging stations.
static bool fixE2DetectorPosition(double &pos, double &length, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
void addAdditionalChild(GNEAdditional *additional)
add additional child to this additional
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:613
A lane area vehicles can halt at (netedit-version)
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:242
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
An access point for a train stop.
static GNEAdditional * buildClosingLaneReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *rerouterIntervalParent, GNELane *closedLane, SVCPermissions permissions)
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1059
static GNEAdditional * buildDetectorExit(GNEViewNet *viewNet, bool allowUndoRedo, GNEAdditional *E3Parent, GNELane *lane, double pos, bool friendlyPos, bool blockMovement)
Builds a exit detector (E3)
A color information.
void parseAndBuildDetectorEntry(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Entry detector.
alternative tag for e3 detector
static GNEAdditional * buildTAZ(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, const PositionVector &shape, const RGBColor &color, const std::vector< GNEEdge *> &edges, bool blockMovement)
Builds a TAZ (Traffic Assignment Zone)
alternative tag for e2 detector
trigger: a step description
void parseAndBuildRerouterClosingReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Closing Reroute.