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-sim.org/
10 // Copyright (C) 2001-2013 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 "GNEUndoList.h"
34 #include "GNEEdge.h"
35 #include "GNELane.h"
36 #include "GNEJunction.h"
37 #include "GNENet.h"
38 #include "GNEViewNet.h"
39 #include "GNEChange_Additional.h"
40 #include "GNEBusStop.h"
41 #include "GNEChargingStation.h"
42 #include "GNEDetectorE1.h"
43 #include "GNEDetectorE2.h"
44 #include "GNEDetectorE3.h"
45 #include "GNEDetectorEntry.h"
46 #include "GNEDetectorExit.h"
47 #include "GNERouteProbe.h"
48 #include "GNEContainerStop.h"
49 #include "GNEVaporizer.h"
50 
51 #ifdef CHECK_MEMORY_LEAKS
52 #include <foreign/nvwa/debug_new.h>
53 #endif
54 
55 
56 // ===========================================================================
57 // member method definitions
58 // ===========================================================================
59 
60 GNEAdditionalHandler::GNEAdditionalHandler(const std::string& file, GNEViewNet* viewNet) :
61  SUMOSAXHandler(file),
62  myViewNet(viewNet),
63  rerouterIntervalToInsertValues(NULL) {
64 }
65 
66 
68 
69 
70 void
72  // Obtain tag of element
73  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
74  // Call parse and build depending of tag
75  switch (element) {
76  case SUMO_TAG_BUS_STOP:
77  parseAndBuildBusStop(attrs, tag);
78  break;
80  parseAndBuildContainerStop(attrs, tag);
81  break;
83  parseAndBuildChargingStation(attrs, tag);
84  break;
87  parseAndBuildDetectorE1(attrs, tag);
88  break;
91  parseAndBuildDetectorE2(attrs, tag);
92  break;
95  parseAndBuildDetectorE3(attrs, tag);
96  break;
97  case SUMO_TAG_DET_ENTRY:
98  parseAndBuildDetectorEntry(attrs, tag);
99  break;
100  case SUMO_TAG_DET_EXIT:
101  parseAndBuildDetectorExit(attrs, tag);
102  break;
103  case SUMO_TAG_VSS:
105  break;
106  case SUMO_TAG_REROUTER:
107  parseAndBuildRerouter(attrs, tag);
108  break;
109  case SUMO_TAG_CALIBRATOR:
110  parseAndBuildCalibrator(attrs, tag);
111  break;
112  case SUMO_TAG_VAPORIZER:
113  parseAndBuildVaporizer(attrs, tag);
114  break;
115  case SUMO_TAG_ROUTEPROBE:
116  parseAndBuildRouteProbe(attrs, tag);
117  break;
118  case SUMO_TAG_FLOW:
119  parseCalibratorFlow(attrs, tag);
120  break;
121  case SUMO_TAG_STEP:
122  parseVariableSpeedSignalStep(attrs, tag);
123  break;
124  default:
125  break;
126  }
127 }
128 
129 
130 void
132  bool ok = true;
133  bool abort = false;
134  // get ID of additional
135  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
136  if (!ok) {
137  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
138  ok = true;
139  abort = true;
140  }
141  // get edge ID
142  const std::string edgeId = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok, false);
143  if (!ok) {
144  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_EDGE) + "' of additional " + toString(tag) + " is missing");
145  ok = true;
146  abort = true;
147  }
148  // get start Time
149  const SUMOReal startTime = attrs.get<SUMOReal>(SUMO_ATTR_STARTTIME, id.c_str(), ok, false);
150  if (!ok) {
151  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_STARTTIME) + "' of additional " + toString(tag) + " is missing");
152  ok = true;
153  abort = true;
154  }
155  // get end Time
156  const SUMOReal endTime = attrs.get<SUMOReal>(SUMO_ATTR_END, id.c_str(), ok, false);
157  if (!ok) {
158  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_END) + "' of additional " + toString(tag) + " is missing");
159  ok = true;
160  abort = true;
161  }
162  // Continue if all parameters were successfully loaded
163  if (!abort) {
164  // get edge
165  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
166  if (edge == NULL) {
167  // Write error if lane isn't valid
168  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
169  } else {
170  // build Vaporizer
171  buildVaporizer(myViewNet, id, edge, startTime, endTime, false);
172  }
173  }
174 }
175 
176 
177 
178 void
180  bool ok = true;
181  bool abort = false;
182  // get ID of additional
183  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
184  if (!ok) {
185  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
186  ok = true;
187  abort = true;
188  }
189  // get edge ID
190  const std::string edgeId = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok, false);
191  if (!ok) {
192  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_EDGE) + "' of additional " + toString(tag) + " is missing");
193  ok = true;
194  abort = true;
195  }
196  // get frequency
197  const int freq = attrs.get<int>(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
198  if (!ok) {
199  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FREQUENCY) + "' of additional " + toString(tag) + " is missing");
200  ok = true;
201  abort = true;
202  }
203  // get File
204  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok, false);
205  if (!ok) {
206  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FILE) + "' of additional " + toString(tag) + " is missing");
207  ok = true;
208  abort = true;
209  }
210  // Get optionals attributes
211  const int begin = attrs.getOpt<int>(SUMO_ATTR_BEGIN, id.c_str(), ok, false);
212  // Continue if all parameters were sucesfully loaded
213  if (!abort) {
214  // get edge
215  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgeId, false);
216  if (edge == NULL) {
217  // Write error if lane isn't valid
218  WRITE_WARNING("The edge '" + edgeId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
219  } else {
220  // build Vaporizer
221  buildRouteProbe(myViewNet, id, edge, freq, file, begin, false);
222  }
223  }
224 }
225 
226 
227 void
229  // Declare calibrator to keep flow
231  bool ok = true;
232  bool abort = false;
233  // Load non empty values
234  std::string flowId = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
235  if (!ok) {
236  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_CALIBRATOR) + " is missing");
237  ok = true;
238  abort = true;
239  }
240  flow.type = attrs.get<std::string>(SUMO_ATTR_TYPE, flowId.c_str(), ok, false);
241  if (!ok) {
242  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_TYPE) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_CALIBRATOR) + " is missing");
243  ok = true;
244  abort = true;
245  }
246  flow.route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowId.c_str(), ok, false);
247  if (!ok) {
248  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ROUTE) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_CALIBRATOR) + " is missing");
249  ok = true;
250  abort = true;
251  }
252  // Load rest of parameters
253  flow.color = attrs.getOpt<std::string>(SUMO_ATTR_COLOR, flowId.c_str(), ok, "", false);
254  flow.departLane = attrs.getOpt<std::string>(SUMO_ATTR_DEPARTLANE, flowId.c_str(), ok, "first", false);
255  flow.departPos = attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, flowId.c_str(), ok, "base", false);
256  flow.departSpeed = attrs.getOpt<std::string>(SUMO_ATTR_DEPARTSPEED, flowId.c_str(), ok, "0", false);
257  flow.arrivalLane = attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALLANE, flowId.c_str(), ok, "current", false);
258  flow.arrivalPos = attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALPOS, flowId.c_str(), ok, "max", false);
259  flow.arrivalSpeed = attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALSPEED, flowId.c_str(), ok, "current", false);
260  flow.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, flowId.c_str(), ok, "", false);
261  flow.personNumber = attrs.getOpt<int>(SUMO_ATTR_PERSON_NUMBER, flowId.c_str(), ok, 0, false);
262  flow.containerNumber = attrs.getOpt<int>(SUMO_ATTR_CONTAINER_NUMBER, flowId.c_str(), ok, 0, false);
263  flow.begin = attrs.getOpt<SUMOTime>(SUMO_ATTR_BEGIN, flowId.c_str(), ok, 0, false);
264  flow.end = attrs.getOpt<SUMOTime>(SUMO_ATTR_END, flowId.c_str(), ok, 0, false);
265  flow.vehsPerHour = attrs.getOpt<SUMOReal>(SUMO_ATTR_VEHSPERHOUR, flowId.c_str(), ok, 0, false);
266  flow.period = attrs.getOpt<SUMOReal>(SUMO_ATTR_PERIOD, flowId.c_str(), ok, 0, false);
267  flow.probability = attrs.getOpt<SUMOReal>(SUMO_ATTR_PROB, flowId.c_str(), ok, 0, false);
268  flow.number = attrs.getOpt<int>(SUMO_ATTR_NUMBER, flowId.c_str(), ok, 0, false);
269  // Continue if all parameters were sucesfully loaded
270  if (!abort) {
271  // Obtain calibrator
273  if (calibratorToInsertFlow == NULL) {
274  WRITE_WARNING("A " + toString(SUMO_TAG_CALIBRATOR) + " must be inserter before insertion of the " + toString(tag) + " '" + flowId + "'");
275  } else {
276  calibratorToInsertFlow->insertFlow(flowId, flow);
277  }
278  }
279 }
280 
281 
282 void
284  bool ok = true;
285  bool abort = false;
286  // Load step values
287  SUMOTime time = attrs.get<SUMOTime>(SUMO_ATTR_TIME, 0, ok, false);
288  if (!ok) {
289  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_TIME) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_VSS) + " is missing");
290  ok = true;
291  abort = true;
292  }
293  SUMOReal speed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, false);
294  if (!ok) {
295  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_SPEED) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_VSS) + " is missing");
296  ok = true;
297  abort = true;
298  }
299  // Continue if all parameters were sucesfully loaded
300  if (!abort) {
301  GNEVariableSpeedSignal* variableSpeedSignalToInsertStep = dynamic_cast<GNEVariableSpeedSignal*>(myViewNet->getNet()->getAdditional(SUMO_TAG_VSS, myAdditionalSetParent));
302  if (variableSpeedSignalToInsertStep == NULL) {
303  WRITE_WARNING("A " + toString(SUMO_TAG_VSS) + " must be inserter before insertion of a " + toString(tag));
304  } else if (!variableSpeedSignalToInsertStep->insertStep(time, speed)) {
305  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_TIME) + "' of " + toString(tag) + "'s " + toString(SUMO_TAG_VSS) + " is duplicated");
306  }
307  }
308 }
309 
310 
311 void
313  bool ok = true;
314  bool abort = false;
315  // get ID of additional
316  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
317  if (!ok) {
318  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
319  ok = true;
320  abort = true;
321  }
322  // get file
323  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok, false);
324  if (!ok) {
325  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FILE) + "' of additional " + toString(tag) + " is missing");
326  ok = true;
327  abort = true;
328  }
329  // get lanes
330  const std::string listOfLanes = attrs.get<std::string>(SUMO_ATTR_LANES, id.c_str(), ok, false);
331  if (!ok) {
332  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANES) + "' of additional " + toString(tag) + " is missing");
333  ok = true;
334  abort = true;
335  }
336  // Get optional attributes
337  const SUMOReal posx = attrs.getOpt<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok, 0, false);
338  const SUMOReal posy = attrs.getOpt<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok, 0, false);
339  // Continue if all parameters were sucesfully loaded
340  if (!abort) {
341  // Obtain lanes
342  std::vector<std::string> lanesID;
343  SUMOSAXAttributes::parseStringVector(listOfLanes, lanesID);
344  // obtain VSS Values
345  // @todo
346  std::map<SUMOTime, SUMOReal> VSSValues;
347  // Obtain pointer to lanes
348  std::vector<GNELane*> lanes;
349  for (int i = 0; i < (int)lanesID.size(); i++) {
350  GNELane* lane = myViewNet->getNet()->retrieveLane(lanesID.at(i));
351  if (lane) {
352  lanes.push_back(lane);
353  } else {
354  WRITE_WARNING("lane '" + lanesID.at(i) + "' isn't valid");
355  }
356  }
357  // if operation of build variable speed signal was sucesfully, save Id
358  if (buildVariableSpeedSignal(myViewNet, id, Position(posx, posy), lanes, file, VSSValues, false)) {
360  }
361  }
362 }
363 
364 
365 void
367  bool ok = true;
368  bool abort = false;
369  // get ID of additional
370  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
371  if (!ok) {
372  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
373  ok = true;
374  abort = true;
375  }
376  // get Edges
377  const std::string edgesAttribute = attrs.get<std::string>(SUMO_ATTR_EDGES, id.c_str(), ok, false);
378  if (!ok) {
379  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_EDGES) + "' of additional " + toString(tag) + " is missing");
380  ok = true;
381  abort = true;
382  }
383  // get rest of parameters
384  const std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, id.c_str(), ok, "", false);
385  const SUMOReal probability = attrs.getOpt<SUMOReal>(SUMO_ATTR_PROB, id.c_str(), ok, 1, false);
386  const bool off = attrs.getOpt<bool>(SUMO_ATTR_OFF, id.c_str(), ok, 0, false);
387  const SUMOReal posx = attrs.getOpt<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok, 0, false);
388  const SUMOReal posy = attrs.getOpt<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok, 0, false);
389  // Continue if all parameters were sucesfully loaded
390  if (!abort) {
391  // Obtain edges
392  std::vector<std::string> edgesID;
393  SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_EDGES, id.c_str(), ok, "", false), edgesID);
394  // obtain Rerouter values Values
395  // @ToDo Finish
396  std::set<GNERerouter::rerouterInterval> rerouterIntervals;
397  // Obtain pointer to edges
398  std::vector<GNEEdge*> edges;
399  for (int i = 0; i < (int)edgesID.size(); i++) {
400  GNEEdge* edge = myViewNet->getNet()->retrieveEdge(edgesID.at(i));
401  if (edge) {
402  edges.push_back(edge);
403  } else {
404  throw ProcessError(); /**************** ARREGLAR **********/
405  }
406  }
407  // if operation of build variable speed signal was sucesfully, save Id
408  if (buildRerouter(myViewNet, id, Position(posx, posy), edges, probability, file, off , rerouterIntervals, false)) {
410  }
411  }
412 }
413 
414 
415 void
417  bool ok = true;
418  bool abort = false;
419  // get ID of additional
420  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
421  if (!ok) {
422  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
423  ok = true;
424  abort = true;
425  }
426  // get lane ID
427  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, false);
428  if (!ok) {
429  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
430  ok = true;
431  abort = true;
432  }
433  // get startPosition
434  SUMOReal startPos = attrs.get<SUMOReal>(SUMO_ATTR_STARTPOS, id.c_str(), ok, false);
435  if (!ok) {
436  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_STARTPOS) + "' of additional " + toString(tag) + " is missing");
437  ok = true;
438  abort = true;
439  }
440  // get End Position
441  SUMOReal endPos = attrs.get<SUMOReal>(SUMO_ATTR_ENDPOS, id.c_str(), ok, false);
442  if (!ok) {
443  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ENDPOS) + "' of additional " + toString(tag) + " is missing");
444  ok = true;
445  abort = true;
446  }
447  // get optional atributes
448  const std::string linesAttribute = attrs.getOpt<std::string>(SUMO_ATTR_LINES, id.c_str(), ok, "", false);
449  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
450  // Continue if all parameters were sucesfully loaded
451  if (!abort) {
452  // Parse lines
453  std::vector<std::string> lines;
454  SUMOSAXAttributes::parseStringVector(linesAttribute, lines);
455  // get pointer to lane
456  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
457  if (lane == NULL) {
458  // Write error if lane isn't valid
459  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
460  } else if (!checkStopPos(startPos, endPos, lane->getLaneShapeLenght(), POSITION_EPS, friendlyPos)) {
461  // Write error if position isn't valid
462  WRITE_WARNING("Invalid position for " + toString(tag) + " '" + id + "'.");
463  } else {
464  // build busStop
465  buildBusStop(myViewNet, id, lane, startPos, endPos, lines, false);
466  }
467  }
468 }
469 
470 
471 void
473  bool ok = true;
474  bool abort = false;
475  // get ID of additional
476  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
477  if (!ok) {
478  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
479  ok = true;
480  abort = true;
481  }
482  // get lane ID
483  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, false);
484  if (!ok) {
485  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
486  ok = true;
487  abort = true;
488  }
489  // get startPosition
490  SUMOReal startPos = attrs.get<SUMOReal>(SUMO_ATTR_STARTPOS, id.c_str(), ok, false);
491  if (!ok) {
492  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_STARTPOS) + "' of additional " + toString(tag) + " is missing");
493  ok = true;
494  abort = true;
495  }
496  // get End Position
497  SUMOReal endPos = attrs.get<SUMOReal>(SUMO_ATTR_ENDPOS, id.c_str(), ok, false);
498  if (!ok) {
499  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ENDPOS) + "' of additional " + toString(tag) + " is missing");
500  ok = true;
501  abort = true;
502  }
503  // get lines
504  const std::string linesAttribute = attrs.getOpt<std::string>(SUMO_ATTR_LINES, id.c_str(), ok, "", false);
505  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
506  // Continue if all parameters were sucesfully loaded
507  if (!abort) {
508  // Parse lines
509  std::vector<std::string> lines;
510  SUMOSAXAttributes::parseStringVector(linesAttribute, lines);
511  // get pointer to lane
512  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
513  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  // Check position and build container stop
517  } else if (!checkStopPos(startPos, endPos, lane->getLaneShapeLenght(), POSITION_EPS, friendlyPos)) {
518  WRITE_WARNING("Invalid position for " + toString(tag) + " '" + id + "'.");
519  } else {
520  buildContainerStop(myViewNet, id, lane, startPos, endPos, lines, false);
521  }
522  }
523 }
524 
525 
526 void
528  bool ok = true;
529  bool abort = false;
530  // get ID of additional
531  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
532  if (!ok) {
533  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
534  ok = true;
535  abort = true;
536  }
537  // get lane ID
538  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, false);
539  if (!ok) {
540  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
541  ok = true;
542  abort = true;
543  }
544  // get startPosition
545  SUMOReal startPos = attrs.get<SUMOReal>(SUMO_ATTR_STARTPOS, id.c_str(), ok, false);
546  if (!ok) {
547  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_STARTPOS) + "' of additional " + toString(tag) + " is missing");
548  ok = true;
549  abort = true;
550  }
551  // get End Position
552  SUMOReal endPos = attrs.get<SUMOReal>(SUMO_ATTR_ENDPOS, id.c_str(), ok, false);
553  if (!ok) {
554  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ENDPOS) + "' of additional " + toString(tag) + " is missing");
555  ok = true;
556  abort = true;
557  }
558  // get rest of parameters
559  const SUMOReal chrgpower = attrs.getOpt<SUMOReal>(SUMO_ATTR_CHARGINGPOWER, id.c_str(), ok, 22000, false);
560  const SUMOReal efficiency = attrs.getOpt<SUMOReal>(SUMO_ATTR_EFFICIENCY, id.c_str(), ok, 0.95, false);
561  const bool chargeInTransit = attrs.getOpt<bool>(SUMO_ATTR_CHARGEINTRANSIT, id.c_str(), ok, 0, false);
562  const SUMOReal chargeDelay = attrs.getOpt<SUMOReal>(SUMO_ATTR_CHARGEDELAY, id.c_str(), ok, 0, false);
563  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
564  // Continue if all parameters were sucesfully loaded
565  if (!abort) {
566  // get pointer to lane
567  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
568  if (lane == NULL) {
569  // Write error if lane isn't valid
570  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
571  } else if (!checkStopPos(startPos, endPos, lane->getLaneShapeLenght(), POSITION_EPS, friendlyPos)) {
572  WRITE_WARNING("Invalid position for " + toString(tag) + " '" + id + "'.");
573  } else {
574  buildChargingStation(myViewNet, id, lane, startPos, endPos, chrgpower, efficiency, chargeInTransit, chargeDelay, false);
575  }
576  }
577 }
578 
579 
580 void
582  bool ok = true;
583  bool abort = false;
584  // get ID of additional
585  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
586  if (!ok) {
587  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
588  ok = true;
589  abort = true;
590  }
591  // get lane ID
592  const std::string laneID = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, false);
593  if (!ok) {
594  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
595  ok = true;
596  abort = true;
597  }
598  // get Output file
599  const std::string outfile = attrs.getOpt<std::string>(SUMO_ATTR_OUTPUT, id.c_str(), ok, "", false);
600  if (!ok) {
601  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_OUTPUT) + "' of additional " + toString(tag) + " is missing");
602  ok = true;
603  abort = true;
604  }
605  // get rest of parameters
606  const SUMOReal position = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok, 0, false);
607  SUMOTime freq = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, DELTA_T, false);
608  // Currently routeProbe not used
609  // std::string routeProbe = attrs.getOpt<std::string>(SUMO_ATTR_ROUTEPROBE, id.c_str(), ok, "");
610  // Continue if all parameters were sucesfully loaded
611  if (!abort) {
612  // get pointer to edge
613  GNEEdge* edge = &(myViewNet->getNet()->retrieveLane(laneID, false)->getParentEdge());
614  if (edge == NULL) {
615  // Write error if lane isn't valid
616  WRITE_WARNING("The lane '" + laneID + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
617  } else {
618  if (buildCalibrator(myViewNet, id, edge, position, outfile, freq, std::map<std::string, GNECalibrator::CalibratorFlow>(), false)) {
619  // Save id for insert flows
621  }
622  }
623  }
624 }
625 
626 
627 void
629  bool ok = true;
630  bool abort = false;
631  // get ID of additional
632  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
633  if (!ok) {
634  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
635  ok = true;
636  abort = true;
637  }
638  // get lane ID
639  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, false);
640  if (!ok) {
641  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
642  ok = true;
643  abort = true;
644  }
645  // Load position
646  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok, false);
647  if (!ok) {
648  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_POSITION) + "' of additional " + toString(tag) + " is missing");
649  ok = true;
650  abort = true;
651  }
652  // Load frequency
653  const SUMOTime frequency = attrs.get<SUMOTime>(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
654  if (!ok) {
655  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FREQUENCY) + "' of additional " + toString(tag) + " is missing");
656  ok = true;
657  abort = true;
658  }
659  // Load file
660  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok, false);
661  if (!ok) {
662  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FILE) + "' of additional " + toString(tag) + " is missing");
663  ok = true;
664  abort = true;
665  }
666  // get rest of attributes
667  const bool splitByType = attrs.getOpt<bool>(SUMO_ATTR_SPLIT_VTYPE, id.c_str(), ok, false, false);
668  // Continue if all parameters were sucesfully loaded
669  if (!abort) {
670  // get pointer to lane
671  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
672  if (lane == NULL) {
673  // Write error if lane isn't valid
674  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
675  } else {
676  // build detector E1
677  buildDetectorE1(myViewNet, id, lane, position, frequency, file, splitByType, false);
678  }
679  }
680 }
681 
682 
683 void
685  bool ok = true;
686  bool abort = false;
687  // get ID of additional
688  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
689  if (!ok) {
690  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
691  ok = true;
692  abort = true;
693  }
694  // get lane ID
695  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, false);
696  if (!ok) {
697  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
698  ok = true;
699  abort = true;
700  }
701  // Load position
702  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok, false);
703  if (!ok) {
704  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_POSITION) + "' of additional " + toString(tag) + " is missing");
705  ok = true;
706  abort = true;
707  }
708  // Load frequency
709  const SUMOTime frequency = attrs.get<SUMOTime>(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
710  if (!ok) {
711  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FREQUENCY) + "' of additional " + toString(tag) + " is missing");
712  ok = true;
713  abort = true;
714  }
715  // Load file
716  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok, false);
717  if (!ok) {
718  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FILE) + "' of additional " + toString(tag) + " is missing");
719  ok = true;
720  abort = true;
721  }
722  // Load lenght
723  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok, false);
724  if (!ok) {
725  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LENGTH) + "' of additional " + toString(tag) + " is missing");
726  ok = true;
727  abort = true;
728  }
729  // get Rest of parameters
730  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1), false);
731  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f, false);
732  const SUMOReal jamDistThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f, false);
733  const bool cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, id.c_str(), ok, false);
734  // Check if parsing of parameters was correct
735  // Continue if all parameters were sucesfully loaded
736  if (!abort) {
737  // get pointer to lane
738  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
739  if (lane == NULL) {
740  // Write error if lane isn't valid
741  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " '" + id + "' is not known.");
742  } else {
743  // build detector E2
744  buildDetectorE2(myViewNet, id, lane, position, length, frequency, file, cont, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, false);
745  }
746  }
747 }
748 
749 
750 void
752  bool ok = true;
753  bool abort = false;
754  // get ID of additional
755  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
756  if (!ok) {
757  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_ID) + "' of additional " + toString(tag) + " is missing");
758  ok = true;
759  abort = true;
760  }
761  // Load frequency
762  const SUMOTime frequency = attrs.get<SUMOTime>(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
763  if (!ok) {
764  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FREQUENCY) + "' of additional " + toString(tag) + " is missing");
765  ok = true;
766  abort = true;
767  }
768  // Load file
769  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok, false);
770  if (!ok) {
771  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_FILE) + "' of additional " + toString(tag) + " is missing");
772  ok = true;
773  abort = true;
774  }
775  // Load rest of parameters
776  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1), false);
777  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f, false);
778  const SUMOReal posx = attrs.getOpt<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok, 0, false);
779  const SUMOReal posy = attrs.getOpt<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok, 0, false);
780  // Continue if all parameters were sucesfully loaded
781  if (!abort) {
782  // if operation of build detector E3 was sucesfully, save Id
783  if (buildDetectorE3(myViewNet, id, Position(posx, posy), frequency, file, haltingTimeThreshold, haltingSpeedThreshold, false)) {
785  }
786  }
787 }
788 
789 
790 void
792  bool ok = true;
793  bool abort = false;
794  // Load position
795  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, false);
796  if (!ok) {
797  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_POSITION) + "' of additional " + toString(tag) + " is missing");
798  ok = true;
799  abort = true;
800  }
801  // get lane ID
802  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, 0, ok, false);
803  if (!ok) {
804  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
805  ok = true;
806  abort = true;
807  }
808  // Check if parsing of parameters was correct
809  if (!abort) {
810  // get pointer to lane
811  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
812  if (lane == NULL) {
813  // Write error if lane isn't valid
814  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
815  } else {
816  // get the ID. Note: This Id is interne, and cannot be defined by user
817  int indexEntry = 0;
818  while (myViewNet->getNet()->getAdditional(tag, toString(tag) + "_" + toString(indexEntry) + "_" + myAdditionalSetParent) != NULL) {
819  indexEntry++;
820  }
821  // build detector entry
822  buildDetectorEntry(myViewNet, toString(tag) + "_" + toString(indexEntry) + "_" + myAdditionalSetParent, lane, position, myAdditionalSetParent, false);
823  }
824  }
825 }
826 
827 
828 void
830  bool ok = true;
831  bool abort = false;
832  // Load position
833  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, false);
834  if (!ok) {
835  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_POSITION) + "' of additional " + toString(tag) + " is missing");
836  ok = true;
837  abort = true;
838  }
839  // get lane ID
840  const std::string laneId = attrs.get<std::string>(SUMO_ATTR_LANE, 0, ok, false);
841  if (!ok) {
842  WRITE_WARNING("Parameter '" + toString(SUMO_ATTR_LANE) + "' of additional " + toString(tag) + " is missing");
843  ok = true;
844  abort = true;
845  }
846  // Check if parsing of parameters was correct
847  if (!abort) {
848  // get pointer to lane
849  GNELane* lane = myViewNet->getNet()->retrieveLane(laneId, false);
850  if (lane == NULL) {
851  // Write error if lane isn't valid
852  WRITE_WARNING("The lane '" + laneId + "' to use within the " + toString(tag) + " is not known.");
853  } else {
854  // get the ID. Note: This Id is interne, and cannot be defined by user
855  int indexExit = 0;
856  while (myViewNet->getNet()->getAdditional(tag, toString(tag) + "_" + toString(indexExit) + "_" + myAdditionalSetParent) != NULL) {
857  indexExit++;
858  }
859  // build detector Exit
860  buildDetectorExit(myViewNet, toString(tag) + "_" + toString(indexExit) + "_" + myAdditionalSetParent, lane, position, myAdditionalSetParent, false);
861  }
862  }
863 }
864 
865 
866 bool
867 GNEAdditionalHandler::buildAdditional(GNEViewNet* viewNet, SumoXMLTag tag, std::map<SumoXMLAttr, std::string> values) {
868  // Extract common attributes
869  std::string id = values[SUMO_ATTR_ID];
870  bool blocked = GNEAttributeCarrier::parse<bool>(values[GNE_ATTR_BLOCK_MOVEMENT]);
871  // create additional depending of the tag
872  switch (tag) {
873  case SUMO_TAG_BUS_STOP: {
874  // get own attributes of busStop
875  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
876  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTPOS]);
877  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_ENDPOS]);
878  std::vector<std::string> lines;
880  // Build busStop
881  if (lane) {
882  return buildBusStop(viewNet, id, lane, startPos, endPos, lines, blocked);
883  } else {
884  return false;
885  }
886  }
888  // get own attributes of containerStop
889  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
890  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTPOS]);
891  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_ENDPOS]);
892  std::vector<std::string> lines;
894  // Build containerStop
895  if (lane) {
896  return buildContainerStop(viewNet, id, lane, startPos, endPos, lines, blocked);
897  } else {
898  return false;
899  }
900  }
902  // get own attributes of chargingStation
903  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
904  SUMOReal startPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_STARTPOS]);
905  SUMOReal endPos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_ENDPOS]);
906  SUMOReal chargingPower = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_CHARGINGPOWER]);
907  SUMOReal efficiency = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_EFFICIENCY]);
908  bool chargeInTransit = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CHARGEINTRANSIT]);
909  int chargeDelay = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_CHARGEDELAY]);
910  // Build chargingStation
911  if (lane) {
912  return buildChargingStation(viewNet, id, lane, startPos, endPos, chargingPower, efficiency, chargeInTransit, chargeDelay, blocked);
913  } else {
914  return false;
915  }
916  }
917  case SUMO_TAG_E1DETECTOR: {
918  // get own attributes of detector E1
919  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
920  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
921  int freq = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_FREQUENCY]);
922  std::string filename = values[SUMO_ATTR_FILE];
923  bool splitByType = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_SPLIT_VTYPE]);
924  // Build detector E1
925  if (lane) {
926  return buildDetectorE1(viewNet, id, lane, pos, freq, filename, splitByType, blocked);
927  } else {
928  return false;
929  }
930  }
931  case SUMO_TAG_E2DETECTOR: {
932  // get own attributes of detector E2
933  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
934  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
935  int freq = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_FREQUENCY]);
936  SUMOReal lenght = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_LENGTH]);
937  std::string filename = values[SUMO_ATTR_FILE];
938  bool cont = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_CONT]);
939  int timeThreshold = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
940  SUMOReal speedThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
941  SUMOReal jamThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_JAM_DIST_THRESHOLD]);
942  // Build detector E2
943  if (lane) {
944  return buildDetectorE2(viewNet, id, lane, pos, lenght, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold, blocked);
945  } else {
946  return false;
947  }
948  }
949  case SUMO_TAG_E3DETECTOR: {
950  // get own attributes of detector E3
951  bool ok;
952  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
953  int freq = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_FREQUENCY]);
954  std::string filename = values[SUMO_ATTR_FILE];
955  int timeThreshold = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_HALTING_TIME_THRESHOLD]);
956  SUMOReal speedThreshold = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_HALTING_SPEED_THRESHOLD]);
957  // Build detector E3
958  if (pos.size() == 1) {
959  return buildDetectorE3(viewNet, id, pos[0], freq, filename, timeThreshold, speedThreshold, blocked);
960  } else {
961  return false;
962  }
963  }
964  case SUMO_TAG_DET_ENTRY: {
965  // get own attributes of detector Entry
966  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
967  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
968  std::string detectorE3ParentID = values[GNE_ATTR_PARENT];
969  // Build detector Entry
970  if (lane && !detectorE3ParentID.empty()) {
971  return buildDetectorEntry(viewNet, id, lane, pos, detectorE3ParentID, blocked);
972  } else {
973  return false;
974  }
975  }
976  case SUMO_TAG_DET_EXIT: {
977  // get own attributes of Detector Exit
978  GNELane* lane = viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false);
979  SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
980  std::string detectorE3ParentID = values[GNE_ATTR_PARENT];
981  // Build detector Exit
982  if (lane && !detectorE3ParentID.empty()) {
983  return buildDetectorExit(viewNet, id, lane, pos, detectorE3ParentID, blocked);
984  } else {
985  return false;
986  }
987  }
988  case SUMO_TAG_VSS: {
989  // get own attributes of variable speed signal
990  bool ok;
991  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
992  // Parse lane Ids
993  std::vector<std::string> laneIds;
995  // By default, VSSValues are empty
996  std::map<SUMOTime, SUMOReal> VSSValues;
997  // Obtain pointers to lanes
998  std::vector<GNELane*> lanes;
999  for (int i = 0; i < (int)laneIds.size(); i++) {
1000  lanes.push_back(viewNet->getNet()->retrieveLane(laneIds.at(i)));
1001  }
1002  std::string file = values[SUMO_ATTR_FILE];
1003  if (pos.size() == 1) {
1004  return buildVariableSpeedSignal(viewNet, id, pos[0], lanes, file, VSSValues, blocked);
1005  } else {
1006  return false;
1007  }
1008  }
1009  case SUMO_TAG_CALIBRATOR: {
1010  // get own attributes of calibrator
1011  GNEEdge* edge = &(viewNet->getNet()->retrieveLane(values[SUMO_ATTR_LANE], false)->getParentEdge());
1012  // get rest of parameters
1013  // Currently unused SUMOReal pos = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_POSITION]);
1014  SUMOReal pos = 0;
1015  std::string outfile = values[SUMO_ATTR_OUTPUT];
1016  SUMOTime freq = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_FREQUENCY]);
1017  // get flow values
1018  std::map<std::string, GNECalibrator::CalibratorFlow> flowValues;
1019  // Build calibrator
1020  if (edge) {
1021  return buildCalibrator(viewNet, id, edge, pos, outfile, freq, flowValues, blocked);
1022  } else {
1023  return false;
1024  }
1025  }
1026  case SUMO_TAG_REROUTER: {
1027  // get own attributes of rerouter
1028  bool ok;
1029  PositionVector pos = GeomConvHelper::parseShapeReporting(values[SUMO_ATTR_POSITION], "user-supplied position", 0, ok, false);
1030  // Parse edges Ids
1031  std::vector<std::string> edgeIds;
1033  // Get rest of parameters
1034  bool off = GNEAttributeCarrier::parse<bool>(values[SUMO_ATTR_OFF]);
1035  SUMOReal prob = GNEAttributeCarrier::parse<SUMOReal>(values[SUMO_ATTR_PROB]);
1036  std::string file = values[SUMO_ATTR_FILE];
1037  // Obtain pointers to edges
1038  std::vector<GNEEdge*> edges;
1039  for (int i = 0; i < (int)edgeIds.size(); i++) {
1040  edges.push_back(viewNet->getNet()->retrieveEdge(edgeIds.at(i)));
1041  }
1042  // Obtain routerIntervals
1043  std::set<GNERerouter::rerouterInterval> rerouterIntervals;
1044  // Build rerouter
1045  if (pos.size() == 1) {
1046  return buildRerouter(viewNet, id, pos[0], edges, prob, file, off, rerouterIntervals, blocked);
1047  } else {
1048  return false;
1049  }
1050  }
1051  case SUMO_TAG_ROUTEPROBE: {
1052  // get own attributes of RouteProbe
1053  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1054  int freq = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_FREQUENCY]);
1055  std::string filename = values[SUMO_ATTR_FILE];
1056  int begin = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_BEGIN]);
1057  // Build RouteProbe
1058  if (edge) {
1059  return buildRouteProbe(viewNet, id, edge, freq, filename, begin, blocked);
1060  } else {
1061  return false;
1062  }
1063  }
1064  case SUMO_TAG_VAPORIZER: {
1065  // get own attributes of vaporizer
1066  GNEEdge* edge = viewNet->getNet()->retrieveEdge(values[SUMO_ATTR_EDGE], false);
1067  int startTime = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_STARTTIME]);
1068  int end = GNEAttributeCarrier::parse<int>(values[SUMO_ATTR_END]);
1069  // Build RouteProbe
1070  if (edge) {
1071  return buildVaporizer(viewNet, id, edge, startTime, end, blocked);
1072  } else {
1073  return false;
1074  }
1075  }
1076  default:
1077  return false;
1078  }
1079 }
1080 
1081 
1082 bool
1083 GNEAdditionalHandler::buildBusStop(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal startPos, SUMOReal endPos, const std::vector<std::string>& lines, bool blocked) {
1084  if (viewNet->getNet()->getAdditional(SUMO_TAG_BUS_STOP, id) == NULL) {
1085  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_BUS_STOP));
1086  GNEBusStop* busStop = new GNEBusStop(id, lane, viewNet, startPos, endPos, lines, blocked);
1087  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), busStop, true), true);
1088  viewNet->getUndoList()->p_end();
1089  return true;
1090  } else {
1091  WRITE_WARNING("Could not build " + toString(SUMO_TAG_BUS_STOP) + " with id '" + id + "' in netEdit; probably declared twice.");
1092  return false;
1093  }
1094 }
1095 
1096 
1097 bool
1098 GNEAdditionalHandler::buildContainerStop(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal startPos, SUMOReal endPos, const std::vector<std::string>& lines, bool blocked) {
1099  if (viewNet->getNet()->getAdditional(SUMO_TAG_CONTAINER_STOP, id) == NULL) {
1100  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CONTAINER_STOP));
1101  GNEContainerStop* containerStop = new GNEContainerStop(id, lane, viewNet, startPos, endPos, lines, blocked);
1102  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), containerStop, true), true);
1103  viewNet->getUndoList()->p_end();
1104  return true;
1105  } else {
1106  WRITE_WARNING("Could not build " + toString(SUMO_TAG_CONTAINER_STOP) + " with id '" + id + "' in netEdit; probably declared twice.");
1107  return false;
1108  }
1109 }
1110 
1111 
1112 bool
1113 GNEAdditionalHandler::buildChargingStation(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal startPos, SUMOReal endPos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, SUMOReal chargeDelay, bool blocked) {
1114  if (viewNet->getNet()->getAdditional(SUMO_TAG_CHARGING_STATION, id) == NULL) {
1115  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CHARGING_STATION));
1116  GNEChargingStation* chargingStation = new GNEChargingStation(id, lane, viewNet, startPos, endPos, chargingPower, efficiency, chargeInTransit, chargeDelay, blocked);
1117  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), chargingStation, true), true);
1118  viewNet->getUndoList()->p_end();
1119  return true;
1120  } else {
1121  WRITE_WARNING("Could not build " + toString(SUMO_TAG_CHARGING_STATION) + " with id '" + id + "' in netEdit; probably declared twice.");
1122  return false;
1123  }
1124 }
1125 
1126 
1127 bool
1128 GNEAdditionalHandler::buildDetectorE1(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal pos, int freq, const std::string& filename, bool splitByType, bool blocked) {
1129  if (viewNet->getNet()->getAdditional(SUMO_TAG_E1DETECTOR, id) == NULL) {
1130  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E1DETECTOR));
1131  GNEDetectorE1* detectorE1 = new GNEDetectorE1(id, lane, viewNet, pos, freq, filename, splitByType, blocked);
1132  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), detectorE1, true), true);
1133  viewNet->getUndoList()->p_end();
1134  return true;
1135  } else {
1136  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E1DETECTOR) + " with id '" + id + "' in netEdit; probably declared twice.");
1137  return false;
1138  }
1139 }
1140 
1141 
1142 bool
1143 GNEAdditionalHandler::buildDetectorE2(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal pos, SUMOReal length, SUMOReal freq, const std::string& filename, bool cont, int timeThreshold, SUMOReal speedThreshold, SUMOReal jamThreshold, bool blocked) {
1144  if (viewNet->getNet()->getAdditional(SUMO_TAG_E2DETECTOR, id) == NULL) {
1145  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E2DETECTOR));
1146  GNEDetectorE2* detectorE2 = new GNEDetectorE2(id, lane, viewNet, pos, length, freq, filename, cont, timeThreshold, speedThreshold, jamThreshold, blocked);
1147  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), detectorE2, true), true);
1148  viewNet->getUndoList()->p_end();
1149  return true;
1150  } else {
1151  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E2DETECTOR) + " with id '" + id + "' in netEdit; probably declared twice.");
1152  return false;
1153  }
1154 }
1155 
1156 
1157 bool
1158 GNEAdditionalHandler::buildDetectorE3(GNEViewNet* viewNet, const std::string& id, Position pos, int freq, const std::string& filename, SUMOTime timeThreshold, SUMOReal speedThreshold, bool blocked) {
1159  if (viewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, id) == NULL) {
1160  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_E3DETECTOR));
1161  GNEDetectorE3* detectorE3 = new GNEDetectorE3(id, viewNet, pos, freq, filename, timeThreshold, speedThreshold, blocked);
1162  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), detectorE3, true), true);
1163  viewNet->getUndoList()->p_end();
1164  return true;
1165  } else {
1166  WRITE_WARNING("Could not build " + toString(SUMO_TAG_E3DETECTOR) + " with id '" + id + "' in netEdit; probably declared twice.");
1167  return false;
1168  }
1169 }
1170 
1171 
1172 bool
1173 GNEAdditionalHandler::buildDetectorEntry(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal pos, std::string idDetectorE3Parent, bool blocked) {
1174  // get DetectorE3 parent
1175  GNEDetectorE3* detectorE3Parent = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, idDetectorE3Parent));
1176  // Check if DetectorE3 parent is correct
1177  if (detectorE3Parent == NULL) {
1178  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " '" + id + "' in netEdit; '" + toString(SUMO_TAG_E3DETECTOR) + " '" + idDetectorE3Parent + "' don't valid.");
1179  return false;
1180  } else if (viewNet->getNet()->getAdditional(SUMO_TAG_DET_ENTRY, id) == NULL) {
1181  // Create detector Entry if don't exist already in the net
1182  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_ENTRY));
1183  GNEDetectorEntry* entry = new GNEDetectorEntry(id, viewNet, lane, pos, detectorE3Parent, blocked);
1184  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), entry, true), true);
1185  viewNet->getUndoList()->p_end();
1186  return true;
1187  } else {
1188  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_ENTRY) + " with id '" + id + "' in netEdit; probably declared twice.");
1189  return false;
1190  }
1191 }
1192 
1193 
1194 bool
1195 GNEAdditionalHandler::buildDetectorExit(GNEViewNet* viewNet, const std::string& id, GNELane* lane, SUMOReal pos, std::string idDetectorE3Parent, bool blocked) {
1196  // get DetectorE3 parent
1197  GNEDetectorE3* detectorE3Parent = dynamic_cast<GNEDetectorE3*>(viewNet->getNet()->getAdditional(SUMO_TAG_E3DETECTOR, idDetectorE3Parent));
1198  // Check if DetectorE3 parent is correct
1199  if (detectorE3Parent == NULL) {
1200  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_EXIT) + " '" + id + "' in netEdit; '" + idDetectorE3Parent + "' don't valid.");
1201  return false;
1202  } else if (viewNet->getNet()->getAdditional(SUMO_TAG_DET_EXIT, id) == NULL) {
1203  // Create detector Exit if don't exist already in the net
1204  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_DET_EXIT));
1205  GNEDetectorExit* exit = new GNEDetectorExit(id, viewNet, lane, pos, detectorE3Parent, blocked);
1206  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), exit, true), true);
1207  viewNet->getUndoList()->p_end();
1208  return true;
1209  } else {
1210  WRITE_WARNING("Could not build " + toString(SUMO_TAG_DET_EXIT) + " with id '" + id + "' in netEdit; probably declared twice.");
1211  return false;
1212  }
1213 }
1214 
1215 
1216 bool
1217 GNEAdditionalHandler::buildCalibrator(GNEViewNet* viewNet, const std::string& id, GNEEdge* edge, SUMOReal pos, const std::string& outfile, const SUMOTime freq, const std::map<std::string, GNECalibrator::CalibratorFlow>& flowValues, bool blocked) {
1218  if (viewNet->getNet()->getAdditional(SUMO_TAG_CALIBRATOR, id) == NULL) {
1219  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_CALIBRATOR));
1220  GNECalibrator* calibrator = new GNECalibrator(id, edge, viewNet, pos, freq, outfile, flowValues, blocked);
1221  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), calibrator, true), true);
1222  viewNet->getUndoList()->p_end();
1223  return true;
1224  } else {
1225  WRITE_WARNING("Could not build " + toString(SUMO_TAG_CALIBRATOR) + " with id '" + id + "' in netEdit; probably declared twice.");
1226  return false;
1227  }
1228 }
1229 
1230 
1231 bool
1232 GNEAdditionalHandler::buildRerouter(GNEViewNet* viewNet, const std::string& id, Position pos, const std::vector<GNEEdge*>& edges, SUMOReal prob, const std::string& file, bool off, const std::set<GNERerouter::rerouterInterval>& rerouterIntervals, bool blocked) {
1233  if (viewNet->getNet()->getAdditional(SUMO_TAG_REROUTER, id) == NULL) {
1234  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_REROUTER));
1235  GNERerouter* rerouter = new GNERerouter(id, viewNet, pos, edges, file, prob, off, rerouterIntervals, blocked);
1236  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), rerouter, true), true);
1237  viewNet->getUndoList()->p_end();
1238  return true;
1239  } else {
1240  WRITE_WARNING("Could not build " + toString(SUMO_TAG_REROUTER) + " with id '" + id + "' in netEdit; probably declared twice.");
1241  return false;
1242  }
1243 }
1244 
1245 
1246 bool
1247 GNEAdditionalHandler::buildRouteProbe(GNEViewNet* viewNet, const std::string& id, GNEEdge* edge, int freq, const std::string& file, int begin, bool blocked) {
1248  if (viewNet->getNet()->getAdditional(SUMO_TAG_REROUTER, id) == NULL) {
1249  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_ROUTEPROBE));
1250  GNERouteProbe* routeProbe = new GNERouteProbe(id, viewNet, edge, freq, file, begin, blocked);
1251  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), routeProbe, true), true);
1252  viewNet->getUndoList()->p_end();
1253  return true;
1254  } else {
1255  WRITE_WARNING("Could not build " + toString(SUMO_TAG_ROUTEPROBE) + " with id '" + id + "' in netEdit; probably declared twice.");
1256  return false;
1257  }
1258 }
1259 
1260 
1261 bool
1262 GNEAdditionalHandler::buildVariableSpeedSignal(GNEViewNet* viewNet, const std::string& id, Position pos, const std::vector<GNELane*>& lanes, const std::string& file, const std::map<SUMOTime, SUMOReal>& VSSValues, bool blocked) {
1263  if (viewNet->getNet()->getAdditional(SUMO_TAG_VSS, id) == NULL) {
1264  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VSS));
1265  GNEVariableSpeedSignal* variableSpeedSignal = new GNEVariableSpeedSignal(id, viewNet, pos, lanes, file, VSSValues, blocked);
1266  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), variableSpeedSignal, true), true);
1267  viewNet->getUndoList()->p_end();
1268  return true;
1269  } else {
1270  WRITE_WARNING("Could not build " + toString(SUMO_TAG_VSS) + " with id '" + id + "' in netEdit; probably declared twice.");
1271  return false;
1272  }
1273 }
1274 
1275 
1276 bool
1277 GNEAdditionalHandler::buildVaporizer(GNEViewNet* viewNet, const std::string& id, GNEEdge* edge, SUMOTime startTime, SUMOTime end, bool blocked) {
1278  if (viewNet->getNet()->getAdditional(SUMO_TAG_VAPORIZER, id) == NULL) {
1279  viewNet->getUndoList()->p_begin("add " + toString(SUMO_TAG_VAPORIZER));
1280  GNEVaporizer* vaporizer = new GNEVaporizer(id, viewNet, edge, startTime, end, blocked);
1281  viewNet->getUndoList()->add(new GNEChange_Additional(viewNet->getNet(), vaporizer, true), true);
1282  viewNet->getUndoList()->p_end();
1283  return true;
1284  } else {
1285  WRITE_WARNING("Could not build " + toString(SUMO_TAG_VAPORIZER) + " with id '" + id + "' in netEdit; probably declared twice.");
1286  return false;
1287  }
1288 }
1289 
1290 
1291 std::string
1292 GNEAdditionalHandler::getFileName(const SUMOSAXAttributes& attrs, const std::string& base, const bool allowEmpty) {
1293  // get the file name to read further definitions from
1294  bool ok = true;
1295  std::string file = attrs.getOpt<std::string>(SUMO_ATTR_FILE, 0, ok, "");
1296  if (file == "") {
1297  if (allowEmpty) {
1298  return file;
1299  }
1300  WRITE_WARNING("No filename given.");
1301  }
1302  // check whether absolute or relative filenames are given
1303  if (!FileHelpers::isAbsolute(file)) {
1304  return FileHelpers::getConfigurationRelative(base, file);
1305  }
1306  return file;
1307 }
1308 
1309 
1310 SUMOReal
1311 GNEAdditionalHandler::getPosition(const SUMOSAXAttributes& attrs, GNELane& lane, const std::string& tt, const std::string& tid) {
1312  bool ok = true;
1313  SUMOReal pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, false);
1314  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
1315  if (!ok) {
1316  WRITE_WARNING("Error on parsing a position information.");
1317  }
1318  if (pos < 0) {
1319  pos = lane.getLaneShapeLenght() + pos;
1320  }
1321  if (pos > lane.getLaneShapeLenght()) {
1322  if (friendlyPos) {
1323  pos = lane.getLaneShapeLenght() - (SUMOReal) 0.1;
1324  } else {
1325  WRITE_WARNING("The position of " + tt + " '" + tid + "' lies beyond the lane's '" + lane.getID() + "' length.");
1326  }
1327  }
1328  return pos;
1329 }
1330 
1331 
1332 bool
1333 GNEAdditionalHandler::checkStopPos(SUMOReal& startPos, SUMOReal& endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos) {
1334  if (minLength > laneLength) {
1335  return false;
1336  }
1337  if (startPos < 0) {
1338  startPos += laneLength;
1339  }
1340  if (endPos < 0) {
1341  endPos += laneLength;
1342  }
1343  if (endPos < minLength || endPos > laneLength) {
1344  if (!friendlyPos) {
1345  return false;
1346  }
1347  if (endPos < minLength) {
1348  endPos = minLength;
1349  }
1350  if (endPos > laneLength) {
1351  endPos = laneLength;
1352  }
1353  }
1354  if (startPos < 0 || startPos > endPos - minLength) {
1355  if (!friendlyPos) {
1356  return false;
1357  }
1358  if (startPos < 0) {
1359  startPos = 0;
1360  }
1361  if (startPos > endPos - minLength) {
1362  startPos = endPos - minLength;
1363  }
1364  }
1365  return true;
1366 }
1367 
1368 
1369 /****************************************************************************/
SumoXMLTag
Numbers representing SUMO-XML - element names.
static bool buildVariableSpeedSignal(GNEViewNet *viewNet, const std::string &id, Position pos, const std::vector< GNELane *> &destLanes, const std::string &file, const std::map< SUMOTime, SUMOReal > &VSSValues, bool blocked)
Builds a VariableSpeedSignal (lane speed trigger)
void parseCalibratorFlow(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses flow values of Calibrators.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:702
long long int SUMOTime
Definition: SUMOTime.h:43
static bool buildContainerStop(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, const std::vector< std::string > &lines, bool blocked)
Builds a container stop.
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
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;.
static bool buildChargingStation(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal startPos, SUMOReal endPos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, SUMOReal chargeDelay, bool blocked)
Builds a charging Station.
void parseAndBuildChargingStation(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a charging station.
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1250
const std::string & getFileName() const
returns the current file name
GNEAdditionalHandler(const std::string &file, GNEViewNet *viewNet)
Constructor.
void insertFlow(const std::string &id, const CalibratorFlow &flow)
insert a new flow
static bool buildAdditional(GNEViewNet *viewNet, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Builds additional / additionalSet.
void parseAndBuildDetectorExit(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Exit detector.
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:55
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
void parseAndBuildVariableSpeedSignal(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Variable Speed Signal (lane speed trigger)
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
SAX-handler base for SUMO-files.
static bool buildVaporizer(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOTime startTime, SUMOTime end, bool blocked)
Builds a vaporizer (lane speed trigger)
static bool buildRerouter(GNEViewNet *viewNet, const std::string &id, Position pos, const std::vector< GNEEdge *> &edges, SUMOReal prob, const std::string &file, bool off, const std::set< GNERerouter::rerouterInterval > &rerouterIntervals, bool blocked)
builds a rerouter
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
void parseAndBuildDetectorE2(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a lane area detector (E2)
static bool buildDetectorE3(GNEViewNet *viewNet, const std::string &id, Position pos, int freq, const std::string &filename, SUMOTime timeThreshold, SUMOReal speedThreshold, bool blocked)
Builds a multi entry exit detector (E3)
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
void parseVariableSpeedSignalStep(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses step values of VariableSpeedSignals.
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:918
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
~GNEAdditionalHandler()
Destructor.
static bool buildCalibrator(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, SUMOReal pos, const std::string &outfile, const SUMOTime freq, const std::map< std::string, GNECalibrator::CalibratorFlow > &flowValues, bool blocked)
builds a microscopic calibrator
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:687
the edges of a route
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1061
Encapsulated SAX-Attributes.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
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
A list of positions.
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
Definition: GNENet.cpp:744
static bool buildRouteProbe(GNEViewNet *viewNet, const std::string &id, GNEEdge *edge, int freq, const std::string &file, int begin, bool blocked)
builds a Route probe
void parseAndBuildRerouter(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a rerouter.
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:58
#define POSITION_EPS
Definition: config.h:187
const std::string getID() const
function to support debugging
GNEViewNet * myViewNet
pointer to View&#39;s Net
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
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, bool blocked)
Builds a bus stop.
void parseAndBuildDetectorE3(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a multi entry exit detector (E3)
std::string myAdditionalSetParent
Id of the last inserted GNEAdditionalSet.
void parseAndBuildRouteProbe(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds routeProbe.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
static bool buildDetectorE2(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, SUMOReal length, SUMOReal freq, const std::string &filename, bool cont, int timeThreshold, SUMOReal speedThreshold, SUMOReal jamThreshold, bool blocked)
Builds a lane Area Detector (E2)
void parseAndBuildCalibrator(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a mesoscopic or microscopic calibrator.
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.
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.
static bool buildDetectorExit(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, std::string idDetectorE3Parent, bool blocked)
Builds a exit detector (E3)
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
void parseAndBuildVaporizer(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Builds a vaporization.
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...
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:912
A variable speed sign.
#define SUMOReal
Definition: config.h:213
A lane area vehicles can halt at (netedit-version)
static bool buildDetectorEntry(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, std::string idDetectorE3Parent, bool blocked)
Builds a entry detector (E3)
static bool buildDetectorE1(GNEViewNet *viewNet, const std::string &id, GNELane *lane, SUMOReal pos, int freq, const std::string &filename, bool splitByType, bool blocked)
Builds a induction loop detector (E1)
Information whether the detector shall be continued on the folowing lanes.
A color information.
bool insertStep(const SUMOTime time, const SUMOReal speed)
insert a new step in variable speed signal
void parseAndBuildDetectorEntry(const SUMOSAXAttributes &attrs, const SumoXMLTag &tag)
Parses his values and builds a Entry 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.