SUMO - Simulation of Urban MObility
GNEAdditionalHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
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 
57 #ifdef CHECK_MEMORY_LEAKS
58 #include <foreign/nvwa/debug_new.h>
59 #endif
60 
61 
62 // ===========================================================================
63 // member method definitions
64 // ===========================================================================
65 
66 GNEAdditionalHandler::GNEAdditionalHandler(const std::string& file, GNEViewNet* viewNet) :
67  SUMOSAXHandler(file),
68  myViewNet(viewNet),
69  myE3Parent(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  myE3Parent = NULL;
89  break;
91  parseAndBuildContainerStop(attrs, tag);
92  myE3Parent = NULL;
93  break;
95  parseAndBuildChargingStation(attrs, tag);
96  myE3Parent = NULL;
97  break;
100  parseAndBuildDetectorE1(attrs, tag);
101  myE3Parent = NULL;
102  break;
103  case SUMO_TAG_E2DETECTOR:
105  parseAndBuildDetectorE2(attrs, tag);
106  myE3Parent = NULL;
107  break;
108  case SUMO_TAG_E3DETECTOR:
110  parseAndBuildDetectorE3(attrs, tag);
111  break;
112  case SUMO_TAG_DET_ENTRY:
113  parseAndBuildDetectorEntry(attrs, tag);
114  break;
115  case SUMO_TAG_DET_EXIT:
116  parseAndBuildDetectorExit(attrs, tag);
117  break;
118  case SUMO_TAG_VSS:
119  parseAndBuildVariableSpeedSign(attrs, tag);
120  myE3Parent = NULL;
121  break;
122  case SUMO_TAG_REROUTER:
123  parseAndBuildRerouter(attrs, tag);
124  myE3Parent = NULL;
125  break;
126  case SUMO_TAG_CALIBRATOR:
127  parseAndBuildCalibrator(attrs, tag);
128  myE3Parent = NULL;
129  break;
130  case SUMO_TAG_VAPORIZER:
131  parseAndBuildVaporizer(attrs, tag);
132  myE3Parent = NULL;
133  break;
134  case SUMO_TAG_ROUTEPROBE:
135  parseAndBuildRouteProbe(attrs, tag);
136  myE3Parent = NULL;
137  break;
138  case SUMO_TAG_FLOW:
139  parseCalibratorFlow(attrs, tag);
140  myE3Parent = NULL;
141  break;
142  case SUMO_TAG_STEP:
143  parseVariableSpeedSignStep(attrs, tag);
144  myE3Parent = NULL;
145  break;
146  default:
147  break;
148  }
149  }
150 }
151 
152 
153 void
155  bool abort = false;
156  // parse attributes of Vaporizer
157  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
158  const std::string edgeId = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_EDGE, abort);
159  SUMOReal startTime = getParsedAttribute<SUMOReal>(attrs, 0, tag, SUMO_ATTR_STARTTIME, abort);
160  SUMOReal endTime = getParsedAttribute<SUMOReal>(attrs, 0, tag, SUMO_ATTR_END, abort);
161  // Continue if all parameters were successfully loaded
162  if (!abort) {
163  // get edge
164  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
165  if (edge == NULL) {
166  // Write error if lane isn't valid
167  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
168  } else {
169  // build Vaporizer
170  buildVaporizer(myViewNet, id, edge, startTime, endTime);
171  }
172  }
173 }
174 
175 
176 
177 void
179  bool abort = false;
180  // parse attributes of RouteProbe
181  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
182  std::string edgeId = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_EDGE, abort);
183  SUMOReal freq = getParsedAttribute<SUMOReal>(attrs, 0, tag, SUMO_ATTR_FREQUENCY, abort);
184  std::string file = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_FILE, abort);
185  int begin = getParsedAttribute<int>(attrs, 0, tag, SUMO_ATTR_BEGIN, abort);
186  // Continue if all parameters were sucesfully loaded
187  if (!abort) {
188  // get edge
189  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
190  if (edge == NULL) {
191  // Write error if lane isn't valid
192  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
193  } else {
194  // build Vaporizer
195  buildRouteProbe(myViewNet, id, edge, freq, file, begin);
196  }
197  }
198 }
199 
200 
201 void
203  bool ok = true;
204  bool abort = false;
205  // Load non empty values
206  std::string flowId = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
207  if (!ok) {
208  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_CALIBRATOR) + " is missing");
209  ok = true;
210  abort = true;
211  }
212  std::string type = attrs.get<std::string>(SUMO_ATTR_TYPE, flowId.c_str(), ok, false);
213  if (!ok) {
214  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_TYPE) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_CALIBRATOR) + " is missing");
215  ok = true;
216  abort = true;
217  }
218  std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowId.c_str(), ok, false);
219  if (!ok) {
220  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ROUTE) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_CALIBRATOR) + " is missing");
221  ok = true;
222  abort = true;
223  }
224  // Declare calibrator flow
226 
227  // Load rest of parameters
228  flow->setColor(attrs.getOpt<std::string>(SUMO_ATTR_COLOR, flowId.c_str(), ok, "", false));
229  flow->setDepartLane(attrs.getOpt<std::string>(SUMO_ATTR_DEPARTLANE, flowId.c_str(), ok, "first", false));
230  flow->setDepartPos(attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, flowId.c_str(), ok, "base", false));
231  flow->setDepartSpeed(attrs.getOpt<std::string>(SUMO_ATTR_DEPARTSPEED, flowId.c_str(), ok, "0", false));
232  flow->setArrivalLane(attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALLANE, flowId.c_str(), ok, "current", false));
233  flow->setArrivalPos(attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALPOS, flowId.c_str(), ok, "max", false));
234  flow->setArrivalSpeed(attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALSPEED, flowId.c_str(), ok, "current", false));
235  flow->setLine(attrs.getOpt<std::string>(SUMO_ATTR_LINE, flowId.c_str(), ok, "", false));
236  flow->setPersonNumber(attrs.getOpt<int>(SUMO_ATTR_PERSON_NUMBER, flowId.c_str(), ok, 0, false));
237  flow->setContainerNumber(attrs.getOpt<int>(SUMO_ATTR_CONTAINER_NUMBER, flowId.c_str(), ok, 0, false));
238  flow->setBegin(attrs.getOpt<SUMOReal>(SUMO_ATTR_BEGIN, flowId.c_str(), ok, 0, false));
239  flow->setEnd(attrs.getOpt<SUMOReal>(SUMO_ATTR_END, flowId.c_str(), ok, 0, false));
240  flow->setVehsPerHour(attrs.getOpt<SUMOReal>(SUMO_ATTR_VEHSPERHOUR, flowId.c_str(), ok, 0, false));
241  flow->setPeriod(attrs.getOpt<SUMOReal>(SUMO_ATTR_PERIOD, flowId.c_str(), ok, 0, false));
242  flow->setProbability(attrs.getOpt<SUMOReal>(SUMO_ATTR_PROB, flowId.c_str(), ok, 0, false));
243  flow->setNumber(attrs.getOpt<int>(SUMO_ATTR_NUMBER, flowId.c_str(), ok, 0, false));
244  // Continue if all parameters were sucesfully loaded
245  if (!abort) {
246  // Obtain calibrator
247  GNECalibrator* calibratorToInsertFlow = /*dynamic_cast<GNECalibrator*>(myViewNet->getNet()->getAdditional(SUMO_TAG_CALIBRATOR, myAdditionalParent))*/ NULL;
248  if (calibratorToInsertFlow == NULL) {
249  WRITE_WARNING("A " + toString(SUMO_TAG_CALIBRATOR) + " must be inserter before insertion of the " + toString(tag) + " '" + flowId + "'");
250  delete flow;
251  } else {
252  calibratorToInsertFlow->insertFlow(flow);
253  }
254  delete flow;
255  }
256 }
257 
258 
259 void
261  bool ok = true;
262  bool abort = false;
263  // Load step values
264  SUMOReal time = attrs.get<SUMOReal>(SUMO_ATTR_TIME, 0, ok, false);
265  if (!ok) {
266  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_TIME) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_VSS) + " is missing");
267  ok = true;
268  abort = true;
269  }
270  SUMOReal speed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, false);
271  if (!ok) {
272  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_SPEED) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_VSS) + " is missing");
273  ok = true;
274  abort = true;
275  }
276  // Continue if all parameters were sucesfully loaded
277  if (!abort) {
278  GNEVariableSpeedSign* variableSpeedSignToInsertStep = /*dynamic_cast<GNEVariableSpeedSign*>(myViewNet->getNet()->getAdditional(SUMO_TAG_VSS, myAdditionalParent))*/ NULL;
279  if (variableSpeedSignToInsertStep == NULL) {
280  WRITE_WARNING("A " + toString(SUMO_TAG_VSS) + " must be inserter before insertion of a " + toString(tag));
281  } else if (!variableSpeedSignToInsertStep->insertStep(time, speed)) {
282  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_TIME) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_VSS) + " is duplicated");
283  }
284  }
285 }
286 
287 
288 void
290  bool abort = false;
291  // parse attributes of VSS
292  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
293  std::string file = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort);
294  std::string listOfLanes = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANES, abort);
295  SUMOReal posx = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_X, abort);
296  SUMOReal posy = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_Y, abort);
297  // Continue if all parameters were sucesfully loaded
298  if (!abort) {
299  // Obtain lanes
300  std::vector<std::string> lanesID;
301  SUMOSAXAttributes::parseStringVector(listOfLanes, lanesID);
302  // obtain VSS Values
303  // @todo
304  std::map<SUMOReal, SUMOReal> VSSValues;
305  // Obtain pointer to lanes
306  std::vector<GNELane*> lanes;
307  for (int i = 0; i < (int)lanesID.size(); i++) {
308  GNELane* lane = myViewNet->getNet()->retrieveLane(lanesID.at(i));
309  if (lane) {
310  lanes.push_back(lane);
311  } else {
312  WRITE_WARNING(toString(SUMO_TAG_LANE) + " '" + lanesID.at(i) + "' isn't valid");
313  }
314  }
315  // if operation of build variable speed signal was sucesfully, save Id
316  if (buildVariableSpeedSign(myViewNet, id, Position(posx, posy), lanes, file, VSSValues)) {
317  ;//myAdditionalParent = id;
318  }
319  }
320 }
321 
322 
323 void
325  bool abort = false;
326  // parse attributes of Rerouter
327  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
328  std::string edgesAttribute = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_EDGES, abort);
329  std::string file = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort);
330  SUMOReal probability = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_PROB, abort);
331  bool off = getParsedAttribute<bool>(attrs, id.c_str(), tag, SUMO_ATTR_OFF, abort);
332  SUMOReal posx = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_X, abort);
333  SUMOReal posy = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_Y, abort);
334  // Continue if all parameters were sucesfully loaded
335  if (!abort) {
336  // Obtain edges
337  std::vector<std::string> edgesID;
338  bool ok = false;
339  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_EDGES, id.c_str(), ok, "", false), edgesID);
340  // obtain Rerouter values Values
341 
342  // Obtain pointer to edges
343  std::vector<GNEEdge*> edges;
344  for (int i = 0; i < (int)edgesID.size(); i++) {
345  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgesID.at(i));
346  if (edge) {
347  edges.push_back(edge);
348  } else {
349  throw ProcessError(); /**************** ARREGLAR **********/
350  }
351  }
352  // if operation of build variable speed signal was sucesfully, save Id
353  if (buildRerouter(myViewNet, id, Position(posx, posy), edges, probability, file, off)) {
354  ;//myAdditionalParent = id;
355  }
356  }
357 }
358 
359 
360 void
362  bool abort = false;
363  // parse attributes of bus stop
364  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
365  std::string laneId = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
366  SUMOReal startPos = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_STARTPOS, abort);
367  SUMOReal endPos = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_ENDPOS, abort);
368  std::string linesAttribute = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LINES, abort, false);
369  // Continue if all parameters were sucesfully loaded
370  if (!abort) {
371  // Parse lines
372  std::vector<std::string> lines;
373  SUMOSAXAttributes::parseStringVector(linesAttribute, lines);
374  // get pointer to lane
375  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
376  if (lane == NULL) {
377  // Write error if lane isn't valid
378  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
379  } else if (!checkStopPos(startPos, endPos, lane->getLaneShapeLenght(), POSITION_EPS, getFriendlyPosition(attrs, id.c_str()))) {
380  // Write error if position isn't valid
381  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
382  } else if (buildBusStop(myViewNet, id, lane, startPos, endPos, lines)) {
383  myLastTag = tag;
384  }
385  }
386 }
387 
388 
389 void
391  bool abort = false;
392  // parse attributes of container stop
393  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
394  std::string laneId = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
395  SUMOReal startPos = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_STARTPOS, abort);
396  SUMOReal endPos = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_ENDPOS, abort);
397  std::string linesAttribute = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LINES, abort, false);
398  // Continue if all parameters were sucesfully loaded
399  if (!abort) {
400  // Parse lines
401  std::vector<std::string> lines;
402  SUMOSAXAttributes::parseStringVector(linesAttribute, lines);
403  // get pointer to lane
404  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
405  if (lane == NULL) {
406  // Write error if lane isn't valid
407  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
408  } else if (!checkStopPos(startPos, endPos, lane->getLaneShapeLenght(), POSITION_EPS, getFriendlyPosition(attrs, id.c_str()))) {
409  // write error if position isn't valid
410  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
411  } else if (buildContainerStop(myViewNet, id, lane, startPos, endPos, lines)) {
412  myLastTag = tag;
413  }
414  }
415 }
416 
417 
418 void
420  bool abort = false;
421  // parse attributes of charging station
422  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
423  std::string laneId = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
424  SUMOReal startPos = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_STARTPOS, abort);
425  SUMOReal endPos = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_ENDPOS, abort);
426  SUMOReal chrgpower = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_CHARGINGPOWER, abort);
427  SUMOReal efficiency = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_EFFICIENCY, abort);
428  bool chargeInTransit = getParsedAttribute<bool>(attrs, id.c_str(), tag, SUMO_ATTR_CHARGEINTRANSIT, abort);
429  SUMOReal chargeDelay = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_CHARGEDELAY, abort);
430  // Continue if all parameters were sucesfully loaded
431  if (!abort) {
432  // get pointer to lane
433  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
434  if (lane == NULL) {
435  // Write error if lane isn't valid
436  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
437  } else if (!checkStopPos(startPos, endPos, lane->getLaneShapeLenght(), POSITION_EPS, getFriendlyPosition(attrs, id.c_str()))) {
438  // write error if position isn't valid
439  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
440  } else if (buildChargingStation(myViewNet, id, lane, startPos, endPos, chrgpower, efficiency, chargeInTransit, chargeDelay)) {
441  myLastTag = tag;
442  }
443  }
444 }
445 
446 
447 void
449  bool abort = false;
450  // parse attributes of calibrator
451  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
452  std::string laneId = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
453  std::string outfile = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_OUTPUT, abort);
454  SUMOReal position = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_POSITION, abort);
455  SUMOReal freq = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
456  // std::string routeProbe = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_ROUTEPROBE, abort); Currently routeProbe not used
457  // Continue if all parameters were sucesfully loaded
458  if (!abort) {
459  // get pointer to edge
460  GNEEdge* edge = &(myViewNet->getNet()->retrieveLane(laneId, false)->getParentEdge());
461  if (edge == NULL) {
462  // Write error if lane isn't valid
463  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
464  } else if (buildCalibrator(myViewNet, id, edge, position, outfile, freq, std::vector<GNECalibrator::GNECalibratorFlow*>())) {
465  myLastTag = tag;
466  }
467  }
468 }
469 
470 
471 void
473  bool abort = false;
474  // parse attributes of E1
475  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
476  std::string laneId = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
477  SUMOReal position = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_POSITION, abort);
478  SUMOReal frequency = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
479  std::string file = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort);
480  bool splitByType = getParsedAttribute<bool>(attrs, id.c_str(), tag, SUMO_ATTR_SPLIT_VTYPE, abort);
481  // Continue if all parameters were sucesfully loaded
482  if (!abort) {
483  // get pointer to lane
484  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
485  if (lane == NULL) {
486  // Write error if lane isn't valid
487  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
488  } else if ((position < 0) || (position > (lane->getLaneShapeLenght()))) {
489  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
490  } else if (buildDetectorE1(myViewNet, id, lane, position, frequency, file, splitByType)) {
491  myLastTag = tag;
492  }
493  }
494 }
495 
496 
497 void
499  bool abort = false;
500  // parse attributes of E2
501  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
502  std::string laneId = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_LANE, abort);
503  SUMOReal position = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_POSITION, abort);
504  SUMOReal frequency = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
505  std::string file = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort);
506  SUMOReal length = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_LENGTH, abort);
507  SUMOReal haltingTimeThreshold = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
508  SUMOReal haltingSpeedThreshold = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
509  SUMOReal jamDistThreshold = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_JAM_DIST_THRESHOLD, abort);
510  bool cont = getParsedAttribute<bool>(attrs, id.c_str(), tag, SUMO_ATTR_CONT, abort);
511  // Continue if all parameters were sucesfully loaded
512  if (!abort) {
513  // get pointer to lane
514  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
515  if (lane == NULL) {
516  // Write error if lane isn't valid
517  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
518  } else if ((position < 0) || ((position + length) > (lane->getLaneShapeLenght()))) {
519  WRITE_WARNING("Invalid position for " + toString(tag) + " with ID = '" + id + "'.");
520  } else if (buildDetectorE2(myViewNet, id, lane, position, length, frequency, file, cont, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold)) {
521  myLastTag = tag;
522  }
523  }
524 }
525 
526 
527 void
529  bool abort = false;
530  // parse attributes of E3
531  std::string id = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_ID, abort);
532  SUMOReal frequency = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_FREQUENCY, abort);
533  std::string file = getParsedAttribute<std::string>(attrs, id.c_str(), tag, SUMO_ATTR_FILE, abort);
534  SUMOReal haltingTimeThreshold = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_TIME_THRESHOLD, abort);
535  SUMOReal haltingSpeedThreshold = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_HALTING_SPEED_THRESHOLD, abort);
536  SUMOReal posx = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_X, abort);
537  SUMOReal posy = getParsedAttribute<SUMOReal>(attrs, id.c_str(), tag, SUMO_ATTR_Y, abort);
538  // Continue if all parameters were sucesfully loaded
539  if (!abort) {
540  // Create without possibility of undo/redo
541  if (myViewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, id) == NULL) {
542  myE3Parent = new GNEDetectorE3(id, myViewNet, Position(posx, posy), frequency, file, haltingTimeThreshold, haltingSpeedThreshold);
544  } else {
545  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E3DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
546  myE3Parent = NULL;
547  }
548  }
549 }
550 
551 
552 void
554  bool abort = false;
555  // parse attributes of Entry
556  std::string laneId = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_LANE, abort);
557  SUMOReal position = getParsedAttribute<SUMOReal>(attrs, 0, tag, SUMO_ATTR_POSITION, abort);
558  // Check if parsing of parameters was correct
559  if (!abort) {
560  // get pointer to lane
561  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
562  if (lane == NULL) {
563  // Write error if lane isn't valid
564  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
565  } else if ((position < 0) || (position > (lane->getLaneShapeLenght()))) {
566  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
567  } else if (myE3Parent != NULL && buildDetectorEntry(myViewNet, myE3Parent, lane, position)) {
568  myLastTag = tag;
569  }
570  }
571 }
572 
573 
574 void
576  bool abort = false;
577  // parse attributes of Exit
578  std::string laneId = getParsedAttribute<std::string>(attrs, 0, tag, SUMO_ATTR_LANE, abort);
579  SUMOReal position = getParsedAttribute<SUMOReal>(attrs, 0, tag, SUMO_ATTR_POSITION, abort);
580  // Check if parsing of parameters was correct
581  if (!abort) {
582  // get pointer to lane
583  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
584  if (lane == NULL) {
585  // Write error if lane isn't valid
586  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
587  } else if ((position < 0) || (position > (lane->getLaneShapeLenght()))) {
588  WRITE_WARNING("Invalid position for " + toString(tag) + ".");
589  } else if (myE3Parent != NULL && buildDetectorExit(myViewNet, myE3Parent, lane, position)) {
590  myLastTag = tag;
591  }
592  }
593 }
594 
595 
596 bool
597 GNEAdditionalHandler::buildAdditional(GNEViewNet* viewNet, SumoXMLTag tag, std::map<SumoXMLAttr, std::string> values) {
598  // create additional depending of the tag
599  switch (tag) {
600  case SUMO_TAG_BUS_STOP: {
601  // obtain specify attributes of busStop
602  std::string id = values[SUMO_ATTR_ID];
603  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
604  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTPOS]);
605  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_ENDPOS]);
606  std::vector<std::string> lines;
608  // Build busStop
609  if (lane) {
610  return buildBusStop(viewNet, id, lane, startPos, endPos, lines);
611  } else {
612  return false;
613  }
614  }
616  // obtain specify attributes of containerStop
617  std::string id = values[SUMO_ATTR_ID];
618  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
619  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTPOS]);
620  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_ENDPOS]);
621  std::vector<std::string> lines;
623  // Build containerStop
624  if (lane) {
625  return buildContainerStop(viewNet, id, lane, startPos, endPos, lines);
626  } else {
627  return false;
628  }
629  }
631  // obtain specify attributes of chargingStation
632  std::string id = values[SUMO_ATTR_ID];
633  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
634  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTPOS]);
635  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_ENDPOS]);
636  SUMOReal chargingPower = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_CHARGINGPOWER]);
637  SUMOReal efficiency = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_EFFICIENCY]);
638  bool chargeInTransit = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CHARGEINTRANSIT]);
639  SUMOReal chargeDelay = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_CHARGEDELAY]);
640  // Build chargingStation
641  if (lane) {
642  return buildChargingStation(viewNet, id, lane, startPos, endPos, chargingPower, efficiency, chargeInTransit, chargeDelay);
643  } else {
644  return false;
645  }
646  }
647  case SUMO_TAG_E1DETECTOR: {
648  // obtain specify attributes of detector E1
649  std::string id = values[SUMO_ATTR_ID];
650  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
651  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
652  SUMOReal freq = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_FREQUENCY]);
653  std::string filename = values[SUMO_ATTR_FILE];
654  bool splitByType = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_SPLIT_VTYPE]);
655  // Build detector E1
656  if (lane) {
657  return buildDetectorE1(viewNet, id, lane, pos, freq, filename, splitByType);
658  } else {
659  return false;
660  }
661  }
662  case SUMO_TAG_E2DETECTOR: {
663  // obtain specify attributes of detector E2
664  std::string id = values[SUMO_ATTR_ID];
665  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
666  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
667  SUMOReal freq = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_FREQUENCY]);
668  SUMOReal lenght = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_LENGTH]);
669  std::string filename = values[SUMO_ATTR_FILE];
670  bool cont = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CONT]);
671  SUMOReal timeThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
672  SUMOReal speedThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
673  SUMOReal jamThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_JAM_DIST_THRESHOLD]);
674  // Build detector E2
675  if (lane) {
676  return buildDetectorE2(viewNet, id, lane, pos, lenght, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold);
677  } else {
678  return false;
679  }
680  }
681  case SUMO_TAG_E3DETECTOR: {
682  // obtain specify attributes of detector E3
683  bool ok;
684  std::string id = values[SUMO_ATTR_ID];
685  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
686  SUMOReal freq = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_FREQUENCY]);
687  std::string filename = values[SUMO_ATTR_FILE];
688  SUMOReal timeThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
689  SUMOReal speedThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
690  // Build detector E3
691  if (pos.size() == 1) {
692  return buildDetectorE3(viewNet, id, pos[0], freq, filename, timeThreshold, speedThreshold);
693  } else {
694  return false;
695  }
696  }
697  case SUMO_TAG_DET_ENTRY: {
698  // obtain specify attributes of detector Entry
699  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
700  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
701  GNEDetectorE3* E3 = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->retrieveAdditional(values[GNE_ATTR_PARENT]));
702  // Build detector Entry
703  if (lane && E3) {
704  return buildDetectorEntry(viewNet, E3, lane, pos);
705  } else {
706  return false;
707  }
708  }
709  case SUMO_TAG_DET_EXIT: {
710  // obtain specify attributes of Detector Exit
711  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
712  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
713  GNEDetectorE3* E3 = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->retrieveAdditional(values[GNE_ATTR_PARENT]));
714  // Build detector Exit
715  if (lane && E3) {
716  return buildDetectorExit(viewNet, E3, lane, pos);
717  } else {
718  return false;
719  }
720  }
721  case SUMO_TAG_VSS: {
722  // obtain specify attributes of variable speed signal
723  std::string id = values[SUMO_ATTR_ID];
724  bool ok;
725  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
726  // Parse lane Ids
727  std::vector<std::string> laneIds;
729  // By default, VSSValues are empty
730  std::map<SUMOReal, SUMOReal> VSSValues;
731  // Obtain pointers to lanes
732  std::vector<GNELane*> lanes;
733  for (int i = 0; i < (int)laneIds.size(); i++) {
734  lanes.push_back(viewNet->getNet()->retrieveLane(laneIds.at(i)));
735  }
736  std::string file = values[SUMO_ATTR_FILE];
737  if (pos.size() == 1) {
738  return buildVariableSpeedSign(viewNet, id, pos[0], lanes, file, VSSValues);
739  } else {
740  return false;
741  }
742  }
743  case SUMO_TAG_CALIBRATOR: {
744  // obtain specify attributes of calibrator
745  std::string id = values[SUMO_ATTR_ID];
746  GNEEdge* edge = &(viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false)->getParentEdge());
747  // get rest of parameters
748  // Currently unused SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
749  SUMOReal pos = 0;
750  std::string outfile = values[SUMO_ATTR_OUTPUT];
751  SUMOReal freq = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_FREQUENCY]);
752  // get flow values
753  std::vector<GNECalibrator::GNECalibratorFlow*> flowValues;
754  // Build calibrator
755  if (edge) {
756  return buildCalibrator(viewNet, id, edge, pos, outfile, freq, flowValues);
757  } else {
758  return false;
759  }
760  }
761  case SUMO_TAG_REROUTER: {
762  // obtain specify attributes of rerouter
763  std::string id = values[SUMO_ATTR_ID];
764  bool ok;
765  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
766  // Parse edges Ids
767  std::vector<std::string> edgeIds;
769  // Get rest of parameters
770  bool off = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_OFF]);
771  SUMOReal prob = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_PROB]);
772  std::string file = values[SUMO_ATTR_FILE];
773  // Obtain pointers to edges
774  std::vector<GNEEdge*> edges;
775  for (int i = 0; i < (int)edgeIds.size(); i++) {
776  edges.push_back(viewNet->getNet()->retrieveEdge(edgeIds.at(i)));
777  }
778  // Build rerouter
779  if (pos.size() == 1) {
780  return buildRerouter(viewNet, id, pos[0], edges, prob, file, off);
781  } else {
782  return false;
783  }
784  }
785  case SUMO_TAG_ROUTEPROBE: {
786  // obtain specify attributes of RouteProbe
787  std::string id = values[SUMO_ATTR_ID];
788  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
789  SUMOReal freq = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_FREQUENCY]);
790  std::string filename = values[SUMO_ATTR_FILE];
791  SUMOReal begin = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_BEGIN]);
792  // Build RouteProbe
793  if (edge) {
794  return buildRouteProbe(viewNet, id, edge, freq, filename, begin);
795  } else {
796  return false;
797  }
798  }
799  case SUMO_TAG_VAPORIZER: {
800  // obtain specify attributes of vaporizer
801  std::string id = values[SUMO_ATTR_ID];
802  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
803  SUMOReal startTime = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTTIME]);
804  SUMOReal end = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_END]);
805  // Build RouteProbe
806  if (edge) {
807  return buildVaporizer(viewNet, id, edge, startTime, end);
808  } else {
809  return false;
810  }
811  }
812  default:
813  return false;
814  }
815 }
816 
817 
818 bool
819 GNEAdditionalHandler::buildBusStop(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal startPos, SUMOReal endPos, const std::vector<std::string>& lines) {
820  if (viewNet->getNet()->getAdditional(SUMO_TAG_BUS_STOP, id) == NULL) {
821  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_BUS_STOP));
822  GNEBusStop* busStop = new GNEBusStop(id, lane, viewNet, startPos, endPos, lines);
823  viewNet->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
824  viewNet->getUndoList()->p_end();
825  return true;
826  } else {
827  WRITE_WARNING("Could not build " + toString(SUMO_TAG_BUS_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
828  return false;
829  }
830 }
831 
832 
833 bool
834 GNEAdditionalHandler::buildContainerStop(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal startPos, SUMOReal endPos, const std::vector<std::string>& lines) {
835  if (viewNet->getNet()->getAdditional(SUMO_TAG_CONTAINER_STOP, id) == NULL) {
836  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CONTAINER_STOP));
837  GNEContainerStop* containerStop = new GNEContainerStop(id, lane, viewNet, startPos, endPos, lines);
838  viewNet->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
839  viewNet->getUndoList()->p_end();
840  return true;
841  } else {
842  WRITE_WARNING("Could not build " + toString(SUMO_TAG_CONTAINER_STOP) + " with ID '" + id + "' in netedit; probably declared twice.");
843  return false;
844  }
845 }
846 
847 
848 bool
849 GNEAdditionalHandler::buildChargingStation(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal startPos, SUMOReal endPos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, SUMOReal chargeDelay) {
850  if (viewNet->getNet()->getAdditional(SUMO_TAG_CHARGING_STATION, id) == NULL) {
851  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CHARGING_STATION));
852  GNEChargingStation* chargingStation = new GNEChargingStation(id, lane, viewNet, startPos, endPos, chargingPower, efficiency, chargeInTransit, chargeDelay);
853  viewNet->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
854  viewNet->getUndoList()->p_end();
855  return true;
856  } else {
857  WRITE_WARNING("Could not build " + toString(SUMO_TAG_CHARGING_STATION) + " with ID '" + id + "' in netedit; probably declared twice.");
858  return false;
859  }
860 }
861 
862 
863 bool
864 GNEAdditionalHandler::buildDetectorE1(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal pos, SUMOReal freq, const std::string& filename, bool splitByType) {
865  if (viewNet->getNet()->getAdditional(SUMO_TAG_E1DETECTOR, id) == NULL) {
866  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E1DETECTOR));
867  GNEDetectorE1* detectorE1 = new GNEDetectorE1(id, lane, viewNet, pos, freq, filename, splitByType);
868  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
869  viewNet->getUndoList()->p_end();
870  return true;
871  } else {
872  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E1DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
873  return false;
874  }
875 }
876 
877 
878 bool
879 GNEAdditionalHandler::buildDetectorE2(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal pos, SUMOReal length, SUMOReal freq, const std::string& filename,
880  bool cont, const SUMOReal timeThreshold, SUMOReal speedThreshold, SUMOReal jamThreshold) {
881  if (viewNet->getNet()->getAdditional(SUMO_TAG_E2DETECTOR, id) == NULL) {
882  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E2DETECTOR));
883  GNEDetectorE2* detectorE2 = new GNEDetectorE2(id, lane, viewNet, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold);
884  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
885  viewNet->getUndoList()->p_end();
886  return true;
887  } else {
888  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E2DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
889  return false;
890  }
891 }
892 
893 
894 bool
895 GNEAdditionalHandler::buildDetectorE3(GNEViewNet* viewNet, const std::string& id, Position pos, SUMOReal freq, const std::string& filename, const SUMOReal timeThreshold, SUMOReal speedThreshold) {
896  if (viewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, id) == NULL) {
897  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
898  GNEDetectorE3* detectorE3 = new GNEDetectorE3(id, viewNet, pos, freq, filename, timeThreshold, speedThreshold);
899  viewNet->getUndoList()->add(new GNEChange_Additional(detectorE3, true), true);
900  viewNet->getUndoList()->p_end();
901  return true;
902  } else {
903  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E3DETECTOR) + " with ID '" + id + "' in netedit; probably declared twice.");
904  return false;
905  }
906 }
907 
908 
909 bool
911  // Check if Detector E3 parent and lane is correct
912  if (lane == NULL) {
913  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
914  return false;
915  } else if (E3Parent == NULL) {
916  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
917  return false;
918  } else {
919  // insert E3 parent in net if previoulsy wasn't inserted
920  if (viewNet->getNet()->getAdditional(E3Parent->getTag(), E3Parent->getID()) == NULL) {
921  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
922  viewNet->getUndoList()->add(new GNEChange_Additional(E3Parent, true), true);
923  viewNet->getUndoList()->p_end();
924  }
925  // Create detector Entry if don't exist already in the net
926  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_ENTRY));
927  GNEDetectorEntry* entry = new GNEDetectorEntry(viewNet, E3Parent, lane, pos);
928  viewNet->getUndoList()->add(new GNEChange_Additional(entry, true), true);
929  viewNet->getUndoList()->p_end();
930  return true;
931  }
932 }
933 
934 
935 bool
937  // Check if Detector E3 parent and lane is correct
938  if (lane == NULL) {
939  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
940  return false;
941  } else if (E3Parent == NULL) {
942  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " in netedit; " + toString(SUMO_TAG_E3DETECTOR) + " parent doesn't exist.");
943  return false;
944  } else {
945  // insert E3 parent in net if previoulsy wasn't inserted
946  if (viewNet->getNet()->getAdditional(E3Parent->getTag(), E3Parent->getID()) == NULL) {
947  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
948  viewNet->getUndoList()->add(new GNEChange_Additional(E3Parent, true), true);
949  viewNet->getUndoList()->p_end();
950  }
951  // Create detector Exit if don't exist already in the net
952  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_EXIT));
953  GNEDetectorExit* exit = new GNEDetectorExit(viewNet, E3Parent, lane, pos);
954  viewNet->getUndoList()->add(new GNEChange_Additional(exit, true), true);
955  viewNet->getUndoList()->p_end();
956  return true;
957  }
958 }
959 
960 
961 bool
962 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, const std::string& id, GNEEdge* edge, SUMOReal pos, const std::string& outfile, const SUMOReal freq, const std::vector<GNECalibrator::GNECalibratorFlow*>& flowValues) {
963  if (viewNet->getNet()->getAdditional(SUMO_TAG_CALIBRATOR, id) == NULL) {
964  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
965  GNECalibrator* calibrator = new GNECalibrator(id, edge, viewNet, pos, freq, outfile, flowValues);
966  viewNet->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
967  viewNet->getUndoList()->p_end();
968  return true;
969  } else {
970  WRITE_WARNING("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with ID '" + id + "' in netedit; probably declared twice.");
971  return false;
972  }
973 }
974 
975 
976 bool
977 GNEAdditionalHandler::buildRerouter(GNEViewNet* viewNet, const std::string& id, Position pos, const std::vector<GNEEdge*>& edges, SUMOReal prob, const std::string& file, bool off) {
978  if (viewNet->getNet()->getAdditional(SUMO_TAG_REROUTER, id) == NULL) {
979  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_REROUTER));
980  GNERerouter* rerouter = new GNERerouter(id, viewNet, pos, edges, file, prob, off);
981  viewNet->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
982  viewNet->getUndoList()->p_end();
983  return true;
984  } else {
985  WRITE_WARNING("Could not build " + toString(SUMO_TAG_REROUTER) + " with ID '" + id + "' in netedit; probably declared twice.");
986  return false;
987  }
988 }
989 
990 
991 bool
992 GNEAdditionalHandler::buildRouteProbe(GNEViewNet* viewNet, const std::string& id, GNEEdge* edge, SUMOReal freq, const std::string& file, SUMOReal begin) {
993  if (viewNet->getNet()->getAdditional(SUMO_TAG_REROUTER, id) == NULL) {
994  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_ROUTEPROBE));
995  GNERouteProbe* routeProbe = new GNERouteProbe(id, viewNet, edge, freq, file, begin);
996  viewNet->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
997  viewNet->getUndoList()->p_end();
998  return true;
999  } else {
1000  WRITE_WARNING("Could not build " + toString(SUMO_TAG_ROUTEPROBE) + " with ID '" + id + "' in netedit; probably declared twice.");
1001  return false;
1002  }
1003 }
1004 
1005 
1006 bool
1007 GNEAdditionalHandler::buildVariableSpeedSign(GNEViewNet* viewNet, const std::string& id, Position pos, const std::vector<GNELane*>& lanes, const std::string& file, const std::map<SUMOReal, SUMOReal>& VSSValues) {
1008  if (viewNet->getNet()->getAdditional(SUMO_TAG_VSS, id) == NULL) {
1009  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VSS));
1010  GNEVariableSpeedSign* variableSpeedSign = new GNEVariableSpeedSign(id, viewNet, pos, lanes, file, VSSValues);
1011  viewNet->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1012  viewNet->getUndoList()->p_end();
1013  return true;
1014  } else {
1015  WRITE_WARNING("Could not build " + toString(SUMO_TAG_VSS) + " with ID '" + id + "' in netedit; probably declared twice.");
1016  return false;
1017  }
1018 }
1019 
1020 
1021 bool
1022 GNEAdditionalHandler::buildVaporizer(GNEViewNet* viewNet, const std::string& id, GNEEdge* edge, SUMOReal startTime, SUMOReal end) {
1023  if (viewNet->getNet()->getAdditional(SUMO_TAG_VAPORIZER, id) == NULL) {
1024  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VAPORIZER));
1025  GNEVaporizer* vaporizer = new GNEVaporizer(id, viewNet, edge, startTime, end);
1026  viewNet->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1027  viewNet->getUndoList()->p_end();
1028  return true;
1029  } else {
1030  WRITE_WARNING("Could not build " + toString(SUMO_TAG_VAPORIZER) + " with ID '" + id + "' in netedit; probably declared twice.");
1031  return false;
1032  }
1033 }
1034 
1035 
1036 std::string
1037 GNEAdditionalHandler::getFileName(const SUMOSAXAttributes& attrs, const std::string& base, const bool allowEmpty) {
1038  // get the file name to read further definitions from
1039  bool ok = true;
1040  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, 0, ok, "");
1041  if (file == "") {
1042  if (allowEmpty) {
1043  return file;
1044  }
1045  WRITE_WARNING("No filename given.");
1046  }
1047  // check whether absolute or relative filenames are given
1048  if (!FileHelpers::isAbsolute(file)) {
1049  return FileHelpers::getConfigurationRelative(base, file);
1050  }
1051  return file;
1052 }
1053 
1054 
1055 SUMOReal
1056 GNEAdditionalHandler::getPosition(const SUMOSAXAttributes& attrs, GNELane& lane, const std::string& tt, const std::string& tid) {
1057  bool ok = true;
1058  SUMOReal pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, false);
1059  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
1060  if (!ok) {
1061  WRITE_WARNING("Error on parsing a position information.");
1062  }
1063  if (pos < 0) {
1064  pos = lane.getLaneShapeLenght() + pos;
1065  }
1066  if (pos > lane.getLaneShapeLenght()) {
1067  if (friendlyPos) {
1068  pos = lane.getLaneShapeLenght() - (SUMOReal) 0.1;
1069  } else {
1070  WRITE_WARNING("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane.getID() + "' length.");
1071  }
1072  }
1073  return pos;
1074 }
1075 
1076 
1077 bool
1078 GNEAdditionalHandler::checkStopPos(SUMOReal& startPos, SUMOReal& endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos) {
1079  if (minLength > laneLength) {
1080  return false;
1081  }
1082  if (startPos < 0) {
1083  startPos += laneLength;
1084  }
1085  if (endPos < 0) {
1086  endPos += laneLength;
1087  }
1088  if (endPos < minLength || endPos > laneLength) {
1089  if (!friendlyPos) {
1090  return false;
1091  }
1092  if (endPos < minLength) {
1093  endPos = minLength;
1094  }
1095  if (endPos > laneLength) {
1096  endPos = laneLength;
1097  }
1098  }
1099  if (startPos < 0 || startPos > endPos - minLength) {
1100  if (!friendlyPos) {
1101  return false;
1102  }
1103  if (startPos < 0) {
1104  startPos = 0;
1105  }
1106  if (startPos > endPos - minLength) {
1107  startPos = endPos - minLength;
1108  }
1109  }
1110  return true;
1111 }
1112 
1113 
1114 template <typename T> T
1115 GNEAdditionalHandler::getParsedAttribute(const SUMOSAXAttributes& attrs, const char* objectid, SumoXMLTag tag, SumoXMLAttr attribute, bool& abort, bool report) {
1116  bool ok = true;
1117  std::string parsedAttribute = "0";
1118  // only show one warning for every error/warning loading additional
1119  if (!abort) {
1120  // set additionalOfWarningMessage
1121  std::string additionalOfWarningMessage;
1122  if (objectid) {
1123  additionalOfWarningMessage = toString(tag) + " with ID '" + toString(objectid) + "'";
1124  } else {
1125  additionalOfWarningMessage = toString(tag);
1126  }
1127  // first check that attribute exists
1128  if (attrs.hasAttribute(attribute)) {
1129  // Parse attribute as string
1130  parsedAttribute = attrs.get<std::string>(attribute, objectid, ok, false);
1131  // check that parsed attribute can be converted to type T
1132  if (ok && !GNEAttributeCarrier::canParse<T>(parsedAttribute)) {
1133  ok = false;
1134  }
1135  std::string errorFormat;
1136  // Set extra checks for int values
1137  if (GNEAttributeCarrier::isInt(tag, attribute)) {
1138  if (GNEAttributeCarrier::canParse<int>(parsedAttribute)) {
1139  // parse to int and check if can be negative
1140  int parsedIntAttribute = GNEAttributeCarrier::parse<int>(parsedAttribute);
1141  if (GNEAttributeCarrier::isPositive(tag, attribute) && parsedIntAttribute < 0) {
1142  errorFormat = "Cannot be negative; ";
1143  ok = false;
1144  }
1145  } else {
1146  errorFormat = "Cannot be parsed to int; ";
1147  ok = false;
1148  }
1149  }
1150  // Set extra checks for float(SUMOReal) values
1151  if (GNEAttributeCarrier::isFloat(tag, attribute)) {
1152  if (GNEAttributeCarrier::canParse<SUMOReal>(parsedAttribute)) {
1153  // parse to SUMOReal and check if can be negative
1154  SUMOReal parsedSumoRealAttribute = GNEAttributeCarrier::parse<SUMOReal>(parsedAttribute);
1155  if (GNEAttributeCarrier::isPositive(tag, attribute) && parsedSumoRealAttribute < 0) {
1156  errorFormat = "Cannot be negative; ";
1157  ok = false;
1158  }
1159  } else {
1160  errorFormat = "Cannot be parsed to float; ";
1161  ok = false;
1162  }
1163  }
1164  // set extra check for time(SUMOReal) values
1165  if (GNEAttributeCarrier::isTime(tag, attribute)) {
1166  if (GNEAttributeCarrier::canParse<SUMOReal>(parsedAttribute)) {
1167  // parse to SUMO Real and check if is negative
1168  SUMOReal parsedSumoRealAttribute = GNEAttributeCarrier::parse<SUMOReal>(parsedAttribute);
1169  if (parsedSumoRealAttribute < 0) {
1170  errorFormat = "Time cannot be negative; ";
1171  ok = false;
1172  }
1173  } else {
1174  errorFormat = "Cannot be parsed to time; ";
1175  ok = false;
1176  }
1177  }
1178  // If attribute has an invalid format
1179  if (!ok) {
1180  // if attribute has a default value, take it as string. In other case, abort.
1181  if (GNEAttributeCarrier::hasDefaultValue(tag, attribute)) {
1182  parsedAttribute = toString(GNEAttributeCarrier::getDefaultValue<T>(tag, attribute));
1183  // report warning of default value
1184  if (report) {
1185  WRITE_WARNING("Format of optional " + GNEAttributeCarrier::getAttributeType(tag, attribute) + " attribute '" + toString(attribute) + "' of " +
1186  additionalOfWarningMessage + " is invalid; " + errorFormat + "Default value '" + toString(parsedAttribute) + "' will be used.");
1187  }
1188  } else {
1189  WRITE_WARNING("Format of essential " + GNEAttributeCarrier::getAttributeType(tag, attribute) + " attribute '" + toString(attribute) + "' of " +
1190  additionalOfWarningMessage + " is invalid; " + errorFormat + "Additional cannot be created");
1191  // set default value of parsedAttribute (to avoid exceptions during conversions)
1192  parsedAttribute = "0";
1193  abort = true;
1194  }
1195  }
1196  } else {
1197  // if attribute has a default value, take it. In other case, abort.
1198  if (GNEAttributeCarrier::hasDefaultValue(tag, attribute)) {
1199  parsedAttribute = toString(GNEAttributeCarrier::getDefaultValue<T>(tag, attribute));
1200  // report warning of default value
1201  if (report) {
1202  WRITE_WARNING("Optional " + GNEAttributeCarrier::getAttributeType(tag, attribute) + " attribute '" + toString(attribute) + "' of " +
1203  additionalOfWarningMessage + " is missing; Default value '" + toString(parsedAttribute) + "' will be used.");
1204  }
1205  } else {
1206  WRITE_WARNING("Essential " + GNEAttributeCarrier::getAttributeType(tag, attribute) + " attribute '" + toString(attribute) + "' of " +
1207  additionalOfWarningMessage + " is missing; Additional cannot be created");
1208  abort = true;
1209  }
1210  }
1211  }
1212  // return parsed attribute
1213  return GNEAttributeCarrier::parse<T>(parsedAttribute);
1214 }
1215 
1216 
1217 bool
1219  bool ok = true;
1220  return attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, objectid, ok, false);
1221 }
1222 
1223 
1224 void
1228  WRITE_WARNING((toString(myE3Parent->getTag()) + "s without " + toString(SUMO_TAG_DET_ENTRY) + "s or " + toString(SUMO_TAG_DET_EXIT) + " aren't allowed; " +
1229  toString(myE3Parent->getTag()) + " with ID = '" + myE3Parent->getID() + "' cannot be created.").c_str());
1230  delete myE3Parent;
1231  myE3Parent = NULL;
1232  }
1233 }
1234 
1235 
1236 bool
1238  // If last tag was an E3 but next tag isn't an Entry or Exit
1240  !((currentTag == SUMO_TAG_DET_ENTRY) || (currentTag == SUMO_TAG_DET_EXIT))) {
1241  // Remove created E3 to avoid load empty detectors
1242  if (myE3Parent != NULL) {
1243  // show E3 empty warning and delete empty E3
1244  WRITE_WARNING((toString(myE3Parent->getTag()) + "s without " + toString(SUMO_TAG_DET_ENTRY) + "s or " + toString(SUMO_TAG_DET_EXIT) + " aren't allowed; " +
1245  toString(myE3Parent->getTag()) + " with ID = '" + myE3Parent->getID() + "' cannot be created.").c_str());
1246  delete myE3Parent;
1247  myE3Parent = NULL;
1248  }
1249  // continue with the processing of additional
1250  return true;
1251  }
1252 
1253  // if last tag wasn't an E3 but next tag is an entry or exit
1255  ((currentTag == SUMO_TAG_DET_ENTRY) || (currentTag == SUMO_TAG_DET_EXIT))) {
1256  if (myE3Parent != NULL) {
1257  // In this case, we're loading a E3 with multiple entry exits, then continue
1258  return true;
1259  } else {
1260  // return false to stop procesing current entry or exit and go to the next tag (this avoid some useless warnings)
1261  return false;
1262  }
1263  } else {
1264  // all OK
1265  return true;
1266  }
1267 }
1268 
1269 /****************************************************************************/
bool insertStep(const SUMOReal time, const SUMOReal speed)
insert a new step in variable speed signal
void parseVariableSpeedSignStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses step values of VariableSpeedSigns.
bool setDepartSpeed(std::string departSpeed)
set depart speed
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool setPersonNumber(int personNumber)
set number of persons
void parseCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
a routeprobe detector
static bool isFloat(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical of type float
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:732
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:86
static std::string getAttributeType(SumoXMLTag tag, SumoXMLAttr attr)
get type of attribute
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
a flow definition (used by router)
static bool buildDetectorEntry(GNEViewNet *viewNet, GNEDetectorE3 *E3Parent, GNELane *lane, SUMOReal pos)
Builds a entry detector (E3)
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
static bool buildVaporizer(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal startTime, SUMOReal end)
Builds a vaporizer (lane speed trigger)
Allow/disallow charge in transit in Charging Stations.
GNEAdditionalHandler(const std::string &file, GNEViewNet *viewNet)
Constructor.
bool setArrivalSpeed(std::string arrivalSpeed)
set arrival speed
weights: time range begin
static bool buildAdditional(GNEViewNet *viewNet, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Build additionals.
static bool isPositive(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is only Positive (i.e. cannot take negative values)
bool setVehsPerHour(SUMOReal vehsPerHour)
set vehicles per hour
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:86
bool setPeriod(SUMOReal period)
set period of vehicles
static bool buildRouteProbe(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal freq, const std::string &file, SUMOReal begin)
builds a Route probe
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static bool buildChargingStation(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, SUMOReal chargeDelay)
Builds a charging Station.
bool setNumber(int number)
set number of vehicles
SAX-handler base for SUMO-files.
bool setBegin(SUMOReal begin)
set begin step
static bool buildDetectorE3(GNEViewNet *viewNet, const std::string &id, Position pos, SUMOReal freq, const std::string &filename, const SUMOReal timeThreshold, SUMOReal speedThreshold)
Builds a multi entry exit 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
bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check if the position of an stoppingPlace over a lane is valid
bool setArrivalLane(std::string arrivalLane)
set arrival lane
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:995
static bool buildContainerStop(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, const std::vector< std::string > &lines)
Builds a container stop.
static bool isInt(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical or type int
static bool buildVariableSpeedSign(GNEViewNet *viewNet, const std::string &id, Position pos, const std::vector< GNELane * > &destLanes, const std::string &file, const std::map< SUMOReal, SUMOReal > &VSSValues)
Builds a VariableSpeedSign (lane speed trigger)
static bool buildDetectorE1(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, SUMOReal freq, const std::string &filename, bool splitByType)
Builds a induction loop detector (E1)
bool getFriendlyPosition(const SUMOSAXAttributes &attrs, const char *objectid)
get special attribute friendly position, used in stopping places
static bool buildDetectorExit(GNEViewNet *viewNet, GNEDetectorE3 *E3Parent, GNELane *lane, SUMOReal pos)
Builds a exit detector (E3)
static bool isTime(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is time
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
~GNEAdditionalHandler()
Destructor.
bool setEnd(SUMOReal end)
set end step
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:55
static bool buildBusStop(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, const std::vector< std::string > &lines)
Builds a bus stop.
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1027
Encapsulated SAX-Attributes.
static bool hasDefaultValue(SumoXMLTag tag, SumoXMLAttr attr)
check if attribute of an element has a default avlue
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
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:93
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
an e3 exit point
A list of positions.
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
Definition: GNENet.cpp:774
void parseAndBuildRerouter(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a rerouter.
bool setContainerNumber(int containerNumber)
set number of container
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:58
#define POSITION_EPS
Definition: config.h:182
bool setDepartPos(std::string departPos)
set depart position
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
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
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:54
static bool buildRerouter(GNEViewNet *viewNet, const std::string &id, Position pos, const std::vector< GNEEdge * > &edges, SUMOReal prob, const std::string &file, bool off)
builds a rerouter
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
bool setLine(std::string line)
set line of busStop/containerStop
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1265
trigger: the time of the step
bool setProbability(SUMOReal probability)
set probability of vehicle
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:683
bool setArrivalPos(std::string arrivalPos)
set arrival position
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.
void insertFlow(GNECalibratorFlow *flow)
insert a new flow
weights: time range end
bool setColor(std::string color)
set color of flow
static T getParsedAttribute(const SUMOSAXAttributes &attrs, const char *objectid, SumoXMLTag tag, SumoXMLAttr attribute, bool &abort, bool report=true)
get parsed attribute of XML and show warnings if there are problems
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a vaporization.
static bool buildCalibrator(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal pos, const std::string &outfile, SUMOReal freq, const std::vector< GNECalibrator::GNECalibratorFlow * > &flowValues)
builds a microscopic calibrator
SUMOReal getPosition(const SUMOSAXAttributes &attrs, GNELane &lane, const std::string &tt, const std::string &tid)
extracts the position, checks whether it shall be mirrored and checks whether it is within the lane...
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
Definition: GNEViewNet.cpp:989
vaporizer of vehicles
bool setDepartLane(std::string departLane)
set depart lane
SumoXMLTag getTag() const
get XML Tag assigned to this object
A variable speed sign.
Eficiency of the charge in Charging Stations.
#define SUMOReal
Definition: config.h:208
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.
Delay in the charge of charging stations.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
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:1250
A lane area vehicles can halt at (netedit-version)
A color information.
void parseAndBuildDetectorEntry(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Entry detector.
static bool buildDetectorE2(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, SUMOReal length, SUMOReal freq, const std::string &filename, bool cont, const SUMOReal timeThreshold, SUMOReal speedThreshold, SUMOReal jamThreshold)
Builds a lane Area Detector (E2)
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
trigger: a step description