Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAdditionalHandler.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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
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, TL("add 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) {
148 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TRAINSTOP, TL("add train stop '") + id + "'");
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(TL("Could not build access in netedit; busStop parent already owns an access in the edge '") + lane->getParentEdge()->getID() + "'");
187 } else if (!lane->allowPedestrians()) {
188 WRITE_WARNING(TLF("Could not build access in netedit; The lane '%' doesn't support pedestrians", lane->getID()));
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, TL("add 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) {
235 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CONTAINERSTOP, TL("add container stop '") + id + "'");
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) {
279 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CHARGINGSTATION, TL("add charging station '") + id + "'");
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,
300 const bool lefthand, const Parameterised::Map& parameters) {
301 // check conditions
305 // get netedit parameters
306 NeteditParameters neteditParameters(sumoBaseObject);
307 // get lane
308 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
309 // get departPos double
310 const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
311 // check lane
312 if (lane == nullptr) {
314 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
316 } else if (roadSideCapacity < 0) {
318 } else if (width < 0) {
320 } else if (length < 0) {
322 } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
323 writeError(TLF("Could not build parking area with ID '%' in netedit; Invalid departPos over lane.", id));
324 } else {
325 // build parkingArea
326 GNEAdditional* parkingArea = new GNEParkingArea(id, lane, myNet, startPos, endPos, GNEAttributeCarrier::canParse<double>(departPos) ? departPos : "",
327 name, friendlyPosition, roadSideCapacity, onRoad,
328 (width == 0) ? SUMO_const_laneWidth : width, length, angle, lefthand, parameters);
329 // insert depending of allowUndoRedo
330 if (myAllowUndoRedo) {
331 myNet->getViewNet()->getUndoList()->begin(GUIIcon::PARKINGAREA, TL("add parking area '") + id + "'");
333 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
335 } else {
337 lane->addChildElement(parkingArea);
338 parkingArea->incRef("buildParkingArea");
339 }
340 }
341 } else {
343 }
344}
345
346
347void
348GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
349 const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
350 const Parameterised::Map& parameters) {
351 // check width and heights
352 if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
353 writeError(TL("Could not build parking space in netedit; attribute width cannot be parse to float."));
354 } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
355 writeError(TL("Could not build parking space in netedit; attribute length cannot be parse to float."));
356 } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
357 writeError(TL("Could not build parking space in netedit; attribute angle cannot be parse to float."));
358 } else {
359 // get netedit parameters
360 NeteditParameters neteditParameters(sumoBaseObject);
361 // get lane
362 GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
363 // get double values
364 const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
365 const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
366 // check lane
367 if (parkingArea == nullptr) {
369 } else if (widthDouble < 0) {
371 } else if (lengthDouble < 0) {
373 } else {
374 // build parkingSpace
375 GNEAdditional* parkingSpace = new GNEParkingSpace(myNet, parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
376 // insert depending of allowUndoRedo
377 if (myAllowUndoRedo) {
378 myNet->getViewNet()->getUndoList()->begin(GUIIcon::PARKINGSPACE, TL("add parking space in '") + parkingArea->getID() + "'");
380 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
382 } else {
384 parkingArea->addChildElement(parkingSpace);
385 parkingSpace->incRef("buildParkingSpace");
386 }
387 // update geometry (due boundaries)
388 parkingSpace->updateGeometry();
389 }
390 }
391}
392
393
394void
395GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
396 const double position, const SUMOTime period, const std::string& file, const std::vector<std::string>& vehicleTypes, const std::string& name,
397 const bool friendlyPos, const Parameterised::Map& parameters) {
398 // check conditions
402 // get netedit parameters
403 NeteditParameters neteditParameters(sumoBaseObject);
404 // get lane
405 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
406 // check lane
407 if (lane == nullptr) {
409 } else if (!checkLanePosition(position, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
411 } else if (period < 0) {
413 } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
415 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
417 } else {
418 // build E1
419 GNEAdditional* detectorE1 = new GNEInductionLoopDetector(id, lane, myNet, position, period, file, vehicleTypes, name, friendlyPos, parameters);
420 // insert depending of allowUndoRedo
421 if (myAllowUndoRedo) {
422 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E1, TL("add induction loop '") + id + "'");
424 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
426 } else {
428 lane->addChildElement(detectorE1);
429 detectorE1->incRef("buildDetectorE1");
430 }
431 }
432 } else {
434 }
435}
436
437
438void
439GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
440 const double pos, const double length, const SUMOTime period, const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
441 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
442 const Parameterised::Map& parameters) {
443 // check conditions
447 // get netedit parameters
448 NeteditParameters neteditParameters(sumoBaseObject);
449 // get lane
450 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
451 // check lane
452 if (lane == nullptr) {
454 } else if (!checkLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
456 } else if (length < 0) {
458 } else if ((period != -1) && (period < 0)) {
460 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
461 // temporal
462 writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
463 } else if (timeThreshold < 0) {
465 } else if (speedThreshold < 0) {
467 } else if (jamThreshold < 0) {
469 } else if (timeThreshold < 0) {
471 } else if (speedThreshold < 0) {
473 } else if (jamThreshold < 0) {
475 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
477 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
479 } else {
480 // build E2 single lane
481 GNEAdditional* detectorE2 = new GNELaneAreaDetector(
482 id, lane, myNet, pos, length, period, trafficLight, filename,
483 vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold,
484 friendlyPos, parameters);
485 // insert depending of allowUndoRedo
486 if (myAllowUndoRedo) {
487 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E2, TL("add lane area detector '") + id + "'");
489 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
491 } else {
493 lane->addChildElement(detectorE2);
494 detectorE2->incRef("buildDetectorE2");
495 }
496 }
497 } else {
499 }
500}
501
502
503void
504GNEAdditionalHandler::buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::vector<std::string>& laneIDs,
505 const double pos, const double endPos, const SUMOTime period, const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
506 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos,
507 const Parameterised::Map& parameters) {
508 // check conditions
512 // get netedit parameters
513 NeteditParameters neteditParameters(sumoBaseObject);
514 // get lanes
515 const auto lanes = parseLanes(SUMO_TAG_LANE_AREA_DETECTOR, laneIDs);
516 // check lanes
517 if (lanes.size() > 0) {
518 // calculate path
520 writeError(TLF("Could not build lane area detector with ID '%' in netedit; Lanes aren't consecutives.", id));
521 } else if (!checkMultiLanePosition(
522 pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
523 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
525 } else if ((period != -1) && (period < 0)) {
527 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
528 // temporal
529 writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
530 } else if (timeThreshold < 0) {
532 } else if (speedThreshold < 0) {
534 } else if (jamThreshold < 0) {
536 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
538 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
540 } else {
541 // build E2 multilane detector
542 GNEAdditional* detectorE2 = new GNELaneAreaDetector(
543 id, lanes, myNet, pos, endPos, period, trafficLight, filename,
544 vehicleTypes, name, timeThreshold, speedThreshold, jamThreshold,
545 friendlyPos, parameters);
546 // insert depending of allowUndoRedo
547 if (myAllowUndoRedo) {
548 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E2, TL("add lane area detector '") + id + "'");
550 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
552 } else {
554 for (const auto& lane : lanes) {
555 lane->addChildElement(detectorE2);
556 }
557 detectorE2->incRef("buildDetectorE2Multilane");
558 }
559 }
560 } else {
562 }
563 } else {
565 }
566}
567
568
569void
570GNEAdditionalHandler::buildDetectorE3(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos, const SUMOTime period,
571 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, const SUMOTime timeThreshold, const double speedThreshold,
572 const Parameterised::Map& parameters) {
573 // check conditions
576 } else if (period < 0) {
578 } else if (timeThreshold < 0) {
580 } else if (speedThreshold < 0) {
582 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
584 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
587 // get netedit parameters
588 NeteditParameters neteditParameters(sumoBaseObject);
589 // build E3
590 GNEAdditional* E3 = new GNEMultiEntryExitDetector(id, myNet, pos, period, filename, vehicleTypes, name, timeThreshold, speedThreshold, parameters);
591 // insert depending of allowUndoRedo
592 if (myAllowUndoRedo) {
593 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E3, TL("add entry-exit detector '") + id + "'");
595 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
597 } else {
599 E3->incRef("buildDetectorE3");
600 }
601 } else {
603 }
604}
605
606
607void
608GNEAdditionalHandler::buildDetectorEntry(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
609 const bool friendlyPos, const Parameterised::Map& parameters) {
610 // get lane
611 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
612 // get E3 parent
614 // Check if Detector E3 parent and lane is correct
615 if (lane == nullptr) {
617 } else if (E3 == nullptr) {
619 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
621 } else {
622 // get netedit parameters
623 NeteditParameters neteditParameters(sumoBaseObject);
624 // build entry instant
625 GNEAdditional* entry = new GNEEntryExitDetector(SUMO_TAG_DET_ENTRY, myNet, E3, lane, pos, friendlyPos, parameters);
626 // insert depending of allowUndoRedo
627 if (myAllowUndoRedo) {
628 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E3ENTRY, TL("add entry detector in '") + E3->getID() + "'");
630 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
632 } else {
634 lane->addChildElement(entry);
635 E3->addChildElement(entry);
636 entry->incRef("buildDetectorEntry");
637 }
638 }
639}
640
641
642void
643GNEAdditionalHandler::buildDetectorExit(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
644 const bool friendlyPos, const Parameterised::Map& parameters) {
645 // get lane
646 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
647 // get E3 parent
649 // Check if Detector E3 parent and lane is correct
650 if (lane == nullptr) {
652 } else if (E3 == nullptr) {
654 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
656 } else {
657 // get netedit parameters
658 NeteditParameters neteditParameters(sumoBaseObject);
659 // build exit instant
660 GNEAdditional* exit = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet, E3, lane, pos, friendlyPos, parameters);
661 // insert depending of allowUndoRedo
662 if (myAllowUndoRedo) {
663 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E3EXIT, TL("add exit detector in '") + E3->getID() + "'");
665 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
667 } else {
669 lane->addChildElement(exit);
670 E3->addChildElement(exit);
671 exit->incRef("buildDetectorExit");
672 }
673 }
674}
675
676
677void
678GNEAdditionalHandler::buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, double pos,
679 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters) {
680 // check conditions
684 // get netedit parameters
685 NeteditParameters neteditParameters(sumoBaseObject);
686 // get lane
687 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
688 // check lane
689 if (lane == nullptr) {
691 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
693 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
695 } else {
696 // build E1 instant
697 GNEAdditional* detectorE1Instant = new GNEInstantInductionLoopDetector(id, lane, myNet, pos, filename, vehicleTypes, name, friendlyPos, parameters);
698 // insert depending of allowUndoRedo
699 if (myAllowUndoRedo) {
700 myNet->getViewNet()->getUndoList()->begin(GUIIcon::E1INSTANT, TL("add instant induction loop '") + id + "'");
702 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
704 } else {
705 myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
706 lane->addChildElement(detectorE1Instant);
707 detectorE1Instant->incRef("buildDetectorE1Instant");
708 }
709 }
710 } else {
712 }
713}
714
715
716void
717GNEAdditionalHandler::buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, const double pos,
718 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
719 const Parameterised::Map& parameters) {
720 // get lane
721 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
722 // get routeProbe
723 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
724 // check conditions
729 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
731 } else if (lane == nullptr) {
733 } else {
734 // get netedit parameters
735 NeteditParameters neteditParameters(sumoBaseObject);
736 // check lane
737 if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
739 } else if (period < 0) {
741 } else if (jamThreshold < 0) {
743 } else {
744 // build Calibrator
745 GNEAdditional* calibrator = (routeProbe == nullptr) ?
746 new GNECalibrator(id, myNet, lane, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
747 new GNECalibrator(id, myNet, lane, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
748 // insert depending of allowUndoRedo
749 if (myAllowUndoRedo) {
750 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CALIBRATOR, TL("add lane calibrator '") + id + "'");
752 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
754 // center after creation
755 if (neteditParameters.centerAfterCreation) {
756 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
757 }
758 } else {
760 lane->addChildElement(calibrator);
761 if (routeProbe) {
762 routeProbe->addChildElement(calibrator);
763 }
764 calibrator->incRef("buildCalibrator");
765 }
766 }
767 }
768}
769
770
771void
772GNEAdditionalHandler::buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const double pos,
773 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
774 const Parameterised::Map& parameters) {
775 // get edge
776 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
777 // get routeProbe
778 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
779 // check conditions
784 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
786 } else if (edge == nullptr) {
788 } else {
789 // get netedit parameters
790 NeteditParameters neteditParameters(sumoBaseObject);
791 if (!checkLanePosition(pos, 0, edge->getLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
793 } else if (period < 0) {
795 } else if (jamThreshold < 0) {
797 } else {
798 // build Calibrator
799 GNEAdditional* calibrator = (routeProbe == nullptr) ?
800 new GNECalibrator(id, myNet, edge, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
801 new GNECalibrator(id, myNet, edge, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
802 // insert depending of allowUndoRedo
803 if (myAllowUndoRedo) {
804 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CALIBRATOR, TL("add calibrator '") + id + "'");
806 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
808 // center after creation
809 if (neteditParameters.centerAfterCreation) {
810 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
811 }
812 } else {
814 edge->addChildElement(calibrator);
815 if (routeProbe) {
816 routeProbe->addChildElement(calibrator);
817 }
818 calibrator->incRef("buildCalibrator");
819 }
820 }
821 }
822}
823
824
825void
827 // get vType
828 GNEDemandElement* vType = myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, vehicleParameter.vtypeid.empty() ? DEFAULT_VTYPE_ID : vehicleParameter.vtypeid, false);
829 // get route
831 // get calibrator parent
833 // check parents
834 if (vType == nullptr) {
836 } else if (route == nullptr) {
838 } else if (calibrator == nullptr) {
840 } else {
841 // create calibrator flow
842 GNEAdditional* flow = new GNECalibratorFlow(calibrator, vType, route, vehicleParameter);
843 // insert depending of allowUndoRedo
844 if (myAllowUndoRedo) {
845 myNet->getViewNet()->getUndoList()->begin(GUIIcon::FLOW, TL("add calibrator flow in '") + calibrator->getID() + "'");
847 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
849 } else {
850 calibrator->addChildElement(flow);
851 route->addChildElement(flow);
852 vType->addChildElement(flow);
853 flow->incRef("buildCalibratorFlow");
854 }
855 }
856}
857
858
859void
860GNEAdditionalHandler::buildRerouter(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
861 const std::vector<std::string>& edgeIDs, const double prob, const std::string& name, const bool off, const SUMOTime timeThreshold,
862 const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
863 // check conditions
866 } else if (prob < 0) {
868 } else if (timeThreshold < 0) {
870 } else if (!vTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vTypes)) {
873 // get netedit parameters
874 NeteditParameters neteditParameters(sumoBaseObject);
875 // parse edges
876 std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, edgeIDs);
877 // check edges
878 if (edges.size() > 0) {
879 GNEAdditional* rerouter = nullptr;
880 // continue depending of position
881 if (pos == Position::INVALID) {
882 if (edges.size() > 0) {
883 PositionVector laneShape = edges.front()->getLanes().front()->getLaneShape();
884 // move to side
885 laneShape.move2side(3);
886 // create rerouter
887 rerouter = new GNERerouter(id, myNet, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, prob, off, timeThreshold, vTypes, parameters);
888 } else {
889 rerouter = new GNERerouter(id, myNet, Position(0, 0), name, prob, off, timeThreshold, vTypes, parameters);
890 }
891 } else {
892 rerouter = new GNERerouter(id, myNet, pos, name, prob, off, timeThreshold, vTypes, parameters);
893 }
894 // create rerouter Symbols
895 std::vector<GNEAdditional*> rerouterSymbols;
896 for (const auto& edge : edges) {
897 rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
898 }
899 // insert depending of allowUndoRedo
900 if (myAllowUndoRedo) {
901 myNet->getViewNet()->getUndoList()->begin(GUIIcon::REROUTER, TL("add rerouter '") + id + "'");
903 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
904 // add symbols
905 for (const auto& rerouterSymbol : rerouterSymbols) {
906 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
907 }
909 } else {
911 rerouter->incRef("buildRerouter");
912 // add symbols into rerouter
913 for (const auto& rerouterSymbol : rerouterSymbols) {
914 rerouter->addChildElement(rerouterSymbol);
915 }
916 // add symbols into edges
917 for (int i = 0; i < (int)edges.size(); i++) {
918 edges.at(i)->addChildElement(rerouterSymbols.at(i));
919 }
920 }
921 }
922 } else {
924 }
925}
926
927
928void
930 // get rerouter parent
931 GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
932 // check if rerouter exist
933 if (rerouter == nullptr) {
935 } else if (begin < 0) {
937 } else if (end < 0) {
939 } else if (end < begin) {
940 writeError(TLF("Could not build interval with ID '%' in netedit; begin is greather than end.", rerouter->getID()));
941 } else {
942 // check if new interval will produce a overlapping
943 if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
944 // create rerouter interval and add it into rerouter parent
945 GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
946 // insert depending of allowUndoRedo
947 if (myAllowUndoRedo) {
948 myNet->getViewNet()->getUndoList()->begin(GUIIcon::REROUTERINTERVAL, TL("add rerouter interval in '") + rerouter->getID() + "'");
950 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
952 } else {
953 rerouter->addChildElement(rerouterInterval);
954 rerouterInterval->incRef("buildRerouterInterval");
955 }
956 } else {
957 writeError(TLF("Could not build interval with begin '%' and end '%' in '%' due overlapping.", toString(begin), toString(end), rerouter->getID()));
958 }
959 }
960}
961
962
963void
964GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
965 // get rerouter interval parent
966 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
967 // get closed lane
968 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
969 // check parents
970 if (lane == nullptr) {
972 } else if (rerouterInterval == nullptr) {
974 } else {
975 // create closing lane reroute
976 GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
977 // add it to interval parent depending of allowUndoRedo
978 if (myAllowUndoRedo) {
979 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CLOSINGLANEREROUTE, TL("add closing lane reroute in '") + lane->getID() + "'");
981 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
983 } else {
984 rerouterInterval->addChildElement(closingLaneReroute);
985 closingLaneReroute->incRef("buildClosingLaneReroute");
986 }
987 }
988}
989
990
991void
992GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
993 // get rerouter interval parent
994 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
995 // get closed edge
996 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
997 // check parents
998 if (edge == nullptr) {
1000 } else if (rerouterInterval == nullptr) {
1002 } else {
1003 // create closing reroute
1004 GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
1005 // add it to interval parent depending of allowUndoRedo
1006 if (myAllowUndoRedo) {
1007 myNet->getViewNet()->getUndoList()->begin(GUIIcon::CLOSINGREROUTE, TL("add closing reroute in '") + edge->getID() + "'");
1009 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1011 } else {
1012 rerouterInterval->addChildElement(closingLaneReroute);
1013 closingLaneReroute->incRef("buildClosingLaneReroute");
1014 }
1015 }
1016}
1017
1018void
1019GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1020 // get rerouter interval parent
1021 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1022 // get edge
1023 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1024 // check parents
1025 if (edge == nullptr) {
1027 } else if (rerouterInterval == nullptr) {
1029 } else {
1030 // create dest probability reroute
1031 GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1032 // add it to interval parent depending of allowUndoRedo
1033 if (myAllowUndoRedo) {
1034 myNet->getViewNet()->getUndoList()->begin(GUIIcon::DESTPROBREROUTE, TL("add dest prob reroute in '") + edge->getID() + "'");
1036 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1038 } else {
1039 rerouterInterval->addChildElement(destProbReroute);
1040 destProbReroute->incRef("builDestProbReroute");
1041 }
1042 }
1043}
1044
1045
1046void
1047GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1048 // get rerouter interval parent
1049 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1050 // get parking area
1051 GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1052 // check parents
1053 if (parkingArea == nullptr) {
1055 } else if (rerouterInterval == nullptr) {
1057 } else {
1058 // create parking area reroute
1059 GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1060 // add it to interval parent depending of allowUndoRedo
1061 if (myAllowUndoRedo) {
1062 myNet->getViewNet()->getUndoList()->begin(GUIIcon::PARKINGZONEREROUTE, TL("add parking area reroute in '") + parkingArea->getID() + "'");
1064 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1066 } else {
1067 rerouterInterval->addChildElement(parkingAreaReroute);
1068 parkingAreaReroute->incRef("builParkingAreaReroute");
1069 }
1070 }
1071}
1072
1073
1074void
1075GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1076 // get rerouter interval parent
1077 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1078 // get route parent
1080 // check parents
1081 if (route == nullptr) {
1083 } else if (rerouterInterval == nullptr) {
1085 } else {
1086 // create rout prob reroute
1087 GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1088 // add it to interval parent depending of allowUndoRedo
1089 if (myAllowUndoRedo) {
1090 myNet->getViewNet()->getUndoList()->begin(GUIIcon::ROUTEPROBREROUTE, TL("add route prob reroute in '") + route->getID() + "'");
1092 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1094 } else {
1095 rerouterInterval->addChildElement(routeProbReroute);
1096 routeProbReroute->incRef("buildRouteProbReroute");
1097 }
1098 }
1099}
1100
1101
1102void
1103GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime period,
1104 const std::string& name, const std::string& file, const SUMOTime begin, const Parameterised::Map& parameters) {
1105 // check conditions
1109 // get netedit parameters
1110 NeteditParameters neteditParameters(sumoBaseObject);
1111 // get edge
1112 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1113 // check lane
1114 if (edge == nullptr) {
1116 } else if (period < 0) {
1118 } else if (begin < 0) {
1120 } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
1122 } else {
1123 // build route probe
1124 GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, edge, period, name, file, begin, parameters);
1125 // insert depending of allowUndoRedo
1126 if (myAllowUndoRedo) {
1127 myNet->getViewNet()->getUndoList()->begin(GUIIcon::ROUTEPROBE, TL("add route probe '") + id + "'");
1129 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1131 // center after creation
1132 if (neteditParameters.centerAfterCreation) {
1133 myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1134 }
1135 } else {
1137 edge->addChildElement(routeProbe);
1138 routeProbe->incRef("buildRouteProbe");
1139 }
1140 }
1141 } else {
1143 }
1144}
1145
1146
1147void
1149 const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
1153 } else if (checkDuplicatedAdditional(SUMO_TAG_VSS, id)) {
1154 // get netedit parameters
1155 NeteditParameters neteditParameters(sumoBaseObject);
1156 // parse lanes
1157 std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, laneIDs);
1158 // check lane
1159 if (lanes.size() > 0) {
1160 // check vTypes
1161 if (!vTypes.empty() && !checkListOfVehicleTypes(vTypes)) {
1163 } else {
1164 // create VSS
1165 GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, pos, name, vTypes, parameters);
1166 // create VSS Symbols
1167 std::vector<GNEAdditional*> VSSSymbols;
1168 for (const auto& lane : lanes) {
1169 VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1170 }
1171 // insert depending of allowUndoRedo
1172 if (myAllowUndoRedo) {
1173 myNet->getViewNet()->getUndoList()->begin(GUIIcon::VARIABLESPEEDSIGN, TL("add Variable Speed Sign '") + id + "'");
1175 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1176 for (const auto& VSSSymbol : VSSSymbols) {
1177 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1178 }
1180 } else {
1181 myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1182 variableSpeedSign->incRef("buildVariableSpeedSign");
1183 // add symbols into VSS
1184 for (const auto& VSSSymbol : VSSSymbols) {
1185 variableSpeedSign->addChildElement(VSSSymbol);
1186 }
1187 // add symbols into lanes
1188 for (int i = 0; i < (int)lanes.size(); i++) {
1189 lanes.at(i)->addChildElement(VSSSymbols.at(i));
1190 }
1191 }
1192 }
1193 }
1194 } else {
1196 }
1197}
1198
1199
1200void
1201GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1202 // get VSS parent
1203 GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1204 // check lane
1205 if (VSS == nullptr) {
1207 } else if (time < 0) {
1209 } else {
1210 // create Variable Speed Sign
1211 GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1212 // add it depending of allow undoRedo
1213 if (myAllowUndoRedo) {
1214 myNet->getViewNet()->getUndoList()->begin(GUIIcon::VSSSTEP, TL("add VSS Step in '") + VSS->getID() + "'");
1216 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1218 } else {
1219 VSS->addChildElement(variableSpeedSignStep);
1220 variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1221 }
1222 }
1223}
1224
1225
1226void
1227GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1228 const SUMOTime endTime, const std::string& name, const Parameterised::Map& parameters) {
1229 // check conditions
1232 } else if (checkDuplicatedAdditional(SUMO_TAG_VAPORIZER, edgeID)) {
1233 // get netedit parameters
1234 NeteditParameters neteditParameters(sumoBaseObject);
1235 // get edge
1236 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1237 // check lane
1238 if (edge == nullptr) {
1240 } else if (beginTime < 0) {
1242 } else if (endTime < 0) {
1244 } else if (endTime < beginTime) {
1245 writeError(TLF("Could not build Vaporizer with ID '%' in netedit; begin is greather than end.", edge->getID()));
1246 } else {
1247 // build vaporizer
1248 GNEAdditional* vaporizer = new GNEVaporizer(myNet, edge, beginTime, endTime, name, parameters);
1249 // add it depending of allow undoRed
1250 if (myAllowUndoRedo) {
1251 myNet->getViewNet()->getUndoList()->begin(GUIIcon::VAPORIZER, TL("add vaporizer in '") + edge->getID() + "'");
1253 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1255 // center after creation
1256 if (neteditParameters.centerAfterCreation) {
1257 myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1258 }
1259 } else {
1261 edge->addChildElement(vaporizer);
1262 vaporizer->incRef("buildVaporizer");
1263 }
1264 }
1265 } else {
1267 }
1268}
1269
1270
1271void
1272GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1273 const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1274 const std::string& name, const Parameterised::Map& parameters) {
1275 // parse edges
1276 const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, edgeIDs);
1277 // check TAZShape
1278 PositionVector TAZShape = shape;
1279 if (TAZShape.size() == 0) {
1280 // declare boundary
1281 Boundary TAZBoundary;
1282 for (const auto& edge : edges) {
1283 TAZBoundary.add(edge->getCenteringBoundary());
1284 }
1285 // iterate over children and add sourceSinkEdge boundaries to make a taz shape
1286 for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1287 // check that childre is a source or sink elements (to avoid parameters)
1288 if ((sourceSink->getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTag() == SUMO_TAG_TAZSINK)) {
1289 const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1290 if (sourceSinkEdge) {
1291 TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1292 }
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(TLF("Could not build TAZ with ID '%' in netedit; Invalid Shape.", id));
1307 } else {
1308 // get netedit parameters
1309 NeteditParameters neteditParameters(sumoBaseObject);
1310 // build TAZ with the given shape
1311 const Position center2 = center == Position::INVALID ? TAZShape.getCentroid() : center;
1312 GNEAdditional* TAZ = new GNETAZ(id, myNet, TAZShape, center2, fill, color, name, parameters);
1313 // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1315 // add it depending of allow undoRed
1316 if (myAllowUndoRedo) {
1317 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("add TAZ '") + id + "'");
1319 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
1320 // create TAZEdges
1321 for (const auto& edge : edges) {
1322 // create TAZ Source using GNEChange_Additional
1323 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1324 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1325 // create TAZ Sink using GNEChange_Additional
1326 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1327 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1328 }
1330 } else {
1332 TAZ->incRef("buildTAZ");
1333 for (const auto& edge : edges) {
1334 // create TAZ Source
1335 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1336 TAZSource->incRef("buildTAZ");
1337 TAZ->addChildElement(TAZSource);
1338 // create TAZ Sink
1339 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1340 TAZSink->incRef("buildTAZ");
1341 TAZ->addChildElement(TAZSink);
1342 }
1343 }
1344 // enable updating geometry again and update geometry of TAZ
1346 // update TAZ parent
1347 TAZ->updateGeometry();
1348 }
1349}
1350
1351
1352void
1353GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1354 // get TAZ parent
1356 // get edge
1357 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1358 // declare TAZ Sink
1359 GNEAdditional* TAZSink = nullptr;
1360 // check parents
1361 if (TAZ == nullptr) {
1363 } else if (edge == nullptr) {
1365 } else {
1366 // first check if a TAZSink in the same edge for the same TAZ
1367 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1368 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1369 TAZSink = TAZElement;
1370 }
1371 }
1372 // check if TAZSink has to be created
1373 if (TAZSink == nullptr) {
1374 // Create TAZ with weight 0 (default)
1375 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 0);
1376 // add it depending of allow undoRed
1377 if (myAllowUndoRedo) {
1378 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1380 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1382 } else {
1384 TAZSink->incRef("buildTAZSource");
1385 }
1386 }
1387 // now check check if TAZSource exist
1388 GNEAdditional* TAZSource = nullptr;
1389 // first check if a TAZSink in the same edge for the same TAZ
1390 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1391 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1392 TAZSource = TAZElement;
1393 }
1394 }
1395 // check if TAZSource has to be created
1396 if (TAZSource == nullptr) {
1397 // Create TAZ only with departWeight
1398 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1399 // add it depending of allow undoRed
1400 if (myAllowUndoRedo) {
1401 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1403 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1405 } else {
1407 TAZSource->incRef("buildTAZSource");
1408 }
1409 } else {
1410 // update TAZ Attribute depending of allow undoRed
1411 if (myAllowUndoRedo) {
1412 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("update TAZ Source in '") + TAZ->getID() + "'");
1413 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1415 } else {
1416 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1417 TAZSource->incRef("buildTAZSource");
1418 }
1419 }
1420 }
1421}
1422
1423
1424void
1425GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1426 // get TAZ parent
1428 // get edge
1429 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1430 // check parents
1431 if (TAZ == nullptr) {
1433 } else if (edge == nullptr) {
1435 } else {
1436 // declare TAZ source
1437 GNEAdditional* TAZSource = nullptr;
1438 // first check if a TAZSink in the same edge for the same TAZ
1439 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1440 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1441 TAZSource = TAZElement;
1442 }
1443 }
1444 // check if TAZSource has to be created
1445 if (TAZSource == nullptr) {
1446 // Create TAZ with empty value
1447 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 0);
1448 // add it depending of allow undoRed
1449 if (myAllowUndoRedo) {
1450 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1452 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1454 } else {
1456 TAZSource->incRef("buildTAZSink");
1457 }
1458 }
1459 GNEAdditional* TAZSink = nullptr;
1460 // first check if a TAZSink in the same edge for the same TAZ
1461 for (const auto& TAZElement : TAZ->getChildAdditionals()) {
1462 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1463 TAZSink = TAZElement;
1464 }
1465 }
1466 // check if TAZSink has to be created
1467 if (TAZSink == nullptr) {
1468 // Create TAZ only with arrivalWeight
1469 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1470 // add it depending of allow undoRed
1471 if (myAllowUndoRedo) {
1472 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1474 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1476 } else {
1478 TAZSink->incRef("buildTAZSink");
1479 }
1480 } else {
1481 // update TAZ Attribute depending of allow undoRed
1482 if (myAllowUndoRedo) {
1483 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TAZ, TL("update TAZ Sink in '") + TAZ->getID() + "'");
1484 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1486 } else {
1487 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1488 TAZSink->incRef("buildTAZSink");
1489 }
1490 }
1491 }
1492}
1493
1494
1495void
1497 const double voltage, const double currentLimit, const Parameterised::Map& parameters) {
1498 // check conditions
1501 } else if (voltage < 0) {
1503 } else if (currentLimit < 0) {
1506 // get netedit parameters
1507 NeteditParameters neteditParameters(sumoBaseObject);
1508 // build traction substation
1509 GNEAdditional* tractionSubstation = new GNETractionSubstation(id, myNet, pos, voltage, currentLimit, parameters);
1510 // insert depending of allowUndoRedo
1511 if (myAllowUndoRedo) {
1512 myNet->getViewNet()->getUndoList()->begin(GUIIcon::TRACTION_SUBSTATION, TL("add taction substation '") + id + "'");
1514 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(tractionSubstation, true), true);
1516 } else {
1517 myNet->getAttributeCarriers()->insertAdditional(tractionSubstation);
1518 tractionSubstation->incRef("buildTractionSubstation");
1519 }
1520 } else {
1522 }
1523}
1524
1525
1526void
1527GNEAdditionalHandler::buildOverheadWire(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& substationId,
1528 const std::vector<std::string>& laneIDs, const double startPos, const double endPos, const bool friendlyPos,
1529 const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters) {
1530 // check conditions
1534 // get netedit parameters
1535 NeteditParameters neteditParameters(sumoBaseObject);
1536 // get lanes
1537 const auto lanes = parseLanes(SUMO_TAG_OVERHEAD_WIRE_SECTION, laneIDs);
1538 // get traction substation
1539 const auto tractionSubstation = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, substationId, false);
1540 // check lanes
1541 if (lanes.size() > 0) {
1542 // calculate path
1544 writeError(TLF("Could not build overhead wire with ID '%' in netedit; Lanes aren't consecutives.", id));
1545 } else if (!checkMultiLanePosition(
1546 startPos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
1547 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1549 } else if (tractionSubstation == nullptr) {
1551 } else {
1552 // build Overhead Wire
1553 GNEAdditional* overheadWire = new GNEOverheadWire(id, lanes, tractionSubstation, myNet, startPos, endPos, friendlyPos, forbiddenInnerLanes, parameters);
1554 // insert depending of allowUndoRedo
1555 if (myAllowUndoRedo) {
1556 myNet->getViewNet()->getUndoList()->begin(GUIIcon::OVERHEADWIRE, TL("add overhead wire '") + id + "'");
1558 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(overheadWire, true), true);
1560 } else {
1562 for (const auto& lane : lanes) {
1563 lane->addChildElement(overheadWire);
1564 }
1565 overheadWire->incRef("buildOverheadWire");
1566 }
1567 }
1568 } else {
1570 }
1571 } else {
1573 }
1574}
1575
1576
1577void
1578GNEAdditionalHandler::buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject* /* sumoBaseObject */, const std::string& /* id */, const std::string& /* overheadWireIDStartClamp */,
1579 const std::string& /* laneIDStartClamp */, const std::string& /* overheadWireIDEndClamp */, const std::string& /* laneIDEndClamp */,
1580 const Parameterised::Map& /* parameters */) {
1581 //
1582}
1583
1584
1585void
1586GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1587 const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill,
1588 double lineWidth, const std::string& name, const Parameterised::Map& parameters) {
1589 // check conditions
1592 } else if (!checkDuplicatedAdditional(SUMO_TAG_POLY, id)) {
1594 } else if (!checkDuplicatedAdditional(SUMO_TAG_TAZ, id)) {
1596 } else if (lineWidth < 0) {
1598 } else {
1599 // get netedit parameters
1600 NeteditParameters neteditParameters(sumoBaseObject);
1601 // create poly
1602 GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, name, parameters);
1603 // add it depending of allow undoRed
1604 if (myAllowUndoRedo) {
1605 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, TL("add polygon '") + id + "'");
1607 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(poly, true), true);
1609 } else {
1610 // insert shape without allowing undo/redo
1612 poly->incRef("addPolygon");
1613 }
1614 }
1615}
1616
1617
1618void
1619GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1620 const RGBColor& color, const double x, const double y, double layer, double angle, const std::string& imgFile, bool relativePath,
1621 double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1622 // check conditions
1625 } else if (width < 0) {
1627 } else if (height < 0) {
1629 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1632 // get netedit parameters
1633 NeteditParameters neteditParameters(sumoBaseObject);
1634 // create POI
1635 GNEPOI* POI = new GNEPOI(myNet, id, type, color, x, y, false, layer, angle, imgFile, relativePath, width, height, name, parameters);
1636 // add it depending of allow undoRed
1637 if (myAllowUndoRedo) {
1638 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POI, TL("add POI '") + id + "'");
1640 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POI, true), true);
1642 } else {
1643 // insert shape without allowing undo/redo
1645 POI->incRef("addPOI");
1646 }
1647 } else {
1649 }
1650}
1651
1652
1653void
1654GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1655 const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat, double layer, double angle,
1656 const std::string& imgFile, bool relativePath, double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1657 // check conditions
1660 } else if (width < 0) {
1662 } else if (height < 0) {
1664 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1667 // get netedit parameters
1668 NeteditParameters neteditParameters(sumoBaseObject);
1669 // get lane
1670 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1671 // check lane
1672 if (lane == nullptr) {
1674 } else if (!checkLanePosition(posOverLane, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1676 } else {
1677 // create POI
1678 GNEAdditional* POILane = new GNEPOI(myNet, id, type, color, lane, posOverLane, friendlyPos, posLat, layer, angle, imgFile, relativePath, width, height, name, parameters);
1679 // add it depending of allow undoRed
1680 if (myAllowUndoRedo) {
1681 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POILANE, TL("add POI '") + id + "'");
1683 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POILane, true), true);
1685 } else {
1686 // insert shape without allowing undo/redo
1688 lane->addChildElement(POILane);
1689 POILane->incRef("buildPOILane");
1690 }
1691 }
1692 } else {
1694 }
1695}
1696
1697
1698void
1699GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1700 const RGBColor& color, const double lon, const double lat, double layer, double angle, const std::string& imgFile, bool relativePath,
1701 double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1702 // check conditions
1705 } else if (width < 0) {
1707 } else if (height < 0) {
1709 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1711 } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1712 writeError(TLF("Could not build POI with ID '%' in netedit", id) + std::string("; ") + TL("Network requires a geo projection."));
1714 // get netedit parameters
1715 NeteditParameters neteditParameters(sumoBaseObject);
1716 // create POIGEO
1717 GNEPOI* POIGEO = new GNEPOI(myNet, id, type, color, lon, lat, true, layer, angle, imgFile, relativePath, width, height, name, parameters);
1718 // add it depending of allow undoRed
1719 if (myAllowUndoRedo) {
1720 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POIGEO, TL("add POI '") + id + "'");
1722 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POIGEO, true), true);
1724 } else {
1725 // insert shape without allowing undo/redo
1727 POIGEO->incRef("buildPOIGeo");
1728 }
1729 } else {
1731 }
1732}
1733
1734
1735bool
1737 // check if exist another access for the same busStop in the given edge
1738 for (const auto& additional : busStopParent->getChildAdditionals()) {
1739 for (const auto& lane : edge->getLanes()) {
1740 if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1741 return false;
1742 }
1743 }
1744 }
1745 return true;
1746}
1747
1748
1749bool
1751 // declare a vector to keep sorted rerouter children
1752 std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1753 // iterate over child additional
1754 for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1755 if (!rerouterChild->getTagProperty().isSymbol()) {
1756 sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1757 // set begin and end
1758 sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1759 sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1760 }
1761 }
1762 // add new intervals
1763 sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1764 // sort children
1765 std::sort(sortedIntervals.begin(), sortedIntervals.end());
1766 // check overlapping after sorting
1767 for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1768 if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1769 return false;
1770 }
1771 }
1772 return true;
1773}
1774
1775
1776bool
1777GNEAdditionalHandler::checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos) {
1778 if (friendlyPos) {
1779 return true;
1780 }
1781 // adjust from and to (negative means that start at the end of lane and count backward)
1782 if (pos < 0) {
1783 pos += laneLength;
1784 }
1785 // check extremes
1786 if ((pos < 0) || (pos > laneLength)) {
1787 return false;
1788 }
1789 // check pos + length
1790 if ((pos + length) > laneLength) {
1791 return false;
1792 }
1793 // all OK
1794 return true;
1795}
1796
1797
1798void
1799GNEAdditionalHandler::fixLanePosition(double& pos, double& length, const double laneLength) {
1800 // negative pos means that start at the end of lane and count backward)
1801 if (pos < 0) {
1802 pos += laneLength;
1803 }
1804 // set position at the start
1805 if (pos < 0) {
1806 pos = 0;
1807 }
1808 // adjust pos
1809 if (pos >= laneLength) {
1810 pos = (laneLength - POSITION_EPS);
1811 }
1812 // adjust length
1813 if ((length < 0) || ((pos + length) > laneLength)) {
1814 length = POSITION_EPS;
1815 }
1816}
1817
1818
1819bool
1820GNEAdditionalHandler::checkLaneDoublePosition(double from, double to, const double laneLength, const bool friendlyPos) {
1821 if (friendlyPos) {
1822 return true;
1823 }
1824 // adjust from and to (negative means that start at the end of lane and count backward)
1825 if (from == INVALID_DOUBLE) {
1826 from = 0;
1827 }
1828 if (to == INVALID_DOUBLE) {
1829 to = laneLength;
1830 }
1831 if (from < 0) {
1832 from += laneLength;
1833 }
1834 if (to < 0) {
1835 to += laneLength;
1836 }
1837 if ((to - from) < POSITION_EPS) {
1838 return false;
1839 }
1840 if ((from < 0) || (from > laneLength)) {
1841 return false;
1842 }
1843 if ((to < 0) || (to > laneLength)) {
1844 return false;
1845 }
1846 return true;
1847}
1848
1849
1850void
1851GNEAdditionalHandler::fixLaneDoublePosition(double& from, double& to, const double laneLength) {
1852 // adjust from (negative means that start at the end of lane and count backward)
1853 if (from == INVALID_DOUBLE) {
1854 from = 0;
1855 }
1856 if (to == INVALID_DOUBLE) {
1857 to = laneLength;
1858 }
1859 if (from < 0) {
1860 from += laneLength;
1861 }
1862 if (from < 0) {
1863 from = 0;
1864 } else if (from > laneLength) {
1865 from = laneLength;
1866 }
1867 // adjust to
1868 if (to < 0) {
1869 to += laneLength;
1870 }
1871 if (to < 0) {
1872 to = 0;
1873 } else if (to > laneLength) {
1874 to = laneLength;
1875 }
1876 // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1877 if ((to - from) < POSITION_EPS) {
1878 if (to >= POSITION_EPS) {
1879 from = to - POSITION_EPS;
1880 } else {
1881 from = 0;
1882 to = POSITION_EPS;
1883 }
1884 }
1885}
1886
1887
1888bool
1889GNEAdditionalHandler::checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos) {
1890 if (friendlyPos) {
1891 return true;
1892 } else {
1893 return (checkLanePosition(fromPos, 0, fromLaneLength, false) && checkLanePosition(toPos, 0, tolaneLength, false));
1894 }
1895}
1896
1897
1898void
1899GNEAdditionalHandler::fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength) {
1900 double length = 0;
1901 fixLanePosition(fromPos, length, fromLaneLength);
1902 fixLanePosition(toPos, length, tolaneLength);
1903}
1904
1905
1906void
1907GNEAdditionalHandler::writeInvalidID(const SumoXMLTag tag, const std::string& id) {
1908 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("ID contains invalid characters."));
1909}
1910
1911
1912void
1914 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Invalid position over lane."));
1915}
1916
1917
1918void
1920 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Declared twice."));
1921}
1922
1923
1924void
1925GNEAdditionalHandler::writeErrorInvalidParent(const SumoXMLTag tag, const std::string& id, const SumoXMLTag parent, const std::string& parentID) {
1926 std::string first, second;
1927 if (id.size() > 0) {
1928 first = TLF("Could not build % '%' in netedit", toString(tag), id);
1929 } else {
1930 first = TLF("Could not build % in netedit", toString(tag));
1931 }
1932 if (parentID.size() > 0) {
1933 second = TLF("% '%' doesn't exist.", toString(parent), parentID);
1934 } else {
1935 second = TLF("% doesn't exist.", toString(parent));
1936 }
1937 writeError(first + std::string("; ") + second);
1938}
1939
1940
1941void
1942GNEAdditionalHandler::writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute) {
1943 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TLF("Attribute % cannot be negative.", toString(attribute)));
1944}
1945
1946
1947void
1949 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("List of VTypes isn't valid."));
1950}
1951
1952
1953void
1955 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Filename is invalid."));
1956}
1957
1958
1959void
1961 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("List of lanes isn't valid."));
1962}
1963
1964
1965bool
1966GNEAdditionalHandler::checkListOfVehicleTypes(const std::vector<std::string>& vTypeIDs) const {
1967 for (const auto& vTypeID : vTypeIDs) {
1968 if (!SUMOXMLDefinitions::isValidTypeID(vTypeID)) {
1969 return false;
1970 }
1971 }
1972 return true;
1973}
1974
1975
1978 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1979 return nullptr;
1980 } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
1981 return nullptr;
1982 } else {
1984 }
1985}
1986
1987
1990 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1991 // parent interval doesn't exist
1992 return nullptr;
1993 } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
1994 // rerouter parent doesn't exist
1995 return nullptr;
1996 } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
1997 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
1998 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
1999 return nullptr;
2000 } else {
2005 }
2006}
2007
2008
2009std::vector<GNEEdge*>
2010GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::vector<std::string>& edgeIDs) {
2011 std::vector<GNEEdge*> edges;
2012 for (const auto& edgeID : edgeIDs) {
2013 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
2014 // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
2015 if (edge == nullptr) {
2016 writeError(TLF("Could not build % in netedit", toString(tag)) + std::string("; ") + TLF("% doesn't exist.", toString(SUMO_TAG_EDGE)));
2017 edges.clear();
2018 return edges;
2019 } else {
2020 edges.push_back(edge);
2021 }
2022 }
2023 return edges;
2024}
2025
2026
2027std::vector<GNELane*>
2028GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::vector<std::string>& laneIDs) {
2029 std::vector<GNELane*> lanes;
2030 for (const auto& laneID : laneIDs) {
2031 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
2032 // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
2033 if (lane == nullptr) {
2034 writeError(TLF("Could not build % in netedit", toString(tag)) + std::string("; ") + TLF("% doesn't exist.", toString(SUMO_TAG_LANE)));
2035 lanes.clear();
2036 return lanes;
2037 } else {
2038 lanes.push_back(lane);
2039 }
2040 }
2041 return lanes;
2042}
2043
2044
2045bool
2047 // retrieve additional
2048 auto additional = myNet->getAttributeCarriers()->retrieveAdditional(tag, id, false);
2049 // if additional exist, check if overwrite (delete)
2050 if (additional) {
2051 if (myAllowUndoRedo == false) {
2052 // only overwrite if allow undo-redo
2053 return false;
2054 } else if (myOverwrite) {
2055 // update additional to overwrite
2056 myAdditionalToOverwrite = additional;
2057 return true;
2058 } else {
2059 // duplicated additional
2060 return false;
2061 }
2062 } else {
2063 // additional with these id doesn't exist, then all ok
2064 return true;
2065 }
2066}
2067
2068
2069void
2072 // remove element
2074 // reset pointer
2075 myAdditionalToOverwrite = nullptr;
2076 }
2077}
2078
2079
2081 myNet(nullptr),
2082 myAllowUndoRedo(false),
2083 myOverwrite(false) {
2084}
2085
2086// ===========================================================================
2087// GNEAdditionalHandler::NeteditParameters method definitions
2088// ===========================================================================
2089
2091 select(sumoBaseObject->hasBoolAttribute(GNE_ATTR_SELECTED) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_SELECTED) : false),
2092 centerAfterCreation(sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) : false) {
2093}
2094
2095
2097
2098
2100 select(false),
2101 centerAfterCreation(false) {
2102}
2103
2104/****************************************************************************/
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:270
#define TL(string)
Definition MsgHandler.h:287
#define TLF(string,...)
Definition MsgHandler.h:288
#define TIME2STEPS(x)
Definition SUMOTime.h:57
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
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_SINK
Sink(s) specification.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_SOURCE
a source
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ GNE_TAG_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_WEIGHT
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ROADSIDE_CAPACITY
@ SUMO_ATTR_CURRENTLIMIT
current limit of the traction substation [A]
@ SUMO_ATTR_CHARGINGPOWER
@ SUMO_ATTR_PROB
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations.
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
const double SUMO_const_laneWidth
Definition StdDefs.h:48
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
void writeError(const std::string &error)
write error and enable error creating element
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp: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 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 bool lefthand, const Parameterised::Map &parameters)
Builds a Parking Area.
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 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 std::string &id, const SumoXMLTag parent, const std::string &parentID)
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.
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)
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:480
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:840
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:124
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:118
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:620
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition GNENet.cpp:2626
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:120
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
void enableUpdateGeometry()
Definition GNENet.cpp:2620
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
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.
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.
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:4564
C++ TraCI client API implementation.
std::map< std::string, std::string > Map
parameters map
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:300
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 getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Structure representing possible vehicle parameter.
std::string vtypeid
The vehicle's type id.
std::string routeid
The vehicle's route id.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
const bool centerAfterCreation
center view after creation