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>
22#include <netedit/GNEViewNet.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNENet.h>
25
27#include "GNEAccess.h"
28#include "GNEBusStop.h"
29#include "GNECalibrator.h"
30#include "GNECalibratorFlow.h"
31#include "GNEChargingStation.h"
33#include "GNEClosingReroute.h"
34#include "GNEContainerStop.h"
35#include "GNEDestProbReroute.h"
38#include "GNELaneAreaDetector.h"
41#include "GNEOverheadWire.h"
42#include "GNEPOI.h"
43#include "GNEParkingArea.h"
45#include "GNEParkingSpace.h"
46#include "GNEPoly.h"
47#include "GNERerouter.h"
48#include "GNERerouterInterval.h"
49#include "GNERerouterSymbol.h"
50#include "GNERouteProbReroute.h"
51#include "GNERouteProbe.h"
52#include "GNETAZ.h"
53#include "GNETAZSourceSink.h"
55#include "GNEVaporizer.h"
59
60
61// ===========================================================================
62// GNEAdditionalHandler method definitions
63// ===========================================================================
64
65GNEAdditionalHandler::GNEAdditionalHandler(GNENet* net, const bool allowUndoRedo, const bool overwrite) :
66 myNet(net),
67 myAllowUndoRedo(allowUndoRedo),
68 myOverwrite(overwrite) {
69}
70
71
73}
74
75
76void
78 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
79 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
80 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
81 // check conditions
85 // get NETEDIT parameters
86 NeteditParameters neteditParameters(sumoBaseObject);
87 // get lane
88 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
89 // check lane
90 if (lane == nullptr) {
92 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
94 } else if (personCapacity < 0) {
96 } else if (parkingLength < 0) {
98 } else {
99 // build busStop
100 GNEAdditional* busStop = new GNEBusStop(SUMO_TAG_BUS_STOP, id, lane, myNet, startPos, endPos, name, lines, personCapacity,
101 parkingLength, color, friendlyPosition, parameters);
102 // insert depending of allowUndoRedo
103 if (myAllowUndoRedo) {
104 myNet->getViewNet()->getUndoList()->begin(GUIIcon::BUSSTOP, "add " + toString(SUMO_TAG_BUS_STOP) + " '" + id + "'");
106 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
108 } else {
110 lane->addChildElement(busStop);
111 busStop->incRef("buildBusStop");
112 }
113 }
114 } else {
116 }
117}
118
119
120void
122 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
123 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
124 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
125 // check conditions
129 // get NETEDIT parameters
130 NeteditParameters neteditParameters(sumoBaseObject);
131 // get lane
132 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
133 // check lane
134 if (lane == nullptr) {
136 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
138 } else if (personCapacity < 0) {
140 } else if (parkingLength < 0) {
142 } else {
143 // build trainStop
144 GNEAdditional* trainStop = new GNEBusStop(SUMO_TAG_TRAIN_STOP, id, lane, myNet, startPos, endPos, name, lines, personCapacity,
145 parkingLength, color, friendlyPosition, parameters);
146 // insert depending of allowUndoRedo
147 if (myAllowUndoRedo) {
150 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(trainStop, true), true);
152 } else {
154 lane->addChildElement(trainStop);
155 trainStop->incRef("buildTrainStop");
156 }
157 }
158 } else {
160 }
161}
162
163
164void
165GNEAdditionalHandler::buildAccess(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID,
166 const double pos, const double length, const bool friendlyPos, const Parameterised::Map& parameters) {
167 // get NETEDIT parameters
168 NeteditParameters neteditParameters(sumoBaseObject);
169 // get lane
170 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
171 // get busStop (or trainStop)
172 GNEAdditional* busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_BUS_STOP);
173 if (busStop == nullptr) {
174 busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_TRAIN_STOP);
175 }
176 // Check if busStop parent and lane is correct
177 if (lane == nullptr) {
179 } else if (busStop == nullptr) {
181 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
183 } else if ((length != -1) && (length < 0)) {
185 } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
186 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() + "'");
187 } else if (!lane->allowPedestrians()) {
188 WRITE_WARNING("Could not build " + toString(SUMO_TAG_ACCESS) + " in netedit; The " + toString(SUMO_TAG_LANE) + " '" + lane->getID() + "' doesn't support pedestrians");
189 } else {
190 // build access
191 GNEAdditional* access = new GNEAccess(busStop, lane, myNet, pos, length, friendlyPos, parameters);
192 // insert depending of allowUndoRedo
193 if (myAllowUndoRedo) {
194 myNet->getViewNet()->getUndoList()->begin(GUIIcon::ACCESS, "add " + toString(SUMO_TAG_ACCESS) + "in '" + busStop->getID() + "'");
196 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(access, true), true);
198 } else {
200 lane->addChildElement(access);
201 busStop->addChildElement(access);
202 access->incRef("buildAccess");
203 }
204 }
205}
206
207
208void
209GNEAdditionalHandler::buildContainerStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
210 const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines, const int containerCapacity,
211 const double parkingLength, const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
212 // check conditions
216 // get NETEDIT parameters
217 NeteditParameters neteditParameters(sumoBaseObject);
218 // get lane
219 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
220 // check lane
221 if (lane == nullptr) {
223 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
225 } else if (containerCapacity < 0) {
227 } else if (parkingLength < 0) {
229 } else {
230 // build containerStop
231 GNEAdditional* containerStop = new GNEContainerStop(id, lane, myNet, startPos, endPos, name, lines, containerCapacity, parkingLength,
232 color, friendlyPosition, parameters);
233 // insert depending of allowUndoRedo
234 if (myAllowUndoRedo) {
237 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
239 } else {
241 lane->addChildElement(containerStop);
242 containerStop->incRef("buildContainerStop");
243 }
244 }
245 } else {
247 }
248}
249
250
251void
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 Parameterised::Map& parameters) {
256 // check conditions
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 (!checkLaneDoublePosition(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) {
281 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
283 } else {
284 myNet->getAttributeCarriers()->insertAdditional(chargingStation);
285 lane->addChildElement(chargingStation);
286 chargingStation->incRef("buildChargingStation");
287 }
288 }
289 } else {
291 }
292
293}
294
295
296void
297GNEAdditionalHandler::buildParkingArea(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
298 const double startPos, const double endPos, const std::string& departPos, const std::string& name, const bool friendlyPosition,
299 const int roadSideCapacity, const bool onRoad, const double width, const double length, const double angle, const Parameterised::Map& parameters) {
300 // check conditions
304 // get NETEDIT parameters
305 NeteditParameters neteditParameters(sumoBaseObject);
306 // get lane
307 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
308 // get departPos double
309 const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
310 // check lane
311 if (lane == nullptr) {
313 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
315 } else if (roadSideCapacity < 0) {
317 } else if (width < 0) {
319 } else if (length < 0) {
321 } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
322 writeError("Could not build " + toString(SUMO_TAG_PARKING_AREA) + " with ID '" + id + "' in netedit; Invalid " + toString(SUMO_ATTR_DEPARTPOS) + " over lane.");
323 } else {
324 // build parkingArea
325 GNEAdditional* parkingArea = new GNEParkingArea(id, lane, myNet, startPos, endPos, GNEAttributeCarrier::canParse<double>(departPos) ? departPos : "",
326 name, friendlyPosition, roadSideCapacity, onRoad,
327 (width == 0) ? SUMO_const_laneWidth : width, length, angle, parameters);
328 // insert depending of allowUndoRedo
329 if (myAllowUndoRedo) {
332 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
334 } else {
336 lane->addChildElement(parkingArea);
337 parkingArea->incRef("buildParkingArea");
338 }
339 }
340 } else {
342 }
343}
344
345
346void
347GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
348 const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
349 const Parameterised::Map& parameters) {
350 // check width and heights
351 if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
352 writeError("Could not build " + toString(SUMO_TAG_PARKING_SPACE) + "' in netedit; attribute " + toString(SUMO_ATTR_WIDTH) + " cannot be parse to float.");
353 } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
354 writeError("Could not build " + toString(SUMO_TAG_PARKING_SPACE) + "' in netedit; attribute " + toString(SUMO_ATTR_LENGTH) + " cannot be parse to float.");
355 } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
356 writeError("Could not build " + toString(SUMO_TAG_PARKING_SPACE) + "' in netedit; attribute " + toString(SUMO_ATTR_ANGLE) + " cannot be parse to float.");
357 } else {
358 // get NETEDIT parameters
359 NeteditParameters neteditParameters(sumoBaseObject);
360 // get lane
361 GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
362 // get double values
363 const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
364 const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
365 // check lane
366 if (parkingArea == nullptr) {
368 } else if (widthDouble < 0) {
370 } else if (lengthDouble < 0) {
372 } else {
373 // build parkingSpace
374 GNEAdditional* parkingSpace = new GNEParkingSpace(myNet, parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
375 // insert depending of allowUndoRedo
376 if (myAllowUndoRedo) {
377 myNet->getViewNet()->getUndoList()->begin(GUIIcon::PARKINGSPACE, "add " + toString(SUMO_TAG_PARKING_SPACE) + " in '" + parkingArea->getID() + "'");
379 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
381 } else {
383 parkingArea->addChildElement(parkingSpace);
384 parkingSpace->incRef("buildParkingSpace");
385 }
386 // update geometry (due boundaries)
387 parkingSpace->updateGeometry();
388 }
389 }
390}
391
392
393void
394GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
395 const double position, const SUMOTime period, const std::string& file, const std::vector<std::string>& vehicleTypes, const std::string& name,
396 const bool friendlyPos, const Parameterised::Map& parameters) {
397 // check conditions
401 // get NETEDIT parameters
402 NeteditParameters neteditParameters(sumoBaseObject);
403 // get lane
404 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
405 // check lane
406 if (lane == nullptr) {
408 } else if (!checkLanePosition(position, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
410 } else if (period < 0) {
412 } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
414 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
416 } else {
417 // build E1
418 GNEAdditional* detectorE1 = new GNEInductionLoopDetector(id, lane, myNet, position, period, file, vehicleTypes, name, friendlyPos, parameters);
419 // insert depending of allowUndoRedo
420 if (myAllowUndoRedo) {
421 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E1, "add " + toString(SUMO_TAG_INDUCTION_LOOP) + " '" + id + "'");
423 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
425 } else {
427 lane->addChildElement(detectorE1);
428 detectorE1->incRef("buildDetectorE1");
429 }
430 }
431 } else {
433 }
434}
435
436
437void
438GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
439 const double pos, const double length, const SUMOTime period, const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
440 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
441 const Parameterised::Map& parameters) {
442 // check conditions
446 // get NETEDIT parameters
447 NeteditParameters neteditParameters(sumoBaseObject);
448 // get lane
449 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
450 // check lane
451 if (lane == nullptr) {
453 } else if (!checkLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
455 } else if (length < 0) {
457 } else if ((period != -1) && (period < 0)) {
459 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
460 // temporal
461 writeError("Could not build " + toString(SUMO_TAG_LANE_AREA_DETECTOR) + " with ID '" + id + "' in netedit; invalid traffic light ID.");
462 } else if (timeThreshold < 0) {
464 } else if (speedThreshold < 0) {
466 } else if (jamThreshold < 0) {
468 } else if (timeThreshold < 0) {
470 } else if (speedThreshold < 0) {
472 } else if (jamThreshold < 0) {
474 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
476 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
478 } else {
479 // build E2 single lane
480 GNEAdditional* detectorE2 = new GNELaneAreaDetector(
481 id, lane, myNet, pos, length, period, trafficLight, filename,
482 vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold,
483 friendlyPos, parameters);
484 // insert depending of allowUndoRedo
485 if (myAllowUndoRedo) {
488 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
490 } else {
492 lane->addChildElement(detectorE2);
493 detectorE2->incRef("buildDetectorE2");
494 }
495 }
496 } else {
498 }
499}
500
501
502void
503GNEAdditionalHandler::buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::vector<std::string>& laneIDs,
504 const double pos, const double endPos, const SUMOTime period, const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
505 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
506 const Parameterised::Map& parameters) {
507 // check conditions
511 // get NETEDIT parameters
512 NeteditParameters neteditParameters(sumoBaseObject);
513 // get lanes
514 const auto lanes = parseLanes(SUMO_TAG_LANE_AREA_DETECTOR, laneIDs);
515 // check lanes
516 if (lanes.size() > 0) {
517 // calculate path
519 writeError("Could not build " + toString(SUMO_TAG_LANE_AREA_DETECTOR) + " with ID '" + id + "' in netedit; Lanes aren't consecutives.");
520 } else if (!checkMultiLanePosition(
521 pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
522 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
524 } else if ((period != -1) && (period < 0)) {
526 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
527 // temporal
528 writeError("Could not build " + toString(SUMO_TAG_LANE_AREA_DETECTOR) + " with ID '" + id + "' in netedit; invalid traffic light ID.");
529 } else if (timeThreshold < 0) {
531 } else if (speedThreshold < 0) {
533 } else if (jamThreshold < 0) {
535 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
537 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
539 } else {
540 // build E2 multilane detector
541 GNEAdditional* detectorE2 = new GNELaneAreaDetector(
542 id, lanes, myNet, pos, endPos, period, trafficLight, filename,
543 vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold,
544 friendlyPos, parameters);
545 // insert depending of allowUndoRedo
546 if (myAllowUndoRedo) {
549 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
551 } else {
553 for (const auto& lane : lanes) {
554 lane->addChildElement(detectorE2);
555 }
556 detectorE2->incRef("buildDetectorE2Multilane");
557 }
558 }
559 } else {
561 }
562 } else {
564 }
565}
566
567
568void
569GNEAdditionalHandler::buildDetectorE3(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos, const SUMOTime period,
570 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, const SUMOTime timeThreshold, const double speedThreshold,
571 const Parameterised::Map& parameters) {
572 // check conditions
575 } else if (period < 0) {
577 } else if (timeThreshold < 0) {
579 } else if (speedThreshold < 0) {
581 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
583 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
586 // get NETEDIT parameters
587 NeteditParameters neteditParameters(sumoBaseObject);
588 // build E3
589 GNEAdditional* E3 = new GNEMultiEntryExitDetector(id, myNet, pos, period, filename, vehicleTypes, name, timeThreshold, speedThreshold, parameters);
590 // insert depending of allowUndoRedo
591 if (myAllowUndoRedo) {
594 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
596 } else {
598 E3->incRef("buildDetectorE3");
599 }
600 } else {
602 }
603}
604
605
606void
607GNEAdditionalHandler::buildDetectorEntry(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
608 const bool friendlyPos, const Parameterised::Map& parameters) {
609 // get lane
610 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
611 // get E3 parent
613 // Check if Detector E3 parent and lane is correct
614 if (lane == nullptr) {
616 } else if (E3 == nullptr) {
618 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
620 } else {
621 // get NETEDIT parameters
622 NeteditParameters neteditParameters(sumoBaseObject);
623 // build entry instant
624 GNEAdditional* entry = new GNEEntryExitDetector(SUMO_TAG_DET_ENTRY, myNet, E3, lane, pos, friendlyPos, parameters);
625 // insert depending of allowUndoRedo
626 if (myAllowUndoRedo) {
627 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E3ENTRY, "add " + toString(SUMO_TAG_DET_ENTRY) + " in '" + E3->getID() + "'");
629 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
631 } else {
633 lane->addChildElement(entry);
634 E3->addChildElement(entry);
635 entry->incRef("buildDetectorEntry");
636 }
637 }
638}
639
640
641void
642GNEAdditionalHandler::buildDetectorExit(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
643 const bool friendlyPos, const Parameterised::Map& parameters) {
644 // get lane
645 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
646 // get E3 parent
648 // Check if Detector E3 parent and lane is correct
649 if (lane == nullptr) {
651 } else if (E3 == nullptr) {
653 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
655 } else {
656 // get NETEDIT parameters
657 NeteditParameters neteditParameters(sumoBaseObject);
658 // build exit instant
659 GNEAdditional* exit = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet, E3, lane, pos, friendlyPos, parameters);
660 // insert depending of allowUndoRedo
661 if (myAllowUndoRedo) {
662 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E3EXIT, "add " + toString(SUMO_TAG_DET_EXIT) + " in '" + E3->getID() + "'");
664 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
666 } else {
668 lane->addChildElement(exit);
669 E3->addChildElement(exit);
670 exit->incRef("buildDetectorExit");
671 }
672 }
673}
674
675
676void
677GNEAdditionalHandler::buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, double pos,
678 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters) {
679 // check conditions
683 // get NETEDIT parameters
684 NeteditParameters neteditParameters(sumoBaseObject);
685 // get lane
686 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
687 // check lane
688 if (lane == nullptr) {
690 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
692 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
694 } else {
695 // build E1 instant
696 GNEAdditional* detectorE1Instant = new GNEInstantInductionLoopDetector(id, lane, myNet, pos, filename, vehicleTypes, name, friendlyPos, parameters);
697 // insert depending of allowUndoRedo
698 if (myAllowUndoRedo) {
701 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
703 } else {
704 myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
705 lane->addChildElement(detectorE1Instant);
706 detectorE1Instant->incRef("buildDetectorE1Instant");
707 }
708 }
709 } else {
711 }
712}
713
714
715void
716GNEAdditionalHandler::buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, const double pos,
717 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
718 const Parameterised::Map& parameters) {
719 // get lane
720 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
721 // get routeProbe
722 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
723 // check conditions
728 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
730 } else if (lane == nullptr) {
732 } else {
733 // get NETEDIT parameters
734 NeteditParameters neteditParameters(sumoBaseObject);
735 // check lane
736 if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
738 } else if (period < 0) {
740 } else if (jamThreshold < 0) {
742 } else {
743 // build Calibrator
744 GNEAdditional* calibrator = (routeProbe == nullptr) ?
745 new GNECalibrator(id, myNet, lane, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
746 new GNECalibrator(id, myNet, lane, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
747 // insert depending of allowUndoRedo
748 if (myAllowUndoRedo) {
751 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
753 // center after creation
754 if (neteditParameters.centerAfterCreation) {
755 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
756 }
757 } else {
759 lane->addChildElement(calibrator);
760 if (routeProbe) {
761 routeProbe->addChildElement(calibrator);
762 }
763 calibrator->incRef("buildCalibrator");
764 }
765 }
766 }
767}
768
769
770void
771GNEAdditionalHandler::buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const double pos,
772 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
773 const Parameterised::Map& parameters) {
774 // get edge
775 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
776 // get routeProbe
777 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
778 // check conditions
783 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
785 } else if (edge == nullptr) {
787 } else {
788 // get NETEDIT parameters
789 NeteditParameters neteditParameters(sumoBaseObject);
790 if (!checkLanePosition(pos, 0, edge->getLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
792 } else if (period < 0) {
794 } else if (jamThreshold < 0) {
796 } else {
797 // build Calibrator
798 GNEAdditional* calibrator = (routeProbe == nullptr) ?
799 new GNECalibrator(id, myNet, edge, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
800 new GNECalibrator(id, myNet, edge, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
801 // insert depending of allowUndoRedo
802 if (myAllowUndoRedo) {
805 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
807 // center after creation
808 if (neteditParameters.centerAfterCreation) {
809 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
810 }
811 } else {
813 edge->addChildElement(calibrator);
814 if (routeProbe) {
815 routeProbe->addChildElement(calibrator);
816 }
817 calibrator->incRef("buildCalibrator");
818 }
819 }
820 }
821}
822
823
824void
826 // get vType
827 GNEDemandElement* vType = myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, vehicleParameter.vtypeid.empty() ? DEFAULT_VTYPE_ID : vehicleParameter.vtypeid, false);
828 // get route
830 // get calibrator parent
832 // check parents
833 if (vType == nullptr) {
835 } else if (route == nullptr) {
837 } else if (calibrator == nullptr) {
839 } else {
840 // create calibrator flow
841 GNEAdditional* flow = new GNECalibratorFlow(calibrator, vType, route, vehicleParameter);
842 // insert depending of allowUndoRedo
843 if (myAllowUndoRedo) {
844 myNet->getViewNet()->getUndoList()->begin(GUIIcon::FLOW, "add " + flow->getTagStr() + " in '" + calibrator->getID() + "'");
846 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
848 } else {
849 calibrator->addChildElement(flow);
850 route->addChildElement(flow);
851 vType->addChildElement(flow);
852 flow->incRef("buildCalibratorFlow");
853 }
854 }
855}
856
857
858void
859GNEAdditionalHandler::buildRerouter(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
860 const std::vector<std::string>& edgeIDs, const double prob, const std::string& name, const bool off, const SUMOTime timeThreshold,
861 const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
862 // check conditions
865 } else if (prob < 0) {
867 } else if (timeThreshold < 0) {
869 } else if (!vTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vTypes)) {
872 // get NETEDIT parameters
873 NeteditParameters neteditParameters(sumoBaseObject);
874 // parse edges
875 std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, edgeIDs);
876 // check edges
877 if (edges.size() > 0) {
878 GNEAdditional* rerouter = nullptr;
879 // continue depending of position
880 if (pos == Position::INVALID) {
881 if (edges.size() > 0) {
882 PositionVector laneShape = edges.front()->getLanes().front()->getLaneShape();
883 // move to side
884 laneShape.move2side(3);
885 // create rerouter
886 rerouter = new GNERerouter(id, myNet, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, prob, off, timeThreshold, vTypes, parameters);
887 } else {
888 rerouter = new GNERerouter(id, myNet, Position(0, 0), name, prob, off, timeThreshold, vTypes, parameters);
889 }
890 } else {
891 rerouter = new GNERerouter(id, myNet, pos, name, prob, off, timeThreshold, vTypes, parameters);
892 }
893 // create rerouter Symbols
894 std::vector<GNEAdditional*> rerouterSymbols;
895 for (const auto& edge : edges) {
896 rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
897 }
898 // insert depending of allowUndoRedo
899 if (myAllowUndoRedo) {
900 myNet->getViewNet()->getUndoList()->begin(GUIIcon::REROUTER, "add " + toString(SUMO_TAG_REROUTER) + " '" + id + "'");
902 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
903 // add symbols
904 for (const auto& rerouterSymbol : rerouterSymbols) {
905 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
906 }
908 } else {
910 rerouter->incRef("buildRerouter");
911 // add symbols into rerouter
912 for (const auto& rerouterSymbol : rerouterSymbols) {
913 rerouter->addChildElement(rerouterSymbol);
914 }
915 // add symbols into edges
916 for (int i = 0; i < (int)edges.size(); i++) {
917 edges.at(i)->addChildElement(rerouterSymbols.at(i));
918 }
919 }
920 }
921 } else {
923 }
924}
925
926
927void
929 // get rerouter parent
930 GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
931 // check if rerouter exist
932 if (rerouter == nullptr) {
934 } else if (begin < 0) {
936 } else if (end < 0) {
938 } else if (end < begin) {
939 writeError("Could not build " + toString(SUMO_TAG_INTERVAL) + " with ID '" + rerouter->getID() + "' in netedit; " + toString(SUMO_ATTR_BEGIN) + " is greather than " + toString(SUMO_ATTR_END) + ".");
940 } else {
941 // check if new interval will produce a overlapping
942 if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
943 // create rerouter interval and add it into rerouter parent
944 GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
945 // insert depending of allowUndoRedo
946 if (myAllowUndoRedo) {
947 myNet->getViewNet()->getUndoList()->begin(GUIIcon::REROUTERINTERVAL, "add " + rerouterInterval->getTagStr() + " in '" + rerouter->getID() + "'");
949 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
951 } else {
952 rerouter->addChildElement(rerouterInterval);
953 rerouterInterval->incRef("buildRerouterInterval");
954 }
955 } else {
956 writeError("Could not build " + toString(SUMO_TAG_INTERVAL) + " with begin '" + toString(begin) + "' and '" + toString(end) + "' in '" + rerouter->getID() + "' due overlapping.");
957 }
958 }
959}
960
961
962void
963GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
964 // get rerouter interval parent
965 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
966 // get closed lane
967 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
968 // check parents
969 if (lane == nullptr) {
971 } else if (rerouterInterval == nullptr) {
973 } else {
974 // create closing lane reroute
975 GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
976 // add it to interval parent depending of allowUndoRedo
977 if (myAllowUndoRedo) {
978 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CLOSINGLANEREROUTE, "add " + closingLaneReroute->getTagStr() + " in '" + lane->getID() + "'");
980 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
982 } else {
983 rerouterInterval->addChildElement(closingLaneReroute);
984 closingLaneReroute->incRef("buildClosingLaneReroute");
985 }
986 }
987}
988
989
990void
991GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
992 // get rerouter interval parent
993 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
994 // get closed edge
995 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
996 // check parents
997 if (edge == nullptr) {
999 } else if (rerouterInterval == nullptr) {
1001 } else {
1002 // create closing reroute
1003 GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
1004 // add it to interval parent depending of allowUndoRedo
1005 if (myAllowUndoRedo) {
1006 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CLOSINGREROUTE, "add " + closingLaneReroute->getTagStr() + " in '" + edge->getID() + "'");
1008 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1010 } else {
1011 rerouterInterval->addChildElement(closingLaneReroute);
1012 closingLaneReroute->incRef("buildClosingLaneReroute");
1013 }
1014 }
1015}
1016
1017void
1018GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1019 // get rerouter interval parent
1020 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1021 // get edge
1022 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1023 // check parents
1024 if (edge == nullptr) {
1026 } else if (rerouterInterval == nullptr) {
1028 } else {
1029 // create dest probability reroute
1030 GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1031 // add it to interval parent depending of allowUndoRedo
1032 if (myAllowUndoRedo) {
1033 myNet->getViewNet()->getUndoList()->begin(GUIIcon::DESTPROBREROUTE, "add " + destProbReroute->getTagStr() + " in '" + edge->getID() + "'");
1035 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1037 } else {
1038 rerouterInterval->addChildElement(destProbReroute);
1039 destProbReroute->incRef("builDestProbReroute");
1040 }
1041 }
1042}
1043
1044
1045void
1046GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1047 // get rerouter interval parent
1048 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1049 // get parking area
1050 GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1051 // check parents
1052 if (rerouterInterval == nullptr) {
1054 } else if (parkingArea == nullptr) {
1056 } else {
1057 // create parking area reroute
1058 GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1059 // add it to interval parent depending of allowUndoRedo
1060 if (myAllowUndoRedo) {
1061 myNet->getViewNet()->getUndoList()->begin(GUIIcon::PARKINGZONEREROUTE, "add " + parkingAreaReroute->getTagStr() + " in '" + parkingArea->getID() + "'");
1063 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1065 } else {
1066 rerouterInterval->addChildElement(parkingAreaReroute);
1067 parkingAreaReroute->incRef("builParkingAreaReroute");
1068 }
1069 }
1070}
1071
1072
1073void
1074GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1075 // get rerouter interval parent
1076 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1077 // get route parent
1079 // check parents
1080 if (rerouterInterval == nullptr) {
1082 } else if (route == nullptr) {
1084 } else {
1085 // create rout prob reroute
1086 GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1087 // add it to interval parent depending of allowUndoRedo
1088 if (myAllowUndoRedo) {
1089 myNet->getViewNet()->getUndoList()->begin(GUIIcon::ROUTEPROBREROUTE, "add " + routeProbReroute->getTagStr() + " in '" + route->getID() + "'");
1091 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1093 } else {
1094 rerouterInterval->addChildElement(routeProbReroute);
1095 routeProbReroute->incRef("buildRouteProbReroute");
1096 }
1097 }
1098}
1099
1100
1101void
1102GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime period,
1103 const std::string& name, const std::string& file, const SUMOTime begin, const Parameterised::Map& parameters) {
1104 // check conditions
1108 // get NETEDIT parameters
1109 NeteditParameters neteditParameters(sumoBaseObject);
1110 // get edge
1111 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1112 // check lane
1113 if (edge == nullptr) {
1115 } else if (period < 0) {
1117 } else if (begin < 0) {
1119 } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
1121 } else {
1122 // build route probe
1123 GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, edge, period, name, file, begin, parameters);
1124 // insert depending of allowUndoRedo
1125 if (myAllowUndoRedo) {
1128 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1130 // center after creation
1131 if (neteditParameters.centerAfterCreation) {
1132 myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1133 }
1134 } else {
1136 edge->addChildElement(routeProbe);
1137 routeProbe->incRef("buildRouteProbe");
1138 }
1139 }
1140 } else {
1142 }
1143}
1144
1145
1146void
1148 const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
1152 } else if (checkDuplicatedAdditional(SUMO_TAG_VSS, id)) {
1153 // get NETEDIT parameters
1154 NeteditParameters neteditParameters(sumoBaseObject);
1155 // parse lanes
1156 std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, laneIDs);
1157 // check lane
1158 if (lanes.size() > 0) {
1159 // check vTypes
1160 if (!vTypes.empty() && !checkListOfVehicleTypes(vTypes)) {
1162 } else {
1163 // create VSS
1164 GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, pos, name, vTypes, parameters);
1165 // create VSS Symbols
1166 std::vector<GNEAdditional*> VSSSymbols;
1167 for (const auto& lane : lanes) {
1168 VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1169 }
1170 // insert depending of allowUndoRedo
1171 if (myAllowUndoRedo) {
1174 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1175 for (const auto& VSSSymbol : VSSSymbols) {
1176 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1177 }
1179 } else {
1180 myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1181 variableSpeedSign->incRef("buildVariableSpeedSign");
1182 // add symbols into VSS
1183 for (const auto& VSSSymbol : VSSSymbols) {
1184 variableSpeedSign->addChildElement(VSSSymbol);
1185 }
1186 // add symbols into lanes
1187 for (int i = 0; i < (int)lanes.size(); i++) {
1188 lanes.at(i)->addChildElement(VSSSymbols.at(i));
1189 }
1190 }
1191 }
1192 }
1193 } else {
1195 }
1196}
1197
1198
1199void
1200GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1201 // get VSS parent
1202 GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1203 // check lane
1204 if (VSS == nullptr) {
1206 } else if (time < 0) {
1208 /*
1209 } else if (speed < 0) {
1210 writeErrorInvalidNegativeValue(SUMO_TAG_STEP, VSS->getID(), SUMO_ATTR_SPEED);
1211 */
1212 } else {
1213 // create Variable Speed Sign
1214 GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1215 // add it depending of allow undoRedo
1216 if (myAllowUndoRedo) {
1217 myNet->getViewNet()->getUndoList()->begin(GUIIcon::VSSSTEP, "add " + variableSpeedSignStep->getTagStr() + " in '" + VSS->getID() + "'");
1219 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1221 } else {
1222 VSS->addChildElement(variableSpeedSignStep);
1223 variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1224 }
1225 }
1226}
1227
1228
1229void
1230GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1231 const SUMOTime endTime, const std::string& name, const Parameterised::Map& parameters) {
1232 // check conditions
1235 } else if (checkDuplicatedAdditional(SUMO_TAG_VAPORIZER, edgeID)) {
1236 // get NETEDIT parameters
1237 NeteditParameters neteditParameters(sumoBaseObject);
1238 // get edge
1239 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1240 // check lane
1241 if (edge == nullptr) {
1243 } else if (beginTime < 0) {
1245 } else if (endTime < 0) {
1247 } else if (endTime < beginTime) {
1248 writeError("Could not build " + toString(SUMO_TAG_VAPORIZER) + " with ID '" + edge->getID() + "' in netedit; " + toString(SUMO_ATTR_BEGIN) + " is greather than " + toString(SUMO_ATTR_END) + ".");
1249 } else {
1250 // build vaporizer
1251 GNEAdditional* vaporizer = new GNEVaporizer(myNet, edge, beginTime, endTime, name, parameters);
1252 // add it depending of allow undoRed
1253 if (myAllowUndoRedo) {
1254 myNet->getViewNet()->getUndoList()->begin(GUIIcon::VAPORIZER, "add " + toString(SUMO_TAG_VAPORIZER) + " in '" + edge->getID() + "'");
1256 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1258 // center after creation
1259 if (neteditParameters.centerAfterCreation) {
1260 myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1261 }
1262 } else {
1264 edge->addChildElement(vaporizer);
1265 vaporizer->incRef("buildVaporizer");
1266 }
1267 }
1268 } else {
1270 }
1271}
1272
1273
1274void
1275GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1276 const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1277 const std::string& name, const Parameterised::Map& parameters) {
1278 // parse edges
1279 const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, edgeIDs);
1280 // check TAZShape
1281 PositionVector TAZShape = shape;
1282 if (TAZShape.size() == 0) {
1283 // declare boundary
1284 Boundary TAZBoundary;
1285 for (const auto& edge : edges) {
1286 TAZBoundary.add(edge->getCenteringBoundary());
1287 }
1288 // iterate over children and add sourceSinkEdge boundaries
1289 for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1290 const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1291 if (sourceSinkEdge) {
1292 TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1293 }
1294 }
1295 // update TAZShape
1296 TAZShape = TAZBoundary.getShape(true);
1297 }
1298 // check TAZ
1301 } else if (!checkDuplicatedAdditional(SUMO_TAG_TAZ, id)) {
1303 } else if (!checkDuplicatedAdditional(SUMO_TAG_POLY, id)) {
1305 } else if (TAZShape.size() == 0) {
1306 writeError("Could not build " + toString(SUMO_TAG_TAZ) + " with ID '" + id + "' in netedit; Invalid Shape.");
1307 } else {
1308 // get NETEDIT parameters
1309 NeteditParameters neteditParameters(sumoBaseObject);
1310 // build TAZ with the given shape
1311 GNEAdditional* TAZ = new GNETAZ(id, myNet, TAZShape, center, fill, color, name, parameters);
1312 // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1314 // add it depending of allow undoRed
1315 if (myAllowUndoRedo) {
1316 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "add " + toString(SUMO_TAG_TAZ) + " '" + id + "'");
1318 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
1319 // create TAZEdges
1320 for (const auto& edge : edges) {
1321 // create TAZ Source using GNEChange_Additional
1322 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1323 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1324 // create TAZ Sink using GNEChange_Additional
1325 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1326 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1327 }
1329 } else {
1331 TAZ->incRef("buildTAZ");
1332 for (const auto& edge : edges) {
1333 // create TAZ Source
1334 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1335 TAZSource->incRef("buildTAZ");
1336 TAZ->addChildElement(TAZSource);
1337 // create TAZ Sink
1338 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1339 TAZSink->incRef("buildTAZ");
1340 TAZ->addChildElement(TAZSink);
1341 }
1342 }
1343 // enable updating geometry again and update geometry of TAZ
1345 // update TAZ parent
1346 TAZ->updateGeometry();
1347 }
1348}
1349
1350
1351void
1352GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1353 // get TAZ parent
1355 // get edge
1356 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1357 // declare TAZ Sink
1358 GNEAdditional* TAZSink = nullptr;
1359 // check parents
1360 if (TAZ == nullptr) {
1362 } else if (edge == nullptr) {
1364 } else {
1365 // first check if a TAZSink in the same edge for the same TAZ
1366 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1367 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1368 TAZSink = TAZElement;
1369 }
1370 }
1371 // check if TAZSink has to be created
1372 if (TAZSink == nullptr) {
1373 // Create TAZ with weight 0 (default)
1374 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 0);
1375 // add it depending of allow undoRed
1376 if (myAllowUndoRedo) {
1377 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "add " + toString(SUMO_TAG_TAZSINK) + " in '" + TAZ->getID() + "'");
1379 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1381 } else {
1383 TAZSink->incRef("buildTAZSource");
1384 }
1385 }
1386 // now check check if TAZSource exist
1387 GNEAdditional* TAZSource = nullptr;
1388 // first check if a TAZSink in the same edge for the same TAZ
1389 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1390 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1391 TAZSource = TAZElement;
1392 }
1393 }
1394 // check if TAZSource has to be created
1395 if (TAZSource == nullptr) {
1396 // Create TAZ only with departWeight
1397 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1398 // add it depending of allow undoRed
1399 if (myAllowUndoRedo) {
1400 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "add " + toString(SUMO_TAG_TAZSOURCE) + " in '" + TAZ->getID() + "'");
1402 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1404 } else {
1406 TAZSource->incRef("buildTAZSource");
1407 }
1408 } else {
1409 // update TAZ Attribute depending of allow undoRed
1410 if (myAllowUndoRedo) {
1411 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "update " + toString(SUMO_TAG_TAZSOURCE) + " in '" + TAZ->getID() + "'");
1412 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1414 } else {
1415 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1416 TAZSource->incRef("buildTAZSource");
1417 }
1418 }
1419 }
1420}
1421
1422
1423void
1424GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1425 // get TAZ parent
1427 // get edge
1428 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1429 // check parents
1430 if (TAZ == nullptr) {
1432 } else if (edge == nullptr) {
1434 } else {
1435 // declare TAZ source
1436 GNEAdditional* TAZSource = nullptr;
1437 // first check if a TAZSink in the same edge for the same TAZ
1438 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1439 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1440 TAZSource = TAZElement;
1441 }
1442 }
1443 // check if TAZSource has to be created
1444 if (TAZSource == nullptr) {
1445 // Create TAZ with empty value
1446 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 0);
1447 // add it depending of allow undoRed
1448 if (myAllowUndoRedo) {
1449 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "add " + toString(SUMO_TAG_TAZSOURCE) + " in '" + TAZ->getID() + "'");
1451 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1453 } else {
1455 TAZSource->incRef("buildTAZSink");
1456 }
1457 }
1458 GNEAdditional* TAZSink = nullptr;
1459 // first check if a TAZSink in the same edge for the same TAZ
1460 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1461 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1462 TAZSink = TAZElement;
1463 }
1464 }
1465 // check if TAZSink has to be created
1466 if (TAZSink == nullptr) {
1467 // Create TAZ only with arrivalWeight
1468 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1469 // add it depending of allow undoRed
1470 if (myAllowUndoRedo) {
1471 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "add " + toString(SUMO_TAG_TAZSINK) + " in '" + TAZ->getID() + "'");
1473 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1475 } else {
1477 TAZSink->incRef("buildTAZSink");
1478 }
1479 } else {
1480 // update TAZ Attribute depending of allow undoRed
1481 if (myAllowUndoRedo) {
1482 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, "update " + toString(SUMO_TAG_TAZSINK) + " in '" + TAZ->getID() + "'");
1483 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1485 } else {
1486 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1487 TAZSink->incRef("buildTAZSink");
1488 }
1489 }
1490 }
1491}
1492
1493
1494void
1496 const double voltage, const double currentLimit, const Parameterised::Map& parameters) {
1497 // check conditions
1500 } else if (voltage < 0) {
1502 } else if (currentLimit < 0) {
1505 // get NETEDIT parameters
1506 NeteditParameters neteditParameters(sumoBaseObject);
1507 // build traction substation
1508 GNEAdditional* tractionSubstation = new GNETractionSubstation(id, myNet, pos, voltage, currentLimit, parameters);
1509 // insert depending of allowUndoRedo
1510 if (myAllowUndoRedo) {
1513 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(tractionSubstation, true), true);
1515 } else {
1516 myNet->getAttributeCarriers()->insertAdditional(tractionSubstation);
1517 tractionSubstation->incRef("buildTractionSubstation");
1518 }
1519 } else {
1521 }
1522}
1523
1524
1525void
1526GNEAdditionalHandler::buildOverheadWire(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& substationId,
1527 const std::vector<std::string>& laneIDs, const double startPos, const double endPos, const bool friendlyPos,
1528 const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters) {
1529 // check conditions
1533 // get NETEDIT parameters
1534 NeteditParameters neteditParameters(sumoBaseObject);
1535 // get lanes
1536 const auto lanes = parseLanes(SUMO_TAG_OVERHEAD_WIRE_SECTION, laneIDs);
1537 // get traction substation
1538 const auto tractionSubstation = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, substationId, false);
1539 // check lanes
1540 if (lanes.size() > 0) {
1541 // calculate path
1543 writeError("Could not build " + toString(SUMO_TAG_OVERHEAD_WIRE_SECTION) + " with ID '" + id + "' in netedit; Lanes aren't consecutives.");
1544 } else if (!checkMultiLanePosition(
1545 startPos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
1546 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1548 } else if (tractionSubstation == nullptr) {
1550 } else {
1551 // build Overhead Wire
1552 GNEAdditional* overheadWire = new GNEOverheadWire(id, lanes, tractionSubstation, myNet, startPos, endPos, friendlyPos, forbiddenInnerLanes, parameters);
1553 // insert depending of allowUndoRedo
1554 if (myAllowUndoRedo) {
1557 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(overheadWire, true), true);
1559 } else {
1561 for (const auto& lane : lanes) {
1562 lane->addChildElement(overheadWire);
1563 }
1564 overheadWire->incRef("buildOverheadWire");
1565 }
1566 }
1567 } else {
1569 }
1570 } else {
1572 }
1573}
1574
1575
1576void
1577GNEAdditionalHandler::buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject* /* sumoBaseObject */, const std::string& /* id */, const std::string& /* overheadWireIDStartClamp */,
1578 const std::string& /* laneIDStartClamp */, const std::string& /* overheadWireIDEndClamp */, const std::string& /* laneIDEndClamp */,
1579 const Parameterised::Map& /* parameters */) {
1580 //
1581}
1582
1583
1584void
1585GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1586 const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill,
1587 double lineWidth, const std::string& name, const Parameterised::Map& parameters) {
1588 // check conditions
1591 } else if (!checkDuplicatedAdditional(SUMO_TAG_POLY, id)) {
1593 } else if (!checkDuplicatedAdditional(SUMO_TAG_TAZ, id)) {
1595 } else if (lineWidth < 0) {
1597 } else {
1598 // get NETEDIT parameters
1599 NeteditParameters neteditParameters(sumoBaseObject);
1600 // create poly
1601 GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, name, parameters);
1602 // add it depending of allow undoRed
1603 if (myAllowUndoRedo) {
1604 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "add " + toString(SUMO_TAG_POLY) + " '" + id + "'");
1606 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(poly, true), true);
1608 } else {
1609 // insert shape without allowing undo/redo
1611 poly->incRef("addPolygon");
1612 }
1613 }
1614}
1615
1616
1617void
1618GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1619 const RGBColor& color, const double x, const double y, double layer, double angle, const std::string& imgFile, bool relativePath,
1620 double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1621 // check conditions
1624 } else if (width < 0) {
1626 } else if (height < 0) {
1628 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1631 // get NETEDIT parameters
1632 NeteditParameters neteditParameters(sumoBaseObject);
1633 // create POI
1634 GNEPOI* POI = new GNEPOI(myNet, id, type, color, x, y, false, layer, angle, imgFile, relativePath, width, height, name, parameters);
1635 // add it depending of allow undoRed
1636 if (myAllowUndoRedo) {
1637 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POI, "add " + POI->getTagStr() + " '" + id + "'");
1639 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POI, true), true);
1641 } else {
1642 // insert shape without allowing undo/redo
1644 POI->incRef("addPOI");
1645 }
1646 } else {
1648 }
1649}
1650
1651
1652void
1653GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1654 const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat, double layer, double angle,
1655 const std::string& imgFile, bool relativePath, double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1656 // check conditions
1659 } else if (width < 0) {
1661 } else if (height < 0) {
1663 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1666 // get NETEDIT parameters
1667 NeteditParameters neteditParameters(sumoBaseObject);
1668 // get lane
1669 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1670 // check lane
1671 if (lane == nullptr) {
1673 } else if (!checkLanePosition(posOverLane, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1675 } else {
1676 // create POI
1677 GNEAdditional* POILane = new GNEPOI(myNet, id, type, color, lane, posOverLane, friendlyPos, posLat, layer, angle, imgFile, relativePath, width, height, name, parameters);
1678 // add it depending of allow undoRed
1679 if (myAllowUndoRedo) {
1680 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POILANE, "add " + POILane->getTagStr() + " '" + id + "'");
1682 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POILane, true), true);
1684 } else {
1685 // insert shape without allowing undo/redo
1687 lane->addChildElement(POILane);
1688 POILane->incRef("buildPOILane");
1689 }
1690 }
1691 } else {
1693 }
1694}
1695
1696
1697void
1698GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1699 const RGBColor& color, const double lon, const double lat, double layer, double angle, const std::string& imgFile, bool relativePath,
1700 double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1701 // check conditions
1704 } else if (width < 0) {
1706 } else if (height < 0) {
1708 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1710 } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1711 writeError("Could not build " + toString(SUMO_TAG_POI) + " with ID '" + id + "' in netedit; Networ requires a geo projection.");
1713 // get NETEDIT parameters
1714 NeteditParameters neteditParameters(sumoBaseObject);
1715 // create POIGEO
1716 GNEPOI* POIGEO = new GNEPOI(myNet, id, type, color, lon, lat, true, layer, angle, imgFile, relativePath, width, height, name, parameters);
1717 // add it depending of allow undoRed
1718 if (myAllowUndoRedo) {
1719 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POIGEO, "add " + POIGEO->getTagStr() + " '" + id + "'");
1721 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POIGEO, true), true);
1723 } else {
1724 // insert shape without allowing undo/redo
1726 POIGEO->incRef("buildPOIGeo");
1727 }
1728 } else {
1730 }
1731}
1732
1733
1734bool
1736 // check if exist another acces for the same busStop in the given edge
1737 for (const auto& additional : busStopParent->getChildAdditionals()) {
1738 for (const auto& lane : edge->getLanes()) {
1739 if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1740 return false;
1741 }
1742 }
1743 }
1744 return true;
1745}
1746
1747
1748bool
1750 // declare a vector to keep sorted rerouter children
1751 std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1752 // iterate over child additional
1753 for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1754 if (!rerouterChild->getTagProperty().isSymbol()) {
1755 sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1756 // set begin and end
1757 sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1758 sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1759 }
1760 }
1761 // add new intervals
1762 sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1763 // sort children
1764 std::sort(sortedIntervals.begin(), sortedIntervals.end());
1765 // check overlapping after sorting
1766 for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1767 if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1768 return false;
1769 }
1770 }
1771 return true;
1772}
1773
1774
1775bool
1776GNEAdditionalHandler::checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos) {
1777 if (friendlyPos) {
1778 return true;
1779 }
1780 // adjust from and to (negative means that start at the end of lane and count backward)
1781 if (pos < 0) {
1782 pos += laneLength;
1783 }
1784 // check extremes
1785 if ((pos < 0) || (pos > laneLength)) {
1786 return false;
1787 }
1788 // check pos + length
1789 if ((pos + length) > laneLength) {
1790 return false;
1791 }
1792 // all OK
1793 return true;
1794}
1795
1796
1797void
1798GNEAdditionalHandler::fixLanePosition(double& pos, double& length, const double laneLength) {
1799 // negative pos means that start at the end of lane and count backward)
1800 if (pos < 0) {
1801 pos += laneLength;
1802 }
1803 // set position at the start
1804 if (pos < 0) {
1805 pos = 0;
1806 }
1807 // adjust pos
1808 if (pos >= laneLength) {
1809 pos = (laneLength - POSITION_EPS);
1810 }
1811 // adjust length
1812 if ((length < 0) || ((pos + length) > laneLength)) {
1813 length = POSITION_EPS;
1814 }
1815}
1816
1817
1818bool
1819GNEAdditionalHandler::checkLaneDoublePosition(double from, double to, const double laneLength, const bool friendlyPos) {
1820 if (friendlyPos) {
1821 return true;
1822 }
1823 // adjust from and to (negative means that start at the end of lane and count backward)
1824 if (from == INVALID_DOUBLE) {
1825 from = 0;
1826 }
1827 if (to == INVALID_DOUBLE) {
1828 to = laneLength;
1829 }
1830 if (from < 0) {
1831 from += laneLength;
1832 }
1833 if (to < 0) {
1834 to += laneLength;
1835 }
1836 if ((to - from) < POSITION_EPS) {
1837 return false;
1838 }
1839 if ((from < 0) || (from > laneLength)) {
1840 return false;
1841 }
1842 if ((to < 0) || (to > laneLength)) {
1843 return false;
1844 }
1845 return true;
1846}
1847
1848
1849void
1850GNEAdditionalHandler::fixLaneDoublePosition(double& from, double& to, const double laneLength) {
1851 // adjust from (negative means that start at the end of lane and count backward)
1852 if (from == INVALID_DOUBLE) {
1853 from = 0;
1854 }
1855 if (to == INVALID_DOUBLE) {
1856 to = laneLength;
1857 }
1858 if (from < 0) {
1859 from += laneLength;
1860 }
1861 if (from < 0) {
1862 from = 0;
1863 } else if (from > laneLength) {
1864 from = laneLength;
1865 }
1866 // adjust to
1867 if (to < 0) {
1868 to += laneLength;
1869 }
1870 if (to < 0) {
1871 to = 0;
1872 } else if (to > laneLength) {
1873 to = laneLength;
1874 }
1875 // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1876 if ((to - from) < POSITION_EPS) {
1877 if (to >= POSITION_EPS) {
1878 from = to - POSITION_EPS;
1879 } else {
1880 from = 0;
1881 to = POSITION_EPS;
1882 }
1883 }
1884}
1885
1886
1887bool
1888GNEAdditionalHandler::checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos) {
1889 if (friendlyPos) {
1890 return true;
1891 } else {
1892 return (checkLanePosition(fromPos, 0, fromLaneLength, false) && checkLanePosition(toPos, 0, tolaneLength, false));
1893 }
1894}
1895
1896
1897void
1898GNEAdditionalHandler::fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength) {
1899 double length = 0;
1900 fixLanePosition(fromPos, length, fromLaneLength);
1901 fixLanePosition(toPos, length, tolaneLength);
1902}
1903
1904
1905void
1906GNEAdditionalHandler::writeInvalidID(const SumoXMLTag tag, const std::string& id) {
1907 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; ID contains invalid characters.");
1908}
1909
1910
1911void
1913 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; Invalid position over lane.");
1914}
1915
1916
1917void
1919 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; declared twice.");
1920}
1921
1922
1923void
1925 writeError("Could not build " + toString(tag) + " in netedit; " + toString(parent) + " doesn't exist.");
1926}
1927
1928
1929void
1930GNEAdditionalHandler::writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute) {
1931 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; attribute " + toString(attribute) + " cannot be negative.");
1932}
1933
1934
1935void
1937 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; list of VTypes isn't valid.");
1938}
1939
1940
1941void
1943 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; filename is invalid.");
1944}
1945
1946
1947void
1949 writeError("Could not build " + toString(tag) + " with ID '" + id + "' in netedit; list of lanes isn't valid.");
1950}
1951
1952
1953bool
1954GNEAdditionalHandler::checkListOfVehicleTypes(const std::vector<std::string>& vTypeIDs) const {
1955 for (const auto& vTypeID : vTypeIDs) {
1956 if (!SUMOXMLDefinitions::isValidTypeID(vTypeID)) {
1957 return false;
1958 }
1959 }
1960 return true;
1961}
1962
1963
1966 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1967 return nullptr;
1968 } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
1969 return nullptr;
1970 } else {
1972 }
1973}
1974
1975
1978 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1979 // parent interval doesn't exist
1980 return nullptr;
1981 } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
1982 // rerouter parent doesn't exist
1983 return nullptr;
1984 } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
1985 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
1986 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
1987 return nullptr;
1988 } else {
1993 }
1994}
1995
1996
1997std::vector<GNEEdge*>
1998GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::vector<std::string>& edgeIDs) {
1999 std::vector<GNEEdge*> edges;
2000 for (const auto& edgeID : edgeIDs) {
2001 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
2002 // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
2003 if (edge == nullptr) {
2004 writeError("Could not build " + toString(tag) + " in netedit; " + toString(SUMO_TAG_EDGE) + " doesn't exist.");
2005 edges.clear();
2006 return edges;
2007 } else {
2008 edges.push_back(edge);
2009 }
2010 }
2011 return edges;
2012}
2013
2014
2015std::vector<GNELane*>
2016GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::vector<std::string>& laneIDs) {
2017 std::vector<GNELane*> lanes;
2018 for (const auto& laneID : laneIDs) {
2019 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
2020 // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
2021 if (lane == nullptr) {
2022 writeError("Could not build " + toString(tag) + " in netedit; " + toString(SUMO_TAG_LANE) + " doesn't exist.");
2023 lanes.clear();
2024 return lanes;
2025 } else {
2026 lanes.push_back(lane);
2027 }
2028 }
2029 return lanes;
2030}
2031
2032
2033bool
2035 // retrieve additional
2036 auto additional = myNet->getAttributeCarriers()->retrieveAdditional(tag, id, false);
2037 // if additional exist, check if overwrite (delete)
2038 if (additional) {
2039 if (myAllowUndoRedo == false) {
2040 // only overwrite if allow undo-redo
2041 return false;
2042 } else if (myOverwrite) {
2043 // update additional to overwrite
2044 myAdditionalToOverwrite = additional;
2045 return true;
2046 } else {
2047 // duplicated additional
2048 return false;
2049 }
2050 } else {
2051 // additional with these id doesn't exist, then all ok
2052 return true;
2053 }
2054}
2055
2056
2057void
2060 // remove element
2062 // reset pointer
2063 myAdditionalToOverwrite = nullptr;
2064 }
2065}
2066
2067
2069 myNet(nullptr),
2070 myAllowUndoRedo(false),
2071 myOverwrite(false) {
2072}
2073
2074// ===========================================================================
2075// GNEAdditionalHandler::NeteditParameters method definitions
2076// ===========================================================================
2077
2079 select(sumoBaseObject->hasBoolAttribute(GNE_ATTR_SELECTED) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_SELECTED) : false),
2080 centerAfterCreation(sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) : false) {
2081}
2082
2083
2085
2086
2088 select(false),
2089 centerAfterCreation(false) {
2090}
2091
2092/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
@ PARKINGSPACE
@ CLOSINGREROUTE
@ CONTAINERSTOP
@ ROUTEPROBREROUTE
@ TRACTION_SUBSTATION
@ CHARGINGSTATION
@ PARKINGZONEREROUTE
@ CLOSINGLANEREROUTE
@ DESTPROBREROUTE
@ REROUTERINTERVAL
@ VARIABLESPEEDSIGN
@ OVERHEADWIRE
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
const std::string DEFAULT_VTYPE_ID
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_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_REROUTER
A rerouter.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_ENTRY
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ 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
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_SINK
Sink(s) specification.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_SOURCE
a source
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destiny of a reroute
@ GNE_TAG_POILANE
Point of interest over Lane.
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ GNE_ATTR_CENTER_AFTER_CREATION
flag to center camera after element creation
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_VOLTAGE
voltage of the traction substation [V]
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_LINEWIDTH
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_WEIGHT
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ROADSIDE_CAPACITY
@ SUMO_ATTR_CURRENTLIMIT
current limit of the traction substation [A]
@ SUMO_ATTR_CHARGINGPOWER
@ SUMO_ATTR_PROB
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations.
const double INVALID_DOUBLE
Definition: StdDefs.h:60
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
void writeError(const std::string &error)
write error and enable error creating element
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition: Boundary.cpp:404
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 Parameterised::Map &parameters)
Builds a polygon using the given values.
void buildDetectorE3(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const SUMOTime period, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const Parameterised::Map &parameters)
Builds a multi entry exit detector (E3)
void buildVariableSpeedSign(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const std::vector< std::string > &laneIDs, const std::string &name, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
Builds a VariableSpeedSign (lane speed additional)
void buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &edgeID, const double pos, const std::string &name, const std::string &outfile, const SUMOTime period, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a microscopic calibrator over an edge
GNEAdditional * getRerouterIntervalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get rerouter interval parent
void writeInvalidID(const SumoXMLTag tag, const std::string &id)
write invalid id
static void fixLaneDoublePosition(double &from, double &to, const double laneLengt)
fix the given positions over lane
void buildOverheadWire(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &substationId, const std::vector< std::string > &laneIDs, const double startPos, const double endPos, const bool friendlyPos, const std::vector< std::string > &forbiddenInnerLanes, const Parameterised::Map &parameters)
build overhead wire
void buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const double length, const SUMOTime period, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a single-lane Area Detector (E2)
static bool accessCanBeCreated(GNEAdditional *busStopParent, GNEEdge *edge)
check if a GNEAccess can be created in a certain Edge
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 Parameterised::Map &parameters)
Builds a POI over lane using the given values.
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 Parameterised::Map &parameters)
Builds a POI using the given values.
void buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const std::string &name, const std::string &outfile, const SUMOTime period, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a microscopic calibrator over a lane
void buildTAZSink(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double arrivalWeight)
Builds a TAZSink (Traffic Assignment Zone)
void buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime time, const std::string &speed)
Builds a VariableSpeedSign Step.
void buildRerouter(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const std::vector< std::string > &edgeIDs, const double prob, const std::string &name, const bool off, const SUMOTime timeThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a rerouter
GNEAdditional * getAdditionalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, SumoXMLTag tag) const
get additional parent
void writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute)
write error "invalid negative element"
void buildTractionSubstation(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const double voltage, const double currentLimit, const Parameterised::Map &parameters)
build traction substation
std::vector< GNELane * > parseLanes(const SumoXMLTag tag, const std::vector< std::string > &laneIDs)
parse lanes
void writeErrorDuplicated(const SumoXMLTag tag, const std::string &id)
write error "duplicated additional"
void buildRerouterInterval(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime begin, const SUMOTime end)
builds a rerouter interval
void buildCalibratorFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameter)
builds a calibrator flow
void buildAccess(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const double length, const bool friendlyPos, const Parameterised::Map &parameters)
Builds an Access.
void overwriteAdditional()
remove overwrited additional
void buildTAZ(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, const Position &center, const bool fill, const RGBColor &color, const std::vector< std::string > &edgeIDs, const std::string &name, const Parameterised::Map &parameters)
Builds a TAZ (Traffic Assignment Zone)
void buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedLane, SVCPermissions permissions)
builds a closing lane reroute
void buildParkingSpace(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const double x, const double y, const double z, const std::string &name, const std::string &width, const std::string &length, const std::string &angle, const double slope, const Parameterised::Map &parameters)
Builds a Parking Space.
void writeErrorInvalidVTypes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of vehicle types"
void buildClosingReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedEdgeID, SVCPermissions permissions)
builds a closing edge reroute
void writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id)
write error "invalid position"
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
void buildDestProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newEdgeDestinationID, const double probability)
builds a dest prob reroute
bool checkListOfVehicleTypes(const std::vector< std::string > &vTypeIDs) const
check list of IDs
const bool myAllowUndoRedo
allow undo/redo
static bool checkLaneDoublePosition(double from, const double to, const double laneLength, const bool friendlyPos)
check if the given positions over a lane is valid
void buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newParkignAreaID, const double probability, const bool visible)
builds a parking area reroute
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 Parameterised::Map &parameters)
Builds a POI in GEO coordinaten using the given values.
static bool checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos)
check if the given position over a lane is valid
void buildRouteProbe(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &edgeID, const SUMOTime period, const std::string &name, const std::string &file, const SUMOTime begin, const Parameterised::Map &parameters)
builds a Route probe
void buildBusStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int personCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a bus stop.
GNEAdditionalHandler()
invalidate default constructo
void writeErrorInvalidFilename(const SumoXMLTag tag, const std::string &id)
write error "invalid filename"
void buildTrainStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int personCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a train stop.
void buildE1Detector(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double position, const SUMOTime period, const std::string &file, const std::vector< std::string > &vehicleTypes, const std::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a induction loop detector (E1)
void writeErrorInvalidLanes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of lanes"
static bool checkOverlappingRerouterIntervals(GNEAdditional *rerouter, const SUMOTime newBegin, const SUMOTime newEnd)
check if an overlapping is produced in rerouter if a interval with certain begin and end is inserted
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
GNENet * myNet
pointer to GNENet
void 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 Parameterised::Map &parameters)
Builds a Parking Area.
void buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newRouteID, const double probability)
builds a route prob reroute
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 Parameterised::Map &parameters)
Builds a Instant Induction Loop Detector (E1Instant)
void buildTAZSource(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double departWeight)
Builds a TAZSource (Traffic Assignment Zone)
bool checkDuplicatedAdditional(const SumoXMLTag tag, const std::string &id)
check if given ID correspond to a duplicated additional
void writeErrorInvalidParent(const SumoXMLTag tag, const SumoXMLTag parent)
write error "invalid parent element"
std::vector< GNEEdge * > parseEdges(const SumoXMLTag tag, const std::vector< std::string > &edgeIDs)
parse edges
void buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &lanes, const double pos, const double endPos, const SUMOTime period, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a multi-lane Area Detector (E2)
void buildVaporizer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const SUMOTime from, const SUMOTime endTime, const std::string &name, const Parameterised::Map &parameters)
Builds a vaporizer (lane speed additional)
void buildContainerStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int containerCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a container stop.
GNEAdditional * myAdditionalToOverwrite
additional to overwrite (using undor-redo
void buildDetectorEntry(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a entry detector (E3)
void buildDetectorExit(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a exit detector (E3)
void buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &overheadWireIDStartClamp, const std::string &laneIDStartClamp, const std::string &overheadWireIDEndClamp, const std::string &laneIDEndClamp, const Parameterised::Map &parameters)
build overhead wire clamp
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 Parameterised::Map &parameters)
Builds a charging Station.
const bool myOverwrite
check if overwrite
static bool checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos)
check if the given positions over two lanes are valid
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
virtual Position getPositionInView() const =0
Returns position of additional in view.
const std::string getID() const
get ID (all Attribute Carriers have one)
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 belong to GNENet but has influence 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:481
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:839
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:130
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:124
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
void insertAdditional(GNEAdditional *additional)
Insert a additional element 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 deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition: GNENet.cpp:629
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition: GNENet.cpp:2605
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
void enableUpdateGeometry()
Definition: GNENet.cpp:2599
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPOI.h:43
A lane area vehicles can park at (netedit-version)
vehicle space used by GNEParkingAreas
void incRef(const std::string &debugMsg="")
Increase reference.
Representation of a RouteProbe in netedit.
Definition: GNERouteProbe.h:32
Definition: GNETAZ.h:34
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
Representation of a vaporizer in netedit.
Definition: GNEVaporizer.h:33
GNEUndoList * getUndoList() const
get the undoList object
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition: NBEdge.cpp:4469
C++ TraCI client API implementation.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:298
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)
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
const bool centerAfterCreation
center view after creation