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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Builds trigger objects for netedit
18 /****************************************************************************/
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
30 
31 #include "GNEAdditionalHandler.h"
32 #include "GNEBusStop.h"
33 #include "GNECalibrator.h"
34 #include "GNECalibratorFlow.h"
35 #include "GNECalibratorRoute.h"
37 #include "GNEChange_Additional.h"
39 #include "GNEChange_RerouterItem.h"
41 #include "GNEChargingStation.h"
42 #include "GNEClosingLaneReroute.h"
43 #include "GNEClosingReroute.h"
44 #include "GNEContainerStop.h"
45 #include "GNEDestProbReroute.h"
46 #include "GNEDetectorE1.h"
47 #include "GNEDetectorE2.h"
48 #include "GNEDetectorE3.h"
49 #include "GNEDetectorEntry.h"
50 #include "GNEDetectorExit.h"
51 #include "GNEEdge.h"
52 #include "GNEJunction.h"
53 #include "GNELane.h"
54 #include "GNENet.h"
55 #include "GNERerouter.h"
56 #include "GNERerouterInterval.h"
57 #include "GNERouteProbReroute.h"
58 #include "GNERouteProbe.h"
59 #include "GNEUndoList.h"
60 #include "GNEVaporizer.h"
61 #include "GNEVariableSpeedSign.h"
63 #include "GNEViewNet.h"
64 
65 // ===========================================================================
66 // member method definitions
67 // ===========================================================================
68 
69 GNEAdditionalHandler::GNEAdditionalHandler(const std::string& file, GNEViewNet* viewNet, bool undoAdditionals) :
70  SUMOSAXHandler(file),
71  myViewNet(viewNet),
72  myUndoAdditionals(undoAdditionals) {
73 }
74 
75 
77 
78 
79 void
81  // Obtain tag of element
82  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
83  // Call parse and build depending of tag
84  switch (element) {
85  case SUMO_TAG_BUS_STOP:
86  parseAndBuildBusStop(attrs, tag);
87  break;
90  break;
92  parseAndBuildContainerStop(attrs, tag);
93  break;
95  parseAndBuildChargingStation(attrs, tag);
96  break;
99  parseAndBuildDetectorE1(attrs, tag);
100  break;
101  case SUMO_TAG_E2DETECTOR:
103  parseAndBuildDetectorE2(attrs, tag);
104  break;
105  case SUMO_TAG_E3DETECTOR:
107  parseAndBuildDetectorE3(attrs, tag);
108  break;
109  case SUMO_TAG_DET_ENTRY:
110  parseAndBuildDetectorEntry(attrs, tag);
111  break;
112  case SUMO_TAG_DET_EXIT:
113  parseAndBuildDetectorExit(attrs, tag);
114  break;
115  case SUMO_TAG_ROUTEPROBE:
116  parseAndBuildRouteProbe(attrs, tag);
117  break;
118  case SUMO_TAG_VAPORIZER:
119  parseAndBuildVaporizer(attrs, tag);
120  break;
121  case SUMO_TAG_VSS:
122  parseAndBuildVariableSpeedSign(attrs, tag);
123  break;
124  case SUMO_TAG_STEP:
126  break;
127  case SUMO_TAG_CALIBRATOR:
128  parseAndBuildCalibrator(attrs, tag);
129  break;
130  case SUMO_TAG_VTYPE:
132  break;
133  case SUMO_TAG_ROUTE:
134  parseAndBuildCalibratorRoute(attrs, tag);
135  break;
136  case SUMO_TAG_FLOW:
137  parseAndBuildCalibratorFlow(attrs, tag);
138  break;
139  case SUMO_TAG_REROUTER:
140  parseAndBuildRerouter(attrs, tag);
141  break;
142  case SUMO_TAG_INTERVAL:
143  parseAndBuildRerouterInterval(attrs, tag);
144  break;
147  break;
150  break;
153  break;
156  break;
157  default:
158  break;
159  }
160 }
161 
162 
163 void
165  bool abort = false;
166  // parse attributes of Vaporizer
167  const std::string edgeId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_EDGE, abort);
168  double startTime = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_STARTTIME, abort);
169  double endTime = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_END, abort);
170  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
172  // Continue if all parameters were successfully loaded
173  if (!abort) {
174  // get GNEEdge
175  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
176  // check that all parameters are valid
177  if (edge == NULL) {
178  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " is not known.");
179  } else if (startTime > endTime) {
180  WRITE_WARNING("Time interval of " + toString(tag) + " isn't valid. Attribute '" + toString(SUMO_ATTR_STARTTIME) + "' is greater than attribute '" + toString(SUMO_ATTR_END) + "'.");
181  } else {
182  buildVaporizer(myViewNet, myUndoAdditionals, edge, startTime, endTime);
183  }
184  }
185 }
186 
187 
188 void
190  bool abort = false;
191  // parse attributes of RouteProbe
192  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
193  std::string edgeId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_EDGE, abort);
194  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
195  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort, false);
196  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_BEGIN, abort);
197  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
199  // Continue if all parameters were sucesfully loaded
200  if (!abort) {
201  // get edge
202  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
203  // check that all elements are valid
204  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
205  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
206  } else if (edge == NULL) {
207  // Write error if lane isn't valid
208  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
209  } else {
210  buildRouteProbe(myViewNet, myUndoAdditionals, id, edge, freq, file, begin);
211  }
212  }
213 }
214 
215 
216 void
218  bool abort = false;
219  // parse attribute of calibrator routes
220  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
221  std::string edgeIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, routeID, tag, SUMO_ATTR_EDGES, abort);
222  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, routeID, tag, SUMO_ATTR_COLOR, abort, false);
223  // Continue if all parameters were sucesfully loaded
224  if (!abort) {
225  // obtain edges (And show warnings if isn't valid)
226  std::vector<GNEEdge*> edges;
229  }
230  // get calibrator parent
232  // check that all elements are valid
233  if (myViewNet->getNet()->retrieveCalibratorRoute(routeID, false) != NULL) {
234  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + routeID + "'.");
235  } else if (calibrator == NULL) {
236  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_CALIBRATOR) + ".");
237  } else if (edges.size() > 0) {
238  // create vehicle type and add it to calibrator parent
239  buildCalibratorRoute(myViewNet, myUndoAdditionals, calibrator, routeID, edges, color);
240  }
241  }
242 }
243 
244 
245 void
247  bool abort = false;
248  // parse attribute of calibrator vehicle types
249  std::string vehicleTypeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
250  double accel = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_ACCEL, abort);
251  double decel = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_DECEL, abort);
252  double sigma = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_SIGMA, abort);
253  double tau = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_TAU, abort);
254  double length = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_LENGTH, abort);
255  double minGap = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MINGAP, abort);
256  double maxSpeed = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MAXSPEED, abort);
257  double speedFactor = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_SPEEDFACTOR, abort);
258  double speedDev = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_SPEEDDEV, abort);
259  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, vehicleTypeID, tag, SUMO_ATTR_COLOR, abort, false);
260  SUMOVehicleClass vClass = GNEAttributeCarrier::parseAttributeFromXML<SUMOVehicleClass>(attrs, vehicleTypeID, tag, SUMO_ATTR_VCLASS, abort);
261  std::string emissionClass = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_EMISSIONCLASS, abort);
262  SUMOVehicleShape shape = GNEAttributeCarrier::parseAttributeFromXML<SUMOVehicleShape>(attrs, vehicleTypeID, tag, SUMO_ATTR_GUISHAPE, abort);
263  double width = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_WIDTH, abort);
264  std::string filename = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_IMGFILE, abort);
265  double impatience = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_IMPATIENCE, abort);
266  std::string laneChangeModel = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_LANE_CHANGE_MODEL, abort);
267  std::string carFollowModel = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_CAR_FOLLOW_MODEL, abort);
268  int personCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, vehicleTypeID, tag, SUMO_ATTR_PERSON_CAPACITY, abort);
269  int containerCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, vehicleTypeID, tag, SUMO_ATTR_CONTAINER_CAPACITY, abort);
270  double boardingDuration = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_BOARDING_DURATION, abort);
271  double loadingDuration = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_LOADING_DURATION, abort);
272  std::string latAlignment = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, vehicleTypeID, tag, SUMO_ATTR_LATALIGNMENT, abort);
273  double minGapLat = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MINGAP_LAT, abort);
274  double maxSpeedLat = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, vehicleTypeID, tag, SUMO_ATTR_MAXSPEED_LAT, abort);
275  // Continue if all parameters were sucesfully loaded
276  if (!abort) {
277  // get calibrator parent
279  // check that all elements are valid
280  if (myViewNet->getNet()->retrieveCalibratorVehicleType(vehicleTypeID, false) != NULL) {
281  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + vehicleTypeID + "'.");
282  } else if (calibrator == NULL) {
283  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_CALIBRATOR) + ".");
284  } else {
285  // build calibrator vehicle type
286  buildCalibratorVehicleType(myViewNet, true, calibrator, vehicleTypeID, accel, decel, sigma, tau, length, minGap, maxSpeed, speedFactor, speedDev,
287  color, vClass, emissionClass, shape, width, filename, impatience, laneChangeModel, carFollowModel, personCapacity,
288  containerCapacity, boardingDuration, loadingDuration, latAlignment, minGapLat, maxSpeedLat);
289  }
290  }
291 }
292 
293 
294 void
296  bool abort = false;
297  // parse attributes of calibrator flows
298  std::string flowID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
299  std::string vehicleTypeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_TYPE, abort);
300  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_ROUTE, abort);
301  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, flowID, tag, SUMO_ATTR_COLOR, abort, false);
302  std::string departLane = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_DEPARTLANE, abort);
303  std::string departPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_DEPARTPOS, abort);
304  std::string departSpeed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_DEPARTSPEED, abort);
305  std::string arrivalLane = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_ARRIVALLANE, abort);
306  std::string arrivalPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_ARRIVALPOS, abort);
307  std::string arrivalSpeed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_ARRIVALSPEED, abort);
308  std::string line = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_LINE, abort);
309  int personNumber = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, flowID, tag, SUMO_ATTR_PERSON_NUMBER, abort);
310  int containerNumber = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, flowID, tag, SUMO_ATTR_CONTAINER_NUMBER, abort);
311  bool reroute = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, flowID, tag, SUMO_ATTR_REROUTE, abort);
312  std::string departPosLat = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_DEPARTPOS_LAT, abort);
313  std::string arrivalPosLat = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, flowID, tag, SUMO_ATTR_ARRIVALPOS_LAT, abort);
314  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, flowID, tag, SUMO_ATTR_BEGIN, abort);
315  double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, flowID, tag, SUMO_ATTR_END, abort);
316  double vehsPerHour = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, flowID, tag, SUMO_ATTR_VEHSPERHOUR, abort);
317  double period = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, flowID, tag, SUMO_ATTR_PERIOD, abort);
318  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, flowID, tag, SUMO_ATTR_PROB, abort);
319  int number = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, flowID, tag, SUMO_ATTR_NUMBER, abort);
320  // Continue if all parameters were sucesfully loaded
321  if (!abort) {
322  // obtain route, vehicle type and calibrator parent
324  GNECalibratorRoute* route = myViewNet->getNet()->retrieveCalibratorRoute(routeID, false);
325  GNECalibratorVehicleType* vtype = myViewNet->getNet()->retrieveCalibratorVehicleType(vehicleTypeID, false);
326  int flowType = getTypeOfFlowDistribution(flowID, vehsPerHour, period, probability);
327  // check that all elements are valid
328  if (myViewNet->getNet()->retrieveCalibratorFlow(flowID, false) != NULL) {
329  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " with ID = '" + flowID + "' cannot be created; Another " + toString(SUMO_TAG_FLOW) + " with the same ID was previously declared");
330  abort = true;
331  } else if (route == NULL) {
332  WRITE_WARNING(toString(SUMO_TAG_ROUTE) + " with ID = '" + routeID + "' cannot be created; their " + toString(SUMO_TAG_ROUTE) + " with ID = '" + routeID + "' doesn't exist");
333  abort = true;
334  } else if (vtype == NULL) {
335  WRITE_WARNING(toString(SUMO_TAG_VTYPE) + " with ID = '" + vehicleTypeID + "' cannot be created; their " + toString(SUMO_TAG_VTYPE) + " with ID = '" + vehicleTypeID + "' doesn't exist");
336  abort = true;
337  } else if (calibrator == NULL) {
338  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_CALIBRATOR) + ".");
339  } else {
340  buildCalibratorFlow(myViewNet, true, calibrator, flowID, route, vtype, color, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
341  line, personNumber, containerNumber, reroute, departPosLat, arrivalPosLat, begin, end, vehsPerHour, period, probability, number, flowType);
342  }
343  }
344 }
345 
346 
347 void
349  bool abort = false;
350  // parse attributes of VSS
351  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
352  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort, false);
353  std::string lanesIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANES, abort);
354  double posx = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_X, abort);
355  double posy = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_Y, abort);
356  // Due this additional can have childs, we need to reset myLastInsertedAdditionalParent
358  // Continue if all parameters were sucesfully loaded
359  if (!abort) {
360  // obtain lanes
361  std::vector<GNELane*> lanes;
362  if (GNEAttributeCarrier::checkGNELanesValid(myViewNet->getNet(), lanesIDs, true)) {
364  }
365  // check that all elements are valid
366  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
367  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
368  } else if ((lanes.size() > 0) && buildVariableSpeedSign(myViewNet, myUndoAdditionals, id, Position(posx, posy), lanes, file)) {
369  // set myLastInsertedAdditionalParent due this additional can have childs
370  myLastInsertedAdditionalParent = id;
371  }
372  }
373 }
374 
375 void
377  bool abort = false;
378  // Load step values
379  double time = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_TIME, abort);
380  double speed = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_SPEED, abort);
381  // Continue if all parameters were sucesfully loaded
382  if (!abort) {
383  // get Variable Speed Signal
385  // check that all parameters are valid
386  if (variableSpeedSign == NULL) {
387  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_VSS) + ".");
388  } else {
389  buildVariableSpeedSignStep(myViewNet, true, variableSpeedSign, time, speed);
390  }
391  }
392 }
393 
394 
395 void
397  bool abort = false;
398  // parse attributes of Rerouter
399  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
400  std::string edgesIDs = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_EDGES, abort);
401  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort, false);
402  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_PROB, abort);
403  bool off = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_OFF, abort);
404  double timeThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), abort, 0);
405  double posx = attrs.getOpt<double>(SUMO_ATTR_X, 0, abort, 0);
406  double posy = attrs.getOpt<double>(SUMO_ATTR_Y, 0, abort, 0);
407  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
409  // Continue if all parameters were sucesfully loaded
410  if (!abort) {
411  // obtain edges
412  std::vector<GNEEdge*> edges;
413  if (GNEAttributeCarrier::checkGNEEdgesValid(myViewNet->getNet(), edgesIDs, true)) {
415  }
416  // check that all elements are valid
417  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
418  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
419  } else if ((edgesIDs.size() > 0) && buildRerouter(myViewNet, myUndoAdditionals, id, Position(posx, posy), edges, probability, file, off, timeThreshold)) {
420  // set myLastInsertedAdditionalParent due this additional can have childs
421  myLastInsertedAdditionalParent = id;
422  }
423  }
424 }
425 
426 
427 void
429  bool abort = false;
430  // parse attributes of Rerouter
431  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_BEGIN, abort);
432  double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_END, abort);
433  // Continue if all parameters were sucesfully loaded
434  if (!abort) {
435  // obtain rerouter
437  // check that all elements are valid
438  if (rerouter == NULL) {
439  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_REROUTER) + ".");
440  } else if (buildRerouterInterval(myViewNet, true, rerouter, begin, end)) {
441  // set myLastInsertedAdditionalParent due this additional can have childs
442  myLastInsertedAdditionalParent = rerouter->getID() + "_" + toString(begin) + "_" + toString(end);
443  }
444  }
445 }
446 
447 
448 void
450  bool abort = false;
451  // parse attributes of Rerouter
452  std::string laneID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
453  SVCPermissions allow = GNEAttributeCarrier::parseAttributeFromXML<SVCPermissions>(attrs, "", tag, SUMO_ATTR_ALLOW, abort);
454  SVCPermissions disallow = GNEAttributeCarrier::parseAttributeFromXML<SVCPermissions>(attrs, "", tag, SUMO_ATTR_DISALLOW, abort);
455  // Continue if all parameters were sucesfully loaded
456  if (!abort) {
457  // obtain lane
458  GNELane* lane = myViewNet->getNet()->retrieveLane(laneID, false, true);
460  // check that all elements are valid
461  if (lane == NULL) {
462  WRITE_WARNING("The lane '" + laneID + "' to use within the " + toString(tag) + " is not known.");
463  } else if (rerouterInterval == NULL) {
464  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_INTERVAL) + ".");
465  } else {
466  buildClosingLaneReroute(myViewNet, true, rerouterInterval, lane, allow, disallow);
467  }
468  }
469 }
470 
471 
472 void
474  bool abort = false;
475  // parse attributes of Rerouter
476  std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
477  SVCPermissions allow = GNEAttributeCarrier::parseAttributeFromXML<SVCPermissions>(attrs, "", tag, SUMO_ATTR_ALLOW, abort);
478  SVCPermissions disallow = GNEAttributeCarrier::parseAttributeFromXML<SVCPermissions>(attrs, "", tag, SUMO_ATTR_DISALLOW, abort);
479  // Continue if all parameters were sucesfully loaded
480  if (!abort) {
481  // obtain edge
482  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
484  // check that all elements are valid
485  if (edge == NULL) {
486  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
487  } else if (rerouterInterval == NULL) {
488  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_INTERVAL) + ".");
489  } else {
490  buildClosingReroute(myViewNet, true, rerouterInterval, edge, allow, disallow);
491  }
492  }
493 }
494 
495 
496 void
498  bool abort = false;
499  // parse attributes of Rerouter
500  std::string edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
501  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_PROB, abort);
502  // Continue if all parameters were sucesfully loaded
503  if (!abort) {
504  // obtain edge
505  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
507  // check that all elements are valid
508  if (edge == NULL) {
509  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(tag) + " is not known.");
510  } else if (rerouterInterval == NULL) {
511  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_INTERVAL) + ".");
512  } else {
513  builDestProbReroute(myViewNet, true, rerouterInterval, edge, probability);
514  }
515  }
516 }
517 
518 
519 void
521  bool abort = false;
522  // parse attributes of Rerouter
523  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
524  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_PROB, abort);
525  // Continue if all parameters were sucesfully loaded
526  if (!abort) {
527  // obtain edge
529  // check that all elements are valid
530  if (rerouterInterval == NULL) {
531  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_INTERVAL) + ".");
532  } else {
533  buildRouteProbReroute(myViewNet, true, rerouterInterval, routeID, probability);
534  }
535  }
536 }
537 
538 
539 void
541  bool abort = false;
542  // parse attributes of bus stop
543  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
544  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
545  double startPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
546  double endPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
547  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort, false);
548  std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id, tag, SUMO_ATTR_LINES, abort, false);
549  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort, false);
550  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
552  // Continue if all parameters were sucesfully loaded
553  if (!abort) {
554  // get pointer to lane
555  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
556  // check that all elements are valid
557  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
558  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
559  } else if (lane == NULL) {
560  // Write error if lane isn't valid
561  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
562  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getLaneParametricLength(), POSITION_EPS, friendlyPosition)) {
563  // Write error if position isn't valid
564  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
565  } else {
566  buildBusStop(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, lines, friendlyPosition);
567  }
568  }
569 }
570 
571 
572 void
574  bool abort = false;
575  // parse attributes of container stop
576  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
577  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
578  double startPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
579  double endPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
580  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort, false);
581  std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id, tag, SUMO_ATTR_LINES, abort, false);
582  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort, false);
583  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
585  // Continue if all parameters were sucesfully loaded
586  if (!abort) {
587  // get pointer to lane
588  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
589  // check that all elements are valid
590  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
591  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
592  } else if (lane == NULL) {
593  // Write error if lane isn't valid
594  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
595  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getLaneParametricLength(), POSITION_EPS, friendlyPosition)) {
596  // write error if position isn't valid
597  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
598  } else {
599  buildContainerStop(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, lines, friendlyPosition);
600  }
601  }
602 }
603 
604 
605 void
607  bool abort = false;
608  // parse attributes of charging station
609  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
610  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
611  double startPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_STARTPOS, abort);
612  double endPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_ENDPOS, abort);
613  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_NAME, abort, false);
614  double chargingPower = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_CHARGINGPOWER, abort);
615  double efficiency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_EFFICIENCY, abort);
616  bool chargeInTransit = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_CHARGEINTRANSIT, abort);
617  double chargeDelay = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_CHARGEDELAY, abort);
618  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort, false);
619  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
621  // Continue if all parameters were sucesfully loaded
622  if (!abort) {
623  // get pointer to lane
624  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
625  // check that all elements are valid
626  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
627  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
628  } else if (lane == NULL) {
629  // Write error if lane isn't valid
630  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
631  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getLaneParametricLength(), POSITION_EPS, friendlyPosition)) {
632  // write error if position isn't valid
633  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
634  } else {
635  buildChargingStation(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition);
636  }
637  }
638 }
639 
640 
641 void
643  bool abort = false;
644  // due there is two differents calibrators, has to be parsed in a different way
645  std::string edgeID, laneId, id;
646  SumoXMLTag typeOfCalibrator = tag;
647  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
649  // change tag depending of XML parmeters
650  if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
651  typeOfCalibrator = SUMO_TAG_CALIBRATOR;
652  id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", typeOfCalibrator, SUMO_ATTR_ID, abort);
653  edgeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_EDGE, abort, false);
654  std::string outfile = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_OUTPUT, abort, false);
655  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_POSITION, abort);
656  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_FREQUENCY, abort);
657  // std::string routeProbe = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_ROUTEPROBE, abort); Currently routeProbe not used
658  // Due this additional can have childs, we need to reset myLastInsertedAdditionalParent
660  // Continue if all parameters were sucesfully loaded
661  if (!abort) {
662  // get pointer and edge
663  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeID, false);
664  // check that all elements are valid
665  if (myViewNet->getNet()->getAdditional(typeOfCalibrator, id) != NULL) {
666  WRITE_WARNING("There is another " + toString(typeOfCalibrator) + " with the same ID='" + id + "'.");
667  } else if (edge == NULL) {
668  WRITE_WARNING("The edge '" + edgeID + "' to use within the " + toString(typeOfCalibrator) + " '" + id + "' is not known.");
669  } else if (buildCalibrator(myViewNet, myUndoAdditionals, id, edge, position, outfile, freq)) {
670  // set myLastInsertedAdditionalParent due this additional can have childs
671  myLastInsertedAdditionalParent = id;
672  }
673  }
674  } else if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
675  typeOfCalibrator = SUMO_TAG_LANECALIBRATOR;
676  id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", typeOfCalibrator, SUMO_ATTR_ID, abort);
677  laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_LANE, abort, false);
678  std::string outfile = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, typeOfCalibrator, SUMO_ATTR_OUTPUT, abort, false);
679  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_POSITION, abort);
680  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, typeOfCalibrator, SUMO_ATTR_FREQUENCY, abort);
681  // std::string routeProbe = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_ROUTEPROBE, abort); Currently routeProbe not used
682  // Due this additional can have childs, we need to reset myLastInsertedAdditionalParent
684  // Continue if all parameters were sucesfully loaded
685  if (!abort) {
686  // get pointer to lane
687  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
688  // check that all elements are valid
689  if (myViewNet->getNet()->getAdditional(typeOfCalibrator, id) != NULL) {
690  WRITE_WARNING("There is another " + toString(typeOfCalibrator) + " with the same ID='" + id + "'.");
691  } else if (lane == NULL) {
692  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(typeOfCalibrator) + " '" + id + "' is not known.");
693  } else if (buildCalibrator(myViewNet, myUndoAdditionals, id, lane, position, outfile, freq)) {
694  // set myLastInsertedAdditionalParent due this additional can have childs
695  myLastInsertedAdditionalParent = id;
696  }
697  }
698  } else {
699  WRITE_WARNING("additional " + toString(tag) + " must have either a lane or an edge attribute.");
700  }
701 }
702 
703 
704 void
706  bool abort = false;
707  // parse attributes of E1
708  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
709  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
710  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
711  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
712  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort, false);
713  std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_VTYPES, abort, false);
714  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
715  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
717  // Continue if all parameters were sucesfully loaded
718  if (!abort) {
719  // get pointer to lane
720  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
721  // check that all elements are valid
722  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
723  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
724  } else if (lane == NULL) {
725  // Write error if lane isn't valid
726  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
727  } else if (!checkAndFixDetectorPositionPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
728  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
729  } else {
730  buildDetectorE1(myViewNet, myUndoAdditionals, id, lane, position, frequency, file, vehicleTypes, friendlyPos);
731  }
732  }
733 }
734 
735 
736 void
738  bool abort = false;
739  // parse attributes of E2
740  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
741  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_LANE, abort);
742  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_POSITION, abort);
743  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
744  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort, false);
745  double length = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_LENGTH, abort);
746  double haltingTimeThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
747  double haltingSpeedThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
748  double jamDistThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_JAM_DIST_THRESHOLD, abort);
749  bool cont = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_CONT, abort);
750  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id, tag, SUMO_ATTR_FRIENDLY_POS, abort);
751  // myLastInsertedAdditionalParent must be empty because this additional cannot be child of another additional
753  // Continue if all parameters were sucesfully loaded
754  if (!abort) {
755  // get pointer to lane
756  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
757  // check that all elements are valid
758  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
759  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
760  } else if (lane == NULL) {
761  // Write error if lane isn't valid
762  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
763  } else if (!fixE2DetectorPositionPosition(position, length, lane->getLaneShapeLength(), friendlyPos)) {
764  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
765  } else {
766  buildDetectorE2(myViewNet, myUndoAdditionals, id, lane, position, length, frequency, file, cont, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, friendlyPos);
767  }
768  }
769 }
770 
771 
772 void
774  bool abort = false;
775  // parse attributes of E3
776  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_ID, abort);
777  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_FREQUENCY, abort);
778  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id, tag, SUMO_ATTR_FILE, abort, false);
779  double haltingTimeThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
780  double haltingSpeedThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
781  double posx = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_X, abort);
782  double posy = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id, tag, SUMO_ATTR_Y, abort);
783  // Due this additional can have childs, we need to reset myLastInsertedAdditionalParent
785  // Continue if all parameters were sucesfully loaded
786  if (!abort) {
787  // check that all elements are valid
788  if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
789  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
790  } else if (buildDetectorE3(myViewNet, true, id, Position(posx, posy), frequency, file, haltingTimeThreshold, haltingSpeedThreshold)) {
791  // set myLastInsertedAdditionalParent due this additional can have childs and was sucesfully created
792  myLastInsertedAdditionalParent = id;
793  }
794  }
795 }
796 
797 
798 void
800  bool abort = false;
801  // parse attributes of Entry
802  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LANE, abort);
803  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_POSITION, abort);
804  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_FRIENDLY_POS, abort);
805  // Check if parsing of parameters was correct
806  if (!abort) {
807  // get lane and E3 parent
808  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
810  // check that all parameters are valid
811  if (lane == NULL) {
812  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
813  } else if (E3Parent == NULL) {
814  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_E3DETECTOR) + ".");
815  } else if (!checkAndFixDetectorPositionPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
816  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
817  } else {
818  buildDetectorEntry(myViewNet, myUndoAdditionals, E3Parent, lane, position, friendlyPos);
819  }
820  }
821 }
822 
823 
824 void
826  bool abort = false;
827  // parse attributes of Exit
828  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, "", tag, SUMO_ATTR_LANE, abort);
829  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, "", tag, SUMO_ATTR_POSITION, abort);
830  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, "", tag, SUMO_ATTR_FRIENDLY_POS, abort);
831  // Check if parsing of parameters was correct
832  if (!abort) {
833  // get lane and E3 parent
834  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false, true);
836  // check that all parameters are valid
837  if (lane == NULL) {
838  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
839  } else if (E3Parent == NULL) {
840  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_E3DETECTOR) + ".");
841  } else if (!checkAndFixDetectorPositionPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
842  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
843  } else {
844  buildDetectorExit(myViewNet, myUndoAdditionals, E3Parent, lane, position, friendlyPos);
845  }
846  }
847 }
848 
849 
850 bool
851 GNEAdditionalHandler::buildAdditional(GNEViewNet* viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map<SumoXMLAttr, std::string> values) {
852  // create additional depending of the tag
853  switch (tag) {
854  case SUMO_TAG_BUS_STOP: {
855  // obtain specify attributes of busStop
856  std::string id = values[SUMO_ATTR_ID];
857  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
858  double startPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTPOS]);
859  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
860  std::string name = values[SUMO_ATTR_NAME];
861  std::vector<std::string> lines = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LINES]);
862  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
863  // Build busStop
864  if (lane) {
865  return buildBusStop(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, lines, friendlyPos);
866  } else {
867  return false;
868  }
869  }
871  // obtain specify attributes of containerStop
872  std::string id = values[SUMO_ATTR_ID];
873  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
874  double startPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTPOS]);
875  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
876  std::string name = values[SUMO_ATTR_NAME];
877  std::vector<std::string> lines = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LINES]);
878  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
879  // Build containerStop
880  if (lane) {
881  return buildContainerStop(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, lines, friendlyPos);
882  } else {
883  return false;
884  }
885  }
887  // obtain specify attributes of chargingStation
888  std::string id = values[SUMO_ATTR_ID];
889  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
890  double startPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTPOS]);
891  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
892  std::string name = values[SUMO_ATTR_NAME];
893  double chargingPower = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_CHARGINGPOWER]);
894  double efficiency = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_EFFICIENCY]);
895  bool chargeInTransit = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CHARGEINTRANSIT]);
896  double chargeDelay = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_CHARGEDELAY]);
897  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
898  // Build chargingStation
899  if (lane) {
900  return buildChargingStation(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPos);
901  } else {
902  return false;
903  }
904  }
905  case SUMO_TAG_E1DETECTOR: {
906  // obtain specify attributes of detector E1
907  std::string id = values[SUMO_ATTR_ID];
908  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
909  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
910  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
911  std::string filename = values[SUMO_ATTR_FILE];
912  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
913  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
914  // Build detector E1
915  if (lane) {
916  return buildDetectorE1(viewNet, allowUndoRedo, id, lane, pos, freq, filename, vehicleTypes, friendlyPos);
917  } else {
918  return false;
919  }
920  }
921  case SUMO_TAG_E2DETECTOR: {
922  // obtain specify attributes of detector E2
923  std::string id = values[SUMO_ATTR_ID];
924  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
925  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
926  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
927  double length = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_LENGTH]);
928  std::string filename = values[SUMO_ATTR_FILE];
929  bool cont = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CONT]);
930  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
931  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
932  double jamThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_JAM_DIST_THRESHOLD]);
933  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
934  // Build detector E2
935  if (lane) {
936  return buildDetectorE2(viewNet, allowUndoRedo, id, lane, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold, friendlyPos);
937  } else {
938  return false;
939  }
940  }
941  case SUMO_TAG_E3DETECTOR: {
942  // obtain specify attributes of detector E3
943  bool ok;
944  std::string id = values[SUMO_ATTR_ID];
945  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
946  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
947  std::string filename = values[SUMO_ATTR_FILE];
948  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
949  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
950  // Build detector E3
951  if (pos.size() == 1) {
952  return buildDetectorE3(viewNet, allowUndoRedo, id, pos[0], freq, filename, timeThreshold, speedThreshold);
953  } else {
954  return false;
955  }
956  }
957  case SUMO_TAG_DET_ENTRY: {
958  // obtain specify attributes of detector Entry
959  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
960  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
961  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
962  GNEDetectorE3* E3 = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->retrieveAdditional(values[GNE_ATTR_PARENT]));
963  // Build detector Entry
964  if (lane && E3) {
965  return buildDetectorEntry(viewNet, allowUndoRedo, E3, lane, pos, friendlyPos);
966  } else {
967  return false;
968  }
969  }
970  case SUMO_TAG_DET_EXIT: {
971  // obtain specify attributes of Detector Exit
972  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
973  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
974  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
975  GNEDetectorE3* E3 = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->retrieveAdditional(values[GNE_ATTR_PARENT]));
976  // Build detector Exit
977  if (lane && E3) {
978  return buildDetectorExit(viewNet, allowUndoRedo, E3, lane, pos, friendlyPos);
979  } else {
980  return false;
981  }
982  }
983  case SUMO_TAG_VSS: {
984  // obtain specify attributes of variable speed signal
985  std::string id = values[SUMO_ATTR_ID];
986  bool ok;
987  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
988  std::vector<GNELane*> lanes = GNEAttributeCarrier::parseGNELanes(viewNet->getNet(), values[SUMO_ATTR_LANES]);
989  // get rest of parameters
990  std::string file = values[SUMO_ATTR_FILE];
991  // build VSS
992  if (pos.size() == 1) {
993  return buildVariableSpeedSign(viewNet, allowUndoRedo, id, pos[0], lanes, file);
994  } else {
995  return false;
996  }
997  }
998  case SUMO_TAG_CALIBRATOR: {
999  // obtain specify attributes of calibrator
1000  std::string id = values[SUMO_ATTR_ID];
1001  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1002  // get rest of parameters
1003  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1004  std::string outfile = values[SUMO_ATTR_OUTPUT];
1005  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1006  // Build calibrator edge
1007  if (edge) {
1008  return buildCalibrator(viewNet, allowUndoRedo, id, edge, pos, outfile, freq);
1009  } else {
1010  return false;
1011  }
1012  }
1013  case SUMO_TAG_LANECALIBRATOR: {
1014  // obtain specify attributes of calibrator
1015  std::string id = values[SUMO_ATTR_ID];
1016  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
1017  // get rest of parameters
1018  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
1019  std::string outfile = values[SUMO_ATTR_OUTPUT];
1020  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1021  // Build calibrator lane
1022  if (lane) {
1023  return buildCalibrator(viewNet, allowUndoRedo, id, lane, pos, outfile, freq);
1024  } else {
1025  return false;
1026  }
1027  }
1028  case SUMO_TAG_REROUTER: {
1029  // obtain specify attributes of rerouter
1030  std::string id = values[SUMO_ATTR_ID];
1031  bool ok;
1032  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
1033  std::vector<GNEEdge*> edges = GNEAttributeCarrier::parseGNEEdges(viewNet->getNet(), values[SUMO_ATTR_EDGES]);
1034  // Get rest of parameters
1035  bool off = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_OFF]);
1036  double prob = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_PROB]);
1037  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
1038  std::string file = values[SUMO_ATTR_FILE];
1039  // Build rerouter
1040  if (pos.size() == 1) {
1041  return buildRerouter(viewNet, allowUndoRedo, id, pos[0], edges, prob, file, off, timeThreshold);
1042  } else {
1043  return false;
1044  }
1045  }
1046  case SUMO_TAG_ROUTEPROBE: {
1047  // obtain specify attributes of RouteProbe
1048  std::string id = values[SUMO_ATTR_ID];
1049  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1050  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
1051  std::string filename = values[SUMO_ATTR_FILE];
1052  double begin = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_BEGIN]);
1053  // Build RouteProbe
1054  if (edge) {
1055  return buildRouteProbe(viewNet, allowUndoRedo, id, edge, freq, filename, begin);
1056  } else {
1057  return false;
1058  }
1059  }
1060  case SUMO_TAG_VAPORIZER: {
1061  // obtain specify attributes of vaporizer
1062  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1063  double startTime = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTTIME]);
1064  double end = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_END]);
1065  // Build RouteProbe
1066  if (edge) {
1067  return buildVaporizer(viewNet, allowUndoRedo, edge, startTime, end);
1068  } else {
1069  return false;
1070  }
1071  }
1072  default:
1073  return false;
1074  }
1075 }
1076 
1077 
1078 bool
1079 GNEAdditionalHandler::buildBusStop(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double startPos, double endPos, const std::string& name, const std::vector<std::string>& lines, bool friendlyPosition) {
1080  if (viewNet->getNet()->getAdditional(SUMO_TAG_BUS_STOP, id) == NULL) {
1081  GNEBusStop* busStop = new GNEBusStop(id, lane, viewNet, startPos, endPos, name, lines, friendlyPosition);
1082  if (allowUndoRedo) {
1083  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_BUS_STOP));
1084  viewNet->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
1085  viewNet->getUndoList()->p_end();
1086  } else {
1087  viewNet->getNet()->insertAdditional(busStop);
1088  lane->addAdditionalChild(busStop);
1089  }
1090  return true;
1091  } else {
1092  throw ProcessError("Could not build " + toString(SUMO_TAG_BUS_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1093  }
1094 }
1095 
1096 
1097 bool
1098 GNEAdditionalHandler::buildContainerStop(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double startPos, double endPos, const std::string& name, const std::vector<std::string>& lines, bool friendlyPosition) {
1099  if (viewNet->getNet()->getAdditional(SUMO_TAG_CONTAINER_STOP, id) == NULL) {
1100  GNEContainerStop* containerStop = new GNEContainerStop(id, lane, viewNet, startPos, endPos, name, lines, friendlyPosition);
1101  if (allowUndoRedo) {
1102  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CONTAINER_STOP));
1103  viewNet->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
1104  viewNet->getUndoList()->p_end();
1105  } else {
1106  viewNet->getNet()->insertAdditional(containerStop);
1107  lane->addAdditionalChild(containerStop);
1108  }
1109  return true;
1110  } else {
1111  throw ProcessError("Could not build " + toString(SUMO_TAG_CONTAINER_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1112  }
1113 }
1114 
1115 
1116 bool
1117 GNEAdditionalHandler::buildChargingStation(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double startPos, double endPos, const std::string& name, double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay, bool friendlyPosition) {
1118  if (viewNet->getNet()->getAdditional(SUMO_TAG_CHARGING_STATION, id) == NULL) {
1119  GNEChargingStation* chargingStation = new GNEChargingStation(id, lane, viewNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition);
1120  if (allowUndoRedo) {
1121  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CHARGING_STATION));
1122  viewNet->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
1123  viewNet->getUndoList()->p_end();
1124  } else {
1125  viewNet->getNet()->insertAdditional(chargingStation);
1126  lane->addAdditionalChild(chargingStation);
1127  }
1128  return true;
1129  } else {
1130  throw ProcessError("Could not build " + toString(SUMO_TAG_CHARGING_STATION) + " with ID '" + id + "' in netedit; probably declared twice.");
1131  }
1132 }
1133 
1134 
1135 bool
1136 GNEAdditionalHandler::buildDetectorE1(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double freq, const std::string& filename, const std::string& vehicleTypes, bool friendlyPos) {
1137  if (viewNet->getNet()->getAdditional(SUMO_TAG_E1DETECTOR, id) == NULL) {
1138  GNEDetectorE1* detectorE1 = new GNEDetectorE1(id, lane, viewNet, pos, freq, filename, vehicleTypes, friendlyPos);
1139  if (allowUndoRedo) {
1140  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E1DETECTOR));
1141  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
1142  viewNet->getUndoList()->p_end();
1143  } else {
1144  viewNet->getNet()->insertAdditional(detectorE1);
1145  lane->addAdditionalChild(detectorE1);
1146  }
1147  return true;
1148  } else {
1149  throw ProcessError("Could not build " + toString(SUMO_TAG_E1DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1150  }
1151 }
1152 
1153 
1154 bool
1155 GNEAdditionalHandler::buildDetectorE2(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double length, double freq, const std::string& filename,
1156  bool cont, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos) {
1157  if (viewNet->getNet()->getAdditional(SUMO_TAG_E2DETECTOR, id) == NULL) {
1158  GNEDetectorE2* detectorE2 = new GNEDetectorE2(id, lane, viewNet, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold, friendlyPos);
1159  if (allowUndoRedo) {
1160  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E2DETECTOR));
1161  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
1162  viewNet->getUndoList()->p_end();
1163  } else {
1164  viewNet->getNet()->insertAdditional(detectorE2);
1165  lane->addAdditionalChild(detectorE2);
1166  }
1167  return true;
1168  } else {
1169  throw ProcessError("Could not build " + toString(SUMO_TAG_E2DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1170  }
1171 }
1172 
1173 
1174 bool
1175 GNEAdditionalHandler::buildDetectorE3(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, double freq, const std::string& filename, const double timeThreshold, double speedThreshold) {
1176  if (viewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, id) == NULL) {
1177  GNEDetectorE3* detectorE3 = new GNEDetectorE3(id, viewNet, pos, freq, filename, timeThreshold, speedThreshold);
1178  if (allowUndoRedo) {
1179  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
1180  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE3, true), true);
1181  viewNet->getUndoList()->p_end();
1182  } else {
1183  viewNet->getNet()->insertAdditional(detectorE3);
1184  }
1185  return true;
1186  } else {
1187  throw ProcessError("Could not build " + toString(SUMO_TAG_E3DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1188  }
1189 }
1190 
1191 
1192 bool
1193 GNEAdditionalHandler::buildDetectorEntry(GNEViewNet* viewNet, bool allowUndoRedo, GNEDetectorE3* E3Parent, GNELane* lane, double pos, bool friendlyPos) {
1194  // Check if Detector E3 parent and lane is correct
1195  if (lane == NULL) {
1196  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1197  } else if (E3Parent == NULL) {
1198  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
1199  } else {
1200  GNEDetectorEntry* entry = new GNEDetectorEntry(viewNet, E3Parent, lane, pos, friendlyPos);
1201  if (allowUndoRedo) {
1202  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_ENTRY));
1203  viewNet->getUndoList()->add(new GNEChange_Additional(entry, true), true);
1204  viewNet->getUndoList()->p_end();
1205  } else {
1206  viewNet->getNet()->insertAdditional(entry);
1207  lane->addAdditionalChild(entry);
1208  E3Parent->addAdditionalChild(entry);
1209  }
1210  return true;
1211  }
1212 }
1213 
1214 
1215 bool
1216 GNEAdditionalHandler::buildDetectorExit(GNEViewNet* viewNet, bool allowUndoRedo, GNEDetectorE3* E3Parent, GNELane* lane, double pos, bool friendlyPos) {
1217  // Check if Detector E3 parent and lane is correct
1218  if (lane == NULL) {
1219  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1220  } else if (E3Parent == NULL) {
1221  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
1222  } else {
1223  GNEDetectorExit* exit = new GNEDetectorExit(viewNet, E3Parent, lane, pos, friendlyPos);
1224  if (allowUndoRedo) {
1225  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_EXIT));
1226  viewNet->getUndoList()->add(new GNEChange_Additional(exit, true), true);
1227  viewNet->getUndoList()->p_end();
1228  } else {
1229  viewNet->getNet()->insertAdditional(exit);
1230  lane->addAdditionalChild(exit);
1231  E3Parent->addAdditionalChild(exit);
1232  }
1233  return true;
1234  }
1235 }
1236 
1237 
1238 bool
1239 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, const std::string& outfile, const double freq) {
1240  if (viewNet->getNet()->getAdditional(SUMO_TAG_CALIBRATOR, id) == NULL) {
1241  GNECalibrator* calibrator = new GNECalibrator(id, viewNet, lane, pos, freq, outfile);
1242  if (allowUndoRedo) {
1243  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
1244  viewNet->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
1245  viewNet->getUndoList()->p_end();
1246  // center after creation
1247  viewNet->centerTo(calibrator->getGlID(), false);
1248  } else {
1249  viewNet->getNet()->insertAdditional(calibrator);
1250  lane->addAdditionalChild(calibrator);
1251  }
1252  return true;
1253  } else {
1254  throw ProcessError("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1255  }
1256 }
1257 
1258 
1259 bool
1260 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNEEdge* edge, double pos, const std::string& outfile, const double freq) {
1261  if (viewNet->getNet()->getAdditional(SUMO_TAG_CALIBRATOR, id) == NULL) {
1262  GNECalibrator* calibrator = new GNECalibrator(id, viewNet, edge, pos, freq, outfile);
1263  if (allowUndoRedo) {
1264  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
1265  viewNet->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
1266  viewNet->getUndoList()->p_end();
1267  // center after creation
1268  viewNet->centerTo(calibrator->getGlID(), false);
1269  } else {
1270  viewNet->getNet()->insertAdditional(calibrator);
1271  edge->addAdditionalChild(calibrator);
1272  }
1273  return true;
1274  } else {
1275  throw ProcessError("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1276  }
1277 }
1278 
1279 
1280 bool
1281 GNEAdditionalHandler::buildCalibratorRoute(GNEViewNet* viewNet, bool allowUndoRedo, GNECalibrator* calibratorParent, const std::string& routeID, const std::vector<GNEEdge*>& edges, const RGBColor& color) {
1282  if (viewNet->getNet()->retrieveCalibratorRoute(routeID, false) == NULL) {
1283  // create route and add it to calibrator parent
1284  GNECalibratorRoute* route = new GNECalibratorRoute(calibratorParent, routeID, edges, color);
1285  if (allowUndoRedo) {
1286  viewNet->getUndoList()->p_begin("add " + toString(route->getTag()));
1287  viewNet->getUndoList()->add(new GNEChange_CalibratorItem(route, true), true);
1288  viewNet->getUndoList()->p_end();
1289  return true;
1290  } else {
1291  viewNet->getNet()->insertCalibratorRoute(route);
1292  calibratorParent->addCalibratorRoute(route);
1293  }
1294  return true;
1295  } else {
1296  throw ProcessError("Could not build " + toString(SUMO_TAG_ROUTE) + " with ID '" + routeID + "' in netedit; probably declared twice.");
1297  }
1298 
1299 }
1300 
1301 
1302 bool
1303 GNEAdditionalHandler::buildCalibratorVehicleType(GNEViewNet* viewNet, bool allowUndoRedo, GNECalibrator* calibratorParent, std::string vehicleTypeID,
1304  double accel, double decel, double sigma, double tau, double length, double minGap, double maxSpeed,
1305  double speedFactor, double speedDev, const RGBColor& color, SUMOVehicleClass vClass, const std::string& emissionClass,
1306  SUMOVehicleShape shape, double width, const std::string& filename, double impatience, const std::string& laneChangeModel,
1307  const std::string& carFollowModel, int personCapacity, int containerCapacity, double boardingDuration,
1308  double loadingDuration, const std::string& latAlignment, double minGapLat, double maxSpeedLat) {
1309  if (viewNet->getNet()->retrieveCalibratorVehicleType(vehicleTypeID, false) == NULL) {
1310  // create vehicle type and add it to calibrator parent
1311  GNECalibratorVehicleType* vType = new GNECalibratorVehicleType(calibratorParent, vehicleTypeID, accel, decel, sigma, tau, length, minGap, maxSpeed,
1312  speedFactor, speedDev, color, vClass, emissionClass, shape, width, filename, impatience,
1313  laneChangeModel, carFollowModel, personCapacity, containerCapacity, boardingDuration,
1314  loadingDuration, latAlignment, minGapLat, maxSpeedLat);
1315  if (allowUndoRedo) {
1316  viewNet->getUndoList()->p_begin("add " + toString(vType->getTag()));
1317  viewNet->getUndoList()->add(new GNEChange_CalibratorItem(vType, true), true);
1318  viewNet->getUndoList()->p_end();
1319  return true;
1320  } else {
1321  viewNet->getNet()->insertCalibratorVehicleType(vType);
1322  calibratorParent->addCalibratorVehicleType(vType);
1323  }
1324  return true;
1325  } else {
1326  throw ProcessError("Could not build " + toString(SUMO_TAG_VTYPE) + " with ID '" + vehicleTypeID + "' in netedit; probably declared twice.");
1327  }
1328 }
1329 
1330 
1331 bool
1332 GNEAdditionalHandler::buildCalibratorFlow(GNEViewNet* viewNet, bool allowUndoRedo, GNECalibrator* calibratorParent,
1333  const std::string& flowID, GNECalibratorRoute* route, GNECalibratorVehicleType* vtype, const RGBColor& color,
1334  const std::string& departLane, const std::string& departPos, const std::string& departSpeed, const std::string& arrivalLane,
1335  const std::string& arrivalPos, const std::string& arrivalSpeed, const std::string& line, int personNumber, int containerNumber, bool reroute,
1336  const std::string& departPosLat, const std::string& arrivalPosLat, double begin, double end, double vehsPerHour, double period,
1337  double probability, int number, int flowType) {
1338 
1339  if (viewNet->getNet()->retrieveCalibratorFlow(flowID, false) == NULL) {
1340  // create Flow and add it to calibrator parent
1341  GNECalibratorFlow* flow = new GNECalibratorFlow(calibratorParent, flowID, vtype, route, color, departLane, departPos, departSpeed,
1342  arrivalLane, arrivalPos, arrivalSpeed, line, personNumber, containerNumber, reroute,
1343  departPosLat, arrivalPosLat, begin, end, vehsPerHour, period, probability, number, static_cast<GNECalibratorFlow::TypeOfFlow>(flowType));
1344  if (allowUndoRedo) {
1345  viewNet->getUndoList()->p_begin("add " + toString(flow->getTag()));
1346  viewNet->getUndoList()->add(new GNEChange_CalibratorItem(flow, true), true);
1347  viewNet->getUndoList()->p_end();
1348  return true;
1349  } else {
1350  viewNet->getNet()->insertCalibratorFlow(flow);
1351  calibratorParent->addCalibratorFlow(flow);
1352  }
1353  return true;
1354  } else {
1355  throw ProcessError("Could not build " + toString(SUMO_TAG_FLOW) + " with ID '" + flowID + "' in netedit; probably declared twice.");
1356  }
1357 }
1358 
1359 
1360 bool
1361 GNEAdditionalHandler::buildRerouter(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNEEdge*>& edges, double prob, const std::string& file, bool off, double timeThreshold) {
1362  if (viewNet->getNet()->getAdditional(SUMO_TAG_REROUTER, id) == NULL) {
1363  GNERerouter* rerouter = new GNERerouter(id, viewNet, pos, edges, file, prob, off, timeThreshold);
1364  if (allowUndoRedo) {
1365  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_REROUTER));
1366  viewNet->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
1367  viewNet->getUndoList()->p_end();
1368  } else {
1369  viewNet->getNet()->insertAdditional(rerouter);
1370  // add this rerouter as parent of all edges
1371  for (auto i : edges) {
1372  i->addAdditionalParent(rerouter);
1373  }
1374  }
1375  return true;
1376  } else {
1377  throw ProcessError("Could not build " + toString(SUMO_TAG_REROUTER) + " with ID '" + id + "' in netedit; probably declared twice.");
1378  }
1379 }
1380 
1381 
1382 bool
1383 GNEAdditionalHandler::buildRerouterInterval(GNEViewNet* viewNet, bool allowUndoRedo, GNERerouter* rerouterParent, double begin, double end) {
1384  // first create rerouter interval and add it into rerouter parent
1385  GNERerouterInterval* rerouterInterval = new GNERerouterInterval(rerouterParent, begin, end);
1386  rerouterParent->addRerouterInterval(rerouterInterval);
1387  // remove it if there is overlapping with another intervals
1388  if (rerouterParent->getNumberOfOverlappedIntervals() == 0) {
1389  // if allowUndoRedo is enabled, remove it and add it again using GNEChange_RerouterItem
1390  if (allowUndoRedo) {
1391  rerouterParent->removeRerouterInterval(rerouterInterval);
1392  viewNet->getUndoList()->p_begin("add " + toString(rerouterInterval->getTag()));
1393  viewNet->getUndoList()->add(new GNEChange_RerouterItem(rerouterInterval, true), true);
1394  viewNet->getUndoList()->p_end();
1395  }
1396  return true;
1397  } else {
1398  // delete created rerouter interval and throw exception
1399  rerouterParent->removeRerouterInterval(rerouterInterval);
1400  delete rerouterInterval;
1401  throw ProcessError("Could not build " + toString(SUMO_TAG_INTERVAL) + " with begin '" + toString(begin) + "' and '" + toString(end) + "' in '" + rerouterParent->getID() + "' due overlapping.");
1402  }
1403 }
1404 
1405 
1406 bool
1407 GNEAdditionalHandler::buildClosingLaneReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNERerouterInterval* rerouterIntervalParent, GNELane* closedLane, SVCPermissions allowedVehicles, SVCPermissions disallowedVehicles) {
1408  // create closing lane reorute
1409  GNEClosingLaneReroute* closingLaneReroute = new GNEClosingLaneReroute(rerouterIntervalParent, closedLane, allowedVehicles, disallowedVehicles);
1410  // add it to interval parent depending of allowUndoRedo
1411  if (allowUndoRedo) {
1412  viewNet->getUndoList()->p_begin("add " + toString(closingLaneReroute->getTag()));
1413  viewNet->getUndoList()->add(new GNEChange_RerouterItem(closingLaneReroute, true), true);
1414  viewNet->getUndoList()->p_end();
1415  } else {
1416  rerouterIntervalParent->addClosingLaneReroute(closingLaneReroute);
1417  }
1418  return true;
1419 }
1420 
1421 
1422 bool
1423 GNEAdditionalHandler::buildClosingReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNERerouterInterval* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions allowedVehicles, SVCPermissions disallowedVehicles) {
1424  // create closing reroute
1425  GNEClosingReroute* closingReroute = new GNEClosingReroute(rerouterIntervalParent, closedEdge, allowedVehicles, disallowedVehicles);
1426  // add it to interval parent depending of allowUndoRedo
1427  if (allowUndoRedo) {
1428  viewNet->getUndoList()->p_begin("add " + toString(closingReroute->getTag()));
1429  viewNet->getUndoList()->add(new GNEChange_RerouterItem(closingReroute, true), true);
1430  viewNet->getUndoList()->p_end();
1431  } else {
1432  rerouterIntervalParent->addClosingReroute(closingReroute);
1433  }
1434  return true;
1435 }
1436 
1437 
1438 bool
1439 GNEAdditionalHandler::builDestProbReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNERerouterInterval* rerouterIntervalParent, GNEEdge* newEdgeDestination, double probability) {
1440  // create dest probability reroute
1441  GNEDestProbReroute* destProbReroute = new GNEDestProbReroute(rerouterIntervalParent, newEdgeDestination, probability);
1442  // add it to interval parent depending of allowUndoRedo
1443  if (allowUndoRedo) {
1444  viewNet->getUndoList()->p_begin("add " + toString(destProbReroute->getTag()));
1445  viewNet->getUndoList()->add(new GNEChange_RerouterItem(destProbReroute, true), true);
1446  viewNet->getUndoList()->p_end();
1447  } else {
1448  rerouterIntervalParent->addDestProbReroute(destProbReroute);
1449  }
1450  return true;
1451 }
1452 
1453 
1454 bool
1455 GNEAdditionalHandler::buildRouteProbReroute(GNEViewNet* viewNet, bool allowUndoRedo, GNERerouterInterval* rerouterIntervalParent, const std::string& newRouteId, double probability) {
1456  // create rout prob rereoute
1457  GNERouteProbReroute* routeProbReroute = new GNERouteProbReroute(rerouterIntervalParent, newRouteId, probability);
1458  // add it to interval parent depending of allowUndoRedo
1459  if (allowUndoRedo) {
1460  viewNet->getUndoList()->p_begin("add " + toString(routeProbReroute->getTag()));
1461  viewNet->getUndoList()->add(new GNEChange_RerouterItem(routeProbReroute, true), true);
1462  viewNet->getUndoList()->p_end();
1463  } else {
1464  rerouterIntervalParent->addRouteProbReroute(routeProbReroute);
1465  }
1466  return true;
1467 }
1468 
1469 
1470 bool
1471 GNEAdditionalHandler::buildRouteProbe(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNEEdge* edge, double freq, const std::string& file, double begin) {
1472  if (viewNet->getNet()->getAdditional(SUMO_TAG_ROUTEPROBE, id) == NULL) {
1473  GNERouteProbe* routeProbe = new GNERouteProbe(id, viewNet, edge, freq, file, begin);
1474  if (allowUndoRedo) {
1475  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_ROUTEPROBE));
1476  viewNet->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1477  viewNet->getUndoList()->p_end();
1478  // center after creation
1479  viewNet->centerTo(routeProbe->getGlID(), false);
1480  } else {
1481  viewNet->getNet()->insertAdditional(routeProbe);
1482  edge->addAdditionalChild(routeProbe);
1483  }
1484  return true;
1485  } else {
1486  throw ProcessError("Could not build " + toString(SUMO_TAG_ROUTEPROBE) + " with ID '" + id + "' in netedit; probably declared twice.");
1487  }
1488 }
1489 
1490 
1491 bool
1492 GNEAdditionalHandler::buildVariableSpeedSign(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNELane*>& lanes, const std::string& file) {
1493  if (viewNet->getNet()->getAdditional(SUMO_TAG_VSS, id) == NULL) {
1494  GNEVariableSpeedSign* variableSpeedSign = new GNEVariableSpeedSign(id, viewNet, pos, lanes, file);
1495  if (allowUndoRedo) {
1496  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VSS));
1497  viewNet->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1498  viewNet->getUndoList()->p_end();
1499  } else {
1500  viewNet->getNet()->insertAdditional(variableSpeedSign);
1501  // add this VSS as parent of all edges
1502  for (auto i : lanes) {
1503  i->addAdditionalParent(variableSpeedSign);
1504  }
1505  }
1506  return true;
1507  } else {
1508  throw ProcessError("Could not build " + toString(SUMO_TAG_VSS) + " with ID '" + id + "' in netedit; probably declared twice.");
1509  }
1510 }
1511 
1512 
1513 bool
1514 GNEAdditionalHandler::buildVariableSpeedSignStep(GNEViewNet* viewNet, bool allowUndoRedo, GNEVariableSpeedSign* VSSParent, double time, double speed) {
1515  // create Variable Speed Sign
1516  GNEVariableSpeedSignStep* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSSParent, time, speed);
1517  // add it depending of allow undoRedo
1518  if (allowUndoRedo) {
1519  viewNet->getUndoList()->p_begin("add " + toString(variableSpeedSignStep->getTag()));
1520  viewNet->getUndoList()->add(new GNEChange_VariableSpeedSignItem(variableSpeedSignStep, true), true);
1521  viewNet->getUndoList()->p_end();
1522  } else {
1523  VSSParent->addVariableSpeedSignStep(variableSpeedSignStep);
1524  }
1525  return true;
1526 }
1527 
1528 
1529 bool
1530 GNEAdditionalHandler::buildVaporizer(GNEViewNet* viewNet, bool allowUndoRedo, GNEEdge* edge, double startTime, double end) {
1531  GNEVaporizer* vaporizer = new GNEVaporizer(viewNet, edge, startTime, end);
1532  if (allowUndoRedo) {
1533  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VAPORIZER));
1534  viewNet->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1535  viewNet->getUndoList()->p_end();
1536  // center after creation
1537  viewNet->centerTo(vaporizer->getGlID(), false);
1538  } else {
1539  viewNet->getNet()->insertAdditional(vaporizer);
1540  edge->addAdditionalChild(vaporizer);
1541  }
1542  return true;
1543 }
1544 
1545 
1546 std::string
1547 GNEAdditionalHandler::getFileName(const SUMOSAXAttributes& attrs, const std::string& base, const bool allowEmpty) {
1548  // get the file name to read further definitions from
1549  bool ok = true;
1550  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, 0, ok, "");
1551  if (file == "") {
1552  if (allowEmpty) {
1553  return file;
1554  }
1555  WRITE_WARNING("No filename given.");
1556  }
1557  // check whether absolute or relative filenames are given
1558  if (!FileHelpers::isAbsolute(file)) {
1559  return FileHelpers::getConfigurationRelative(base, file);
1560  }
1561  return file;
1562 }
1563 
1564 
1565 double
1566 GNEAdditionalHandler::getPosition(double pos, GNELane& lane, bool friendlyPos , const std::string& additionalID) {
1567  if (pos < 0) {
1568  pos = lane.getLaneShapeLength() + pos;
1569  }
1570  if (pos > lane.getLaneShapeLength()) {
1571  if (friendlyPos) {
1572  pos = lane.getLaneShapeLength() - (double) 0.1;
1573  } else {
1574  WRITE_WARNING("The position of additional '" + additionalID + "' lies beyond the lane's '" + lane.getID() + "' length.");
1575  }
1576  }
1577  return pos;
1578 }
1579 
1580 
1581 bool
1582 GNEAdditionalHandler::fixStoppinPlacePosition(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos) {
1583  if (minLength > laneLength) {
1584  return false;
1585  }
1586  if (startPos < 0) {
1587  startPos += laneLength;
1588  }
1589  if (endPos < 0) {
1590  endPos += laneLength;
1591  }
1592  if (endPos < minLength || endPos > laneLength) {
1593  if (!friendlyPos) {
1594  return false;
1595  }
1596  if (endPos < minLength) {
1597  endPos = minLength;
1598  }
1599  if (endPos > laneLength) {
1600  endPos = laneLength;
1601  }
1602  }
1603  if (startPos < 0 || startPos > endPos - minLength) {
1604  if (!friendlyPos) {
1605  return false;
1606  }
1607  if (startPos < 0) {
1608  startPos = 0;
1609  }
1610  if (startPos > endPos - minLength) {
1611  startPos = endPos - minLength;
1612  }
1613  }
1614  return true;
1615 }
1616 
1617 
1618 bool GNEAdditionalHandler::checkAndFixDetectorPositionPosition(double& pos, const double laneLength, const bool friendlyPos) {
1619  if ((pos < 0) || (pos > laneLength)) {
1620  if (!friendlyPos) {
1621  return false;
1622  } else if (pos < 0) {
1623  pos = 0;
1624  } else if (pos > laneLength) {
1625  pos = laneLength;
1626  }
1627  }
1628  return true;
1629 }
1630 
1631 
1632 int
1633 GNEAdditionalHandler::getTypeOfFlowDistribution(std::string flowID, double vehsPerHour, double period, double probability) {
1634  if ((vehsPerHour == -1) && (period == -1) && (probability == -1)) {
1635  WRITE_WARNING("A type of distribution (" + toString(SUMO_ATTR_VEHSPERHOUR) + ", " + toString(SUMO_ATTR_PERIOD) + " or " +
1636  toString(SUMO_ATTR_PROB) + ") must be defined in " + toString(SUMO_TAG_FLOW) + " '" + flowID + "'");
1638  } else {
1639  int vehsPerHourDefined = (vehsPerHour != -1) ? 1 : 0;
1640  int periodDefined = (period != -1) ? 1 : 0;
1641  int probabilityDefined = (probability != -1) ? 1 : 0;
1642 
1643  if ((vehsPerHourDefined + periodDefined + probabilityDefined) != 1) {
1644  WRITE_WARNING("Only a type of distribution (" + toString(SUMO_ATTR_VEHSPERHOUR) + ", " + toString(SUMO_ATTR_PERIOD) + " or " +
1645  toString(SUMO_ATTR_PROB) + ") can be defined at the same time in " + toString(SUMO_TAG_FLOW) + " '" + flowID + "'");
1647  } else if (vehsPerHourDefined == 1) {
1649  } else if (periodDefined == 1) {
1651  } else if (probabilityDefined == 1) {
1653  } else {
1655  }
1656  }
1657 }
1658 
1659 
1660 bool GNEAdditionalHandler::fixE2DetectorPositionPosition(double& pos, double& length, const double laneLength, const bool friendlyPos) {
1661  if ((pos < 0) || ((pos + length) > laneLength)) {
1662  if (!friendlyPos) {
1663  return false;
1664  } else if (pos < 0) {
1665  pos = 0;
1666  } else if (pos > laneLength) {
1667  pos = laneLength;
1668  length = 0;
1669  } else if ((pos + length) > laneLength) {
1670  length = laneLength - pos;
1671  }
1672  }
1673  return true;
1674 }
1675 
1676 /****************************************************************************/
void insertCalibratorVehicleType(GNECalibratorVehicleType *vehicleType)
insert Calibrator VehicleType in net
Definition: GNENet.cpp:2095
void insertAdditional(GNEAdditional *additional)
Insert a additional element int GNENet container.
Definition: GNENet.cpp:2020
SumoXMLTag
Numbers representing SUMO-XML - element names.
int getTypeOfFlowDistribution(std::string flowID, double vehsPerHour, double period, double probability)
get a error message, if configuration of flow distribution is invalid
a routeprobe detector
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:902
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:81
description of a vehicle type
void parseAndBuildRerouterRouteProbReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Route Prob Reroute.
void removeRerouterInterval(GNERerouterInterval *rerouterInterval)
add rerouter interval
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;.
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)
void addDestProbReroute(GNEDestProbReroute *destProbReroute)
add destiny probability reroute
A calibrator placed over edge.
static bool buildVariableSpeedSign(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNELane *> &destLanes, const std::string &file)
Builds a VariableSpeedSign (lane speed trigger)
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1667
lane of a reroute of type closing
Allow/disallow charge in transit in Charging Stations.
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
static bool builDestProbReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNERerouterInterval *rerouterIntervalParent, GNEEdge *newEdgeDestination, double probability)
bool myUndoAdditionals
flag to check if created additionals must be undo and redo
static bool buildAdditional(GNEViewNet *viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Build additionals.
int getNumberOfOverlappedIntervals() const
get number of overlapped intervals
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:42
GNERerouterInterval * getRerouterInterval(const std::string &rerouterIntervalID) const
Definition: GNENet.cpp:1691
weights: time range begin
static bool checkAndFixDetectorPositionPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
static bool buildClosingLaneReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNERerouterInterval *rerouterIntervalParent, GNELane *closedLane, SVCPermissions allowedVehicles, SVCPermissions disallowedVehicles)
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:53
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:84
static bool buildClosingReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNERerouterInterval *rerouterIntervalParent, GNEEdge *closedEdge, SVCPermissions allowedVehicles, SVCPermissions disallowedVehicles)
static bool buildVaporizer(GNEViewNet *viewNet, bool allowUndoRedo, GNEEdge *edge, double startTime, double end)
Builds a vaporizer (lane speed trigger)
SAX-handler base for SUMO-files.
static std::vector< GNEEdge * > parseGNEEdges(GNENet *net, const std::string &value)
parse string into vector of GNEEdges
void addClosingReroute(GNEClosingReroute *closingReroute)
add closing reroute
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...
begin/end of the description of a route
static bool buildDetectorEntry(GNEViewNet *viewNet, bool allowUndoRedo, GNEDetectorE3 *E3Parent, GNELane *lane, double pos, bool friendlyPos)
Builds a entry detector (E3)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
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)
an e3 entry point
void addRerouterInterval(GNERerouterInterval *rerouterInterval)
add rerouter interval
GNEUndoList * getUndoList() const
get the undoList object
~GNEAdditionalHandler()
Destructor.
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:701
void parseAndBuildCalibratorVehicleType(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses vehicle type values of Calibrators.
static bool buildRouteProbReroute(GNEViewNet *viewNet, bool allowUndoRedo, GNERerouterInterval *rerouterIntervalParent, const std::string &newRouteId, double probability)
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
void parseAndBuildRerouterInterval(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Rerouter Interval.
Encapsulated SAX-Attributes.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
Definition: FileHelpers.cpp:96
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:91
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
an e3 exit point
A list of positions.
static bool buildRouteProbe(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNEEdge *edge, double freq, const std::string &file, double begin)
builds a Route probe
GNEAdditionalHandler(const std::string &file, GNEViewNet *viewNet, bool undoAdditionals=true)
Constructor.
void insertCalibratorRoute(GNECalibratorRoute *route)
insert Calibrator Route in net
Definition: GNENet.cpp:2053
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:42
static bool checkGNELanesValid(GNENet *net, const std::string &value, bool report)
check if a list of Lane IDs is valid
void parseAndBuildCalibratorRoute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses route values of Calibrators.
void addCalibratorRoute(GNECalibratorRoute *route)
add calibrator route
static bool buildCalibratorRoute(GNEViewNet *viewNet, bool allowUndoRedo, GNECalibrator *calibratorParent, const std::string &routeID, const std::vector< GNEEdge *> &edges, const RGBColor &color)
std::string myLastInsertedAdditionalParent
ID of last inserted Additional parent (needed for additionasl that own a child)
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:49
#define POSITION_EPS
Definition: config.h:175
static bool buildCalibratorVehicleType(GNEViewNet *viewNet, bool allowUndoRedo, GNECalibrator *calibratorParent, 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)
static bool buildDetectorE2(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, double length, double freq, const std::string &filename, bool cont, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos)
Builds a lane Area Detector (E2)
void insertCalibratorFlow(GNECalibratorFlow *flow)
insert Calibrator Flow in net
Definition: GNENet.cpp:2074
probability of route of a reroute
probability of destiny of a reroute
const std::string getID() const
function to support debugging
static bool buildChargingStation(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double startPos, double endPos, const std::string &name, double chargingPower, double efficiency, bool chargeInTransit, double chargeDelay, bool friendlyPosition)
Builds a charging Station.
GNEViewNet * myViewNet
pointer to View&#39;s Net
void addRouteProbReroute(GNERouteProbReroute *routeProbabilityReroute)
add reoute probability reroute
GNECalibratorRoute * retrieveCalibratorRoute(const std::string &id, bool hardFail=true) const
Returns the named calibrator route.
Definition: GNENet.cpp:1800
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:712
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
static bool buildCalibrator(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, const std::string &outfile, double freq)
builds a microscopic calibrator over a lane
void parseAndBuildRouteProbe(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds routeProbe.
reroute of type closing
static bool buildVariableSpeedSignStep(GNEViewNet *viewNet, bool allowUndoRedo, GNEVariableSpeedSign *VSSParent, double time, double speed)
Builds a VariableSpeedSign Step.
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:56
void addCalibratorVehicleType(GNECalibratorVehicleType *vehicleType)
add calibrator vehicleType
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
void parseAndBuildVariableSpeedSignStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Variable Speed Signal Step.
static bool buildContainerStop(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double startPos, double endPos, const std::string &name, const std::vector< std::string > &lines, bool friendlyPosition)
Builds a container stop.
void addCalibratorFlow(GNECalibratorFlow *flow)
add calibrator flow
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)
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.
static bool fixE2DetectorPositionPosition(double &pos, double &length, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
void parseAndBuildCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
GNEAdditional * retrieveAdditional(const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:1640
weights: time range end
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a vaporization.
GNECalibratorVehicleType * retrieveCalibratorVehicleType(const std::string &id, bool hardFail=true) const
Returns the named calibrator vehicle type.
Definition: GNENet.cpp:1816
vaporizer of vehicles
static bool buildRerouter(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNEEdge *> &edges, double prob, const std::string &file, bool off, double timeThreshold)
builds a rerouter
void parseAndBuildRerouterClosingLaneReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Closing Lane reroute.
GNENet * getNet() const
get the net object
GUIGlID getGlID() const
Returns the numerical id of the object.
an aggreagated-output interval
A variable speed sign.
Eficiency of the charge in Charging Stations.
parent of an additional element
static bool buildDetectorE3(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, double freq, const std::string &filename, const double timeThreshold, double speedThreshold)
Builds a multi entry exit detector (E3)
Delay in the charge of charging stations.
void addAdditionalChild(GNEAdditional *additional)
add additional child to this additional
static std::vector< GNELane * > parseGNELanes(GNENet *net, const std::string &value)
parse string into vector of GNELanes
static bool buildBusStop(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double startPos, double endPos, const std::string &name, const std::vector< std::string > &lines, bool friendlyPosition)
Builds a bus stop.
A lane area vehicles can halt at (netedit-version)
static bool checkGNEEdgesValid(GNENet *net, const std::string &value, bool report)
check if a list of edge IDs is valid
void addClosingLaneReroute(GNEClosingLaneReroute *closingLaneReroute)
add closing reroute
static bool fixStoppinPlacePosition(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check if the position of an stoppingPlace over a lane is valid
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1000
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 PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occured errors.
alternative tag for e2 detector
static bool buildDetectorExit(GNEViewNet *viewNet, bool allowUndoRedo, GNEDetectorE3 *E3Parent, GNELane *lane, double pos, bool friendlyPos)
Builds a exit detector (E3)
void addVariableSpeedSignStep(GNEVariableSpeedSignStep *step)
insert a new step in variable speed signal
static bool buildCalibratorFlow(GNEViewNet *viewNet, bool allowUndoRedo, GNECalibrator *calibratorParent, const std::string &flowID, GNECalibratorRoute *route, GNECalibratorVehicleType *vtype, 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, double vehsPerHour, double period, double probability, int number, int flowType)
static bool buildDetectorE1(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, double freq, const std::string &filename, const std::string &vehicleTypes, bool friendlyPos)
Builds a induction loop detector (E1)
GNECalibratorFlow * retrieveCalibratorFlow(const std::string &id, bool hardFail=true) const
Returns the named calibrator flow.
Definition: GNENet.cpp:1832
trigger: a step description
static bool buildRerouterInterval(GNEViewNet *viewNet, bool allowUndoRedo, GNERerouter *rerouterParent, double begin, double end)
builds a rerouter interval
void parseAndBuildRerouterClosingReroute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Closing Reroute.
SumoXMLTag getTag() const
get XML Tag assigned to this object