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-2025 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
22#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNEViewNet.h>
30
31#include "GNEAccess.h"
33#include "GNEBusStop.h"
34#include "GNECalibrator.h"
35#include "GNECalibratorFlow.h"
36#include "GNEChargingStation.h"
38#include "GNEClosingReroute.h"
39#include "GNEContainerStop.h"
40#include "GNEDestProbReroute.h"
44#include "GNELaneAreaDetector.h"
46#include "GNEOverheadWire.h"
47#include "GNEPOI.h"
48#include "GNEParkingArea.h"
50#include "GNEParkingSpace.h"
51#include "GNEPoly.h"
52#include "GNERerouter.h"
53#include "GNERerouterInterval.h"
54#include "GNERerouterSymbol.h"
55#include "GNERouteProbReroute.h"
56#include "GNERouteProbe.h"
57#include "GNETAZ.h"
58#include "GNETAZSourceSink.h"
60#include "GNEVaporizer.h"
64
65// ===========================================================================
66// GNEAdditionalHandler method definitions
67// ===========================================================================
68
69GNEAdditionalHandler::GNEAdditionalHandler(GNENet* net, const std::string& filename, const bool allowUndoRedo, const bool overwrite) :
70 AdditionalHandler(filename),
71 myNet(net),
72 myAllowUndoRedo(allowUndoRedo),
73 myOverwrite(overwrite) {
74}
75
76
79
80
81bool
83 // nothing to do
84 return true;
85}
86
87
88bool
89GNEAdditionalHandler::buildBusStop(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id,
90 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
91 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
92 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
93 // check conditions
94 const auto element = retrieveAdditionalElement(NamespaceIDs::busStops, id);
95 if (!checkElement(SUMO_TAG_BUS_STOP, element)) {
96 return false;
98 return false;
99 } else {
100 // get lane
101 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
102 // check lane
103 if (lane == nullptr) {
105 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
107 } else if (!checkNegative(SUMO_TAG_BUS_STOP, id, SUMO_ATTR_PERSON_CAPACITY, personCapacity, true)) {
108 return false;
109 } else if (!checkNegative(SUMO_TAG_BUS_STOP, id, SUMO_ATTR_PARKING_LENGTH, parkingLength, true)) {
110 return false;
111 } else {
112 // build busStop
113 GNEAdditional* busStop = GNEBusStop::buildBusStop(id, myNet, myFilename, lane, startPos, endPos, name, lines, personCapacity,
114 parkingLength, color, friendlyPosition, parameters);
115 // insert depending of allowUndoRedo
116 if (myAllowUndoRedo) {
117 myNet->getViewNet()->getUndoList()->begin(busStop, TL("add bus stop '") + id + "'");
118 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(busStop, true), true);
120 } else {
122 lane->addChildElement(busStop);
123 busStop->incRef("buildBusStop");
124 }
125 return true;
126 }
127 }
128}
129
130
131bool
132GNEAdditionalHandler::buildTrainStop(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id,
133 const std::string& laneID, const double startPos, const double endPos, const std::string& name,
134 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
135 const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
136 // check conditions
137 const auto element = retrieveAdditionalElement(NamespaceIDs::busStops, id);
138 if (!checkElement(SUMO_TAG_TRAIN_STOP, element)) {
139 return false;
141 return false;
142 } else {
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, myNet, myFilename, lane, 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 lane
178 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
179 // get busStop (or trainStop)
180 GNEAdditional* busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_BUS_STOP);
181 if (busStop == nullptr) {
182 busStop = getAdditionalParent(sumoBaseObject, SUMO_TAG_TRAIN_STOP);
183 }
184 // pos double
185 bool validPos = true;
186 double posDouble = 0;
187 if (lane) {
188 if (GNEAttributeCarrier::canParse<double>(pos)) {
189 posDouble = GNEAttributeCarrier::parse<double>(pos);
190 validPos = checkLanePosition(posDouble, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
191 } else if (pos == "random" || pos == "doors" || pos == "carriage") {
192 posDouble = INVALID_DOUBLE;
193 } else if (pos.empty()) {
194 posDouble = 0;
195 } else {
196 validPos = false;
197 }
198 }
199 // Check if busStop parent and lane is correct
200 if (lane == nullptr) {
202 } else if (busStop == nullptr) {
204 } else if (!validPos) {
206 } else if ((length != -1) && !checkNegative(SUMO_TAG_ACCESS, busStop->getID(), SUMO_ATTR_LENGTH, length, true)) {
207 return false;
208 } else if (!accessCanBeCreated(busStop, lane->getParentEdge())) {
209 return writeError(TL("Could not build access in netedit; busStop parent already owns an access in the edge '") + lane->getParentEdge()->getID() + "'");
210 } else if (!lane->allowPedestrians()) {
211 return writeError(TLF("Could not build access in netedit; The lane '%' doesn't support pedestrians", lane->getID()));
212 } else {
213 // build access
214 GNEAdditional* access = new GNEAccess(busStop, lane, posDouble, pos, friendlyPos, length, parameters);
215 // insert depending of allowUndoRedo
216 if (myAllowUndoRedo) {
217 myNet->getViewNet()->getUndoList()->begin(access, TL("add access in '") + busStop->getID() + "'");
218 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(access, true), true);
220 } else {
222 lane->addChildElement(access);
223 busStop->addChildElement(access);
224 access->incRef("buildAccess");
225 }
226 return true;
227 }
228}
229
230
231bool
232GNEAdditionalHandler::buildContainerStop(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& laneID,
233 const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines, const int containerCapacity,
234 const double parkingLength, const RGBColor& color, const bool friendlyPosition, const Parameterised::Map& parameters) {
235 // check conditions
236 const auto element = retrieveAdditionalElement({SUMO_TAG_CONTAINER_STOP}, id);
237 if (!checkElement(SUMO_TAG_CONTAINER_STOP, element)) {
238 return false;
240 return false;
241 } else {
242 // get lane
243 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
244 // check lane
245 if (lane == nullptr) {
247 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
249 } else if (!checkNegative(SUMO_TAG_CONTAINER_STOP, id, SUMO_ATTR_CONTAINER_CAPACITY, containerCapacity, true)) {
250 return false;
251 } else if (!checkNegative(SUMO_TAG_CONTAINER_STOP, id, SUMO_ATTR_PARKING_LENGTH, parkingLength, true)) {
252 return false;
253 } else {
254 // build containerStop
255 GNEAdditional* containerStop = new GNEContainerStop(id, myNet, myFilename, lane, startPos, endPos, name, lines, containerCapacity, parkingLength,
256 color, friendlyPosition, parameters);
257 // insert depending of allowUndoRedo
258 if (myAllowUndoRedo) {
259 myNet->getViewNet()->getUndoList()->begin(containerStop, TL("add container stop '") + id + "'");
260 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(containerStop, true), true);
262 } else {
264 lane->addChildElement(containerStop);
265 containerStop->incRef("buildContainerStop");
266 }
267 return true;
268 }
269 }
270}
271
272
273bool
275 const std::string& laneID, const double startPos, const double endPos, const std::string& name, const double chargingPower,
276 const double efficiency, const bool chargeInTransit, const SUMOTime chargeDelay, const std::string& chargeType,
277 const SUMOTime waitingTime, const bool friendlyPosition, const std::string& parkingAreaID, const Parameterised::Map& parameters) {
278 // check conditions
279 const auto element = retrieveAdditionalElement({SUMO_TAG_CHARGING_STATION}, id);
281 return false;
283 return false;
284 } else {
285 // get lane
286 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
287 // check lane
288 if (lane == nullptr) {
290 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
292 } else if (!checkNegative(SUMO_TAG_CHARGING_STATION, id, SUMO_ATTR_CHARGINGPOWER, chargingPower, true)) {
293 return false;
294 } else if (!checkNegative(SUMO_TAG_CHARGING_STATION, id, SUMO_ATTR_CHARGEDELAY, chargeDelay, true)) {
295 return false;
296 } else if (!SUMOXMLDefinitions::ChargeTypes.hasString(chargeType)) {
297 return writeError(TLF("Could not build % with ID '%' in netedit; Invalid charge type '%' .", toString(SUMO_TAG_CHARGING_STATION), id, chargeType));
298 } else {
299 // build chargingStation
300 GNEAdditional* chargingStation = new GNEChargingStation(id, myNet, myFilename, lane, startPos, endPos, name, chargingPower, efficiency, chargeInTransit,
301 chargeDelay, chargeType, waitingTime, parkingAreaID, friendlyPosition, parameters);
302 // insert depending of allowUndoRedo
303 if (myAllowUndoRedo) {
304 myNet->getViewNet()->getUndoList()->begin(chargingStation, TL("add charging station '") + id + "'");
305 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(chargingStation, true), true);
307 } else {
308 myNet->getAttributeCarriers()->insertAdditional(chargingStation);
309 lane->addChildElement(chargingStation);
310 chargingStation->incRef("buildChargingStation");
311 }
312 return true;
313 }
314 }
315}
316
317
318bool
319GNEAdditionalHandler::buildParkingArea(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& laneID,
320 const double startPos, const double endPos, const std::string& departPos, const std::string& name,
321 const std::vector<std::string>& badges, const bool friendlyPosition, const int roadSideCapacity, const bool onRoad,
322 const double width, const double length, const double angle, const bool lefthand, const Parameterised::Map& parameters) {
323 // check conditions
324 const auto element = retrieveAdditionalElement({SUMO_TAG_PARKING_AREA}, id);
325 if (!checkElement(SUMO_TAG_PARKING_AREA, element)) {
326 return false;
328 return false;
329 } else {
330 // get lane
331 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
332 // get departPos double
333 const double departPosDouble = GNEAttributeCarrier::canParse<double>(departPos) ? GNEAttributeCarrier::parse<double>(departPos) : 0;
334 // check lane
335 if (lane == nullptr) {
337 } else if (!checkLaneDoublePosition(startPos, endPos, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosition)) {
339 } else if (!checkNegative(SUMO_TAG_PARKING_AREA, id, SUMO_ATTR_ROADSIDE_CAPACITY, roadSideCapacity, true)) {
340 return false;
341 } else if (!checkNegative(SUMO_TAG_PARKING_AREA, id, SUMO_ATTR_WIDTH, width, true)) {
342 return false;
343 } else if (!checkNegative(SUMO_TAG_PARKING_AREA, id, SUMO_ATTR_LENGTH, length, true)) {
344 return false;
345 } else if ((departPosDouble < 0) || (departPosDouble > lane->getParentEdge()->getNBEdge()->getFinalLength())) {
346 return writeError(TLF("Could not build parking area with ID '%' in netedit; Invalid departPos over lane.", id));
347 } else {
348 // build parkingArea
349 GNEAdditional* parkingArea = new GNEParkingArea(id, myNet, myFilename, lane, startPos, endPos, GNEAttributeCarrier::canParse<double>(departPos) ? departPos : "",
350 name, badges, friendlyPosition, roadSideCapacity, onRoad,
351 (width == 0) ? SUMO_const_laneWidth : width, length, angle, lefthand, parameters);
352 // insert depending of allowUndoRedo
353 if (myAllowUndoRedo) {
354 myNet->getViewNet()->getUndoList()->begin(parkingArea, TL("add parking area '") + id + "'");
355 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingArea, true), true);
357 } else {
359 lane->addChildElement(parkingArea);
360 parkingArea->incRef("buildParkingArea");
361 }
362 return true;
363 }
364 }
365}
366
367
368bool
369GNEAdditionalHandler::buildParkingSpace(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const double x, const double y, const double z,
370 const std::string& name, const std::string& width, const std::string& length, const std::string& angle, const double slope,
371 const Parameterised::Map& parameters) {
372 // check width and heights
373 if (!width.empty() && !GNEAttributeCarrier::canParse<double>(width)) {
374 return writeError(TL("Could not build parking space in netedit; attribute width cannot be parse to float."));
375 } else if (!length.empty() && !GNEAttributeCarrier::canParse<double>(length)) {
376 return writeError(TL("Could not build parking space in netedit; attribute length cannot be parse to float."));
377 } else if (!angle.empty() && !GNEAttributeCarrier::canParse<double>(angle)) {
378 return writeError(TL("Could not build parking space in netedit; attribute angle cannot be parse to float."));
379 } else {
380 // get lane
381 GNEAdditional* parkingArea = getAdditionalParent(sumoBaseObject, SUMO_TAG_PARKING_AREA);
382 // get double values
383 const double widthDouble = width.empty() ? 0 : GNEAttributeCarrier::parse<double>(width);
384 const double lengthDouble = length.empty() ? 0 : GNEAttributeCarrier::parse<double>(length);
385 // check lane
386 if (parkingArea == nullptr) {
388 } else if (!checkNegative(SUMO_TAG_PARKING_SPACE, parkingArea->getID(), SUMO_ATTR_WIDTH, widthDouble, true)) {
389 return false;
390 } else if (!checkNegative(SUMO_TAG_PARKING_SPACE, parkingArea->getID(), SUMO_ATTR_LENGTH, lengthDouble, true)) {
391 return false;
392 } else {
393 // build parkingSpace
394 GNEAdditional* parkingSpace = new GNEParkingSpace(parkingArea, Position(x, y, z), width, length, angle, slope, name, parameters);
395 // insert depending of allowUndoRedo
396 if (myAllowUndoRedo) {
397 myNet->getViewNet()->getUndoList()->begin(parkingSpace, TL("add parking space in '") + parkingArea->getID() + "'");
398 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingSpace, true), true);
400 } else {
402 parkingArea->addChildElement(parkingSpace);
403 parkingSpace->incRef("buildParkingSpace");
404 }
405 // update geometry (due boundaries)
406 parkingSpace->updateGeometry();
407 return true;
408 }
409 }
410}
411
412
413bool
414GNEAdditionalHandler::buildE1Detector(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& laneID,
415 const double position, const SUMOTime period, const std::string& file, const std::vector<std::string>& vehicleTypes,
416 const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name,
417 const bool friendlyPos, const Parameterised::Map& parameters) {
418 // check conditions
419 const auto element = retrieveAdditionalElement({SUMO_TAG_INDUCTION_LOOP}, id);
420 if (!checkElement(SUMO_TAG_INDUCTION_LOOP, element)) {
421 return false;
423 return false;
424 } else {
425 // get lane
426 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
427 // check lane
428 if (lane == nullptr) {
430 } else if (!checkLanePosition(position, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
432 } else if (!checkNegative(SUMO_TAG_INDUCTION_LOOP, id, SUMO_ATTR_PERIOD, period, true)) {
433 return false;
434 } else if (!checkFileName(SUMO_TAG_INDUCTION_LOOP, id, SUMO_ATTR_FILE, file)) {
435 return false;
436 } else if (!checkListOfVehicleTypes(SUMO_TAG_INDUCTION_LOOP, id, vehicleTypes)) {
437 return false;
438 } else {
439 // build E1
440 GNEAdditional* detectorE1 = new GNEInductionLoopDetector(id, myNet, myFilename, lane, position, period, file, vehicleTypes,
441 nextEdges, detectPersons, name, friendlyPos, parameters);
442 // insert depending of allowUndoRedo
443 if (myAllowUndoRedo) {
444 myNet->getViewNet()->getUndoList()->begin(detectorE1, TL("add induction loop '") + id + "'");
445 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1, true), true);
447 } else {
449 lane->addChildElement(detectorE1);
450 detectorE1->incRef("buildDetectorE1");
451 }
452 return true;
453 }
454 }
455}
456
457
458bool
459GNEAdditionalHandler::buildSingleLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& laneID,
460 const double pos, const double length, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
461 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
462 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
463 const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
464 // check conditions
467 return false;
469 return false;
470 } else {
471 // get lane
472 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
473 // check lane
474 if (lane == nullptr) {
476 } else {
477 // check friendlyPos in small lanes
478 const bool friendlyPosCheck = checkFriendlyPosSmallLanes(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
479 if (!checkLanePosition(pos, length, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPosCheck)) {
481 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_LENGTH, length, true)) {
482 return false;
483 } else if ((period != -1) && !checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_PERIOD, period, true)) {
484 return false;
485 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
486 // temporal
487 return writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
488 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold, true)) {
489 return false;
490 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_HALTING_SPEED_THRESHOLD, speedThreshold, true)) {
491 return false;
492 } else if (!checkNegative(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold, true)) {
493 return false;
494 } else if (!checkFileName(SUMO_TAG_LANE_AREA_DETECTOR, id, SUMO_ATTR_FILE, filename)) {
495 return false;
496 } else if (!checkListOfVehicleTypes(SUMO_TAG_LANE_AREA_DETECTOR, id, vehicleTypes)) {
497 return false;
498 } else {
499 // build E2 single lane
500 GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, myNet, myFilename, lane, pos, length, period, trafficLight, filename,
501 vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
502 speedThreshold, jamThreshold, friendlyPosCheck, show, parameters);
503 // insert depending of allowUndoRedo
504 if (myAllowUndoRedo) {
505 myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
506 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
508 } else {
510 lane->addChildElement(detectorE2);
511 detectorE2->incRef("buildDetectorE2");
512 }
513 return true;
514 }
515 }
516 }
517}
518
519
520bool
521GNEAdditionalHandler::buildMultiLaneDetectorE2(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::vector<std::string>& laneIDs,
522 const double pos, const double endPos, const SUMOTime period, const std::string& trafficLight, const std::string& filename,
523 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
524 const std::string& name, const SUMOTime timeThreshold, const double speedThreshold, const double jamThreshold,
525 const bool friendlyPos, const bool show, const Parameterised::Map& parameters) {
526 // check conditions
529 return false;
531 return false;
532 } else {
533 // get lanes
534 const auto lanes = parseLanes(GNE_TAG_MULTI_LANE_AREA_DETECTOR, id, laneIDs);
535 // check lanes
536 if (lanes.empty()) {
537 return false;
538 } else {
539 // calculate path
541 return writeError(TLF("Could not build lane area detector with ID '%' in netedit; Lanes aren't consecutives.", id));
542 } else if (!checkMultiLanePosition(
543 pos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
544 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
546 } else if ((period != -1) && !checkNegative(GNE_TAG_MULTI_LANE_AREA_DETECTOR, id, SUMO_ATTR_PERIOD, period, true)) {
547 return false;
548 } else if ((trafficLight.size() > 0) && !(SUMOXMLDefinitions::isValidNetID(trafficLight))) {
549 // temporal
550 return writeError(TLF("Could not build lane area detector with ID '%' in netedit; invalid traffic light ID.", id));
552 return false;
554 return false;
556 return false;
558 return false;
559 } else if (!checkListOfVehicleTypes(GNE_TAG_MULTI_LANE_AREA_DETECTOR, id, vehicleTypes)) {
560 return false;
561 } else {
562 // build E2 multilane detector
563 GNEAdditional* detectorE2 = new GNELaneAreaDetector(id, myNet, myFilename, lanes, pos, endPos, period, trafficLight, filename,
564 vehicleTypes, nextEdges, detectPersons, name, timeThreshold,
565 speedThreshold, jamThreshold, friendlyPos, show, parameters);
566 // insert depending of allowUndoRedo
567 if (myAllowUndoRedo) {
568 myNet->getViewNet()->getUndoList()->begin(detectorE2, TL("add lane area detector '") + id + "'");
569 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE2, true), true);
571 } else {
573 for (const auto& lane : lanes) {
574 lane->addChildElement(detectorE2);
575 }
576 detectorE2->incRef("buildDetectorE2Multilane");
577 }
578 return true;
579 }
580 }
581 }
582}
583
584
585bool
586GNEAdditionalHandler::buildDetectorE3(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const Position& pos, const SUMOTime period,
587 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
588 const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold, const double speedThreshold,
589 const bool openEntry, const bool expectedArrival, const Parameterised::Map& parameters) {
590 // check conditions
593 return false;
595 return false;
596 } else if (!checkNegative(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_PERIOD, period, true)) {
597 return false;
598 } else if (!checkNegative(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold, true)) {
599 return false;
600 } else if (!checkNegative(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_HALTING_SPEED_THRESHOLD, speedThreshold, true)) {
601 return false;
602 } else if (!checkFileName(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, SUMO_ATTR_FILE, filename)) {
603 return false;
604 } else if (!checkListOfVehicleTypes(SUMO_TAG_ENTRY_EXIT_DETECTOR, id, vehicleTypes)) {
605 return false;
606 } else {
607 // build E3
608 GNEAdditional* E3 = new GNEMultiEntryExitDetector(id, myNet, myFilename, pos, period, filename, vehicleTypes, nextEdges, detectPersons,
609 name, timeThreshold, speedThreshold, openEntry, expectedArrival, parameters);
610 // insert depending of allowUndoRedo
611 if (myAllowUndoRedo) {
612 myNet->getViewNet()->getUndoList()->begin(E3, TL("add entry-exit detector '") + id + "'");
613 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(E3, true), true);
615 } else {
617 E3->incRef("buildDetectorE3");
618 }
619 return true;
620 }
621}
622
623
624bool
625GNEAdditionalHandler::buildDetectorEntry(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
626 const bool friendlyPos, const Parameterised::Map& parameters) {
627 // get lane
628 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
629 // get E3 parent
631 // Check if Detector E3 parent and lane is correct
632 if (lane == nullptr) {
634 } else if (E3 == nullptr) {
636 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
638 } else {
639 // build entry instant
640 GNEAdditional* entry = new GNEEntryExitDetector(SUMO_TAG_DET_ENTRY, E3, lane, pos, friendlyPos, parameters);
641 // insert depending of allowUndoRedo
642 if (myAllowUndoRedo) {
643 myNet->getViewNet()->getUndoList()->begin(entry, TL("add entry detector in '") + E3->getID() + "'");
644 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(entry, true), true);
646 } else {
648 lane->addChildElement(entry);
649 E3->addChildElement(entry);
650 entry->incRef("buildDetectorEntry");
651 }
652 return true;
653 }
654}
655
656
657bool
658GNEAdditionalHandler::buildDetectorExit(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& laneID, const double pos,
659 const bool friendlyPos, const Parameterised::Map& parameters) {
660 // get lane
661 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
662 // get E3 parent
664 // Check if Detector E3 parent and lane is correct
665 if (lane == nullptr) {
667 } else if (E3 == nullptr) {
669 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
671 } else {
672 // build exit instant
673 GNEAdditional* exit = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, E3, lane, pos, friendlyPos, parameters);
674 // insert depending of allowUndoRedo
675 if (myAllowUndoRedo) {
676 myNet->getViewNet()->getUndoList()->begin(exit, TL("add exit detector in '") + E3->getID() + "'");
677 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(exit, true), true);
679 } else {
681 lane->addChildElement(exit);
682 E3->addChildElement(exit);
683 exit->incRef("buildDetectorExit");
684 }
685 return true;
686 }
687}
688
689
690bool
691GNEAdditionalHandler::buildDetectorE1Instant(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& laneID, double pos,
692 const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
693 const std::string& detectPersons, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters) {
694 // check conditions
697 return false;
699 return false;
700 } else {
701 // get lane
702 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
703 // check lane
704 if (lane == nullptr) {
707 return false;
708 } else if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
710 } else {
711 // build E1 instant
712 GNEAdditional* detectorE1Instant = new GNEInstantInductionLoopDetector(id, myNet, myFilename, lane, pos, filename, vehicleTypes, nextEdges,
713 detectPersons, name, friendlyPos, parameters);
714 // insert depending of allowUndoRedo
715 if (myAllowUndoRedo) {
716 myNet->getViewNet()->getUndoList()->begin(detectorE1Instant, TL("add instant induction loop '") + id + "'");
717 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(detectorE1Instant, true), true);
719 } else {
720 myNet->getAttributeCarriers()->insertAdditional(detectorE1Instant);
721 lane->addChildElement(detectorE1Instant);
722 detectorE1Instant->incRef("buildDetectorE1Instant");
723 }
724 return true;
725 }
726 }
727}
728
729
730bool
731GNEAdditionalHandler::buildLaneCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& laneID, const double pos,
732 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
733 const Parameterised::Map& parameters) {
734 // get lane
735 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
736 // get routeProbe
737 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
738 // check conditions
740 if (!checkElement(GNE_TAG_CALIBRATOR_LANE, element)) {
741 return false;
743 return false;
744 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
746 } else if (lane == nullptr) {
748 } else {
749 // check lane
750 if (!checkLanePosition(pos, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
752 } else if (!checkNegative(GNE_TAG_CALIBRATOR_LANE, id, SUMO_ATTR_PERIOD, period, true)) {
753 return false;
754 } else if (!checkNegative(GNE_TAG_CALIBRATOR_LANE, id, SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold, true)) {
755 return false;
756 } else {
757 // build Calibrator
758 GNEAdditional* calibrator = (routeProbe == nullptr) ?
759 new GNECalibrator(id, myNet, myFilename, lane, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
760 new GNECalibrator(id, myNet, myFilename, lane, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
761 // insert depending of allowUndoRedo
762 if (myAllowUndoRedo) {
763 myNet->getViewNet()->getUndoList()->begin(calibrator, TL("add lane calibrator '") + id + "'");
764 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
766 // check if center after creation
769 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
770 }
771 } else {
773 lane->addChildElement(calibrator);
774 if (routeProbe) {
775 routeProbe->addChildElement(calibrator);
776 }
777 calibrator->incRef("buildCalibrator");
778 }
779 return true;
780 }
781 }
782}
783
784
785bool
786GNEAdditionalHandler::buildEdgeCalibrator(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const double pos,
787 const std::string& name, const std::string& outfile, const SUMOTime period, const std::string& routeprobeID, const double jamThreshold, const std::vector<std::string>& vTypes,
788 const Parameterised::Map& parameters) {
789 // get edge
790 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
791 // get routeProbe
792 GNEAdditional* routeProbe = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_ROUTEPROBE, routeprobeID, false);
793 // check conditions
795 if (!checkElement(SUMO_TAG_CALIBRATOR, element)) {
796 return false;
798 return false;
799 } else if ((routeprobeID.size() > 0) && (routeProbe == nullptr)) {
801 } else if (edge == nullptr) {
803 } else {
804 if (!checkLanePosition(pos, 0, edge->getChildLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), false)) {
806 } else if (!checkNegative(SUMO_TAG_CALIBRATOR, id, SUMO_ATTR_PERIOD, period, true)) {
807 return false;
808 } else if (!checkNegative(SUMO_TAG_CALIBRATOR, id, SUMO_ATTR_JAM_DIST_THRESHOLD, jamThreshold, true)) {
809 return false;
810 } else {
811 // build Calibrator
812 GNEAdditional* calibrator = (routeProbe == nullptr) ?
813 new GNECalibrator(id, myNet, myFilename, edge, pos, period, name, outfile, jamThreshold, vTypes, parameters) :
814 new GNECalibrator(id, myNet, myFilename, edge, pos, period, name, outfile, routeProbe, jamThreshold, vTypes, parameters);
815 // insert depending of allowUndoRedo
816 if (myAllowUndoRedo) {
817 myNet->getViewNet()->getUndoList()->begin(calibrator, TL("add calibrator '") + id + "'");
818 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(calibrator, true), true);
820 // check if center after creation
823 myNet->getViewNet()->centerTo(calibrator->getPositionInView(), false);
824 }
825 } else {
827 edge->addChildElement(calibrator);
828 if (routeProbe) {
829 routeProbe->addChildElement(calibrator);
830 }
831 calibrator->incRef("buildCalibrator");
832 }
833 return true;
834 }
835 }
836}
837
838
839bool
841 // get vType
842 GNEDemandElement* vType = myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, vehicleParameter.vtypeid.empty() ? DEFAULT_VTYPE_ID : vehicleParameter.vtypeid, false);
843 // get route
845 // get calibrator parent
847 // check parents
848 if (vType == nullptr) {
849 return writeErrorInvalidParent(SUMO_TAG_FLOW, "", SUMO_TAG_VTYPE, vehicleParameter.vtypeid);
850 } else if (route == nullptr) {
851 return writeErrorInvalidParent(SUMO_TAG_FLOW, "", SUMO_TAG_ROUTE, vehicleParameter.routeid);
852 } else if (calibrator == nullptr) {
854 } else {
855 // create calibrator flow
856 GNEAdditional* flow = new GNECalibratorFlow(calibrator, vType, route, vehicleParameter);
857 // insert depending of allowUndoRedo
858 if (myAllowUndoRedo) {
859 myNet->getViewNet()->getUndoList()->begin(flow, TL("add calibrator flow in '") + calibrator->getID() + "'");
860 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(flow, true), true);
862 } else {
864 calibrator->addChildElement(flow);
865 route->addChildElement(flow);
866 vType->addChildElement(flow);
867 flow->incRef("buildCalibratorFlow");
868 }
869 return true;
870 }
871}
872
873
874bool
875GNEAdditionalHandler::buildRerouter(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const Position& pos,
876 const std::vector<std::string>& edgeIDs, const double prob, const std::string& name,
877 const bool off, const bool optional, const SUMOTime timeThreshold,
878 const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
879 // check conditions
880 const auto element = retrieveAdditionalElement({SUMO_TAG_REROUTER}, id);
881 if (!checkElement(SUMO_TAG_REROUTER, element)) {
882 return false;
883 } else if (!checkValidAdditionalID(SUMO_TAG_REROUTER, id)) {
884 return false;
885 } else if (!checkNegative(SUMO_TAG_REROUTER, id, SUMO_ATTR_PROB, prob, true)) {
886 return false;
887 } else if (!checkNegative(SUMO_TAG_REROUTER, id, SUMO_ATTR_HALTING_TIME_THRESHOLD, timeThreshold, true)) {
888 return false;
889 } else if (!checkListOfVehicleTypes(SUMO_TAG_REROUTER, id, vTypes)) {
890 return false;
891 } else {
892 // parse edges
893 std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_REROUTER, id, edgeIDs);
894 // check edges
895 if (edges.empty()) {
896 return false;
897 } else {
898 GNEAdditional* rerouter = nullptr;
899 // continue depending of position
900 if (pos == Position::INVALID) {
901 if (edges.size() > 0) {
902 PositionVector laneShape = edges.front()->getChildLanes().front()->getLaneShape();
903 // move to side
904 laneShape.move2side(3);
905 // create rerouter
906 rerouter = new GNERerouter(id, myNet, myFilename, laneShape.positionAtOffset2D(laneShape.length2D() - 6), name, prob, off, optional, timeThreshold, vTypes, parameters);
907 } else {
908 rerouter = new GNERerouter(id, myNet, myFilename, Position(0, 0), name, prob, off, optional, timeThreshold, vTypes, parameters);
909 }
910 } else {
911 rerouter = new GNERerouter(id, myNet, myFilename, pos, name, prob, off, optional, timeThreshold, vTypes, parameters);
912 }
913 // create rerouter Symbols
914 std::vector<GNEAdditional*> rerouterSymbols;
915 for (const auto& edge : edges) {
916 rerouterSymbols.push_back(new GNERerouterSymbol(rerouter, edge));
917 }
918 // insert depending of allowUndoRedo
919 if (myAllowUndoRedo) {
920 myNet->getViewNet()->getUndoList()->begin(rerouter, TL("add rerouter '") + id + "'");
921 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouter, true), true);
922 // add symbols
923 for (const auto& rerouterSymbol : rerouterSymbols) {
924 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterSymbol, true), true);
925 }
927 } else {
929 rerouter->incRef("buildRerouter");
930 // add symbols into rerouter
931 for (const auto& rerouterSymbol : rerouterSymbols) {
932 rerouter->addChildElement(rerouterSymbol);
933 }
934 // add symbols into edges
935 for (int i = 0; i < (int)edges.size(); i++) {
936 edges.at(i)->addChildElement(rerouterSymbols.at(i));
937 }
938 }
939 return true;
940 }
941 }
942}
943
944
945bool
947 // get rerouter parent
948 GNEAdditional* rerouter = getAdditionalParent(sumoBaseObject, SUMO_TAG_REROUTER);
949 // check if rerouter exist
950 if (rerouter == nullptr) {
952 } else if (!checkNegative(SUMO_TAG_INTERVAL, rerouter->getID(), SUMO_ATTR_BEGIN, begin, true)) {
953 return false;
954 } else if (!checkNegative(SUMO_TAG_INTERVAL, rerouter->getID(), SUMO_ATTR_END, end, true)) {
955 return false;
956 } else if (end < begin) {
957 return writeError(TLF("Could not build interval with ID '%' in netedit; begin is greater than end.", rerouter->getID()));
958 } else {
959 // check if new interval will produce a overlapping
960 if (checkOverlappingRerouterIntervals(rerouter, begin, end)) {
961 // create rerouter interval and add it into rerouter parent
962 GNEAdditional* rerouterInterval = new GNERerouterInterval(rerouter, begin, end);
963 // insert depending of allowUndoRedo
964 if (myAllowUndoRedo) {
965 myNet->getViewNet()->getUndoList()->begin(rerouterInterval, TL("add rerouter interval in '") + rerouter->getID() + "'");
966 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(rerouterInterval, true), true);
968 } else {
969 rerouter->addChildElement(rerouterInterval);
970 rerouterInterval->incRef("buildRerouterInterval");
971 }
972 } else {
973 return writeError(TLF("Could not build interval with begin '%' and end '%' in '%' due overlapping.", toString(begin), toString(end), rerouter->getID()));
974 }
975 return true;
976 }
977}
978
979
980bool
981GNEAdditionalHandler::buildClosingLaneReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedLaneID, SVCPermissions permissions) {
982 // get rerouter interval parent
983 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
984 // get closed lane
985 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(closedLaneID, false);
986 // check parents
987 if (lane == nullptr) {
989 } else if (rerouterInterval == nullptr) {
991 } else {
992 // create closing lane reroute
993 GNEAdditional* closingLaneReroute = new GNEClosingLaneReroute(rerouterInterval, lane, permissions);
994 // add it to interval parent depending of allowUndoRedo
995 if (myAllowUndoRedo) {
996 myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing lane reroute in '") + lane->getID() + "'");
997 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
999 } else {
1000 rerouterInterval->addChildElement(closingLaneReroute);
1001 closingLaneReroute->incRef("buildClosingLaneReroute");
1002 }
1003 return true;
1004 }
1005}
1006
1007
1008bool
1009GNEAdditionalHandler::buildClosingReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& closedEdgeID, SVCPermissions permissions) {
1010 // get rerouter interval parent
1011 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1012 // get closed edge
1013 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(closedEdgeID, false);
1014 // check parents
1015 if (edge == nullptr) {
1017 } else if (rerouterInterval == nullptr) {
1019 } else {
1020 // create closing reroute
1021 GNEAdditional* closingLaneReroute = new GNEClosingReroute(rerouterInterval, edge, permissions);
1022 // add it to interval parent depending of allowUndoRedo
1023 if (myAllowUndoRedo) {
1024 myNet->getViewNet()->getUndoList()->begin(closingLaneReroute, TL("add closing reroute in '") + edge->getID() + "'");
1025 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(closingLaneReroute, true), true);
1027 } else {
1028 rerouterInterval->addChildElement(closingLaneReroute);
1029 closingLaneReroute->incRef("buildClosingLaneReroute");
1030 }
1031 return true;
1032 }
1033}
1034
1035bool
1036GNEAdditionalHandler::buildDestProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newEdgeDestinationID, const double probability) {
1037 // get rerouter interval parent
1038 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1039 // get edge
1040 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(newEdgeDestinationID, false);
1041 // check parents
1042 if (edge == nullptr) {
1043 return writeErrorInvalidParent(SUMO_TAG_DEST_PROB_REROUTE, "", SUMO_TAG_EDGE, newEdgeDestinationID);
1044 } else if (rerouterInterval == nullptr) {
1046 } else {
1047 // create dest probability reroute
1048 GNEAdditional* destProbReroute = new GNEDestProbReroute(rerouterInterval, edge, probability);
1049 // add it to interval parent depending of allowUndoRedo
1050 if (myAllowUndoRedo) {
1051 myNet->getViewNet()->getUndoList()->begin(destProbReroute, TL("add dest prob reroute in '") + edge->getID() + "'");
1052 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(destProbReroute, true), true);
1054 } else {
1055 rerouterInterval->addChildElement(destProbReroute);
1056 destProbReroute->incRef("builDestProbReroute");
1057 }
1058 return true;
1059 }
1060}
1061
1062
1063bool
1064GNEAdditionalHandler::buildParkingAreaReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newParkignAreaID, const double probability, const bool visible) {
1065 // get rerouter interval parent
1066 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1067 // get parking area
1068 GNEAdditional* parkingArea = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, newParkignAreaID, false);
1069 // check parents
1070 if (parkingArea == nullptr) {
1072 } else if (rerouterInterval == nullptr) {
1074 } else {
1075 // create parking area reroute
1076 GNEAdditional* parkingAreaReroute = new GNEParkingAreaReroute(rerouterInterval, parkingArea, probability, visible);
1077 // add it to interval parent depending of allowUndoRedo
1078 if (myAllowUndoRedo) {
1079 myNet->getViewNet()->getUndoList()->begin(parkingAreaReroute, TL("add parking area reroute in '") + parkingArea->getID() + "'");
1080 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(parkingAreaReroute, true), true);
1082 } else {
1083 rerouterInterval->addChildElement(parkingAreaReroute);
1084 parkingAreaReroute->incRef("builParkingAreaReroute");
1085 }
1086 return true;
1087 }
1088}
1089
1090
1091bool
1092GNEAdditionalHandler::buildRouteProbReroute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& newRouteID, const double probability) {
1093 // get rerouter interval parent
1094 GNEAdditional* rerouterInterval = getRerouterIntervalParent(sumoBaseObject);
1095 // get route parent
1097 // check parents
1098 if (route == nullptr) {
1100 } else if (rerouterInterval == nullptr) {
1102 } else {
1103 // create rout prob reroute
1104 GNEAdditional* routeProbReroute = new GNERouteProbReroute(rerouterInterval, route, probability);
1105 // add it to interval parent depending of allowUndoRedo
1106 if (myAllowUndoRedo) {
1107 myNet->getViewNet()->getUndoList()->begin(routeProbReroute, TL("add route prob reroute in '") + route->getID() + "'");
1108 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbReroute, true), true);
1110 } else {
1111 rerouterInterval->addChildElement(routeProbReroute);
1112 routeProbReroute->incRef("buildRouteProbReroute");
1113 }
1114 return true;
1115 }
1116}
1117
1118
1119bool
1120GNEAdditionalHandler::buildRouteProbe(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& edgeID, const SUMOTime period,
1121 const std::string& name, const std::string& file, const SUMOTime begin, const std::vector<std::string>& vTypes,
1122 const Parameterised::Map& parameters) {
1123 // check conditions
1124 const auto element = retrieveAdditionalElement({SUMO_TAG_ROUTEPROBE}, id);
1125 if (!checkElement(SUMO_TAG_ROUTEPROBE, element)) {
1126 return false;
1128 return false;
1129 } else {
1130 // get edge
1131 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1132 // check lane
1133 if (edge == nullptr) {
1135 } else if (!checkNegative(SUMO_TAG_ROUTEPROBE, id, SUMO_ATTR_PERIOD, period, true)) {
1136 return false;
1137 } else if (!checkNegative(SUMO_TAG_ROUTEPROBE, id, SUMO_ATTR_BEGIN, begin, true)) {
1138 return false;
1139 } else if (!checkFileName(SUMO_TAG_ROUTEPROBE, id, SUMO_ATTR_FILE, file)) {
1140 return false;
1141 } else {
1142 // build route probe
1143 GNEAdditional* routeProbe = new GNERouteProbe(id, myNet, myFilename, edge, period, name, file, begin, vTypes, parameters);
1144 // insert depending of allowUndoRedo
1145 if (myAllowUndoRedo) {
1146 myNet->getViewNet()->getUndoList()->begin(routeProbe, TL("add route probe '") + id + "'");
1147 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(routeProbe, true), true);
1149 // check if center after creation
1150 if (sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) &&
1152 myNet->getViewNet()->centerTo(routeProbe->getPositionInView(), false);
1153 }
1154 } else {
1156 edge->addChildElement(routeProbe);
1157 routeProbe->incRef("buildRouteProbe");
1158 }
1159 return true;
1160 }
1161 }
1162}
1163
1164
1165bool
1166GNEAdditionalHandler::buildVariableSpeedSign(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const Position& pos,
1167 const std::vector<std::string>& laneIDs, const std::string& name, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters) {
1168 // check conditions
1169 const auto element = retrieveAdditionalElement({SUMO_TAG_VSS}, id);
1170 if (!checkElement(SUMO_TAG_VSS, element)) {
1171 return false;
1172 } else if (!checkValidAdditionalID(SUMO_TAG_VSS, id)) {
1173 return false;
1174 } else {
1175 // parse lanes
1176 std::vector<GNELane*> lanes = parseLanes(SUMO_TAG_VSS, id, laneIDs);
1177 // check lane
1178 if (lanes.empty()) {
1179 return false;
1180 } else {
1181 // check vTypes
1182 if (!checkListOfVehicleTypes(SUMO_TAG_VSS, id, vTypes)) {
1183 return false;
1184 } else {
1185 // create VSS
1186 GNEAdditional* variableSpeedSign = new GNEVariableSpeedSign(id, myNet, myFilename, pos, name, vTypes, parameters);
1187 // create VSS Symbols
1188 std::vector<GNEAdditional*> VSSSymbols;
1189 for (const auto& lane : lanes) {
1190 VSSSymbols.push_back(new GNEVariableSpeedSignSymbol(variableSpeedSign, lane));
1191 }
1192 // insert depending of allowUndoRedo
1193 if (myAllowUndoRedo) {
1194 myNet->getViewNet()->getUndoList()->begin(variableSpeedSign, TL("add Variable Speed Sign '") + id + "'");
1195 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSign, true), true);
1196 for (const auto& VSSSymbol : VSSSymbols) {
1197 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(VSSSymbol, true), true);
1198 }
1200 } else {
1201 myNet->getAttributeCarriers()->insertAdditional(variableSpeedSign);
1202 variableSpeedSign->incRef("buildVariableSpeedSign");
1203 // add symbols into VSS
1204 for (const auto& VSSSymbol : VSSSymbols) {
1205 variableSpeedSign->addChildElement(VSSSymbol);
1206 }
1207 // add symbols into lanes
1208 for (int i = 0; i < (int)lanes.size(); i++) {
1209 lanes.at(i)->addChildElement(VSSSymbols.at(i));
1210 }
1211 }
1212 }
1213 return true;
1214 }
1215 }
1216}
1217
1218
1219bool
1220GNEAdditionalHandler::buildVariableSpeedSignStep(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOTime time, const std::string& speed) {
1221 // get VSS parent
1222 GNEAdditional* VSS = getAdditionalParent(sumoBaseObject, SUMO_TAG_VSS);
1223 // check lane
1224 if (VSS == nullptr) {
1226 } else if (!checkNegative(SUMO_TAG_STEP, VSS->getID(), SUMO_ATTR_TIME, time, true)) {
1227 return false;
1228 } else {
1229 // create Variable Speed Sign
1230 GNEAdditional* variableSpeedSignStep = new GNEVariableSpeedSignStep(VSS, time, speed);
1231 // add it depending of allow undoRedo
1232 if (myAllowUndoRedo) {
1233 myNet->getViewNet()->getUndoList()->begin(variableSpeedSignStep, TL("add VSS Step in '") + VSS->getID() + "'");
1234 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(variableSpeedSignStep, true), true);
1236 } else {
1237 VSS->addChildElement(variableSpeedSignStep);
1238 variableSpeedSignStep->incRef("buildVariableSpeedSignStep");
1239 }
1240 return true;
1241 }
1242}
1243
1244
1245bool
1246GNEAdditionalHandler::buildVaporizer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const SUMOTime beginTime,
1247 const SUMOTime endTime, const std::string& name, const Parameterised::Map& parameters) {
1248 // check conditions
1249 const auto element = retrieveAdditionalElement({SUMO_TAG_VAPORIZER}, edgeID);
1250 if (!checkElement(SUMO_TAG_VAPORIZER, element)) {
1251 return false;
1252 } else if (!checkValidAdditionalID(SUMO_TAG_VAPORIZER, edgeID)) {
1253 return false;
1254 } else {
1255 // get edge
1256 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1257 // check lane
1258 if (edge == nullptr) {
1260 } else if (!checkNegative(SUMO_TAG_VAPORIZER, edge->getID(), SUMO_ATTR_BEGIN, beginTime, true)) {
1261 return false;
1262 } else if (!checkNegative(SUMO_TAG_VAPORIZER, edge->getID(), SUMO_ATTR_END, endTime, true)) {
1263 return false;
1264 } else if (endTime < beginTime) {
1265 return writeError(TLF("Could not build Vaporizer with ID '%' in netedit; begin is greater than end.", edge->getID()));
1266 } else {
1267 // build vaporizer
1268 GNEAdditional* vaporizer = new GNEVaporizer(myNet, myFilename, edge, beginTime, endTime, name, parameters);
1269 // add it depending of allow undoRed
1270 if (myAllowUndoRedo) {
1271 myNet->getViewNet()->getUndoList()->begin(vaporizer, TL("add vaporizer in '") + edge->getID() + "'");
1272 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(vaporizer, true), true);
1274 // check if center after creation
1275 if (sumoBaseObject->hasBoolAttribute(GNE_ATTR_CENTER_AFTER_CREATION) &&
1277 myNet->getViewNet()->centerTo(vaporizer->getPositionInView(), false);
1278 }
1279 } else {
1281 edge->addChildElement(vaporizer);
1282 vaporizer->incRef("buildVaporizer");
1283 }
1284 return true;
1285 }
1286 }
1287}
1288
1289
1290bool
1291GNEAdditionalHandler::buildTAZ(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const PositionVector& shape,
1292 const Position& center, const bool fill, const RGBColor& color, const std::vector<std::string>& edgeIDs,
1293 const std::string& name, const Parameterised::Map& parameters) {
1294 // parse edges
1295 const std::vector<GNEEdge*> edges = parseEdges(SUMO_TAG_TAZ, id, edgeIDs);
1296 if (edges.size() != edgeIDs.size()) {
1297 return false;
1298 } else {
1299 // check TAZShape
1300 PositionVector TAZShape = shape;
1301 if (TAZShape.size() == 0) {
1302 // declare boundary
1303 Boundary TAZBoundary;
1304 for (const auto& edge : edges) {
1305 TAZBoundary.add(edge->getCenteringBoundary());
1306 }
1307 // iterate over children and add sourceSinkEdge boundaries to make a taz shape
1308 for (const auto& sourceSink : sumoBaseObject->getSumoBaseObjectChildren()) {
1309 // check that child is a source or sink elements (to avoid other elements)
1310 if ((sourceSink->getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTag() == SUMO_TAG_TAZSINK)) {
1311 const GNEEdge* sourceSinkEdge = myNet->getAttributeCarriers()->retrieveEdge(sourceSink->getStringAttribute(SUMO_ATTR_ID), false);
1312 if (sourceSinkEdge) {
1313 TAZBoundary.add(sourceSinkEdge->getCenteringBoundary());
1314 }
1315 }
1316 }
1317 // update TAZShape
1318 TAZShape = TAZBoundary.getShape(true);
1319 }
1320 // check TAZ
1321 const auto element = retrieveAdditionalElement({SUMO_TAG_TAZ}, id);
1322 if (!checkElement(SUMO_TAG_TAZ, element)) {
1323 return false;
1324 } else if (!checkValidAdditionalID(SUMO_TAG_TAZ, id)) {
1325 return false;
1326 } else if (TAZShape.size() == 0) {
1327 return writeError(TLF("Could not build TAZ with ID '%' in netedit; Invalid Shape.", id));
1328 } else {
1329 // build TAZ with the given shape
1330 const Position center2 = center == Position::INVALID ? TAZShape.getCentroid() : center;
1331 GNEAdditional* TAZ = new GNETAZ(id, myNet, myFilename, TAZShape, center2, fill, color, name, parameters);
1332 // disable updating geometry of TAZ children during insertion (because in large nets provokes slowdowns)
1334 // add it depending of allow undoRed
1335 if (myAllowUndoRedo) {
1336 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ '") + id + "'");
1337 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(TAZ, true), true);
1338 // create TAZEdges
1339 for (const auto& edge : edges) {
1340 // create TAZ Source using GNEChange_Additional
1341 GNETAZSourceSink* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1342 myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZSourceSink(TAZSource, true), true);
1343 // create TAZ Sink using GNEChange_Additional
1344 GNETAZSourceSink* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1345 myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZSourceSink(TAZSink, true), true);
1346 }
1348 } else {
1350 TAZ->incRef("buildTAZ");
1351 for (const auto& edge : edges) {
1352 // create TAZ Source
1353 GNETAZSourceSink* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, 1);
1355 TAZSource->incRef("buildTAZ");
1356 TAZ->addChildElement(TAZSource);
1357 edge->addChildElement(TAZSource);
1358 // create TAZ Sink
1359 GNETAZSourceSink* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, 1);
1361 TAZSink->incRef("buildTAZ");
1362 TAZ->addChildElement(TAZSink);
1363 edge->addChildElement(TAZSink);
1364 }
1365 }
1366 // enable updating geometry again and update geometry of TAZ
1368 // update TAZ parent
1369 TAZ->updateGeometry();
1370 return true;
1371 }
1372 }
1373}
1374
1375
1376bool
1377GNEAdditionalHandler::buildTAZSource(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double departWeight) {
1378 // get TAZ parent
1380 // get edge
1381 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1382 // check parents
1383 if (TAZ == nullptr) {
1385 } else if (edge == nullptr) {
1386 return writeErrorInvalidParent(SUMO_TAG_SOURCE, edgeID, SUMO_TAG_EDGE, TAZ->getID());
1387 } else {
1388 // declare TAZ Source
1389 GNETAZSourceSink* existentTAZSource = nullptr;
1390 // first check if already exist a TAZ Source for the given edge and TAZ
1391 for (auto it = edge->getChildTAZSourceSinks().begin(); (it != edge->getChildTAZSourceSinks().end()) && !existentTAZSource; it++) {
1392 if (((*it)->getTagProperty()->getTag() == SUMO_TAG_TAZSOURCE) && ((*it)->getParentAdditionals().front() == TAZ)) {
1393 existentTAZSource = (*it);
1394 }
1395 }
1396 // check if TAZSource has to be created
1397 if (existentTAZSource == nullptr) {
1398 // Create TAZ only with departWeight
1399 GNETAZSourceSink* TAZSource = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, TAZ, edge, departWeight);
1400 // add it depending of allow undoRed
1401 if (myAllowUndoRedo) {
1402 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Source in '") + TAZ->getID() + "'");
1403 myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZSourceSink(TAZSource, true), true);
1405 } else {
1407 TAZ->addChildElement(TAZSource);
1408 edge->addChildElement(TAZSource);
1409 TAZSource->incRef("buildTAZSource");
1410 }
1411 } else {
1412 // update TAZ Attribute depending of allow undoRed
1413 if (myAllowUndoRedo) {
1414 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Source in '") + TAZ->getID() + "'");
1415 existentTAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), myNet->getViewNet()->getUndoList());
1417 } else {
1418 existentTAZSource->setAttribute(SUMO_ATTR_WEIGHT, toString(departWeight), nullptr);
1419 }
1420 }
1421 return true;
1422 }
1423}
1424
1425
1426bool
1427GNEAdditionalHandler::buildTAZSink(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID, const double arrivalWeight) {
1428 // get TAZ parent
1430 // get edge
1431 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1432 // check parents
1433 if (TAZ == nullptr) {
1435 } else if (edge == nullptr) {
1436 return writeErrorInvalidParent(SUMO_TAG_SOURCE, edgeID, SUMO_TAG_EDGE, TAZ->getID());
1437 } else {
1438 // declare TAZ Sink
1439 GNETAZSourceSink* existentTAZSink = nullptr;
1440 // first check if already exist a TAZ Sink for the given edge and TAZ
1441 for (auto it = edge->getChildTAZSourceSinks().begin(); (it != edge->getChildTAZSourceSinks().end()) && !existentTAZSink; it++) {
1442 if (((*it)->getTagProperty()->getTag() == SUMO_TAG_TAZSINK) && ((*it)->getParentAdditionals().front() == TAZ)) {
1443 existentTAZSink = (*it);
1444 }
1445 }
1446 // check if TAZSink has to be created
1447 if (existentTAZSink == nullptr) {
1448 // Create TAZ only with departWeight
1449 GNETAZSourceSink* TAZSink = new GNETAZSourceSink(SUMO_TAG_TAZSINK, TAZ, edge, arrivalWeight);
1450 // add it depending of allow undoRed
1451 if (myAllowUndoRedo) {
1452 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("add TAZ Sink in '") + TAZ->getID() + "'");
1453 myNet->getViewNet()->getUndoList()->add(new GNEChange_TAZSourceSink(TAZSink, true), true);
1455 } else {
1457 TAZ->addChildElement(TAZSink);
1458 edge->addChildElement(TAZSink);
1459 TAZSink->incRef("buildTAZSink");
1460 }
1461 } else {
1462 // update TAZ Attribute depending of allow undoRed
1463 if (myAllowUndoRedo) {
1464 myNet->getViewNet()->getUndoList()->begin(TAZ, TL("update TAZ Sink in '") + TAZ->getID() + "'");
1465 existentTAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), myNet->getViewNet()->getUndoList());
1467 } else {
1468 existentTAZSink->setAttribute(SUMO_ATTR_WEIGHT, toString(arrivalWeight), nullptr);
1469 }
1470 }
1471 return true;
1472 }
1473}
1474
1475
1476bool
1477GNEAdditionalHandler::buildTractionSubstation(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const Position& pos,
1478 const double voltage, const double currentLimit, const Parameterised::Map& parameters) {
1479 // check conditions
1480 const auto element = retrieveAdditionalElement({SUMO_TAG_TRACTION_SUBSTATION}, id);
1482 return false;
1484 return false;
1485 } else if (!checkNegative(SUMO_TAG_TRACTION_SUBSTATION, id, SUMO_ATTR_VOLTAGE, voltage, true)) {
1486 return false;
1487 } else if (!checkNegative(SUMO_TAG_TRACTION_SUBSTATION, id, SUMO_ATTR_CURRENTLIMIT, currentLimit, true)) {
1488 return false;
1489 } else {
1490 // build traction substation
1491 GNEAdditional* tractionSubstation = new GNETractionSubstation(id, myNet, myFilename, pos, voltage, currentLimit, parameters);
1492 // insert depending of allowUndoRedo
1493 if (myAllowUndoRedo) {
1494 myNet->getViewNet()->getUndoList()->begin(tractionSubstation, TL("add traction substation '") + id + "'");
1495 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(tractionSubstation, true), true);
1497 } else {
1498 myNet->getAttributeCarriers()->insertAdditional(tractionSubstation);
1499 tractionSubstation->incRef("buildTractionSubstation");
1500 }
1501 return true;
1502 }
1503}
1504
1505
1506bool
1507GNEAdditionalHandler::buildOverheadWire(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& substationId,
1508 const std::vector<std::string>& laneIDs, const double startPos, const double endPos, const bool friendlyPos,
1509 const std::vector<std::string>& forbiddenInnerLanes, const Parameterised::Map& parameters) {
1510 // check conditions
1513 return false;
1515 return false;
1516 } else {
1517 // get lanes
1518 const auto lanes = parseLanes(SUMO_TAG_OVERHEAD_WIRE_SECTION, id, laneIDs);
1519 // get traction substation
1520 const auto tractionSubstation = myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, substationId, false);
1521 // check lanes
1522 if (lanes.empty()) {
1523 return false;
1524 } else {
1525 // calculate path
1527 return writeError(TLF("Could not build overhead wire with ID '%' in netedit; Lanes aren't consecutives.", id));
1528 } else if (!checkMultiLanePosition(
1529 startPos, lanes.front()->getParentEdge()->getNBEdge()->getFinalLength(),
1530 endPos, lanes.back()->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1532 } else if (tractionSubstation == nullptr) {
1534 } else {
1535 // build Overhead Wire
1536 GNEAdditional* overheadWire = new GNEOverheadWire(id, myNet, myFilename, lanes, tractionSubstation, startPos, endPos, friendlyPos, forbiddenInnerLanes, parameters);
1537 // insert depending of allowUndoRedo
1538 if (myAllowUndoRedo) {
1539 myNet->getViewNet()->getUndoList()->begin(overheadWire, TL("add overhead wire '") + id + "'");
1540 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(overheadWire, true), true);
1542 } else {
1544 for (const auto& lane : lanes) {
1545 lane->addChildElement(overheadWire);
1546 }
1547 overheadWire->incRef("buildOverheadWire");
1548 }
1549 }
1550 return true;
1551 }
1552 }
1553}
1554
1555
1556bool
1557GNEAdditionalHandler::buildOverheadWireClamp(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& /* id */, const std::string& /* overheadWireIDStartClamp */,
1558 const std::string& /* laneIDStartClamp */, const std::string& /* overheadWireIDEndClamp */, const std::string& /* laneIDEndClamp */,
1559 const Parameterised::Map& /* parameters */) {
1560 //
1561 return false;
1562}
1563
1564
1565bool
1566GNEAdditionalHandler::buildPolygon(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const std::string& type,
1567 const RGBColor& color, double layer, double angle, const std::string& imgFile, const PositionVector& shape,
1568 bool geo, bool fill, double lineWidth, const std::string& name, const Parameterised::Map& parameters) {
1569 // check conditions
1570 if (type == "jupedsim.walkable_area") {
1571 return buildJpsWalkableArea(sumoBaseObject, id, shape, geo, name, parameters);
1572 } else if (type == "jupedsim.obstacle") {
1573 return buildJpsObstacle(sumoBaseObject, id, shape, geo, name, parameters);
1574 } else {
1575 // check conditions
1576 const auto element = retrieveAdditionalElement(NamespaceIDs::polygons, id);
1577 if (!checkElement(SUMO_TAG_POLY, element)) {
1578 return false;
1579 } else if (!checkValidAdditionalID(SUMO_TAG_POLY, id)) {
1580 return false;
1581 } else if (!checkNegative(SUMO_TAG_POLY, id, SUMO_ATTR_LINEWIDTH, lineWidth, true)) {
1582 return false;
1583 } else {
1584 // create poly
1585 GNEPoly* poly = new GNEPoly(id, myNet, myFilename, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, name, parameters);
1586 // add it depending of allow undoRed
1587 if (myAllowUndoRedo) {
1588 myNet->getViewNet()->getUndoList()->begin(poly, TL("add polygon '") + id + "'");
1589 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(poly, true), true);
1591 } else {
1592 // insert shape without allowing undo/redo
1594 poly->incRef("addPolygon");
1595 }
1596 return true;
1597 }
1598 }
1599}
1600
1601
1602bool
1603GNEAdditionalHandler::buildPOI(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& type,
1604 const RGBColor& color, const double x, const double y, const std::string& icon, double layer, double angle,
1605 const std::string& imgFile, double width, double height, const std::string& name, const Parameterised::Map& parameters) {
1606 // check conditions
1607 const auto element = retrieveAdditionalElement(NamespaceIDs::POIs, id);
1608 if (!checkElement(SUMO_TAG_POI, element)) {
1609 return false;
1610 } else if (!checkValidAdditionalID(SUMO_TAG_POI, id)) {
1611 return false;
1612 } else if (!checkNegative(SUMO_TAG_POI, id, SUMO_ATTR_WIDTH, width, true)) {
1613 return false;
1614 } else if (!checkNegative(SUMO_TAG_POI, id, SUMO_ATTR_HEIGHT, height, true)) {
1615 return false;
1616 } else if (!checkFileName(SUMO_TAG_POI, id, SUMO_ATTR_IMGFILE, imgFile)) {
1617 return false;
1618 } else {
1619 // create POI
1620 GNEPOI* POI = new GNEPOI(id, myNet, myFilename, type, color, x, y, false, icon, layer, angle, imgFile, width, height, name, parameters);
1621 // add it depending of allow undoRed
1622 if (myAllowUndoRedo) {
1623 myNet->getViewNet()->getUndoList()->begin(POI, TL("add POI '") + id + "'");
1624 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POI, true), true);
1626 } else {
1627 // insert shape without allowing undo/redo
1629 POI->incRef("addPOI");
1630 }
1631 return true;
1632 }
1633}
1634
1635
1636bool
1637GNEAdditionalHandler::buildPOILane(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& type,
1638 const RGBColor& color, const std::string& laneID, double posOverLane, const bool friendlyPos, double posLat,
1639 const std::string& icon, double layer, double angle, const std::string& imgFile, double width, double height,
1640 const std::string& name, const Parameterised::Map& parameters) {
1641 // check conditions
1642 const auto element = retrieveAdditionalElement(NamespaceIDs::POIs, id);
1643 if (!checkElement(GNE_TAG_POILANE, element)) {
1644 return false;
1645 } else if (!checkValidAdditionalID(GNE_TAG_POILANE, id)) {
1646 return false;
1647 } else if (!checkNegative(GNE_TAG_POILANE, id, SUMO_ATTR_WIDTH, width, true)) {
1648 return false;
1649 } else if (!checkNegative(GNE_TAG_POILANE, id, SUMO_ATTR_HEIGHT, height, true)) {
1650 return false;
1651 } else if (!checkFileName(GNE_TAG_POILANE, id, SUMO_ATTR_IMGFILE, imgFile)) {
1652 return false;
1653 } else {
1654 // get lane
1655 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
1656 // check lane
1657 if (lane == nullptr) {
1659 } else if (!checkLanePosition(posOverLane, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos)) {
1661 } else {
1662 // create POI (use GNEAdditional instead GNEPOI for add child references)
1663 GNEAdditional* POILane = new GNEPOI(id, myNet, myFilename, type, color, lane, posOverLane, friendlyPos, posLat, icon, layer,
1664 angle, imgFile, width, height, name, parameters);
1665 // add it depending of allow undoRed
1666 if (myAllowUndoRedo) {
1667 myNet->getViewNet()->getUndoList()->begin(POILane, TL("add POI '") + id + "'");
1668 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POILane, true), true);
1670 } else {
1671 // insert shape without allowing undo/redo
1673 lane->addChildElement(POILane);
1674 POILane->incRef("buildPOILane");
1675 }
1676 }
1677 return true;
1678 }
1679}
1680
1681
1682bool
1683GNEAdditionalHandler::buildPOIGeo(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const std::string& type,
1684 const RGBColor& color, const double lon, const double lat, const std::string& icon, double layer,
1685 double angle, const std::string& imgFile, double width, double height, const std::string& name,
1686 const Parameterised::Map& parameters) {
1687 // check conditions
1688 const auto element = retrieveAdditionalElement(NamespaceIDs::POIs, id);
1689 if (!checkElement(GNE_TAG_POIGEO, element)) {
1690 return false;
1691 } else if (!checkValidAdditionalID(GNE_TAG_POIGEO, id)) {
1692 return false;
1693 } else if (!checkNegative(GNE_TAG_POIGEO, id, SUMO_ATTR_WIDTH, width, true)) {
1694 return false;
1695 } else if (!checkNegative(GNE_TAG_POIGEO, id, SUMO_ATTR_HEIGHT, height, true)) {
1696 return false;
1697 } else if (!checkFileName(GNE_TAG_POIGEO, id, SUMO_ATTR_IMGFILE, imgFile)) {
1698 return false;
1699 } else if (GeoConvHelper::getFinal().getProjString() == "!") {
1700 return writeError(TLF("Could not build POI with ID '%' in netedit", id) + std::string("; ") + TL("Network requires a geo projection."));
1701 } else {
1702 // create POIGEO
1703 GNEPOI* POIGEO = new GNEPOI(id, myNet, myFilename, type, color, lon, lat, true, icon, layer, angle, imgFile, width, height, name, parameters);
1704 // add it depending of allow undoRed
1705 if (myAllowUndoRedo) {
1706 myNet->getViewNet()->getUndoList()->begin(POIGEO, TL("add POI '") + id + "'");
1707 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(POIGEO, true), true);
1709 } else {
1710 // insert shape without allowing undo/redo
1712 POIGEO->incRef("buildPOIGeo");
1713 }
1714 return true;
1715 }
1716}
1717
1718
1719bool
1720GNEAdditionalHandler::buildJpsWalkableArea(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const PositionVector& shape,
1721 bool geo, const std::string& name, const Parameterised::Map& parameters) {
1722 // check conditions
1723 const auto element = retrieveAdditionalElement(NamespaceIDs::polygons, id);
1724 if (!checkElement(GNE_TAG_JPS_WALKABLEAREA, element)) {
1725 return false;
1727 return false;
1728 } else {
1729 // create walkable area
1730 GNEPoly* walkableArea = new GNEPoly(GNE_TAG_JPS_WALKABLEAREA, id, myNet, myFilename, shape, geo, name, parameters);
1731 // add it depending of allow undoRed
1732 if (myAllowUndoRedo) {
1733 myNet->getViewNet()->getUndoList()->begin(walkableArea, TL("add jps walkable area '") + id + "'");
1734 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(walkableArea, true), true);
1736 } else {
1737 // insert shape without allowing undo/redo
1739 walkableArea->incRef("addWalkableArea");
1740 }
1741 return true;
1742 }
1743}
1744
1745
1746bool
1747GNEAdditionalHandler::buildJpsObstacle(const CommonXMLStructure::SumoBaseObject* /*sumoBaseObject*/, const std::string& id, const PositionVector& shape,
1748 bool geo, const std::string& name, const Parameterised::Map& parameters) {
1749 // check conditions
1750 const auto element = retrieveAdditionalElement(NamespaceIDs::polygons, id);
1751 if (!checkElement(GNE_TAG_JPS_OBSTACLE, element)) {
1752 return false;
1754 return false;
1755 } else {
1756 // create walkable area
1757 GNEPoly* obstacle = new GNEPoly(GNE_TAG_JPS_OBSTACLE, id, myNet, myFilename, shape, geo, name, parameters);
1758 // add it depending of allow undoRed
1759 if (myAllowUndoRedo) {
1760 myNet->getViewNet()->getUndoList()->begin(obstacle, TL("add jps obstacle '") + id + "'");
1761 myNet->getViewNet()->getUndoList()->add(new GNEChange_Additional(obstacle, true), true);
1763 } else {
1764 // insert shape without allowing undo/redo
1766 obstacle->incRef("addObstacle");
1767 }
1768 return true;
1769 }
1770}
1771
1772
1773bool
1775 // check if exist another access for the same busStop in the given edge
1776 for (const auto& additional : busStopParent->getChildAdditionals()) {
1777 for (const auto& lane : edge->getChildLanes()) {
1778 if (additional->getAttribute(SUMO_ATTR_LANE) == lane->getID()) {
1779 return false;
1780 }
1781 }
1782 }
1783 return true;
1784}
1785
1786
1787bool
1789 // declare a vector to keep sorted rerouter children
1790 std::vector<std::pair<SUMOTime, SUMOTime>> sortedIntervals;
1791 // iterate over child additional
1792 for (const auto& rerouterChild : rerouter->getChildAdditionals()) {
1793 if (!rerouterChild->getTagProperty()->isSymbol()) {
1794 sortedIntervals.push_back(std::make_pair((SUMOTime)0., (SUMOTime)0.));
1795 // set begin and end
1796 sortedIntervals.back().first = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_BEGIN));
1797 sortedIntervals.back().second = TIME2STEPS(rerouterChild->getAttributeDouble(SUMO_ATTR_END));
1798 }
1799 }
1800 // add new intervals
1801 sortedIntervals.push_back(std::make_pair(newBegin, newEnd));
1802 // sort children
1803 std::sort(sortedIntervals.begin(), sortedIntervals.end());
1804 // check overlapping after sorting
1805 for (int i = 0; i < (int)sortedIntervals.size() - 1; i++) {
1806 if (sortedIntervals.at(i).second > sortedIntervals.at(i + 1).first) {
1807 return false;
1808 }
1809 }
1810 return true;
1811}
1812
1813
1814bool
1815GNEAdditionalHandler::checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos) {
1816 if (friendlyPos) {
1817 return true;
1818 }
1819 // adjust from and to (negative means that start at the end of lane and count backward)
1820 if (pos < 0) {
1821 pos += laneLength;
1822 }
1823 // check extremes
1824 if ((pos < 0) || (pos > laneLength)) {
1825 return false;
1826 }
1827 // check pos + length
1828 if ((pos + length) > laneLength) {
1829 return false;
1830 }
1831 // all OK
1832 return true;
1833}
1834
1835
1836void
1837GNEAdditionalHandler::fixLanePosition(double& pos, double& length, const double laneLength) {
1838 // negative pos means that start at the end of lane and count backward)
1839 if (pos < 0) {
1840 pos += laneLength;
1841 }
1842 // set position at the start
1843 if (pos < 0) {
1844 pos = 0;
1845 }
1846 // adjust pos
1847 if (pos >= laneLength) {
1848 pos = (laneLength - POSITION_EPS);
1849 }
1850 // adjust length
1851 if ((length < 0) || ((pos + length) > laneLength)) {
1852 length = POSITION_EPS;
1853 }
1854}
1855
1856
1857bool
1858GNEAdditionalHandler::checkFriendlyPosSmallLanes(double pos, const double length, const double laneLength, const bool friendlyPos) {
1859 if (friendlyPos == true) {
1860 return true;
1861 } else if (OptionsCont::getOptions().getBool("e2.friendlyPos.automatic")) {
1862 // adjust from and to (negative means that start at the end of lane and count backward)
1863 if (pos < 0) {
1864 pos += laneLength;
1865 }
1866 // check extremes
1867 if ((pos < 0) || (pos > laneLength)) {
1868 return true;
1869 }
1870 // check pos + length
1871 if ((pos + length) > laneLength) {
1872 return true;
1873 }
1874 }
1875 return false;
1876}
1877
1878
1879bool
1880GNEAdditionalHandler::checkLaneDoublePosition(double from, double to, const double laneLength, const bool friendlyPos) {
1881 if (friendlyPos) {
1882 return true;
1883 }
1884 // adjust from and to (negative means that start at the end of lane and count backward)
1885 if (from == INVALID_DOUBLE) {
1886 from = 0;
1887 }
1888 if (to == INVALID_DOUBLE) {
1889 to = laneLength;
1890 }
1891 if (from < 0) {
1892 from += laneLength;
1893 }
1894 if (to < 0) {
1895 to += laneLength;
1896 }
1897 if ((to - from) < POSITION_EPS) {
1898 return false;
1899 }
1900 if ((from < 0) || (from > laneLength)) {
1901 return false;
1902 }
1903 if ((to < 0) || (to > laneLength)) {
1904 return false;
1905 }
1906 return true;
1907}
1908
1909
1910void
1911GNEAdditionalHandler::fixLaneDoublePosition(double& from, double& to, const double laneLength) {
1912 // adjust from (negative means that start at the end of lane and count backward)
1913 if (from == INVALID_DOUBLE) {
1914 from = 0;
1915 }
1916 if (to == INVALID_DOUBLE) {
1917 to = laneLength;
1918 }
1919 if (from < 0) {
1920 from += laneLength;
1921 }
1922 if (from < 0) {
1923 from = 0;
1924 } else if (from > laneLength) {
1925 from = laneLength;
1926 }
1927 // adjust to
1928 if (to < 0) {
1929 to += laneLength;
1930 }
1931 if (to < 0) {
1932 to = 0;
1933 } else if (to > laneLength) {
1934 to = laneLength;
1935 }
1936 // to has more priorty as from, and distance between from and to must be >= POSITION_EPS
1937 if ((to - from) < POSITION_EPS) {
1938 if (to >= POSITION_EPS) {
1939 from = to - POSITION_EPS;
1940 } else {
1941 from = 0;
1942 to = POSITION_EPS;
1943 }
1944 }
1945}
1946
1947
1948bool
1949GNEAdditionalHandler::checkMultiLanePosition(double fromPos, const double fromLaneLength, const double toPos, const double tolaneLength, const bool friendlyPos) {
1950 if (friendlyPos) {
1951 return true;
1952 } else {
1953 return (checkLanePosition(fromPos, 0, fromLaneLength, false) && checkLanePosition(toPos, 0, tolaneLength, false));
1954 }
1955}
1956
1957
1958void
1959GNEAdditionalHandler::fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength) {
1960 double length = 0;
1961 fixLanePosition(fromPos, length, fromLaneLength);
1962 fixLanePosition(toPos, length, tolaneLength);
1963}
1964
1965
1968 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1969 return nullptr;
1970 } else if (!sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID)) {
1971 return nullptr;
1972 } else {
1974 }
1975}
1976
1977
1980 if (sumoBaseObject->getParentSumoBaseObject() == nullptr) {
1981 // parent interval doesn't exist
1982 return nullptr;
1983 } else if (sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject() == nullptr) {
1984 // rerouter parent doesn't exist
1985 return nullptr;
1986 } else if (!sumoBaseObject->getParentSumoBaseObject()->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) || // rerouter ID
1987 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_BEGIN) || // interval begin
1988 !sumoBaseObject->getParentSumoBaseObject()->hasTimeAttribute(SUMO_ATTR_END)) { // interval end
1989 return nullptr;
1990 } else {
1995 }
1996}
1997
1998
1999std::vector<GNEEdge*>
2000GNEAdditionalHandler::parseEdges(const SumoXMLTag tag, const std::string& id, const std::vector<std::string>& edgeIDs) {
2001 std::vector<GNEEdge*> edges;
2002 for (const auto& edgeID : edgeIDs) {
2003 GNEEdge* edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
2004 // empty edges aren't allowed. If edge is empty, write error, clear edges and stop
2005 if (edge == nullptr) {
2006 writeError(TLF("Could not build % with ID '%' in netedit; % with ID '%' doesn't exist.", toString(tag), id, toString(SUMO_TAG_EDGE), edgeID));
2007 edges.clear();
2008 return edges;
2009 } else {
2010 edges.push_back(edge);
2011 }
2012 }
2013 return edges;
2014}
2015
2016
2017std::vector<GNELane*>
2018GNEAdditionalHandler::parseLanes(const SumoXMLTag tag, const std::string& id, const std::vector<std::string>& laneIDs) {
2019 std::vector<GNELane*> lanes;
2020 for (const auto& laneID : laneIDs) {
2021 GNELane* lane = myNet->getAttributeCarriers()->retrieveLane(laneID, false);
2022 // empty lanes aren't allowed. If lane is empty, write error, clear lanes and stop
2023 if (lane == nullptr) {
2024 writeError(TLF("Could not build % with ID '%' in netedit; % with ID '%' doesn't exist.", toString(tag), id, toString(SUMO_TAG_LANE), laneID));
2025 lanes.clear();
2026 return lanes;
2027 } else {
2028 lanes.push_back(lane);
2029 }
2030 }
2031 return lanes;
2032}
2033
2034
2036GNEAdditionalHandler::retrieveAdditionalElement(const std::vector<SumoXMLTag> tags, const std::string& id) {
2037 for (const auto& tag : tags) {
2038 // retrieve additional element
2039 auto additionalElement = myNet->getAttributeCarriers()->retrieveAdditional(tag, id, false);
2040 if (additionalElement) {
2041 return additionalElement;
2042 }
2043 }
2044 return nullptr;
2045}
2046
2047
2048bool
2050 if (additionalElement) {
2052 writeWarningOverwritting(tag, additionalElement->getID());
2053 // delete element
2054 myNet->deleteAdditional(additionalElement, myNet->getViewNet()->getUndoList());
2055 // continue creating new element
2056 return true;
2057 } else {
2058 // write warning duplicated additional element
2059 return writeWarningDuplicated(tag, additionalElement->getID(), additionalElement->getTagProperty()->getTag());
2060 }
2061 } else {
2062 return true;
2063 }
2064}
2065
2066/****************************************************************************/
const unsigned char E3[]
Definition E3.cpp:22
long long int SUMOTime
Definition GUI.h:36
#define TL(string)
Definition MsgHandler.h:305
#define TLF(string,...)
Definition MsgHandler.h:307
#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
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_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_JAM_DIST_THRESHOLD
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_VOLTAGE
voltage of the traction substation [V]
@ 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:75
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:444
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 writeWarningDuplicated(const SumoXMLTag tag, const std::string &id, const SumoXMLTag checkedTag)
write warning duplicated element
void writeWarningOverwritting(const SumoXMLTag tag, const std::string &id)
write warning overwritting element
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"
const std::string myFilename
filename
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 hasBoolAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given bool 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
bool getBoolAttribute(const SumoXMLAttr attr) const
get bool attribute
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
GNEAdditional * retrieveAdditionalElement(const std::vector< SumoXMLTag > tags, const std::string &id)
get element by ID
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
static bool checkFriendlyPosSmallLanes(double pos, const double length, const double laneLength, const bool friendlyPos)
check if enable friendly pos in small lanes
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, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI using the given values.
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, const double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI in GEO coordinaten using the given values.
static bool 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 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 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 double width, const double height, const std::string &name, const Parameterised::Map &parameters)
Builds a POI over lane using the given values.
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
GNEAdditionalHandler()=delete
invalidate default constructo
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)
bool checkElement(const SumoXMLTag tag, GNEAdditional *additional)
check if element exist, and if overwritte
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 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 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
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 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.
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
virtual void updateGeometry()=0
update pre-computed geometry information
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
virtual Position getPositionInView() const =0
Returns position of additional in view.
const std::string getID() const
get ID (all Attribute Carriers have one)
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
static GNEBusStop * buildTrainStop(GNENet *net)
default constructor
static GNEBusStop * buildBusStop(GNENet *net)
default constructor
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:829
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:702
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
const GNEHierarchicalContainerChildrenSet< GNETAZSourceSink * > & getChildTAZSourceSinks() const
return child TAZSourceSinks (Set)
void addChildElement(ChildType *element)
add child without updating parent (ONLY used if we're creating elements without undo-redo)
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:208
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
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.
void insertTAZSourceSink(GNETAZSourceSink *sourceSink)
Insert a sourceSink element in container.
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
void 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:715
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition GNENet.cpp:2912
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:147
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
void enableUpdateGeometry()
Definition GNENet.cpp:2906
void incRef(const std::string &debugMsg="")
Increase reference.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
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...
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:4828
static const std::vector< SumoXMLTag > busStops
busStops namespace
static const std::vector< SumoXMLTag > laneAreaDetectors
lane area detectors namespace
static const std::vector< SumoXMLTag > POIs
POIs namespace.
static const std::vector< SumoXMLTag > calibrators
calibrators 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:319
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, bool extrapolateBeyond=false) 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 StringBijection< ChargeType > ChargeTypes
charge type
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element