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
79bool
81 // nothing to do
82 return true;
83}
84
85
86bool
88 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
89 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
90 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
91 // check conditions
93 return false;
95 return false;
96 } else {
97 // get netedit parameters
98 NeteditParameters neteditParameters(sumoBaseObject);
99 // get lane
100 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
101 // check lane
102 if (lane == nullptr) {
104 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
106 } else if (!checkNegative(SUMO_TAG_BUS_STOP, id, SUMO_ATTR_PERSON_CAPACITY, personCapacity, true)) {
107 return false;
108 } else if (!checkNegative(SUMO_TAG_BUS_STOP, id, SUMO_ATTR_PARKING_LENGTH, parkingLength, true)) {
109 return false;
110 } else {
111 // build busStop
112 GNEAdditional* busStop = GNEBusStop::buildBusStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
113 parkingLength, color, friendlyPosition, parameters);
114 // insert depending of allowUndoRedo
115 if (myAllowUndoRedo) {
116 myNet->getViewNet()->getUndoList()->begin(busStop, TL("add bus stop '") + id + "'");
117 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
119 } else {
121 lane->addChildElement(busStop);
122 busStop->incRef("buildBusStop");
123 }
124 return true;
125 }
126 }
127}
128
129
130bool
132 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
133 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
134 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
135 // check conditions
137 return false;
139 return false;
140 } else {
141 // get netedit parameters
142 NeteditParameters neteditParameters(sumoBaseObject);
143 // get lane
144 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
145 // check lane
146 if (lane == nullptr) {
148 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
150 } else if (!checkNegative(SUMO_TAG_TRAIN_STOP, id, SUMO_ATTR_PERSON_CAPACITY, personCapacity, true)) {
151 return false;
152 } else if (!checkNegative(SUMO_TAG_TRAIN_STOP, id, SUMO_ATTR_PARKING_LENGTH, parkingLength, true)) {
153 return false;
154 } else {
155 // build trainStop
156 GNEAdditional* trainStop = GNEBusStop::buildTrainStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
157 parkingLength, color, friendlyPosition, parameters);
158 // insert depending of allowUndoRedo
159 if (myAllowUndoRedo) {
160 myNet->getViewNet()->getUndoList()->begin(trainStop, TL("add train stop '") + id + "'");
161 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(trainStop, true), true);
163 } else {
165 lane->addChildElement(trainStop);
166 trainStop->incRef("buildTrainStop");
167 }
168 return true;
169 }
170 }
171}
172
173
174bool
175GNEAdditionalHandler::buildAccess(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID,
176 const std::string& pos, const double length, const bool friendlyPos, const Parameterised::Map& parameters) {
177 // get netedit parameters
178 NeteditParameters neteditParameters(sumoBaseObject);
179 // get lane
180 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
181 // get busStop (or trainStop)
182 GNEAdditional* busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_BUS_STOP);
183 if (busStop == nullptr) {
184 busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_TRAIN_STOP);
185 }
186 // pos double
187 bool validPos = true;
188 double posDouble = 0;
189 if (lane) {
190 if (GNEAttributeCarrier::canParse<double>(pos)) {
191 posDouble = GNEAttributeCarrier::parse<double>(pos);
192 validPos = checkLanePosition(posDouble, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
193 } else if (pos == "random" || pos == "doors" || pos == "carriage") {
194 posDouble = INVALID_DOUBLE;
195 } else if (pos.empty()) {
196 posDouble = 0;
197 } else {
198 validPos = false;
199 }
200 }
201 // Check if busStop parent and lane is correct
202 if (lane == nullptr) {
204 } else if (busStop == nullptr) {
206 } else if (!validPos) {
208 } else if ((length != -1) && !checkNegative(SUMO_TAG_ACCESS, busStop->getID(), SUMO_ATTR_LENGTH, length, true)) {
209 return false;
210 } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
211 return writeError(TL("Could not build access in netedit; busStop parent already owns an access in the edge '") + lane->getParentEdge()->getID() + "'");
212 } else if (!lane->allowPedestrians()) {
213 return writeError(TLF("Could not build access in netedit; The lane '%' doesn't support pedestrians", lane->getID()));
214 } else {
215 // build access
216 GNEAdditional* access = new GNEAccess(busStop, lane, myNet, posDouble, pos, friendlyPos, length, parameters);
217 // insert depending of allowUndoRedo
218 if (myAllowUndoRedo) {
219 myNet->getViewNet()->getUndoList()->begin(access, TL("add access in '") + busStop->getID() + "'");
220 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(access, true), true);
222 } else {
224 lane->addChildElement(access);
225 busStop->addChildElement(access);
226 access->incRef("buildAccess");
227 }
228 return true;
229 }
230}
231
232
233bool
234GNEAdditionalHandler::buildContainerStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
235 const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines, const int containerCapacity,
236 const double parkingLength, const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
237 // check conditions
239 return false;
241 return false;
242 } else {
243 // get netedit parameters
244 NeteditParameters neteditParameters(sumoBaseObject);
245 // get lane
246 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
247 // check lane
248 if (lane == nullptr) {
250 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
252 } else if (!checkNegative(SUMO_TAG_CONTAINER_STOP, id, SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity, true)) {
253 return false;
254 } else if (!checkNegative(SUMO_TAG_CONTAINER_STOP, id, SUMO_ATTR_PARKING_LENGTH, parkingLength, true)) {
255 return false;
256 } else {
257 // build containerStop
258 GNEAdditional* containerStop = new GNEContainerStop(id, lane, myNet, startPos, endPos, name, lines, containerCapacity, parkingLength,
259 color, friendlyPosition, parameters);
260 // insert depending of allowUndoRedo
261 if (myAllowUndoRedo) {
262 myNet->getViewNet()->getUndoList()->begin(containerStop, TL("add container stop '") + id + "'");
263 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
265 } else {
267 lane->addChildElement(containerStop);
268 containerStop->incRef("buildContainerStop");
269 }
270 return true;
271 }
272 }
273}
274
275
276bool
278 const std::string& laneID, const double startPos, const double endPos, const std::string& name, const double chargingPower,
279 const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string& chargeType,
280 const SUMOTime waitingTime, const bool friendlyPosition, const std::string& /* parkingAreaID */, const Parameterised::Map& parameters) {
281 // check conditions
283 return false;
285 return false;
286 } else {
287 // get netedit parameters
288 NeteditParameters neteditParameters(sumoBaseObject);
289 // get lane
290 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
291 // check lane
292 if (lane == nullptr) {
294 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
296 } else if (!checkNegative(SUMO_TAG_CHARGING_STATION, id, SUMO_ATTR_CHARGINGPOWER, chargingPower, true)) {
297 return false;
298 } else if (!checkNegative(SUMO_TAG_CHARGING_STATION, id, SUMO_ATTR_CHARGEDELAY, chargeDelay, true)) {
299 return false;
300 } else {
301 // build chargingStation
302 GNEAdditional* chargingStation = new GNEChargingStation(id, lane, myNet, startPos, endPos, name, chargingPower, efficiency, chargeInTransit,
303 chargeDelay, chargeType, waitingTime, friendlyPosition, parameters);
304 // insert depending of allowUndoRedo
305 if (myAllowUndoRedo) {
306 myNet->getViewNet()->getUndoList()->begin(chargingStation, TL("add charging station '") + id + "'");
307 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
309 } else {
310 myNet->getAttributeCarriers()->insertAdditional(chargingStation);
311 lane->addChildElement(chargingStation);
312 chargingStation->incRef("buildChargingStation");
313 }
314 return true;
315 }
316 }
317}
318
319
320bool
321GNEAdditionalHandler::buildParkingArea(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
322 const double startPos, const double endPos, const std::string& departPos, const std::string& name,
323 const std::vector<std::string>& badges, const bool friendlyPosition, const int roadSideCapacity, const bool onRoad,
324 const double width, const double length, const double angle, const bool lefthand, const Parameterised::Map& parameters) {
325 // check conditions
327 return false;
329 return false;
330 } else {
331 // get netedit parameters
332 NeteditParameters neteditParameters(sumoBaseObject);
333 // get lane
334 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
335 // get departPos double
336 const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
337 // check lane
338 if (lane == nullptr) {
340 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
342 } else if (!checkNegative(SUMO_TAG_PARKING_AREA, id, SUMO_ATTR_ROADSIDE_CAPACITY, roadSideCapacity, true)) {
343 return false;
344 } else if (!checkNegative(SUMO_TAG_PARKING_AREA, id, SUMO_ATTR_WIDTH, width, true)) {
345 return false;
346 } else if (!checkNegative(SUMO_TAG_PARKING_AREA, id, SUMO_ATTR_LENGTH, length, true)) {
347 return false;
348 } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
349 return writeError(TLF("Could not build parking area with ID '%' in netedit; Invalid departPos over lane.", id));
350 } else {
351 // build parkingArea
352 GNEAdditional* parkingArea = new GNEParkingArea(id, lane, myNet, startPos, endPos, GNEAttributeCarrier::canParse<double>(departPos) ? departPos : "",
353 name, badges, friendlyPosition, roadSideCapacity, onRoad,
354 (width == 0) ? SUMO_const_laneWidth : width, length, angle, lefthand, parameters);
355 // insert depending of allowUndoRedo
356 if (myAllowUndoRedo) {
357 myNet->getViewNet()->getUndoList()->begin(parkingArea, TL("add parking area '") + id + "'");
358 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
360 } else {
362 lane->addChildElement(parkingArea);
363 parkingArea->incRef("buildParkingArea");
364 }
365 return true;
366 }
367 }
368}
369
370
371bool
372GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
373 const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
374 const Parameterised::Map& parameters) {
375 // check width and heights
376 if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
377 return writeError(TL("Could not build parking space in netedit; attribute width cannot be parse to float."));
378 } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
379 return writeError(TL("Could not build parking space in netedit; attribute length cannot be parse to float."));
380 } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
381 return writeError(TL("Could not build parking space in netedit; attribute angle cannot be parse to float."));
382 } else {
383 // get netedit parameters
384 NeteditParameters neteditParameters(sumoBaseObject);
385 // get lane
386 GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
387 // get double values
388 const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
389 const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
390 // check lane
391 if (parkingArea == nullptr) {
393 } else if (!checkNegative(SUMO_TAG_PARKING_SPACE, parkingArea->getID(), SUMO_ATTR_WIDTH, widthDouble, true)) {
394 return false;
395 } else if (!checkNegative(SUMO_TAG_PARKING_SPACE, parkingArea->getID(), SUMO_ATTR_LENGTH, lengthDouble, true)) {
396 return false;
397 } else {
398 // build parkingSpace
399 GNEAdditional* parkingSpace = new GNEParkingSpace(myNet, parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
400 // insert depending of allowUndoRedo
401 if (myAllowUndoRedo) {
402 myNet->getViewNet()->getUndoList()->begin(parkingSpace, TL("add parking space in '") + parkingArea->getID() + "'");
403 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
405 } else {
407 parkingArea->addChildElement(parkingSpace);
408 parkingSpace->incRef("buildParkingSpace");
409 }
410 // update geometry (due boundaries)
411 parkingSpace->updateGeometry();
412 return true;
413 }
414 }
415}
416
417
418bool
419GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
420 const double position, const SUMOTime period, const std::string& file, const std::vector<std::string>& vehicleTypes,
421 const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
422 const bool friendlyPos, const Parameterised::Map& parameters) {
423 // check conditions
425 return false;
427 return false;
428 } else {
429 // get netedit parameters
430 NeteditParameters neteditParameters(sumoBaseObject);
431 // get lane
432 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
433 // check lane
434 if (lane == nullptr) {
436 } else if (!checkLanePosition(position, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
438 } else if (!checkNegative(SUMO_TAG_INDUCTION_LOOP, id, SUMO_ATTR_PERIOD, period, true)) {
439 return false;
440 } else if (!checkFileName(SUMO_TAG_INDUCTION_LOOP, id, SUMO_ATTR_FILE, file)) {
441 return false;
442 } else if (!checkListOfVehicleTypes(SUMO_TAG_INDUCTION_LOOP, id, vehicleTypes)) {
443 return false;
444 } else {
445 // build E1
446 GNEAdditional* detectorE1 = new GNEInductionLoopDetector(id, lane, myNet, position, period, file, vehicleTypes,
447 nextEdges, detectPersons, name, friendlyPos, parameters);
448 // insert depending of allowUndoRedo
449 if (myAllowUndoRedo) {
450 myNet->getViewNet()->getUndoList()->begin(detectorE1, TL("add induction loop '") + id + "'");
451 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
453 } else {
455 lane->addChildElement(detectorE1);
456 detectorE1->incRef("buildDetectorE1");
457 }
458 return true;
459 }
460 }
461}
462
463
464bool
465GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID,
466 const double pos, const double length, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
467 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
468 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
469 const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
470 // check conditions
472 return false;
474 return false;
475 } else {
476 // get netedit parameters
477 NeteditParameters neteditParameters(sumoBaseObject);
478 // get lane
479 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
480 // check lane
481 if (lane == nullptr) {
483 } else {
484 // check friendlyPos in small lanes
485 const bool friendlyPosCheck = checkFriendlyPosSmallLanes(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
486 if (!checkLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosCheck)) {
488 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_LENGTH, length, true)) {
489 return false;
490 } else if ((period != -1) && !checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_PERIOD, period, true)) {
491 return false;
492 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
493 // temporal
494 return writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
495 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold, true)) {
496 return false;
497 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_HALTING_SPEED_THRESHOLD, speedThreshold, true)) {
498 return false;
499 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold, true)) {
500 return false;
501 } else if (!checkFileName(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_FILE, filename)) {
502 return false;
503 } else if (!checkListOfVehicleTypes(SUMO_TAG_LANE_AREA_DETECTOR, id, vehicleTypes)) {
504 return false;
505 } else {
506 // build E2 single lane
507 GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, lane, myNet, pos, length, period, trafficLight, filename,
508 vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
509 speedThreshold, jamThreshold, friendlyPosCheck, show, parameters);
510 // insert depending of allowUndoRedo
511 if (myAllowUndoRedo) {
512 myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
513 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
515 } else {
517 lane->addChildElement(detectorE2);
518 detectorE2->incRef("buildDetectorE2");
519 }
520 return true;
521 }
522 }
523 }
524}
525
526
527bool
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
535 return false;
537 return false;
538 } else {
539 // get netedit parameters
540 NeteditParameters neteditParameters(sumoBaseObject);
541 // get lanes
542 const auto lanes = parseLanes(GNE_TAG_MULTI_LANE_AREA_DETECTOR, id, laneIDs);
543 // check lanes
544 if (lanes.empty()) {
545 return false;
546 } else {
547 // calculate path
549 return writeError(TLF("Could not build lane area detector with ID '%' in netedit; Lanes aren't consecutives.", id));
550 } else if (!checkMultiLanePosition(
551 pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
552 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
554 } else if ((period != -1) && !checkNegative(GNE_TAG_MULTI_LANE_AREA_DETECTOR, id, SUMO_ATTR_PERIOD, period, true)) {
555 return false;
556 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
557 // temporal
558 return writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
560 return false;
562 return false;
564 return false;
566 return false;
567 } else if (!checkListOfVehicleTypes(GNE_TAG_MULTI_LANE_AREA_DETECTOR, id, vehicleTypes)) {
568 return false;
569 } else {
570 // build E2 multilane detector
571 GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, lanes, myNet, pos, endPos, period, trafficLight, filename,
572 vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
573 speedThreshold, jamThreshold, friendlyPos, show, parameters);
574 // insert depending of allowUndoRedo
575 if (myAllowUndoRedo) {
576 myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
577 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
579 } else {
581 for (const auto& lane : lanes) {
582 lane->addChildElement(detectorE2);
583 }
584 detectorE2->incRef("buildDetectorE2Multilane");
585 }
586 return true;
587 }
588 }
589 }
590}
591
592
593bool
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
600 return false;
601 } else if (!checkNegative(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_PERIOD, period, true)) {
602 return false;
603 } else if (!checkNegative(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold, true)) {
604 return false;
605 } else if (!checkNegative(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_HALTING_SPEED_THRESHOLD, speedThreshold, true)) {
606 return false;
607 } else if (!checkFileName(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_FILE, filename)) {
608 return false;
609 } else if (!checkListOfVehicleTypes(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, vehicleTypes)) {
610 return false;
612 return false;
613 } else {
614 // get netedit parameters
615 NeteditParameters neteditParameters(sumoBaseObject);
616 // build E3
617 GNEAdditional* E3 = new GNEMultiEntryExitDetector(id, myNet, pos, period, filename, vehicleTypes, nextEdges, detectPersons,
618 name, timeThreshold, speedThreshold, openEntry, expectedArrival, parameters);
619 // insert depending of allowUndoRedo
620 if (myAllowUndoRedo) {
621 myNet->getViewNet()->getUndoList()->begin(E3, TL("add entry-exit detector '") + id + "'");
622 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
624 } else {
626 E3->incRef("buildDetectorE3");
627 }
628 return true;
629 }
630}
631
632
633bool
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() + "'");
655 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
657 } else {
659 lane->addChildElement(entry);
660 E3->addChildElement(entry);
661 entry->incRef("buildDetectorEntry");
662 }
663 return true;
664 }
665}
666
667
668bool
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() + "'");
690 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
692 } else {
694 lane->addChildElement(exit);
695 E3->addChildElement(exit);
696 exit->incRef("buildDetectorExit");
697 }
698 return true;
699 }
700}
701
702
703bool
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
709 return false;
711 return false;
712 } else {
713 // get netedit parameters
714 NeteditParameters neteditParameters(sumoBaseObject);
715 // get lane
716 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
717 // check lane
718 if (lane == nullptr) {
721 return false;
722 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
724 } else {
725 // build E1 instant
726 GNEAdditional* detectorE1Instant = new GNEInstantInductionLoopDetector(id, lane, myNet, pos, filename, vehicleTypes, nextEdges,
727 detectPersons, name, friendlyPos, parameters);
728 // insert depending of allowUndoRedo
729 if (myAllowUndoRedo) {
730 myNet->getViewNet()->getUndoList()->begin(detectorE1Instant, TL("add instant induction loop '") + id + "'");
731 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
733 } else {
734 myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
735 lane->addChildElement(detectorE1Instant);
736 detectorE1Instant->incRef("buildDetectorE1Instant");
737 }
738 return true;
739 }
740 }
741}
742
743
744bool
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
754 return false;
756 return false;
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 (!checkNegative(GNE_TAG_CALIBRATOR_LANE, id, SUMO_ATTR_PERIOD, period, true)) {
768 return false;
769 } else if (!checkNegative(GNE_TAG_CALIBRATOR_LANE, id, SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold, true)) {
770 return false;
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 + "'");
779 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
781 // center after creation
782 if (neteditParameters.centerAfterCreation) {
783 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
784 }
785 } else {
787 lane->addChildElement(calibrator);
788 if (routeProbe) {
789 routeProbe->addChildElement(calibrator);
790 }
791 calibrator->incRef("buildCalibrator");
792 }
793 return true;
794 }
795 }
796}
797
798
799bool
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
809 return false;
811 return false;
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 (!checkNegative(SUMO_TAG_CALIBRATOR, id, SUMO_ATTR_PERIOD, period, true)) {
822 return false;
823 } else if (!checkNegative(SUMO_TAG_CALIBRATOR, id, SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold, true)) {
824 return false;
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 + "'");
833 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
835 // center after creation
836 if (neteditParameters.centerAfterCreation) {
837 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
838 }
839 } else {
841 edge->addChildElement(calibrator);
842 if (routeProbe) {
843 routeProbe->addChildElement(calibrator);
844 }
845 calibrator->incRef("buildCalibrator");
846 }
847 return true;
848 }
849 }
850}
851
852
853bool
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) {
863 return writeErrorInvalidParent(SUMO_TAG_FLOW, "", SUMO_TAG_VTYPE, vehicleParameter.vtypeid);
864 } else if (route == nullptr) {
865 return writeErrorInvalidParent(SUMO_TAG_FLOW, "", SUMO_TAG_ROUTE, vehicleParameter.routeid);
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() + "'");
874 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
876 } else {
877 calibrator->addChildElement(flow);
878 route->addChildElement(flow);
879 vType->addChildElement(flow);
880 flow->incRef("buildCalibratorFlow");
881 }
882 return true;
883 }
884}
885
886
887bool
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
894 return false;
895 } else if (!checkNegative(SUMO_TAG_REROUTER, id, SUMO_ATTR_PROB, prob, true)) {
896 return false;
897 } else if (!checkNegative(SUMO_TAG_REROUTER, id, SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold, true)) {
898 return false;
899 } else if (!checkListOfVehicleTypes(SUMO_TAG_REROUTER, id, vTypes)) {
900 return false;
902 return false;
903 } else {
904 // get netedit parameters
905 NeteditParameters neteditParameters(sumoBaseObject);
906 // parse edges
907 std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, id, edgeIDs);
908 // check edges
909 if (edges.empty()) {
910 return false;
911 } else {
912 GNEAdditional* rerouter = nullptr;
913 // continue depending of position
914 if (pos == Position::INVALID) {
915 if (edges.size() > 0) {
916 PositionVector laneShape = edges.front()->getLanes().front()->getLaneShape();
917 // move to side
918 laneShape.move2side(3);
919 // create rerouter
920 rerouter = new GNERerouter(id, myNet, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, prob, off, optional, timeThreshold, vTypes, parameters);
921 } else {
922 rerouter = new GNERerouter(id, myNet, Position(0, 0), name, prob, off, optional, timeThreshold, vTypes, parameters);
923 }
924 } else {
925 rerouter = new GNERerouter(id, myNet, pos, name, prob, off, optional, timeThreshold, vTypes, parameters);
926 }
927 // create rerouter Symbols
928 std::vector<GNEAdditional*> rerouterSymbols;
929 for (const auto& edge : edges) {
930 rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
931 }
932 // insert depending of allowUndoRedo
933 if (myAllowUndoRedo) {
934 myNet->getViewNet()->getUndoList()->begin(rerouter, TL("add rerouter '") + id + "'");
935 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
936 // add symbols
937 for (const auto& rerouterSymbol : rerouterSymbols) {
938 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
939 }
941 } else {
943 rerouter->incRef("buildRerouter");
944 // add symbols into rerouter
945 for (const auto& rerouterSymbol : rerouterSymbols) {
946 rerouter->addChildElement(rerouterSymbol);
947 }
948 // add symbols into edges
949 for (int i = 0; i < (int)edges.size(); i++) {
950 edges.at(i)->addChildElement(rerouterSymbols.at(i));
951 }
952 }
953 return true;
954 }
955 }
956}
957
958
959bool
961 // get rerouter parent
962 GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
963 // check if rerouter exist
964 if (rerouter == nullptr) {
966 } else if (!checkNegative(SUMO_TAG_INTERVAL, rerouter->getID(), SUMO_ATTR_BEGIN, begin, true)) {
967 return false;
968 } else if (!checkNegative(SUMO_TAG_INTERVAL, rerouter->getID(), SUMO_ATTR_END, end, true)) {
969 return false;
970 } else if (end < begin) {
971 return writeError(TLF("Could not build interval with ID '%' in netedit; begin is greater than end.", rerouter->getID()));
972 } else {
973 // check if new interval will produce a overlapping
974 if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
975 // create rerouter interval and add it into rerouter parent
976 GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
977 // insert depending of allowUndoRedo
978 if (myAllowUndoRedo) {
979 myNet->getViewNet()->getUndoList()->begin(rerouterInterval, TL("add rerouter interval in '") + rerouter->getID() + "'");
980 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
982 } else {
983 rerouter->addChildElement(rerouterInterval);
984 rerouterInterval->incRef("buildRerouterInterval");
985 }
986 } else {
987 return writeError(TLF("Could not build interval with begin '%' and end '%' in '%' due overlapping.", toString(begin), toString(end), rerouter->getID()));
988 }
989 return true;
990 }
991}
992
993
994bool
995GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
996 // get rerouter interval parent
997 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
998 // get closed lane
999 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
1000 // check parents
1001 if (lane == nullptr) {
1003 } else if (rerouterInterval == nullptr) {
1005 } else {
1006 // create closing lane reroute
1007 GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
1008 // add it to interval parent depending of allowUndoRedo
1009 if (myAllowUndoRedo) {
1010 myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing lane reroute in '") + lane->getID() + "'");
1011 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1013 } else {
1014 rerouterInterval->addChildElement(closingLaneReroute);
1015 closingLaneReroute->incRef("buildClosingLaneReroute");
1016 }
1017 return true;
1018 }
1019}
1020
1021
1022bool
1023GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
1024 // get rerouter interval parent
1025 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1026 // get closed edge
1027 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
1028 // check parents
1029 if (edge == nullptr) {
1031 } else if (rerouterInterval == nullptr) {
1033 } else {
1034 // create closing reroute
1035 GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
1036 // add it to interval parent depending of allowUndoRedo
1037 if (myAllowUndoRedo) {
1038 myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing reroute in '") + edge->getID() + "'");
1039 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1041 } else {
1042 rerouterInterval->addChildElement(closingLaneReroute);
1043 closingLaneReroute->incRef("buildClosingLaneReroute");
1044 }
1045 return true;
1046 }
1047}
1048
1049bool
1050GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1051 // get rerouter interval parent
1052 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1053 // get edge
1054 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1055 // check parents
1056 if (edge == nullptr) {
1057 return writeErrorInvalidParent(SUMO_TAG_DEST_PROB_REROUTE, "", SUMO_TAG_EDGE, newEdgeDestinationID);
1058 } else if (rerouterInterval == nullptr) {
1060 } else {
1061 // create dest probability reroute
1062 GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1063 // add it to interval parent depending of allowUndoRedo
1064 if (myAllowUndoRedo) {
1065 myNet->getViewNet()->getUndoList()->begin(destProbReroute, TL("add dest prob reroute in '") + edge->getID() + "'");
1066 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1068 } else {
1069 rerouterInterval->addChildElement(destProbReroute);
1070 destProbReroute->incRef("builDestProbReroute");
1071 }
1072 return true;
1073 }
1074}
1075
1076
1077bool
1078GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1079 // get rerouter interval parent
1080 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1081 // get parking area
1082 GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1083 // check parents
1084 if (parkingArea == nullptr) {
1086 } else if (rerouterInterval == nullptr) {
1088 } else {
1089 // create parking area reroute
1090 GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1091 // add it to interval parent depending of allowUndoRedo
1092 if (myAllowUndoRedo) {
1093 myNet->getViewNet()->getUndoList()->begin(parkingAreaReroute, TL("add parking area reroute in '") + parkingArea->getID() + "'");
1094 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1096 } else {
1097 rerouterInterval->addChildElement(parkingAreaReroute);
1098 parkingAreaReroute->incRef("builParkingAreaReroute");
1099 }
1100 return true;
1101 }
1102}
1103
1104
1105bool
1106GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1107 // get rerouter interval parent
1108 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1109 // get route parent
1111 // check parents
1112 if (route == nullptr) {
1114 } else if (rerouterInterval == nullptr) {
1116 } else {
1117 // create rout prob reroute
1118 GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1119 // add it to interval parent depending of allowUndoRedo
1120 if (myAllowUndoRedo) {
1121 myNet->getViewNet()->getUndoList()->begin(routeProbReroute, TL("add route prob reroute in '") + route->getID() + "'");
1122 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1124 } else {
1125 rerouterInterval->addChildElement(routeProbReroute);
1126 routeProbReroute->incRef("buildRouteProbReroute");
1127 }
1128 return true;
1129 }
1130}
1131
1132
1133bool
1134GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime period,
1135 const std::string& name, const std::string& file, const SUMOTime begin, const std::vector<std::string>& vTypes,
1136 const Parameterised::Map& parameters) {
1137 // check conditions
1139 return false;
1141 return false;
1142 } else {
1143 // get netedit parameters
1144 NeteditParameters neteditParameters(sumoBaseObject);
1145 // get edge
1146 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1147 // check lane
1148 if (edge == nullptr) {
1150 } else if (!checkNegative(SUMO_TAG_ROUTEPROBE, id, SUMO_ATTR_PERIOD, period, true)) {
1151 return false;
1152 } else if (!checkNegative(SUMO_TAG_ROUTEPROBE, id, SUMO_ATTR_BEGIN, begin, true)) {
1153 return false;
1154 } else if (!checkFileName(SUMO_TAG_ROUTEPROBE, id, SUMO_ATTR_FILE, file)) {
1155 return false;
1156 } else {
1157 // build route probe
1158 GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, edge, period, name, file, begin, vTypes, parameters);
1159 // insert depending of allowUndoRedo
1160 if (myAllowUndoRedo) {
1161 myNet->getViewNet()->getUndoList()->begin(routeProbe, TL("add route probe '") + id + "'");
1162 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1164 // center after creation
1165 if (neteditParameters.centerAfterCreation) {
1166 myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1167 }
1168 } else {
1170 edge->addChildElement(routeProbe);
1171 routeProbe->incRef("buildRouteProbe");
1172 }
1173 return true;
1174 }
1175 }
1176}
1177
1178
1179bool
1181 const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
1184 return false;
1186 return false;
1187 } else {
1188 // get netedit parameters
1189 NeteditParameters neteditParameters(sumoBaseObject);
1190 // parse lanes
1191 std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, id, laneIDs);
1192 // check lane
1193 if (lanes.empty()) {
1194 return false;
1195 } else {
1196 // check vTypes
1197 if (!checkListOfVehicleTypes(SUMO_TAG_VSS, id, vTypes)) {
1198 return false;
1199 } else {
1200 // create VSS
1201 GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, pos, name, vTypes, parameters);
1202 // create VSS Symbols
1203 std::vector<GNEAdditional*> VSSSymbols;
1204 for (const auto& lane : lanes) {
1205 VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1206 }
1207 // insert depending of allowUndoRedo
1208 if (myAllowUndoRedo) {
1209 myNet->getViewNet()->getUndoList()->begin(variableSpeedSign, TL("add Variable Speed Sign '") + id + "'");
1210 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1211 for (const auto& VSSSymbol : VSSSymbols) {
1212 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1213 }
1215 } else {
1216 myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1217 variableSpeedSign->incRef("buildVariableSpeedSign");
1218 // add symbols into VSS
1219 for (const auto& VSSSymbol : VSSSymbols) {
1220 variableSpeedSign->addChildElement(VSSSymbol);
1221 }
1222 // add symbols into lanes
1223 for (int i = 0; i < (int)lanes.size(); i++) {
1224 lanes.at(i)->addChildElement(VSSSymbols.at(i));
1225 }
1226 }
1227 }
1228 return true;
1229 }
1230 }
1231}
1232
1233
1234bool
1235GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1236 // get VSS parent
1237 GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1238 // check lane
1239 if (VSS == nullptr) {
1241 } else if (!checkNegative(SUMO_TAG_STEP, VSS->getID(), SUMO_ATTR_TIME, time, true)) {
1242 return false;
1243 } else {
1244 // create Variable Speed Sign
1245 GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1246 // add it depending of allow undoRedo
1247 if (myAllowUndoRedo) {
1248 myNet->getViewNet()->getUndoList()->begin(variableSpeedSignStep, TL("add VSS Step in '") + VSS->getID() + "'");
1249 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1251 } else {
1252 VSS->addChildElement(variableSpeedSignStep);
1253 variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1254 }
1255 return true;
1256 }
1257}
1258
1259
1260bool
1261GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1262 const SUMOTime endTime, const std::string& name, const Parameterised::Map& parameters) {
1263 // check conditions
1265 return false;
1267 return false;
1268 } else {
1269 // get netedit parameters
1270 NeteditParameters neteditParameters(sumoBaseObject);
1271 // get edge
1272 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1273 // check lane
1274 if (edge == nullptr) {
1276 } else if (!checkNegative(SUMO_TAG_VAPORIZER, edge->getID(), SUMO_ATTR_BEGIN, beginTime, true)) {
1277 return false;
1278 } else if (!checkNegative(SUMO_TAG_VAPORIZER, edge->getID(), SUMO_ATTR_END, endTime, true)) {
1279 return false;
1280 } else if (endTime < beginTime) {
1281 return writeError(TLF("Could not build Vaporizer with ID '%' in netedit; begin is greater than end.", edge->getID()));
1282 } else {
1283 // build vaporizer
1284 GNEAdditional* vaporizer = new GNEVaporizer(myNet, edge, beginTime, endTime, name, parameters);
1285 // add it depending of allow undoRed
1286 if (myAllowUndoRedo) {
1287 myNet->getViewNet()->getUndoList()->begin(vaporizer, TL("add vaporizer in '") + edge->getID() + "'");
1288 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1290 // center after creation
1291 if (neteditParameters.centerAfterCreation) {
1292 myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1293 }
1294 } else {
1296 edge->addChildElement(vaporizer);
1297 vaporizer->incRef("buildVaporizer");
1298 }
1299 return true;
1300 }
1301 }
1302}
1303
1304
1305bool
1306GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1307 const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1308 const std::string& name, const Parameterised::Map& parameters) {
1309 // parse edges
1310 const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, id, edgeIDs);
1311 if (edges.size() != edgeIDs.size()) {
1312 return false;
1313 } else {
1314 // check TAZShape
1315 PositionVector TAZShape = shape;
1316 if (TAZShape.size() == 0) {
1317 // declare boundary
1318 Boundary TAZBoundary;
1319 for (const auto& edge : edges) {
1320 TAZBoundary.add(edge->getCenteringBoundary());
1321 }
1322 // iterate over children and add sourceSinkEdge boundaries to make a taz shape
1323 for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1324 // check that childre is a source or sink elements (to abool parameters)
1325 if ((sourceSink->getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTag() == SUMO_TAG_TAZSINK)) {
1326 const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1327 if (sourceSinkEdge) {
1328 TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1329 }
1330 }
1331 }
1332 // update TAZShape
1333 TAZShape = TAZBoundary.getShape(true);
1334 }
1335 // check TAZ
1337 return false;
1339 return false;
1340 } else if (TAZShape.size() == 0) {
1341 return writeError(TLF("Could not build TAZ with ID '%' in netedit; Invalid Shape.", id));
1342 } else {
1343 // get netedit parameters
1344 NeteditParameters neteditParameters(sumoBaseObject);
1345 // build TAZ with the given shape
1346 const Position center2 = center == Position::INVALID ? TAZShape.getCentroid() : center;
1347 GNEAdditional* TAZ = new GNETAZ(id, myNet, TAZShape, center2, fill, color, name, parameters);
1348 // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1350 // add it depending of allow undoRed
1351 if (myAllowUndoRedo) {
1352 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ '") + id + "'");
1353 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
1354 // create TAZEdges
1355 for (const auto& edge : edges) {
1356 // create TAZ Source using GNEChange_Additional
1357 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1358 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1359 // create TAZ Sink using GNEChange_Additional
1360 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1361 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1362 }
1364 } else {
1366 TAZ->incRef("buildTAZ");
1367 for (const auto& edge : edges) {
1368 // create TAZ Source
1369 GNEAdditional* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1370 TAZSource->incRef("buildTAZ");
1371 TAZ->addChildElement(TAZSource);
1372 // create TAZ Sink
1373 GNEAdditional* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1374 TAZSink->incRef("buildTAZ");
1375 TAZ->addChildElement(TAZSink);
1376 }
1377 }
1378 // enable updating geometry again and update geometry of TAZ
1380 // update TAZ parent
1381 TAZ->updateGeometry();
1382 return true;
1383 }
1384 }
1385}
1386
1387
1388bool
1389GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1390 // get TAZ parent
1392 // get edge
1393 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1394 // declare TAZ Sink
1395 GNEAdditional* TAZSink = nullptr;
1396 // check parents
1397 if (TAZ == nullptr) {
1399 } else if (edge == nullptr) {
1401 } else {
1402 // first check if a TAZSink in the same edge for the same TAZ
1403 for (const auto& TAZElement : edge->getChildAdditionals()) {
1404 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1405 TAZSink = TAZElement;
1406 }
1407 }
1408 // check if TAZSink has to be created
1409 if (TAZSink == nullptr) {
1410 // Create TAZ with weight 0 (default)
1411 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 0);
1412 // add it depending of allow undoRed
1413 if (myAllowUndoRedo) {
1414 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1415 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1417 } else {
1419 TAZ->addChildElement(TAZSink);
1420 TAZSink->incRef("buildTAZSource");
1421 }
1422 }
1423 // now check check if TAZSource exist
1424 GNEAdditional* TAZSource = nullptr;
1425 // first check if a TAZSink in the same edge for the same TAZ
1426 for (const auto& TAZElement : edge->getChildAdditionals()) {
1427 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1428 TAZSource = TAZElement;
1429 }
1430 }
1431 // check if TAZSource has to be created
1432 if (TAZSource == nullptr) {
1433 // Create TAZ only with departWeight
1434 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1435 // add it depending of allow undoRed
1436 if (myAllowUndoRedo) {
1437 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1438 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1440 } else {
1442 TAZ->addChildElement(TAZSource);
1443 TAZSource->incRef("buildTAZSource");
1444 }
1445 } else {
1446 // update TAZ Attribute depending of allow undoRed
1447 if (myAllowUndoRedo) {
1448 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Source in '") + TAZ->getID() + "'");
1449 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1451 } else {
1452 TAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1453 }
1454 }
1455 return true;
1456 }
1457}
1458
1459
1460bool
1461GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1462 // get TAZ parent
1464 // get edge
1465 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1466 // check parents
1467 if (TAZ == nullptr) {
1469 } else if (edge == nullptr) {
1471 } else {
1472 // declare TAZ source
1473 GNEAdditional* TAZSource = nullptr;
1474 // first check if a TAZSink in the same edge for the same TAZ
1475 for (const auto& TAZElement : edge->getChildAdditionals()) {
1476 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1477 TAZSource = TAZElement;
1478 }
1479 }
1480 // check if TAZSource has to be created
1481 if (TAZSource == nullptr) {
1482 // Create TAZ with empty value
1483 TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 0);
1484 // add it depending of allow undoRed
1485 if (myAllowUndoRedo) {
1486 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1487 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSource, true), true);
1489 } else {
1491 TAZ->addChildElement(TAZSource);
1492 TAZSource->incRef("buildTAZSink");
1493 }
1494 }
1495 GNEAdditional* TAZSink = nullptr;
1496 // first check if a TAZSink in the same edge for the same TAZ
1497 for (const auto& TAZElement : edge->getChildAdditionals()) {
1498 if ((TAZElement->getTagProperty().getTag() == SUMO_TAG_TAZSINK) && (TAZElement->getAttribute(SUMO_ATTR_EDGE) == edge->getID())) {
1499 TAZSink = TAZElement;
1500 }
1501 }
1502 // check if TAZSink has to be created
1503 if (TAZSink == nullptr) {
1504 // Create TAZ only with arrivalWeight
1505 TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1506 // add it depending of allow undoRed
1507 if (myAllowUndoRedo) {
1508 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1509 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZSink, true), true);
1511 } else {
1513 TAZ->addChildElement(TAZSink);
1514 TAZSink->incRef("buildTAZSink");
1515 }
1516 } else {
1517 // update TAZ Attribute depending of allow undoRed
1518 if (myAllowUndoRedo) {
1519 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Sink in '") + TAZ->getID() + "'");
1520 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1522 } else {
1523 TAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1524 }
1525 }
1526 return true;
1527 }
1528}
1529
1530
1531bool
1533 const double voltage, const double currentLimit, const Parameterised::Map& parameters) {
1534 // check conditions
1536 return false;
1537 } else if (!checkNegative(SUMO_TAG_TRACTION_SUBSTATION, id, SUMO_ATTR_VOLTAGE, voltage, true)) {
1538 return false;
1539 } else if (!checkNegative(SUMO_TAG_TRACTION_SUBSTATION, id, SUMO_ATTR_CURRENTLIMIT, currentLimit, true)) {
1540 return false;
1542 return false;
1543 } else {
1544 // get netedit parameters
1545 NeteditParameters neteditParameters(sumoBaseObject);
1546 // build traction substation
1547 GNEAdditional* tractionSubstation = new GNETractionSubstation(id, myNet, pos, voltage, currentLimit, parameters);
1548 // insert depending of allowUndoRedo
1549 if (myAllowUndoRedo) {
1550 myNet->getViewNet()->getUndoList()->begin(tractionSubstation, TL("add traction substation '") + id + "'");
1551 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(tractionSubstation, true), true);
1553 } else {
1554 myNet->getAttributeCarriers()->insertAdditional(tractionSubstation);
1555 tractionSubstation->incRef("buildTractionSubstation");
1556 }
1557 return true;
1558 }
1559}
1560
1561
1562bool
1563GNEAdditionalHandler::buildOverheadWire(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& substationId,
1564 const std::vector<std::string>& laneIDs, const double startPos, const double endPos, const bool friendlyPos,
1565 const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters) {
1566 // check conditions
1568 return false;
1570 return false;
1571 } else {
1572 // get netedit parameters
1573 NeteditParameters neteditParameters(sumoBaseObject);
1574 // get lanes
1575 const auto lanes = parseLanes(SUMO_TAG_OVERHEAD_WIRE_SECTION, id, laneIDs);
1576 // get traction substation
1577 const auto tractionSubstation = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, substationId, false);
1578 // check lanes
1579 if (lanes.empty()) {
1580 return false;
1581 } else {
1582 // calculate path
1584 return writeError(TLF("Could not build overhead wire with ID '%' in netedit; Lanes aren't consecutives.", id));
1585 } else if (!checkMultiLanePosition(
1586 startPos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
1587 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1589 } else if (tractionSubstation == nullptr) {
1591 } else {
1592 // build Overhead Wire
1593 GNEAdditional* overheadWire = new GNEOverheadWire(id, lanes, tractionSubstation, myNet, startPos, endPos, friendlyPos, forbiddenInnerLanes, parameters);
1594 // insert depending of allowUndoRedo
1595 if (myAllowUndoRedo) {
1596 myNet->getViewNet()->getUndoList()->begin(overheadWire, TL("add overhead wire '") + id + "'");
1597 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(overheadWire, true), true);
1599 } else {
1601 for (const auto& lane : lanes) {
1602 lane->addChildElement(overheadWire);
1603 }
1604 overheadWire->incRef("buildOverheadWire");
1605 }
1606 }
1607 return true;
1608 }
1609 }
1610}
1611
1612
1613bool
1614GNEAdditionalHandler::buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject* /* sumoBaseObject */, const std::string& /* id */, const std::string& /* overheadWireIDStartClamp */,
1615 const std::string& /* laneIDStartClamp */, const std::string& /* overheadWireIDEndClamp */, const std::string& /* laneIDEndClamp */,
1616 const Parameterised::Map& /* parameters */) {
1617 //
1618 return false;
1619}
1620
1621
1622bool
1623GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1624 const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill,
1625 double lineWidth, const std::string& name, const Parameterised::Map& parameters) {
1626 // check conditions
1627 if (type == "jupedsim.walkable_area") {
1628 return buildJpsWalkableArea(sumoBaseObject, id, shape, geo, name, parameters);
1629 } else if (type == "jupedsim.obstacle") {
1630 return buildJpsObstacle(sumoBaseObject, id, shape, geo, name, parameters);
1631 } else if (!checkValidAdditionalID(SUMO_TAG_POLY, id)) {
1632 return false;
1634 return false;
1635 } else if (!checkNegative(SUMO_TAG_POLY, id, SUMO_ATTR_LINEWIDTH, lineWidth, true)) {
1636 return false;
1637 } else {
1638 // get netedit parameters
1639 NeteditParameters neteditParameters(sumoBaseObject);
1640 // create poly
1641 GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, name, parameters);
1642 // add it depending of allow undoRed
1643 if (myAllowUndoRedo) {
1644 myNet->getViewNet()->getUndoList()->begin(poly, TL("add polygon '") + id + "'");
1645 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(poly, true), true);
1647 } else {
1648 // insert shape without allowing undo/redo
1650 poly->incRef("addPolygon");
1651 }
1652 return true;
1653 }
1654}
1655
1656
1657bool
1658GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1659 const RGBColor& color, const double x, const double y, const std::string& icon, double layer, double angle,
1660 const std::string& imgFile, bool relativePath, double width, double height, const std::string& name,
1661 const Parameterised::Map& parameters) {
1662 // check conditions
1664 return false;
1665 } else if (!checkNegative(SUMO_TAG_POI, id, SUMO_ATTR_WIDTH, width, true)) {
1666 return false;
1667 } else if (!checkNegative(SUMO_TAG_POI, id, SUMO_ATTR_HEIGHT, height, true)) {
1668 return false;
1669 } else if (!checkFileName(SUMO_TAG_POI, id, SUMO_ATTR_IMGFILE, imgFile)) {
1670 return false;
1672 return false;
1673 } else {
1674 // get netedit parameters
1675 NeteditParameters neteditParameters(sumoBaseObject);
1676 // create POI
1677 GNEPOI* POI = new GNEPOI(myNet, id, type, color, x, y, false, icon, layer, angle, imgFile, relativePath, width, height, name, parameters);
1678 // add it depending of allow undoRed
1679 if (myAllowUndoRedo) {
1680 myNet->getViewNet()->getUndoList()->begin(POI, TL("add POI '") + id + "'");
1681 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POI, true), true);
1683 } else {
1684 // insert shape without allowing undo/redo
1686 POI->incRef("addPOI");
1687 }
1688 return true;
1689 }
1690}
1691
1692
1693bool
1694GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1695 const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat,
1696 const std::string& icon, double layer, double angle, const std::string& imgFile, bool relativePath, double width,
1697 double height, const std::string& name, const Parameterised::Map& parameters) {
1698 // check conditions
1700 return false;
1701 } else if (!checkNegative(GNE_TAG_POILANE, id, SUMO_ATTR_WIDTH, width, true)) {
1702 return false;
1703 } else if (!checkNegative(GNE_TAG_POILANE, id, SUMO_ATTR_HEIGHT, height, true)) {
1704 return false;
1705 } else if (!checkFileName(GNE_TAG_POILANE, id, SUMO_ATTR_IMGFILE, imgFile)) {
1706 return false;
1708 return false;
1709 } else {
1710 // get netedit parameters
1711 NeteditParameters neteditParameters(sumoBaseObject);
1712 // get lane
1713 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1714 // check lane
1715 if (lane == nullptr) {
1717 } else if (!checkLanePosition(posOverLane, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1719 } else {
1720 // create POI (use GNEAdditional instead GNEPOI for add child references)
1721 GNEAdditional* POILane = new GNEPOI(myNet, id, type, color, lane, posOverLane, friendlyPos, posLat, icon, layer,
1722 angle, imgFile, relativePath, width, height, name, parameters);
1723 // add it depending of allow undoRed
1724 if (myAllowUndoRedo) {
1725 myNet->getViewNet()->getUndoList()->begin(POILane, TL("add POI '") + id + "'");
1726 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POILane, true), true);
1728 } else {
1729 // insert shape without allowing undo/redo
1731 lane->addChildElement(POILane);
1732 POILane->incRef("buildPOILane");
1733 }
1734 }
1735 return true;
1736 }
1737}
1738
1739
1740bool
1741GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1742 const RGBColor& color, const double lon, const double lat, const std::string& icon, double layer,
1743 double angle, const std::string& imgFile, bool relativePath, double width, double height,
1744 const std::string& name, const Parameterised::Map& parameters) {
1745 // check conditions
1747 return false;
1748 } else if (!checkNegative(GNE_TAG_POIGEO, id, SUMO_ATTR_WIDTH, width, true)) {
1749 return false;
1750 } else if (!checkNegative(GNE_TAG_POIGEO, id, SUMO_ATTR_HEIGHT, height, true)) {
1751 return false;
1752 } else if (!checkFileName(GNE_TAG_POIGEO, id, SUMO_ATTR_IMGFILE, imgFile)) {
1753 return false;
1754 } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1755 return writeError(TLF("Could not build POI with ID '%' in netedit", id) + std::string("; ") + TL("Network requires a geo projection."));
1757 return false;
1758 } else {
1759 // get netedit parameters
1760 NeteditParameters neteditParameters(sumoBaseObject);
1761 // create POIGEO
1762 GNEPOI* POIGEO = new GNEPOI(myNet, id, type, color, lon, lat, true, icon, layer, angle, imgFile, relativePath, width, height, name, parameters);
1763 // add it depending of allow undoRed
1764 if (myAllowUndoRedo) {
1765 myNet->getViewNet()->getUndoList()->begin(POIGEO, TL("add POI '") + id + "'");
1766 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POIGEO, true), true);
1768 } else {
1769 // insert shape without allowing undo/redo
1771 POIGEO->incRef("buildPOIGeo");
1772 }
1773 return true;
1774 }
1775}
1776
1777
1778bool
1780 bool geo, const std::string& name, const Parameterised::Map& parameters) {
1781 // check conditions
1783 return false;
1785 return false;
1786 } else {
1787 // get netedit parameters
1788 NeteditParameters neteditParameters(sumoBaseObject);
1789 // create walkable area
1790 GNEPoly* walkableArea = new GNEPoly(GNE_TAG_JPS_WALKABLEAREA, myNet, id, shape, geo, name, parameters);
1791 // add it depending of allow undoRed
1792 if (myAllowUndoRedo) {
1793 myNet->getViewNet()->getUndoList()->begin(walkableArea, TL("add jps walkable area '") + id + "'");
1794 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(walkableArea, true), true);
1796 } else {
1797 // insert shape without allowing undo/redo
1799 walkableArea->incRef("addWalkableArea");
1800 }
1801 return true;
1802 }
1803}
1804
1805
1806bool
1807GNEAdditionalHandler::buildJpsObstacle(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1808 bool geo, const std::string& name, const Parameterised::Map& parameters) {
1809 // check conditions
1811 return false;
1813 return false;
1814 } else {
1815 // get netedit parameters
1816 NeteditParameters neteditParameters(sumoBaseObject);
1817 // create walkable area
1818 GNEPoly* obstacle = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet, id, shape, geo, name, parameters);
1819 // add it depending of allow undoRed
1820 if (myAllowUndoRedo) {
1821 myNet->getViewNet()->getUndoList()->begin(obstacle, TL("add jps obstacle '") + id + "'");
1822 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(obstacle, true), true);
1824 } else {
1825 // insert shape without allowing undo/redo
1827 obstacle->incRef("addObstacle");
1828 }
1829 return true;
1830 }
1831}
1832
1833
1834bool
1836 // check if exist another access for the same busStop in the given edge
1837 for (const auto& additional : busStopParent->getChildAdditionals()) {
1838 for (const auto& lane : edge->getLanes()) {
1839 if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1840 return false;
1841 }
1842 }
1843 }
1844 return true;
1845}
1846
1847
1848bool
1850 // declare a vector to keep sorted rerouter children
1851 std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1852 // iterate over child additional
1853 for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1854 if (!rerouterChild->getTagProperty().isSymbol()) {
1855 sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1856 // set begin and end
1857 sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1858 sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1859 }
1860 }
1861 // add new intervals
1862 sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1863 // sort children
1864 std::sort(sortedIntervals.begin(), sortedIntervals.end());
1865 // check overlapping after sorting
1866 for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1867 if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1868 return false;
1869 }
1870 }
1871 return true;
1872}
1873
1874
1875bool
1876GNEAdditionalHandler::checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos) {
1877 if (friendlyPos) {
1878 return true;
1879 }
1880 // adjust from and to (negative means that start at the end of lane and count backward)
1881 if (pos < 0) {
1882 pos += laneLength;
1883 }
1884 // check extremes
1885 if ((pos < 0) || (pos > laneLength)) {
1886 return false;
1887 }
1888 // check pos + length
1889 if ((pos + length) > laneLength) {
1890 return false;
1891 }
1892 // all OK
1893 return true;
1894}
1895
1896
1897void
1898GNEAdditionalHandler::fixLanePosition(double& pos, double& length, const double laneLength) {
1899 // negative pos means that start at the end of lane and count backward)
1900 if (pos < 0) {
1901 pos += laneLength;
1902 }
1903 // set position at the start
1904 if (pos < 0) {
1905 pos = 0;
1906 }
1907 // adjust pos
1908 if (pos >= laneLength) {
1909 pos = (laneLength - POSITION_EPS);
1910 }
1911 // adjust length
1912 if ((length < 0) || ((pos + length) > laneLength)) {
1913 length = POSITION_EPS;
1914 }
1915}
1916
1917
1918bool
1919GNEAdditionalHandler::checkFriendlyPosSmallLanes(double pos, const double length, const double laneLength, const bool friendlyPos) {
1920 if (friendlyPos == true) {
1921 return true;
1922 } else if (OptionsCont::getOptions().getBool("e2.friendlyPos.automatic")) {
1923 // adjust from and to (negative means that start at the end of lane and count backward)
1924 if (pos < 0) {
1925 pos += laneLength;
1926 }
1927 // check extremes
1928 if ((pos < 0) || (pos > laneLength)) {
1929 return true;
1930 }
1931 // check pos + length
1932 if ((pos + length) > laneLength) {
1933 return true;
1934 }
1935 }
1936 return false;
1937}
1938
1939
1940bool
1941GNEAdditionalHandler::checkLaneDoublePosition(double from, double to, const double laneLength, const bool friendlyPos) {
1942 if (friendlyPos) {
1943 return true;
1944 }
1945 // adjust from and to (negative means that start at the end of lane and count backward)
1946 if (from == INVALID_DOUBLE) {
1947 from = 0;
1948 }
1949 if (to == INVALID_DOUBLE) {
1950 to = laneLength;
1951 }
1952 if (from < 0) {
1953 from += laneLength;
1954 }
1955 if (to < 0) {
1956 to += laneLength;
1957 }
1958 if ((to - from) < POSITION_EPS) {
1959 return false;
1960 }
1961 if ((from < 0) || (from > laneLength)) {
1962 return false;
1963 }
1964 if ((to < 0) || (to > laneLength)) {
1965 return false;
1966 }
1967 return true;
1968}
1969
1970
1971void
1972GNEAdditionalHandler::fixLaneDoublePosition(double& from, double& to, const double laneLength) {
1973 // adjust from (negative means that start at the end of lane and count backward)
1974 if (from == INVALID_DOUBLE) {
1975 from = 0;
1976 }
1977 if (to == INVALID_DOUBLE) {
1978 to = laneLength;
1979 }
1980 if (from < 0) {
1981 from += laneLength;
1982 }
1983 if (from < 0) {
1984 from = 0;
1985 } else if (from > laneLength) {
1986 from = laneLength;
1987 }
1988 // adjust to
1989 if (to < 0) {
1990 to += laneLength;
1991 }
1992 if (to < 0) {
1993 to = 0;
1994 } else if (to > laneLength) {
1995 to = laneLength;
1996 }
1997 // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1998 if ((to - from) < POSITION_EPS) {
1999 if (to >= POSITION_EPS) {
2000 from = to - POSITION_EPS;
2001 } else {
2002 from = 0;
2003 to = POSITION_EPS;
2004 }
2005 }
2006}
2007
2008
2009bool
2010GNEAdditionalHandler::checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos) {
2011 if (friendlyPos) {
2012 return true;
2013 } else {
2014 return (checkLanePosition(fromPos, 0, fromLaneLength, false) && checkLanePosition(toPos, 0, tolaneLength, false));
2015 }
2016}
2017
2018
2019void
2020GNEAdditionalHandler::fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength) {
2021 double length = 0;
2022 fixLanePosition(fromPos, length, fromLaneLength);
2023 fixLanePosition(toPos, length, tolaneLength);
2024}
2025
2026
2029 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
2030 return nullptr;
2031 } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
2032 return nullptr;
2033 } else {
2035 }
2036}
2037
2038
2041 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
2042 // parent interval doesn't exist
2043 return nullptr;
2044 } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
2045 // rerouter parent doesn't exist
2046 return nullptr;
2047 } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
2048 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
2049 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
2050 return nullptr;
2051 } else {
2056 }
2057}
2058
2059
2060std::vector<GNEEdge*>
2061GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::string &id, const std::vector<std::string>& edgeIDs) {
2062 std::vector<GNEEdge*> edges;
2063 for (const auto& edgeID : edgeIDs) {
2064 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
2065 // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
2066 if (edge == nullptr) {
2067 writeError(TLF("Could not build % with ID '%' in netedit; % with ID '%' doesn't exist.", toString(tag), id, toString(SUMO_TAG_EDGE), edgeID));
2068 edges.clear();
2069 return edges;
2070 } else {
2071 edges.push_back(edge);
2072 }
2073 }
2074 return edges;
2075}
2076
2077
2078std::vector<GNELane*>
2079GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::string &id, const std::vector<std::string>& laneIDs) {
2080 std::vector<GNELane*> lanes;
2081 for (const auto& laneID : laneIDs) {
2082 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
2083 // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
2084 if (lane == nullptr) {
2085 writeError(TLF("Could not build % with ID '%' in netedit; % with ID '%' doesn't exist.", toString(tag), id, toString(SUMO_TAG_LANE), laneID));
2086 lanes.clear();
2087 return lanes;
2088 } else {
2089 lanes.push_back(lane);
2090 }
2091 }
2092 return lanes;
2093}
2094
2095
2096bool
2097GNEAdditionalHandler::checkDuplicatedAdditional(const SumoXMLTag tag, const std::vector<SumoXMLTag> tags, const std::string& id) {
2098 for (const auto& tagChecked : tags) {
2099 // retrieve additional
2100 auto additional = myNet->getAttributeCarriers()->retrieveAdditional(tagChecked, id, false);
2101 // if additional exist, check if overwrite (delete)
2102 if (additional) {
2103 if (!myAllowUndoRedo) {
2104 // only overwrite if allow undo-redo
2105 return writeErrorDuplicated(tag, id, tagChecked);
2106 } else if (myOverwrite) {
2107 // delete additional (and all of their childrens)
2109 } else {
2110 // duplicated additional
2111 return writeErrorDuplicated(tag, id, tagChecked);
2112 }
2113 }
2114 }
2115 return true;
2116}
2117
2118
2120 myNet(nullptr),
2121 myAllowUndoRedo(false),
2122 myOverwrite(false) {
2123}
2124
2125// ===========================================================================
2126// GNEAdditionalHandler::NeteditParameters method definitions
2127// ===========================================================================
2128
2130 select(sumoBaseObject->hasBoolAttribute(GNE_ATTR_SELECTED) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_SELECTED) : false),
2131 centerAfterCreation(sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) ? sumoBaseObject->getBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) : false) {
2132}
2133
2134
2136
2137
2139 select(false),
2140 centerAfterCreation(false) {
2141}
2142
2143/****************************************************************************/
const unsigned char E3[]
Definition E3.cpp:22
long long int SUMOTime
Definition GUI.h:36
#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
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_SINK
Sink(s) specification.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_SOURCE
a source
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ GNE_TAG_POILANE
Point of interest over Lane.
@ 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
@ SUMO_ATTR_LANE
@ GNE_ATTR_CENTER_AFTER_CREATION
flag to center camera after element creation
@ SUMO_ATTR_FILE
@ 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_IMGFILE
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_PERSON_CAPACITY
@ SUMO_ATTR_CHARGEDELAY
Delay in the charge of charging stations (different of waiting time)
@ SUMO_ATTR_TIME
trigger: the time of the step
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
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
bool writeError(const std::string &error)
write error and enable error creating element
bool checkValidDetectorID(const SumoXMLTag tag, const std::string &value)
check if the given detector ID is valid
bool writeErrorInvalidParent(const SumoXMLTag tag, const std::string &id, const SumoXMLTag parentTag, const std::string &parentID)
write error "invalid parent element" giving ids of current and parent element
bool checkListOfVehicleTypes(const SumoXMLTag tag, const std::string &id, const std::vector< std::string > &vTypeIDs)
check list of IDs
bool writeErrorDuplicated(const SumoXMLTag tag, const std::string &id, const SumoXMLTag checkedTag)
write error "duplicated additional"
bool checkValidAdditionalID(const SumoXMLTag tag, const std::string &value)
check if the given additional ID is valid
bool checkFileName(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const std::string &value)
check if the given filename is valid
bool writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id)
write error "invalid position"
bool checkNegative(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const int value, const bool canBeZero)
check if the given int value is NOT negative
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
bool 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.
bool 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
bool buildClosingReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedEdgeID, SVCPermissions permissions)
builds a closing edge reroute
bool 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.
GNEAdditional * getRerouterIntervalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get rerouter interval parent
std::vector< GNELane * > parseLanes(const SumoXMLTag tag, const std::string &id, const std::vector< std::string > &laneIDs)
parse lanes
static void fixLaneDoublePosition(double &from, double &to, const double laneLengt)
fix the given positions over lane
bool checkDuplicatedAdditional(const SumoXMLTag tag, const std::vector< SumoXMLTag > tags, const std::string &id)
check if given ID correspond to a duplicated additional
static bool checkFriendlyPosSmallLanes(double pos, const double length, const double laneLength, const bool friendlyPos)
check if enable friendly pos in small lanes
static bool accessCanBeCreated(GNEAdditional *busStopParent, GNEEdge *edge)
check if a GNEAccess can be created in a certain Edge
bool buildTAZSource(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double departWeight)
Builds a TAZSource (Traffic Assignment Zone)
bool 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.
bool 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.
bool 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
bool 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
GNEAdditional * getAdditionalParent(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, SumoXMLTag tag) const
get additional parent
bool 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)
bool 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)
bool 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.
bool buildDetectorEntry(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a entry detector (E3)
bool 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
bool 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
bool buildDestProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newEdgeDestinationID, const double probability)
builds a dest prob reroute
bool buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &closedLane, SVCPermissions permissions)
builds a closing lane reroute
bool buildCalibratorFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameter)
builds a calibrator flow
bool 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)
bool buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime time, const std::string &speed)
Builds a VariableSpeedSign Step.
bool buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newParkignAreaID, const double probability, const bool visible)
builds a parking area reroute
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
bool buildDetectorExit(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &laneID, const double pos, const bool friendlyPos, const Parameterised::Map &parameters)
Builds a exit detector (E3)
bool 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.
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
std::vector< GNEEdge * > parseEdges(const SumoXMLTag tag, const std::string &id, const std::vector< std::string > &edgeIDs)
parse edges
bool postParserTasks()
run post parser tasks
bool 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
static bool checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos)
check if the given position over a lane is valid
bool buildRerouterInterval(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOTime begin, const SUMOTime end)
builds a rerouter interval
bool 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)
bool buildTAZSink(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const double arrivalWeight)
Builds a TAZSink (Traffic Assignment Zone)
GNEAdditionalHandler()
invalidate default constructo
bool 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.
bool 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.
bool 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 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
bool 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.
bool 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.
bool 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.
bool 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)
bool 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.
bool 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)
bool 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
bool 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.
bool 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)
bool buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &newRouteID, const double probability)
builds a route prob reroute
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:781
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:1118
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:654
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:676
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition GNENet.cpp:2837
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
void enableUpdateGeometry()
Definition GNENet.cpp:2831
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:4715
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 isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
const bool centerAfterCreation
center view after creation