SUMO - Simulation of Urban MObility
GNEAdditionalHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Builds trigger objects for netedit
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
31 
32 #include "GNEAdditionalHandler.h"
33 #include "GNEBusStop.h"
34 #include "GNEChange_Additional.h"
35 #include "GNEChargingStation.h"
36 #include "GNEClosingLaneReroute.h"
37 #include "GNEClosingReroute.h"
38 #include "GNEContainerStop.h"
39 #include "GNEDestProbReroute.h"
40 #include "GNEDetectorE1.h"
41 #include "GNEDetectorE2.h"
42 #include "GNEDetectorE3.h"
43 #include "GNEDetectorEntry.h"
44 #include "GNEDetectorExit.h"
45 #include "GNEEdge.h"
46 #include "GNEJunction.h"
47 #include "GNELane.h"
48 #include "GNENet.h"
49 #include "GNERerouter.h"
50 #include "GNERerouterInterval.h"
51 #include "GNERouteProbReroute.h"
52 #include "GNERouteProbe.h"
53 #include "GNEUndoList.h"
54 #include "GNEVaporizer.h"
55 #include "GNEViewNet.h"
56 #include "GNECalibrator.h"
57 
58 
59 // ===========================================================================
60 // member method definitions
61 // ===========================================================================
62 
63 GNEAdditionalHandler::GNEAdditionalHandler(const std::string& file, GNEViewNet* viewNet, bool undoAdditionals) :
64  SUMOSAXHandler(file),
65  myViewNet(viewNet),
66  myUndoAdditionals(undoAdditionals),
67  myE3Parent(NULL),
68  myCalibratorParent(NULL),
69  myVariableSpeedSignParent(NULL),
70  rerouterIntervalToInsertValues(NULL),
71  myLastTag(SUMO_TAG_NOTHING) {
72 }
73 
74 
76 
77 
78 void
80  // Obtain tag of element
81  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
82  // first chek additional parent tag
83  if (checkAdditionalParent(tag)) {
84  // Call parse and build depending of tag
85  switch (element) {
86  case SUMO_TAG_BUS_STOP:
87  parseAndBuildBusStop(attrs, tag);
88  // disable other additional parents
89  myCalibratorParent = NULL;
90  myE3Parent = NULL;
92  break;
94  parseAndBuildContainerStop(attrs, tag);
95  // disable other additional parents
96  myCalibratorParent = NULL;
97  myE3Parent = NULL;
99  break;
101  parseAndBuildChargingStation(attrs, tag);
102  // disable other additional parents
103  myCalibratorParent = NULL;
104  myE3Parent = NULL;
105  break;
106  case SUMO_TAG_E1DETECTOR:
108  parseAndBuildDetectorE1(attrs, tag);
109  // disable other additional parents
110  myCalibratorParent = NULL;
111  myE3Parent = NULL;
113  break;
114  case SUMO_TAG_E2DETECTOR:
116  parseAndBuildDetectorE2(attrs, tag);
117  // disable other additional parents
118  myCalibratorParent = NULL;
119  myE3Parent = NULL;
121  break;
122  case SUMO_TAG_E3DETECTOR:
124  parseAndBuildDetectorE3(attrs, tag);
125  // disable other additional parents
126  myCalibratorParent = NULL;
128  break;
129  case SUMO_TAG_DET_ENTRY:
130  parseAndBuildDetectorEntry(attrs, tag);
131  // disable other additional parents
132  myCalibratorParent = NULL;
134  break;
135  case SUMO_TAG_DET_EXIT:
136  parseAndBuildDetectorExit(attrs, tag);
137  // disable other additional parents
138  myCalibratorParent = NULL;
139  break;
140  case SUMO_TAG_VSS:
141  parseAndBuildVariableSpeedSign(attrs, tag);
142  // disable other additional parents
143  myCalibratorParent = NULL;
144  myE3Parent = NULL;
145  break;
146  case SUMO_TAG_REROUTER:
147  parseAndBuildRerouter(attrs, tag);
148  // disable other additional parents
149  myCalibratorParent = NULL;
150  myE3Parent = NULL;
152  break;
153  case SUMO_TAG_CALIBRATOR:
154  parseAndBuildCalibrator(attrs, tag);
155  // disable other additional parents
156  myE3Parent = NULL;
158  break;
159  case SUMO_TAG_VAPORIZER:
160  parseAndBuildVaporizer(attrs, tag);
161  // disable other additional parents
162  myCalibratorParent = NULL;
163  myE3Parent = NULL;
165  break;
166  case SUMO_TAG_ROUTEPROBE:
167  parseAndBuildRouteProbe(attrs, tag);
168  // disable other additional parents
169  myCalibratorParent = NULL;
170  myE3Parent = NULL;
172  break;
173  case SUMO_TAG_VTYPE:
174  parseCalibratorVehicleType(attrs, tag);
175  // disable other additional parents
176  myCalibratorParent = NULL;
178  break;
179  case SUMO_TAG_ROUTE:
180  parseCalibratorRoute(attrs, tag);
181  // disable other additional parents
182  myCalibratorParent = NULL;
183  // disable other additional parents
184  myE3Parent = NULL;
186  break;
187  case SUMO_TAG_FLOW:
188  parseCalibratorFlow(attrs, tag);
189  // disable other additional parents
190  myE3Parent = NULL;
192  break;
193  case SUMO_TAG_STEP:
194  parseVariableSpeedSignStep(attrs, tag);
195  // disable other additional parents
196  myCalibratorParent = NULL;
197  myE3Parent = NULL;
198  break;
199  default:
200  break;
201  }
202  }
203 }
204 
205 
206 void
208  bool abort = false;
209  // parse attributes of Vaporizer
210  const std::string edgeId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_EDGE, abort);
211  double startTime = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_STARTTIME, abort);
212  double endTime = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_END, abort);
213  // Continue if all parameters were successfully loaded
214  if (!abort) {
215  // get edge
216  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
217  if (edge == NULL) {
218  // Write error if lane isn't valid
219  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " is not known.");
220  } else if (startTime > endTime) {
221  // write error if time interval ins't valid
222  WRITE_WARNING("Time interval of " + toString(tag) + " isn't valid. Attribute '" + toString(SUMO_ATTR_STARTTIME) + "' is greater than attribute '" + toString(SUMO_ATTR_END) + "'.");
223  } else {
224  // build Vaporizer
225  buildVaporizer(myViewNet, myUndoAdditionals, edge, startTime, endTime);
226  }
227  }
228 }
229 
230 
231 
232 void
234  bool abort = false;
235  // parse attributes of RouteProbe
236  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
237  std::string edgeId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_EDGE, abort);
238  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_FREQUENCY, abort);
239  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_FILE, abort, false);
240  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_BEGIN, abort);
241  // Continue if all parameters were sucesfully loaded
242  if (!abort) {
243  // get edge
244  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
245  // check that all parameters are valid
246  if (GNEAttributeCarrier::isValidID(id) == false) {
247  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
248  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
249  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
250  } else if (edge == NULL) {
251  // Write error if lane isn't valid
252  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
253  } else {
254  // build Vaporizer
255  buildRouteProbe(myViewNet, myUndoAdditionals, id, edge, freq, file, begin);
256  }
257  }
258 }
259 
260 
261 void
263  bool abort = false;
264  // parse attribute of calibrator routes
265  std::string routeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
266  std::vector<std::string> edgeIDs = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, 0, tag, SUMO_ATTR_EDGES, abort);
267  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, 0, tag, SUMO_ATTR_COLOR, abort, false);
268 
269  // Continue if all parameters were sucesfully loaded
270  if (!abort) {
271  // check if already exist a route with the same ID
272  if (myViewNet->getNet()->routeExists(routeID)) {
273  WRITE_WARNING(toString(SUMO_TAG_ROUTE) + " with ID = '" + routeID + "' cannot be created; Another " +
274  toString(SUMO_TAG_ROUTE) + " with the same ID was previously declared");
275  abort = true;
276  }
277  // declare vector with pointers to GNEEdges
278  std::vector<GNEEdge*> edges;
279  for (std::vector<std::string>::const_iterator i = edgeIDs.begin(); (i != edgeIDs.end()) && (abort == false); i++) {
280  GNEEdge* retrievedEdge = myViewNet->getNet()->retrieveEdge((*i), false);
281  // stop
282  if (retrievedEdge != NULL) {
283  edges.push_back(retrievedEdge);
284  } else {
285  WRITE_WARNING(toString(SUMO_TAG_ROUTE) + " with ID = '" + routeID + "' cannot be created; " +
286  toString(SUMO_TAG_EDGE) + " with id '" + (*i) + "' doesn't exist in net");
287  }
288  }
289  // create vehicle type if calibrator parent is currently defined
290  if ((myCalibratorParent != NULL) && (abort == false)) {
291  // create vehicle type and add it to calibrator parent
292  GNECalibratorRoute route(myCalibratorParent, routeID, edges, color);
294  }
295  }
296 }
297 
298 
299 void
301  bool abort = false;
302  // parse attribute of calibrator vehicle types
303  std::string vehicleTypeID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
304  double accel = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_ACCEL, abort);
305  double decel = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_DECEL, abort);
306  double sigma = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_SIGMA, abort);
307  double tau = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_TAU, abort);
308  double length = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_LENGTH, abort);
309  double minGap = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_MINGAP, abort);
310  double maxSpeed = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_MAXSPEED, abort);
311  double speedFactor = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_SPEEDFACTOR, abort);
312  double speedDev = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_SPEEDDEV, abort);
313  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, 0, tag, SUMO_ATTR_COLOR, abort, false);
314  SUMOVehicleClass vClass = GNEAttributeCarrier::parseAttributeFromXML<SUMOVehicleClass>(attrs, 0, tag, SUMO_ATTR_VCLASS, abort);
315  std::string emissionClass = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_EMISSIONCLASS, abort);
316  SUMOVehicleShape shape = GNEAttributeCarrier::parseAttributeFromXML<SUMOVehicleShape>(attrs, 0, tag, SUMO_ATTR_GUISHAPE, abort);
317  double width = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_WIDTH, abort);
318  std::string filename = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_IMGFILE, abort);
319  double impatience = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_IMPATIENCE, abort);
320  std::string laneChangeModel = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_LANE_CHANGE_MODEL, abort);
321  std::string carFollowModel = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_CAR_FOLLOW_MODEL, abort);
322  int personCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, 0, tag, SUMO_ATTR_PERSON_CAPACITY, abort);
323  int containerCapacity = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, 0, tag, SUMO_ATTR_CONTAINER_CAPACITY, abort);
324  double boardingDuration = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_BOARDING_DURATION, abort);
325  double loadingDuration = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_LOADING_DURATION, abort);
326  std::string latAlignment = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_LATALIGNMENT, abort);
327  double minGapLat = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_MINGAP_LAT, abort);
328  double maxSpeedLat = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_MAXSPEED_LAT, abort);
329 
330  // Continue if all parameters were sucesfully loaded
331  if (!abort) {
332  // check if already exist a vehicleType with the same ID
333  if (myViewNet->getNet()->vehicleTypeExists(vehicleTypeID)) {
334  WRITE_WARNING(toString(SUMO_TAG_VTYPE) + " with ID = '" + vehicleTypeID + "' cannot be created; Another " + toString(SUMO_TAG_VTYPE) + " with the same ID was previously declared");
335  } else if (myCalibratorParent != NULL) {
336  // create vehicle type and add it to calibrator parent
337  GNECalibratorVehicleType vehicleType(myCalibratorParent, vehicleTypeID, accel, decel, sigma, tau, length, minGap, maxSpeed,
338  speedFactor, speedDev, color, vClass, emissionClass, shape, width, filename, impatience,
339  laneChangeModel, carFollowModel, personCapacity, containerCapacity, boardingDuration,
340  loadingDuration, latAlignment, minGapLat, maxSpeedLat);
342  }
343  }
344 }
345 
346 
347 void
349  bool abort = false;
350 
351  // parse attributes of calibrator flows
352  std::string flowID = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
353  std::string vehicleType = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_TYPE, abort);
354  std::string route = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ROUTE, abort);
355  RGBColor color = GNEAttributeCarrier::parseAttributeFromXML<RGBColor>(attrs, 0, tag, SUMO_ATTR_COLOR, abort, false);
356  std::string departLane = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_DEPARTLANE, abort);
357  std::string departPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_DEPARTPOS, abort);
358  std::string departSpeed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_DEPARTSPEED, abort);
359  std::string arrivalLane = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ARRIVALLANE, abort);
360  std::string arrivalPos = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ARRIVALPOS, abort);
361  std::string arrivalSpeed = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ARRIVALSPEED, abort);
362  std::string line = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_LINE, abort);
363  int personNumber = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, 0, tag, SUMO_ATTR_PERSON_NUMBER, abort);
364  int containerNumber = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, 0, tag, SUMO_ATTR_CONTAINER_NUMBER, abort);
365  bool reroute = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, 0, tag, SUMO_ATTR_REROUTE, abort);
366  std::string departPosLat = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_DEPARTPOS_LAT, abort);
367  std::string arrivalPosLat = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ARRIVALPOS_LAT, abort);
368  double begin = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_BEGIN, abort);
369  double end = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_END, abort);
370  double vehsPerHour = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_VEHSPERHOUR, abort);
371  double period = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_PERIOD, abort);
372  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_PROB, abort);
373  int number = GNEAttributeCarrier::parseAttributeFromXML<int>(attrs, 0, tag, SUMO_ATTR_NUMBER, abort);
374 
375  // Continue if all parameters were sucesfully loaded
376  if (!abort) {
377  // check if flowID, route and vehicle type already exists
378  if (myViewNet->getNet()->flowExists(flowID) == false) {
379  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " with ID = '" + flowID + "' cannot be created; Another " + toString(SUMO_TAG_FLOW) + " with the same ID was previously declared");
380  abort = true;
381  } else if (myViewNet->getNet()->routeExists(route) == false) {
382  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " with ID = '" + flowID + "' cannot be created; their " + toString(SUMO_TAG_ROUTE) + " with ID = '" + route + "' doesn't exist");
383  abort = true;
384  } else if (myViewNet->getNet()->vehicleTypeExists(vehicleType) == false) {
385  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " with ID = '" + flowID + "' cannot be created; their " + toString(SUMO_TAG_VTYPE) + " with ID = '" + vehicleType + "' doesn't exist");
386  abort = true;
387  }
388  // check if distributions are correct and calibrator parent is defined
389  if ((myCalibratorParent != NULL) && (abort == false)) {
390  // obtain type of distribution
391  GNECalibratorFlow::TypeOfFlow flowType = getTypeOfFlowDistribution(flowID, vehsPerHour, period, probability);
393  WRITE_WARNING(toString(SUMO_TAG_FLOW) + " with ID = '" + flowID + "' cannot be created; Type of distribution undefined");
394  } else {
395  // create Flow and add it to calibrator parent
396  GNECalibratorFlow flow(myCalibratorParent, flowID, vehicleType, route, color, departLane, departPos, departSpeed,
397  arrivalLane, arrivalPos, arrivalSpeed, line, personNumber, containerNumber, reroute,
398  departPosLat, arrivalPosLat, begin, end, vehsPerHour, period, probability, number);
400  }
401  }
402  }
403 }
404 
405 
406 void
408  bool abort = false;
409  // Load step values
410  double time = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_TIME, abort);
411  double speed = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_SPEED, abort);
412  // Continue if all parameters were sucesfully loaded
413  if ((!abort) && (myVariableSpeedSignParent != NULL)) {
414  // create step and check that is valid
416  // show warning if is duplicated
417  if (std::find(myVariableSpeedSignParent->getSteps().begin(), myVariableSpeedSignParent->getSteps().end(), step) != myVariableSpeedSignParent->getSteps().end()) {
418  WRITE_WARNING(toString(step.getTag()) + " cannot be inserted into " + toString(myVariableSpeedSignParent->getTag()) + " with id = '" + myVariableSpeedSignParent->getID() +
419  "'; Already exist another " + toString(step.getTag()) + " with the same " + toString(SUMO_ATTR_TIME) + ".");
420  } else {
422  }
423  }
424 }
425 
426 
427 void
429  bool abort = false;
430  // parse attributes of VSS
431  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
432  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort, false);
433  std::vector<std::string> lanesID = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id.c_str(), tag, SUMO_ATTR_LANES, abort);
434  double posx = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_X, abort);
435  double posy = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_Y, abort);
436  // Continue if all parameters were sucesfully loaded
437  if (!abort) {
438  // obtain VSS Values
439  // @todo
440  std::vector<GNEVariableSpeedSignStep> steps;
441  // Obtain pointer to lanes
442  std::vector<GNELane*> lanes;
443  for (std::vector<std::string>::iterator i = lanesID.begin(); (i < lanesID.end()) && (abort == false); i++) {
444  GNELane* lane = myViewNet->getNet()->retrieveLane((*i), false);
445  if (lane != NULL) {
446  lanes.push_back(lane);
447  } else {
448  WRITE_WARNING(toString(SUMO_TAG_VSS) + " with ID = '" + id + "' cannot be created; " + toString(SUMO_TAG_LANE) + " '" + (*i) + "' doesn't exist.");
449  abort = true;
450  }
451  }
452  // if operation of build variable speed signal was sucesfully, save Id
453  if ((abort == false) && buildVariableSpeedSign(myViewNet, myUndoAdditionals, id, Position(posx, posy), lanes, file, steps)) {
454  myLastTag = tag;
455  }
456  }
457 }
458 
459 
460 void
462  bool abort = false;
463  // parse attributes of Rerouter
464  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
465  std::vector<std::string> edgesID = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id.c_str(), tag, SUMO_ATTR_EDGES, abort);
466  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort, false);
467  double probability = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_PROB, abort);
468  bool off = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_OFF, abort);
469  double posx = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_X, abort);
470  double posy = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_Y, abort);
471  // Continue if all parameters were sucesfully loaded
472  if (!abort) {
473  // obtain Rerouter values Values
474 
475  // Obtain pointer to edges
476  std::vector<GNEEdge*> edges;
477  for (int i = 0; i < (int)edgesID.size(); i++) {
478  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgesID.at(i));
479  if (edge) {
480  edges.push_back(edge);
481  } else {
482  throw ProcessError(); /**************** ARREGLAR **********/
483  }
484  }
485  // if operation of build variable speed signal was sucesfully, save Id
486  if (buildRerouter(myViewNet, myUndoAdditionals, id, Position(posx, posy), edges, probability, file, off)) {
487  ;//myAdditionalParent = id;
488  }
489  }
490 }
491 
492 
493 void
495  bool abort = false;
496  // parse attributes of bus stop
497  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
498  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
499  double startPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_STARTPOS, abort);
500  double endPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_ENDPOS, abort);
501  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_NAME, abort, false);
502  std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id.c_str(), tag, SUMO_ATTR_LINES, abort, false);
503  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_FRIENDLY_POS, abort, false);
504  // Continue if all parameters were sucesfully loaded
505  if (!abort) {
506  // get pointer to lane
507  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
508  // check that all parameters are valid
509  if (GNEAttributeCarrier::isValidID(id) == false) {
510  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
511  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
512  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
513  } else if (lane == NULL) {
514  // Write error if lane isn't valid
515  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
516  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getLaneParametricLength(), POSITION_EPS, friendlyPosition)) {
517  // Write error if position isn't valid
518  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
519  } else if (buildBusStop(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, lines, friendlyPosition)) {
520  myLastTag = tag;
521  }
522  }
523 }
524 
525 
526 void
528  bool abort = false;
529  // parse attributes of container stop
530  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
531  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
532  double startPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_STARTPOS, abort);
533  double endPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_ENDPOS, abort);
534  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_NAME, abort, false);
535  std::vector<std::string> lines = GNEAttributeCarrier::parseAttributeFromXML<std::vector<std::string> >(attrs, id.c_str(), tag, SUMO_ATTR_LINES, abort, false);
536  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_FRIENDLY_POS, abort, false);
537  // Continue if all parameters were sucesfully loaded
538  if (!abort) {
539  // get pointer to lane
540  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
541  // check that all parameters are valid
542  if (GNEAttributeCarrier::isValidID(id) == false) {
543  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
544  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
545  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
546  } else if (lane == NULL) {
547  // Write error if lane isn't valid
548  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
549  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getLaneParametricLength(), POSITION_EPS, friendlyPosition)) {
550  // write error if position isn't valid
551  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
552  } else if (buildContainerStop(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, lines, friendlyPosition)) {
553  myLastTag = tag;
554  }
555  }
556 }
557 
558 
559 void
561  bool abort = false;
562  // parse attributes of charging station
563  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
564  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
565  double startPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_STARTPOS, abort);
566  double endPos = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_ENDPOS, abort);
567  std::string name = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_NAME, abort, false);
568  double chargingPower = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_CHARGINGPOWER, abort);
569  double efficiency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_EFFICIENCY, abort);
570  bool chargeInTransit = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_CHARGEINTRANSIT, abort);
571  double chargeDelay = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_CHARGEDELAY, abort);
572  bool friendlyPosition = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_FRIENDLY_POS, abort, false);
573  // Continue if all parameters were sucesfully loaded
574  if (!abort) {
575  // get pointer to lane
576  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
577  // check that all parameters are valid
578  if (GNEAttributeCarrier::isValidID(id) == false) {
579  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
580  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
581  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
582  } else if (lane == NULL) {
583  // Write error if lane isn't valid
584  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
585  } else if (!fixStoppinPlacePosition(startPos, endPos, lane->getLaneParametricLength(), POSITION_EPS, friendlyPosition)) {
586  // write error if position isn't valid
587  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
588  } else if (buildChargingStation(myViewNet, myUndoAdditionals, id, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition)) {
589  myLastTag = tag;
590  }
591  }
592 }
593 
594 
595 void
597  bool abort = false;
598  // parse attributes of calibrator
599  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
600  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
601  std::string outfile = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_OUTPUT, abort, false);
602  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_POSITION, abort);
603  double freq = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
604  // std::string routeProbe = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_ROUTEPROBE, abort); Currently routeProbe not used
605  std::vector<GNECalibratorRoute> calibratorRoutes;
606  std::vector<GNECalibratorFlow> calibratorFlows;
607  std::vector<GNECalibratorVehicleType> calibratorVehicleTypes;
608  // Continue if all parameters were sucesfully loaded
609  if (!abort) {
610  // get pointer to lane
611  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
612  // check that all parameters are valid
613  if (GNEAttributeCarrier::isValidID(id) == false) {
614  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
615  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
616  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
617  } else if (lane == NULL) {
618  // Write error if lane isn't valid
619  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
620  } else if (buildCalibrator(myViewNet, myUndoAdditionals, id, lane, position, outfile, freq, calibratorRoutes, calibratorFlows, calibratorVehicleTypes)) {
621  myLastTag = tag;
622  }
623  }
624 }
625 
626 
627 void
629  bool abort = false;
630  // parse attributes of E1
631  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
632  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
633  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_POSITION, abort);
634  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
635  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort, false);
636  std::string vehicleTypes = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_VTYPES, abort, false);
637  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_FRIENDLY_POS, abort);
638  // Continue if all parameters were sucesfully loaded
639  if (!abort) {
640  // get pointer to lane
641  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
642  // check that all parameters are valid
643  if (GNEAttributeCarrier::isValidID(id) == false) {
644  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
645  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
646  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
647  } else if (lane == NULL) {
648  // Write error if lane isn't valid
649  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
650  } else if (!checkAndFixDetectorPositionPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
651  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
652  } else if (buildDetectorE1(myViewNet, myUndoAdditionals, id, lane, position, frequency, file, vehicleTypes, friendlyPos)) {
653  myLastTag = tag;
654  }
655  }
656 }
657 
658 
659 void
661  bool abort = false;
662  // parse attributes of E2
663  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
664  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
665  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_POSITION, abort);
666  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
667  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort, false);
668  double length = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_LENGTH, abort);
669  double haltingTimeThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
670  double haltingSpeedThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
671  double jamDistThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_JAM_DIST_THRESHOLD, abort);
672  bool cont = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_CONT, abort);
673  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, id.c_str(), tag, SUMO_ATTR_FRIENDLY_POS, abort);
674  // Continue if all parameters were sucesfully loaded
675  if (!abort) {
676  // get pointer to lane
677  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
678  // check that all parameters are valid
679  if (GNEAttributeCarrier::isValidID(id) == false) {
680  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
681  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
682  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
683  } else if (lane == NULL) {
684  // Write error if lane isn't valid
685  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
686  } else if (!fixE2DetectorPositionPosition(position, length, lane->getLaneShapeLength(), friendlyPos)) {
687  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
688  } else if (buildDetectorE2(myViewNet, myUndoAdditionals, id, lane, position, length, frequency, file, cont, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, friendlyPos)) {
689  myLastTag = tag;
690  }
691  }
692 }
693 
694 
695 void
697  bool abort = false;
698  // parse attributes of E3
699  std::string id = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
700  double frequency = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
701  std::string file = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort, false);
702  double haltingTimeThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
703  double haltingSpeedThreshold = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
704  double posx = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_X, abort);
705  double posy = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, id.c_str(), tag, SUMO_ATTR_Y, abort);
706  // Continue if all parameters were sucesfully loaded
707  if (!abort) {
708  // check that all parameters are valid
709  if (GNEAttributeCarrier::isValidID(id) == false) {
710  WRITE_WARNING("The id '" + id + "' of additional " + toString(tag) + " contains invalid characters.");
711  myE3Parent = NULL;
713  } else if (myViewNet->getNet()->getAdditional(tag, id) != NULL) {
714  WRITE_WARNING("There is another " + toString(tag) + " with the same ID='" + id + "'.");
715  myE3Parent = NULL;
717  } else if (myViewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, id) == NULL) {
718  // Create without possibility of undo/redo
719  myE3Parent = new GNEDetectorE3(id, myViewNet, Position(posx, posy), frequency, file, haltingTimeThreshold, haltingSpeedThreshold);
720  myLastTag = tag;
721  }
722  }
723 }
724 
725 
726 void
728  bool abort = false;
729  // parse attributes of Entry
730  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_LANE, abort);
731  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_POSITION, abort);
732  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, 0, tag, SUMO_ATTR_FRIENDLY_POS, abort);
733  // Check if parsing of parameters was correct
734  if (!abort) {
735  // get pointer to lane
736  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
737  // check that all parameters are valid
738  if (lane == NULL) {
739  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
740  } else if (myE3Parent == NULL) {
741  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_E3DETECTOR) + ".");
742  } else if (!checkAndFixDetectorPositionPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
743  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
744  } else if (buildDetectorEntry(myViewNet, myUndoAdditionals, myE3Parent, lane, position, friendlyPos)) {
745  myLastTag = tag;
746  }
747  }
748 }
749 
750 
751 void
753  bool abort = false;
754  // parse attributes of Exit
755  std::string laneId = GNEAttributeCarrier::parseAttributeFromXML<std::string>(attrs, 0, tag, SUMO_ATTR_LANE, abort);
756  double position = GNEAttributeCarrier::parseAttributeFromXML<double>(attrs, 0, tag, SUMO_ATTR_POSITION, abort);
757  bool friendlyPos = GNEAttributeCarrier::parseAttributeFromXML<bool>(attrs, 0, tag, SUMO_ATTR_FRIENDLY_POS, abort);
758  // Check if parsing of parameters was correct
759  if (!abort) {
760  // get pointer to lane
761  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
762  // check that all parameters are valid
763  if (lane == NULL) {
764  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
765  } else if (myE3Parent == NULL) {
766  WRITE_WARNING("A " + toString(tag) + " must be declared within the definition of a " + toString(SUMO_TAG_E3DETECTOR) + ".");
767  } else if (!checkAndFixDetectorPositionPosition(position, lane->getLaneShapeLength(), friendlyPos)) {
768  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
769  } else if (buildDetectorExit(myViewNet, myUndoAdditionals, myE3Parent, lane, position, friendlyPos)) {
770  myLastTag = tag;
771  }
772  }
773 }
774 
775 
776 bool
777 GNEAdditionalHandler::buildAdditional(GNEViewNet* viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map<SumoXMLAttr, std::string> values) {
778  // create additional depending of the tag
779  switch (tag) {
780  case SUMO_TAG_BUS_STOP: {
781  // obtain specify attributes of busStop
782  std::string id = values[SUMO_ATTR_ID];
783  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
784  double startPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTPOS]);
785  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
786  std::string name = values[SUMO_ATTR_NAME];
787  std::vector<std::string> lines = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LINES]);
788  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
789  // Build busStop
790  if (lane) {
791  return buildBusStop(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, lines, friendlyPos);
792  } else {
793  return false;
794  }
795  }
797  // obtain specify attributes of containerStop
798  std::string id = values[SUMO_ATTR_ID];
799  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
800  double startPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTPOS]);
801  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
802  std::string name = values[SUMO_ATTR_NAME];
803  std::vector<std::string> lines = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LINES]);
804  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
805  // Build containerStop
806  if (lane) {
807  return buildContainerStop(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, lines, friendlyPos);
808  } else {
809  return false;
810  }
811  }
813  // obtain specify attributes of chargingStation
814  std::string id = values[SUMO_ATTR_ID];
815  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
816  double startPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTPOS]);
817  double endPos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_ENDPOS]);
818  std::string name = values[SUMO_ATTR_NAME];
819  double chargingPower = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_CHARGINGPOWER]);
820  double efficiency = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_EFFICIENCY]);
821  bool chargeInTransit = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CHARGEINTRANSIT]);
822  double chargeDelay = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_CHARGEDELAY]);
823  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
824  // Build chargingStation
825  if (lane) {
826  return buildChargingStation(viewNet, allowUndoRedo, id, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPos);
827  } else {
828  return false;
829  }
830  }
831  case SUMO_TAG_E1DETECTOR: {
832  // obtain specify attributes of detector E1
833  std::string id = values[SUMO_ATTR_ID];
834  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
835  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
836  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
837  std::string filename = values[SUMO_ATTR_FILE];
838  std::string vehicleTypes = values[SUMO_ATTR_VTYPES];
839  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
840  // Build detector E1
841  if (lane) {
842  return buildDetectorE1(viewNet, allowUndoRedo, id, lane, pos, freq, filename, vehicleTypes, friendlyPos);
843  } else {
844  return false;
845  }
846  }
847  case SUMO_TAG_E2DETECTOR: {
848  // obtain specify attributes of detector E2
849  std::string id = values[SUMO_ATTR_ID];
850  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
851  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
852  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
853  double length = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_LENGTH]);
854  std::string filename = values[SUMO_ATTR_FILE];
855  bool cont = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CONT]);
856  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
857  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
858  double jamThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_JAM_DIST_THRESHOLD]);
859  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
860  // Build detector E2
861  if (lane) {
862  return buildDetectorE2(viewNet, allowUndoRedo, id, lane, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold, friendlyPos);
863  } else {
864  return false;
865  }
866  }
867  case SUMO_TAG_E3DETECTOR: {
868  // obtain specify attributes of detector E3
869  bool ok;
870  std::string id = values[SUMO_ATTR_ID];
871  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
872  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
873  std::string filename = values[SUMO_ATTR_FILE];
874  double timeThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
875  double speedThreshold = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
876  // Build detector E3
877  if (pos.size() == 1) {
878  return buildDetectorE3(viewNet, allowUndoRedo, id, pos[0], freq, filename, timeThreshold, speedThreshold);
879  } else {
880  return false;
881  }
882  }
883  case SUMO_TAG_DET_ENTRY: {
884  // obtain specify attributes of detector Entry
885  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
886  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
887  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
888  GNEDetectorE3* E3 = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->retrieveAdditional(values[GNE_ATTR_PARENT]));
889  // Build detector Entry
890  if (lane && E3) {
891  return buildDetectorEntry(viewNet, allowUndoRedo, E3, lane, pos, friendlyPos);
892  } else {
893  return false;
894  }
895  }
896  case SUMO_TAG_DET_EXIT: {
897  // obtain specify attributes of Detector Exit
898  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
899  double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
900  bool friendlyPos = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_FRIENDLY_POS]);
901  GNEDetectorE3* E3 = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->retrieveAdditional(values[GNE_ATTR_PARENT]));
902  // Build detector Exit
903  if (lane && E3) {
904  return buildDetectorExit(viewNet, allowUndoRedo, E3, lane, pos, friendlyPos);
905  } else {
906  return false;
907  }
908  }
909  case SUMO_TAG_VSS: {
910  // obtain specify attributes of variable speed signal
911  std::string id = values[SUMO_ATTR_ID];
912  bool ok;
913  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
914  // Parse lane Ids
915  std::vector<std::string> laneIds = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_LANES]);
916  // By default, steps are empty
917  std::vector<GNEVariableSpeedSignStep> steps;
918  // Obtain pointers to lanes
919  std::vector<GNELane*> lanes;
920  for (int i = 0; i < (int)laneIds.size(); i++) {
921  lanes.push_back(viewNet->getNet()->retrieveLane(laneIds.at(i)));
922  }
923  std::string file = values[SUMO_ATTR_FILE];
924  if (pos.size() == 1) {
925  return buildVariableSpeedSign(viewNet, allowUndoRedo, id, pos[0], lanes, file, steps);
926  } else {
927  return false;
928  }
929  }
930  case SUMO_TAG_CALIBRATOR: {
931  // obtain specify attributes of calibrator
932  std::string id = values[SUMO_ATTR_ID];
933  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
934  // get rest of parameters
935  // Currently unused double pos = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_POSITION]);
936  double pos = 0;
937  std::string outfile = values[SUMO_ATTR_OUTPUT];
938  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
939  // get Calibrator values
940  std::vector<GNECalibratorRoute> calibratorRoutes;
941  std::vector<GNECalibratorFlow> calibratorFlows;
942  std::vector<GNECalibratorVehicleType> calibratorVehicleTypes;
943  // Build calibrator
944  if (lane) {
945  return buildCalibrator(viewNet, allowUndoRedo, id, lane, pos, outfile, freq, calibratorRoutes, calibratorFlows, calibratorVehicleTypes);
946  } else {
947  return false;
948  }
949  }
950  case SUMO_TAG_REROUTER: {
951  // obtain specify attributes of rerouter
952  std::string id = values[SUMO_ATTR_ID];
953  bool ok;
954  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
955  // Parse edges Ids
956  std::vector<std::string> edgeIds = GNEAttributeCarrier::parse<std::vector<std::string> >(values[SUMO_ATTR_EDGES]);
957  // Get rest of parameters
958  bool off = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_OFF]);
959  double prob = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_PROB]);
960  std::string file = values[SUMO_ATTR_FILE];
961  // Obtain pointers to edges
962  std::vector<GNEEdge*> edges;
963  for (int i = 0; i < (int)edgeIds.size(); i++) {
964  edges.push_back(viewNet->getNet()->retrieveEdge(edgeIds.at(i)));
965  }
966  // Build rerouter
967  if (pos.size() == 1) {
968  return buildRerouter(viewNet, allowUndoRedo, id, pos[0], edges, prob, file, off);
969  } else {
970  return false;
971  }
972  }
973  case SUMO_TAG_ROUTEPROBE: {
974  // obtain specify attributes of RouteProbe
975  std::string id = values[SUMO_ATTR_ID];
976  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
977  double freq = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_FREQUENCY]);
978  std::string filename = values[SUMO_ATTR_FILE];
979  double begin = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_BEGIN]);
980  // Build RouteProbe
981  if (edge) {
982  return buildRouteProbe(viewNet, allowUndoRedo, id, edge, freq, filename, begin);
983  } else {
984  return false;
985  }
986  }
987  case SUMO_TAG_VAPORIZER: {
988  // obtain specify attributes of vaporizer
989  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
990  double startTime = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_STARTTIME]);
991  double end = GNEAttributeCarrier::parse<double>(values[SUMO_ATTR_END]);
992  // Build RouteProbe
993  if (edge) {
994  return buildVaporizer(viewNet, allowUndoRedo, edge, startTime, end);
995  } else {
996  return false;
997  }
998  }
999  default:
1000  return false;
1001  }
1002 }
1003 
1004 
1005 bool
1006 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) {
1007  if (viewNet->getNet()->getAdditional(SUMO_TAG_BUS_STOP, id) == NULL) {
1008  GNEBusStop* busStop = new GNEBusStop(id, lane, viewNet, startPos, endPos, name, lines, friendlyPosition);
1009  if (allowUndoRedo) {
1010  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_BUS_STOP));
1011  viewNet->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
1012  viewNet->getUndoList()->p_end();
1013  } else {
1014  viewNet->getNet()->insertAdditional(busStop);
1015  lane->addAdditionalChild(busStop);
1016  }
1017  return true;
1018  } else {
1019  throw ProcessError("Could not build " + toString(SUMO_TAG_BUS_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1020  }
1021 }
1022 
1023 
1024 bool
1025 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) {
1026  if (viewNet->getNet()->getAdditional(SUMO_TAG_CONTAINER_STOP, id) == NULL) {
1027  GNEContainerStop* containerStop = new GNEContainerStop(id, lane, viewNet, startPos, endPos, name, lines, friendlyPosition);
1028  if (allowUndoRedo) {
1029  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CONTAINER_STOP));
1030  viewNet->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
1031  viewNet->getUndoList()->p_end();
1032  } else {
1033  viewNet->getNet()->insertAdditional(containerStop);
1034  lane->addAdditionalChild(containerStop);
1035  }
1036  return true;
1037  } else {
1038  throw ProcessError("Could not build " + toString(SUMO_TAG_CONTAINER_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
1039  }
1040 }
1041 
1042 
1043 bool
1044 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) {
1045  if (viewNet->getNet()->getAdditional(SUMO_TAG_CHARGING_STATION, id) == NULL) {
1046  GNEChargingStation* chargingStation = new GNEChargingStation(id, lane, viewNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit, chargeDelay, friendlyPosition);
1047  if (allowUndoRedo) {
1048  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CHARGING_STATION));
1049  viewNet->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
1050  viewNet->getUndoList()->p_end();
1051  } else {
1052  viewNet->getNet()->insertAdditional(chargingStation);
1053  lane->addAdditionalChild(chargingStation);
1054  }
1055  return true;
1056  } else {
1057  throw ProcessError("Could not build " + toString(SUMO_TAG_CHARGING_STATION) + " with ID '" + id + "' in netedit; probably declared twice.");
1058  }
1059 }
1060 
1061 
1062 bool
1063 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) {
1064  if (viewNet->getNet()->getAdditional(SUMO_TAG_E1DETECTOR, id) == NULL) {
1065  GNEDetectorE1* detectorE1 = new GNEDetectorE1(id, lane, viewNet, pos, freq, filename, vehicleTypes, friendlyPos);
1066  if (allowUndoRedo) {
1067  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E1DETECTOR));
1068  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
1069  viewNet->getUndoList()->p_end();
1070  } else {
1071  viewNet->getNet()->insertAdditional(detectorE1);
1072  lane->addAdditionalChild(detectorE1);
1073  }
1074  return true;
1075  } else {
1076  throw ProcessError("Could not build " + toString(SUMO_TAG_E1DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1077  }
1078 }
1079 
1080 
1081 bool
1082 GNEAdditionalHandler::buildDetectorE2(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, double length, double freq, const std::string& filename,
1083  bool cont, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos) {
1084  if (viewNet->getNet()->getAdditional(SUMO_TAG_E2DETECTOR, id) == NULL) {
1085  GNEDetectorE2* detectorE2 = new GNEDetectorE2(id, lane, viewNet, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold, friendlyPos);
1086  if (allowUndoRedo) {
1087  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E2DETECTOR));
1088  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
1089  viewNet->getUndoList()->p_end();
1090  } else {
1091  viewNet->getNet()->insertAdditional(detectorE2);
1092  lane->addAdditionalChild(detectorE2);
1093  }
1094  return true;
1095  } else {
1096  throw ProcessError("Could not build " + toString(SUMO_TAG_E2DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1097  }
1098 }
1099 
1100 
1101 bool
1102 GNEAdditionalHandler::buildDetectorE3(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, double freq, const std::string& filename, const double timeThreshold, double speedThreshold) {
1103  if (viewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, id) == NULL) {
1104  GNEDetectorE3* detectorE3 = new GNEDetectorE3(id, viewNet, pos, freq, filename, timeThreshold, speedThreshold);
1105  if (allowUndoRedo) {
1106  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
1107  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE3, true), true);
1108  viewNet->getUndoList()->p_end();
1109  } else {
1110  viewNet->getNet()->insertAdditional(detectorE3);
1111  }
1112  return true;
1113  } else {
1114  throw ProcessError("Could not build " + toString(SUMO_TAG_E3DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1115  }
1116 }
1117 
1118 
1119 bool
1120 GNEAdditionalHandler::buildDetectorEntry(GNEViewNet* viewNet, bool allowUndoRedo, GNEDetectorE3* E3Parent, GNELane* lane, double pos, bool friendlyPos) {
1121  // Check if Detector E3 parent and lane is correct
1122  if (lane == NULL) {
1123  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1124  } else if (E3Parent == NULL) {
1125  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
1126  } else {
1127  GNEDetectorEntry* entry = new GNEDetectorEntry(viewNet, E3Parent, lane, pos, friendlyPos);
1128  if (allowUndoRedo) {
1129  // insert E3 parent in net if previoulsy wasn't inserted
1130  if (viewNet->getNet()->getAdditional(E3Parent->getTag(), E3Parent->getID()) == NULL) {
1131  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
1132  viewNet->getUndoList()->add(new GNEChange_Additional(E3Parent, true), true);
1133  viewNet->getUndoList()->p_end();
1134  }
1135  // Create detector Entry if don't exist already in the net
1136  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_ENTRY));
1137  viewNet->getUndoList()->add(new GNEChange_Additional(entry, true), true);
1138  viewNet->getUndoList()->p_end();
1139  } else {
1140  // insert E3 parent in net if previoulsy wasn't inserted
1141  if (viewNet->getNet()->getAdditional(E3Parent->getTag(), E3Parent->getID()) == NULL) {
1142  viewNet->getNet()->insertAdditional(E3Parent);
1143  }
1144  E3Parent->addEntryChild(entry);
1145  viewNet->getNet()->insertAdditional(entry);
1146  lane->addAdditionalChild(entry);
1147  // update geometry for draw lines
1148  E3Parent->updateGeometry();
1149  }
1150  return true;
1151  }
1152 }
1153 
1154 
1155 bool
1156 GNEAdditionalHandler::buildDetectorExit(GNEViewNet* viewNet, bool allowUndoRedo, GNEDetectorE3* E3Parent, GNELane* lane, double pos, bool friendlyPos) {
1157  // Check if Detector E3 parent and lane is correct
1158  if (lane == NULL) {
1159  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1160  } else if (E3Parent == NULL) {
1161  throw ProcessError("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
1162  } else {
1163  GNEDetectorExit* exit = new GNEDetectorExit(viewNet, E3Parent, lane, pos, friendlyPos);
1164  if (allowUndoRedo) {
1165  // insert E3 parent in net if previoulsy wasn't inserted
1166  if (viewNet->getNet()->getAdditional(E3Parent->getTag(), E3Parent->getID()) == NULL) {
1167  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
1168  viewNet->getUndoList()->add(new GNEChange_Additional(E3Parent, true), true);
1169  viewNet->getUndoList()->p_end();
1170  }
1171  // Create detector Exit if don't exist already in the net
1172  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_EXIT));
1173  viewNet->getUndoList()->add(new GNEChange_Additional(exit, true), true);
1174  viewNet->getUndoList()->p_end();
1175  } else {
1176  // insert E3 parent in net if previoulsy wasn't inserted
1177  if (viewNet->getNet()->getAdditional(E3Parent->getTag(), E3Parent->getID()) == NULL) {
1178  viewNet->getNet()->insertAdditional(E3Parent);
1179  }
1180  E3Parent->addExitChild(exit);
1181  viewNet->getNet()->insertAdditional(exit);
1182  lane->addAdditionalChild(exit);
1183  // update geometry for draw lines
1184  E3Parent->updateGeometry();
1185  }
1186  return true;
1187  }
1188 }
1189 
1190 
1191 bool
1192 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNELane* lane, double pos, const std::string& outfile, const double freq,
1193  const std::vector<GNECalibratorRoute>& calibratorRoutes, const std::vector<GNECalibratorFlow>& calibratorFlows,
1194  const std::vector<GNECalibratorVehicleType>& calibratorVehicleTypes) {
1195  if (viewNet->getNet()->getAdditional(SUMO_TAG_CALIBRATOR, id) == NULL) {
1196  GNECalibrator* calibrator = new GNECalibrator(id, lane, viewNet, pos, freq, outfile, calibratorRoutes, calibratorFlows, calibratorVehicleTypes);
1197  if (allowUndoRedo) {
1198  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
1199  viewNet->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
1200  viewNet->getUndoList()->p_end();
1201  } else {
1202  viewNet->getNet()->insertAdditional(calibrator);
1203  lane->addAdditionalChild(calibrator);
1204  }
1205  return true;
1206  } else {
1207  throw ProcessError("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with ID '" + id + "' in netedit; probably declared twice.");
1208  }
1209 }
1210 
1211 
1212 bool
1213 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) {
1214  if (viewNet->getNet()->getAdditional(SUMO_TAG_REROUTER, id) == NULL) {
1215  GNERerouter* rerouter = new GNERerouter(id, viewNet, pos, edges, file, prob, off);
1216  if (allowUndoRedo) {
1217  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_REROUTER));
1218  viewNet->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
1219  viewNet->getUndoList()->p_end();
1220  } else {
1221  viewNet->getNet()->insertAdditional(rerouter);
1222  for (std::vector<GNEEdge*>::const_iterator i = edges.begin(); i != edges.end(); i++) {
1223  (*i)->addGNERerouter(rerouter);
1224  }
1225  }
1226  return true;
1227  } else {
1228  throw ProcessError("Could not build " + toString(SUMO_TAG_REROUTER) + " with ID '" + id + "' in netedit; probably declared twice.");
1229  }
1230 }
1231 
1232 
1233 bool
1234 GNEAdditionalHandler::buildRouteProbe(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, GNEEdge* edge, double freq, const std::string& file, double begin) {
1235  if (viewNet->getNet()->getAdditional(SUMO_TAG_ROUTEPROBE, id) == NULL) {
1236  GNERouteProbe* routeProbe = new GNERouteProbe(id, viewNet, edge, freq, file, begin);
1237  if (allowUndoRedo) {
1238  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_ROUTEPROBE));
1239  viewNet->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1240  viewNet->getUndoList()->p_end();
1241  } else {
1242  viewNet->getNet()->insertAdditional(routeProbe);
1243  edge->addAdditionalChild(routeProbe);
1244  }
1245  return true;
1246  } else {
1247  throw ProcessError("Could not build " + toString(SUMO_TAG_ROUTEPROBE) + " with ID '" + id + "' in netedit; probably declared twice.");
1248  }
1249 }
1250 
1251 
1252 bool
1253 GNEAdditionalHandler::buildVariableSpeedSign(GNEViewNet* viewNet, bool allowUndoRedo, const std::string& id, Position pos, const std::vector<GNELane*>& lanes, const std::string& file, const std::vector<GNEVariableSpeedSignStep>& steps) {
1254  if (viewNet->getNet()->getAdditional(SUMO_TAG_VSS, id) == NULL) {
1255  GNEVariableSpeedSign* variableSpeedSign = new GNEVariableSpeedSign(id, viewNet, pos, lanes, file, steps);
1256  if (allowUndoRedo) {
1257  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VSS));
1258  viewNet->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1259  viewNet->getUndoList()->p_end();
1260  } else {
1261  viewNet->getNet()->insertAdditional(variableSpeedSign);
1265  }
1266  return true;
1267  } else {
1268  throw ProcessError("Could not build " + toString(SUMO_TAG_VSS) + " with ID '" + id + "' in netedit; probably declared twice.");
1269  }
1270 }
1271 
1272 
1273 bool
1274 GNEAdditionalHandler::buildVaporizer(GNEViewNet* viewNet, bool allowUndoRedo, GNEEdge* edge, double startTime, double end) {
1275  GNEVaporizer* vaporizer = new GNEVaporizer(viewNet, edge, startTime, end);
1276  if (allowUndoRedo) {
1277  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VAPORIZER));
1278  viewNet->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1279  viewNet->getUndoList()->p_end();
1280  } else {
1281  viewNet->getNet()->insertAdditional(vaporizer);
1282  edge->addAdditionalChild(vaporizer);
1283  }
1284  return true;
1285 }
1286 
1287 
1288 std::string
1289 GNEAdditionalHandler::getFileName(const SUMOSAXAttributes& attrs, const std::string& base, const bool allowEmpty) {
1290  // get the file name to read further definitions from
1291  bool ok = true;
1292  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, 0, ok, "");
1293  if (file == "") {
1294  if (allowEmpty) {
1295  return file;
1296  }
1297  WRITE_WARNING("No filename given.");
1298  }
1299  // check whether absolute or relative filenames are given
1300  if (!FileHelpers::isAbsolute(file)) {
1301  return FileHelpers::getConfigurationRelative(base, file);
1302  }
1303  return file;
1304 }
1305 
1306 
1307 double
1308 GNEAdditionalHandler::getPosition(double pos, GNELane& lane, bool friendlyPos , const std::string& additionalID) {
1309  if (pos < 0) {
1310  pos = lane.getLaneShapeLength() + pos;
1311  }
1312  if (pos > lane.getLaneShapeLength()) {
1313  if (friendlyPos) {
1314  pos = lane.getLaneShapeLength() - (double) 0.1;
1315  } else {
1316  WRITE_WARNING("The position of additional '" + additionalID + "' lies beyond the lane's '" + lane.getID() + "' length.");
1317  }
1318  }
1319  return pos;
1320 }
1321 
1322 
1323 bool
1324 GNEAdditionalHandler::fixStoppinPlacePosition(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos) {
1325  if (minLength > laneLength) {
1326  return false;
1327  }
1328  if (startPos < 0) {
1329  startPos += laneLength;
1330  }
1331  if (endPos < 0) {
1332  endPos += laneLength;
1333  }
1334  if (endPos < minLength || endPos > laneLength) {
1335  if (!friendlyPos) {
1336  return false;
1337  }
1338  if (endPos < minLength) {
1339  endPos = minLength;
1340  }
1341  if (endPos > laneLength) {
1342  endPos = laneLength;
1343  }
1344  }
1345  if (startPos < 0 || startPos > endPos - minLength) {
1346  if (!friendlyPos) {
1347  return false;
1348  }
1349  if (startPos < 0) {
1350  startPos = 0;
1351  }
1352  if (startPos > endPos - minLength) {
1353  startPos = endPos - minLength;
1354  }
1355  }
1356  return true;
1357 }
1358 
1359 
1360 bool GNEAdditionalHandler::checkAndFixDetectorPositionPosition(double& pos, const double laneLength, const bool friendlyPos) {
1361  if ((pos < 0) || (pos > laneLength)) {
1362  if (!friendlyPos) {
1363  return false;
1364  } else if (pos < 0) {
1365  pos = 0;
1366  } else if (pos > laneLength) {
1367  pos = laneLength;
1368  }
1369  }
1370  return true;
1371 }
1372 
1373 
1375 GNEAdditionalHandler::getTypeOfFlowDistribution(std::string flowID, double vehsPerHour, double period, double probability) {
1376  if ((vehsPerHour == -1) && (period == -1) && (probability == -1)) {
1377  WRITE_WARNING("A type of distribution (" + toString(SUMO_ATTR_VEHSPERHOUR) + ", " + toString(SUMO_ATTR_PERIOD) + " or " +
1378  toString(SUMO_ATTR_PROB) + ") must be defined in " + toString(SUMO_TAG_FLOW) + " '" + flowID + "'");
1380  } else {
1381  int vehsPerHourDefined = (vehsPerHour != -1) ? 1 : 0;
1382  int periodDefined = (period != -1) ? 1 : 0;
1383  int probabilityDefined = (probability != -1) ? 1 : 0;
1384 
1385  if ((vehsPerHourDefined + periodDefined + probabilityDefined) != 1) {
1386  WRITE_WARNING("Only a type of distribution (" + toString(SUMO_ATTR_VEHSPERHOUR) + ", " + toString(SUMO_ATTR_PERIOD) + " or " +
1387  toString(SUMO_ATTR_PROB) + ") can be defined at the same time in " + toString(SUMO_TAG_FLOW) + " '" + flowID + "'");
1389  } else if (vehsPerHourDefined == 1) {
1391  } else if (periodDefined == 1) {
1393  } else if (probabilityDefined == 1) {
1395  } else {
1397  }
1398  }
1399 }
1400 
1401 
1402 bool GNEAdditionalHandler::fixE2DetectorPositionPosition(double& pos, double& length, const double laneLength, const bool friendlyPos) {
1403  if ((pos < 0) || ((pos + length) > laneLength)) {
1404  if (!friendlyPos) {
1405  return false;
1406  } else if (pos < 0) {
1407  pos = 0;
1408  } else if (pos > laneLength) {
1409  pos = laneLength;
1410  length = 0;
1411  } else if ((pos + length) > laneLength) {
1412  length = laneLength - pos;
1413  }
1414  }
1415  return true;
1416 }
1417 
1418 
1419 void
1423  WRITE_WARNING((toString(myE3Parent->getTag()) + "s without " + toString(SUMO_TAG_DET_ENTRY) + "s or " + toString(SUMO_TAG_DET_EXIT) + " aren't allowed; " +
1424  toString(myE3Parent->getTag()) + " with ID = '" + myE3Parent->getID() + "' cannot be created.").c_str());
1425  // check if has to be removed of the net before removing
1426  if (myViewNet->getNet()->getAdditional(myE3Parent->getTag(), myE3Parent->getID()) != NULL) {
1428  }
1429  delete myE3Parent;
1430  myE3Parent = NULL;
1431  }
1432 }
1433 
1434 
1435 bool
1437  // If last tag was an E3 but next tag isn't an Entry or Exit
1439  !((currentTag == SUMO_TAG_DET_ENTRY) || (currentTag == SUMO_TAG_DET_EXIT))) {
1440  // Remove created E3 to avoid load empty detectors
1441  if (myE3Parent != NULL) {
1442  // show E3 empty warning and delete empty E3
1443  WRITE_WARNING((toString(myE3Parent->getTag()) + "s without " + toString(SUMO_TAG_DET_ENTRY) + "s or " + toString(SUMO_TAG_DET_EXIT) + " aren't allowed; " +
1444  toString(myE3Parent->getTag()) + " with ID = '" + myE3Parent->getID() + "' cannot be created.").c_str());
1445  delete myE3Parent;
1446  myE3Parent = NULL;
1447  }
1448  // continue with the processing of additional
1449  return true;
1450  }
1451 
1452  // if last tag wasn't an E3 but next tag is an entry or exit
1454  ((currentTag == SUMO_TAG_DET_ENTRY) || (currentTag == SUMO_TAG_DET_EXIT))) {
1455  if (myE3Parent != NULL) {
1456  // In this case, we're loading a E3 with multiple entry exits, then continue
1457  return true;
1458  } else {
1459  // return false to stop procesing current entry or exit and go to the next tag (this avoid some useless warnings)
1460  return false;
1461  }
1462  }
1463 
1464  // if last tag was a Calibrator but next tag is a vehicle type, route or flow
1465  if (!(myLastTag == SUMO_TAG_CALIBRATOR) && ((currentTag == SUMO_TAG_ROUTE) || (currentTag == SUMO_TAG_FLOW) || (currentTag == SUMO_TAG_VTYPE))) {
1466  if (myCalibratorParent != NULL) {
1467  // In this case, we're loading a Calibrator with multiple routes/flows/vehicleTypes, then continue
1468  return true;
1469  } else {
1470  // return false to stop procesing current route/flow/vehicleType and go to the next tag (this avoid some useless warnings)
1471  return false;
1472  }
1473  }
1474 
1475  // if last tag wasn't a Variable speed Sign but next tag is a step
1476  if (!(myLastTag != SUMO_TAG_CALIBRATOR) && (currentTag == SUMO_TAG_STEP)) {
1477  if (myVariableSpeedSignParent != NULL) {
1478  // In this case, we're loading a Variable Speed Signal with multiple steps, then continue
1479  return true;
1480  } else {
1481  // return false to stop procesing current step and go to the next tag (this avoid some useless warnings)
1482  return false;
1483  }
1484  }
1485 
1486  // all OK
1487  return true;
1488 }
1489 
1490 /****************************************************************************/
void parseVariableSpeedSignStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses step values of VariableSpeedSigns.
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:730
SumoXMLTag
Numbers representing SUMO-XML - element names.
void parseCalibratorVehicleType(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses vehicle type values of Calibrators.
void parseCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
a routeprobe detector
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:899
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:82
description of a vehicle type
void addCalibratorRoute(const GNECalibratorRoute &route)
add calibrator route
bool flowExists(const std::string &flowID) const
Check if exist a flow with these ID.
Definition: GNENet.cpp:1792
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 addCalibratorFlow(const GNECalibratorFlow &flow)
add calibrator flow
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
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)
builds a rerouter
Allow/disallow charge in transit in Charging Stations.
bool vehicleTypeExists(const std::string &vehicleTypeID) const
Check if exist a vehicle type with these ID.
Definition: GNENet.cpp:1779
void addExitChild(GNEDetectorExit *exit)
add an Exit child
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.
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
bool routeExists(const std::string &routeID) const
Check if exist a route with these ID.
Definition: GNENet.cpp:1766
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:54
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:85
GNEVariableSpeedSign * myVariableSpeedSignParent
Pointer to the last inserted variableSpeedSign.
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.
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...
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:200
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
const std::vector< GNEVariableSpeedSignStep > & getSteps() const
get values of variable speed signal
GNEUndoList * getUndoList() const
get the undoList object
GNECalibratorFlow::TypeOfFlow getTypeOfFlowDistribution(std::string flowID, double vehsPerHour, double period, double probability)
get a error message, if configuration of flow distribution is invalid
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
~GNEAdditionalHandler()
Destructor.
TypeOfFlow
type of flow
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
Definition: GNEEdge.cpp:1185
const std::string & getFileName() const
returns the current file name
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
void updateGeometry()
update pre-computed geometry information
Encapsulated SAX-Attributes.
SumoXMLTag getTag() const
get tag
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
Definition: FileHelpers.cpp:97
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:92
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void addAdditionalChild(GNEAdditional *additional)
add additional child to this lane
Definition: GNELane.cpp:735
an e3 exit point
A list of positions.
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
Definition: GNENet.cpp:958
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 parseAndBuildRerouter(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a rerouter.
void addStep(const GNEVariableSpeedSignStep &step)
insert a new step in variable speed signal
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:58
#define POSITION_EPS
Definition: config.h:176
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)
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.
const std::string getID() const
function to support debugging
bool checkAdditionalParent(SumoXMLTag currentTag)
used to check hierarchy of aditionals with parents and childs (for example, E3)
GNEViewNet * myViewNet
pointer to View&#39;s Net
GNECalibrator * myCalibratorParent
Pointer to the last inserted Calibrator.
void addCalibratorVehicleType(const GNECalibratorVehicleType &vehicleType)
add calibrator vehicleType
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
begin/end of the description of an edge
void parseAndBuildRouteProbe(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds routeProbe.
GNEDetectorE3 * myE3Parent
Pointer to the last inserted E3.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
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.
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1680
trigger: the time of the step
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
weights: time range end
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a vaporization.
void resetLastTag()
reset last Tag and clear non-valid Additionals (For example, created E3 withouts Entry/Exit childs) ...
GNENet * getNet() const
get the net object
vaporizer of vehicles
void deleteAdditional(GNEAdditional *additional)
delete additional element previously inserted
Definition: GNENet.cpp:1622
SumoXMLTag getTag() const
get XML Tag assigned to this object
void addEntryChild(GNEDetectorEntry *entry)
add an Entry child
A variable speed sign.
Eficiency of the charge in Charging Stations.
SumoXMLTag myLastTag
last used Tag
parent of an additional element
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.
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.
static bool buildVariableSpeedSign(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, Position pos, const std::vector< GNELane * > &destLanes, const std::string &file, const std::vector< GNEVariableSpeedSignStep > &steps)
Builds a VariableSpeedSign (lane speed trigger)
int getNumberOfEntryChilds() const
get number of entry childs
int getNumberOfExitChilds() const
get number of exit childs
GNEAdditional * retrieveAdditional(const std::string &idl, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:1653
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 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
void insertAdditional(GNEAdditional *additional, bool hardFail=true)
Insert a additional element previously created in GNEAdditionalHandler.
Definition: GNENet.cpp:1604
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:719
void parseCalibratorRoute(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses route values of Calibrators.
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)
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)
trigger: a step description
static bool buildCalibrator(GNEViewNet *viewNet, bool allowUndoRedo, const std::string &id, GNELane *lane, double pos, const std::string &outfile, double freq, const std::vector< GNECalibratorRoute > &calibratorRoutes, const std::vector< GNECalibratorFlow > &calibratorFlows, const std::vector< GNECalibratorVehicleType > &calibratorVehicleTypes)
builds a microscopic calibrator