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