Eclipse SUMO - Simulation of Urban MObility
GNEAdditionalHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Builds trigger objects for netedit
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEUndoList.h>
25 #include <netedit/GNENet.h>
26 #include <utils/xml/NamespaceIDs.h>
27 
28 #include "GNEAdditionalHandler.h"
29 #include "GNEAccess.h"
30 #include "GNEBusStop.h"
31 #include "GNECalibrator.h"
32 #include "GNECalibratorFlow.h"
33 #include "GNEChargingStation.h"
34 #include "GNEClosingLaneReroute.h"
35 #include "GNEClosingReroute.h"
36 #include "GNEContainerStop.h"
37 #include "GNEDestProbReroute.h"
40 #include "GNELaneAreaDetector.h"
42 #include "GNEEntryExitDetector.h"
43 #include "GNEOverheadWire.h"
44 #include "GNEPOI.h"
45 #include "GNEParkingArea.h"
46 #include "GNEParkingAreaReroute.h"
47 #include "GNEParkingSpace.h"
48 #include "GNEPoly.h"
49 #include "GNERerouter.h"
50 #include "GNERerouterInterval.h"
51 #include "GNERerouterSymbol.h"
52 #include "GNERouteProbReroute.h"
53 #include "GNERouteProbe.h"
54 #include "GNETAZ.h"
55 #include "GNETAZSourceSink.h"
56 #include "GNETractionSubstation.h"
57 #include "GNEVaporizer.h"
58 #include "GNEVariableSpeedSign.h"
61 
62 
63 // ===========================================================================
64 // GNEAdditionalHandler method definitions
65 // ===========================================================================
66 
67 GNEAdditionalHandler::GNEAdditionalHandler(GNENet* net, const bool allowUndoRedo, const bool overwrite) :
68  myNet(net),
69  myAllowUndoRedo(allowUndoRedo),
70  myOverwrite(overwrite) {
71 }
72 
73 
75 }
76 
77 
78 void
79 GNEAdditionalHandler::buildBusStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id,
80  const std::string& laneID, const double startPos, const double endPos, const std::string& name,
81  const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
82  const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
83  // check conditions
87  // get netedit parameters
88  NeteditParameters neteditParameters(sumoBaseObject);
89  // get lane
90  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
91  // check lane
92  if (lane == nullptr) {
94  } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
96  } else if (personCapacity < 0) {
98  } else if (parkingLength < 0) {
100  } else {
101  // build busStop
102  GNEAdditional* busStop = GNEBusStop::buildBusStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
103  parkingLength, color, friendlyPosition, parameters);
104  // insert depending of allowUndoRedo
105  if (myAllowUndoRedo) {
106  myNet->getViewNet()->getUndoList()->begin(busStop, TL("add bus stop '") + id + "'");
108  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
109  myNet->getViewNet()->getUndoList()->end();
110  } else {
112  lane->addChildElement(busStop);
113  busStop->incRef("buildBusStop");
114  }
115  }
116  } else {
118  }
119 }
120 
121 
122 void
124  const std::string& laneID, const double startPos, const double endPos, const std::string& name,
125  const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
126  const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
127  // check conditions
131  // get netedit parameters
132  NeteditParameters neteditParameters(sumoBaseObject);
133  // get lane
134  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
135  // check lane
136  if (lane == nullptr) {
138  } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
140  } else if (personCapacity < 0) {
142  } else if (parkingLength < 0) {
144  } else {
145  // build trainStop
146  GNEAdditional* trainStop = GNEBusStop::buildTrainStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
147  parkingLength, color, friendlyPosition, parameters);
148  // insert depending of allowUndoRedo
149  if (myAllowUndoRedo) {
150  myNet->getViewNet()->getUndoList()->begin(trainStop, TL("add train stop '") + id + "'");
152  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(trainStop, true), true);
153  myNet->getViewNet()->getUndoList()->end();
154  } else {
156  lane->addChildElement(trainStop);
157  trainStop->incRef("buildTrainStop");
158  }
159  }
160  } else {
162  }
163 }
164 
165 
166 void
167 GNEAdditionalHandler::buildAccess(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID,
168  const std::string& pos, const double length, const bool friendlyPos, const Parameterised::Map& parameters) {
169  // get netedit parameters
170  NeteditParameters neteditParameters(sumoBaseObject);
171  // get lane
172  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
173  // get busStop (or trainStop)
174  GNEAdditional* busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_BUS_STOP);
175  if (busStop == nullptr) {
176  busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_TRAIN_STOP);
177  }
178  // pos double
179  bool validPos = true;
180  double posDouble = 0;
181  if (lane) {
182  if (GNEAttributeCarrier::canParse<double>(pos)) {
183  posDouble = GNEAttributeCarrier::parse<double>(pos);
184  validPos = checkLanePosition(posDouble, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
185  } else if (pos == "random" || pos == "doors" || pos == "carriage") {
186  posDouble = INVALID_DOUBLE;
187  } else if (pos.empty()) {
188  posDouble = 0;
189  } else {
190  validPos = false;
191  }
192  }
193  // Check if busStop parent and lane is correct
194  if (lane == nullptr) {
196  } else if (busStop == nullptr) {
198  } else if (!validPos) {
200  } else if ((length != -1) && (length < 0)) {
202  } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
203  WRITE_WARNING(TL("Could not build access in netedit; busStop parent already owns an access in the edge '") + lane->getParentEdge()->getID() + "'");
204  } else if (!lane->allowPedestrians()) {
205  WRITE_WARNING(TLF("Could not build access in netedit; The lane '%' doesn't support pedestrians", lane->getID()));
206  } else {
207  // build access
208  GNEAdditional* access = new GNEAccess(busStop, lane, myNet, posDouble, pos, friendlyPos, length, parameters);
209  // insert depending of allowUndoRedo
210  if (myAllowUndoRedo) {
211  myNet->getViewNet()->getUndoList()->begin(access, TL("add access in '") + busStop->getID() + "'");
213  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(access, true), true);
214  myNet->getViewNet()->getUndoList()->end();
215  } else {
217  lane->addChildElement(access);
218  busStop->addChildElement(access);
219  access->incRef("buildAccess");
220  }
221  }
222 }
223 
224 
225 void
226 GNEAdditionalHandler::buildContainerStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
227  const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines, const int containerCapacity,
228  const double parkingLength, const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
229  // check conditions
232  } else if (checkDuplicatedID({SUMO_TAG_CONTAINER_STOP}, id)) {
233  // get netedit parameters
234  NeteditParameters neteditParameters(sumoBaseObject);
235  // get lane
236  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
237  // check lane
238  if (lane == nullptr) {
240  } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
242  } else if (containerCapacity < 0) {
244  } else if (parkingLength < 0) {
246  } else {
247  // build containerStop
248  GNEAdditional* containerStop = new GNEContainerStop(id, lane, myNet, startPos, endPos, name, lines, containerCapacity, parkingLength,
249  color, friendlyPosition, parameters);
250  // insert depending of allowUndoRedo
251  if (myAllowUndoRedo) {
252  myNet->getViewNet()->getUndoList()->begin(containerStop, TL("add container stop '") + id + "'");
254  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
255  myNet->getViewNet()->getUndoList()->end();
256  } else {
257  myNet->getAttributeCarriers()->insertAdditional(containerStop);
258  lane->addChildElement(containerStop);
259  containerStop->incRef("buildContainerStop");
260  }
261  }
262  } else {
264  }
265 }
266 
267 
268 void
270  const std::string& laneID, const double startPos, const double endPos, const std::string& name, const double chargingPower,
271  const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string& chargeType,
272  const SUMOTime waitingTime, const bool friendlyPosition, const std::string& /* parkingAreaID */, const Parameterised::Map& parameters) {
273  // check conditions
276  } else if (checkDuplicatedID({SUMO_TAG_CHARGING_STATION}, id)) {
277  // get netedit parameters
278  NeteditParameters neteditParameters(sumoBaseObject);
279  // get lane
280  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
281  // check lane
282  if (lane == nullptr) {
284  } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
286  } else if (chargingPower < 0) {
288  } else if (chargeDelay < 0) {
290  } else {
291  // build chargingStation
292  GNEAdditional* chargingStation = new GNEChargingStation(id, lane, myNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit,
293  chargeDelay, chargeType, waitingTime, friendlyPosition, parameters);
294  // insert depending of allowUndoRedo
295  if (myAllowUndoRedo) {
296  myNet->getViewNet()->getUndoList()->begin(chargingStation, TL("add charging station '") + id + "'");
298  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
299  myNet->getViewNet()->getUndoList()->end();
300  } else {
301  myNet->getAttributeCarriers()->insertAdditional(chargingStation);
302  lane->addChildElement(chargingStation);
303  chargingStation->incRef("buildChargingStation");
304  }
305  }
306  } else {
308  }
309 
310 }
311 
312 
313 void
314 GNEAdditionalHandler::buildParkingArea(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
315  const double startPos, const double endPos, const std::string& departPos, const std::string& name,
316  const std::vector<std::string>& badges, const bool friendlyPosition, const int roadSideCapacity, const bool onRoad,
317  const double width, const double length, const double angle, const bool lefthand, const Parameterised::Map& parameters) {
318  // check conditions
321  } else if (checkDuplicatedID({SUMO_TAG_PARKING_AREA}, id)) {
322  // get netedit parameters
323  NeteditParameters neteditParameters(sumoBaseObject);
324  // get lane
325  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
326  // get departPos double
327  const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
328  // check lane
329  if (lane == nullptr) {
331  } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
333  } else if (roadSideCapacity < 0) {
335  } else if (width < 0) {
337  } else if (length < 0) {
339  } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
340  writeError(TLF("Could not build parking area with ID '%' in netedit; Invalid departPos over lane.", id));
341  } else {
342  // build parkingArea
343  GNEAdditional* parkingArea = new GNEParkingArea(id, lane, myNet, startPos, endPos, GNEAttributeCarrier::canParse<double>(departPos) ? departPos : "",
344  name, badges, friendlyPosition, roadSideCapacity, onRoad,
345  (width == 0) ? SUMO_const_laneWidth : width, length, angle, lefthand, parameters);
346  // insert depending of allowUndoRedo
347  if (myAllowUndoRedo) {
348  myNet->getViewNet()->getUndoList()->begin(parkingArea, TL("add parking area '") + id + "'");
350  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
351  myNet->getViewNet()->getUndoList()->end();
352  } else {
354  lane->addChildElement(parkingArea);
355  parkingArea->incRef("buildParkingArea");
356  }
357  }
358  } else {
360  }
361 }
362 
363 
364 void
365 GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
366  const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
367  const Parameterised::Map& parameters) {
368  // check width and heights
369  if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
370  writeError(TL("Could not build parking space in netedit; attribute width cannot be parse to float."));
371  } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
372  writeError(TL("Could not build parking space in netedit; attribute length cannot be parse to float."));
373  } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
374  writeError(TL("Could not build parking space in netedit; attribute angle cannot be parse to float."));
375  } else {
376  // get netedit parameters
377  NeteditParameters neteditParameters(sumoBaseObject);
378  // get lane
379  GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
380  // get double values
381  const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
382  const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
383  // check lane
384  if (parkingArea == nullptr) {
386  } else if (widthDouble < 0) {
388  } else if (lengthDouble < 0) {
390  } else {
391  // build parkingSpace
392  GNEAdditional* parkingSpace = new GNEParkingSpace(myNet, parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
393  // insert depending of allowUndoRedo
394  if (myAllowUndoRedo) {
395  myNet->getViewNet()->getUndoList()->begin(parkingSpace, TL("add parking space in '") + parkingArea->getID() + "'");
397  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
398  myNet->getViewNet()->getUndoList()->end();
399  } else {
400  myNet->getAttributeCarriers()->insertAdditional(parkingSpace);
401  parkingArea->addChildElement(parkingSpace);
402  parkingSpace->incRef("buildParkingSpace");
403  }
404  // update geometry (due boundaries)
405  parkingSpace->updateGeometry();
406  }
407  }
408 }
409 
410 
411 void
412 GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
413  const double position, const SUMOTime period, const std::string& file, const std::vector<std::string>& vehicleTypes,
414  const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
415  const bool friendlyPos, const Parameterised::Map& parameters) {
416  // check conditions
419  } else if (checkDuplicatedID({SUMO_TAG_INDUCTION_LOOP}, id)) {
420  // get netedit parameters
421  NeteditParameters neteditParameters(sumoBaseObject);
422  // get lane
423  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
424  // check lane
425  if (lane == nullptr) {
427  } else if (!checkLanePosition(position, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
429  } else if (period < 0) {
431  } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
433  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
435  } else {
436  // build E1
437  GNEAdditional* detectorE1 = new GNEInductionLoopDetector(id, lane, myNet, position, period, file, vehicleTypes,
438  nextEdges, detectPersons, name, friendlyPos, parameters);
439  // insert depending of allowUndoRedo
440  if (myAllowUndoRedo) {
441  myNet->getViewNet()->getUndoList()->begin(detectorE1, TL("add induction loop '") + id + "'");
443  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
444  myNet->getViewNet()->getUndoList()->end();
445  } else {
447  lane->addChildElement(detectorE1);
448  detectorE1->incRef("buildDetectorE1");
449  }
450  }
451  } else {
453  }
454 }
455 
456 
457 void
458 GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
459  const double pos, const double length, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
460  const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
461  const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
462  const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
463  // check conditions
467  // get netedit parameters
468  NeteditParameters neteditParameters(sumoBaseObject);
469  // get lane
470  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
471  // check lane
472  if (lane == nullptr) {
474  } else if (!checkLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
476  } else if (length < 0) {
478  } else if ((period != -1) && (period < 0)) {
480  } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
481  // temporal
482  writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
483  } else if (timeThreshold < 0) {
485  } else if (speedThreshold < 0) {
487  } else if (jamThreshold < 0) {
489  } else if (timeThreshold < 0) {
491  } else if (speedThreshold < 0) {
493  } else if (jamThreshold < 0) {
495  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
497  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
499  } else {
500  // build E2 single lane
501  GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, lane, myNet, pos, length, period, trafficLight, filename,
502  vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
503  speedThreshold, jamThreshold, friendlyPos, show, parameters);
504  // insert depending of allowUndoRedo
505  if (myAllowUndoRedo) {
506  myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
508  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
509  myNet->getViewNet()->getUndoList()->end();
510  } else {
512  lane->addChildElement(detectorE2);
513  detectorE2->incRef("buildDetectorE2");
514  }
515  }
516  } else {
518  }
519 }
520 
521 
522 void
523 GNEAdditionalHandler::buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::vector<std::string>& laneIDs,
524  const double pos, const double endPos, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
525  const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
526  const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
527  const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
528  // check conditions
532  // get netedit parameters
533  NeteditParameters neteditParameters(sumoBaseObject);
534  // get lanes
535  const auto lanes = parseLanes(SUMO_TAG_LANE_AREA_DETECTOR, laneIDs);
536  // check lanes
537  if (lanes.size() > 0) {
538  // calculate path
540  writeError(TLF("Could not build lane area detector with ID '%' in netedit; Lanes aren't consecutives.", id));
541  } else if (!checkMultiLanePosition(
542  pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
543  endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
545  } else if ((period != -1) && (period < 0)) {
547  } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
548  // temporal
549  writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
550  } else if (timeThreshold < 0) {
552  } else if (speedThreshold < 0) {
554  } else if (jamThreshold < 0) {
556  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
558  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
560  } else {
561  // build E2 multilane detector
562  GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, lanes, myNet, pos, endPos, period, trafficLight, filename,
563  vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
564  speedThreshold, jamThreshold, friendlyPos, show, parameters);
565  // insert depending of allowUndoRedo
566  if (myAllowUndoRedo) {
567  myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
569  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
570  myNet->getViewNet()->getUndoList()->end();
571  } else {
573  for (const auto& lane : lanes) {
574  lane->addChildElement(detectorE2);
575  }
576  detectorE2->incRef("buildDetectorE2Multilane");
577  }
578  }
579  } else {
581  }
582  } else {
584  }
585 }
586 
587 
588 void
589 GNEAdditionalHandler::buildDetectorE3(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos, const SUMOTime period,
590  const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
591  const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold, const double speedThreshold,
592  const bool openEntry, const bool expectedArrival, const Parameterised::Map& parameters) {
593  // check conditions
596  } else if (period < 0) {
598  } else if (timeThreshold < 0) {
600  } else if (speedThreshold < 0) {
602  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
604  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
607  // get netedit parameters
608  NeteditParameters neteditParameters(sumoBaseObject);
609  // build E3
610  GNEAdditional* E3 = new GNEMultiEntryExitDetector(id, myNet, pos, period, filename, vehicleTypes, nextEdges, detectPersons,
611  name, timeThreshold, speedThreshold, openEntry, expectedArrival, parameters);
612  // insert depending of allowUndoRedo
613  if (myAllowUndoRedo) {
614  myNet->getViewNet()->getUndoList()->begin(E3, TL("add entry-exit detector '") + id + "'");
616  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
617  myNet->getViewNet()->getUndoList()->end();
618  } else {
620  E3->incRef("buildDetectorE3");
621  }
622  } else {
624  }
625 }
626 
627 
628 void
629 GNEAdditionalHandler::buildDetectorEntry(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
630  const bool friendlyPos, const Parameterised::Map& parameters) {
631  // get lane
632  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
633  // get E3 parent
635  // Check if Detector E3 parent and lane is correct
636  if (lane == nullptr) {
638  } else if (E3 == nullptr) {
640  } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
642  } else {
643  // get netedit parameters
644  NeteditParameters neteditParameters(sumoBaseObject);
645  // build entry instant
646  GNEAdditional* entry = new GNEEntryExitDetector(SUMO_TAG_DET_ENTRY, myNet, E3, lane, pos, friendlyPos, parameters);
647  // insert depending of allowUndoRedo
648  if (myAllowUndoRedo) {
649  myNet->getViewNet()->getUndoList()->begin(entry, TL("add entry detector in '") + E3->getID() + "'");
651  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
652  myNet->getViewNet()->getUndoList()->end();
653  } else {
655  lane->addChildElement(entry);
656  E3->addChildElement(entry);
657  entry->incRef("buildDetectorEntry");
658  }
659  }
660 }
661 
662 
663 void
664 GNEAdditionalHandler::buildDetectorExit(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
665  const bool friendlyPos, const Parameterised::Map& parameters) {
666  // get lane
667  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
668  // get E3 parent
670  // Check if Detector E3 parent and lane is correct
671  if (lane == nullptr) {
673  } else if (E3 == nullptr) {
675  } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
677  } else {
678  // get netedit parameters
679  NeteditParameters neteditParameters(sumoBaseObject);
680  // build exit instant
681  GNEAdditional* exit = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet, E3, lane, pos, friendlyPos, parameters);
682  // insert depending of allowUndoRedo
683  if (myAllowUndoRedo) {
684  myNet->getViewNet()->getUndoList()->begin(exit, TL("add exit detector in '") + E3->getID() + "'");
686  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
687  myNet->getViewNet()->getUndoList()->end();
688  } else {
690  lane->addChildElement(exit);
691  E3->addChildElement(exit);
692  exit->incRef("buildDetectorExit");
693  }
694  }
695 }
696 
697 
698 void
699 GNEAdditionalHandler::buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, double pos,
700  const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
701  const std::string& detectPersons, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters) {
702  // check conditions
706  // get netedit parameters
707  NeteditParameters neteditParameters(sumoBaseObject);
708  // get lane
709  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
710  // check lane
711  if (lane == nullptr) {
713  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
715  } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
717  } else {
718  // build E1 instant
719  GNEAdditional* detectorE1Instant = new GNEInstantInductionLoopDetector(id, lane, myNet, pos, filename, vehicleTypes, nextEdges,
720  detectPersons, name, friendlyPos, parameters);
721  // insert depending of allowUndoRedo
722  if (myAllowUndoRedo) {
723  myNet->getViewNet()->getUndoList()->begin(detectorE1Instant, TL("add instant induction loop '") + id + "'");
725  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
726  myNet->getViewNet()->getUndoList()->end();
727  } else {
728  myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
729  lane->addChildElement(detectorE1Instant);
730  detectorE1Instant->incRef("buildDetectorE1Instant");
731  }
732  }
733  } else {
735  }
736 }
737 
738 
739 void
740 GNEAdditionalHandler::buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, const double pos,
741  const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
742  const Parameterised::Map& parameters) {
743  // get lane
744  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
745  // get routeProbe
746  GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
747  // check conditions
752  } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
754  } else if (lane == nullptr) {
756  } else {
757  // get netedit parameters
758  NeteditParameters neteditParameters(sumoBaseObject);
759  // check lane
760  if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
762  } else if (period < 0) {
764  } else if (jamThreshold < 0) {
766  } else {
767  // build Calibrator
768  GNEAdditional* calibrator = (routeProbe == nullptr) ?
769  new GNECalibrator(id, myNet, lane, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
770  new GNECalibrator(id, myNet, lane, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
771  // insert depending of allowUndoRedo
772  if (myAllowUndoRedo) {
773  myNet->getViewNet()->getUndoList()->begin(calibrator, TL("add lane calibrator '") + id + "'");
775  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
776  myNet->getViewNet()->getUndoList()->end();
777  // center after creation
778  if (neteditParameters.centerAfterCreation) {
779  myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
780  }
781  } else {
783  lane->addChildElement(calibrator);
784  if (routeProbe) {
785  routeProbe->addChildElement(calibrator);
786  }
787  calibrator->incRef("buildCalibrator");
788  }
789  }
790  }
791 }
792 
793 
794 void
795 GNEAdditionalHandler::buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const double pos,
796  const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
797  const Parameterised::Map& parameters) {
798  // get edge
799  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
800  // get routeProbe
801  GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
802  // check conditions
807  } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
809  } else if (edge == nullptr) {
811  } else {
812  // get netedit parameters
813  NeteditParameters neteditParameters(sumoBaseObject);
814  if (!checkLanePosition(pos, 0, edge->getLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
816  } else if (period < 0) {
818  } else if (jamThreshold < 0) {
820  } else {
821  // build Calibrator
822  GNEAdditional* calibrator = (routeProbe == nullptr) ?
823  new GNECalibrator(id, myNet, edge, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
824  new GNECalibrator(id, myNet, edge, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
825  // insert depending of allowUndoRedo
826  if (myAllowUndoRedo) {
827  myNet->getViewNet()->getUndoList()->begin(calibrator, TL("add calibrator '") + id + "'");
829  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
830  myNet->getViewNet()->getUndoList()->end();
831  // center after creation
832  if (neteditParameters.centerAfterCreation) {
833  myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
834  }
835  } else {
837  edge->addChildElement(calibrator);
838  if (routeProbe) {
839  routeProbe->addChildElement(calibrator);
840  }
841  calibrator->incRef("buildCalibrator");
842  }
843  }
844  }
845 }
846 
847 
848 void
850  // get vType
851  GNEDemandElement* vType = myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, vehicleParameter.vtypeid.empty() ? DEFAULT_VTYPE_ID : vehicleParameter.vtypeid, false);
852  // get route
854  // get calibrator parent
856  // check parents
857  if (vType == nullptr) {
859  } else if (route == nullptr) {
861  } else if (calibrator == nullptr) {
863  } else {
864  // create calibrator flow
865  GNEAdditional* flow = new GNECalibratorFlow(calibrator, vType, route, vehicleParameter);
866  // insert depending of allowUndoRedo
867  if (myAllowUndoRedo) {
868  myNet->getViewNet()->getUndoList()->begin(flow, TL("add calibrator flow in '") + calibrator->getID() + "'");
870  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
871  myNet->getViewNet()->getUndoList()->end();
872  } else {
873  calibrator->addChildElement(flow);
874  route->addChildElement(flow);
875  vType->addChildElement(flow);
876  flow->incRef("buildCalibratorFlow");
877  }
878  }
879 }
880 
881 
882 void
883 GNEAdditionalHandler::buildRerouter(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
884  const std::vector<std::string>& edgeIDs, const double prob, const std::string& name,
885  const bool off, const bool optional, const SUMOTime timeThreshold,
886  const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
887  // check conditions
890  } else if (prob < 0) {
892  } else if (timeThreshold < 0) {
894  } else if (!vTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vTypes)) {
896  } else if (checkDuplicatedID({SUMO_TAG_REROUTER}, id)) {
897  // get netedit parameters
898  NeteditParameters neteditParameters(sumoBaseObject);
899  // parse edges
900  std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, edgeIDs);
901  // check edges
902  if (edges.size() > 0) {
903  GNEAdditional* rerouter = nullptr;
904  // continue depending of position
905  if (pos == Position::INVALID) {
906  if (edges.size() > 0) {
907  PositionVector laneShape = edges.front()->getLanes().front()->getLaneShape();
908  // move to side
909  laneShape.move2side(3);
910  // create rerouter
911  rerouter = new GNERerouter(id, myNet, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, prob, off, optional, timeThreshold, vTypes, parameters);
912  } else {
913  rerouter = new GNERerouter(id, myNet, Position(0, 0), name, prob, off, optional, timeThreshold, vTypes, parameters);
914  }
915  } else {
916  rerouter = new GNERerouter(id, myNet, pos, name, prob, off, optional, timeThreshold, vTypes, parameters);
917  }
918  // create rerouter Symbols
919  std::vector<GNEAdditional*> rerouterSymbols;
920  for (const auto& edge : edges) {
921  rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
922  }
923  // insert depending of allowUndoRedo
924  if (myAllowUndoRedo) {
925  myNet->getViewNet()->getUndoList()->begin(rerouter, TL("add rerouter '") + id + "'");
927  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
928  // add symbols
929  for (const auto& rerouterSymbol : rerouterSymbols) {
930  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
931  }
932  myNet->getViewNet()->getUndoList()->end();
933  } else {
935  rerouter->incRef("buildRerouter");
936  // add symbols into rerouter
937  for (const auto& rerouterSymbol : rerouterSymbols) {
938  rerouter->addChildElement(rerouterSymbol);
939  }
940  // add symbols into edges
941  for (int i = 0; i < (int)edges.size(); i++) {
942  edges.at(i)->addChildElement(rerouterSymbols.at(i));
943  }
944  }
945  }
946  } else {
948  }
949 }
950 
951 
952 void
954  // get rerouter parent
955  GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
956  // check if rerouter exist
957  if (rerouter == nullptr) {
959  } else if (begin < 0) {
961  } else if (end < 0) {
963  } else if (end < begin) {
964  writeError(TLF("Could not build interval with ID '%' in netedit; begin is greater than end.", rerouter->getID()));
965  } else {
966  // check if new interval will produce a overlapping
967  if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
968  // create rerouter interval and add it into rerouter parent
969  GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
970  // insert depending of allowUndoRedo
971  if (myAllowUndoRedo) {
972  myNet->getViewNet()->getUndoList()->begin(rerouterInterval, TL("add rerouter interval in '") + rerouter->getID() + "'");
974  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
975  myNet->getViewNet()->getUndoList()->end();
976  } else {
977  rerouter->addChildElement(rerouterInterval);
978  rerouterInterval->incRef("buildRerouterInterval");
979  }
980  } else {
981  writeError(TLF("Could not build interval with begin '%' and end '%' in '%' due overlapping.", toString(begin), toString(end), rerouter->getID()));
982  }
983  }
984 }
985 
986 
987 void
988 GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
989  // get rerouter interval parent
990  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
991  // get closed lane
992  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
993  // check parents
994  if (lane == nullptr) {
996  } else if (rerouterInterval == nullptr) {
998  } else {
999  // create closing lane reroute
1000  GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
1001  // add it to interval parent depending of allowUndoRedo
1002  if (myAllowUndoRedo) {
1003  myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing lane reroute in '") + lane->getID() + "'");
1005  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1006  myNet->getViewNet()->getUndoList()->end();
1007  } else {
1008  rerouterInterval->addChildElement(closingLaneReroute);
1009  closingLaneReroute->incRef("buildClosingLaneReroute");
1010  }
1011  }
1012 }
1013 
1014 
1015 void
1016 GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
1017  // get rerouter interval parent
1018  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1019  // get closed edge
1020  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
1021  // check parents
1022  if (edge == nullptr) {
1024  } else if (rerouterInterval == nullptr) {
1026  } else {
1027  // create closing reroute
1028  GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
1029  // add it to interval parent depending of allowUndoRedo
1030  if (myAllowUndoRedo) {
1031  myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing reroute in '") + edge->getID() + "'");
1033  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1034  myNet->getViewNet()->getUndoList()->end();
1035  } else {
1036  rerouterInterval->addChildElement(closingLaneReroute);
1037  closingLaneReroute->incRef("buildClosingLaneReroute");
1038  }
1039  }
1040 }
1041 
1042 void
1043 GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1044  // get rerouter interval parent
1045  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1046  // get edge
1047  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1048  // check parents
1049  if (edge == nullptr) {
1051  } else if (rerouterInterval == nullptr) {
1053  } else {
1054  // create dest probability reroute
1055  GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1056  // add it to interval parent depending of allowUndoRedo
1057  if (myAllowUndoRedo) {
1058  myNet->getViewNet()->getUndoList()->begin(destProbReroute, TL("add dest prob reroute in '") + edge->getID() + "'");
1060  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1061  myNet->getViewNet()->getUndoList()->end();
1062  } else {
1063  rerouterInterval->addChildElement(destProbReroute);
1064  destProbReroute->incRef("builDestProbReroute");
1065  }
1066  }
1067 }
1068 
1069 
1070 void
1071 GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1072  // get rerouter interval parent
1073  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1074  // get parking area
1075  GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1076  // check parents
1077  if (parkingArea == nullptr) {
1079  } else if (rerouterInterval == nullptr) {
1081  } else {
1082  // create parking area reroute
1083  GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1084  // add it to interval parent depending of allowUndoRedo
1085  if (myAllowUndoRedo) {
1086  myNet->getViewNet()->getUndoList()->begin(parkingAreaReroute, TL("add parking area reroute in '") + parkingArea->getID() + "'");
1088  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1089  myNet->getViewNet()->getUndoList()->end();
1090  } else {
1091  rerouterInterval->addChildElement(parkingAreaReroute);
1092  parkingAreaReroute->incRef("builParkingAreaReroute");
1093  }
1094  }
1095 }
1096 
1097 
1098 void
1099 GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1100  // get rerouter interval parent
1101  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1102  // get route parent
1104  // check parents
1105  if (route == nullptr) {
1107  } else if (rerouterInterval == nullptr) {
1109  } else {
1110  // create rout prob reroute
1111  GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1112  // add it to interval parent depending of allowUndoRedo
1113  if (myAllowUndoRedo) {
1114  myNet->getViewNet()->getUndoList()->begin(routeProbReroute, TL("add route prob reroute in '") + route->getID() + "'");
1116  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1117  myNet->getViewNet()->getUndoList()->end();
1118  } else {
1119  rerouterInterval->addChildElement(routeProbReroute);
1120  routeProbReroute->incRef("buildRouteProbReroute");
1121  }
1122  }
1123 }
1124 
1125 
1126 void
1127 GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime period,
1128  const std::string& name, const std::string& file, const SUMOTime begin, const Parameterised::Map& parameters) {
1129  // check conditions
1132  } else if (checkDuplicatedID({SUMO_TAG_ROUTEPROBE}, id)) {
1133  // get netedit parameters
1134  NeteditParameters neteditParameters(sumoBaseObject);
1135  // get edge
1136  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1137  // check lane
1138  if (edge == nullptr) {
1140  } else if (period < 0) {
1142  } else if (begin < 0) {
1144  } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
1146  } else {
1147  // build route probe
1148  GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, edge, period, name, file, begin, parameters);
1149  // insert depending of allowUndoRedo
1150  if (myAllowUndoRedo) {
1151  myNet->getViewNet()->getUndoList()->begin(routeProbe, TL("add route probe '") + id + "'");
1153  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1154  myNet->getViewNet()->getUndoList()->end();
1155  // center after creation
1156  if (neteditParameters.centerAfterCreation) {
1157  myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1158  }
1159  } else {
1161  edge->addChildElement(routeProbe);
1162  routeProbe->incRef("buildRouteProbe");
1163  }
1164  }
1165  } else {
1167  }
1168 }
1169 
1170 
1171 void
1172 GNEAdditionalHandler::buildVariableSpeedSign(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
1173  const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
1177  } else if (checkDuplicatedID({SUMO_TAG_VSS}, id)) {
1178  // get netedit parameters
1179  NeteditParameters neteditParameters(sumoBaseObject);
1180  // parse lanes
1181  std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, laneIDs);
1182  // check lane
1183  if (lanes.size() > 0) {
1184  // check vTypes
1185  if (!vTypes.empty() && !checkListOfVehicleTypes(vTypes)) {
1187  } else {
1188  // create VSS
1189  GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, pos, name, vTypes, parameters);
1190  // create VSS Symbols
1191  std::vector<GNEAdditional*> VSSSymbols;
1192  for (const auto& lane : lanes) {
1193  VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1194  }
1195  // insert depending of allowUndoRedo
1196  if (myAllowUndoRedo) {
1197  myNet->getViewNet()->getUndoList()->begin(variableSpeedSign, TL("add Variable Speed Sign '") + id + "'");
1199  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1200  for (const auto& VSSSymbol : VSSSymbols) {
1201  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1202  }
1203  myNet->getViewNet()->getUndoList()->end();
1204  } else {
1205  myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1206  variableSpeedSign->incRef("buildVariableSpeedSign");
1207  // add symbols into VSS
1208  for (const auto& VSSSymbol : VSSSymbols) {
1209  variableSpeedSign->addChildElement(VSSSymbol);
1210  }
1211  // add symbols into lanes
1212  for (int i = 0; i < (int)lanes.size(); i++) {
1213  lanes.at(i)->addChildElement(VSSSymbols.at(i));
1214  }
1215  }
1216  }
1217  }
1218  } else {
1220  }
1221 }
1222 
1223 
1224 void
1225 GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1226  // get VSS parent
1227  GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1228  // check lane
1229  if (VSS == nullptr) {
1231  } else if (time < 0) {
1233  } else {
1234  // create Variable Speed Sign
1235  GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1236  // add it depending of allow undoRedo
1237  if (myAllowUndoRedo) {
1238  myNet->getViewNet()->getUndoList()->begin(variableSpeedSignStep, TL("add VSS Step in '") + VSS->getID() + "'");
1240  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1241  myNet->getViewNet()->getUndoList()->end();
1242  } else {
1243  VSS->addChildElement(variableSpeedSignStep);
1244  variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1245  }
1246  }
1247 }
1248 
1249 
1250 void
1251 GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1252  const SUMOTime endTime, const std::string& name, const Parameterised::Map& parameters) {
1253  // check conditions
1256  } else if (checkDuplicatedID({SUMO_TAG_VAPORIZER}, edgeID)) {
1257  // get netedit parameters
1258  NeteditParameters neteditParameters(sumoBaseObject);
1259  // get edge
1260  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1261  // check lane
1262  if (edge == nullptr) {
1264  } else if (beginTime < 0) {
1266  } else if (endTime < 0) {
1268  } else if (endTime < beginTime) {
1269  writeError(TLF("Could not build Vaporizer with ID '%' in netedit; begin is greater than end.", edge->getID()));
1270  } else {
1271  // build vaporizer
1272  GNEAdditional* vaporizer = new GNEVaporizer(myNet, edge, beginTime, endTime, name, parameters);
1273  // add it depending of allow undoRed
1274  if (myAllowUndoRedo) {
1275  myNet->getViewNet()->getUndoList()->begin(vaporizer, TL("add vaporizer in '") + edge->getID() + "'");
1277  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1278  myNet->getViewNet()->getUndoList()->end();
1279  // center after creation
1280  if (neteditParameters.centerAfterCreation) {
1281  myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1282  }
1283  } else {
1285  edge->addChildElement(vaporizer);
1286  vaporizer->incRef("buildVaporizer");
1287  }
1288  }
1289  } else {
1291  }
1292 }
1293 
1294 
1295 void
1296 GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1297  const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1298  const std::string& name, const Parameterised::Map& parameters) {
1299  // parse edges
1300  const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, edgeIDs);
1301  // check TAZShape
1302  PositionVector TAZShape = shape;
1303  if (TAZShape.size() == 0) {
1304  // declare boundary
1305  Boundary TAZBoundary;
1306  for (const auto& edge : edges) {
1307  TAZBoundary.add(edge->getCenteringBoundary());
1308  }
1309  // iterate over children and add sourceSinkEdge boundaries to make a taz shape
1310  for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1311  // check that childre is a source or sink elements (to avoid parameters)
1312  if ((sourceSink->getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTag() == SUMO_TAG_TAZSINK)) {
1313  const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1314  if (sourceSinkEdge) {
1315  TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1316  }
1317  }
1318  }
1319  // update TAZShape
1320  TAZShape = TAZBoundary.getShape(true);
1321  }
1322  // check TAZ
1325  } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1327  } else if (TAZShape.size() == 0) {
1328  writeError(TLF("Could not build TAZ with ID '%' in netedit; Invalid Shape.", id));
1329  } else {
1330  // get netedit parameters
1331  NeteditParameters neteditParameters(sumoBaseObject);
1332  // build TAZ with the given shape
1333  const Position center2 = center == Position::INVALID ? TAZShape.getCentroid() : center;
1334  GNEAdditional* TAZ = new GNETAZ(id, myNet, TAZShape, center2, fill, color, name, parameters);
1335  // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1337  // add it depending of allow undoRed
1338  if (myAllowUndoRedo) {
1339  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ '") + id + "'");
1341  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
1342  // create TAZEdges
1343  for (const auto& edge : edges) {
1344  // create TAZ Source using GNEChange_Additional
1345  GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1346  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1347  // create TAZ Sink using GNEChange_Additional
1348  GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1349  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1350  }
1351  myNet->getViewNet()->getUndoList()->end();
1352  } else {
1354  TAZ->incRef("buildTAZ");
1355  for (const auto& edge : edges) {
1356  // create TAZ Source
1357  GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1358  TAZSource->incRef("buildTAZ");
1359  TAZ->addChildElement(TAZSource);
1360  // create TAZ Sink
1361  GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1362  TAZSink->incRef("buildTAZ");
1363  TAZ->addChildElement(TAZSink);
1364  }
1365  }
1366  // enable updating geometry again and update geometry of TAZ
1368  // update TAZ parent
1369  TAZ->updateGeometry();
1370  }
1371 }
1372 
1373 
1374 void
1375 GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1376  // get TAZ parent
1377  GNEAdditional* TAZ = getAdditionalParent(sumoBaseObject, SUMO_TAG_TAZ);
1378  // get edge
1379  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1380  // declare TAZ Sink
1381  GNEAdditional* TAZSink = nullptr;
1382  // check parents
1383  if (TAZ == nullptr) {
1385  } else if (edge == nullptr) {
1387  } else {
1388  // first check if a TAZSink in the same edge for the same TAZ
1389  for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1390  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1391  TAZSink = TAZElement;
1392  }
1393  }
1394  // check if TAZSink has to be created
1395  if (TAZSink == nullptr) {
1396  // Create TAZ with weight 0 (default)
1397  TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 0);
1398  // add it depending of allow undoRed
1399  if (myAllowUndoRedo) {
1400  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1402  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1403  myNet->getViewNet()->getUndoList()->end();
1404  } else {
1406  TAZ->addChildElement(TAZSink);
1407  TAZSink->incRef("buildTAZSource");
1408  }
1409  }
1410  // now check check if TAZSource exist
1411  GNEAdditional* TAZSource = nullptr;
1412  // first check if a TAZSink in the same edge for the same TAZ
1413  for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1414  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1415  TAZSource = TAZElement;
1416  }
1417  }
1418  // check if TAZSource has to be created
1419  if (TAZSource == nullptr) {
1420  // Create TAZ only with departWeight
1421  TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1422  // add it depending of allow undoRed
1423  if (myAllowUndoRedo) {
1424  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1426  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1427  myNet->getViewNet()->getUndoList()->end();
1428  } else {
1430  TAZ->addChildElement(TAZSource);
1431  TAZSource->incRef("buildTAZSource");
1432  }
1433  } else {
1434  // update TAZ Attribute depending of allow undoRed
1435  if (myAllowUndoRedo) {
1436  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Source in '") + TAZ->getID() + "'");
1437  TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1438  myNet->getViewNet()->getUndoList()->end();
1439  } else {
1440  TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1441  }
1442  }
1443  }
1444 }
1445 
1446 
1447 void
1448 GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1449  // get TAZ parent
1450  GNEAdditional* TAZ = getAdditionalParent(sumoBaseObject, SUMO_TAG_TAZ);
1451  // get edge
1452  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1453  // check parents
1454  if (TAZ == nullptr) {
1456  } else if (edge == nullptr) {
1458  } else {
1459  // declare TAZ source
1460  GNEAdditional* TAZSource = nullptr;
1461  // first check if a TAZSink in the same edge for the same TAZ
1462  for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1463  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1464  TAZSource = TAZElement;
1465  }
1466  }
1467  // check if TAZSource has to be created
1468  if (TAZSource == nullptr) {
1469  // Create TAZ with empty value
1470  TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 0);
1471  // add it depending of allow undoRed
1472  if (myAllowUndoRedo) {
1473  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1475  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1476  myNet->getViewNet()->getUndoList()->end();
1477  } else {
1479  TAZ->addChildElement(TAZSource);
1480  TAZSource->incRef("buildTAZSink");
1481  }
1482  }
1483  GNEAdditional* TAZSink = nullptr;
1484  // first check if a TAZSink in the same edge for the same TAZ
1485  for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1486  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1487  TAZSink = TAZElement;
1488  }
1489  }
1490  // check if TAZSink has to be created
1491  if (TAZSink == nullptr) {
1492  // Create TAZ only with arrivalWeight
1493  TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1494  // add it depending of allow undoRed
1495  if (myAllowUndoRedo) {
1496  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1498  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1499  myNet->getViewNet()->getUndoList()->end();
1500  } else {
1502  TAZ->addChildElement(TAZSink);
1503  TAZSink->incRef("buildTAZSink");
1504  }
1505  } else {
1506  // update TAZ Attribute depending of allow undoRed
1507  if (myAllowUndoRedo) {
1508  myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Sink in '") + TAZ->getID() + "'");
1509  TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1510  myNet->getViewNet()->getUndoList()->end();
1511  } else {
1512  TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1513  }
1514  }
1515  }
1516 }
1517 
1518 
1519 void
1520 GNEAdditionalHandler::buildTractionSubstation(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
1521  const double voltage, const double currentLimit, const Parameterised::Map& parameters) {
1522  // check conditions
1525  } else if (voltage < 0) {
1527  } else if (currentLimit < 0) {
1529  } else if (checkDuplicatedID({SUMO_TAG_TRACTION_SUBSTATION}, id)) {
1530  // get netedit parameters
1531  NeteditParameters neteditParameters(sumoBaseObject);
1532  // build traction substation
1533  GNEAdditional* tractionSubstation = new GNETractionSubstation(id, myNet, pos, voltage, currentLimit, parameters);
1534  // insert depending of allowUndoRedo
1535  if (myAllowUndoRedo) {
1536  myNet->getViewNet()->getUndoList()->begin(tractionSubstation, TL("add traction substation '") + id + "'");
1538  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(tractionSubstation, true), true);
1539  myNet->getViewNet()->getUndoList()->end();
1540  } else {
1541  myNet->getAttributeCarriers()->insertAdditional(tractionSubstation);
1542  tractionSubstation->incRef("buildTractionSubstation");
1543  }
1544  } else {
1546  }
1547 }
1548 
1549 
1550 void
1551 GNEAdditionalHandler::buildOverheadWire(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& substationId,
1552  const std::vector<std::string>& laneIDs, const double startPos, const double endPos, const bool friendlyPos,
1553  const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters) {
1554  // check conditions
1558  // get netedit parameters
1559  NeteditParameters neteditParameters(sumoBaseObject);
1560  // get lanes
1561  const auto lanes = parseLanes(SUMO_TAG_OVERHEAD_WIRE_SECTION, laneIDs);
1562  // get traction substation
1563  const auto tractionSubstation = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, substationId, false);
1564  // check lanes
1565  if (lanes.size() > 0) {
1566  // calculate path
1567  if (!GNEAdditional::areLaneConsecutives(lanes)) {
1568  writeError(TLF("Could not build overhead wire with ID '%' in netedit; Lanes aren't consecutives.", id));
1569  } else if (!checkMultiLanePosition(
1570  startPos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
1571  endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1573  } else if (tractionSubstation == nullptr) {
1575  } else {
1576  // build Overhead Wire
1577  GNEAdditional* overheadWire = new GNEOverheadWire(id, lanes, tractionSubstation, myNet, startPos, endPos, friendlyPos, forbiddenInnerLanes, parameters);
1578  // insert depending of allowUndoRedo
1579  if (myAllowUndoRedo) {
1580  myNet->getViewNet()->getUndoList()->begin(overheadWire, TL("add overhead wire '") + id + "'");
1582  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(overheadWire, true), true);
1583  myNet->getViewNet()->getUndoList()->end();
1584  } else {
1585  myNet->getAttributeCarriers()->insertAdditional(overheadWire);
1586  for (const auto& lane : lanes) {
1587  lane->addChildElement(overheadWire);
1588  }
1589  overheadWire->incRef("buildOverheadWire");
1590  }
1591  }
1592  } else {
1594  }
1595  } else {
1597  }
1598 }
1599 
1600 
1601 void
1602 GNEAdditionalHandler::buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject* /* sumoBaseObject */, const std::string& /* id */, const std::string& /* overheadWireIDStartClamp */,
1603  const std::string& /* laneIDStartClamp */, const std::string& /* overheadWireIDEndClamp */, const std::string& /* laneIDEndClamp */,
1604  const Parameterised::Map& /* parameters */) {
1605  //
1606 }
1607 
1608 
1609 void
1610 GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1611  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill,
1612  double lineWidth, const std::string& name, const Parameterised::Map& parameters) {
1613  // check conditions
1614  if (type == "jupedsim.walkable_area") {
1615  buildJpsWalkableArea(sumoBaseObject, id, shape, geo, name, parameters);
1616  } else if (type == "jupedsim.obstacle") {
1617  buildJpsObstacle(sumoBaseObject, id, shape, geo, name, parameters);
1618  } else if (!SUMOXMLDefinitions::isValidAdditionalID(id)) {
1620  } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1622  } else if (lineWidth < 0) {
1624  } else {
1625  // get netedit parameters
1626  NeteditParameters neteditParameters(sumoBaseObject);
1627  // create poly
1628  GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, name, parameters);
1629  // add it depending of allow undoRed
1630  if (myAllowUndoRedo) {
1631  myNet->getViewNet()->getUndoList()->begin(poly, TL("add polygon '") + id + "'");
1633  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(poly, true), true);
1634  myNet->getViewNet()->getUndoList()->end();
1635  } else {
1636  // insert shape without allowing undo/redo
1638  poly->incRef("addPolygon");
1639  }
1640  }
1641 }
1642 
1643 
1644 void
1645 GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1646  const RGBColor& color, const double x, const double y, const std::string& icon, double layer, double angle,
1647  const std::string& imgFile, bool relativePath, double width, double height, const std::string& name,
1648  const Parameterised::Map& parameters) {
1649  // check conditions
1652  } else if (width < 0) {
1654  } else if (height < 0) {
1656  } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1658  } else if (checkDuplicatedID(NamespaceIDs::POIs, id)) {
1659  // get netedit parameters
1660  NeteditParameters neteditParameters(sumoBaseObject);
1661  // create POI
1662  GNEPOI* POI = new GNEPOI(myNet, id, type, color, x, y, false, icon, layer, angle, imgFile, relativePath, width, height, name, parameters);
1663  // add it depending of allow undoRed
1664  if (myAllowUndoRedo) {
1665  myNet->getViewNet()->getUndoList()->begin(POI, TL("add POI '") + id + "'");
1667  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POI, true), true);
1668  myNet->getViewNet()->getUndoList()->end();
1669  } else {
1670  // insert shape without allowing undo/redo
1672  POI->incRef("addPOI");
1673  }
1674  } else {
1676  }
1677 }
1678 
1679 
1680 void
1681 GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1682  const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat,
1683  const std::string& icon, double layer, double angle, const std::string& imgFile, bool relativePath, double width,
1684  double height, const std::string& name, const Parameterised::Map& parameters) {
1685  // check conditions
1688  } else if (width < 0) {
1690  } else if (height < 0) {
1692  } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1694  } else if (checkDuplicatedID(NamespaceIDs::POIs, id)) {
1695  // get netedit parameters
1696  NeteditParameters neteditParameters(sumoBaseObject);
1697  // get lane
1698  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1699  // check lane
1700  if (lane == nullptr) {
1702  } else if (!checkLanePosition(posOverLane, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1704  } else {
1705  // create POI (use GNEAdditional instead GNEPOI for add child references)
1706  GNEAdditional* POILane = new GNEPOI(myNet, id, type, color, lane, posOverLane, friendlyPos, posLat, icon, layer,
1707  angle, imgFile, relativePath, width, height, name, parameters);
1708  // add it depending of allow undoRed
1709  if (myAllowUndoRedo) {
1710  myNet->getViewNet()->getUndoList()->begin(POILane, TL("add POI '") + id + "'");
1712  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POILane, true), true);
1713  myNet->getViewNet()->getUndoList()->end();
1714  } else {
1715  // insert shape without allowing undo/redo
1717  lane->addChildElement(POILane);
1718  POILane->incRef("buildPOILane");
1719  }
1720  }
1721  } else {
1723  }
1724 }
1725 
1726 
1727 void
1728 GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1729  const RGBColor& color, const double lon, const double lat, const std::string& icon, double layer,
1730  double angle, const std::string& imgFile, bool relativePath, double width, double height,
1731  const std::string& name, const Parameterised::Map& parameters) {
1732  // check conditions
1735  } else if (width < 0) {
1737  } else if (height < 0) {
1739  } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1741  } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1742  writeError(TLF("Could not build POI with ID '%' in netedit", id) + std::string("; ") + TL("Network requires a geo projection."));
1743  } else if (checkDuplicatedID(NamespaceIDs::POIs, id)) {
1744  // get netedit parameters
1745  NeteditParameters neteditParameters(sumoBaseObject);
1746  // create POIGEO
1747  GNEPOI* POIGEO = new GNEPOI(myNet, id, type, color, lon, lat, true, icon, layer, angle, imgFile, relativePath, width, height, name, parameters);
1748  // add it depending of allow undoRed
1749  if (myAllowUndoRedo) {
1750  myNet->getViewNet()->getUndoList()->begin(POIGEO, TL("add POI '") + id + "'");
1752  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POIGEO, true), true);
1753  myNet->getViewNet()->getUndoList()->end();
1754  } else {
1755  // insert shape without allowing undo/redo
1757  POIGEO->incRef("buildPOIGeo");
1758  }
1759  } else {
1761  }
1762 }
1763 
1764 
1765 void
1766 GNEAdditionalHandler::buildJpsWalkableArea(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1767  bool geo, const std::string& name, const Parameterised::Map& parameters) {
1768  // check conditions
1771  } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1773  } else {
1774  // get netedit parameters
1775  NeteditParameters neteditParameters(sumoBaseObject);
1776  // create walkable area
1777  GNEPoly* walkableArea = new GNEPoly(GNE_TAG_JPS_WALKABLEAREA, myNet, id, shape, geo, name, parameters);
1778  // add it depending of allow undoRed
1779  if (myAllowUndoRedo) {
1780  myNet->getViewNet()->getUndoList()->begin(walkableArea, TL("add jps walkable area '") + id + "'");
1782  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(walkableArea, true), true);
1783  myNet->getViewNet()->getUndoList()->end();
1784  } else {
1785  // insert shape without allowing undo/redo
1786  myNet->getAttributeCarriers()->insertAdditional(walkableArea);
1787  walkableArea->incRef("addWalkableArea");
1788  }
1789  }
1790 }
1791 
1792 
1793 void
1794 GNEAdditionalHandler::buildJpsObstacle(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1795  bool geo, const std::string& name, const Parameterised::Map& parameters) {
1796  // check conditions
1799  } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1801  } else {
1802  // get netedit parameters
1803  NeteditParameters neteditParameters(sumoBaseObject);
1804  // create walkable area
1805  GNEPoly* obstacle = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet, id, shape, geo, name, parameters);
1806  // add it depending of allow undoRed
1807  if (myAllowUndoRedo) {
1808  myNet->getViewNet()->getUndoList()->begin(obstacle, TL("add jps obstacle '") + id + "'");
1810  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(obstacle, true), true);
1811  myNet->getViewNet()->getUndoList()->end();
1812  } else {
1813  // insert shape without allowing undo/redo
1815  obstacle->incRef("addObstacle");
1816  }
1817  }
1818 }
1819 
1820 
1821 bool
1823  // check if exist another access for the same busStop in the given edge
1824  for (const auto& additional : busStopParent->getChildAdditionals()) {
1825  for (const auto& lane : edge->getLanes()) {
1826  if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1827  return false;
1828  }
1829  }
1830  }
1831  return true;
1832 }
1833 
1834 
1835 bool
1837  // declare a vector to keep sorted rerouter children
1838  std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1839  // iterate over child additional
1840  for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1841  if (!rerouterChild->getTagProperty().isSymbol()) {
1842  sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1843  // set begin and end
1844  sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1845  sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1846  }
1847  }
1848  // add new intervals
1849  sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1850  // sort children
1851  std::sort(sortedIntervals.begin(), sortedIntervals.end());
1852  // check overlapping after sorting
1853  for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1854  if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1855  return false;
1856  }
1857  }
1858  return true;
1859 }
1860 
1861 
1862 bool
1863 GNEAdditionalHandler::checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos) {
1864  if (friendlyPos) {
1865  return true;
1866  }
1867  // adjust from and to (negative means that start at the end of lane and count backward)
1868  if (pos < 0) {
1869  pos += laneLength;
1870  }
1871  // check extremes
1872  if ((pos < 0) || (pos > laneLength)) {
1873  return false;
1874  }
1875  // check pos + length
1876  if ((pos + length) > laneLength) {
1877  return false;
1878  }
1879  // all OK
1880  return true;
1881 }
1882 
1883 
1884 void
1885 GNEAdditionalHandler::fixLanePosition(double& pos, double& length, const double laneLength) {
1886  // negative pos means that start at the end of lane and count backward)
1887  if (pos < 0) {
1888  pos += laneLength;
1889  }
1890  // set position at the start
1891  if (pos < 0) {
1892  pos = 0;
1893  }
1894  // adjust pos
1895  if (pos >= laneLength) {
1896  pos = (laneLength - POSITION_EPS);
1897  }
1898  // adjust length
1899  if ((length < 0) || ((pos + length) > laneLength)) {
1900  length = POSITION_EPS;
1901  }
1902 }
1903 
1904 
1905 bool
1906 GNEAdditionalHandler::checkLaneDoublePosition(double from, double to, const double laneLength, const bool friendlyPos) {
1907  if (friendlyPos) {
1908  return true;
1909  }
1910  // adjust from and to (negative means that start at the end of lane and count backward)
1911  if (from == INVALID_DOUBLE) {
1912  from = 0;
1913  }
1914  if (to == INVALID_DOUBLE) {
1915  to = laneLength;
1916  }
1917  if (from < 0) {
1918  from += laneLength;
1919  }
1920  if (to < 0) {
1921  to += laneLength;
1922  }
1923  if ((to - from) < POSITION_EPS) {
1924  return false;
1925  }
1926  if ((from < 0) || (from > laneLength)) {
1927  return false;
1928  }
1929  if ((to < 0) || (to > laneLength)) {
1930  return false;
1931  }
1932  return true;
1933 }
1934 
1935 
1936 void
1937 GNEAdditionalHandler::fixLaneDoublePosition(double& from, double& to, const double laneLength) {
1938  // adjust from (negative means that start at the end of lane and count backward)
1939  if (from == INVALID_DOUBLE) {
1940  from = 0;
1941  }
1942  if (to == INVALID_DOUBLE) {
1943  to = laneLength;
1944  }
1945  if (from < 0) {
1946  from += laneLength;
1947  }
1948  if (from < 0) {
1949  from = 0;
1950  } else if (from > laneLength) {
1951  from = laneLength;
1952  }
1953  // adjust to
1954  if (to < 0) {
1955  to += laneLength;
1956  }
1957  if (to < 0) {
1958  to = 0;
1959  } else if (to > laneLength) {
1960  to = laneLength;
1961  }
1962  // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1963  if ((to - from) < POSITION_EPS) {
1964  if (to >= POSITION_EPS) {
1965  from = to - POSITION_EPS;
1966  } else {
1967  from = 0;
1968  to = POSITION_EPS;
1969  }
1970  }
1971 }
1972 
1973 
1974 bool
1975 GNEAdditionalHandler::checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos) {
1976  if (friendlyPos) {
1977  return true;
1978  } else {
1979  return (checkLanePosition(fromPos, 0, fromLaneLength, false) && checkLanePosition(toPos, 0, tolaneLength, false));
1980  }
1981 }
1982 
1983 
1984 void
1985 GNEAdditionalHandler::fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength) {
1986  double length = 0;
1987  fixLanePosition(fromPos, length, fromLaneLength);
1988  fixLanePosition(toPos, length, tolaneLength);
1989 }
1990 
1991 
1992 void
1993 GNEAdditionalHandler::writeInvalidID(const SumoXMLTag tag, const std::string& id) {
1994  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("ID contains invalid characters."));
1995 }
1996 
1997 
1998 void
2000  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Invalid position over lane."));
2001 }
2002 
2003 
2004 void
2005 GNEAdditionalHandler::writeErrorDuplicated(const SumoXMLTag tag, const std::string& id) {
2006  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Declared twice."));
2007 }
2008 
2009 
2010 void
2011 GNEAdditionalHandler::writeErrorInvalidParent(const SumoXMLTag tag, const std::string& id, const SumoXMLTag parent, const std::string& parentID) {
2012  std::string first, second;
2013  if (id.size() > 0) {
2014  first = TLF("Could not build % '%' in netedit", toString(tag), id);
2015  } else {
2016  first = TLF("Could not build % in netedit", toString(tag));
2017  }
2018  if (parentID.size() > 0) {
2019  second = TLF("% '%' doesn't exist.", toString(parent), parentID);
2020  } else {
2021  second = TLF("% doesn't exist.", toString(parent));
2022  }
2023  writeError(first + std::string("; ") + second);
2024 }
2025 
2026 
2027 void
2028 GNEAdditionalHandler::writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute) {
2029  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TLF("Attribute % cannot be negative.", toString(attribute)));
2030 }
2031 
2032 
2033 void
2035  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("List of VTypes isn't valid."));
2036 }
2037 
2038 
2039 void
2041  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Filename is invalid."));
2042 }
2043 
2044 
2045 void
2047  writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("List of lanes isn't valid."));
2048 }
2049 
2050 
2051 bool
2052 GNEAdditionalHandler::checkListOfVehicleTypes(const std::vector<std::string>& vTypeIDs) const {
2053  for (const auto& vTypeID : vTypeIDs) {
2054  if (!SUMOXMLDefinitions::isValidTypeID(vTypeID)) {
2055  return false;
2056  }
2057  }
2058  return true;
2059 }
2060 
2061 
2064  if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
2065  return nullptr;
2066  } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
2067  return nullptr;
2068  } else {
2070  }
2071 }
2072 
2073 
2076  if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
2077  // parent interval doesn't exist
2078  return nullptr;
2079  } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
2080  // rerouter parent doesn't exist
2081  return nullptr;
2082  } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
2083  !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
2084  !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
2085  return nullptr;
2086  } else {
2091  }
2092 }
2093 
2094 
2095 std::vector<GNEEdge*>
2096 GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::vector<std::string>& edgeIDs) {
2097  std::vector<GNEEdge*> edges;
2098  for (const auto& edgeID : edgeIDs) {
2099  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
2100  // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
2101  if (edge == nullptr) {
2102  writeError(TLF("Could not build % in netedit", toString(tag)) + std::string("; ") + TLF("% doesn't exist.", toString(SUMO_TAG_EDGE)));
2103  edges.clear();
2104  return edges;
2105  } else {
2106  edges.push_back(edge);
2107  }
2108  }
2109  return edges;
2110 }
2111 
2112 
2113 std::vector<GNELane*>
2114 GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::vector<std::string>& laneIDs) {
2115  std::vector<GNELane*> lanes;
2116  for (const auto& laneID : laneIDs) {
2117  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
2118  // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
2119  if (lane == nullptr) {
2120  writeError(TLF("Could not build % in netedit", toString(tag)) + std::string("; ") + TLF("% doesn't exist.", toString(SUMO_TAG_LANE)));
2121  lanes.clear();
2122  return lanes;
2123  } else {
2124  lanes.push_back(lane);
2125  }
2126  }
2127  return lanes;
2128 }
2129 
2130 
2131 bool
2132 GNEAdditionalHandler::checkDuplicatedID(const std::vector<SumoXMLTag> tags, const std::string& id) {
2133  for (const auto& tag : tags) {
2134  // retrieve additional
2135  auto additional = myNet->getAttributeCarriers()->retrieveAdditional(tag, id, false);
2136  // if additional exist, check if overwrite (delete)
2137  if (additional) {
2138  if (!myAllowUndoRedo) {
2139  // only overwrite if allow undo-redo
2140  return false;
2141  } else if (myOverwrite) {
2142  // update additional to overwrite
2143  myAdditionalToOverwrite = additional;
2144  } else {
2145  // duplicated additional
2146  return false;
2147  }
2148  } else {
2149 
2150  }
2151  }
2152  // ID is ok
2153  return true;
2154 }
2155 
2156 
2157 void
2160  // remove element
2162  // reset pointer
2163  myAdditionalToOverwrite = nullptr;
2164  }
2165 }
2166 
2167 
2169  myNet(nullptr),
2170  myAllowUndoRedo(false),
2171  myOverwrite(false) {
2172 }
2173 
2174 // ===========================================================================
2175 // GNEAdditionalHandler::NeteditParameters method definitions
2176 // ===========================================================================
2177 
2179  select(sumoBaseObject->hasBoolAttribute(GNE_ATTR_SELECTED) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_SELECTED) : false),
2180  centerAfterCreation(sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) : false) {
2181 }
2182 
2183 
2185 
2186 
2188  select(false),
2189  centerAfterCreation(false) {
2190 }
2191 
2192 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_VTYPE_ID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_REROUTER
A rerouter.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_SINK
Sink(s) specification.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_SOURCE
a source
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ GNE_ATTR_CENTER_AFTER_CREATION
flag to center camera after element creation
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_VOLTAGE
voltage of the traction substation [V]
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_LINEWIDTH
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_WEIGHT
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ROADSIDE_CAPACITY
@ SUMO_ATTR_CURRENTLIMIT
current limit of the traction substation [A]
@ SUMO_ATTR_CHARGINGPOWER
@ SUMO_ATTR_PROB
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations (different of waiting time)
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
void writeError(const std::string &error)
write error and enable error creating element
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition: Boundary.cpp:423
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
bool hasTimeAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given time attribute
SumoXMLTag getTag() const
get XML myTag
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
void buildPolygon(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double layer, const double angle, const std::string &imgFile, const bool relativePath, const PositionVector &shape, const bool geo, const bool fill, const double lineWidth, const std::string &name, const Parameterised::Map &parameters)
Builds a polygon using the given values.
void buildVariableSpeedSign(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const std::vector< std::string > &laneIDs, const std::string &name, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
Builds a VariableSpeedSign (lane speed additional)
void buildDetectorE3(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const SUMOTime period, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const bool openEntry, const bool expectedArrival, const Parameterised::Map &parameters)
Builds a multi entry exit detector (E3)
void buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &edgeID, const double pos, const std::string &name, const std::string &outfile, const SUMOTime period, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a microscopic calibrator over an edge
GNEAdditional * getRerouterIntervalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get rerouter interval parent
void writeInvalidID(const SumoXMLTag tag, const std::string &id)
write invalid id
static void fixLaneDoublePosition(double &from, double &to, const double laneLengt)
fix the given positions over lane
void buildOverheadWire(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &substationId, const std::vector< std::string > &laneIDs, const double startPos, const double endPos, const bool friendlyPos, const std::vector< std::string > &forbiddenInnerLanes, const Parameterised::Map &parameters)
build overhead wire
void buildE1Detector(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double position, const SUMOTime period, const std::string &file, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a induction loop detector (E1)
void buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const double length, const SUMOTime period, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map &parameters)
Builds a single-lane Area Detector (E2)
void buildPOI(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double x, const double y, const std::string &icon, const double layer, const double angle, const std::string &imgFile, bool relativePath, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI using the given values.
static bool accessCanBeCreated(GNEAdditional *busStopParent, GNEEdge *edge)
check if a GNEAccess can be created in a certain Edge
void buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const std::string &name, const std::string &outfile, const SUMOTime period, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a microscopic calibrator over a lane
void buildTAZSink(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double arrivalWeight)
Builds a TAZSink (Traffic Assignment Zone)
void buildAccess(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const std::string &pos, const double length, const bool friendlyPos, const Parameterised::Map &parameters)
Builds an Access.
void buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime time, const std::string &speed)
Builds a VariableSpeedSign Step.
bool checkDuplicatedID(const std::vector< SumoXMLTag > tags, const std::string &id)
check if given ID correspond to a duplicated additionals
GNEAdditional * getAdditionalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, SumoXMLTag tag) const
get additional parent
void writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute)
write error "invalid negative element"
void buildTractionSubstation(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const double voltage, const double currentLimit, const Parameterised::Map &parameters)
build traction substation
std::vector< GNELane * > parseLanes(const SumoXMLTag tag, const std::vector< std::string > &laneIDs)
parse lanes
void writeErrorDuplicated(const SumoXMLTag tag, const std::string &id)
write error "duplicated additional"
void buildRerouterInterval(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime begin, const SUMOTime end)
builds a rerouter interval
void buildCalibratorFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameter)
builds a calibrator flow
void buildPOILane(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const std::string &laneID, const double posOverLane, const bool friendlyPos, const double posLat, const std::string &icon, const double layer, const double angle, const std::string &imgFile, const bool relativePath, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI over lane using the given values.
void overwriteAdditional()
remove overwritten additional
void buildTAZ(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, const Position &center, const bool fill, const RGBColor &color, const std::vector< std::string > &edgeIDs, const std::string &name, const Parameterised::Map &parameters)
Builds a TAZ (Traffic Assignment Zone)
void buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedLane, SVCPermissions permissions)
builds a closing lane reroute
void buildParkingSpace(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const double x, const double y, const double z, const std::string &name, const std::string &width, const std::string &length, const std::string &angle, const double slope, const Parameterised::Map &parameters)
Builds a Parking Space.
void writeErrorInvalidVTypes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of vehicle types"
void buildClosingReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedEdgeID, SVCPermissions permissions)
builds a closing edge reroute
void writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id)
write error "invalid position"
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
void buildDestProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newEdgeDestinationID, const double probability)
builds a dest prob reroute
bool checkListOfVehicleTypes(const std::vector< std::string > &vTypeIDs) const
check list of IDs
const bool myAllowUndoRedo
allow undo/redo
static bool checkLaneDoublePosition(double from, const double to, const double laneLength, const bool friendlyPos)
check if the given positions over a lane is valid
void buildJpsObstacle(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, bool geo, const std::string &name, const Parameterised::Map &parameters)
Builds a JuPedSim obstacle using the given values.
void buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newParkignAreaID, const double probability, const bool visible)
builds a parking area reroute
static bool checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos)
check if the given position over a lane is valid
void buildRouteProbe(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &edgeID, const SUMOTime period, const std::string &name, const std::string &file, const SUMOTime begin, const Parameterised::Map &parameters)
builds a Route probe
void buildBusStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int personCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a bus stop.
GNEAdditionalHandler()
invalidate default constructo
void writeErrorInvalidFilename(const SumoXMLTag tag, const std::string &id)
write error "invalid filename"
void buildTrainStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int personCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a train stop.
void buildParkingArea(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &departPos, const std::string &name, const std::vector< std::string > &badges, const bool friendlyPosition, const int roadSideCapacity, const bool onRoad, const double width, const double length, const double angle, const bool lefthand, const Parameterised::Map &parameters)
Builds a Parking Area.
void writeErrorInvalidLanes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of lanes"
void buildJpsWalkableArea(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, bool geo, const std::string &name, const Parameterised::Map &parameters)
Builds a JuPedSim walkable area using the given values.
void buildPOIGeo(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double lon, const double lat, const std::string &icon, const double layer, const double angle, const std::string &imgFile, bool relativePath, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI in GEO coordinaten using the given values.
static bool checkOverlappingRerouterIntervals(GNEAdditional *rerouter, const SUMOTime newBegin, const SUMOTime newEnd)
check if an overlapping is produced in rerouter if a interval with certain begin and end is inserted
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
GNENet * myNet
pointer to GNENet
void buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &laneIDs, const double pos, const double endPos, const SUMOTime period, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map &parameters)
Builds a multi-lane Area Detector (E2)
void buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newRouteID, const double probability)
builds a route prob reroute
void buildTAZSource(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double departWeight)
Builds a TAZSource (Traffic Assignment Zone)
void buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a Instant Induction Loop Detector (E1Instant)
void writeErrorInvalidParent(const SumoXMLTag tag, const std::string &id, const SumoXMLTag parent, const std::string &parentID)
write error "invalid parent element"
void buildChargingStation(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const double chargingPower, const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string &chargeType, const SUMOTime waitingTime, const bool friendlyPosition, const std::string &parkingAreaID, const Parameterised::Map &parameters)
Builds a charging Station.
std::vector< GNEEdge * > parseEdges(const SumoXMLTag tag, const std::vector< std::string > &edgeIDs)
parse edges
void buildVaporizer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const SUMOTime from, const SUMOTime endTime, const std::string &name, const Parameterised::Map &parameters)
Builds a vaporizer (lane speed additional)
void buildContainerStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int containerCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a container stop.
GNEAdditional * myAdditionalToOverwrite
additional to overwrite (using undor-redo
void buildRerouter(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const std::vector< std::string > &edgeIDs, const double prob, const std::string &name, const bool off, const bool optional, const SUMOTime timeThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a rerouter
void buildDetectorEntry(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a entry detector (E3)
void buildDetectorExit(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a exit detector (E3)
void buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &overheadWireIDStartClamp, const std::string &laneIDStartClamp, const std::string &overheadWireIDEndClamp, const std::string &laneIDEndClamp, const Parameterised::Map &parameters)
build overhead wire clamp
const bool myOverwrite
check if overwrite
static bool checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos)
check if the given positions over two lanes are valid
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
virtual Position getPositionInView() const =0
Returns position of additional in view.
const std::string getID() const
get ID (all Attribute Carriers have one)
static GNEBusStop * buildTrainStop(GNENet *net)
default constructor
Definition: GNEBusStop.cpp:46
static GNEBusStop * buildBusStop(GNENet *net)
default constructor
Definition: GNEBusStop.cpp:40
A lane area vehicles can halt at (netedit-version)
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:753
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:1090
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:633
void addChildElement(T *element)
add child element
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
bool allowPedestrians() const
check if current lane allow pedestrians
Definition: GNELane.cpp:202
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:196
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition: GNENet.cpp:654
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition: GNENet.cpp:2781
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:123
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2136
void enableUpdateGeometry()
Definition: GNENet.cpp:2775
Definition: GNEPOI.h:43
A lane area vehicles can park at (netedit-version)
vehicle space used by GNEParkingAreas
void incRef(const std::string &debugMsg="")
Increase reference.
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:32
Definition: GNETAZ.h:34
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:33
GNEUndoList * getUndoList() const
get the undoList object
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:4704
static const std::vector< SumoXMLTag > POIs
POIs namespace.
Definition: NamespaceIDs.h:50
static const std::vector< SumoXMLTag > polygons
polygon namespace
Definition: NamespaceIDs.h:47
C++ TraCI client API implementation.
Definition: POI.h:34
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:322
A list of positions.
double length2D() const
Returns the length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Structure representing possible vehicle parameter.
std::string vtypeid
The vehicle's type id.
std::string routeid
The vehicle's route id.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
const bool centerAfterCreation
center view after creation