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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Builds trigger objects for netedit
19/****************************************************************************/
20#include <config.h>
21
23#include <netedit/GNEViewNet.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNENet.h>
28
30#include "GNEAccess.h"
31#include "GNEBusStop.h"
32#include "GNECalibrator.h"
33#include "GNECalibratorFlow.h"
34#include "GNEChargingStation.h"
36#include "GNEClosingReroute.h"
37#include "GNEContainerStop.h"
38#include "GNEDestProbReroute.h"
41#include "GNELaneAreaDetector.h"
44#include "GNEOverheadWire.h"
45#include "GNEPOI.h"
46#include "GNEParkingArea.h"
48#include "GNEParkingSpace.h"
49#include "GNEPoly.h"
50#include "GNERerouter.h"
51#include "GNERerouterInterval.h"
52#include "GNERerouterSymbol.h"
53#include "GNERouteProbReroute.h"
54#include "GNERouteProbe.h"
55#include "GNETAZ.h"
56#include "GNETAZSourceSink.h"
58#include "GNEVaporizer.h"
62
63
64// ===========================================================================
65// GNEAdditionalHandler method definitions
66// ===========================================================================
67
68GNEAdditionalHandler::GNEAdditionalHandler(GNENet* net, const bool allowUndoRedo, const bool overwrite) :
69 myNet(net),
70 myAllowUndoRedo(allowUndoRedo),
71 myOverwrite(overwrite) {
72}
73
74
77
78
79void
81 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
82 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
83 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
84 // check conditions
88 // get netedit parameters
89 NeteditParameters neteditParameters(sumoBaseObject);
90 // get lane
91 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
92 // check lane
93 if (lane == nullptr) {
95 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
97 } else if (personCapacity < 0) {
99 } else if (parkingLength < 0) {
101 } else {
102 // build busStop
103 GNEAdditional* busStop = GNEBusStop::buildBusStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
104 parkingLength, color, friendlyPosition, parameters);
105 // insert depending of allowUndoRedo
106 if (myAllowUndoRedo) {
107 myNet->getViewNet()->getUndoList()->begin(busStop, TL("add bus stop '") + id + "'");
109 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
111 } else {
113 lane->addChildElement(busStop);
114 busStop->incRef("buildBusStop");
115 }
116 }
117 } else {
119 }
120}
121
122
123void
125 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
126 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
127 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
128 // check conditions
132 // get netedit parameters
133 NeteditParameters neteditParameters(sumoBaseObject);
134 // get lane
135 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
136 // check lane
137 if (lane == nullptr) {
139 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
141 } else if (personCapacity < 0) {
143 } else if (parkingLength < 0) {
145 } else {
146 // build trainStop
147 GNEAdditional* trainStop = GNEBusStop::buildTrainStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
148 parkingLength, color, friendlyPosition, parameters);
149 // insert depending of allowUndoRedo
150 if (myAllowUndoRedo) {
151 myNet->getViewNet()->getUndoList()->begin(trainStop, TL("add train stop '") + id + "'");
153 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(trainStop, true), true);
155 } else {
157 lane->addChildElement(trainStop);
158 trainStop->incRef("buildTrainStop");
159 }
160 }
161 } else {
163 }
164}
165
166
167void
168GNEAdditionalHandler::buildAccess(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID,
169 const std::string& pos, const double length, const bool friendlyPos, const Parameterised::Map& parameters) {
170 // get netedit parameters
171 NeteditParameters neteditParameters(sumoBaseObject);
172 // get lane
173 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
174 // get busStop (or trainStop)
175 GNEAdditional* busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_BUS_STOP);
176 if (busStop == nullptr) {
177 busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_TRAIN_STOP);
178 }
179 // pos double
180 bool validPos = true;
181 double posDouble = 0;
182 if (lane) {
183 if (GNEAttributeCarrier::canParse<double>(pos)) {
184 posDouble = GNEAttributeCarrier::parse<double>(pos);
185 validPos = checkLanePosition(posDouble, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
186 } else if (pos == "random" || pos == "doors" || pos == "carriage") {
187 posDouble = INVALID_DOUBLE;
188 } else if (pos.empty()) {
189 posDouble = 0;
190 } else {
191 validPos = false;
192 }
193 }
194 // Check if busStop parent and lane is correct
195 if (lane == nullptr) {
197 } else if (busStop == nullptr) {
199 } else if (!validPos) {
201 } else if ((length != -1) && (length < 0)) {
203 } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
204 WRITE_WARNING(TL("Could not build access in netedit; busStop parent already owns an access in the edge '") + lane->getParentEdge()->getID() + "'");
205 } else if (!lane->allowPedestrians()) {
206 WRITE_WARNING(TLF("Could not build access in netedit; The lane '%' doesn't support pedestrians", lane->getID()));
207 } else {
208 // build access
209 GNEAdditional* access = new GNEAccess(busStop, lane, myNet, posDouble, pos, friendlyPos, length, parameters);
210 // insert depending of allowUndoRedo
211 if (myAllowUndoRedo) {
212 myNet->getViewNet()->getUndoList()->begin(access, TL("add access in '") + busStop->getID() + "'");
214 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(access, true), true);
216 } else {
218 lane->addChildElement(access);
219 busStop->addChildElement(access);
220 access->incRef("buildAccess");
221 }
222 }
223}
224
225
226void
227GNEAdditionalHandler::buildContainerStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
228 const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines, const int containerCapacity,
229 const double parkingLength, const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
230 // check conditions
233 } else if (checkDuplicatedID({SUMO_TAG_CONTAINER_STOP}, id)) {
234 // get netedit parameters
235 NeteditParameters neteditParameters(sumoBaseObject);
236 // get lane
237 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
238 // check lane
239 if (lane == nullptr) {
241 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
243 } else if (containerCapacity < 0) {
245 } else if (parkingLength < 0) {
247 } else {
248 // build containerStop
249 GNEAdditional* containerStop = new GNEContainerStop(id, lane, myNet, startPos, endPos, name, lines, containerCapacity, parkingLength,
250 color, friendlyPosition, parameters);
251 // insert depending of allowUndoRedo
252 if (myAllowUndoRedo) {
253 myNet->getViewNet()->getUndoList()->begin(containerStop, TL("add container stop '") + id + "'");
255 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
257 } else {
259 lane->addChildElement(containerStop);
260 containerStop->incRef("buildContainerStop");
261 }
262 }
263 } else {
265 }
266}
267
268
269void
271 const std::string& laneID, const double startPos, const double endPos, const std::string& name, const double chargingPower,
272 const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string& chargeType,
273 const SUMOTime waitingTime, const bool friendlyPosition, const std::string& /* parkingAreaID */, const Parameterised::Map& parameters) {
274 // check conditions
278 // get netedit parameters
279 NeteditParameters neteditParameters(sumoBaseObject);
280 // get lane
281 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
282 // check lane
283 if (lane == nullptr) {
285 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
287 } else if (chargingPower < 0) {
289 } else if (chargeDelay < 0) {
291 } else {
292 // build chargingStation
293 GNEAdditional* chargingStation = new GNEChargingStation(id, lane, myNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit,
294 chargeDelay, chargeType, waitingTime, friendlyPosition, parameters);
295 // insert depending of allowUndoRedo
296 if (myAllowUndoRedo) {
297 myNet->getViewNet()->getUndoList()->begin(chargingStation, TL("add charging station '") + id + "'");
299 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
301 } else {
302 myNet->getAttributeCarriers()->insertAdditional(chargingStation);
303 lane->addChildElement(chargingStation);
304 chargingStation->incRef("buildChargingStation");
305 }
306 }
307 } else {
309 }
310
311}
312
313
314void
315GNEAdditionalHandler::buildParkingArea(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
316 const double startPos, const double endPos, const std::string& departPos, const std::string& name,
317 const std::vector<std::string>& badges, const bool friendlyPosition, const int roadSideCapacity, const bool onRoad,
318 const double width, const double length, const double angle, const bool lefthand, const Parameterised::Map& parameters) {
319 // check conditions
322 } else if (checkDuplicatedID({SUMO_TAG_PARKING_AREA}, id)) {
323 // get netedit parameters
324 NeteditParameters neteditParameters(sumoBaseObject);
325 // get lane
326 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
327 // get departPos double
328 const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
329 // check lane
330 if (lane == nullptr) {
332 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
334 } else if (roadSideCapacity < 0) {
336 } else if (width < 0) {
338 } else if (length < 0) {
340 } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
341 writeError(TLF("Could not build parking area with ID '%' in netedit; Invalid departPos over lane.", id));
342 } else {
343 // build parkingArea
344 GNEAdditional* parkingArea = new GNEParkingArea(id, lane, myNet, startPos, endPos, GNEAttributeCarrier::canParse<double>(departPos) ? departPos : "",
345 name, badges, friendlyPosition, roadSideCapacity, onRoad,
346 (width == 0) ? SUMO_const_laneWidth : width, length, angle, lefthand, parameters);
347 // insert depending of allowUndoRedo
348 if (myAllowUndoRedo) {
349 myNet->getViewNet()->getUndoList()->begin(parkingArea, TL("add parking area '") + id + "'");
351 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
353 } else {
355 lane->addChildElement(parkingArea);
356 parkingArea->incRef("buildParkingArea");
357 }
358 }
359 } else {
361 }
362}
363
364
365void
366GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
367 const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
368 const Parameterised::Map& parameters) {
369 // check width and heights
370 if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
371 writeError(TL("Could not build parking space in netedit; attribute width cannot be parse to float."));
372 } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
373 writeError(TL("Could not build parking space in netedit; attribute length cannot be parse to float."));
374 } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
375 writeError(TL("Could not build parking space in netedit; attribute angle cannot be parse to float."));
376 } else {
377 // get netedit parameters
378 NeteditParameters neteditParameters(sumoBaseObject);
379 // get lane
380 GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
381 // get double values
382 const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
383 const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
384 // check lane
385 if (parkingArea == nullptr) {
387 } else if (widthDouble < 0) {
389 } else if (lengthDouble < 0) {
391 } else {
392 // build parkingSpace
393 GNEAdditional* parkingSpace = new GNEParkingSpace(myNet, parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
394 // insert depending of allowUndoRedo
395 if (myAllowUndoRedo) {
396 myNet->getViewNet()->getUndoList()->begin(parkingSpace, TL("add parking space in '") + parkingArea->getID() + "'");
398 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
400 } else {
402 parkingArea->addChildElement(parkingSpace);
403 parkingSpace->incRef("buildParkingSpace");
404 }
405 // update geometry (due boundaries)
406 parkingSpace->updateGeometry();
407 }
408 }
409}
410
411
412void
413GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
414 const double position, const SUMOTime period, const std::string& file, const std::vector<std::string>& vehicleTypes,
415 const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
416 const bool friendlyPos, const Parameterised::Map& parameters) {
417 // check conditions
420 } else if (checkDuplicatedID({SUMO_TAG_INDUCTION_LOOP}, id)) {
421 // get netedit parameters
422 NeteditParameters neteditParameters(sumoBaseObject);
423 // get lane
424 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
425 // check lane
426 if (lane == nullptr) {
428 } else if (!checkLanePosition(position, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
430 } else if (period < 0) {
432 } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
434 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
436 } else {
437 // build E1
438 GNEAdditional* detectorE1 = new GNEInductionLoopDetector(id, lane, myNet, position, period, file, vehicleTypes,
439 nextEdges, detectPersons, name, friendlyPos, parameters);
440 // insert depending of allowUndoRedo
441 if (myAllowUndoRedo) {
442 myNet->getViewNet()->getUndoList()->begin(detectorE1, TL("add induction loop '") + id + "'");
444 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
446 } else {
448 lane->addChildElement(detectorE1);
449 detectorE1->incRef("buildDetectorE1");
450 }
451 }
452 } else {
454 }
455}
456
457
458void
459GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
460 const double pos, const double length, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
461 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
462 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
463 const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
464 // check conditions
468 // get netedit parameters
469 NeteditParameters neteditParameters(sumoBaseObject);
470 // get lane
471 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
472 // check lane
473 if (lane == nullptr) {
475 } else {
476 // check friendlyPos in small lanes
477 const bool friendlyPosCheck = checkFriendlyPosSmallLanes(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
478 if (!checkLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosCheck)) {
480 } else if (length < 0) {
482 } else if ((period != -1) && (period < 0)) {
484 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
485 // temporal
486 writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
487 } else if (timeThreshold < 0) {
489 } else if (speedThreshold < 0) {
491 } else if (jamThreshold < 0) {
493 } else if (timeThreshold < 0) {
495 } else if (speedThreshold < 0) {
497 } else if (jamThreshold < 0) {
499 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
501 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
503 } else {
504 // build E2 single lane
505 GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, lane, myNet, pos, length, period, trafficLight, filename,
506 vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
507 speedThreshold, jamThreshold, friendlyPosCheck, show, parameters);
508 // insert depending of allowUndoRedo
509 if (myAllowUndoRedo) {
510 myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
512 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
514 } else {
516 lane->addChildElement(detectorE2);
517 detectorE2->incRef("buildDetectorE2");
518 }
519 }
520 }
521 } else {
523 }
524}
525
526
527void
528GNEAdditionalHandler::buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::vector<std::string>& laneIDs,
529 const double pos, const double endPos, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
530 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
531 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
532 const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
533 // check conditions
537 // get netedit parameters
538 NeteditParameters neteditParameters(sumoBaseObject);
539 // get lanes
540 const auto lanes = parseLanes(SUMO_TAG_LANE_AREA_DETECTOR, laneIDs);
541 // check lanes
542 if (lanes.size() > 0) {
543 // calculate path
545 writeError(TLF("Could not build lane area detector with ID '%' in netedit; Lanes aren't consecutives.", id));
546 } else if (!checkMultiLanePosition(
547 pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
548 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
550 } else if ((period != -1) && (period < 0)) {
552 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
553 // temporal
554 writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
555 } else if (timeThreshold < 0) {
557 } else if (speedThreshold < 0) {
559 } else if (jamThreshold < 0) {
561 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
563 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
565 } else {
566 // build E2 multilane detector
567 GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, lanes, myNet, pos, endPos, period, trafficLight, filename,
568 vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
569 speedThreshold, jamThreshold, friendlyPos, show, parameters);
570 // insert depending of allowUndoRedo
571 if (myAllowUndoRedo) {
572 myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
574 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
576 } else {
578 for (const auto& lane : lanes) {
579 lane->addChildElement(detectorE2);
580 }
581 detectorE2->incRef("buildDetectorE2Multilane");
582 }
583 }
584 } else {
586 }
587 } else {
589 }
590}
591
592
593void
594GNEAdditionalHandler::buildDetectorE3(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos, const SUMOTime period,
595 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
596 const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold, const double speedThreshold,
597 const bool openEntry, const bool expectedArrival, const Parameterised::Map& parameters) {
598 // check conditions
601 } else if (period < 0) {
603 } else if (timeThreshold < 0) {
605 } else if (speedThreshold < 0) {
607 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
609 } else if (!vehicleTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vehicleTypes)) {
612 // get netedit parameters
613 NeteditParameters neteditParameters(sumoBaseObject);
614 // build E3
615 GNEAdditional* E3 = new GNEMultiEntryExitDetector(id, myNet, pos, period, filename, vehicleTypes, nextEdges, detectPersons,
616 name, timeThreshold, speedThreshold, openEntry, expectedArrival, parameters);
617 // insert depending of allowUndoRedo
618 if (myAllowUndoRedo) {
619 myNet->getViewNet()->getUndoList()->begin(E3, TL("add entry-exit detector '") + id + "'");
621 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
623 } else {
625 E3->incRef("buildDetectorE3");
626 }
627 } else {
629 }
630}
631
632
633void
634GNEAdditionalHandler::buildDetectorEntry(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
635 const bool friendlyPos, const Parameterised::Map& parameters) {
636 // get lane
637 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
638 // get E3 parent
640 // Check if Detector E3 parent and lane is correct
641 if (lane == nullptr) {
643 } else if (E3 == nullptr) {
645 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
647 } else {
648 // get netedit parameters
649 NeteditParameters neteditParameters(sumoBaseObject);
650 // build entry instant
651 GNEAdditional* entry = new GNEEntryExitDetector(SUMO_TAG_DET_ENTRY, myNet, E3, lane, pos, friendlyPos, parameters);
652 // insert depending of allowUndoRedo
653 if (myAllowUndoRedo) {
654 myNet->getViewNet()->getUndoList()->begin(entry, TL("add entry detector in '") + E3->getID() + "'");
656 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
658 } else {
660 lane->addChildElement(entry);
661 E3->addChildElement(entry);
662 entry->incRef("buildDetectorEntry");
663 }
664 }
665}
666
667
668void
669GNEAdditionalHandler::buildDetectorExit(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
670 const bool friendlyPos, const Parameterised::Map& parameters) {
671 // get lane
672 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
673 // get E3 parent
675 // Check if Detector E3 parent and lane is correct
676 if (lane == nullptr) {
678 } else if (E3 == nullptr) {
680 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
682 } else {
683 // get netedit parameters
684 NeteditParameters neteditParameters(sumoBaseObject);
685 // build exit instant
686 GNEAdditional* exit = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet, E3, lane, pos, friendlyPos, parameters);
687 // insert depending of allowUndoRedo
688 if (myAllowUndoRedo) {
689 myNet->getViewNet()->getUndoList()->begin(exit, TL("add exit detector in '") + E3->getID() + "'");
691 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
693 } else {
695 lane->addChildElement(exit);
696 E3->addChildElement(exit);
697 exit->incRef("buildDetectorExit");
698 }
699 }
700}
701
702
703void
704GNEAdditionalHandler::buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, double pos,
705 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
706 const std::string& detectPersons, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters) {
707 // check conditions
711 // get netedit parameters
712 NeteditParameters neteditParameters(sumoBaseObject);
713 // get lane
714 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
715 // check lane
716 if (lane == nullptr) {
718 } else if (!SUMOXMLDefinitions::isValidFilename(filename)) {
720 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
722 } else {
723 // build E1 instant
724 GNEAdditional* detectorE1Instant = new GNEInstantInductionLoopDetector(id, lane, myNet, pos, filename, vehicleTypes, nextEdges,
725 detectPersons, name, friendlyPos, parameters);
726 // insert depending of allowUndoRedo
727 if (myAllowUndoRedo) {
728 myNet->getViewNet()->getUndoList()->begin(detectorE1Instant, TL("add instant induction loop '") + id + "'");
730 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
732 } else {
733 myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
734 lane->addChildElement(detectorE1Instant);
735 detectorE1Instant->incRef("buildDetectorE1Instant");
736 }
737 }
738 } else {
740 }
741}
742
743
744void
745GNEAdditionalHandler::buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, const double pos,
746 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
747 const Parameterised::Map& parameters) {
748 // get lane
749 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
750 // get routeProbe
751 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
752 // check conditions
757 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
759 } else if (lane == nullptr) {
761 } else {
762 // get netedit parameters
763 NeteditParameters neteditParameters(sumoBaseObject);
764 // check lane
765 if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
767 } else if (period < 0) {
769 } else if (jamThreshold < 0) {
771 } else {
772 // build Calibrator
773 GNEAdditional* calibrator = (routeProbe == nullptr) ?
774 new GNECalibrator(id, myNet, lane, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
775 new GNECalibrator(id, myNet, lane, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
776 // insert depending of allowUndoRedo
777 if (myAllowUndoRedo) {
778 myNet->getViewNet()->getUndoList()->begin(calibrator, TL("add lane calibrator '") + id + "'");
780 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
782 // center after creation
783 if (neteditParameters.centerAfterCreation) {
784 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
785 }
786 } else {
788 lane->addChildElement(calibrator);
789 if (routeProbe) {
790 routeProbe->addChildElement(calibrator);
791 }
792 calibrator->incRef("buildCalibrator");
793 }
794 }
795 }
796}
797
798
799void
800GNEAdditionalHandler::buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const double pos,
801 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
802 const Parameterised::Map& parameters) {
803 // get edge
804 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
805 // get routeProbe
806 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
807 // check conditions
812 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
814 } else if (edge == nullptr) {
816 } else {
817 // get netedit parameters
818 NeteditParameters neteditParameters(sumoBaseObject);
819 if (!checkLanePosition(pos, 0, edge->getLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
821 } else if (period < 0) {
823 } else if (jamThreshold < 0) {
825 } else {
826 // build Calibrator
827 GNEAdditional* calibrator = (routeProbe == nullptr) ?
828 new GNECalibrator(id, myNet, edge, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
829 new GNECalibrator(id, myNet, edge, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
830 // insert depending of allowUndoRedo
831 if (myAllowUndoRedo) {
832 myNet->getViewNet()->getUndoList()->begin(calibrator, TL("add calibrator '") + id + "'");
834 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
836 // center after creation
837 if (neteditParameters.centerAfterCreation) {
838 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
839 }
840 } else {
842 edge->addChildElement(calibrator);
843 if (routeProbe) {
844 routeProbe->addChildElement(calibrator);
845 }
846 calibrator->incRef("buildCalibrator");
847 }
848 }
849 }
850}
851
852
853void
855 // get vType
856 GNEDemandElement* vType = myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, vehicleParameter.vtypeid.empty() ? DEFAULT_VTYPE_ID : vehicleParameter.vtypeid, false);
857 // get route
859 // get calibrator parent
861 // check parents
862 if (vType == nullptr) {
864 } else if (route == nullptr) {
866 } else if (calibrator == nullptr) {
868 } else {
869 // create calibrator flow
870 GNEAdditional* flow = new GNECalibratorFlow(calibrator, vType, route, vehicleParameter);
871 // insert depending of allowUndoRedo
872 if (myAllowUndoRedo) {
873 myNet->getViewNet()->getUndoList()->begin(flow, TL("add calibrator flow in '") + calibrator->getID() + "'");
875 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
877 } else {
878 calibrator->addChildElement(flow);
879 route->addChildElement(flow);
880 vType->addChildElement(flow);
881 flow->incRef("buildCalibratorFlow");
882 }
883 }
884}
885
886
887void
888GNEAdditionalHandler::buildRerouter(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const Position& pos,
889 const std::vector<std::string>& edgeIDs, const double prob, const std::string& name,
890 const bool off, const bool optional, const SUMOTime timeThreshold,
891 const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
892 // check conditions
895 } else if (prob < 0) {
897 } else if (timeThreshold < 0) {
899 } else if (!vTypes.empty() && !SUMOXMLDefinitions::isValidListOfTypeID(vTypes)) {
901 } else if (checkDuplicatedID({SUMO_TAG_REROUTER}, id)) {
902 // get netedit parameters
903 NeteditParameters neteditParameters(sumoBaseObject);
904 // parse edges
905 std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, edgeIDs);
906 // check edges
907 if (edges.size() > 0) {
908 GNEAdditional* rerouter = nullptr;
909 // continue depending of position
910 if (pos == Position::INVALID) {
911 if (edges.size() > 0) {
912 PositionVector laneShape = edges.front()->getLanes().front()->getLaneShape();
913 // move to side
914 laneShape.move2side(3);
915 // create rerouter
916 rerouter = new GNERerouter(id, myNet, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, prob, off, optional, timeThreshold, vTypes, parameters);
917 } else {
918 rerouter = new GNERerouter(id, myNet, Position(0, 0), name, prob, off, optional, timeThreshold, vTypes, parameters);
919 }
920 } else {
921 rerouter = new GNERerouter(id, myNet, pos, name, prob, off, optional, timeThreshold, vTypes, parameters);
922 }
923 // create rerouter Symbols
924 std::vector<GNEAdditional*> rerouterSymbols;
925 for (const auto& edge : edges) {
926 rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
927 }
928 // insert depending of allowUndoRedo
929 if (myAllowUndoRedo) {
930 myNet->getViewNet()->getUndoList()->begin(rerouter, TL("add rerouter '") + id + "'");
932 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
933 // add symbols
934 for (const auto& rerouterSymbol : rerouterSymbols) {
935 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
936 }
938 } else {
940 rerouter->incRef("buildRerouter");
941 // add symbols into rerouter
942 for (const auto& rerouterSymbol : rerouterSymbols) {
943 rerouter->addChildElement(rerouterSymbol);
944 }
945 // add symbols into edges
946 for (int i = 0; i < (int)edges.size(); i++) {
947 edges.at(i)->addChildElement(rerouterSymbols.at(i));
948 }
949 }
950 }
951 } else {
953 }
954}
955
956
957void
959 // get rerouter parent
960 GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
961 // check if rerouter exist
962 if (rerouter == nullptr) {
964 } else if (begin < 0) {
966 } else if (end < 0) {
968 } else if (end < begin) {
969 writeError(TLF("Could not build interval with ID '%' in netedit; begin is greater than end.", rerouter->getID()));
970 } else {
971 // check if new interval will produce a overlapping
972 if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
973 // create rerouter interval and add it into rerouter parent
974 GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
975 // insert depending of allowUndoRedo
976 if (myAllowUndoRedo) {
977 myNet->getViewNet()->getUndoList()->begin(rerouterInterval, TL("add rerouter interval in '") + rerouter->getID() + "'");
979 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
981 } else {
982 rerouter->addChildElement(rerouterInterval);
983 rerouterInterval->incRef("buildRerouterInterval");
984 }
985 } else {
986 writeError(TLF("Could not build interval with begin '%' and end '%' in '%' due overlapping.", toString(begin), toString(end), rerouter->getID()));
987 }
988 }
989}
990
991
992void
993GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
994 // get rerouter interval parent
995 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
996 // get closed lane
997 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
998 // check parents
999 if (lane == nullptr) {
1001 } else if (rerouterInterval == nullptr) {
1003 } else {
1004 // create closing lane reroute
1005 GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
1006 // add it to interval parent depending of allowUndoRedo
1007 if (myAllowUndoRedo) {
1008 myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing lane reroute in '") + lane->getID() + "'");
1010 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1012 } else {
1013 rerouterInterval->addChildElement(closingLaneReroute);
1014 closingLaneReroute->incRef("buildClosingLaneReroute");
1015 }
1016 }
1017}
1018
1019
1020void
1021GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
1022 // get rerouter interval parent
1023 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1024 // get closed edge
1025 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
1026 // check parents
1027 if (edge == nullptr) {
1029 } else if (rerouterInterval == nullptr) {
1031 } else {
1032 // create closing reroute
1033 GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
1034 // add it to interval parent depending of allowUndoRedo
1035 if (myAllowUndoRedo) {
1036 myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing reroute in '") + edge->getID() + "'");
1038 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1040 } else {
1041 rerouterInterval->addChildElement(closingLaneReroute);
1042 closingLaneReroute->incRef("buildClosingLaneReroute");
1043 }
1044 }
1045}
1046
1047void
1048GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1049 // get rerouter interval parent
1050 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1051 // get edge
1052 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1053 // check parents
1054 if (edge == nullptr) {
1056 } else if (rerouterInterval == nullptr) {
1058 } else {
1059 // create dest probability reroute
1060 GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1061 // add it to interval parent depending of allowUndoRedo
1062 if (myAllowUndoRedo) {
1063 myNet->getViewNet()->getUndoList()->begin(destProbReroute, TL("add dest prob reroute in '") + edge->getID() + "'");
1065 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1067 } else {
1068 rerouterInterval->addChildElement(destProbReroute);
1069 destProbReroute->incRef("builDestProbReroute");
1070 }
1071 }
1072}
1073
1074
1075void
1076GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1077 // get rerouter interval parent
1078 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1079 // get parking area
1080 GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1081 // check parents
1082 if (parkingArea == nullptr) {
1084 } else if (rerouterInterval == nullptr) {
1086 } else {
1087 // create parking area reroute
1088 GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1089 // add it to interval parent depending of allowUndoRedo
1090 if (myAllowUndoRedo) {
1091 myNet->getViewNet()->getUndoList()->begin(parkingAreaReroute, TL("add parking area reroute in '") + parkingArea->getID() + "'");
1093 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1095 } else {
1096 rerouterInterval->addChildElement(parkingAreaReroute);
1097 parkingAreaReroute->incRef("builParkingAreaReroute");
1098 }
1099 }
1100}
1101
1102
1103void
1104GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1105 // get rerouter interval parent
1106 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1107 // get route parent
1109 // check parents
1110 if (route == nullptr) {
1112 } else if (rerouterInterval == nullptr) {
1114 } else {
1115 // create rout prob reroute
1116 GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1117 // add it to interval parent depending of allowUndoRedo
1118 if (myAllowUndoRedo) {
1119 myNet->getViewNet()->getUndoList()->begin(routeProbReroute, TL("add route prob reroute in '") + route->getID() + "'");
1121 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1123 } else {
1124 rerouterInterval->addChildElement(routeProbReroute);
1125 routeProbReroute->incRef("buildRouteProbReroute");
1126 }
1127 }
1128}
1129
1130
1131void
1132GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime period,
1133 const std::string& name, const std::string& file, const SUMOTime begin, const std::vector<std::string>& vTypes,
1134 const Parameterised::Map& parameters) {
1135 // check conditions
1138 } else if (checkDuplicatedID({SUMO_TAG_ROUTEPROBE}, id)) {
1139 // get netedit parameters
1140 NeteditParameters neteditParameters(sumoBaseObject);
1141 // get edge
1142 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1143 // check lane
1144 if (edge == nullptr) {
1146 } else if (period < 0) {
1148 } else if (begin < 0) {
1150 } else if (!SUMOXMLDefinitions::isValidFilename(file)) {
1152 } else {
1153 // build route probe
1154 GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, edge, period, name, file, begin, vTypes, parameters);
1155 // insert depending of allowUndoRedo
1156 if (myAllowUndoRedo) {
1157 myNet->getViewNet()->getUndoList()->begin(routeProbe, TL("add route probe '") + id + "'");
1159 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1161 // center after creation
1162 if (neteditParameters.centerAfterCreation) {
1163 myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1164 }
1165 } else {
1167 edge->addChildElement(routeProbe);
1168 routeProbe->incRef("buildRouteProbe");
1169 }
1170 }
1171 } else {
1173 }
1174}
1175
1176
1177void
1179 const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
1183 } else if (checkDuplicatedID({SUMO_TAG_VSS}, id)) {
1184 // get netedit parameters
1185 NeteditParameters neteditParameters(sumoBaseObject);
1186 // parse lanes
1187 std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, laneIDs);
1188 // check lane
1189 if (lanes.size() > 0) {
1190 // check vTypes
1191 if (!vTypes.empty() && !checkListOfVehicleTypes(vTypes)) {
1193 } else {
1194 // create VSS
1195 GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, pos, name, vTypes, parameters);
1196 // create VSS Symbols
1197 std::vector<GNEAdditional*> VSSSymbols;
1198 for (const auto& lane : lanes) {
1199 VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1200 }
1201 // insert depending of allowUndoRedo
1202 if (myAllowUndoRedo) {
1203 myNet->getViewNet()->getUndoList()->begin(variableSpeedSign, TL("add Variable Speed Sign '") + id + "'");
1205 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1206 for (const auto& VSSSymbol : VSSSymbols) {
1207 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1208 }
1210 } else {
1211 myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1212 variableSpeedSign->incRef("buildVariableSpeedSign");
1213 // add symbols into VSS
1214 for (const auto& VSSSymbol : VSSSymbols) {
1215 variableSpeedSign->addChildElement(VSSSymbol);
1216 }
1217 // add symbols into lanes
1218 for (int i = 0; i < (int)lanes.size(); i++) {
1219 lanes.at(i)->addChildElement(VSSSymbols.at(i));
1220 }
1221 }
1222 }
1223 }
1224 } else {
1226 }
1227}
1228
1229
1230void
1231GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1232 // get VSS parent
1233 GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1234 // check lane
1235 if (VSS == nullptr) {
1237 } else if (time < 0) {
1239 } else {
1240 // create Variable Speed Sign
1241 GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1242 // add it depending of allow undoRedo
1243 if (myAllowUndoRedo) {
1244 myNet->getViewNet()->getUndoList()->begin(variableSpeedSignStep, TL("add VSS Step in '") + VSS->getID() + "'");
1246 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1248 } else {
1249 VSS->addChildElement(variableSpeedSignStep);
1250 variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1251 }
1252 }
1253}
1254
1255
1256void
1257GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1258 const SUMOTime endTime, const std::string& name, const Parameterised::Map& parameters) {
1259 // check conditions
1262 } else if (checkDuplicatedID({SUMO_TAG_VAPORIZER}, edgeID)) {
1263 // get netedit parameters
1264 NeteditParameters neteditParameters(sumoBaseObject);
1265 // get edge
1266 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1267 // check lane
1268 if (edge == nullptr) {
1270 } else if (beginTime < 0) {
1272 } else if (endTime < 0) {
1274 } else if (endTime < beginTime) {
1275 writeError(TLF("Could not build Vaporizer with ID '%' in netedit; begin is greater than end.", edge->getID()));
1276 } else {
1277 // build vaporizer
1278 GNEAdditional* vaporizer = new GNEVaporizer(myNet, edge, beginTime, endTime, name, parameters);
1279 // add it depending of allow undoRed
1280 if (myAllowUndoRedo) {
1281 myNet->getViewNet()->getUndoList()->begin(vaporizer, TL("add vaporizer in '") + edge->getID() + "'");
1283 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1285 // center after creation
1286 if (neteditParameters.centerAfterCreation) {
1287 myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1288 }
1289 } else {
1291 edge->addChildElement(vaporizer);
1292 vaporizer->incRef("buildVaporizer");
1293 }
1294 }
1295 } else {
1297 }
1298}
1299
1300
1301void
1302GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1303 const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1304 const std::string& name, const Parameterised::Map& parameters) {
1305 // parse edges
1306 const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, edgeIDs);
1307 // check TAZShape
1308 PositionVector TAZShape = shape;
1309 if (TAZShape.size() == 0) {
1310 // declare boundary
1311 Boundary TAZBoundary;
1312 for (const auto& edge : edges) {
1313 TAZBoundary.add(edge->getCenteringBoundary());
1314 }
1315 // iterate over children and add sourceSinkEdge boundaries to make a taz shape
1316 for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1317 // check that childre is a source or sink elements (to avoid parameters)
1318 if ((sourceSink->getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTag() == SUMO_TAG_TAZSINK)) {
1319 const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1320 if (sourceSinkEdge) {
1321 TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1322 }
1323 }
1324 }
1325 // update TAZShape
1326 TAZShape = TAZBoundary.getShape(true);
1327 }
1328 // check TAZ
1331 } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1333 } else if (TAZShape.size() == 0) {
1334 writeError(TLF("Could not build TAZ with ID '%' in netedit; Invalid Shape.", id));
1335 } else {
1336 // get netedit parameters
1337 NeteditParameters neteditParameters(sumoBaseObject);
1338 // build TAZ with the given shape
1339 const Position center2 = center == Position::INVALID ? TAZShape.getCentroid() : center;
1340 GNEAdditional* TAZ = new GNETAZ(id, myNet, TAZShape, center2, fill, color, name, parameters);
1341 // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1343 // add it depending of allow undoRed
1344 if (myAllowUndoRedo) {
1345 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ '") + id + "'");
1347 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
1348 // create TAZEdges
1349 for (const auto& edge : edges) {
1350 // create TAZ Source using GNEChange_Additional
1351 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1352 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1353 // create TAZ Sink using GNEChange_Additional
1354 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1355 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1356 }
1358 } else {
1360 TAZ->incRef("buildTAZ");
1361 for (const auto& edge : edges) {
1362 // create TAZ Source
1363 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1364 TAZSource->incRef("buildTAZ");
1365 TAZ->addChildElement(TAZSource);
1366 // create TAZ Sink
1367 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1368 TAZSink->incRef("buildTAZ");
1369 TAZ->addChildElement(TAZSink);
1370 }
1371 }
1372 // enable updating geometry again and update geometry of TAZ
1374 // update TAZ parent
1375 TAZ->updateGeometry();
1376 }
1377}
1378
1379
1380void
1381GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1382 // get TAZ parent
1384 // get edge
1385 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1386 // declare TAZ Sink
1387 GNEAdditional* TAZSink = nullptr;
1388 // check parents
1389 if (TAZ == nullptr) {
1391 } else if (edge == nullptr) {
1393 } else {
1394 // first check if a TAZSink in the same edge for the same TAZ
1395 for (const auto& TAZElement : edge->getChildAdditionals()) {
1396 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1397 TAZSink = TAZElement;
1398 }
1399 }
1400 // check if TAZSink has to be created
1401 if (TAZSink == nullptr) {
1402 // Create TAZ with weight 0 (default)
1403 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 0);
1404 // add it depending of allow undoRed
1405 if (myAllowUndoRedo) {
1406 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1408 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1410 } else {
1412 TAZ->addChildElement(TAZSink);
1413 TAZSink->incRef("buildTAZSource");
1414 }
1415 }
1416 // now check check if TAZSource exist
1417 GNEAdditional* TAZSource = nullptr;
1418 // first check if a TAZSink in the same edge for the same TAZ
1419 for (const auto& TAZElement : edge->getChildAdditionals()) {
1420 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1421 TAZSource = TAZElement;
1422 }
1423 }
1424 // check if TAZSource has to be created
1425 if (TAZSource == nullptr) {
1426 // Create TAZ only with departWeight
1427 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1428 // add it depending of allow undoRed
1429 if (myAllowUndoRedo) {
1430 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1432 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1434 } else {
1436 TAZ->addChildElement(TAZSource);
1437 TAZSource->incRef("buildTAZSource");
1438 }
1439 } else {
1440 // update TAZ Attribute depending of allow undoRed
1441 if (myAllowUndoRedo) {
1442 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Source in '") + TAZ->getID() + "'");
1443 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1445 } else {
1446 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1447 }
1448 }
1449 }
1450}
1451
1452
1453void
1454GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1455 // get TAZ parent
1457 // get edge
1458 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1459 // check parents
1460 if (TAZ == nullptr) {
1462 } else if (edge == nullptr) {
1464 } else {
1465 // declare TAZ source
1466 GNEAdditional* TAZSource = nullptr;
1467 // first check if a TAZSink in the same edge for the same TAZ
1468 for (const auto& TAZElement : edge->getChildAdditionals()) {
1469 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1470 TAZSource = TAZElement;
1471 }
1472 }
1473 // check if TAZSource has to be created
1474 if (TAZSource == nullptr) {
1475 // Create TAZ with empty value
1476 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 0);
1477 // add it depending of allow undoRed
1478 if (myAllowUndoRedo) {
1479 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1481 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1483 } else {
1485 TAZ->addChildElement(TAZSource);
1486 TAZSource->incRef("buildTAZSink");
1487 }
1488 }
1489 GNEAdditional* TAZSink = nullptr;
1490 // first check if a TAZSink in the same edge for the same TAZ
1491 for (const auto& TAZElement : edge->getChildAdditionals()) {
1492 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1493 TAZSink = TAZElement;
1494 }
1495 }
1496 // check if TAZSink has to be created
1497 if (TAZSink == nullptr) {
1498 // Create TAZ only with arrivalWeight
1499 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1500 // add it depending of allow undoRed
1501 if (myAllowUndoRedo) {
1502 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1504 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1506 } else {
1508 TAZ->addChildElement(TAZSink);
1509 TAZSink->incRef("buildTAZSink");
1510 }
1511 } else {
1512 // update TAZ Attribute depending of allow undoRed
1513 if (myAllowUndoRedo) {
1514 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Sink in '") + TAZ->getID() + "'");
1515 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1517 } else {
1518 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1519 }
1520 }
1521 }
1522}
1523
1524
1525void
1527 const double voltage, const double currentLimit, const Parameterised::Map& parameters) {
1528 // check conditions
1531 } else if (voltage < 0) {
1533 } else if (currentLimit < 0) {
1536 // get netedit parameters
1537 NeteditParameters neteditParameters(sumoBaseObject);
1538 // build traction substation
1539 GNEAdditional* tractionSubstation = new GNETractionSubstation(id, myNet, pos, voltage, currentLimit, parameters);
1540 // insert depending of allowUndoRedo
1541 if (myAllowUndoRedo) {
1542 myNet->getViewNet()->getUndoList()->begin(tractionSubstation, TL("add traction substation '") + id + "'");
1544 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(tractionSubstation, true), true);
1546 } else {
1547 myNet->getAttributeCarriers()->insertAdditional(tractionSubstation);
1548 tractionSubstation->incRef("buildTractionSubstation");
1549 }
1550 } else {
1552 }
1553}
1554
1555
1556void
1557GNEAdditionalHandler::buildOverheadWire(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& substationId,
1558 const std::vector<std::string>& laneIDs, const double startPos, const double endPos, const bool friendlyPos,
1559 const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters) {
1560 // check conditions
1564 // get netedit parameters
1565 NeteditParameters neteditParameters(sumoBaseObject);
1566 // get lanes
1567 const auto lanes = parseLanes(SUMO_TAG_OVERHEAD_WIRE_SECTION, laneIDs);
1568 // get traction substation
1569 const auto tractionSubstation = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, substationId, false);
1570 // check lanes
1571 if (lanes.size() > 0) {
1572 // calculate path
1574 writeError(TLF("Could not build overhead wire with ID '%' in netedit; Lanes aren't consecutives.", id));
1575 } else if (!checkMultiLanePosition(
1576 startPos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
1577 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1579 } else if (tractionSubstation == nullptr) {
1581 } else {
1582 // build Overhead Wire
1583 GNEAdditional* overheadWire = new GNEOverheadWire(id, lanes, tractionSubstation, myNet, startPos, endPos, friendlyPos, forbiddenInnerLanes, parameters);
1584 // insert depending of allowUndoRedo
1585 if (myAllowUndoRedo) {
1586 myNet->getViewNet()->getUndoList()->begin(overheadWire, TL("add overhead wire '") + id + "'");
1588 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(overheadWire, true), true);
1590 } else {
1592 for (const auto& lane : lanes) {
1593 lane->addChildElement(overheadWire);
1594 }
1595 overheadWire->incRef("buildOverheadWire");
1596 }
1597 }
1598 } else {
1600 }
1601 } else {
1603 }
1604}
1605
1606
1607void
1608GNEAdditionalHandler::buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject* /* sumoBaseObject */, const std::string& /* id */, const std::string& /* overheadWireIDStartClamp */,
1609 const std::string& /* laneIDStartClamp */, const std::string& /* overheadWireIDEndClamp */, const std::string& /* laneIDEndClamp */,
1610 const Parameterised::Map& /* parameters */) {
1611 //
1612}
1613
1614
1615void
1616GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1617 const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill,
1618 double lineWidth, const std::string& name, const Parameterised::Map& parameters) {
1619 // check conditions
1620 if (type == "jupedsim.walkable_area") {
1621 buildJpsWalkableArea(sumoBaseObject, id, shape, geo, name, parameters);
1622 } else if (type == "jupedsim.obstacle") {
1623 buildJpsObstacle(sumoBaseObject, id, shape, geo, name, parameters);
1626 } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1628 } else if (lineWidth < 0) {
1630 } else {
1631 // get netedit parameters
1632 NeteditParameters neteditParameters(sumoBaseObject);
1633 // create poly
1634 GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, name, parameters);
1635 // add it depending of allow undoRed
1636 if (myAllowUndoRedo) {
1637 myNet->getViewNet()->getUndoList()->begin(poly, TL("add polygon '") + id + "'");
1639 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(poly, true), true);
1641 } else {
1642 // insert shape without allowing undo/redo
1644 poly->incRef("addPolygon");
1645 }
1646 }
1647}
1648
1649
1650void
1651GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1652 const RGBColor& color, const double x, const double y, const std::string& icon, double layer, double angle,
1653 const std::string& imgFile, bool relativePath, double width, double height, const std::string& name,
1654 const Parameterised::Map& parameters) {
1655 // check conditions
1658 } else if (width < 0) {
1660 } else if (height < 0) {
1662 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1664 } else if (checkDuplicatedID(NamespaceIDs::POIs, id)) {
1665 // get netedit parameters
1666 NeteditParameters neteditParameters(sumoBaseObject);
1667 // create POI
1668 GNEPOI* POI = new GNEPOI(myNet, id, type, color, x, y, false, icon, layer, angle, imgFile, relativePath, width, height, name, parameters);
1669 // add it depending of allow undoRed
1670 if (myAllowUndoRedo) {
1671 myNet->getViewNet()->getUndoList()->begin(POI, TL("add POI '") + id + "'");
1673 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POI, true), true);
1675 } else {
1676 // insert shape without allowing undo/redo
1678 POI->incRef("addPOI");
1679 }
1680 } else {
1682 }
1683}
1684
1685
1686void
1687GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1688 const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat,
1689 const std::string& icon, double layer, double angle, const std::string& imgFile, bool relativePath, double width,
1690 double height, const std::string& name, const Parameterised::Map& parameters) {
1691 // check conditions
1694 } else if (width < 0) {
1696 } else if (height < 0) {
1698 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1700 } else if (checkDuplicatedID(NamespaceIDs::POIs, id)) {
1701 // get netedit parameters
1702 NeteditParameters neteditParameters(sumoBaseObject);
1703 // get lane
1704 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1705 // check lane
1706 if (lane == nullptr) {
1708 } else if (!checkLanePosition(posOverLane, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1710 } else {
1711 // create POI (use GNEAdditional instead GNEPOI for add child references)
1712 GNEAdditional* POILane = new GNEPOI(myNet, id, type, color, lane, posOverLane, friendlyPos, posLat, icon, layer,
1713 angle, imgFile, relativePath, width, height, name, parameters);
1714 // add it depending of allow undoRed
1715 if (myAllowUndoRedo) {
1716 myNet->getViewNet()->getUndoList()->begin(POILane, TL("add POI '") + id + "'");
1718 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POILane, true), true);
1720 } else {
1721 // insert shape without allowing undo/redo
1723 lane->addChildElement(POILane);
1724 POILane->incRef("buildPOILane");
1725 }
1726 }
1727 } else {
1729 }
1730}
1731
1732
1733void
1734GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1735 const RGBColor& color, const double lon, const double lat, const std::string& icon, double layer,
1736 double angle, const std::string& imgFile, bool relativePath, double width, double height,
1737 const std::string& name, const Parameterised::Map& parameters) {
1738 // check conditions
1741 } else if (width < 0) {
1743 } else if (height < 0) {
1745 } else if (!SUMOXMLDefinitions::isValidFilename(imgFile)) {
1747 } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1748 writeError(TLF("Could not build POI with ID '%' in netedit", id) + std::string("; ") + TL("Network requires a geo projection."));
1749 } else if (checkDuplicatedID(NamespaceIDs::POIs, id)) {
1750 // get netedit parameters
1751 NeteditParameters neteditParameters(sumoBaseObject);
1752 // create POIGEO
1753 GNEPOI* POIGEO = new GNEPOI(myNet, id, type, color, lon, lat, true, icon, layer, angle, imgFile, relativePath, width, height, name, parameters);
1754 // add it depending of allow undoRed
1755 if (myAllowUndoRedo) {
1756 myNet->getViewNet()->getUndoList()->begin(POIGEO, TL("add POI '") + id + "'");
1758 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POIGEO, true), true);
1760 } else {
1761 // insert shape without allowing undo/redo
1763 POIGEO->incRef("buildPOIGeo");
1764 }
1765 } else {
1767 }
1768}
1769
1770
1771void
1773 bool geo, const std::string& name, const Parameterised::Map& parameters) {
1774 // check conditions
1777 } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1779 } else {
1780 // get netedit parameters
1781 NeteditParameters neteditParameters(sumoBaseObject);
1782 // create walkable area
1783 GNEPoly* walkableArea = new GNEPoly(GNE_TAG_JPS_WALKABLEAREA, myNet, id, shape, geo, name, parameters);
1784 // add it depending of allow undoRed
1785 if (myAllowUndoRedo) {
1786 myNet->getViewNet()->getUndoList()->begin(walkableArea, TL("add jps walkable area '") + id + "'");
1788 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(walkableArea, true), true);
1790 } else {
1791 // insert shape without allowing undo/redo
1793 walkableArea->incRef("addWalkableArea");
1794 }
1795 }
1796}
1797
1798
1799void
1800GNEAdditionalHandler::buildJpsObstacle(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1801 bool geo, const std::string& name, const Parameterised::Map& parameters) {
1802 // check conditions
1805 } else if (!checkDuplicatedID(NamespaceIDs::polygons, id)) {
1807 } else {
1808 // get netedit parameters
1809 NeteditParameters neteditParameters(sumoBaseObject);
1810 // create walkable area
1811 GNEPoly* obstacle = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet, id, shape, geo, name, parameters);
1812 // add it depending of allow undoRed
1813 if (myAllowUndoRedo) {
1814 myNet->getViewNet()->getUndoList()->begin(obstacle, TL("add jps obstacle '") + id + "'");
1816 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(obstacle, true), true);
1818 } else {
1819 // insert shape without allowing undo/redo
1821 obstacle->incRef("addObstacle");
1822 }
1823 }
1824}
1825
1826
1827bool
1829 // check if exist another access for the same busStop in the given edge
1830 for (const auto& additional : busStopParent->getChildAdditionals()) {
1831 for (const auto& lane : edge->getLanes()) {
1832 if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1833 return false;
1834 }
1835 }
1836 }
1837 return true;
1838}
1839
1840
1841bool
1843 // declare a vector to keep sorted rerouter children
1844 std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1845 // iterate over child additional
1846 for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1847 if (!rerouterChild->getTagProperty().isSymbol()) {
1848 sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1849 // set begin and end
1850 sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1851 sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1852 }
1853 }
1854 // add new intervals
1855 sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1856 // sort children
1857 std::sort(sortedIntervals.begin(), sortedIntervals.end());
1858 // check overlapping after sorting
1859 for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1860 if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1861 return false;
1862 }
1863 }
1864 return true;
1865}
1866
1867
1868bool
1869GNEAdditionalHandler::checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos) {
1870 if (friendlyPos) {
1871 return true;
1872 }
1873 // adjust from and to (negative means that start at the end of lane and count backward)
1874 if (pos < 0) {
1875 pos += laneLength;
1876 }
1877 // check extremes
1878 if ((pos < 0) || (pos > laneLength)) {
1879 return false;
1880 }
1881 // check pos + length
1882 if ((pos + length) > laneLength) {
1883 return false;
1884 }
1885 // all OK
1886 return true;
1887}
1888
1889
1890void
1891GNEAdditionalHandler::fixLanePosition(double& pos, double& length, const double laneLength) {
1892 // negative pos means that start at the end of lane and count backward)
1893 if (pos < 0) {
1894 pos += laneLength;
1895 }
1896 // set position at the start
1897 if (pos < 0) {
1898 pos = 0;
1899 }
1900 // adjust pos
1901 if (pos >= laneLength) {
1902 pos = (laneLength - POSITION_EPS);
1903 }
1904 // adjust length
1905 if ((length < 0) || ((pos + length) > laneLength)) {
1906 length = POSITION_EPS;
1907 }
1908}
1909
1910
1911bool
1912GNEAdditionalHandler::checkFriendlyPosSmallLanes(double pos, const double length, const double laneLength, const bool friendlyPos) {
1913 if (friendlyPos == true) {
1914 return true;
1915 } else if (OptionsCont::getOptions().getBool("e2.friendlyPos.automatic")) {
1916 // adjust from and to (negative means that start at the end of lane and count backward)
1917 if (pos < 0) {
1918 pos += laneLength;
1919 }
1920 // check extremes
1921 if ((pos < 0) || (pos > laneLength)) {
1922 return true;
1923 }
1924 // check pos + length
1925 if ((pos + length) > laneLength) {
1926 return true;
1927 }
1928 }
1929 return false;
1930}
1931
1932
1933bool
1934GNEAdditionalHandler::checkLaneDoublePosition(double from, double to, const double laneLength, const bool friendlyPos) {
1935 if (friendlyPos) {
1936 return true;
1937 }
1938 // adjust from and to (negative means that start at the end of lane and count backward)
1939 if (from == INVALID_DOUBLE) {
1940 from = 0;
1941 }
1942 if (to == INVALID_DOUBLE) {
1943 to = laneLength;
1944 }
1945 if (from < 0) {
1946 from += laneLength;
1947 }
1948 if (to < 0) {
1949 to += laneLength;
1950 }
1951 if ((to - from) < POSITION_EPS) {
1952 return false;
1953 }
1954 if ((from < 0) || (from > laneLength)) {
1955 return false;
1956 }
1957 if ((to < 0) || (to > laneLength)) {
1958 return false;
1959 }
1960 return true;
1961}
1962
1963
1964void
1965GNEAdditionalHandler::fixLaneDoublePosition(double& from, double& to, const double laneLength) {
1966 // adjust from (negative means that start at the end of lane and count backward)
1967 if (from == INVALID_DOUBLE) {
1968 from = 0;
1969 }
1970 if (to == INVALID_DOUBLE) {
1971 to = laneLength;
1972 }
1973 if (from < 0) {
1974 from += laneLength;
1975 }
1976 if (from < 0) {
1977 from = 0;
1978 } else if (from > laneLength) {
1979 from = laneLength;
1980 }
1981 // adjust to
1982 if (to < 0) {
1983 to += laneLength;
1984 }
1985 if (to < 0) {
1986 to = 0;
1987 } else if (to > laneLength) {
1988 to = laneLength;
1989 }
1990 // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1991 if ((to - from) < POSITION_EPS) {
1992 if (to >= POSITION_EPS) {
1993 from = to - POSITION_EPS;
1994 } else {
1995 from = 0;
1996 to = POSITION_EPS;
1997 }
1998 }
1999}
2000
2001
2002bool
2003GNEAdditionalHandler::checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos) {
2004 if (friendlyPos) {
2005 return true;
2006 } else {
2007 return (checkLanePosition(fromPos, 0, fromLaneLength, false) && checkLanePosition(toPos, 0, tolaneLength, false));
2008 }
2009}
2010
2011
2012void
2013GNEAdditionalHandler::fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength) {
2014 double length = 0;
2015 fixLanePosition(fromPos, length, fromLaneLength);
2016 fixLanePosition(toPos, length, tolaneLength);
2017}
2018
2019
2020void
2021GNEAdditionalHandler::writeInvalidID(const SumoXMLTag tag, const std::string& id) {
2022 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("ID contains invalid characters."));
2023}
2024
2025
2026void
2028 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Invalid position over lane."));
2029}
2030
2031
2032void
2034 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Declared twice."));
2035}
2036
2037
2038void
2039GNEAdditionalHandler::writeErrorInvalidParent(const SumoXMLTag tag, const std::string& id, const SumoXMLTag parent, const std::string& parentID) {
2040 std::string first, second;
2041 if (id.size() > 0) {
2042 first = TLF("Could not build % '%' in netedit", toString(tag), id);
2043 } else {
2044 first = TLF("Could not build % in netedit", toString(tag));
2045 }
2046 if (parentID.size() > 0) {
2047 second = TLF("% '%' doesn't exist.", toString(parent), parentID);
2048 } else {
2049 second = TLF("% doesn't exist.", toString(parent));
2050 }
2051 writeError(first + std::string("; ") + second);
2052}
2053
2054
2055void
2056GNEAdditionalHandler::writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute) {
2057 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TLF("Attribute % cannot be negative.", toString(attribute)));
2058}
2059
2060
2061void
2063 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("List of VTypes isn't valid."));
2064}
2065
2066
2067void
2069 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("Filename is invalid."));
2070}
2071
2072
2073void
2075 writeError(TLF("Could not build % with ID '%' in netedit", toString(tag), id) + std::string("; ") + TL("List of lanes isn't valid."));
2076}
2077
2078
2079bool
2080GNEAdditionalHandler::checkListOfVehicleTypes(const std::vector<std::string>& vTypeIDs) const {
2081 for (const auto& vTypeID : vTypeIDs) {
2082 if (!SUMOXMLDefinitions::isValidTypeID(vTypeID)) {
2083 return false;
2084 }
2085 }
2086 return true;
2087}
2088
2089
2092 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
2093 return nullptr;
2094 } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
2095 return nullptr;
2096 } else {
2098 }
2099}
2100
2101
2104 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
2105 // parent interval doesn't exist
2106 return nullptr;
2107 } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
2108 // rerouter parent doesn't exist
2109 return nullptr;
2110 } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
2111 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
2112 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
2113 return nullptr;
2114 } else {
2119 }
2120}
2121
2122
2123std::vector<GNEEdge*>
2124GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::vector<std::string>& edgeIDs) {
2125 std::vector<GNEEdge*> edges;
2126 for (const auto& edgeID : edgeIDs) {
2127 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
2128 // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
2129 if (edge == nullptr) {
2130 writeError(TLF("Could not build % in netedit", toString(tag)) + std::string("; ") + TLF("% doesn't exist.", toString(SUMO_TAG_EDGE)));
2131 edges.clear();
2132 return edges;
2133 } else {
2134 edges.push_back(edge);
2135 }
2136 }
2137 return edges;
2138}
2139
2140
2141std::vector<GNELane*>
2142GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::vector<std::string>& laneIDs) {
2143 std::vector<GNELane*> lanes;
2144 for (const auto& laneID : laneIDs) {
2145 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
2146 // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
2147 if (lane == nullptr) {
2148 writeError(TLF("Could not build % in netedit", toString(tag)) + std::string("; ") + TLF("% doesn't exist.", toString(SUMO_TAG_LANE)));
2149 lanes.clear();
2150 return lanes;
2151 } else {
2152 lanes.push_back(lane);
2153 }
2154 }
2155 return lanes;
2156}
2157
2158
2159bool
2160GNEAdditionalHandler::checkDuplicatedID(const std::vector<SumoXMLTag> tags, const std::string& id) {
2161 for (const auto& tag : tags) {
2162 // retrieve additional
2163 auto additional = myNet->getAttributeCarriers()->retrieveAdditional(tag, id, false);
2164 // if additional exist, check if overwrite (delete)
2165 if (additional) {
2166 if (!myAllowUndoRedo) {
2167 // only overwrite if allow undo-redo
2168 return false;
2169 } else if (myOverwrite) {
2170 // update additional to overwrite
2171 myAdditionalToOverwrite = additional;
2172 } else {
2173 // duplicated additional
2174 return false;
2175 }
2176 } else {
2177
2178 }
2179 }
2180 // ID is ok
2181 return true;
2182}
2183
2184
2185void
2188 // remove element
2190 // reset pointer
2191 myAdditionalToOverwrite = nullptr;
2192 }
2193}
2194
2195
2197 myNet(nullptr),
2198 myAllowUndoRedo(false),
2199 myOverwrite(false) {
2200}
2201
2202// ===========================================================================
2203// GNEAdditionalHandler::NeteditParameters method definitions
2204// ===========================================================================
2205
2207 select(sumoBaseObject->hasBoolAttribute(GNE_ATTR_SELECTED) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_SELECTED) : false),
2208 centerAfterCreation(sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) : false) {
2209}
2210
2211
2213
2214
2216 select(false),
2217 centerAfterCreation(false) {
2218}
2219
2220/****************************************************************************/
const unsigned char E3[]
Definition E3.cpp:22
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
#define TIME2STEPS(x)
Definition SUMOTime.h:57
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_VTYPE_ID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_REROUTER
A rerouter.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_SINK
Sink(s) specification.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_SOURCE
a source
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ GNE_ATTR_CENTER_AFTER_CREATION
flag to center camera after element creation
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_VOLTAGE
voltage of the traction substation [V]
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_LINEWIDTH
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_WEIGHT
@ SUMO_ATTR_CONTAINER_CAPACITY
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ROADSIDE_CAPACITY
@ SUMO_ATTR_CURRENTLIMIT
current limit of the traction substation [A]
@ SUMO_ATTR_CHARGINGPOWER
@ SUMO_ATTR_PROB
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations (different of waiting time)
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
const double SUMO_const_laneWidth
Definition StdDefs.h:48
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
void writeError(const std::string &error)
write error and enable error creating element
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:447
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
bool hasTimeAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given time attribute
SumoXMLTag getTag() const
get XML myTag
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
void buildPolygon(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double layer, const double angle, const std::string &imgFile, const bool relativePath, const PositionVector &shape, const bool geo, const bool fill, const double lineWidth, const std::string &name, const Parameterised::Map &parameters)
Builds a polygon using the given values.
void buildVariableSpeedSign(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const std::vector< std::string > &laneIDs, const std::string &name, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
Builds a VariableSpeedSign (lane speed additional)
void buildDetectorE3(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const SUMOTime period, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const bool openEntry, const bool expectedArrival, const Parameterised::Map &parameters)
Builds a multi entry exit detector (E3)
void buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &edgeID, const double pos, const std::string &name, const std::string &outfile, const SUMOTime period, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a microscopic calibrator over an edge
GNEAdditional * getRerouterIntervalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get rerouter interval parent
void writeInvalidID(const SumoXMLTag tag, const std::string &id)
write invalid id
static void fixLaneDoublePosition(double &from, double &to, const double laneLengt)
fix the given positions over lane
void buildOverheadWire(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &substationId, const std::vector< std::string > &laneIDs, const double startPos, const double endPos, const bool friendlyPos, const std::vector< std::string > &forbiddenInnerLanes, const Parameterised::Map &parameters)
build overhead wire
void buildE1Detector(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double position, const SUMOTime period, const std::string &file, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a induction loop detector (E1)
void buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const double length, const SUMOTime period, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map &parameters)
Builds a single-lane Area Detector (E2)
static bool checkFriendlyPosSmallLanes(double pos, const double length, const double laneLength, const bool friendlyPos)
check if enable friendly pos in small lanes
void buildPOI(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double x, const double y, const std::string &icon, const double layer, const double angle, const std::string &imgFile, bool relativePath, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI using the given values.
static bool accessCanBeCreated(GNEAdditional *busStopParent, GNEEdge *edge)
check if a GNEAccess can be created in a certain Edge
void buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const std::string &name, const std::string &outfile, const SUMOTime period, const std::string &routeprobe, const double jamThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a microscopic calibrator over a lane
void buildTAZSink(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double arrivalWeight)
Builds a TAZSink (Traffic Assignment Zone)
void buildAccess(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const std::string &pos, const double length, const bool friendlyPos, const Parameterised::Map &parameters)
Builds an Access.
void buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime time, const std::string &speed)
Builds a VariableSpeedSign Step.
bool checkDuplicatedID(const std::vector< SumoXMLTag > tags, const std::string &id)
check if given ID correspond to a duplicated additionals
GNEAdditional * getAdditionalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, SumoXMLTag tag) const
get additional parent
void writeErrorInvalidNegativeValue(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute)
write error "invalid negative element"
void buildTractionSubstation(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const double voltage, const double currentLimit, const Parameterised::Map &parameters)
build traction substation
std::vector< GNELane * > parseLanes(const SumoXMLTag tag, const std::vector< std::string > &laneIDs)
parse lanes
void writeErrorDuplicated(const SumoXMLTag tag, const std::string &id)
write error "duplicated additional"
void buildRerouterInterval(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime begin, const SUMOTime end)
builds a rerouter interval
void buildCalibratorFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameter)
builds a calibrator flow
void buildPOILane(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const std::string &laneID, const double posOverLane, const bool friendlyPos, const double posLat, const std::string &icon, const double layer, const double angle, const std::string &imgFile, const bool relativePath, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI over lane using the given values.
void overwriteAdditional()
remove overwritten additional
void buildTAZ(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, const Position &center, const bool fill, const RGBColor &color, const std::vector< std::string > &edgeIDs, const std::string &name, const Parameterised::Map &parameters)
Builds a TAZ (Traffic Assignment Zone)
void buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedLane, SVCPermissions permissions)
builds a closing lane reroute
void buildParkingSpace(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const double x, const double y, const double z, const std::string &name, const std::string &width, const std::string &length, const std::string &angle, const double slope, const Parameterised::Map &parameters)
Builds a Parking Space.
void writeErrorInvalidVTypes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of vehicle types"
void buildClosingReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedEdgeID, SVCPermissions permissions)
builds a closing edge reroute
void writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id)
write error "invalid position"
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
void buildDestProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newEdgeDestinationID, const double probability)
builds a dest prob reroute
bool checkListOfVehicleTypes(const std::vector< std::string > &vTypeIDs) const
check list of IDs
const bool myAllowUndoRedo
allow undo/redo
static bool checkLaneDoublePosition(double from, const double to, const double laneLength, const bool friendlyPos)
check if the given positions over a lane is valid
void buildJpsObstacle(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, bool geo, const std::string &name, const Parameterised::Map &parameters)
Builds a JuPedSim obstacle using the given values.
void buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newParkignAreaID, const double probability, const bool visible)
builds a parking area reroute
static bool checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos)
check if the given position over a lane is valid
void buildBusStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int personCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a bus stop.
GNEAdditionalHandler()
invalidate default constructo
void writeErrorInvalidFilename(const SumoXMLTag tag, const std::string &id)
write error "invalid filename"
void buildTrainStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int personCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a train stop.
void buildParkingArea(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &departPos, const std::string &name, const std::vector< std::string > &badges, const bool friendlyPosition, const int roadSideCapacity, const bool onRoad, const double width, const double length, const double angle, const bool lefthand, const Parameterised::Map &parameters)
Builds a Parking Area.
void writeErrorInvalidLanes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of lanes"
void buildJpsWalkableArea(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const PositionVector &shape, bool geo, const std::string &name, const Parameterised::Map &parameters)
Builds a JuPedSim walkable area using the given values.
void buildPOIGeo(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &type, const RGBColor &color, const double lon, const double lat, const std::string &icon, const double layer, const double angle, const std::string &imgFile, bool relativePath, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI in GEO coordinaten using the given values.
static bool checkOverlappingRerouterIntervals(GNEAdditional *rerouter, const SUMOTime newBegin, const SUMOTime newEnd)
check if an overlapping is produced in rerouter if a interval with certain begin and end is inserted
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
GNENet * myNet
pointer to GNENet
void buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &laneIDs, const double pos, const double endPos, const SUMOTime period, const std::string &trafficLight, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map &parameters)
Builds a multi-lane Area Detector (E2)
void buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newRouteID, const double probability)
builds a route prob reroute
void buildTAZSource(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double departWeight)
Builds a TAZSource (Traffic Assignment Zone)
void 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 std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a Route probe
void buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double pos, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a Instant Induction Loop Detector (E1Instant)
void writeErrorInvalidParent(const SumoXMLTag tag, const std::string &id, const SumoXMLTag parent, const std::string &parentID)
write error "invalid parent element"
void buildChargingStation(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const double chargingPower, const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string &chargeType, const SUMOTime waitingTime, const bool friendlyPosition, const std::string &parkingAreaID, const Parameterised::Map &parameters)
Builds a charging Station.
std::vector< GNEEdge * > parseEdges(const SumoXMLTag tag, const std::vector< std::string > &edgeIDs)
parse edges
void buildVaporizer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const SUMOTime from, const SUMOTime endTime, const std::string &name, const Parameterised::Map &parameters)
Builds a vaporizer (lane speed additional)
void buildContainerStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &laneID, const double startPos, const double endPos, const std::string &name, const std::vector< std::string > &lines, const int containerCapacity, const double parkingLength, const RGBColor &color, const bool friendlyPosition, const Parameterised::Map &parameters)
Builds a container stop.
GNEAdditional * myAdditionalToOverwrite
additional to overwrite (using undor-redo
void buildRerouter(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const Position &pos, const std::vector< std::string > &edgeIDs, const double prob, const std::string &name, const bool off, const bool optional, const SUMOTime timeThreshold, const std::vector< std::string > &vTypes, const Parameterised::Map &parameters)
builds a rerouter
void buildDetectorEntry(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a entry detector (E3)
void buildDetectorExit(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a exit detector (E3)
void buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::string &overheadWireIDStartClamp, const std::string &laneIDStartClamp, const std::string &overheadWireIDEndClamp, const std::string &laneIDEndClamp, const Parameterised::Map &parameters)
build overhead wire clamp
const bool myOverwrite
check if overwrite
static bool checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos)
check if the given positions over two lanes are valid
An Element which don't belong to GNENet but has influence in the simulation.
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
virtual Position getPositionInView() const =0
Returns position of additional in view.
const std::string getID() const
get ID (all Attribute Carriers have one)
static GNEBusStop * buildTrainStop(GNENet *net)
default constructor
static GNEBusStop * buildBusStop(GNENet *net)
default constructor
A lane area vehicles can halt at (netedit-version)
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:779
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:1116
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:652
void addChildElement(T *element)
add child element
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
bool allowPedestrians() const
check if current lane allow pedestrians
Definition GNELane.cpp:202
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition GNENet.cpp:664
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition GNENet.cpp:2788
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:125
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
void enableUpdateGeometry()
Definition GNENet.cpp:2782
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:4714
static const std::vector< SumoXMLTag > POIs
POIs namespace.
static const std::vector< SumoXMLTag > polygons
polygon namespace
static OptionsCont & getOptions()
Retrieves the options.
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:322
A list of positions.
double length2D() const
Returns the length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Structure representing possible vehicle parameter.
std::string vtypeid
The vehicle's type id.
std::string routeid
The vehicle's route id.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
const bool centerAfterCreation
center view after creation