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.org/sumo
3 // Copyright (C) 2001-2022 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 #include <utils/xml/XMLSubSys.h>
27 #include <netedit/GNEViewNet.h>
28 #include <netedit/GNEUndoList.h>
29 #include <netedit/GNENet.h>
32 
33 #include "GNEAdditionalHandler.h"
34 #include "GNEAccess.h"
35 #include "GNEBusStop.h"
36 #include "GNECalibrator.h"
37 #include "GNECalibratorFlow.h"
38 #include "GNEChargingStation.h"
39 #include "GNEClosingLaneReroute.h"
40 #include "GNEClosingReroute.h"
41 #include "GNEContainerStop.h"
42 #include "GNEDestProbReroute.h"
43 #include "GNEDetectorE1.h"
44 #include "GNEDetectorE1Instant.h"
45 #include "GNEDetectorE2.h"
46 #include "GNEDetectorE3.h"
47 #include "GNEDetectorEntryExit.h"
48 #include "GNEPOI.h"
49 #include "GNEParkingArea.h"
50 #include "GNEParkingAreaReroute.h"
51 #include "GNEParkingSpace.h"
52 #include "GNEPoly.h"
53 #include "GNERerouter.h"
54 #include "GNERerouterInterval.h"
55 #include "GNERerouterSymbol.h"
56 #include "GNERouteProbReroute.h"
57 #include "GNERouteProbe.h"
58 #include "GNETAZ.h"
59 #include "GNETAZSourceSink.h"
60 #include "GNEVaporizer.h"
61 #include "GNEVariableSpeedSign.h"
64 
65 
66 // ===========================================================================
67 // GNEAdditionalHandler method definitions
68 // ===========================================================================
69 
70 GNEAdditionalHandler::GNEAdditionalHandler(GNENet* net, const bool allowUndoRedo) :
71  myNet(net),
72  myAllowUndoRedo(allowUndoRedo) {
73 }
74 
75 
77 }
78 
79 
80 void
81 GNEAdditionalHandler::buildBusStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id,
82  const std::string& laneID, const double startPos, const double endPos, const std::string& name,
83  const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
84  const RGBColor& color, const bool friendlyPosition, const std::map<std::string, std::string>& parameters) {
85  // check conditions
88  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_BUS_STOP, id, false) == nullptr) {
89  // get NETEDIT parameters
90  NeteditParameters neteditParameters(sumoBaseObject);
91  // get lane
92  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
93  // check lane
94  if (lane == nullptr) {
96  } else if (!checkDoublePositionOverLane(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
98  } else if (personCapacity < 0) {
100  } else if (parkingLength < 0) {
102  } else {
103  // build busStop
104  GNEAdditional* busStop = new GNEBusStop(SUMO_TAG_BUS_STOP, id, lane, myNet, startPos, endPos, name, lines, personCapacity,
105  parkingLength, color, friendlyPosition, parameters);
106  // insert depending of allowUndoRedo
107  if (myAllowUndoRedo) {
109  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
110  myNet->getViewNet()->getUndoList()->end();
111  } else {
113  lane->addChildElement(busStop);
114  busStop->incRef("buildBusStop");
115  }
116  }
117  } else {
119  }
120 }
121 
122 
123 void
125  const std::string& laneID, const double startPos, const double endPos, const std::string& name,
126  const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
127  const RGBColor& color, const bool friendlyPosition, const std::map<std::string, std::string>& parameters) {
128  // check conditions
131  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRAIN_STOP, id, false) == nullptr) {
132  // get NETEDIT parameters
133  NeteditParameters neteditParameters(sumoBaseObject);
134  // get lane
135  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
136  // check lane
137  if (lane == nullptr) {
139  } else if (!checkDoublePositionOverLane(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
141  } else if (personCapacity < 0) {
143  } else if (parkingLength < 0) {
145  } else {
146  // build trainStop
147  GNEAdditional* trainStop = new GNEBusStop(SUMO_TAG_TRAIN_STOP, id, lane, myNet, startPos, endPos, name, lines, personCapacity,
148  parkingLength, color, friendlyPosition, parameters);
149  // insert depending of allowUndoRedo
150  if (myAllowUndoRedo) {
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 double pos, const double length, const bool friendlyPos, const std::map<std::string, std::string>& 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  // Check if busStop parent and lane is correct
179  if (lane == nullptr) {
181  } else if (busStop == nullptr) {
183  } else if (!checkSinglePositionOverLane(pos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
185  } else if ((length != -1) && (length < 0)) {
187  } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
188  WRITE_WARNING("Could not build " + toString(SUMO_TAG_ACCESS) + " in netedit; " + toString(SUMO_TAG_BUS_STOP) + " parent already owns an " + toString(SUMO_TAG_ACCESS) + " in the edge '" + lane->getParentEdge()->getID() + "'");
189  } else if (!lane->allowPedestrians()) {
190  WRITE_WARNING("Could not build " + toString(SUMO_TAG_ACCESS) + " in netedit; The " + toString(SUMO_TAG_LANE) + " '" + lane->getID() + "' doesn't support pedestrians");
191  } else {
192  // build access
193  GNEAdditional* access = new GNEAccess(busStop, lane, myNet, pos, length, friendlyPos, parameters);
194  // insert depending of allowUndoRedo
195  if (myAllowUndoRedo) {
197  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(access, true), true);
198  myNet->getViewNet()->getUndoList()->end();
199  } else {
201  lane->addChildElement(access);
202  busStop->addChildElement(access);
203  access->incRef("buildAccess");
204  }
205  }
206 }
207 
208 
209 void
210 GNEAdditionalHandler::buildContainerStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
211  const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines, const int containerCapacity,
212  const double parkingLength, const RGBColor& color, const bool friendlyPosition, const std::map<std::string, std::string>& parameters) {
213  // check conditions
216  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_CONTAINER_STOP, id, false) == nullptr) {
217  // get NETEDIT parameters
218  NeteditParameters neteditParameters(sumoBaseObject);
219  // get lane
220  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
221  // check lane
222  if (lane == nullptr) {
224  } else if (!checkDoublePositionOverLane(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
226  } else if (containerCapacity < 0) {
228  } else if (parkingLength < 0) {
230  } else {
231  // build containerStop
232  GNEAdditional* containerStop = new GNEContainerStop(id, lane, myNet, startPos, endPos, name, lines, containerCapacity, parkingLength,
233  color, friendlyPosition, parameters);
234  // insert depending of allowUndoRedo
235  if (myAllowUndoRedo) {
237  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
238  myNet->getViewNet()->getUndoList()->end();
239  } else {
240  myNet->getAttributeCarriers()->insertAdditional(containerStop);
241  lane->addChildElement(containerStop);
242  containerStop->incRef("buildContainerStop");
243  }
244  }
245  } else {
247  }
248 }
249 
250 
251 void
253  const std::string& laneID, const double startPos, const double endPos, const std::string& name, const double chargingPower,
254  const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const bool friendlyPosition,
255  const std::map<std::string, std::string>& parameters) {
256  // check conditions
259  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_CHARGING_STATION, id, false) == nullptr) {
260  // get NETEDIT parameters
261  NeteditParameters neteditParameters(sumoBaseObject);
262  // get lane
263  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
264  // check lane
265  if (lane == nullptr) {
267  } else if (!checkDoublePositionOverLane(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
269  } else if (chargingPower < 0) {
271  } else if (chargeDelay < 0) {
273  } else {
274  // build chargingStation
275  GNEAdditional* chargingStation = new GNEChargingStation(id, lane, myNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit,
276  chargeDelay, friendlyPosition, parameters);
277  // insert depending of allowUndoRedo
278  if (myAllowUndoRedo) {
280  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
281  myNet->getViewNet()->getUndoList()->end();
282  } else {
283  myNet->getAttributeCarriers()->insertAdditional(chargingStation);
284  lane->addChildElement(chargingStation);
285  chargingStation->incRef("buildChargingStation");
286  }
287  }
288  } else {
290  }
291 
292 }
293 
294 
295 void
296 GNEAdditionalHandler::buildParkingArea(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
297  const double startPos, const double endPos, const std::string& departPos, const std::string& name, const bool friendlyPosition,
298  const int roadSideCapacity, const bool onRoad, const double width, const double length, const double angle, const std::map<std::string, std::string>& parameters) {
299  // check conditions
302  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, id, false) == nullptr) {
303  // get NETEDIT parameters
304  NeteditParameters neteditParameters(sumoBaseObject);
305  // get lane
306  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
307  // get departPos double
308  const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
309  // check lane
310  if (lane == nullptr) {
312  } else if (!checkDoublePositionOverLane(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
314  } else if (roadSideCapacity < 0) {
316  } else if (width < 0) {
318  } else if (length < 0) {
320  } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
321  WRITE_ERROR("Could not build " + toString(SUMO_TAG_PARKING_AREA) + " with ID '" + id + "' in netedit; Invalid " + toString(SUMO_ATTR_DEPARTPOS) + " over lane.");
322  } else {
323  // build parkingArea
324  GNEAdditional* parkingArea = new GNEParkingArea(id, lane, myNet, startPos, endPos, departPos, name, friendlyPosition, roadSideCapacity,
325  onRoad, (width == 0) ? SUMO_const_laneWidth : width, length, angle, parameters);
326  // insert depending of allowUndoRedo
327  if (myAllowUndoRedo) {
329  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
330  myNet->getViewNet()->getUndoList()->end();
331  } else {
333  lane->addChildElement(parkingArea);
334  parkingArea->incRef("buildParkingArea");
335  }
336  }
337  } else {
339  }
340 }
341 
342 
343 void
344 GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
345  const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
346  const std::map<std::string, std::string>& parameters) {
347  // check width and heights
348  if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
349  WRITE_ERROR("Could not build " + toString(SUMO_TAG_PARKING_SPACE) + "' in netedit; attribute " + toString(SUMO_ATTR_WIDTH) + " cannot be parse to float.");
350  } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
351  WRITE_ERROR("Could not build " + toString(SUMO_TAG_PARKING_SPACE) + "' in netedit; attribute " + toString(SUMO_ATTR_LENGTH) + " cannot be parse to float.");
352  } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
353  WRITE_ERROR("Could not build " + toString(SUMO_TAG_PARKING_SPACE) + "' in netedit; attribute " + toString(SUMO_ATTR_ANGLE) + " cannot be parse to float.");
354  } else {
355  // get NETEDIT parameters
356  NeteditParameters neteditParameters(sumoBaseObject);
357  // get lane
358  GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
359  // get double values
360  const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
361  const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
362  // check lane
363  if (parkingArea == nullptr) {
365  } else if (widthDouble < 0) {
367  } else if (lengthDouble < 0) {
369  } else {
370  // build parkingSpace
371  GNEAdditional* parkingSpace = new GNEParkingSpace(myNet, parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
372  // insert depending of allowUndoRedo
373  if (myAllowUndoRedo) {
375  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
376  myNet->getViewNet()->getUndoList()->end();
377  } else {
378  myNet->getAttributeCarriers()->insertAdditional(parkingSpace);
379  parkingArea->addChildElement(parkingSpace);
380  parkingSpace->incRef("buildParkingSpace");
381  }
382  // update geometry (due boundaries)
383  parkingSpace->updateGeometry();
384  }
385  }
386 }
387 
388 
389 void
390 GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
391  const double position, const SUMOTime frequency, const std::string& file, const std::vector<std::string>& vehicleTypes, const std::string& name,
392  const bool friendlyPos, const std::map<std::string, std::string>& parameters) {
393  // check conditions
396  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_E1DETECTOR, id, false) == nullptr) {
397  // get NETEDIT parameters
398  NeteditParameters neteditParameters(sumoBaseObject);
399  // get lane
400  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
401  // check lane
402  if (lane == nullptr) {
404  } else if (!checkSinglePositionOverLane(position, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
406  } else if (frequency < 0) {
408  } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
410  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
412  } else {
413  // build E1
414  GNEAdditional* detectorE1 = new GNEDetectorE1(id, lane, myNet, position, frequency, file, vehicleTypes, name, friendlyPos, parameters);
415  // insert depending of allowUndoRedo
416  if (myAllowUndoRedo) {
418  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
419  myNet->getViewNet()->getUndoList()->end();
420  } else {
422  lane->addChildElement(detectorE1);
423  detectorE1->incRef("buildDetectorE1");
424  }
425  }
426  } else {
428  }
429 }
430 
431 
432 void
433 GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
434  const double pos, const double length, const SUMOTime freq, const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
435  const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
436  const std::map<std::string, std::string>& parameters) {
437  // check conditions
440  } else if ((myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_E2DETECTOR, id, false) == nullptr) &&
442  // get NETEDIT parameters
443  NeteditParameters neteditParameters(sumoBaseObject);
444  // get lane
445  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
446  // check lane
447  if (lane == nullptr) {
449  } else if (!checkE2SingleLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
451  } else if (length < 0) {
453  } else if ((freq != -1) && (freq < 0)) {
455  } else if (timeThreshold < 0) {
457  } else if (speedThreshold < 0) {
459  } else if (jamThreshold < 0) {
461  } else if (freq < 0) {
463  } else if (timeThreshold < 0) {
465  } else if (speedThreshold < 0) {
467  } else if (jamThreshold < 0) {
469  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
471  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
473  } else {
474  // build E2 single lane
475  GNEAdditional* detectorE2 = new GNEDetectorE2(
476  id, lane, myNet, pos, length, freq, trafficLight, filename,
477  vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold,
478  friendlyPos, parameters);
479  // insert depending of allowUndoRedo
480  if (myAllowUndoRedo) {
482  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
483  myNet->getViewNet()->getUndoList()->end();
484  } else {
486  lane->addChildElement(detectorE2);
487  detectorE2->incRef("buildDetectorE2");
488  }
489  }
490  } else {
492  }
493 }
494 
495 
496 void
497 GNEAdditionalHandler::buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::vector<std::string>& laneIDs,
498  const double pos, const double endPos, const SUMOTime freq, const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
499  const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
500  const std::map<std::string, std::string>& parameters) {
501  // check conditions
504  } else if ((myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_E2DETECTOR, id, false) == nullptr) &&
506  // get NETEDIT parameters
507  NeteditParameters neteditParameters(sumoBaseObject);
508  // get lanes
509  std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_E2DETECTOR, laneIDs);
510  // chek lanes
511  if (lanes.size() > 0) {
513  pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
514  endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
516  } else if (freq < 0) {
518  } else if (timeThreshold < 0) {
520  } else if (speedThreshold < 0) {
522  } else if (jamThreshold < 0) {
524  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
526  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
528  } else {
529  // build E2 multilane detector
530  GNEAdditional* detectorE2 = new GNEDetectorE2(
531  id, lanes, myNet, pos, endPos, freq, trafficLight, filename,
532  vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold,
533  friendlyPos, parameters);
534  // insert depending of allowUndoRedo
535  if (myAllowUndoRedo) {
537  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
538  myNet->getViewNet()->getUndoList()->end();
539  } else {
541  for (const auto& lane : lanes) {
542  lane->addChildElement(detectorE2);
543  }
544  detectorE2->incRef("buildDetectorE2Multilane");
545  }
546  }
547  }
548  } else {
550  }
551 }
552 
553 
554 void
555 GNEAdditionalHandler::buildDetectorE3(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos, const SUMOTime freq,
556  const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, const SUMOTime timeThreshold, const double speedThreshold,
557  const std::map<std::string, std::string>& parameters) {
558  // check conditions
561  } else if (freq < 0) {
563  } else if (timeThreshold < 0) {
565  } else if (speedThreshold < 0) {
567  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
569  } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
571  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_E3DETECTOR, id, false) == nullptr) {
572  // get NETEDIT parameters
573  NeteditParameters neteditParameters(sumoBaseObject);
574  // build E3
575  GNEAdditional* E3 = new GNEDetectorE3(id, myNet, pos, freq, filename, vehicleTypes, name, timeThreshold, speedThreshold, parameters);
576  // insert depending of allowUndoRedo
577  if (myAllowUndoRedo) {
579  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
580  myNet->getViewNet()->getUndoList()->end();
581  } else {
583  E3->incRef("buildDetectorE3");
584  }
585  } else {
587  }
588 }
589 
590 
591 void
592 GNEAdditionalHandler::buildDetectorEntry(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
593  const bool friendlyPos, const std::map<std::string, std::string>& parameters) {
594  // get lane
595  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
596  // get E3 parent
598  // Check if Detector E3 parent and lane is correct
599  if (lane == nullptr) {
601  } else if (E3 == nullptr) {
603  } else if (!checkSinglePositionOverLane(pos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
605  } else {
606  // get NETEDIT parameters
607  NeteditParameters neteditParameters(sumoBaseObject);
608  // build entry instant
609  GNEAdditional* entry = new GNEDetectorEntryExit(SUMO_TAG_DET_ENTRY, myNet, E3, lane, pos, friendlyPos, parameters);
610  // insert depending of allowUndoRedo
611  if (myAllowUndoRedo) {
613  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
614  myNet->getViewNet()->getUndoList()->end();
615  } else {
617  lane->addChildElement(entry);
618  E3->addChildElement(entry);
619  entry->incRef("buildDetectorEntry");
620  }
621  }
622 }
623 
624 
625 void
626 GNEAdditionalHandler::buildDetectorExit(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
627  const bool friendlyPos, const std::map<std::string, std::string>& parameters) {
628  // get lane
629  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
630  // get E3 parent
632  // Check if Detector E3 parent and lane is correct
633  if (lane == nullptr) {
635  } else if (E3 == nullptr) {
637  } else if (!checkSinglePositionOverLane(pos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
639  } else {
640  // get NETEDIT parameters
641  NeteditParameters neteditParameters(sumoBaseObject);
642  // build exit instant
643  GNEAdditional* exit = new GNEDetectorEntryExit(SUMO_TAG_DET_EXIT, myNet, E3, lane, pos, friendlyPos, parameters);
644  // insert depending of allowUndoRedo
645  if (myAllowUndoRedo) {
647  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
648  myNet->getViewNet()->getUndoList()->end();
649  } else {
651  lane->addChildElement(exit);
652  E3->addChildElement(exit);
653  exit->incRef("buildDetectorExit");
654  }
655  }
656 }
657 
658 
659 void
660 GNEAdditionalHandler::buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, double pos,
661  const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, const bool friendlyPos, const std::map<std::string, std::string>& parameters) {
662  // check conditions
665  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_INSTANT_INDUCTION_LOOP, id, false) == nullptr) {
666  // get NETEDIT parameters
667  NeteditParameters neteditParameters(sumoBaseObject);
668  // get lane
669  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
670  // check lane
671  if (lane == nullptr) {
673  } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
675  } else if (!checkSinglePositionOverLane(pos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
677  } else {
678  // build E1 instant
679  GNEAdditional* detectorE1Instant = new GNEDetectorE1Instant(id, lane, myNet, pos, filename, vehicleTypes, name, friendlyPos, parameters);
680  // insert depending of allowUndoRedo
681  if (myAllowUndoRedo) {
683  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
684  myNet->getViewNet()->getUndoList()->end();
685  } else {
686  myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
687  lane->addChildElement(detectorE1Instant);
688  detectorE1Instant->incRef("buildDetectorE1Instant");
689  }
690  }
691  } else {
693  }
694 }
695 
696 
697 void
698 GNEAdditionalHandler::buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, const double pos,
699  const std::string& name, const std::string& outfile, const SUMOTime freq, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
700  const std::map<std::string, std::string>& parameters) {
701  // get lane
702  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
703  // get routeProbe
704  GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
705  // check conditions
708  } else if ((myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_CALIBRATOR, id, false) != nullptr) ||
711  } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
713  } else if (lane == nullptr) {
715  } else {
716  // get NETEDIT parameters
717  NeteditParameters neteditParameters(sumoBaseObject);
718  // check lane
719  if (!checkSinglePositionOverLane(pos, lane->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
721  } else if (freq < 0) {
723  } else if (jamThreshold < 0) {
725  } else {
726  // build Calibrator
727  GNEAdditional* calibrator = (routeProbe == nullptr) ?
728  new GNECalibrator(id, myNet, lane, pos, freq, name, outfile, jamThreshold, vTypes, parameters) :
729  new GNECalibrator(id, myNet, lane, pos, freq, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
730  // insert depending of allowUndoRedo
731  if (myAllowUndoRedo) {
733  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
734  myNet->getViewNet()->getUndoList()->end();
735  // center after creation
736  if (neteditParameters.centerAfterCreation) {
737  myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
738  }
739  } else {
741  lane->addChildElement(calibrator);
742  if (routeProbe) {
743  routeProbe->addChildElement(calibrator);
744  }
745  calibrator->incRef("buildCalibrator");
746  }
747  }
748  }
749 }
750 
751 
752 void
753 GNEAdditionalHandler::buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const double pos,
754  const std::string& name, const std::string& outfile, const SUMOTime freq, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
755  const std::map<std::string, std::string>& parameters) {
756  // get edge
757  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
758  // get routeProbe
759  GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
760  // check conditions
763  } else if ((myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_CALIBRATOR, id, false) != nullptr) ||
766  } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
768  } else if (edge == nullptr) {
770  } else {
771  // get NETEDIT parameters
772  NeteditParameters neteditParameters(sumoBaseObject);
773  if (!checkSinglePositionOverLane(pos, edge->getLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
775  } else if (freq < 0) {
777  } else if (jamThreshold < 0) {
779  } else {
780  // build Calibrator
781  GNEAdditional* calibrator = (routeProbe == nullptr) ?
782  new GNECalibrator(id, myNet, edge, pos, freq, name, outfile, jamThreshold, vTypes, parameters) :
783  new GNECalibrator(id, myNet, edge, pos, freq, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
784  // insert depending of allowUndoRedo
785  if (myAllowUndoRedo) {
787  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
788  myNet->getViewNet()->getUndoList()->end();
789  // center after creation
790  if (neteditParameters.centerAfterCreation) {
791  myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
792  }
793  } else {
795  edge->addChildElement(calibrator);
796  if (routeProbe) {
797  routeProbe->addChildElement(calibrator);
798  }
799  calibrator->incRef("buildCalibrator");
800  }
801  }
802  }
803 }
804 
805 
806 void
808  // get vType
810  // get route
812  // get calibrator parent
814  // check parents
815  if (vType == nullptr) {
817  } else if (route == nullptr) {
819  } else if (calibrator == nullptr) {
821  } else {
822  // create calibrator flow
823  GNEAdditional* flow = new GNECalibratorFlow(calibrator, vType, route, vehicleParameter);
824  // insert depending of allowUndoRedo
825  if (myAllowUndoRedo) {
826  myNet->getViewNet()->getUndoList()->begin(GUIIcon::FLOW, "add " + flow->getTagStr());
827  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
828  myNet->getViewNet()->getUndoList()->end();
829  } else {
830  calibrator->addChildElement(flow);
831  route->addChildElement(flow);
832  vType->addChildElement(flow);
833  flow->incRef("buildCalibratorFlow");
834  }
835  }
836 }
837 
838 
839 void
840 GNEAdditionalHandler::buildRerouter(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
841  const std::vector<std::string>& edgeIDs, const double prob, const std::string& name, const std::string& file, const bool off, const SUMOTime timeThreshold,
842  const std::vector<std::string>& vTypes, const std::map<std::string, std::string>& parameters) {
843  // check conditions
846  } else if (prob < 0) {
848  } else if (timeThreshold < 0) {
850  } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
852  } else if (!vTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vTypes)) {
854  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_REROUTER, id, false) == nullptr) {
855  // get NETEDIT parameters
856  NeteditParameters neteditParameters(sumoBaseObject);
857  // parse edges
858  std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, edgeIDs);
859  // check edges
860  if (edges.size() > 0) {
861  GNEAdditional* rerouter = nullptr;
862  // continue depending of position
863  if (pos == Position::INVALID) {
864  if (edges.size() > 0) {
865  PositionVector laneShape = edges.front()->getLanes().front()->getLaneShape();
866  // move to side
867  laneShape.move2side(3);
868  // create rerouter
869  rerouter = new GNERerouter(id, myNet, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, file, prob, off, timeThreshold, vTypes, parameters);
870  } else {
871  rerouter = new GNERerouter(id, myNet, Position(0, 0), name, file, prob, off, timeThreshold, vTypes, parameters);
872  }
873  } else {
874  rerouter = new GNERerouter(id, myNet, pos, name, file, prob, off, timeThreshold, vTypes, parameters);
875  }
876  // create rerouter Symbols
877  std::vector<GNEAdditional*> rerouterSymbols;
878  for (const auto& edge : edges) {
879  rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
880  }
881  // insert depending of allowUndoRedo
882  if (myAllowUndoRedo) {
884  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
885  // add symbols
886  for (const auto& rerouterSymbol : rerouterSymbols) {
887  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
888  }
889  myNet->getViewNet()->getUndoList()->end();
890  } else {
892  // add symbols
893  for (int i = 0; i < (int)edges.size(); i++) {
894  edges.at(i)->addChildElement(rerouterSymbols.at(i));
895  rerouterSymbols.at(i)->incRef("buildRerouterSymbol");
896  }
897  rerouter->incRef("buildRerouter");
898  }
899  /*
900  // parse rerouter children
901  if (!file.empty()) {
902  // we assume that rerouter values files is placed in the same folder as the additional file
903  std::string currentAdditionalFilename = FileHelpers::getFilePath(OptionsCont::getOptions().getString("additional-files"));
904  // Create additional handler for parse rerouter values
905  GNEAdditionalHandler rerouterValuesHandler(currentAdditionalFilename + file, net, rerouter);
906  // disable validation for rerouters
907  XMLSubSys::setValidation("never", "auto", "auto");
908  // Run parser
909  if (!XMLSubSys::runParser(rerouterValuesHandler, currentAdditionalFilename + file, false)) {
910  WRITE_MESSAGE("Loading of " + file + " failed.");
911  }
912  // enable validation for rerouters
913  XMLSubSys::setValidation("auto", "auto", "auto");
914  }
915  */
916  }
917  } else {
919  }
920 }
921 
922 
923 void
925  // get rerouter parent
926  GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
927  // check if rerouter exist
928  if (rerouter == nullptr) {
930  } else if (begin < 0) {
932  } else if (end < 0) {
934  } else if (end < begin) {
935  WRITE_ERROR("Could not build " + toString(SUMO_TAG_INTERVAL) + " with ID '" + rerouter->getID() + "' in netedit; " + toString(SUMO_ATTR_BEGIN) + " is greather than " + toString(SUMO_ATTR_END) + ".");
936  } else {
937  // check if new interval will produce a overlapping
938  if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
939  // create rerouter interval and add it into rerouter parent
940  GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
941  // insert depending of allowUndoRedo
942  if (myAllowUndoRedo) {
943  myNet->getViewNet()->getUndoList()->begin(GUIIcon::REROUTERINTERVAL, "add " + rerouterInterval->getTagStr());
944  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
945  myNet->getViewNet()->getUndoList()->end();
946  } else {
947  rerouter->addChildElement(rerouterInterval);
948  rerouterInterval->incRef("buildRerouterInterval");
949  }
950  } else {
951  WRITE_ERROR("Could not build " + toString(SUMO_TAG_INTERVAL) + " with begin '" + toString(begin) + "' and '" + toString(end) + "' in '" + rerouter->getID() + "' due overlapping.");
952  }
953  }
954 }
955 
956 
957 void
958 GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
959  // get rerouter interval parent
960  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
961  // get closed lane
962  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
963  // check parents
964  if (lane == nullptr) {
966  } else if (rerouterInterval == nullptr) {
968  } else {
969  // create closing lane reorute
970  GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
971  // add it to interval parent depending of allowUndoRedo
972  if (myAllowUndoRedo) {
973  myNet->getViewNet()->getUndoList()->begin(GUIIcon::CLOSINGLANEREROUTE, "add " + closingLaneReroute->getTagStr());
974  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
975  myNet->getViewNet()->getUndoList()->end();
976  } else {
977  rerouterInterval->addChildElement(closingLaneReroute);
978  closingLaneReroute->incRef("buildClosingLaneReroute");
979  }
980  }
981 }
982 
983 
984 void
985 GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
986  // get rerouter interval parent
987  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
988  // get closed edge
989  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
990  // check parents
991  if (edge == nullptr) {
993  } else if (rerouterInterval == nullptr) {
995  } else {
996  // create closing reroute
997  GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
998  // add it to interval parent depending of allowUndoRedo
999  if (myAllowUndoRedo) {
1000  myNet->getViewNet()->getUndoList()->begin(GUIIcon::CLOSINGREROUTE, "add " + closingLaneReroute->getTagStr());
1001  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1002  myNet->getViewNet()->getUndoList()->end();
1003  } else {
1004  rerouterInterval->addChildElement(closingLaneReroute);
1005  closingLaneReroute->incRef("buildClosingLaneReroute");
1006  }
1007  }
1008 }
1009 
1010 void
1011 GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1012  // get rerouter interval parent
1013  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1014  // get edge
1015  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1016  // check parents
1017  if (edge == nullptr) {
1019  } else if (rerouterInterval == nullptr) {
1021  } else {
1022  // create dest probability reroute
1023  GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1024  // add it to interval parent depending of allowUndoRedo
1025  if (myAllowUndoRedo) {
1026  myNet->getViewNet()->getUndoList()->begin(GUIIcon::DESTPROBREROUTE, "add " + destProbReroute->getTagStr());
1027  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1028  myNet->getViewNet()->getUndoList()->end();
1029  } else {
1030  rerouterInterval->addChildElement(destProbReroute);
1031  destProbReroute->incRef("builDestProbReroute");
1032  }
1033  }
1034 }
1035 
1036 
1037 void
1038 GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1039  // get rerouter interval parent
1040  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1041  // get parking area
1042  GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1043  // check parents
1044  if (rerouterInterval == nullptr) {
1046  } else if (parkingArea == nullptr) {
1048  } else {
1049  // create parking area reroute
1050  GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1051  // add it to interval parent depending of allowUndoRedo
1052  if (myAllowUndoRedo) {
1053  myNet->getViewNet()->getUndoList()->begin(GUIIcon::PARKINGZONEREROUTE, "add " + parkingAreaReroute->getTagStr());
1054  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1055  myNet->getViewNet()->getUndoList()->end();
1056  } else {
1057  rerouterInterval->addChildElement(parkingAreaReroute);
1058  parkingAreaReroute->incRef("builParkingAreaReroute");
1059  }
1060  }
1061 }
1062 
1063 
1064 void
1065 GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1066  // get rerouter interval parent
1067  GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1068  // get route parent
1070  // check parents
1071  if (rerouterInterval == nullptr) {
1073  } else if (route == nullptr) {
1075  } else {
1076  // create rout prob reroute
1077  GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1078  // add it to interval parent depending of allowUndoRedo
1079  if (myAllowUndoRedo) {
1080  myNet->getViewNet()->getUndoList()->begin(GUIIcon::ROUTEPROBREROUTE, "add " + routeProbReroute->getTagStr());
1081  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1082  myNet->getViewNet()->getUndoList()->end();
1083  } else {
1084  rerouterInterval->addChildElement(routeProbReroute);
1085  routeProbReroute->incRef("buildRouteProbReroute");
1086  }
1087  }
1088 }
1089 
1090 
1091 void
1092 GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime freq,
1093  const std::string& name, const std::string& file, const SUMOTime begin, const std::map<std::string, std::string>& parameters) {
1094  // check conditions
1097  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, id, false) == nullptr) {
1098  // get NETEDIT parameters
1099  NeteditParameters neteditParameters(sumoBaseObject);
1100  // get edge
1101  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1102  // check lane
1103  if (edge == nullptr) {
1105  } else if (freq < 0) {
1107  } else if (begin < 0) {
1109  } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
1111  } else {
1112  // build route probe
1113  GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, edge, freq, name, file, begin, parameters);
1114  // insert depending of allowUndoRedo
1115  if (myAllowUndoRedo) {
1117  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1118  myNet->getViewNet()->getUndoList()->end();
1119  // center after creation
1120  if (neteditParameters.centerAfterCreation) {
1121  myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1122  }
1123  } else {
1125  edge->addChildElement(routeProbe);
1126  routeProbe->incRef("buildRouteProbe");
1127  }
1128  }
1129  } else {
1131  }
1132 }
1133 
1134 
1135 void
1136 GNEAdditionalHandler::buildVariableSpeedSign(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
1137  const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const std::map<std::string, std::string>& parameters) {
1141  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_VSS, id, false) == nullptr) {
1142  // get NETEDIT parameters
1143  NeteditParameters neteditParameters(sumoBaseObject);
1144  // parse lanes
1145  std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, laneIDs);
1146  // check lane
1147  if (lanes.size() > 0) {
1148  // check vTypes
1149  if (!vTypes.empty() && !checkListOfVehicleTypes(vTypes)) {
1151  } else {
1152  // create VSS
1153  GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, pos, name, vTypes, parameters);
1154  // create VSS Symbols
1155  std::vector<GNEAdditional*> VSSSymbols;
1156  for (const auto& lane : lanes) {
1157  VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1158  }
1159  // insert depending of allowUndoRedo
1160  if (myAllowUndoRedo) {
1162  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1163  for (const auto& VSSSymbol : VSSSymbols) {
1164  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1165  }
1166  myNet->getViewNet()->getUndoList()->end();
1167  } else {
1168  myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1169  // add symbols
1170  for (int i = 0; i < (int)lanes.size(); i++) {
1171  lanes.at(i)->addChildElement(VSSSymbols.at(i));
1172  VSSSymbols.at(i)->incRef("buildVariableSpeedSignSymbol");
1173  }
1174  variableSpeedSign->incRef("buildVariableSpeedSign");
1175  }
1176  }
1177  }
1178  } else {
1180  }
1181 }
1182 
1183 
1184 void
1185 GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1186  // get VSS parent
1187  GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1188  // check lane
1189  if (VSS == nullptr) {
1191  } else if (time < 0) {
1193  /*
1194  } else if (speed < 0) {
1195  writeErrorInvalidNegativeValue(SUMO_TAG_STEP, VSS->getID(), SUMO_ATTR_SPEED);
1196  */
1197  } else {
1198  // create Variable Speed Sign
1199  GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1200  // add it depending of allow undoRedo
1201  if (myAllowUndoRedo) {
1202  myNet->getViewNet()->getUndoList()->begin(GUIIcon::VSSSTEP, "add " + variableSpeedSignStep->getTagStr());
1203  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1204  myNet->getViewNet()->getUndoList()->end();
1205  } else {
1206  VSS->addChildElement(variableSpeedSignStep);
1207  variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1208  }
1209  }
1210 }
1211 
1212 
1213 void
1214 GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1215  const SUMOTime endTime, const std::string& name, const std::map<std::string, std::string>& parameters) {
1216  // check conditions
1219  } else if (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_VAPORIZER, edgeID, false) == nullptr) {
1220  // get NETEDIT parameters
1221  NeteditParameters neteditParameters(sumoBaseObject);
1222  // get edge
1223  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1224  // check lane
1225  if (edge == nullptr) {
1227  } else if (beginTime < 0) {
1229  } else if (endTime < 0) {
1231  } else if (endTime < beginTime) {
1232  WRITE_ERROR("Could not build " + toString(SUMO_TAG_VAPORIZER) + " with ID '" + edge->getID() + "' in netedit; " + toString(SUMO_ATTR_BEGIN) + " is greather than " + toString(SUMO_ATTR_END) + ".");
1233  } else {
1234  // build vaporizer
1235  GNEAdditional* vaporizer = new GNEVaporizer(myNet, edge, beginTime, endTime, name, parameters);
1236  // add it depending of allow undoRed
1237  if (myAllowUndoRedo) {
1239  myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1240  myNet->getViewNet()->getUndoList()->end();
1241  // center after creation
1242  if (neteditParameters.centerAfterCreation) {
1243  myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1244  }
1245  } else {
1247  edge->addChildElement(vaporizer);
1248  vaporizer->incRef("buildVaporizer");
1249  }
1250  }
1251  } else {
1253  }
1254 }
1255 
1256 
1257 void
1258 GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1259  const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1260  const std::string& name, const std::map<std::string, std::string>& parameters) {
1261  // parse edges
1262  const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, edgeIDs);
1263  // check TAZShape
1264  PositionVector TAZShape = shape;
1265  if (TAZShape.size() == 0) {
1266  // declare boundary
1267  Boundary TAZBoundary;
1268  for (const auto& edge : edges) {
1269  TAZBoundary.add(edge->getCenteringBoundary());
1270  }
1271  // iterate over children and add sourceSinkEdge boundaries
1272  for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1273  const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1274  if (sourceSinkEdge) {
1275  TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1276  }
1277  }
1278  // update TAZShape
1279  TAZShape = TAZBoundary.getShape(true);
1280  }
1281  // check TAZ
1284  } else if (myNet->getAttributeCarriers()->retrieveTAZElement(SUMO_TAG_TAZ, id, false) != nullptr) {
1286  } else if (myNet->getAttributeCarriers()->retrieveShape(SUMO_TAG_POLY, id, false) != nullptr) {
1288  } else if (TAZShape.size() == 0) {
1289  WRITE_ERROR("Could not build " + toString(SUMO_TAG_TAZ) + " with ID '" + id + "' in netedit; Invalid Shape.");
1290  } else {
1291  // get NETEDIT parameters
1292  NeteditParameters neteditParameters(sumoBaseObject);
1293  // build TAZ with the given shape
1294  GNETAZElement* TAZ = new GNETAZ(id, myNet, TAZShape, center, fill, color, name, parameters);
1295  // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1297  // add it depending of allow undoRed
1298  if (myAllowUndoRedo) {
1300  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZ, true), true);
1301  // create TAZEdges
1302  for (const auto& edge : edges) {
1303  // create TAZ Source using GNEChange_Additional
1304  GNETAZElement* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1305  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZSource, true), true);
1306  // create TAZ Sink using GNEChange_Additional
1307  GNETAZElement* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1308  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZSink, true), true);
1309  }
1310  myNet->getViewNet()->getUndoList()->end();
1311  } else {
1313  TAZ->incRef("buildTAZ");
1314  for (const auto& edge : edges) {
1315  // create TAZ Source
1316  GNETAZElement* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1317  TAZSource->incRef("buildTAZ");
1318  TAZ->addChildElement(TAZSource);
1319  // create TAZ Sink
1320  GNETAZElement* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1321  TAZSink->incRef("buildTAZ");
1322  TAZ->addChildElement(TAZSink);
1323  }
1324  }
1325  // enable updating geometry again and update geometry of TAZ
1327  // update TAZ parent
1328  TAZ->updateGeometry();
1329  }
1330 }
1331 
1332 
1333 void
1334 GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1335  // get TAZ parent
1336  GNETAZElement* TAZ = getTAZParent(sumoBaseObject);
1337  // get edge
1338  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1339  // declare TAZ Sink
1340  GNETAZElement* TAZSink = nullptr;
1341  // check parents
1342  if (TAZ == nullptr) {
1344  } else if (edge == nullptr) {
1346  } else {
1347  // first check if a TAZSink in the same edge for the same TAZ
1348  for (const auto& TAZElement : TAZ->getChildTAZElements()) {
1349  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1350  TAZSink = TAZElement;
1351  }
1352  }
1353  // check if TAZSink has to be created
1354  if (TAZSink == nullptr) {
1355  // Create TAZ with weight 0 (default)
1356  TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 0);
1357  // add it depending of allow undoRed
1358  if (myAllowUndoRedo) {
1360  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZSink, true), true);
1361  myNet->getViewNet()->getUndoList()->end();
1362  } else {
1364  TAZSink->incRef("buildTAZSource");
1365  }
1366  }
1367  // now check check if TAZSource exist
1368  GNETAZElement* TAZSource = nullptr;
1369  // first check if a TAZSink in the same edge for the same TAZ
1370  for (const auto& TAZElement : TAZ->getChildTAZElements()) {
1371  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1372  TAZSource = TAZElement;
1373  }
1374  }
1375  // check if TAZSource has to be created
1376  if (TAZSource == nullptr) {
1377  // Create TAZ only with departWeight
1378  TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1379  // add it depending of allow undoRed
1380  if (myAllowUndoRedo) {
1382  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZSource, true), true);
1383  myNet->getViewNet()->getUndoList()->end();
1384  } else {
1386  TAZSource->incRef("buildTAZSource");
1387  }
1388  } else {
1389  // update TAZ Attribute depending of allow undoRed
1390  if (myAllowUndoRedo) {
1392  TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1393  myNet->getViewNet()->getUndoList()->end();
1394  } else {
1395  TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1396  TAZSource->incRef("buildTAZSource");
1397  }
1398  }
1399  }
1400 }
1401 
1402 
1403 void
1404 GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1405  // get TAZ parent
1406  GNETAZElement* TAZ = getTAZParent(sumoBaseObject);
1407  // get edge
1408  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1409  // check parents
1410  if (TAZ == nullptr) {
1412  } else if (edge == nullptr) {
1414  } else {
1415  // declare TAZ source
1416  GNETAZElement* TAZSource = nullptr;
1417  // first check if a TAZSink in the same edge for the same TAZ
1418  for (const auto& TAZElement : TAZ->getChildTAZElements()) {
1419  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1420  TAZSource = TAZElement;
1421  }
1422  }
1423  // check if TAZSource has to be created
1424  if (TAZSource == nullptr) {
1425  // Create TAZ with empty value
1426  TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 0);
1427  // add it depending of allow undoRed
1428  if (myAllowUndoRedo) {
1430  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZSource, true), true);
1431  myNet->getViewNet()->getUndoList()->end();
1432  } else {
1434  TAZSource->incRef("buildTAZSink");
1435  }
1436  }
1437  GNETAZElement* TAZSink = nullptr;
1438  // first check if a TAZSink in the same edge for the same TAZ
1439  for (const auto& TAZElement : TAZ->getChildTAZElements()) {
1440  if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1441  TAZSink = TAZElement;
1442  }
1443  }
1444  // check if TAZSink has to be created
1445  if (TAZSink == nullptr) {
1446  // Create TAZ only with arrivalWeight
1447  TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1448  // add it depending of allow undoRed
1449  if (myAllowUndoRedo) {
1451  myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZElement(TAZSink, true), true);
1452  myNet->getViewNet()->getUndoList()->end();
1453  } else {
1455  TAZSink->incRef("buildTAZSink");
1456  }
1457  } else {
1458  // update TAZ Attribute depending of allow undoRed
1459  if (myAllowUndoRedo) {
1461  TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1462  myNet->getViewNet()->getUndoList()->end();
1463  } else {
1464  TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1465  TAZSink->incRef("buildTAZSink");
1466  }
1467  }
1468  }
1469 }
1470 
1471 
1472 void
1473 GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1474  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill,
1475  double lineWidth, const std::string& name, const std::map<std::string, std::string>& parameters) {
1476  // check conditions
1479  } else if (myNet->getAttributeCarriers()->retrieveShape(SUMO_TAG_POLY, id, false) != nullptr) {
1481  } else if (myNet->getAttributeCarriers()->retrieveTAZElement(SUMO_TAG_TAZ, id, false) != nullptr) {
1483  } else if (lineWidth < 0) {
1485  } else {
1486  // get NETEDIT parameters
1487  NeteditParameters neteditParameters(sumoBaseObject);
1488  // create poly
1489  GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, name, parameters);
1490  // add it depending of allow undoRed
1491  if (myAllowUndoRedo) {
1493  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(poly, true), true);
1494  myNet->getViewNet()->getUndoList()->end();
1495  } else {
1496  // insert shape without allowing undo/redo
1498  poly->incRef("addPolygon");
1499  }
1500  }
1501 }
1502 
1503 
1504 void
1505 GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1506  const RGBColor& color, const double x, const double y, double layer, double angle, const std::string& imgFile, bool relativePath,
1507  double width, double height, const std::string& name, const std::map<std::string, std::string>& parameters) {
1508  // check conditions
1511  } else if (width < 0) {
1513  } else if (height < 0) {
1515  } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1517  } else if (myNet->getAttributeCarriers()->retrieveShape(SUMO_TAG_POI, id, false) == nullptr) {
1518  // get NETEDIT parameters
1519  NeteditParameters neteditParameters(sumoBaseObject);
1520  // create POI
1521  GNEPOI* POI = new GNEPOI(myNet, id, type, color, x, y, false, layer, angle, imgFile, relativePath, width, height, name, parameters);
1522  // add it depending of allow undoRed
1523  if (myAllowUndoRedo) {
1524  myNet->getViewNet()->getUndoList()->begin(GUIIcon::POI, "add " + POI->getTagStr());
1525  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(POI, true), true);
1526  myNet->getViewNet()->getUndoList()->end();
1527  } else {
1528  // insert shape without allowing undo/redo
1530  POI->incRef("addPOI");
1531  }
1532  } else {
1534  }
1535 }
1536 
1537 
1538 void
1539 GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1540  const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat, double layer, double angle,
1541  const std::string& imgFile, bool relativePath, double width, double height, const std::string& name, const std::map<std::string, std::string>& parameters) {
1542  // check conditions
1545  } else if (width < 0) {
1547  } else if (height < 0) {
1549  } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1551  } else if (myNet->getAttributeCarriers()->retrieveShape(SUMO_TAG_POI, id, false) == nullptr) {
1552  // get NETEDIT parameters
1553  NeteditParameters neteditParameters(sumoBaseObject);
1554  // get lane
1555  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1556  // check lane
1557  if (lane == nullptr) {
1559  } else if (!checkSinglePositionOverLane(posOverLane, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1561  } else {
1562  // create POI
1563  GNEShape* POILane = new GNEPOI(myNet, id, type, color, lane, posOverLane, friendlyPos, posLat, layer, angle, imgFile, relativePath, width, height, name, parameters);
1564  // add it depending of allow undoRed
1565  if (myAllowUndoRedo) {
1566  myNet->getViewNet()->getUndoList()->begin(GUIIcon::POILANE, "add " + POILane->getTagStr());
1567  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(POILane, true), true);
1568  myNet->getViewNet()->getUndoList()->end();
1569  } else {
1570  // insert shape without allowing undo/redo
1571  myNet->getAttributeCarriers()->insertShape(POILane);
1572  lane->addChildElement(POILane);
1573  POILane->incRef("buildPOILane");
1574  }
1575  }
1576  } else {
1578  }
1579 }
1580 
1581 
1582 void
1583 GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1584  const RGBColor& color, const double lon, const double lat, double layer, double angle, const std::string& imgFile, bool relativePath,
1585  double width, double height, const std::string& name, const std::map<std::string, std::string>& parameters) {
1586  // check conditions
1589  } else if (width < 0) {
1591  } else if (height < 0) {
1593  } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1595  } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1596  WRITE_ERROR("Could not build " + toString(SUMO_TAG_POI) + " with ID '" + id + "' in netedit; Networ requieres a geo projection.");
1597  } else if (myNet->getAttributeCarriers()->retrieveShape(SUMO_TAG_POI, id, false) == nullptr) {
1598  // get NETEDIT parameters
1599  NeteditParameters neteditParameters(sumoBaseObject);
1600  // create POIGEO
1601  GNEPOI* POIGEO = new GNEPOI(myNet, id, type, color, lon, lat, true, layer, angle, imgFile, relativePath, width, height, name, parameters);
1602  // add it depending of allow undoRed
1603  if (myAllowUndoRedo) {
1604  myNet->getViewNet()->getUndoList()->begin(GUIIcon::POIGEO, "add " + POIGEO->getTagStr());
1605  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(POIGEO, true), true);
1606  myNet->getViewNet()->getUndoList()->end();
1607  } else {
1608  // insert shape without allowing undo/redo
1610  POIGEO->incRef("buildPOIGeo");
1611  }
1612  } else {
1614  }
1615 }
1616 
1617 
1618 bool
1620  // check if exist another acces for the same busStop in the given edge
1621  for (const auto& additional : busStopParent->getChildAdditionals()) {
1622  for (const auto& lane : edge->getLanes()) {
1623  if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1624  return false;
1625  }
1626  }
1627  }
1628  return true;
1629 }
1630 
1631 
1632 bool
1634  // declare a vector to keep sorted rerouter children
1635  std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1636  // iterate over child additional
1637  for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1638  if (!rerouterChild->getTagProperty().isSymbol()) {
1639  sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1640  // set begin and end
1641  sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1642  sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1643  }
1644  }
1645  // add new intervals
1646  sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1647  // sort children
1648  std::sort(sortedIntervals.begin(), sortedIntervals.end());
1649  // check overlapping after sorting
1650  for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1651  if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1652  return false;
1653  }
1654  }
1655  return true;
1656 }
1657 
1658 
1659 bool
1660 GNEAdditionalHandler::checkSinglePositionOverLane(double pos, const double laneLength, const bool friendlyPos) {
1661  if (friendlyPos) {
1662  return true;
1663  }
1664  // adjust position (negative means that start at the end of lane and count backward)
1665  if (pos < 0) {
1666  pos += laneLength;
1667  }
1668  if ((pos < 0) || (pos > laneLength)) {
1669  return false;
1670  } else {
1671  return true;
1672  }
1673 }
1674 
1675 
1676 void
1677 GNEAdditionalHandler::fixSinglePositionOverLane(double& pos, const double laneLength) {
1678  if (pos < 0) {
1679  pos += laneLength;
1680  }
1681  // adjust pos (negative means that start at the end of lane and count backward)
1682  if (pos < 0) {
1683  pos = 0;
1684  } else if (pos > laneLength) {
1685  pos = laneLength;
1686  }
1687 }
1688 
1689 
1690 bool
1691 GNEAdditionalHandler::checkDoublePositionOverLane(double from, double to, const double laneLength, const bool friendlyPos) {
1692  if (friendlyPos) {
1693  return true;
1694  }
1695  // adjust from and to (negative means that start at the end of lane and count backward)
1696  if (from == INVALID_DOUBLE) {
1697  from = 0;
1698  }
1699  if (to == INVALID_DOUBLE) {
1700  to = laneLength;
1701  }
1702  if (from < 0) {
1703  from += laneLength;
1704  }
1705  if (to < 0) {
1706  to += laneLength;
1707  }
1708  if ((to - from) < POSITION_EPS) {
1709  return false;
1710  }
1711  if ((from < 0) || (from > laneLength)) {
1712  return false;
1713  }
1714  if ((to < 0) || (to > laneLength)) {
1715  return false;
1716  }
1717  return true;
1718 }
1719 
1720 
1721 void
1722 GNEAdditionalHandler::fixDoublePositionOverLane(double& from, double& to, const double laneLength) {
1723  // adjust from (negative means that start at the end of lane and count backward)
1724  if (from == INVALID_DOUBLE) {
1725  from = 0;
1726  }
1727  if (to == INVALID_DOUBLE) {
1728  to = laneLength;
1729  }
1730  if (from < 0) {
1731  from += laneLength;
1732  }
1733  if (from < 0) {
1734  from = 0;
1735  } else if (from > laneLength) {
1736  from = laneLength;
1737  }
1738  // adjust to
1739  if (to < 0) {
1740  to += laneLength;
1741  }
1742  if (to < 0) {
1743  to = 0;
1744  } else if (to > laneLength) {
1745  to = laneLength;
1746  }
1747  // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1748  if ((to - from) < POSITION_EPS) {
1749  if (to >= POSITION_EPS) {
1750  from = to - POSITION_EPS;
1751  } else {
1752  from = 0;
1753  to = POSITION_EPS;
1754  }
1755  }
1756 }
1757 
1758 
1759 bool
1760 GNEAdditionalHandler::checkE2SingleLanePosition(double pos, double length, const double laneLength, const bool friendlyPos) {
1761  if (friendlyPos) {
1762  return true;
1763  }
1764  // adjust from and to (negative means that start at the end of lane and count backward)
1765  if (pos < 0) {
1766  pos += laneLength;
1767  }
1768  if ((pos < 0) || (pos > laneLength)) {
1769  return false;
1770  }
1771  if ((pos + length) > laneLength) {
1772  return false;
1773  } else {
1774  return true;
1775  }
1776 }
1777 
1778 
1779 void
1780 GNEAdditionalHandler::fixE2SingleLanePosition(double& pos, double& length, const double laneLength) {
1781  // adjust from and to (negative means that start at the end of lane and count backward)
1782  if (pos < 0) {
1783  pos += laneLength;
1784  }
1785  if (pos < 0) {
1786  pos = 0;
1787  }
1788  if (length < 0) {
1789  length = POSITION_EPS;
1790  }
1791  if (pos > (laneLength - POSITION_EPS)) {
1792  pos = (laneLength - POSITION_EPS);
1793  length = POSITION_EPS;
1794  } else if ((pos + length) > laneLength) {
1795  length = (laneLength - pos);
1796  }
1797 }
1798 
1799 
1800 bool
1801 GNEAdditionalHandler::checkE2MultiLanePosition(double pos, const double fromLaneLength, double to, const double TolaneLength, const bool friendlyPos) {
1802  if (friendlyPos) {
1803  return true;
1804  } else {
1805  return (checkSinglePositionOverLane(pos, fromLaneLength, false) && checkSinglePositionOverLane(to, TolaneLength, false));
1806  }
1807 }
1808 
1809 
1810 void
1811 GNEAdditionalHandler::fixE2MultiLanePosition(double& pos, const double fromLaneLength, double& to, const double TolaneLength) {
1812  fixSinglePositionOverLane(pos, fromLaneLength);
1813  fixSinglePositionOverLane(to, TolaneLength);
1814 }
1815 
1816 
1817 void
1818 GNEAdditionalHandler::writeInvalidID(const SumoXMLTag tag, const std::string& id) const {
1819  WRITE_ERROR("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; ID contains invalid characters.");
1820 }
1821 
1822 
1823 void
1824 GNEAdditionalHandler::writeErrorInvalidPosition(const SumoXMLTag tag, const std::string& id) const {
1825  WRITE_ERROR("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; Invalid position over lane.");
1826 }
1827 
1828 
1829 void
1830 GNEAdditionalHandler::writeErrorDuplicated(const SumoXMLTag tag, const std::string& id) const {
1831  WRITE_ERROR("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; declared twice.");
1832 }
1833 
1834 
1835 void
1837  WRITE_ERROR("Could not build " + toString(tag) + " in netedit; " + toString(parent) + " doesn't exist.");
1838 }
1839 
1840 
1841 void
1842 GNEAdditionalHandler::writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute) const {
1843  WRITE_ERROR("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; attribute " + toString(attribute) + " cannot be negative.");
1844 }
1845 
1846 
1847 void
1848 GNEAdditionalHandler::writeErrorInvalidVTypes(const SumoXMLTag tag, const std::string& id) const {
1849  WRITE_ERROR("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; list of VTypes isn't valid.");
1850 }
1851 
1852 
1853 void
1854 GNEAdditionalHandler::writeErrorInvalidFilename(const SumoXMLTag tag, const std::string& id) const {
1855  WRITE_ERROR("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; filename is invalid.");
1856 }
1857 
1858 
1859 bool
1860 GNEAdditionalHandler::checkListOfVehicleTypes(const std::vector<std::string>& vTypeIDs) const {
1861  for (const auto& vTypeID : vTypeIDs) {
1862  if (!SUMOXMLDefinitions::isValidTypeID(vTypeID)) {
1863  return false;
1864  }
1865  }
1866  return true;
1867 }
1868 
1869 
1872  if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1873  return nullptr;
1874  } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
1875  return nullptr;
1876  } else {
1878  }
1879 }
1880 
1881 
1884  if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1885  // parent interval doesn't exist
1886  return nullptr;
1887  } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
1888  // rerouter parent doesn't exist
1889  return nullptr;
1890  } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
1891  !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
1892  !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
1893  return nullptr;
1894  } else {
1899  }
1900 }
1901 
1902 
1905  if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1906  return nullptr;
1907  } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
1908  return nullptr;
1909  } else {
1911  }
1912 }
1913 
1914 
1915 std::vector<GNEEdge*>
1916 GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::vector<std::string>& edgeIDs) const {
1917  std::vector<GNEEdge*> edges;
1918  for (const auto& edgeID : edgeIDs) {
1919  GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1920  // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
1921  if (edge == nullptr) {
1922  WRITE_ERROR("Could not build " + toString(tag) + " in netedit; " + toString(SUMO_TAG_EDGE) + " doesn't exist.");
1923  edges.clear();
1924  return edges;
1925  } else {
1926  edges.push_back(edge);
1927  }
1928  }
1929  return edges;
1930 }
1931 
1932 
1933 std::vector<GNELane*>
1934 GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::vector<std::string>& laneIDs) const {
1935  std::vector<GNELane*> lanes;
1936  for (const auto& laneID : laneIDs) {
1937  GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1938  // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
1939  if (lane == nullptr) {
1940  WRITE_ERROR("Could not build " + toString(tag) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
1941  lanes.clear();
1942  return lanes;
1943  } else {
1944  lanes.push_back(lane);
1945  }
1946  }
1947  return lanes;
1948 }
1949 
1950 
1952  myNet(nullptr),
1953  myAllowUndoRedo(false) {
1954 }
1955 
1956 // ===========================================================================
1957 // GNEAdditionalHandler::NeteditParameters method definitions
1958 // ===========================================================================
1959 
1961  select(sumoBaseObject->hasBoolAttribute(GNE_ATTR_SELECTED) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_SELECTED) : false),
1962  centerAfterCreation(sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) : false) {
1963 }
1964 
1965 
1967 
1968 
1970  select(false),
1971  centerAfterCreation(false) {
1972 }
1973 
1974 /****************************************************************************/
@ PARKINGSPACE
@ CLOSINGREROUTE
@ CONTAINERSTOP
@ ROUTEPROBREROUTE
@ CHARGINGSTATION
@ PARKINGZONEREROUTE
@ CLOSINGLANEREROUTE
@ DESTPROBREROUTE
@ REROUTERINTERVAL
@ VARIABLESPEEDSIGN
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ 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_LANECALIBRATOR
A calibrator placed over lane (used in netedit)
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_ENTRY
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ GNE_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ 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_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 destiny of a reroute
@ SUMO_TAG_E1DETECTOR
an e1 detector
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ 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
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_E3DETECTOR
an 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
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_LINEWIDTH
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_WEIGHT
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_FREQUENCY
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ROADSIDE_CAPACITY
@ 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.
const double INVALID_DOUBLE
Definition: StdDefs.h:63
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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:77
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition: Boundary.cpp:387
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
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 std::map< std::string, std::string > &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 std::map< std::string, std::string > &parameters)
Builds a VariableSpeedSign (lane speed additional)
void writeErrorInvalidVTypes(const SumoXMLTag tag, const std::string &id) const
write error "invalid list of vehicle types"
std::vector< GNELane * > parseLanes(const SumoXMLTag tag, const std::vector< std::string > &laneIDs) const
parse lanes
GNEAdditional * getRerouterIntervalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get rerouter interval parent
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 freq, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const std::map< std::string, std::string > &parameters)
builds a microscopic calibrator over an edge
void buildPOI(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double x, const double y, const double layer, const double angle, const std::string &imgFile, bool relativePath, const double width, const double height, const std::string &name, const std::map< std::string, std::string > &parameters)
Builds a POI using the given values.
void buildAccess(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const double length, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds an Access.
static bool accessCanBeCreated(GNEAdditional *busStopParent, GNEEdge *edge)
check if a GNEAccess can be created in a certain Edge
void buildTAZSink(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double arrivalWeight)
Builds a TAZSink (Traffic Assignment Zone)
void buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime time, const std::string &speed)
Builds a VariableSpeedSign Step.
void buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &lanes, const double pos, const double endPos, const SUMOTime freq, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds a multi-lane Area Detector (E2)
GNEAdditional * getAdditionalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, SumoXMLTag tag) const
get additional parent
void buildVaporizer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const SUMOTime from, const SUMOTime endTime, const std::string &name, const std::map< std::string, std::string > &parameters)
Builds a vaporizer (lane speed additional)
static void fixE2MultiLanePosition(double &pos, const double fromLaneLength, double &to, const double TolaneLength)
fix the given positions over lane
void writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute) const
write error "invalid negative element"
void buildRerouterInterval(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime begin, const SUMOTime end)
builds a rerouter interval
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 std::map< std::string, std::string > &parameters)
Builds a train stop.
void buildCalibratorFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameter)
builds a calibrator flow
void buildE1Detector(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double position, const SUMOTime frequency, const std::string &file, const std::vector< std::string > &vehicleTypes, const std::string &name, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds a induction loop detector (E1)
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 double layer, const double angle, const std::string &imgFile, const bool relativePath, const double width, const double height, const std::string &name, const std::map< std::string, std::string > &parameters)
Builds a POI over lane using the given values.
void buildDetectorE3(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const SUMOTime freq, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const std::map< std::string, std::string > &parameters)
Builds a multi entry exit detector (E3)
static void fixDoublePositionOverLane(double &from, double &to, const double laneLengt)
fix the given positions over lane
void writeErrorDuplicated(const SumoXMLTag tag, const std::string &id) const
write error "duplicated additional"
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 std::map< std::string, std::string > &parameters)
Builds a bus stop.
void writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id) const
write error "invalid position"
static void fixE2SingleLanePosition(double &pos, double &length, const double laneLength)
fix the given positions over lane
void writeErrorInvalidFilename(const SumoXMLTag tag, const std::string &id) const
write error "invalid filename"
static bool checkSinglePositionOverLane(double pos, const double laneLength, const bool friendlyPos)
check if the given position over a lane is valid
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 std::map< std::string, std::string > &parameters)
Builds a container stop.
void buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedLane, SVCPermissions permissions)
builds a closing lane reroute
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 freq, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const std::map< std::string, std::string > &parameters)
builds a microscopic calibrator over a lane
void buildClosingReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedEdgeID, SVCPermissions permissions)
builds a closing edge reroute
void buildDetectorEntry(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds a entry detector (E3)
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 bool friendlyPosition, const std::map< std::string, std::string > &parameters)
Builds a charging Station.
static bool checkDoublePositionOverLane(double from, const double to, const double laneLength, const bool friendlyPos)
check if the given positions over a lane is valid
void buildDestProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newEdgeDestinationID, const double probability)
builds a dest prob 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 std::map< std::string, std::string > &parameters)
Builds a Parking Space.
bool checkListOfVehicleTypes(const std::vector< std::string > &vTypeIDs) const
check list of IDs
const bool myAllowUndoRedo
allow undo/redo
void buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newParkignAreaID, const double probability, const bool visible)
builds a parking area reroute
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 bool friendlyPosition, const int roadSideCapacity, const bool onRoad, const double width, const double length, const double angle, const std::map< std::string, std::string > &parameters)
Builds a Parking Area.
GNEAdditionalHandler()
invalidate default constructo
void writeErrorInvalidParent(const SumoXMLTag tag, const SumoXMLTag parent) const
write error "invalid parent element"
static bool checkE2MultiLanePosition(double pos, const double fromLaneLength, const double to, const double TolaneLength, const bool friendlyPos)
check if the given positions over a lane is valid
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::string &name, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds a Instant Induction Loop Detector (E1Instant)
GNETAZElement * getTAZParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get TAZ parent
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
GNENet * myNet
pointer to GNENet
static void fixSinglePositionOverLane(double &pos, const double laneLength)
fix given position over lane
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 std::string &file, const bool off, const SUMOTime timeThreshold, const std::vector< std::string > &vTypes, const std::map< std::string, std::string > &parameters)
builds a rerouter
void buildRouteProbe(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &edgeID, const SUMOTime freq, const std::string &name, const std::string &file, const SUMOTime begin, const std::map< std::string, std::string > &parameters)
builds a Route probe
std::vector< GNEEdge * > parseEdges(const SumoXMLTag tag, const std::vector< std::string > &edgeIDs) const
parse edges
void buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newRouteID, const double probability)
builds a route prob reroute
void writeInvalidID(const SumoXMLTag tag, const std::string &id) const
write invalid id
void buildTAZSource(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double departWeight)
Builds a TAZSource (Traffic Assignment Zone)
void buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const double length, const SUMOTime freq, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds a single-lane Area Detector (E2)
void buildDetectorExit(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Builds a exit detector (E3)
void buildPOIGeo(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double lon, const double lat, const double layer, const double angle, const std::string &imgFile, bool relativePath, const double width, const double height, const std::string &name, const std::map< std::string, std::string > &parameters)
Builds a POI in GEO coordinaten using the given values.
static bool checkE2SingleLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos)
check if the given positions over a lane is valid
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 std::map< std::string, std::string > &parameters)
Builds a TAZ (Traffic Assignment Zone)
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
const std::string & getID() const
get ID
virtual void updateGeometry()=0
update pre-computed geometry information
virtual Position getPositionInView() const =0
Returns position of additional in view.
const std::string & getTagStr() const
get tag assigned to this object in string format
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:33
A lane area vehicles can halt at (netedit-version)
An Element which don't belongs to GNENet but has influency in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:435
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:782
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:119
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:113
GNETAZElement * retrieveTAZElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named TAZElement.
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEShape * retrieveShape(SumoXMLTag, const std::string &id, bool hardFail=true) const
Returns the named shape.
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
void insertShape(GNEShape *shape)
Insert a shape element int GNENet container.
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
void insertTAZElement(GNETAZElement *TAZElement)
Insert a TAZElement element int GNENet container.
void insertAdditional(GNEAdditional *additional)
Insert a additional element int GNENet 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 disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition: GNENet.cpp:2455
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1964
void enableUpdateGeometry()
Definition: GNENet.cpp:2449
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string & getID() const
get ID
Definition: GNEPOI.h:43
A lane area vehicles can park at (netedit-version)
vehicle space used by GNEParkingAreas
void incRef(const std::string &debugMsg="")
Increarse reference.
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:32
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform TAZElement changes
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:4354
C++ TraCI client API implementation.
Definition: GUI.h:31
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:293
A list of positions.
double length2D() const
Returns the length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
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)
const bool centerAfterCreation
center view after creation