Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNENet.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-2026 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// A visual container for GNE-network-components such as GNEEdge and GNEJunction.
19// GNE components wrap netbuild-components and supply visualisation and editing
20// capabilities (adapted from GUINet)
21//
22// WorkrouteFlow (rough draft)
23// use NILoader to fill
24// do netedit stuff
25// call compute to save results
26//
27/****************************************************************************/
28
60#include <netwrite/NWFrame.h>
69
71#include "GNENet.h"
72#include "GNEUndoList.h"
73#include "GNEViewParent.h"
74
75// ===========================================================================
76// FOX callback mapping
77// ===========================================================================
78
79FXIMPLEMENT_ABSTRACT(GNENetHelper::GNEChange_ReplaceEdgeInTLS, GNEChange, nullptr, 0)
80
81// ===========================================================================
82// static members
83// ===========================================================================
84const double GNENet::Z_INITIALIZED = 1;
85const std::map<SumoXMLAttr, std::string> GNENet::EMPTY_HEADER;
86
87
88// ===========================================================================
89// member method definitions
90// ===========================================================================
91#ifdef _MSC_VER
92#pragma warning(push)
93#pragma warning(disable: 4355) // mask warning about "this" in initializers
94#endif
95GNENet::GNENet(GNEApplicationWindow* applicationWindow, NBNetBuilder* netBuilder) :
96 GUIGlObject(GLO_NETWORK, "", nullptr),
97 myApplicationWindow(applicationWindow),
98 myNetBuilder(netBuilder),
99 myAttributeCarriers(new GNENetHelper::AttributeCarriers(this)),
100 myACTemplates(new GNENetHelper::ACTemplate(this)),
101 mySavingStatus(new GNENetHelper::SavingStatus(this)),
102 myNetworkPathManager(new GNEPathManager(this)),
103 myDemandPathManager(new GNEPathManager(this)),
104 myDataPathManager(new GNEPathManager(this)) {
105 // set net in gIDStorage
107 // build templates
109 // init junction and edges
111 // check Z boundary
112 if (myZBoundary.ymin() != Z_INITIALIZED) {
113 myZBoundary.add(0, 0);
114 }
115 // add default vTypes
117}
118#ifdef _MSC_VER
119#pragma warning(pop)
120#endif
121
122
124 // delete path managers
126 delete myDemandPathManager;
127 delete myDataPathManager;
128 // delete attribute carriers
129 delete myAttributeCarriers;
130 delete myACTemplates;
131 // delete saving status
132 delete mySavingStatus;
133 delete myNetBuilder;
134}
135
136
141
142
147
148
153
154
159
160
165
166
169 return myNetBuilder;
170}
171
172
177
178
181 return myACTemplates;
182}
183
184
187 return mySavingStatus;
188}
189
190
195
196
201
202
207
208
209const Boundary&
211 // SUMORTree is also a Boundary
212 return myGrid;
213}
214
215
218 return myGrid;
219}
220
221const std::map<std::string, int>&
225
226
229 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
230 buildPopupHeader(ret, app);
232 buildPositionCopyEntry(ret, app);
233 if (GeoConvHelper::getFinal().usingGeoProjection()) {
234 GUIDesigns::buildFXMenuCommand(ret, TL("Copy view geo-boundary to clipboard"), nullptr, ret, MID_COPY_VIEW_GEOBOUNDARY);
235 }
236 return ret;
237}
238
239
242 // Nets lanes don't have attributes
244 // close building
245 ret->closeBuilding();
246 return ret;
247}
248
249
250void
252 // draw boundaries
254}
255
256
259 return getBoundary();
260}
261
262
263void
264GNENet::expandBoundary(const Boundary& newBoundary) {
265 myGrid.add(newBoundary);
266}
267
268
269const Boundary&
271 return myZBoundary;
272}
273
274
275void
277 // @todo let Boundary class track z-coordinate natively
278 if (z != 0) {
280 }
281}
282
283
287 // get junction prefix
288 const std::string junctionPrefix = oc.getString("prefix") + oc.getString("node-prefix");
289 // generate new ID
290 while (myAttributeCarriers->getJunctions().count(junctionPrefix + toString(myJunctionIDCounter)) != 0) {
292 }
293 SumoXMLNodeType type = SUMOXMLDefinitions::NodeTypes.hasString(oc.getString("default.junctions.type"))
295 // create new NBNode
296 NBNode* nbn = new NBNode(junctionPrefix + toString(myJunctionIDCounter), pos, type);
297 GNEJunction* junction = new GNEJunction(this, nbn);
298 undoList->add(new GNEChange_Junction(junction, true), true);
299 return junction;
300}
301
302
303GNEEdge*
304GNENet::createEdge(GNEJunction* src, GNEJunction* dest, GNEEdge* edgeTemplate, GNEUndoList* undoList,
305 const std::string& suggestedName, bool wasSplit, bool allowDuplicateGeom, bool recomputeConnections) {
306 // prevent duplicate edge (same geometry)
307 for (const auto& outgoingEdge : src->getNBNode()->getOutgoingEdges()) {
308 if (outgoingEdge->getToNode() == dest->getNBNode() && outgoingEdge->getGeometry().size() == 2) {
309 if (!allowDuplicateGeom) {
310 return nullptr;
311 }
312 }
313 }
314 // check if exist opposite edge
315 const auto oppositeEdges = myAttributeCarriers->retrieveEdges(dest, src);
316 // get edge prefix
317 const std::string edgePrefix = OptionsCont::getOptions().getString("prefix") + OptionsCont::getOptions().getString("edge-prefix");
318 // get edge infix
319 std::string edgeInfix = OptionsCont::getOptions().getString("edge-infix");
320 // declare edge id
321 std::string edgeID;
322 // update id
323 if (oppositeEdges.size() > 0) {
324 // avoid ids with "--..."
325 if ((oppositeEdges.front()->getID().size() > 1) && (oppositeEdges.front()->getID().front() == '-')) {
326 edgeID = oppositeEdges.front()->getID().substr(1);
327 } else {
328 edgeID = "-" + oppositeEdges.front()->getID();
329 }
330 // check if already exist an edge with edgeID
331 if (myAttributeCarriers->getEdges().count(edgeID) > 0) {
332 int counter = 0;
333 // generate new ID using edgeID and counter
334 while (myAttributeCarriers->getEdges().count(edgeID + toString(counter)) > 0) {
335 counter++;
336 }
337 edgeID = edgeID + toString(counter);
338 }
339 } else if ((suggestedName.size() > 0) && (myAttributeCarriers->retrieveEdge(suggestedName, false) == nullptr)) {
340 edgeID = suggestedName;
341 } else if (edgeInfix.size() > 0) {
342 // permit empty infix by setting it to <SPACE>
343 edgeInfix = StringUtils::trim(edgeInfix);
344 // check if exist edge with id <fromNodeID><infix><toNodeID>
345 if (myAttributeCarriers->getEdges().count(src->getID() + edgeInfix + dest->getID()) == 0) {
346 edgeID = src->getID() + edgeInfix + dest->getID();
347 } else {
348 int counter = 0;
349 // generate new ID using edgeInfix and counter
350 while (myAttributeCarriers->getEdges().count(src->getID() + edgeInfix + toString(counter) + dest->getID()) != 0) {
352 }
353 edgeID = src->getID() + edgeInfix + toString(counter) + dest->getID();
354 }
355 } else {
357 }
358 GNEEdge* edge;
359 // check if there is a template edge
360 if (edgeTemplate) {
361 // create NBEdgeTemplate
362 NBEdge* nbe = new NBEdge(edgeID, src->getNBNode(), dest->getNBNode(), edgeTemplate->getNBEdge());
363 edge = new GNEEdge(this, nbe, wasSplit);
364 } else {
365 // default if no template is given
366 const auto& neteditOptions = OptionsCont::getOptions();
367 double defaultSpeed = neteditOptions.getFloat("default.speed");
368 const std::string defaultType = neteditOptions.getString("default.type");
369 const int defaultNrLanes = neteditOptions.getInt("default.lanenumber");
370 const int defaultPriority = neteditOptions.getInt("default.priority");
371 const double defaultWidth = NBEdge::UNSPECIFIED_WIDTH;
372 const double defaultOffset = NBEdge::UNSPECIFIED_OFFSET;
374 // build NBEdge
375 NBEdge* nbe = new NBEdge(edgeID, src->getNBNode(), dest->getNBNode(),
376 defaultType, defaultSpeed, NBEdge::UNSPECIFIED_FRICTION,
377 defaultNrLanes, defaultPriority,
378 defaultWidth, defaultOffset, spread);
379 // create edge
380 edge = new GNEEdge(this, nbe, wasSplit);
381 }
382 // add edge using undo list
383 undoList->begin(edge, TL("create edge"));
384 undoList->add(new GNEChange_Edge(edge, true), true);
385 // recompute connection
386 if (recomputeConnections) {
387 src->setLogicValid(false, undoList);
388 dest->setLogicValid(false, undoList);
389 }
391 undoList->end();
392 return edge;
393}
394
395
396void
398 if (networkElement->getTagProperty()->getTag() == SUMO_TAG_JUNCTION) {
399 // get junction (note: could be already removed if is a child, then hardfail=false)
400 GNEJunction* junction = myAttributeCarriers->retrieveJunction(networkElement->getID(), false);
401 // if exist, remove it
402 if (junction) {
403 deleteJunction(junction, undoList);
404 }
405 } else if (networkElement->getTagProperty()->getTag() == SUMO_TAG_CROSSING) {
406 // get crossing (note: could be already removed if is a child, then hardfail=false)
407 GNECrossing* crossing = myAttributeCarriers->retrieveCrossing(networkElement->getGUIGlObject(), false);
408 // if exist, remove it
409 if (crossing) {
410 deleteCrossing(crossing, undoList);
411 }
412 } else if (networkElement->getTagProperty()->getTag() == SUMO_TAG_EDGE) {
413 // get edge (note: could be already removed if is a child, then hardfail=false)
414 GNEEdge* edge = myAttributeCarriers->retrieveEdge(networkElement->getID(), false);
415 // if exist, remove it
416 if (edge) {
417 deleteEdge(edge, undoList, false);
418 }
419 } else if (networkElement->getTagProperty()->getTag() == SUMO_TAG_LANE) {
420 // get lane (note: could be already removed if is a child, then hardfail=false)
421 GNELane* lane = myAttributeCarriers->retrieveLane(networkElement->getGUIGlObject(), false);
422 // if exist, remove it
423 if (lane) {
424 deleteLane(lane, undoList, false);
425 }
426 } else if (networkElement->getTagProperty()->getTag() == SUMO_TAG_CONNECTION) {
427 // get connection (note: could be already removed if is a child, then hardfail=false)
428 GNEConnection* connection = myAttributeCarriers->retrieveConnection(networkElement->getGUIGlObject(), false);
429 // if exist, remove it
430 if (connection) {
431 deleteConnection(connection, undoList);
432 }
433 }
434}
435
436
437void
439 // we have to delete all incident edges because they cannot exist without that junction
440 // all deletions must be undone/redone together so we start a new command group
441 // @todo if any of those edges are dead-ends should we remove their orphan junctions as well?
442 undoList->begin(GUIIcon::MODEDELETE, TL("delete junction"));
443 // invalidate junction path elements
447 // delete junction child demand elements
448 while (junction->getChildDemandElements().size() > 0) {
449 deleteDemandElement(junction->getChildDemandElements().front(), undoList);
450 }
451 // delete all crossings vinculated with junction
452 while (junction->getGNECrossings().size() > 0) {
453 deleteCrossing(junction->getGNECrossings().front(), undoList);
454 }
455 // find all crossings of neighbour junctions that shares an edge of this junction
456 std::vector<GNECrossing*> crossingsToRemove;
457 std::vector<GNEJunction*> junctionNeighbours = junction->getJunctionNeighbours();
458 for (const auto& junctionNeighbour : junctionNeighbours) {
459 // iterate over crossing of neighbour junction
460 for (const auto& crossing : junctionNeighbour->getGNECrossings()) {
461 // if at least one of the edges of junction to remove belongs to a crossing of the neighbour junction, delete it
462 if (crossing->checkEdgeBelong(junction->getChildEdges())) {
463 crossingsToRemove.push_back(crossing);
464 }
465 }
466 }
467 // delete collected crossings
468 for (const auto& crossing : crossingsToRemove) {
469 deleteCrossing(crossing, undoList);
470 }
471 // deleting edges changes in the underlying EdgeVector so we have to make a copy
472 const EdgeVector incidentEdges = junction->getNBNode()->getEdges();
473 for (const auto& edge : incidentEdges) {
474 deleteEdge(myAttributeCarriers->getEdges().at(edge->getID()), undoList, true);
475 }
476 // remove any traffic lights from the traffic light container (avoids lots of warnings)
478 // delete edge
479 undoList->add(new GNEChange_Junction(junction, false), true);
480 undoList->end();
481}
482
483
484void
485GNENet::deleteEdge(GNEEdge* edge, GNEUndoList* undoList, bool recomputeConnections) {
486 undoList->begin(GUIIcon::MODEDELETE, TL("delete edge"));
487 // iterate over lanes
488 for (const auto& lane : edge->getChildLanes()) {
489 // invalidate lane path elements
493 // delete lane additionals
494 while (lane->getChildAdditionals().size() > 0) {
495 deleteAdditional(lane->getChildAdditionals().front(), undoList);
496 }
497 // delete lane demand elements
498 while (lane->getChildDemandElements().size() > 0) {
499 deleteDemandElement(lane->getChildDemandElements().front(), undoList);
500 }
501 // delete lane generic data elements
502 while (lane->getChildGenericDatas().size() > 0) {
503 deleteGenericData(lane->getChildGenericDatas().front(), undoList);
504 }
505 }
506 // delete edge child additionals
507 while (edge->getChildAdditionals().size() > 0) {
508 deleteAdditional(edge->getChildAdditionals().front(), undoList);
509 }
510 // delete TAZSourceSink children
511 while (edge->getChildTAZSourceSinks().size() > 0) {
512 deleteTAZSourceSink(*edge->getChildTAZSourceSinks().begin(), undoList);
513 }
514 // delete edge child demand elements
515 while (edge->getChildDemandElements().size() > 0) {
516 // special case for embedded routes
517 if (edge->getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
518 deleteDemandElement(edge->getChildDemandElements().front()->getParentDemandElements().front(), undoList);
519 } else if (edge->getChildDemandElements().front()->getTagProperty()->isPlan()) {
520 const auto planParent = edge->getChildDemandElements().front()->getParentDemandElements().front();
521 // if this is the last person child, remove plan parent (person/container) instead plan element
522 if (planParent->getChildDemandElements().size() == 1) {
523 deleteDemandElement(planParent, undoList);
524 } else {
525 deleteDemandElement(edge->getChildDemandElements().front(), undoList);
526 }
527 } else {
528 deleteDemandElement(edge->getChildDemandElements().front(), undoList);
529 }
530 }
531 // delete edge child generic datas
532 while (edge->getChildGenericDatas().size() > 0) {
533 deleteGenericData(edge->getChildGenericDatas().front(), undoList);
534 }
535 // remove edge from crossings related with this edge
536 edge->getFromJunction()->removeEdgeFromCrossings(edge, undoList);
537 edge->getToJunction()->removeEdgeFromCrossings(edge, undoList);
538 // update affected connections
539 if (recomputeConnections) {
540 edge->getFromJunction()->setLogicValid(false, undoList);
541 edge->getToJunction()->setLogicValid(false, undoList);
542 } else {
543 edge->getFromJunction()->removeConnectionsTo(edge, undoList, true);
544 edge->getToJunction()->removeConnectionsFrom(edge, undoList, true);
545 }
546 // if junction source is a TLS and after deletion will have only an edge, remove TLS
547 if (edge->getFromJunction()->getNBNode()->isTLControlled() && (edge->getFromJunction()->getGNEOutgoingEdges().size() <= 1)) {
549 }
550 // if junction destination is a TLS and after deletion will have only an edge, remove TLS
551 if (edge->getToJunction()->getNBNode()->isTLControlled() && (edge->getToJunction()->getGNEIncomingEdges().size() <= 1)) {
553 }
554 const std::string oppLaneID = edge->getChildLanes().back()->getAttribute(GNE_ATTR_OPPOSITE);
555 if (oppLaneID != "") {
556 GNELane* lane = myAttributeCarriers->retrieveLane(oppLaneID, false);
557 if (lane != nullptr) {
558 lane->setAttribute(GNE_ATTR_OPPOSITE, "", undoList);
559 }
560 }
561 // Delete edge
562 undoList->add(new GNEChange_Edge(edge, false), true);
563 // remove edge requires always a recompute (due geometry and connections)
565 // finish delete edge
566 undoList->end();
567}
568
569
570void
572 undoList->begin(which, TL("replace edge"));
574 // iterate over lane
575 for (const auto& lane : which->getChildLanes()) {
576 // replace in additionals
577 std::vector<GNEAdditional*> copyOfLaneAdditionals = lane->getChildAdditionals();
578 for (const auto& additional : copyOfLaneAdditionals) {
579 GNEChange_Attribute::changeAttribute(additional, SUMO_ATTR_LANE, by->getNBEdge()->getLaneID(lane->getIndex()), undoList);
580 if (additional->hasAttribute(SUMO_ATTR_STARTPOS)) {
582 toString(StringUtils::toDouble(additional->getAttribute(SUMO_ATTR_STARTPOS)) + which->getNBEdge()->getFinalLength()),
583 undoList);
584 }
585 if (additional->hasAttribute(SUMO_ATTR_ENDPOS)) {
587 toString(StringUtils::toDouble(additional->getAttribute(SUMO_ATTR_ENDPOS)) + which->getNBEdge()->getFinalLength()),
588 undoList);
589 }
590 }
591 // replace in demand elements
592 std::vector<GNEDemandElement*> copyOfLaneDemandElements = lane->getChildDemandElements();
593 for (const auto& demandElement : copyOfLaneDemandElements) {
594 GNEChange_Attribute::changeAttribute(demandElement, SUMO_ATTR_LANE, by->getNBEdge()->getLaneID(lane->getIndex()), undoList);
595 }
596 // replace in generic datas
597 std::vector<GNEGenericData*> copyOfLaneGenericDatas = lane->getChildGenericDatas();
598 for (const auto& demandElement : copyOfLaneGenericDatas) {
599 GNEChange_Attribute::changeAttribute(demandElement, SUMO_ATTR_LANE, by->getNBEdge()->getLaneID(lane->getIndex()), undoList);
600 }
601 }
602 // replace in edge additionals children
603 std::vector<GNEAdditional*> addElements = which->getChildAdditionals();
604 for (GNEAdditional* add : addElements) {
605 if (add->hasAttribute(SUMO_ATTR_EDGE)) {
607 }
608 }
609 // replace in edge demand elements children
610 const std::vector<GNEDemandElement*> demandElements = which->getChildDemandElements();
611 for (GNEDemandElement* demandElement : demandElements) {
612 if (demandElement->hasAttribute(SUMO_ATTR_EDGE)) {
613 GNEChange_Attribute::changeAttribute(demandElement, SUMO_ATTR_EDGE, by->getID(), undoList);
614 }
615 if (demandElement->hasAttribute(SUMO_ATTR_EDGES)) {
616 replaceInListAttribute(demandElement, SUMO_ATTR_EDGES, which->getID(), by->getID(), undoList);
617 }
618 if (demandElement->hasAttribute(SUMO_ATTR_VIA)) {
619 replaceInListAttribute(demandElement, SUMO_ATTR_VIA, which->getID(), by->getID(), undoList);
620 }
621 if (demandElement->hasAttribute(SUMO_ATTR_FROM) && demandElement->getAttribute(SUMO_ATTR_FROM) == which->getID()) {
622 GNEChange_Attribute::changeAttribute(demandElement, SUMO_ATTR_FROM, by->getID(), undoList);
623 }
624 if (demandElement->hasAttribute(SUMO_ATTR_TO) && demandElement->getAttribute(SUMO_ATTR_TO) == which->getID()) {
625 GNEChange_Attribute::changeAttribute(demandElement, SUMO_ATTR_TO, by->getID(), undoList);
626 }
627 }
628 // replace in data
629 const std::vector<GNEGenericData*> dataElements = which->getChildGenericDatas();
630 for (GNEGenericData* dataElement : dataElements) {
631 if (dataElement->hasAttribute(SUMO_ATTR_EDGE)) {
632 GNEChange_Attribute::changeAttribute(dataElement, SUMO_ATTR_EDGE, by->getID(), undoList);
633 }
634 }
635 // replace in rerouters
636 addElements = which->getParentAdditionals();
637 for (GNEAdditional* add : addElements) {
638 if (add->hasAttribute(SUMO_ATTR_EDGES)) {
639 replaceInListAttribute(add, SUMO_ATTR_EDGES, which->getID(), by->getID(), undoList);
640 }
641 }
642 // replace in crossings
643 for (const auto& crossing : which->getToJunction()->getGNECrossings()) {
644 // if at least one of the edges of junction to remove belongs to a crossing of the source junction, delete it
645 replaceInListAttribute(crossing, SUMO_ATTR_EDGES, which->getID(), by->getID(), undoList);
646 }
647 // fix connections (make a copy because they will be modified
648 std::vector<NBEdge::Connection> NBConnections = which->getNBEdge()->getConnections();
649 for (const auto& NBConnection : NBConnections) {
650 if (NBConnection.toEdge != nullptr) {
651 undoList->add(new GNEChange_Connection(which, NBConnection, false, false), true);
652 undoList->add(new GNEChange_Connection(by, NBConnection, false, true), true);
653 }
654 }
655 undoList->add(new GNENetHelper::GNEChange_ReplaceEdgeInTLS(getTLLogicCont(), which->getNBEdge(), by->getNBEdge()), true);
656 // Delete edge
657 undoList->add(new GNEChange_Edge(which, false), true);
658 // finish replace edge
659 undoList->end();
660}
661
662
663void
664GNENet::deleteLane(GNELane* lane, GNEUndoList* undoList, bool recomputeConnections) {
665 GNEEdge* edge = lane->getParentEdge();
666 if (edge->getNBEdge()->getNumLanes() == 1) {
667 // remove the whole edge instead
668 deleteEdge(edge, undoList, recomputeConnections);
669 } else {
670 undoList->begin(GUIIcon::MODEDELETE, TL("delete lane"));
671 // invalidate lane path elements
675 // delete lane additional children
676 while (lane->getChildAdditionals().size() > 0) {
677 deleteAdditional(lane->getChildAdditionals().front(), undoList);
678 }
679 // delete lane demand element children
680 while (lane->getChildDemandElements().size() > 0) {
681 deleteDemandElement(lane->getChildDemandElements().front(), undoList);
682 }
683 // delete lane generic data children
684 while (lane->getChildGenericDatas().size() > 0) {
685 deleteGenericData(lane->getChildGenericDatas().front(), undoList);
686 }
687 // update affected connections
688 if (recomputeConnections) {
689 edge->getFromJunction()->setLogicValid(false, undoList);
690 edge->getToJunction()->setLogicValid(false, undoList);
691 } else {
692 edge->getFromJunction()->removeConnectionsTo(edge, undoList, true, lane->getIndex());
693 edge->getToJunction()->removeConnectionsFrom(edge, undoList, true, lane->getIndex());
694 }
695 // delete lane
696 const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
697 undoList->add(new GNEChange_Lane(edge, lane, laneAttrs, false, recomputeConnections), true);
698 // remove lane requires always a recompute (due geometry and connections)
700 undoList->end();
701 }
702}
703
704
705void
707 undoList->begin(GUIIcon::MODEDELETE, TL("delete connection"));
708 // obtain NBConnection to remove
709 NBConnection deleted = connection->getNBConnection();
710 GNEJunction* junctionDestination = connection->getEdgeFrom()->getToJunction();
711 junctionDestination->markAsModified(undoList);
712 undoList->add(new GNEChange_Connection(connection->getEdgeFrom(), connection->getNBEdgeConnection(), connection->isAttributeCarrierSelected(), false), true);
713 junctionDestination->invalidateTLS(undoList, deleted);
714 // remove connection requires always a recompute (due geometry and connections)
716 undoList->end();
717}
718
719
720void
722 undoList->begin(GUIIcon::MODEDELETE, TL("delete crossing"));
723 // remove it using GNEChange_Crossing
724 undoList->add(new GNEChange_Crossing(
725 crossing->getParentJunctions().front(), crossing->getNBCrossing()->edges,
726 crossing->getNBCrossing()->width, crossing->getNBCrossing()->priority,
727 crossing->getNBCrossing()->customTLIndex,
728 crossing->getNBCrossing()->customTLIndex2,
729 crossing->getNBCrossing()->customShape,
730 crossing->isAttributeCarrierSelected(),
731 false), true);
732 // remove crossing requires always a recompute (due geometry and connections)
734 undoList->end();
735}
736
737
738void
740 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + additional->getTagStr());
741 // remove all demand element children
742 while (additional->getChildDemandElements().size() > 0) {
743 deleteDemandElement(additional->getChildDemandElements().front(), undoList);
744 }
745 // remove all generic data children
746 while (additional->getChildGenericDatas().size() > 0) {
747 deleteGenericData(additional->getChildGenericDatas().front(), undoList);
748 }
749 // remove all additional children
750 while (additional->getChildAdditionals().size() > 0) {
751 deleteAdditional(additional->getChildAdditionals().front(), undoList);
752 }
753 // remove all TAZSourceSinks children
754 while (additional->getChildTAZSourceSinks().size() > 0) {
755 deleteTAZSourceSink(*additional->getChildTAZSourceSinks().begin(), undoList);
756 }
757 // remove additional
758 undoList->add(new GNEChange_Additional(additional, false), true);
759 undoList->end();
760}
761
762
763void
765 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + TAZSourceSink->getTagStr());
766 // remove additional
767 undoList->add(new GNEChange_TAZSourceSink(TAZSourceSink, false), true);
768 undoList->end();
769}
770
771
772void
774 // check that default VTypes aren't removed
775 if ((demandElement->getTagProperty()->getTag() == SUMO_TAG_VTYPE) && (GNEAttributeCarrier::parse<bool>(demandElement->getAttribute(GNE_ATTR_DEFAULT_VTYPE)))) {
776 throw ProcessError(TL("Trying to delete a default Vehicle Type"));
777 } else {
778 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + demandElement->getTagStr());
779 // remove all child additional elements of this demandElement calling this function recursively
780 while (demandElement->getChildAdditionals().size() > 0) {
781 deleteAdditional(demandElement->getChildAdditionals().front(), undoList);
782 }
783 // remove all child demand elements of this demandElement calling this function recursively
784 while (demandElement->getChildDemandElements().size() > 0) {
785 deleteDemandElement(demandElement->getChildDemandElements().front(), undoList);
786 }
787 // remove all generic data children of this additional deleteGenericData this function recursively
788 while (demandElement->getChildGenericDatas().size() > 0) {
789 deleteGenericData(demandElement->getChildGenericDatas().front(), undoList);
790 }
791 // remove demandElement
792 undoList->add(new GNEChange_DemandElement(demandElement, false), true);
793 undoList->end();
794 }
795}
796
797
798void
800 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + dataSet->getTagStr());
801 // make a copy of all generic data children
802 auto copyOfDataIntervalChildren = dataSet->getDataIntervalChildren();
803 // clear all data intervals (this will be delete also the dataSet)
804 for (const auto& dataInterval : copyOfDataIntervalChildren) {
805 deleteDataInterval(dataInterval.second, undoList);
806 }
807 undoList->end();
808}
809
810
811void
813 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + dataInterval->getTagStr());
814 // make a copy of all generic data children
815 auto copyOfGenericDataChildren = dataInterval->getGenericDataChildren();
816 // clear all generic datas (this will be delete also the data intervals)
817 for (const auto& genericData : copyOfGenericDataChildren) {
818 deleteGenericData(genericData, undoList);
819 }
820 undoList->end();
821}
822
823
824void
826 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + genericData->getTagStr());
827 // remove all child demand elements of this demandElement calling this function recursively
828 while (genericData->getChildDemandElements().size() > 0) {
829 deleteDemandElement(genericData->getChildDemandElements().front(), undoList);
830 }
831 // remove all generic data children of this additional deleteGenericData this function recursively
832 while (genericData->getChildGenericDatas().size() > 0) {
833 deleteGenericData(genericData->getChildGenericDatas().front(), undoList);
834 }
835 // get pointer to dataInterval and dataSet
836 GNEDataInterval* dataInterval = genericData->getDataIntervalParent();
837 GNEDataSet* dataSet = dataInterval->getDataSetParent();
838 // remove generic data
839 undoList->add(new GNEChange_GenericData(genericData, false), true);
840 // check if data interval is empty
841 if (dataInterval->getGenericDataChildren().empty()) {
842 // remove data interval
843 undoList->add(new GNEChange_DataInterval(genericData->getDataIntervalParent(), false), true);
844 // now check if data set is empty
845 if (dataSet->getDataIntervalChildren().empty()) {
846 // remove data set
847 undoList->add(new GNEChange_DataSet(genericData->getDataIntervalParent()->getDataSetParent(), false), true);
848 }
849 }
850 undoList->end();
851}
852
853
854void
856 undoList->begin(GUIIcon::MODEDELETE, TL("delete ") + meanData->getTagStr());
857 // remove mean data
858 undoList->add(new GNEChange_MeanData(meanData, false), true);
859 undoList->end();
860}
861
862
863void
864GNENet::duplicateLane(GNELane* lane, GNEUndoList* undoList, bool recomputeConnections) {
865 undoList->begin(lane, TL("duplicate lane"));
866 GNEEdge* edge = lane->getParentEdge();
867 const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
868 if (recomputeConnections) {
869 edge->getFromJunction()->setLogicValid(false, undoList);
870 edge->getToJunction()->setLogicValid(false, undoList);
871 }
872 GNELane* newLane = new GNELane(edge, lane->getIndex());
873 undoList->add(new GNEChange_Lane(edge, newLane, laneAttrs, true, recomputeConnections), true);
875 undoList->end();
876}
877
878
879bool
881 bool addRestriction = true;
882 if (vclass == SVC_PEDESTRIAN) {
883 GNEEdge* edge = lane->getParentEdge();
884 for (const auto& edgeLane : edge->getChildLanes()) {
885 if (edgeLane->isRestricted(SVC_PEDESTRIAN)) {
886 // prevent adding a 2nd sidewalk
887 addRestriction = false;
888 } else {
889 // ensure that the sidewalk is used exclusively
890 const SVCPermissions allOldWithoutPeds = edge->getNBEdge()->getPermissions(edgeLane->getIndex()) & ~SVC_PEDESTRIAN;
891 edgeLane->setAttribute(SUMO_ATTR_ALLOW, getVehicleClassNames(allOldWithoutPeds), undoList);
892 }
893 }
894 }
895 // restrict the lane
896 if (addRestriction) {
897 double width;
898 if (vclass == SVC_PEDESTRIAN) {
899 width = OptionsCont::getOptions().getFloat("default.sidewalk-width");
900 } else if (vclass == SVC_BICYCLE) {
901 width = OptionsCont::getOptions().getFloat("default.bikelane-width");
902 } else {
903 width = OptionsCont::getOptions().getFloat("default.lanewidth");
904 }
905 lane->setAttribute(SUMO_ATTR_ALLOW, toString(vclass), undoList);
906 lane->setAttribute(SUMO_ATTR_WIDTH, toString(width), undoList);
907 if ((vclass & ~SVC_PEDESTRIAN) == 0) {
908 std::vector<GNEConnection*> cons;
910 if (reguess) {
911 // remove all connections and rebuild from scratch
912 cons = lane->getParentEdge()->getGNEConnections();
913 } else {
914 // remove connections that have become invalid (pedestrians are
915 // connected via walkingareas somewhere else)
916 cons = lane->getGNEOutcomingConnections();
917 }
918 for (auto c : cons) {
919 undoList->add(new GNEChange_Connection(lane->getParentEdge(), c->getNBEdgeConnection(), false, false), true);
920 }
921 if (reguess) {
923 }
924 }
925 return true;
926 } else {
927 return false;
928 }
929}
930
931
932bool
933GNENet::addRestrictedLane(SUMOVehicleClass vclass, GNEEdge* edge, int index, GNEUndoList* undoList) {
934 // First check that edge don't have a restricted lane of the given vclass
935 for (const auto& lane : edge->getChildLanes()) {
936 if (lane->isRestricted(vclass)) {
937 return false;
938 }
939 }
940 // check that index is correct (index == size adds to the left of the leftmost lane)
941 const int numLanes = (int)edge->getChildLanes().size();
942 if (index > numLanes) {
943 return false;
944 }
945 if (index < 0) {
946 // for pedestrians and greenVerge, always index 0
947 index = 0;
948 // guess index from vclass
949 if (vclass == SVC_BICYCLE) {
950 // add bikelanes to the left of an existing sidewalk
951 index = edge->getChildLanes()[0]->isRestricted(SVC_PEDESTRIAN) ? 1 : 0;
952 } else if (vclass == SVC_BUS) {
953 // add greenVerge to the left of an existing sidewalk or bikeLane
954 // add busLane to the left of an existing sidewalk, bikeLane or greenVerge
955 index = 0;
956 while (index < numLanes && (edge->getNBEdge()->getPermissions(index) & ~(SVC_PEDESTRIAN | SVC_BICYCLE)) == 0) {
957 index++;
958 }
959 }
960 }
961 // duplicate selected lane
962 duplicateLane(edge->getChildLanes().at(MIN2(index, numLanes - 1)), undoList, true);
963 // transform the created lane
964 return restrictLane(vclass, edge->getChildLanes().at(index), undoList);
965}
966
967
968bool
969GNENet::addGreenVergeLane(GNEEdge* edge, int index, GNEUndoList* undoList) {
970 // check that index is correct (index == size adds to the left of the leftmost lane)
971 const int numLanes = (int)edge->getChildLanes().size();
972 if (index > numLanes) {
973 index = numLanes;
974 }
975 if (index < 0) {
976 index = 0;
977 }
978 // duplicate selected lane
979 duplicateLane(edge->getChildLanes().at(MIN2(index, numLanes - 1)), undoList, true);
980 // transform the created lane
981 return restrictLane(SVC_IGNORING, edge->getChildLanes().at(index), undoList);
982}
983
984
985bool
987 // iterate over lanes of edge
988 for (const auto& lane : edge->getChildLanes()) {
989 if (lane->isRestricted(vclass)) {
990 // Delete lane
991 deleteLane(lane, undoList, true);
992 return true;
993 }
994 }
995 return false;
996}
997
998
999std::pair<GNEJunction*, GNEEdge*>
1000GNENet::splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction) {
1001 // begin undo list
1002 undoList->begin(edge, TL("split edge"));
1003 // check if we have to create a new edge
1004 if (newJunction == nullptr) {
1005 newJunction = createJunction(pos, undoList);
1006 }
1007 // obtain edge geometry and split position
1008 const PositionVector& oldEdgeGeometry = edge->getNBEdge()->getGeometry();
1009 const double edgeSplitPosition = oldEdgeGeometry.nearest_offset_to_point2D(pos, false);
1010 // obtain lane geometry and split position (needed for adjust additional and demand childs)
1011 const PositionVector& oldLaneGeometry = edge->getChildLanes().front()->getLaneShape();
1012 const double laneSplitPosition = oldLaneGeometry.nearest_offset_to_point2D(pos, false);
1013 // split edge geometry in two new geometries using edgeSplitPosition
1014 std::pair<PositionVector, PositionVector> newGeoms = oldEdgeGeometry.splitAt(edgeSplitPosition);
1015 const double oldLength = oldEdgeGeometry.length();
1016 const double relativeLength1 = oldLength != 0 ? newGeoms.first.length() / oldLength : 1;
1017 const double relativeLength2 = oldLength != 0 ? newGeoms.second.length() / oldLength : 1;
1018 // get shape end
1019 const std::string shapeEnd = edge->getAttribute(GNE_ATTR_SHAPE_END);
1020 // figure out the new name
1021 int posBase = 0;
1022 // set baseName
1023 std::string baseName = edge->getMicrosimID();
1024 if (edge->wasSplit()) {
1025 const std::string::size_type sep_index = baseName.rfind('.');
1026 // edge may have been renamed in between
1027 if (sep_index != std::string::npos) {
1028 std::string posString = baseName.substr(sep_index + 1);
1029 if (GNEAttributeCarrier::canParse<int>(posString.c_str())) {
1030 ;
1031 posBase = GNEAttributeCarrier::parse<int>(posString.c_str());
1032 baseName = baseName.substr(0, sep_index); // includes the .
1033 }
1034 }
1035 }
1036 baseName += '.';
1037 // create a new edge from the new junction to the previous destination
1038 GNEEdge* secondPart = createEdge(newJunction, edge->getToJunction(), edge,
1039 undoList, baseName + toString(posBase + (int)edgeSplitPosition), true, false, false);
1040 // fix connections from the split edge (must happen before changing SUMO_ATTR_TO)
1041 edge->getToJunction()->replaceIncomingConnections(edge, secondPart, undoList);
1042 // remove affected crossings from junction (must happen before changing SUMO_ATTR_TO)
1043 std::vector<NBNode::Crossing> affectedCrossings;
1044 for (GNECrossing* crossing : edge->getToJunction()->getGNECrossings()) {
1045 if (crossing->checkEdgeBelong(edge)) {
1046 NBNode::Crossing nbC = *crossing->getNBCrossing();
1047 undoList->add(new GNEChange_Crossing(edge->getToJunction(), nbC, false), true);
1048 EdgeVector newEdges;
1049 for (NBEdge* nbEdge : nbC.edges) {
1050 if (nbEdge == edge->getNBEdge()) {
1051 newEdges.push_back(secondPart->getNBEdge());
1052 } else {
1053 newEdges.push_back(nbEdge);
1054 }
1055 }
1056 nbC.edges = newEdges;
1057 affectedCrossings.push_back(nbC);
1058 }
1059 }
1060 // modify the edge so that it ends at the new junction (and all incoming connections are preserved
1061 GNEChange_Attribute::changeAttribute(edge, SUMO_ATTR_TO, newJunction->getID(), undoList);
1062 // set first part of geometry
1063 newGeoms.first.pop_back();
1064 newGeoms.first.erase(newGeoms.first.begin());
1065 edge->setAttribute(GNE_ATTR_SHAPE_END, "", undoList);
1066 edge->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.first), undoList);
1067 // set second part of geometry
1068 secondPart->setAttribute(GNE_ATTR_SHAPE_END, shapeEnd, undoList);
1069 newGeoms.second.pop_back();
1070 newGeoms.second.erase(newGeoms.second.begin());
1071 secondPart->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.second), undoList);
1072 // fix custom length
1073 if (edge->getNBEdge()->hasLoadedLength()) {
1074 // split in proportion to geometry lengths
1075 const double loadedLength = edge->getNBEdge()->getLoadedLength();
1076 edge->setAttribute(SUMO_ATTR_LENGTH, toString(relativeLength1 * loadedLength), undoList);
1077 secondPart->setAttribute(SUMO_ATTR_LENGTH, toString(relativeLength2 * loadedLength), undoList);
1078 }
1079 // reconnect across the split
1080 for (int i = 0; i < (int)edge->getChildLanes().size(); ++i) {
1081 undoList->add(new GNEChange_Connection(edge, NBEdge::Connection(i, secondPart->getNBEdge(), i), false, true), true);
1082 }
1083 // re-add modified crossings
1084 for (const auto& nbC : affectedCrossings) {
1085 undoList->add(new GNEChange_Crossing(secondPart->getToJunction(), nbC, true), true);
1086 }
1087 // Split geometry of all child additional
1088 auto childAdditionals = edge->getChildAdditionals();
1089 for (const auto& additional : childAdditionals) {
1090 additional->splitEdgeGeometry(edgeSplitPosition, edge, secondPart, undoList);
1091 }
1092 // Split geometry of all child lane additional
1093 for (int i = 0; i < (int)edge->getChildLanes().size(); i++) {
1094 for (const auto& additional : edge->getChildLanes().at(i)->getChildAdditionals()) {
1095 additional->splitEdgeGeometry(laneSplitPosition, edge->getChildLanes().at(i), secondPart->getChildLanes().at(i), undoList);
1096 }
1097 }
1098 // Split geometry of all child demand elements
1099 auto childDemandElements = edge->getChildDemandElements();
1100 for (const auto& demandElement : childDemandElements) {
1101 demandElement->splitEdgeGeometry(edgeSplitPosition, edge, secondPart, undoList);
1102 }
1103 // Split geometry of all child lane demand elements
1104 for (int i = 0; i < (int)edge->getChildLanes().size(); i++) {
1105 for (const auto& demandElement : edge->getChildLanes().at(i)->getChildDemandElements()) {
1106 demandElement->splitEdgeGeometry(laneSplitPosition, edge->getChildLanes().at(i), secondPart->getChildLanes().at(i), undoList);
1107 }
1108 }
1109 // finish undo list
1110 undoList->end();
1111 // return new junction
1112 return std::make_pair(newJunction, secondPart);
1113}
1114
1115
1116void
1117GNENet::splitEdgesBidi(GNEEdge* edge, GNEEdge* oppositeEdge, const Position& pos, GNEUndoList* undoList) {
1118 GNEJunction* newJunction = nullptr;
1119 undoList->begin(edge, TL("split edges"));
1120 // split edge and save created junction
1121 auto newStuff = splitEdge(edge, pos, undoList, newJunction);
1122 newJunction = newStuff.first;
1123 // split second edge
1124 splitEdge(oppositeEdge, pos, undoList, newJunction);
1125 if (edge->getChildLanes().back()->getAttribute(GNE_ATTR_OPPOSITE) != "") {
1126 // restore opposite lane information
1127 for (const auto& nbEdge : newJunction->getNBNode()->getEdges()) {
1128 GNEEdge* e = myAttributeCarriers->retrieveEdge(nbEdge->getID());
1129 // store old attribute before it's changed by guess opposite
1130 e->getChildLanes().back()->setAttribute(GNE_ATTR_OPPOSITE, "", undoList);
1131 if (nbEdge->guessOpposite(true)) {
1132 e->getChildLanes().back()->setAttribute(GNE_ATTR_OPPOSITE, nbEdge->getLanes().back().oppositeID, undoList);
1133 }
1134 }
1135 }
1136 undoList->end();
1137}
1138
1139
1140void
1142 undoList->begin(edge, TL("reverse edge"));
1143 auto fromJunction = edge->getFromJunction();
1144 auto ToJunction = edge->getToJunction();
1145 deleteEdge(edge, undoList, false); // still exists. we delete it so we can reuse the name in case of resplit
1146 GNEEdge* reversed = createEdge(ToJunction, fromJunction, edge, undoList, edge->getID(), false, true);
1147 if (reversed) {
1148 reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
1151 }
1152 undoList->end();
1153}
1154
1155
1156GNEEdge*
1157GNENet::addReversedEdge(GNEEdge* edge, const bool disconnected, GNEUndoList* undoList) {
1158 GNEEdge* reversed = edge->getReverseEdge();
1159 if (reversed != nullptr) {
1160 return reversed;
1161 }
1162 undoList->begin(edge, TL("add reversed edge"));
1163 if (!disconnected) {
1164 // for rail edges, we assume bi-directional tracks are wanted
1165 reversed = createEdge(edge->getToJunction(), edge->getFromJunction(), edge, undoList, "-" + edge->getID(), false, true);
1166 assert(reversed != 0);
1167 reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
1170 } else {
1171 // if the edge is centered it should probably connect somewhere else
1172 // make it easy to move and reconnect it
1173 PositionVector orig = edge->getNBEdge()->getGeometry();
1174 PositionVector origInner = edge->getNBEdge()->getInnerGeometry();
1175 const double tentativeShift = edge->getNBEdge()->getTotalWidth() + 2;
1176 orig.move2side(-tentativeShift);
1177 origInner.move2side(-tentativeShift);
1178 GNEJunction* src = createJunction(orig.back(), undoList);
1179 GNEJunction* dest = createJunction(orig.front(), undoList);
1180 reversed = createEdge(src, dest, edge, undoList, "-" + edge->getID(), false, true);
1181 assert(reversed != 0);
1182 reversed->setAttribute(SUMO_ATTR_SHAPE, toString(origInner.reverse()), undoList);
1183 reversed->setAttribute(SUMO_ATTR_SHAPE, toString(origInner.reverse()), undoList);
1184 // select the new edge and its nodes
1185 reversed->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1186 src->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1187 dest->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1188 }
1189 undoList->end();
1190 return reversed;
1191}
1192
1193
1194void
1196 undoList->begin(moved, TL("merge junctions"));
1197 // deleting edges changes in the underlying EdgeVector so we have to make a copy
1198 const EdgeVector incomingNBEdges = moved->getNBNode()->getIncomingEdges();
1199 for (const auto& incomingNBEdge : incomingNBEdges) {
1200 // delete edges between the merged junctions
1201 GNEEdge* edge = myAttributeCarriers->getEdges().at(incomingNBEdge->getID());
1202 if (edge->getFromJunction() == target) {
1203 deleteEdge(edge, undoList, false);
1204 } else {
1205 edge->setAttribute(SUMO_ATTR_TO, target->getID(), undoList);
1206 }
1207 }
1208 // deleting edges changes in the underlying EdgeVector so we have to make a copy
1209 const EdgeVector outgoingNBEdges = moved->getNBNode()->getOutgoingEdges();
1210 for (const auto& outgoingNBEdge : outgoingNBEdges) {
1211 // delete edges between the merged junctions
1212 GNEEdge* edge = myAttributeCarriers->getEdges().at(outgoingNBEdge->getID());
1213 if (edge->getToJunction() == target) {
1214 deleteEdge(edge, undoList, false);
1215 } else {
1216 edge->setAttribute(SUMO_ATTR_FROM, target->getID(), undoList);
1217 }
1218 }
1219 // deleted moved junction
1220 deleteJunction(moved, undoList);
1221 undoList->end();
1222}
1223
1224
1225void
1227 for (const EdgeSet& roundabout : myNetBuilder->getEdgeCont().getRoundabouts()) {
1228 for (NBEdge* edge : roundabout) {
1229 if (edge->getFromNode() == junction->getNBNode()) {
1230 undoList->begin(junction, TL("select roundabout"));
1231 for (const auto& roundaboutEdge : roundabout) {
1232 GNEEdge* e = myAttributeCarriers->retrieveEdge(roundaboutEdge->getID());
1233 e->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1234 e->getToJunction()->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1235 }
1236 undoList->end();
1237 return;
1238 }
1239 }
1240 }
1241}
1242
1243
1244void
1246 undoList->begin(junction, TL("create roundabout"));
1247 // reset shape end from incoming edges
1248 for (const auto& incomingEdge : junction->getGNEIncomingEdges()) {
1249 incomingEdge->setAttribute(GNE_ATTR_SHAPE_END, "", undoList);
1250 }
1251 // reset shape start from outgoing edges
1252 for (const auto& outgoingEdge : junction->getGNEOutgoingEdges()) {
1253 outgoingEdge->setAttribute(GNE_ATTR_SHAPE_START, "", undoList);
1254 }
1255 junction->getNBNode()->updateSurroundingGeometry();
1256 double radius = junction->getNBNode()->getRadius();
1257 if (radius == NBNode::UNSPECIFIED_RADIUS) {
1258 radius = OptionsCont::getOptions().getFloat("default.junctions.radius");
1259 }
1260 std::vector<GNEEdge*> edges;
1261 // use clockwise sorting
1262 for (const auto& nbEdge : junction->getNBNode()->getEdges()) {
1263 edges.push_back(myAttributeCarriers->retrieveEdge(nbEdge->getID()));
1264 }
1265 const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
1266 if (lefthand) {
1267 std::reverse(edges.begin(), edges.end());
1268 }
1269 const double lefthandSign = lefthand ? -1 : 1;
1270 std::vector<GNEJunction*> newJunctions;
1271 GNEEdge* templateEdge = nullptr;
1272 GNEEdge* prevOpposite = nullptr;
1273 // store old crossings edges as ids because edges are renamed and pointers will be invalid
1274 std::vector<std::pair<NBNode::Crossing, std::vector<std::string>>> oldCrossings;
1275 for (const auto& crossing : junction->getGNECrossings()) {
1276 std::vector<std::string> edgeIDs;
1277 for (auto e : crossing->getCrossingEdges()) {
1278 edgeIDs.push_back(e->getID());
1279 }
1280 oldCrossings.push_back(std::make_pair(*crossing->getNBCrossing(), edgeIDs));
1281 }
1282 std::map<std::string, std::string> edgeRename;
1283 // split incoming/outgoing edges
1284 for (GNEEdge* edge : edges) {
1285 GNEJunction* newJunction = nullptr;
1286 if (edge == prevOpposite) {
1287 newJunction = newJunctions.back();
1288 }
1289 // update template (most "important" incoming edge)
1290 if (edge->getToJunction() == junction) {
1291 if (templateEdge == nullptr) {
1292 templateEdge = edge;
1293 } else {
1294 NBEdge* tpl = templateEdge->getNBEdge();
1295 NBEdge* e = edge->getNBEdge();
1296 if (tpl->getNumLanes() < e->getNumLanes()
1297 || (tpl->getNumLanes() == e->getNumLanes()
1298 && tpl->getPriority() < e->getPriority())) {
1299 templateEdge = edge;
1300 }
1301 }
1302 }
1303 //std::cout << " edge=" << edge->getID() << " prevOpposite=" << Named::getIDSecure(prevOpposite) << " newJunction=" << Named::getIDSecure(newJunction) << "\n";
1304 prevOpposite = edge->getOppositeEdges().size() > 0 ? edge->getOppositeEdges().front() : nullptr;
1305 const double geomLength = edge->getNBEdge()->getGeometry().length2D();
1306 const double splitOffset = (edge->getToJunction() == junction
1307 ? MAX2(POSITION_EPS, geomLength - radius)
1308 : MIN2(geomLength - POSITION_EPS, radius));
1309 Position pos = edge->getNBEdge()->getGeometry().positionAtOffset2D(splitOffset);
1310 auto newStuff = splitEdge(edge, pos, undoList, newJunction);
1311 newJunction = newStuff.first;
1312 if (edge->getFromJunction() == junction) {
1313 // edge will be deleted and the new part after the split kept. Preserve edge id
1314 edgeRename[newStuff.second->getID()] = edge->getID();
1315 }
1316 if (newJunctions.empty() || newJunction != newJunctions.back()) {
1317 newJunctions.push_back(newJunction);
1318 }
1319 }
1320
1321 Position center = junction->getPositionInView();
1322 deleteJunction(junction, undoList);
1323 // rename edges after the originals have been deleted
1324 for (auto item : edgeRename) {
1325 GNEEdge* outgoing = myAttributeCarriers->retrieveEdge(item.first);
1326 outgoing->setAttribute(SUMO_ATTR_ID, item.second, undoList);
1327 }
1328 // restore crossings (after rename)
1329 for (auto nbCItem : oldCrossings) {
1330 for (GNEJunction* nj : newJunctions) {
1331 nbCItem.first.edges.clear();
1332 // check whether this junction has all the edges of the crossing
1333 for (const std::string& ce : nbCItem.second) {
1334 bool foundCE = false;
1335 for (NBEdge* je : nj->getNBNode()->getEdges()) {
1336 if (je->getID() == ce) {
1337 foundCE = true;
1338 nbCItem.first.edges.push_back(je);
1339 break;
1340 }
1341 }
1342 if (!foundCE) {
1343 break;
1344 }
1345 }
1346 if (nbCItem.first.edges.size() == nbCItem.second.size()) {
1347 undoList->add(new GNEChange_Crossing(nj, nbCItem.first, true), true);
1348 break;
1349 }
1350 }
1351 }
1352 // create new edges to connect roundabout junctions (counter-clockwise)
1353 const double resolution = OptionsCont::getOptions().getFloat("opendrive.curve-resolution") * 3;
1354 for (int i = 0; i < (int)newJunctions.size(); i++) {
1355 GNEJunction* from = newJunctions[(i + 1) % newJunctions.size()];
1356 GNEJunction* to = newJunctions[i];
1357 GNEEdge* newEdge = createEdge(from, to, nullptr, undoList);
1358 const double angle1 = center.angleTo2D(from->getPositionInView());
1359 const double angle2 = center.angleTo2D(to->getPositionInView());
1360 // insert geometry points every resolution meters
1361 const double angleDiff = fabs(GeomHelper::angleDiff(angle2, angle1));
1362 // circumference = 2 * M_PI * radius, angularFraction = angleDiff / 2 * M_PI
1363 int numSegments = MAX2(2, (int)ceil(angleDiff * radius / resolution));
1364 PositionVector innerGeom;
1365 for (int j = 1; j < numSegments; j++) {
1366 const double angle = angle1 + lefthandSign * j * angleDiff / numSegments;
1367 innerGeom.push_back(center + Position(cos(angle) * radius, sin(angle) * radius));
1368 }
1369 //std::cout << " newEdge=" << newEdge->getID() << " angle1=" << angle1 << " angle2=" << angle2 << " angleDiff=" << angleDiff
1370 // << " numSegments=" << numSegments << " innerGeom=" << innerGeom << "\n";
1371 newEdge->setAttribute(SUMO_ATTR_SHAPE, toString(innerGeom), undoList);
1372 if (templateEdge) {
1373 GNEEdgeTemplate t(templateEdge);
1374 newEdge->copyTemplate(&t, undoList);
1375 }
1376 }
1377 undoList->end();
1378}
1379
1380
1381bool
1383 // Check that there isn't another junction in the same position as Pos
1384 for (auto& junction : myAttributeCarriers->getJunctions()) {
1385 if (junction.second->getPositionInView() == pos) {
1386 return false;
1387 }
1388 }
1389 return true;
1390}
1391
1392
1393void
1395 auto& neteditOptions = OptionsCont::getOptions();
1396 auto& sumoOptions = myApplicationWindow->getSumoOptions();
1397 // begin save network
1398 myApplicationWindow->getApp()->beginWaitCursor();
1399 // set output file in SUMO and netedit options
1400 neteditOptions.resetWritable();
1402 // compute without volatile options and update network
1403 computeAndUpdate(neteditOptions, false);
1404 // clear typeContainer
1406 // now update typeContainer with edgeTypes
1407 for (const auto& edgeType : myAttributeCarriers->getEdgeTypes()) {
1408 myNetBuilder->getTypeCont().insertEdgeType(edgeType.first, edgeType.second);
1409 for (int i = 0; i < (int)edgeType.second->getLaneTypes().size(); i++) {
1410 myNetBuilder->getTypeCont().insertLaneType(edgeType.first, i,
1411 edgeType.second->getLaneTypes().at(i)->speed,
1412 edgeType.second->getLaneTypes().at(i)->permissions,
1413 edgeType.second->getLaneTypes().at(i)->width,
1414 edgeType.second->getLaneTypes().at(i)->attrs);
1415 }
1416 }
1417 // write network
1418 NWFrame::writeNetwork(neteditOptions, *myNetBuilder);
1419 // reset output file
1420 sumoOptions.resetWritable();
1421 neteditOptions.resetDefault("output-file");
1422 // mark network as saved
1424 // end save network
1425 myApplicationWindow->getApp()->endWaitCursor();
1426}
1427
1428
1429void
1430GNENet::savePlain(const std::string& prefix, const OptionsCont& netconvertOptions) {
1431 // compute without volatile options
1433 // save netconvert options
1434 NWWriter_XML::writeNetwork(netconvertOptions, prefix, *myNetBuilder);
1435}
1436
1437
1438void
1439GNENet::saveJoined(const std::string& filename) {
1440 // compute without volatile options
1443}
1444
1445
1446void
1448 // check if object must be inserted in RTREE
1449 if (AC->getTagProperty()->isPlacedInRTree() && !AC->inGrid()) {
1451 AC->setInGrid(true);
1452 }
1453}
1454
1455
1456void
1458 // check if object must be inserted in RTREE
1459 if (AC->getTagProperty()->isPlacedInRTree() && AC->inGrid()) {
1461 AC->setInGrid(false);
1462 }
1463}
1464
1465
1466void
1467GNENet::computeNetwork(GNEApplicationWindow* window, bool force, bool volatileOptions) {
1468 if (!myNeedRecompute) {
1469 if (force) {
1470 if (volatileOptions) {
1471 window->setStatusBarText(TL("Forced computing junctions with volatile options ..."));
1472 } else {
1473 window->setStatusBarText(TL("Forced computing junctions ..."));
1474 }
1475 } else {
1476 return;
1477 }
1478 } else {
1479 if (volatileOptions) {
1480 window->setStatusBarText(TL("Computing junctions with volatile options ..."));
1481 } else {
1482 window->setStatusBarText(TL("Computing junctions ..."));
1483 }
1484 }
1485 // start recomputing
1486 myApplicationWindow->getApp()->beginWaitCursor();
1487 // save current number of lanes for every edge if recomputing is with volatile options
1488 if (volatileOptions) {
1489 for (const auto& edge : myAttributeCarriers->getEdges()) {
1490 myEdgesAndNumberOfLanes[edge.second->getID()] = (int)edge.second->getChildLanes().size();
1491 }
1492 }
1493 // compute and update
1494 auto& neteditOptions = OptionsCont::getOptions();
1495 computeAndUpdate(neteditOptions, volatileOptions);
1496 // load additionals if was recomputed with volatile options
1497 if (volatileOptions) {
1499 if (bucket->getFilename().size() > 0) {
1500 // Create general handler
1501 GNEGeneralHandler generalHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1502 // Run parser
1503 if (!generalHandler.parse()) {
1504 WRITE_ERROR(TL("Loading of additional file failed: ") + bucket->getFilename());
1505 } else {
1506 WRITE_MESSAGE(TL("Loading of additional file successfully: ") + bucket->getFilename());
1507 }
1508 }
1509 }
1510 }
1511 // load demand elements if was recomputed with volatile options
1512 if (volatileOptions) {
1514 if (bucket->getFilename().size() > 0) {
1515 // Create general handler
1516 GNEGeneralHandler generalHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1517 // Run parser
1518 if (!generalHandler.parse()) {
1519 WRITE_ERROR(TL("Loading of route file failed: ") + bucket->getFilename());
1520 } else {
1521 WRITE_MESSAGE(TL("Loading of route file successfully: ") + bucket->getFilename());
1522 }
1523 }
1524 }
1525 }
1526 // load datas if was recomputed with volatile options
1527 if (volatileOptions) {
1529 if (bucket->getFilename().size() > 0) {
1530 // Create general handler
1531 GNEDataHandler dataHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1532 // Run parser
1533 if (!dataHandler.parse()) {
1534 WRITE_ERROR(TL("Loading of data file failed: ") + bucket->getFilename());
1535 } else {
1536 WRITE_MESSAGE(TL("Loading of data file successfully: ") + bucket->getFilename());
1537 }
1538 }
1539 }
1540 }
1541 // load meanDatas if was recomputed with volatile options
1542 if (volatileOptions) {
1544 if (bucket->getFilename().size() > 0) {
1545 // Create general handler
1546 GNEGeneralHandler generalHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1547 // Run parser
1548 if (!generalHandler.parse()) {
1549 WRITE_ERROR(TL("Loading of meandata file failed: ") + bucket->getFilename());
1550 } else {
1551 WRITE_MESSAGE(TL("Loading of meandata file successfully: ") + bucket->getFilename());
1552 }
1553 }
1554 }
1555 }
1556 // clear myEdgesAndNumberOfLanes after reload additionals
1558 // end recomputing
1559 myApplicationWindow->getApp()->endWaitCursor();
1560 // update status bar
1561 window->setStatusBarText(TL("Finished computing junctions."));
1562}
1563
1564
1565void
1567 window->setStatusBarText(TL("Computing demand elements ..."));
1568 // if we aren't in Demand mode, update path calculator
1572 }
1573 // clear demand paths
1575 // iterate over all demand elements and compute
1576 for (const auto& demandElements : myAttributeCarriers->getDemandElements()) {
1577 for (const auto& demandElement : demandElements.second) {
1578 demandElement.second->computePathElement();
1579 }
1580 }
1581 window->setStatusBarText(TL("Finished computing demand elements."));
1582}
1583
1584
1585void
1587 window->setStatusBarText(TL("Computing data elements ..."));
1588 // iterate over all demand elements and compute
1589 for (const auto& genericDataTag : myAttributeCarriers->getGenericDatas()) {
1590 for (const auto& genericData : genericDataTag.second) {
1591 genericData.second->computePathElement();
1592 }
1593 }
1594 window->setStatusBarText(TL("Finished computing data elements."));
1595}
1596
1597
1598void
1600 // recompute tl-logics
1601 auto& neteditOptions = OptionsCont::getOptions();
1603 // iterate over traffic lights definitions. Make a copy because invalid
1604 // definitions will be removed (and would otherwise destroy the iterator)
1605 const std::set<NBTrafficLightDefinition*> tlsDefs = junction->getNBNode()->getControllingTLS();
1606 for (auto it : tlsDefs) {
1607 it->setParticipantsInformation();
1608 it->setTLControllingInformation();
1609 tllCont.computeSingleLogic(neteditOptions, it);
1610 }
1611
1612 // @todo compute connections etc...
1613}
1614
1615
1616void
1620
1621
1622bool
1624 return !myNeedRecompute;
1625}
1626
1627
1628bool
1630 const auto selectedJunctions = myAttributeCarriers->getSelectedJunctions();
1631 if (selectedJunctions.size() < 2) {
1632 return false;
1633 }
1634 EdgeVector allIncoming;
1635 EdgeVector allOutgoing;
1636 std::set<NBNode*, ComparatorIdLess> cluster;
1637 for (const auto& selectedJunction : selectedJunctions) {
1638 cluster.insert(selectedJunction->getNBNode());
1639 const EdgeVector& incoming = selectedJunction->getNBNode()->getIncomingEdges();
1640 allIncoming.insert(allIncoming.end(), incoming.begin(), incoming.end());
1641 const EdgeVector& outgoing = selectedJunction->getNBNode()->getOutgoingEdges();
1642 allOutgoing.insert(allOutgoing.end(), outgoing.begin(), outgoing.end());
1643 }
1644 // create new junction
1645 Position pos;
1646 Position oldPos;
1647 bool setTL = false;
1648 std::string id = "cluster";
1649 TrafficLightType type;
1651 myNetBuilder->getNodeCont().analyzeCluster(cluster, id, pos, setTL, type, nodeType);
1652 // save position
1653 oldPos = pos;
1654 // Check that there isn't another junction in the same position as Pos but doesn't belong to cluster
1655 for (const auto& junction : myAttributeCarriers->getJunctions()) {
1656 if ((junction.second->getPositionInView() == pos) && (cluster.find(junction.second->getNBNode()) == cluster.end())) {
1657 // open dialog
1659 TL("Position of joined junction"),
1660 TL("There is another unselected junction in the same position of joined junction."),
1661 TL("It will be joined with the other selected junctions. Continue?"));
1662 // check dialog result
1663 if (questionDialog.getResult() == GNEDialog::Result::ACCEPT) {
1664 // select conflicted junction an join all again
1665 junction.second->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1666 return joinSelectedJunctions(undoList);
1667 } else {
1668 return false;
1669 }
1670 }
1671 }
1672 // use checkJunctionPosition to avoid conflicts with junction in the same position as others
1673 while (!checkJunctionPosition(pos)) {
1674 pos.setx(pos.x() + 0.1);
1675 pos.sety(pos.y() + 0.1);
1676 }
1677 // start with the join selected junctions
1678 undoList->begin(GUIIcon::JUNCTION, "Join selected " + toString(SUMO_TAG_JUNCTION) + "s");
1679 GNEJunction* joined = createJunction(pos, undoList);
1680 joined->setAttribute(SUMO_ATTR_ID, id, undoList);
1681 // id must be set before type because it is used when creating a new tls
1682 joined->setAttribute(SUMO_ATTR_TYPE, toString(nodeType), undoList); // i.e. rail crossing
1683 if (setTL) {
1684 joined->setAttribute(SUMO_ATTR_TLTYPE, toString(type), undoList);
1685 }
1687 // first remove all crossing of the involved junctions and edges
1688 // (otherwise edge removal will trigger discarding)
1689 std::vector<NBNode::Crossing> oldCrossings;
1690 for (const auto& selectedJunction : selectedJunctions) {
1691 const auto crossings = selectedJunction->getGNECrossings();
1692 for (auto crossing : crossings) {
1693 deleteCrossing(crossing, undoList);
1694 }
1695 }
1696 // preserve old connections
1697 for (const auto& selectedJunction : selectedJunctions) {
1698 selectedJunction->setLogicValid(false, undoList);
1699 }
1700 // remap edges
1701 for (const auto& incomingEdge : allIncoming) {
1702 if (std::find(allOutgoing.begin(), allOutgoing.end(), incomingEdge) == allOutgoing.end()) {
1703 GNEChange_Attribute::changeAttribute(myAttributeCarriers->getEdges().at(incomingEdge->getID()), SUMO_ATTR_TO, joined->getID(), undoList);
1704 }
1705 }
1706 EdgeSet edgesWithin;
1707 for (const auto& outgoingEdge : allOutgoing) {
1708 // delete edges within the cluster
1709 GNEEdge* edge = myAttributeCarriers->getEdges().at(outgoingEdge->getID());
1710 if (edge->getToJunction() == joined) {
1711 edgesWithin.insert(outgoingEdge);
1712 deleteEdge(edge, undoList, false);
1713 } else {
1714 GNEChange_Attribute::changeAttribute(myAttributeCarriers->getEdges().at(outgoingEdge->getID()), SUMO_ATTR_FROM, joined->getID(), undoList);
1715 }
1716 }
1717 // remap all crossing of the involved junctions and edges
1718 for (const auto& nbc : oldCrossings) {
1719 bool keep = true;
1720 for (NBEdge* e : nbc.edges) {
1721 if (edgesWithin.count(e) != 0) {
1722 keep = false;
1723 break;
1724 }
1725 };
1726 if (keep) {
1727 undoList->add(new GNEChange_Crossing(joined, nbc.edges, nbc.width,
1728 nbc.priority || joined->getNBNode()->isTLControlled(),
1729 nbc.customTLIndex, nbc.customTLIndex2, nbc.customShape,
1730 false, true), true);
1731 }
1732 }
1733 // delete original junctions
1734 for (const auto& selectedJunction : selectedJunctions) {
1735 deleteJunction(selectedJunction, undoList);
1736 }
1737 // check if joined junction had to change their original position to avoid errors
1738 if (pos != oldPos) {
1739 joined->setAttribute(SUMO_ATTR_POSITION, toString(oldPos), undoList);
1740 }
1741 undoList->end();
1742 return true;
1743}
1744
1745
1746bool
1748 // obtain current net's crossings
1749 std::vector<GNECrossing*> myNetCrossings;
1750 for (const auto& junction : myAttributeCarriers->getJunctions()) {
1751 myNetCrossings.reserve(myNetCrossings.size() + junction.second->getGNECrossings().size());
1752 myNetCrossings.insert(myNetCrossings.end(), junction.second->getGNECrossings().begin(), junction.second->getGNECrossings().end());
1753 }
1754 // obtain invalid crossings
1755 std::vector<GNECrossing*> myInvalidCrossings;
1756 for (auto i = myNetCrossings.begin(); i != myNetCrossings.end(); i++) {
1757 if (!(*i)->getNBCrossing()->valid) {
1758 myInvalidCrossings.push_back(*i);
1759 }
1760 }
1761 // continue depending of invalid crossings
1762 if (myInvalidCrossings.empty()) {
1763 // open a warning dialog informing that there isn't crossing to remove
1765 TL("Clear crossings"),
1766 TL("There are no invalid crossings to remove."));
1767 } else {
1768 std::string plural = myInvalidCrossings.size() == 1 ? ("") : ("s");
1769 // Ask confirmation to user
1770 const GNEQuestionBasicDialog questionDialog(myApplicationWindow,
1771 GNEDialog::Buttons::YES_NO, TL("Clear crossings"),
1772 TL("Crossings will be cleared. Continue?"));
1773 // 1:yes, 2:no, 4:esc
1774 if (questionDialog.getResult() == GNEDialog::Result::ACCEPT) {
1775 undoList->begin(GUIIcon::MODEDELETE, TL("clear crossings"));
1776 for (const auto& crossing : myInvalidCrossings) {
1777 deleteCrossing(crossing, undoList);
1778 }
1779 undoList->end();
1780 } else {
1781 return false;
1782 }
1783 }
1784 return true;
1785}
1786
1787
1788void
1790 undoList->begin(GUIIcon::MODEDELETE, TL("clear junctions"));
1791 std::vector<GNEJunction*> toRemove;
1792 for (auto& junction : myAttributeCarriers->getJunctions()) {
1793 if (junction.second->getNBNode()->getEdges().size() == 0) {
1794 toRemove.push_back(junction.second);
1795 }
1796 }
1797 for (auto junction : toRemove) {
1798 deleteJunction(junction, undoList);
1799 }
1800 undoList->end();
1801}
1802
1803
1804void
1806 // first declare a vector to save all routes without children
1807 std::vector<GNEDemandElement*> routesWithoutChildren;
1808 routesWithoutChildren.reserve(myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE).size());
1809 // iterate over routes
1810 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
1811 if (route.second->getChildDemandElements().empty()) {
1812 routesWithoutChildren.push_back(route.second);
1813 }
1814 }
1815 // finally remove all routesWithoutChildren
1816 if (routesWithoutChildren.size() > 0) {
1817 // begin undo list
1818 undoList->begin(GUIIcon::MODEDELETE, TL("clear unused routes"));
1819 // iterate over routesWithoutChildren
1820 for (const auto& i : routesWithoutChildren) {
1821 // due route doesn't have children, simply call GNEChange_DemandElement
1822 undoList->add(new GNEChange_DemandElement(i, false), true);
1823 }
1824 // end undo list
1825 undoList->end();
1826 }
1827}
1828
1829
1830void
1832 // first declare a sorted set of sorted route's edges in string format
1833 std::set<std::pair<std::string, GNEDemandElement*> > mySortedRoutes;
1834 // iterate over routes and save it in mySortedRoutes (only if it doesn't have Stop Children)
1835 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
1836 // first check route has stops
1837 bool hasStops = false;
1838 for (const auto& stop : route.second->getChildDemandElements()) {
1839 if (stop->getTagProperty()->isVehicleStop()) {
1840 hasStops = true;
1841 }
1842 }
1843 if (!hasStops) {
1844 mySortedRoutes.insert(std::make_pair(GNEAttributeCarrier::parseIDs(route.second->getParentEdges()), route.second));
1845 }
1846 }
1847 // now declare a matrix in which organize routes to be merged
1848 std::vector<std::vector<GNEDemandElement*> > routesToMerge;
1849 auto index = mySortedRoutes.begin();
1850 // iterate over mySortedRoutes
1851 for (auto i = mySortedRoutes.begin(); i != mySortedRoutes.end(); i++) {
1852 if (routesToMerge.empty()) {
1853 routesToMerge.push_back({i->second});
1854 } else {
1855 if (index->first == i->first) {
1856 routesToMerge.back().push_back(i->second);
1857 } else {
1858 routesToMerge.push_back({i->second});
1859 index = i;
1860 }
1861 }
1862 }
1863 // now check if there is routes to merge
1864 bool thereIsRoutesToMerge = false;
1865 for (const auto& i : routesToMerge) {
1866 if (i.size() > 1) {
1867 thereIsRoutesToMerge = true;
1868 }
1869 }
1870 // if exist
1871 if (thereIsRoutesToMerge) {
1872 // begin undo list
1873 undoList->begin(GUIIcon::ROUTE, TL("merge routes"));
1874 // iterate over route to edges
1875 for (const auto& routes : routesToMerge) {
1876 if (routes.size() > 1) {
1877 // iterate over duplicated routes
1878 for (int i = 1; i < (int)routes.size(); i++) {
1879 // move all vehicles of every duplicated route
1880 while (routes.at(i)->getChildDemandElements().size() > 0) {
1881 routes.at(i)->getChildDemandElements().front()->setAttribute(SUMO_ATTR_ROUTE, routes.at(0)->getID(), undoList);
1882 }
1883 // finally remove route
1884 undoList->add(new GNEChange_DemandElement(routes.at(i), false), true);
1885 }
1886 }
1887 }
1888 // end undo list
1889 undoList->end();
1890 }
1891}
1892
1893
1894void
1896 // declare personPlan-pos map
1897 std::map<GNEDemandElement*, std::string> personPlanMap;
1898 // iterate over persons
1899 for (const auto& persontag : {
1901 }) {
1902 for (const auto& person : myAttributeCarriers->getDemandElements().at(persontag)) {
1903 if (person.second->getChildDemandElements().size() > 0) {
1904 // get person plan
1905 GNEDemandElement* personPlan = person.second->getChildDemandElements().front();
1906 // iterate over all personPlans
1907 while (personPlan) {
1908 // check if personPlan is a stopPerson over edge
1909 if (personPlan->getTagProperty()->getTag() == GNE_TAG_STOPPERSON_EDGE) {
1910 // get previous person plan
1911 GNEDemandElement* previousPersonPlan = person.second->getPreviousChildDemandElement(personPlan);
1912 // check if arrivalPos of previous personPlan is different of endPos of stopPerson
1913 if (previousPersonPlan && previousPersonPlan->getTagProperty()->hasAttribute(SUMO_ATTR_ARRIVALPOS) &&
1914 (previousPersonPlan->getAttribute(SUMO_ATTR_ARRIVALPOS) != personPlan->getAttribute(SUMO_ATTR_ENDPOS))) {
1915 personPlanMap[previousPersonPlan] = personPlan->getAttribute(SUMO_ATTR_ENDPOS);
1916 }
1917 }
1918 // go to next person plan
1919 personPlan = person.second->getNextChildDemandElement(personPlan);
1920 }
1921 }
1922 }
1923 }
1924 // continue if there is personPlanMap to adjust
1925 if (personPlanMap.size() > 0) {
1926 // begin undo list
1927 undoList->begin(GUIIcon::MODEPERSONPLAN, TL("adjust person plans"));
1928 // iterate over invalidDemandElements
1929 for (const auto& personPlan : personPlanMap) {
1930 // set arrivalPos attribute
1931 personPlan.first->setAttribute(SUMO_ATTR_ARRIVALPOS, personPlan.second, undoList);
1932 }
1933 // end undo list
1934 undoList->end();
1935 }
1936}
1937
1938
1939void
1941 // first declare a vector to save all invalid demand elements
1942 std::vector<GNEDemandElement*> invalidDemandElements;
1943 invalidDemandElements.reserve(myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE).size() +
1946 // iterate over routes
1947 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
1948 if (route.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
1949 invalidDemandElements.push_back(route.second);
1950 }
1951 }
1952 // iterate over flows
1953 for (const auto& flow : myAttributeCarriers->getDemandElements().at(SUMO_TAG_FLOW)) {
1954 if (flow.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
1955 invalidDemandElements.push_back(flow.second);
1956 }
1957 }
1958 // iterate over trip
1959 for (const auto& trip : myAttributeCarriers->getDemandElements().at(SUMO_TAG_TRIP)) {
1960 if (trip.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
1961 invalidDemandElements.push_back(trip.second);
1962 }
1963 }
1964 // continue if there is invalidDemandElements to remove
1965 if (invalidDemandElements.size() > 0) {
1966 // begin undo list
1967 undoList->begin(GUIIcon::MODEDELETE, TL("remove invalid demand elements"));
1968 // iterate over invalidDemandElements
1969 for (const auto& invalidDemandElement : invalidDemandElements) {
1970 // simply call GNEChange_DemandElement
1971 undoList->add(new GNEChange_DemandElement(invalidDemandElement, false), true);
1972 }
1973 // end undo list
1974 undoList->end();
1975 }
1976}
1977
1978void
1980 if (junction->getNBNode()->checkIsRemovable()) {
1981 // start operation
1982 undoList->begin(junction, TL("replace junction by geometry"));
1983 // obtain Edges to join
1984 std::vector<std::pair<NBEdge*, NBEdge*> > edgesToJoin = junction->getNBNode()->getEdgesToJoin();
1985 // clear connections of junction to replace
1986 clearJunctionConnections(junction, undoList);
1987 // iterate over NBEdges to join
1988 for (auto edgePair : edgesToJoin) {
1989 // obtain GNEEdges
1990 GNEEdge* begin = myAttributeCarriers->getEdges().at(edgePair.first->getID());
1991 GNEEdge* continuation = myAttributeCarriers->getEdges().at(edgePair.second->getID());
1992 // remove connections between the edges
1993 std::vector<NBEdge::Connection> connections = begin->getNBEdge()->getConnections();
1994 for (auto con : connections) {
1995 undoList->add(new GNEChange_Connection(begin, con, false, false), true);
1996 }
1997 // fix shape of replaced edge
1998 PositionVector newShape = begin->getNBEdge()->getInnerGeometry();
1999 newShape.push_back(junction->getNBNode()->getPosition());
2000 // replace incoming edge
2001 replaceIncomingEdge(continuation, begin, undoList);
2002
2003 newShape.append(continuation->getNBEdge()->getInnerGeometry());
2004 begin->setAttribute(GNE_ATTR_SHAPE_END, "", undoList);
2005 begin->setAttribute(SUMO_ATTR_ENDOFFSET, continuation->getAttribute(SUMO_ATTR_ENDOFFSET), undoList);
2006 begin->setAttribute(SUMO_ATTR_SHAPE, toString(newShape), undoList);
2007 begin->getNBEdge()->resetNodeBorder(begin->getNBEdge()->getToNode());
2008 // fix loaded lengths
2009 if (begin->getNBEdge()->hasLoadedLength() || continuation->getNBEdge()->hasLoadedLength()) {
2010 begin->setAttribute(SUMO_ATTR_LENGTH, toString(begin->getNBEdge()->getLoadedLength() + continuation->getNBEdge()->getLoadedLength()), undoList);
2011 }
2012 }
2013 //delete replaced junction
2014 deleteJunction(junction, undoList);
2015 // finish operation
2016 undoList->end();
2017 } else {
2018 throw ProcessError(TL("Junction isn't removable"));
2019 }
2020}
2021
2022
2023void
2024GNENet::splitJunction(GNEJunction* junction, bool reconnect, GNEUndoList* undoList) {
2025 std::vector<std::pair<Position, std::string> > endpoints = junction->getNBNode()->getEndPoints();
2026 if (endpoints.size() < 2) {
2027 return;
2028 }
2029 // start operation
2030 undoList->begin(junction, TL("split junction"));
2031 // record connections
2032 std::map<std::pair<std::string, GNEEdge*>, std::vector<NBEdge::Connection>> straightConnections;
2033 for (GNEEdge* e : junction->getGNEIncomingEdges()) {
2034 for (const auto& c : e->getNBEdge()->getConnections()) {
2035 if (c.fromLane >= 0 && junction->getNBNode()->getDirection(e->getNBEdge(), c.toEdge) == LinkDirection::STRAIGHT) {
2036 straightConnections[std::make_pair(e->getID(), e)].push_back(c);
2037 }
2038 };
2039 }
2040 junction->setLogicValid(false, undoList);
2041 for (const auto& pair : endpoints) {
2042 const Position& pos = pair.first;
2043 const std::string& origID = pair.second;
2044 GNEJunction* newJunction = createJunction(pos, undoList);
2045 std::string newID = origID != "" ? origID : newJunction->getID();
2046 // make a copy because the original vectors are modified during iteration
2047 const std::vector<GNEEdge*> incoming = junction->getGNEIncomingEdges();
2048 const std::vector<GNEEdge*> outgoing = junction->getGNEOutgoingEdges();
2049 //std::cout << " checkEndpoint " << pair.first << " " << pair.second << " newID=" << newID << "\n";
2050 for (GNEEdge* e : incoming) {
2051 //std::cout << " incoming " << e->getID() << " pos=" << pos << " origTo=" << e->getNBEdge()->getParameter("origTo") << " newID=" << newID << "\n";
2052 if (e->getNBEdge()->getGeometry().back().almostSame(pos) || e->getNBEdge()->getParameter("origTo") == newID) {
2053 //std::cout << " match\n";
2054 GNEChange_Attribute::changeAttribute(e, SUMO_ATTR_TO, newJunction->getID(), undoList);
2055 }
2056 }
2057 for (GNEEdge* e : outgoing) {
2058 //std::cout << " outgoing " << e->getID() << " pos=" << pos << " origFrom=" << e->getNBEdge()->getParameter("origFrom") << " newID=" << newID << "\n";
2059 if (e->getNBEdge()->getGeometry().front().almostSame(pos) || e->getNBEdge()->getParameter("origFrom") == newID) {
2060 //std::cout << " match\n";
2061 GNEChange_Attribute::changeAttribute(e, SUMO_ATTR_FROM, newJunction->getID(), undoList);
2062 }
2063 }
2064 if (newID != newJunction->getID()) {
2065 if (newJunction->isValid(SUMO_ATTR_ID, newID)) {
2066 GNEChange_Attribute::changeAttribute(newJunction, SUMO_ATTR_ID, newID, undoList);
2067 } else {
2068 WRITE_WARNINGF(TL("Could not rename split node to '%'"), newID);
2069 }
2070 }
2071 }
2072 // recreate edges from straightConnections
2073 if (reconnect) {
2074 for (const auto& item : straightConnections) {
2075 GNEEdge* in = item.first.second;
2076 std::map<std::pair<std::string, NBEdge*>, GNEEdge*> newEdges;
2077 for (auto& c : item.second) {
2078 GNEEdge* out = myAttributeCarriers->retrieveEdge(c.toEdge->getID());
2079 GNEEdge* newEdge = nullptr;
2080 if (in->getToJunction() == out->getFromJunction()) {
2081 continue;
2082 }
2083 if (newEdges.count(std::make_pair(c.toEdge->getID(), c.toEdge)) == 0) {
2084 newEdge = createEdge(in->getToJunction(), out->getFromJunction(), in, undoList);
2085 if (newEdge) {
2086 newEdges[std::make_pair(c.toEdge->getID(), c.toEdge)] = newEdge;
2087 newEdge->setAttribute(SUMO_ATTR_NUMLANES, "1", undoList);
2088 }
2089 } else {
2090 newEdge = newEdges[std::make_pair(c.toEdge->getID(), c.toEdge)];
2091 duplicateLane(newEdge->getChildLanes().back(), undoList, true);
2092 }
2093 if (newEdge) {
2094 // copy permissions
2095 newEdge->getChildLanes().back()->setAttribute(SUMO_ATTR_ALLOW,
2096 in->getChildLanes()[c.fromLane]-> getAttribute(SUMO_ATTR_ALLOW), undoList);
2097 }
2098 }
2099 }
2100 }
2101 deleteJunction(junction, undoList);
2102 // finish operation
2103 undoList->end();
2104}
2105
2106
2107
2108void
2110 undoList->begin(GUIIcon::MODEDELETE, TL("clear junction connections"));
2111 std::vector<GNEConnection*> connections = junction->getGNEConnections();
2112 // Iterate over all connections and clear it
2113 for (auto i : connections) {
2114 deleteConnection(i, undoList);
2115 }
2116 undoList->end();
2117}
2118
2119
2120void
2122 undoList->begin(junction, TL("reset junction connections"));
2123 // first clear connections
2124 clearJunctionConnections(junction, undoList);
2125 // invalidate logic to create new connections in the next recomputing
2126 junction->setLogicValid(false, undoList);
2127 undoList->end();
2128}
2129
2130
2131void
2133 undoList->begin(GUIIcon::MODEDELETE, TL("clear additional elements"));
2134 // clear additionals
2135 for (const auto& additionalMap : myAttributeCarriers->getAdditionals()) {
2136 while (additionalMap.second.size() > 0) {
2137 deleteAdditional(additionalMap.second.begin()->second, undoList);
2138 }
2139 }
2140 undoList->end();
2141}
2142
2143
2144void
2146 undoList->begin(GUIIcon::MODEDELETE, TL("clear demand elements"));
2147 // clear demand elements
2148 for (const auto& demandElementsMap : myAttributeCarriers->getDemandElements()) {
2149 if (demandElementsMap.first != SUMO_TAG_VTYPE) {
2150 while (demandElementsMap.second.size() > 0) {
2151 deleteDemandElement(demandElementsMap.second.begin()->second, undoList);
2152 }
2153 }
2154 }
2155 // special case for vTypes
2156 const std::unordered_map<const GUIGlObject*, GNEDemandElement*> types = myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE);
2157 for (const auto& type : types) {
2158 if (type.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE) == GNEAttributeCarrier::FALSE_STR) {
2159 deleteDemandElement(type.second, undoList);
2160 }
2161 }
2162 undoList->end();
2163}
2164
2165
2166void
2168 undoList->begin(GUIIcon::MODEDELETE, TL("clear data elements"));
2169 // clear data sets
2170 while (myAttributeCarriers->getDataSets().size() > 0) {
2171 deleteDataSet(myAttributeCarriers->getDataSets().begin()->second, undoList);
2172 }
2173 undoList->end();
2174}
2175
2176
2177void
2179 undoList->begin(GUIIcon::MODEDELETE, TL("clear meanData elements"));
2180 // clear meanDatas
2181 for (const auto& meanDataMap : myAttributeCarriers->getMeanDatas()) {
2182 while (meanDataMap.second.size() > 0) {
2183 deleteMeanData(meanDataMap.second.begin()->second, undoList);
2184 }
2185 }
2186 undoList->end();
2187}
2188
2189
2190void
2191GNENet::changeEdgeEndpoints(GNEEdge* edge, const std::string& newSource, const std::string& newDest) {
2194 edge->getNBEdge()->reinitNodes(from, to);
2196}
2197
2198
2203
2204
2209
2210
2211void
2215
2216
2217void
2219 myExplicitTurnarounds.erase(id);
2220}
2221
2222
2223bool
2225 // obtain invalid additionals depending of number of their parent lanes
2226 std::vector<GNEAdditional*> invalidAdditionals;
2227 // iterate over additionals and obtain invalids
2228 for (const auto& additionalPair : myAttributeCarriers->getAdditionals()) {
2229 for (const auto& addditional : additionalPair.second) {
2230 // check if has to be fixed
2231 if (!addditional.second->isAdditionalValid()) {
2232 invalidAdditionals.push_back(addditional.second);
2233 }
2234 }
2235 }
2236 // if there are invalid additionls, open GNEFixAdditionalElementsDialog
2237 if (invalidAdditionals.size() > 0) {
2238 // open fix additional elements dialog
2239 const GNEFixAdditionalElementsDialog fixAdditionalElements(myApplicationWindow, invalidAdditionals);
2240 if (fixAdditionalElements.getResult() != GNEDialog::Result::ACCEPT) {
2241 return false;
2242 }
2243 }
2244 // Start saving additionals
2245 myApplicationWindow->getApp()->beginWaitCursor();
2246 // iterate over all elements and save files
2248 // only write buckets with elements
2249 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2250 // open file
2251 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2252 // open header
2253 device.writeXMLHeader("additional", "additional_file.xsd", EMPTY_HEADER, false);
2254 // save additionals, demand elements and meanDatas
2255 writeAdditionalFileElements(device, bucket);
2256 // close device
2257 device.close();
2258 }
2259 }
2260 // mark additionals as saved
2262 // end saving additionals
2263 myApplicationWindow->getApp()->endWaitCursor();
2264 return true;
2265}
2266
2267
2268bool
2269GNENet::saveJuPedSimElements(const std::string& filename) {
2270 OutputDevice& device = OutputDevice::getDevice(filename);
2271 // open header
2272 device.writeXMLHeader("additional", "additional_file.xsd", EMPTY_HEADER, false);
2273 // juPedSim elements
2274 writeJuPedSimComment(device, nullptr);
2276 writeAdditionalByType(device, nullptr, {GNE_TAG_JPS_OBSTACLE});
2277 // close device
2278 device.close();
2279 // set focus again in net
2280 myApplicationWindow->getViewNet()->setFocus();
2281 return true;
2282}
2283
2284
2285bool
2287 // first recompute demand elements
2289 // obtain invalid demandElements depending of number of their parent lanes
2290 std::vector<GNEDemandElement*> invalidSingleLaneDemandElements;
2291 // iterate over demandElements and obtain invalids
2292 for (const auto& demandElementSet : myAttributeCarriers->getDemandElements()) {
2293 for (const auto& demandElement : demandElementSet.second) {
2294 // compute before check if demand element is valid
2295 demandElement.second->computePathElement();
2296 // check if has to be fixed
2297 if (demandElement.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
2298 invalidSingleLaneDemandElements.push_back(demandElement.second);
2299 }
2300 }
2301 }
2302 // if there are invalid demand elements, open GNEFixDemandElementsDialog
2303 if (invalidSingleLaneDemandElements.size() > 0) {
2304 // open fix demand elements dialog
2305 const GNEFixDemandElementsDialog fixDemandElement(myApplicationWindow, invalidSingleLaneDemandElements);
2306 if (fixDemandElement.getResult() != GNEDialog::Result::ACCEPT) {
2307 return false;
2308 }
2309 }
2310 // Start saving additionals
2311 myApplicationWindow->getApp()->beginWaitCursor();
2312 // iterate over all elements and save files
2314 // only write buckets with elements
2315 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2316 // open file
2317 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2318 // open header
2319 device.writeXMLHeader("routes", "routes_file.xsd", EMPTY_HEADER, false);
2320 // save additionals, demand elements and meanDatas
2321 writeAdditionalFileElements(device, bucket);
2322 // close device
2323 device.close();
2324 }
2325 }
2326 // mark demand elements as saved
2328 // end saving additionals
2329 myApplicationWindow->getApp()->endWaitCursor();
2330 return true;
2331}
2332
2333
2334bool
2336 // first recompute data sets
2338 // Start saving data elements
2339 myApplicationWindow->getApp()->beginWaitCursor();
2340 // iterate over all elements and save files
2342 // only write buckets with elements
2343 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2344 // open file
2345 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2346 // write header
2347 device.writeXMLHeader("data", "datamode_file.xsd", EMPTY_HEADER, false);
2348 for (const auto& dataSet : myAttributeCarriers->getDataSets()) {
2349 if (dataSet.second->getFileBucket() == bucket) {
2350 dataSet.second->writeDataSet(device);
2351 }
2352 }
2353 // close device
2354 device.close();
2355 }
2356 }
2357 // mark data element as saved
2359 // end saving additionals
2360 myApplicationWindow->getApp()->endWaitCursor();
2361 return true;
2362}
2363
2364
2365double
2367 double minimumBegin = 0;
2368 // update with first minimum (if exist)
2369 if (myAttributeCarriers->getDataIntervals().size() > 0) {
2370 minimumBegin = myAttributeCarriers->getDataIntervals().begin()->second->getAttributeDouble(SUMO_ATTR_BEGIN);
2371 }
2372 // iterate over interval
2373 for (const auto& interval : myAttributeCarriers->getDataIntervals()) {
2374 if (interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) < minimumBegin) {
2375 minimumBegin = interval.second->getAttributeDouble(SUMO_ATTR_BEGIN);
2376 }
2377 }
2378 return minimumBegin;
2379}
2380
2381
2382double
2384 double maximumEnd = 0;
2385 // update with first maximum (if exist)
2386 if (myAttributeCarriers->getDataIntervals().size() > 0) {
2387 maximumEnd = myAttributeCarriers->getDataIntervals().begin()->second->getAttributeDouble(SUMO_ATTR_END);
2388 }
2389 // iterate over intervals
2390 for (const auto& interval : myAttributeCarriers->getDataIntervals()) {
2391 if (interval.second->getAttributeDouble(SUMO_ATTR_END) > maximumEnd) {
2392 maximumEnd = interval.second->getAttributeDouble(SUMO_ATTR_END);
2393 }
2394 }
2395 return maximumEnd;
2396}
2397
2398
2399bool
2401 // Start saving additionals
2402 myApplicationWindow->getApp()->beginWaitCursor();
2403 // iterate over all elements and save files
2405 // only write buckets with elements
2406 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2407 // open file
2408 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2409 // open header
2410 device.writeXMLHeader("additional", "additional_file.xsd", EMPTY_HEADER, false);
2411 // save additionals, demand elements and meanDatas
2412 writeAdditionalFileElements(device, bucket);
2413 // close device
2414 device.close();
2415 }
2416 }
2417 // mark mean datas as saved
2419 // end saving additionals
2420 myApplicationWindow->getApp()->endWaitCursor();
2421 return true;
2422}
2423
2424
2425void
2427 // 1) stoppingPlaces
2428 writeStoppingPlaceComment(device, fileBucket);
2429 writeAdditionalByType(device, fileBucket, {SUMO_TAG_BUS_STOP});
2430 writeAdditionalByType(device, fileBucket, {SUMO_TAG_TRAIN_STOP});
2431 writeAdditionalByType(device, fileBucket, {SUMO_TAG_CONTAINER_STOP});
2432 writeAdditionalByType(device, fileBucket, {SUMO_TAG_PARKING_AREA});
2433 writeAdditionalByType(device, fileBucket, {SUMO_TAG_CHARGING_STATION});
2434 // detectors
2435 writeDetectorComment(device, fileBucket);
2436 writeAdditionalByType(device, fileBucket, {SUMO_TAG_INDUCTION_LOOP});
2440 // variable speed signs
2441 writeVariableSpeedSignComment(device, fileBucket);
2442 writeAdditionalByType(device, fileBucket, {SUMO_TAG_VSS});
2443 // routeProbes
2444 writeRouteProbeComment(device, fileBucket);
2445 writeAdditionalByType(device, fileBucket, {SUMO_TAG_ROUTEPROBE});
2446 // vaporizers
2447 writeVaporizerComment(device, fileBucket);
2448 writeAdditionalByType(device, fileBucket, {SUMO_TAG_VAPORIZER});
2449 // Wire element
2450 writeWireComment(device, fileBucket);
2454 // shapes
2455 writeShapesComment(device, fileBucket);
2456 writeAdditionalByType(device, fileBucket, {SUMO_TAG_POLY});
2458 // juPedSim elements
2459 writeJuPedSimComment(device, fileBucket);
2460 writeAdditionalByType(device, fileBucket, {GNE_TAG_JPS_WALKABLEAREA});
2461 writeAdditionalByType(device, fileBucket, {GNE_TAG_JPS_OBSTACLE});
2462 // TAZs
2463 writeTAZComment(device, fileBucket);
2464 writeAdditionalByType(device, fileBucket, {SUMO_TAG_TAZ});
2465 // vtypes
2466 writeVTypeComment(device, fileBucket);
2467 writeVTypes(device, fileBucket);
2468 writeVTypeDistributions(device, fileBucket);
2469 // now write all routes (and their associated stops), except routes with additional children (due routeProbReroutes)
2470 writeRouteComment(device, fileBucket);
2471 writeRoutes(device, fileBucket);
2472 writeRouteDistributions(device, fileBucket);
2473 // sort vehicles/persons by depart
2474 std::map<double, std::map<std::pair<SumoXMLTag, std::string>, GNEDemandElement*> > vehiclesSortedByDepart;
2475 for (const auto& demandElementTag : myAttributeCarriers->getDemandElements()) {
2476 for (const auto& demandElement : demandElementTag.second) {
2477 if ((demandElement.second->getFileBucket() == fileBucket) &&
2478 (demandElement.second->getTagProperty()->isVehicle() || demandElement.second->getTagProperty()->isPerson() || demandElement.second->getTagProperty()->isContainer())) {
2479 vehiclesSortedByDepart[demandElement.second->getAttributeDouble(SUMO_ATTR_DEPART)][std::make_pair(demandElement.second->getTagProperty()->getTag(), demandElement.second->getID())] = demandElement.second;
2480 }
2481 }
2482 }
2483 // finally write all vehicles, persons and containers sorted by depart time (and their associated stops, personPlans, etc.)
2484 if (vehiclesSortedByDepart.size() > 0) {
2485 device << (" <!-- Vehicles, persons and containers (sorted by depart) -->\n");
2486 for (const auto& vehicleTag : vehiclesSortedByDepart) {
2487 for (const auto& vehicle : vehicleTag.second) {
2488 vehicle.second->writeDemandElement(device);
2489 }
2490 }
2491 }
2492 // calibrator
2493 writeCalibratorComment(device, fileBucket);
2495 // rerouters
2496 writeRerouterComment(device, fileBucket);
2497 writeAdditionalByType(device, fileBucket, {SUMO_TAG_REROUTER});
2498 // MeanDataEdges
2499 writeMeanDataEdgeComment(device, fileBucket);
2500 writeMeanDatas(device, fileBucket, SUMO_TAG_MEANDATA_EDGE);
2501 // MeanDataLanes
2502 writeMeanDataLaneComment(device, fileBucket);
2503 writeMeanDatas(device, fileBucket, SUMO_TAG_MEANDATA_LANE);
2504}
2505
2506
2507void
2508GNENet::writeAdditionalByType(OutputDevice& device, const FileBucket* fileBucket, const std::vector<SumoXMLTag> tags) const {
2509 std::map<std::string, std::vector<GNEAdditional*> > sortedAdditionals;
2510 for (const auto& tag : tags) {
2511 for (const auto& additional : myAttributeCarriers->getAdditionals().at(tag)) {
2512 if ((fileBucket == nullptr) || (additional.second->getFileBucket() == fileBucket)) {
2513 if ((tag == SUMO_TAG_VAPORIZER) || (sortedAdditionals.count(additional.second->getID()) == 0)) {
2514 sortedAdditionals[additional.second->getID()].push_back(additional.second);
2515 } else {
2516 throw ProcessError(TL("Duplicated ID"));
2517 }
2518 }
2519 }
2520 }
2521 for (const auto& additionalVector : sortedAdditionals) {
2522 for (const auto& additional : additionalVector.second) {
2523 additional->writeAdditional(device);
2524 }
2525 }
2526}
2527
2528
2529void
2530GNENet::writeDemandByType(OutputDevice& device, const FileBucket* fileBucket, SumoXMLTag tag) const {
2531 std::map<std::string, GNEDemandElement*> sortedDemandElements;
2532 for (const auto& demandElement : myAttributeCarriers->getDemandElements().at(tag)) {
2533 if (demandElement.second->getFileBucket() == fileBucket) {
2534 sortedDemandElements[demandElement.second->getID()] = demandElement.second;
2535 }
2536 }
2537 for (const auto& demandElement : sortedDemandElements) {
2538 demandElement.second->writeDemandElement(device);
2539 }
2540}
2541
2542
2543void
2545 std::map<std::string, GNEDemandElement*> sortedElements;
2546 // first write route Distributions
2547 for (const auto& routeDistribution : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE_DISTRIBUTION)) {
2548 if (routeDistribution.second->getFileBucket() == fileBucket) {
2549 sortedElements[routeDistribution.second->getID()] = routeDistribution.second;
2550 }
2551 }
2552 for (const auto& element : sortedElements) {
2553 element.second->writeDemandElement(device);
2554 }
2555}
2556
2557
2558void
2559GNENet::writeRoutes(OutputDevice& device, const FileBucket* fileBucket) const {
2560 std::map<std::string, GNEDemandElement*> sortedRoutes;
2561 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
2562 if (route.second->getFileBucket() == fileBucket) {
2563 sortedRoutes[route.second->getID()] = route.second;
2564 }
2565 }
2566 for (const auto& route : sortedRoutes) {
2567 route.second->writeDemandElement(device);
2568 }
2569}
2570
2571
2572void
2574 std::map<std::string, GNEDemandElement*> sortedElements;
2575 // first write vType Distributions
2576 for (const auto& vTypeDistribution : myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE_DISTRIBUTION)) {
2577 if (vTypeDistribution.second->getFileBucket() == fileBucket) {
2578 sortedElements[vTypeDistribution.second->getID()] = vTypeDistribution.second;
2579 }
2580 }
2581 for (const auto& element : sortedElements) {
2582 element.second->writeDemandElement(device);
2583 }
2584}
2585
2586
2587void
2588GNENet::writeVTypes(OutputDevice& device, const FileBucket* fileBucket) const {
2589 std::map<std::string, GNEDemandElement*> sortedVTypes;
2590 for (const auto& vType : myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE)) {
2591 if (vType.second->getFileBucket() == fileBucket) {
2592 sortedVTypes[vType.second->getID()] = vType.second;
2593 }
2594 }
2595 for (const auto& vType : sortedVTypes) {
2596 vType.second->writeDemandElement(device);
2597 }
2598}
2599
2600
2601void
2602GNENet::writeMeanDatas(OutputDevice& device, const FileBucket* fileBucket, SumoXMLTag tag) const {
2603 std::map<std::string, GNEMeanData*> sortedMeanDatas;
2604 for (const auto& meanData : myAttributeCarriers->getMeanDatas().at(tag)) {
2605 if (meanData.second->getFileBucket() == fileBucket) {
2606 if (sortedMeanDatas.count(meanData.second->getID()) == 0) {
2607 sortedMeanDatas[meanData.second->getID()] = meanData.second;
2608 } else {
2609 throw ProcessError(TL("Duplicated ID"));
2610 }
2611 }
2612 }
2613 for (const auto& additional : sortedMeanDatas) {
2614 additional.second->writeMeanData(device);
2615 }
2616}
2617
2618bool
2619GNENet::writeVTypeComment(OutputDevice& device, const FileBucket* fileBucket) const {
2620 // vTypes
2621 for (const auto& vType : myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE)) {
2622 // special case for default vTypes
2623 const bool defaultVType = GNEAttributeCarrier::parse<bool>(vType.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE));
2624 const bool defaultVTypeModified = GNEAttributeCarrier::parse<bool>(vType.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE_MODIFIED));
2625 // only write default vType modified
2626 if ((vType.second->getParentDemandElements().size() == 0) && (!defaultVType || (defaultVType && defaultVTypeModified))) {
2627 if (vType.second->getFileBucket() == fileBucket) {
2628 device << (" <!-- VTypes -->\n");
2629 return true;
2630 }
2631 }
2632 }
2633 return false;
2634}
2635
2636
2637bool
2638GNENet::writeRouteComment(OutputDevice& device, const FileBucket* fileBucket) const {
2639 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
2640 if (route.second->getFileBucket() == fileBucket) {
2641 device << (" <!-- Routes -->\n");
2642 return true;
2643 }
2644 }
2645 return false;
2646}
2647
2648
2649bool
2650GNENet::writeRerouterComment(OutputDevice& device, const FileBucket* fileBucket) const {
2651 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_REROUTER)) {
2652 if (routeProbe.second->getFileBucket() == fileBucket) {
2653 device << (" <!-- Rerouter -->\n");
2654 return true;
2655 }
2656 }
2657 return false;
2658}
2659
2660
2661bool
2663 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_VSS)) {
2664 if (routeProbe.second->getFileBucket() == fileBucket) {
2665 device << (" <!-- VariableSpeedSigns -->\n");
2666 return true;
2667 }
2668 }
2669 return false;
2670}
2671
2672
2673bool
2674GNENet::writeRouteProbeComment(OutputDevice& device, const FileBucket* fileBucket) const {
2675 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_ROUTEPROBE)) {
2676 if (routeProbe.second->getFileBucket() == fileBucket) {
2677 device << (" <!-- RouteProbes -->\n");
2678 return true;
2679 }
2680 }
2681 return false;
2682}
2683
2684
2685bool
2686GNENet::writeVaporizerComment(OutputDevice& device, const FileBucket* fileBucket) const {
2687 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_VAPORIZER)) {
2688 if (routeProbe.second->getFileBucket() == fileBucket) {
2689 device << (" <!-- Vaporizers -->\n");
2690 return true;
2691 }
2692 }
2693 return false;
2694}
2695
2696
2697bool
2698GNENet::writeCalibratorComment(OutputDevice& device, const FileBucket* fileBucket) const {
2699 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2700 for (const auto& additional : additionalTag.second) {
2701 if (additional.second->getTagProperty()->isCalibrator() &&
2702 (additional.second->getFileBucket() == fileBucket)) {
2703 device << (" <!-- Calibrators -->\n");
2704 return true;
2705 }
2706 }
2707 }
2708 return false;
2709}
2710
2711
2712bool
2714 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2715 for (const auto& additional : additionalTag.second) {
2716 if (additional.second->getTagProperty()->isStoppingPlace() &&
2717 (additional.second->getFileBucket() == fileBucket)) {
2718 device << (" <!-- StoppingPlaces -->\n");
2719 return true;
2720 }
2721 }
2722 }
2723 return false;
2724}
2725
2726
2727bool
2728GNENet::writeDetectorComment(OutputDevice& device, const FileBucket* fileBucket) const {
2729 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2730 for (const auto& additional : additionalTag.second) {
2731 if (additional.second->getTagProperty()->isDetector() &&
2732 (additional.second->getFileBucket() == fileBucket)) {
2733 device << (" <!-- Detectors -->\n");
2734 return true;
2735 }
2736 }
2737 }
2738 return false;
2739}
2740
2741
2742bool
2743GNENet::writeShapesComment(OutputDevice& device, const FileBucket* fileBucket) const {
2744 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2745 for (const auto& additional : additionalTag.second) {
2746 if (additional.second->getTagProperty()->isShapeElement() &&
2747 (additional.second->getFileBucket() == fileBucket) &&
2748 !additional.second->getTagProperty()->isJuPedSimElement()) {
2749 device << (" <!-- Shapes -->\n");
2750 return true;
2751 }
2752 }
2753 }
2754 return false;
2755}
2756
2757
2758bool
2759GNENet::writeJuPedSimComment(OutputDevice& device, const FileBucket* fileBucket) const {
2760 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2761 for (const auto& additional : additionalTag.second) {
2762 if (additional.second->getTagProperty()->isJuPedSimElement() &&
2763 ((fileBucket == nullptr) || (additional.second->getFileBucket() == fileBucket))) {
2764 device << (" <!-- JuPedSim elements -->\n");
2765 return true;
2766 }
2767 }
2768 }
2769 return false;
2770}
2771
2772
2773bool
2774GNENet::writeTAZComment(OutputDevice& device, const FileBucket* fileBucket) const {
2775 for (const auto& TAZ : myAttributeCarriers->getAdditionals().at(SUMO_TAG_TAZ)) {
2776 if (TAZ.second->getFileBucket() == fileBucket) {
2777 device << (" <!-- TAZs -->\n");
2778 return true;
2779 }
2780 }
2781 return false;
2782}
2783
2784
2785bool
2786GNENet::writeWireComment(OutputDevice& device, const FileBucket* fileBucket) const {
2787 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2788 for (const auto& additional : additionalTag.second) {
2789 if (additional.second->getTagProperty()->isWireElement() &&
2790 (additional.second->getFileBucket() == fileBucket)) {
2791 device << (" <!-- Wires -->\n");
2792 return true;
2793 }
2794 }
2795 }
2796 return false;
2797}
2798
2799
2800bool
2802 for (const auto& meanDataEdge : myAttributeCarriers->getMeanDatas().at(SUMO_TAG_MEANDATA_EDGE)) {
2803 if (meanDataEdge.second->getFileBucket() == fileBucket) {
2804 device << (" <!-- MeanDataEdges -->\n");
2805 return true;
2806 }
2807 }
2808 return false;
2809}
2810
2811
2812bool
2814 for (const auto& meanDataLane : myAttributeCarriers->getMeanDatas().at(SUMO_TAG_MEANDATA_LANE)) {
2815 if (meanDataLane.second->getFileBucket() == fileBucket) {
2816 device << (" <!-- MeanDataLanes -->\n");
2817 return true;
2818 }
2819 }
2820 return false;
2821}
2822
2823
2824void
2825GNENet::saveTLSPrograms(const std::string& filename) {
2826 // open output device
2827 OutputDevice& device = OutputDevice::getDevice(filename);
2828 device.openTag("additionals");
2829 // write traffic lights using NWWriter
2831 device.close();
2832 // change save status
2834}
2835
2836
2837int
2839 return -1;
2840}
2841
2842
2843void
2844GNENet::saveEdgeTypes(const std::string& filename) {
2845 // first clear typeContainer
2847 // now update typeContainer with edgeTypes
2848 for (const auto& edgeType : myAttributeCarriers->getEdgeTypes()) {
2849 myNetBuilder->getTypeCont().insertEdgeType(edgeType.first, edgeType.second);
2850 for (int i = 0; i < (int)edgeType.second->getLaneTypes().size(); i++) {
2851 myNetBuilder->getTypeCont().insertLaneType(edgeType.first, i,
2852 edgeType.second->getLaneTypes().at(i)->speed,
2853 edgeType.second->getLaneTypes().at(i)->permissions,
2854 edgeType.second->getLaneTypes().at(i)->width,
2855 edgeType.second->getLaneTypes().at(i)->attrs);
2856 }
2857 }
2858 // open device
2859 OutputDevice& device = OutputDevice::getDevice(filename);
2860 // open tag
2861 device.openTag(SUMO_TAG_TYPES);
2862 // write edge types
2864 // close tag
2865 device.closeTag();
2866 // close device
2867 device.close();
2868}
2869
2870
2871void
2875
2876
2877void
2881
2882
2883bool
2887
2888
2889void
2891 myUpdateDataEnabled = true;
2892 // update data elements
2893 for (const auto& dataInterval : myAttributeCarriers->getDataIntervals()) {
2894 dataInterval.second->updateGenericDataIDs();
2895 dataInterval.second->updateAttributeColors();
2896 }
2897}
2898
2899
2900void
2904
2905
2906bool
2910
2911
2912unsigned int&
2916
2917
2918unsigned int&
2922
2923// ===========================================================================
2924// private
2925// ===========================================================================
2926
2927void
2929 // init edge types
2930 for (const auto& edgeType : myNetBuilder->getTypeCont()) {
2931 // register edge type
2932 myAttributeCarriers->registerEdgeType(new GNEEdgeType(this, edgeType.first, edgeType.second));
2933 }
2934 // init junctions (by default Crossing and walking areas aren't created)
2935 for (const auto& nodeName : myNetBuilder->getNodeCont().getAllNames()) {
2936 // create and register junction
2938 }
2939 // init edges
2940 for (const auto& edgeName : myNetBuilder->getEdgeCont().getAllNames()) {
2941 // create edge using NBEdge
2942 GNEEdge* edge = new GNEEdge(this, myNetBuilder->getEdgeCont().retrieve(edgeName), false, true);
2943 // register edge
2945 // add manually child references due initJunctionsAndEdges doesn't use undo-redo
2946 edge->getFromJunction()->addChildElement(edge);
2947 edge->getToJunction()->addChildElement(edge);
2948 // check grid
2949 if (myGrid.getWidth() > 10e16 || myGrid.getHeight() > 10e16) {
2950 throw ProcessError(TL("Network size exceeds 1 Lightyear. Please reconsider your inputs.") + std::string("\n"));
2951 }
2952 }
2953 // make sure myGrid is initialized even for an empty net. This ensure that the network starts with a zoom of 100
2954 if (myAttributeCarriers->getEdges().size() == 0) {
2955 myGrid.add(Boundary(-50, -50, 50, 50));
2956 }
2957 // recalculate all lane2lane connections
2958 for (const auto& edge : myAttributeCarriers->getEdges()) {
2959 for (const auto& lane : edge.second->getChildLanes()) {
2960 lane->updateGeometry();
2961 }
2962 }
2963 // sort nodes edges so that arrows can be drawn correctly
2965}
2966
2967
2968void
2970 for (const auto& edge : myAttributeCarriers->getEdges()) {
2971 // remake connections
2972 edge.second->remakeGNEConnections();
2973 // update geometry of connections
2974 for (const auto& connection : edge.second->getGNEConnections()) {
2975 connection->updateGeometry();
2976 }
2977 }
2978}
2979
2980
2981void
2982GNENet::computeAndUpdate(OptionsCont& neteditOptions, bool volatileOptions) {
2983 // make sure we only add turn arounds to edges which currently exist within the network
2984 std::set<std::string> liveExplicitTurnarounds;
2985 for (const auto& explicitTurnarounds : myExplicitTurnarounds) {
2986 if (myAttributeCarriers->getEdges().count(explicitTurnarounds) > 0) {
2987 liveExplicitTurnarounds.insert(explicitTurnarounds);
2988 }
2989 }
2990 // removes all junctions of grid
2991 for (const auto& junction : myAttributeCarriers->getJunctions()) {
2992 removeGLObjectFromGrid(junction.second);
2993 }
2994 // remove all edges from grid
2995 for (const auto& edge : myAttributeCarriers->getEdges()) {
2996 removeGLObjectFromGrid(edge.second);
2997 }
2998 // compute using NetBuilder
2999 myNetBuilder->compute(neteditOptions, liveExplicitTurnarounds, volatileOptions);
3000 // remap ids if necessary
3001 if (neteditOptions.getBool("numerical-ids") || neteditOptions.isSet("reserved-ids")) {
3003 }
3004 // update rtree if necessary
3005 if (!neteditOptions.getBool("offset.disable-normalization")) {
3006 for (const auto& edge : myAttributeCarriers->getEdges()) {
3007 // refresh edge geometry
3008 edge.second->updateGeometry();
3009 }
3010 }
3011 // Clear current inspected ACs in inspectorFrame if a previous net was loaded
3012 if (myApplicationWindow->getViewNet() != nullptr) {
3014 }
3015 // Reset Grid
3016 myGrid.reset();
3018 // if volatile options are true
3019 if (volatileOptions) {
3020 // check that net exist
3021 if (myApplicationWindow->getViewNet() == nullptr) {
3022 throw ProcessError("ViewNet doesn't exist");
3023 }
3024 // disable update geometry before clear undo list
3026 // destroy Popup
3028 // clear undo list (This will be remove additionals and shapes)
3030 // clear all elements (it will also removed from grid)
3035 // enable update geometry again
3037 // init again junction an edges (Additionals and shapes will be loaded after the end of this function)
3039 // init default vTypes again
3041 } else {
3042 // insert all junctions of grid again
3043 for (const auto& junction : myAttributeCarriers->getJunctions()) {
3044 // update centering boundary
3045 junction.second->updateCenteringBoundary(false);
3046 // add junction in grid again
3047 addGLObjectIntoGrid(junction.second);
3048 }
3049 // insert all edges from grid again
3050 for (const auto& edge : myAttributeCarriers->getEdges()) {
3051 // update centeting boundary
3052 edge.second->updateCenteringBoundary(false);
3053 // add edge in grid again
3054 addGLObjectIntoGrid(edge.second);
3055 }
3056 // remake connections
3057 for (const auto& edge : myAttributeCarriers->getEdges()) {
3058 edge.second->remakeGNEConnections(true);
3059 }
3060 // iterate over junctions of net
3061 for (const auto& junction : myAttributeCarriers->getJunctions()) {
3062 // undolist may not yet exist but is also not needed when just marking junctions as valid
3063 junction.second->setLogicValid(true, nullptr);
3064 // updated geometry
3065 junction.second->updateGeometryAfterNetbuild();
3066 // rebuild walking areas
3067 junction.second->rebuildGNEWalkingAreas();
3068 }
3069 // iterate over all edges of net
3070 for (const auto& edge : myAttributeCarriers->getEdges()) {
3071 // update geometry
3072 edge.second->updateGeometry();
3073 }
3074 }
3075 // net recomputed, then return false;
3076 myNeedRecompute = false;
3077}
3078
3079
3080void
3081GNENet::replaceInListAttribute(GNEAttributeCarrier* ac, SumoXMLAttr key, const std::string& which, const std::string& by, GNEUndoList* undoList) {
3082 assert(ac->getTagProperty()->getAttributeProperties(key)->isList());
3083 std::vector<std::string> values = GNEAttributeCarrier::parse<std::vector<std::string> >(ac->getAttribute(key));
3084 std::vector<std::string> newValues;
3085 bool lastBy = false;
3086 for (auto v : values) {
3087 if (v == which && !lastBy) {
3088 // avoid duplicate occurence of the 'by' edge (i.e. in routes)
3089 newValues.push_back(by);
3090 } else {
3091 newValues.push_back(v);
3092 }
3093 lastBy = v == by;
3094 }
3095 ac->setAttribute(key, toString(newValues), undoList);
3096}
3097
3098
3099/****************************************************************************/
@ MID_COPY_VIEW_GEOBOUNDARY
Copy view geo-coordinate boundary - popup entry.
Definition GUIAppEnum.h:467
@ GLO_NETWORK
The network - empty.
@ MODEPERSONPLAN
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:304
std::set< NBEdge * > EdgeSet
container for unique edges
Definition NBCont.h:50
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition NBCont.h:42
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ 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_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_MEANDATA_LANE
a lane based mean data detector
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_OVERHEAD_WIRE_CLAMP
An overhead wire clamp (connection of wires in opposite directions)
@ 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_CONNECTION
connectioon between two lanes
@ SUMO_TAG_PARKING_AREA
A parking area.
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_TYPES
types (edge)
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_TAG_ROUTE
description of a route
@ SUMO_TAG_MEANDATA_EDGE
an edge based mean data detector
@ 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_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ GNE_TAG_POILANE
Point of interest over Lane.
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ SUMO_TAG_PERSON
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ 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.
@ GNE_TAG_STOPPERSON_EDGE
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
@ STRAIGHT
The link is a straight direction.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_VIA
@ GNE_ATTR_OPPOSITE
to busStop (used by personPlans)
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_NUMLANES
@ GNE_ATTR_DEFAULT_VTYPE
Flag to check if VType is a default VType.
@ GNE_ATTR_MODIFICATION_STATUS
whether a feature has been loaded,guessed,modified or approved
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_TLTYPE
node: the type of traffic light
@ SUMO_ATTR_ENDOFFSET
@ GNE_ATTR_SHAPE_END
last coordinate of edge shape
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_ID
@ GNE_ATTR_DEFAULT_VTYPE_MODIFIED
Flag to check if a default VType was modified.
@ GNE_ATTR_SHAPE_START
first coordinate of edge shape
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_POSITION
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
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
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
void reset()
Resets the boundary.
Definition Boundary.cpp:63
double getHeight() const
Returns the height of the boundary (y-axis)
Definition Boundary.cpp:157
double getWidth() const
Returns the width of the boudary (x-axis)
Definition Boundary.cpp:151
bool parse()
parse
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:952
std::string getDefaultFilename(const FileBucket::Type type) const
functions related with filenames
const std::vector< FileBucket * > & getFileBuckets(const FileBucket::Type type) const
get vector with all fileBuckets related with the given file type
OptionsCont & getSumoOptions()
get SUMO options container
void setStatusBarText(const std::string &statusBarText)
set text of the statusBar
GNEUndoList * getUndoList()
get pointer to undoList
GNEViewNet * getViewNet()
get pointer to viewNet
GNEApplicationWindowHelper::FileBucketHandler * getFileBucketHandler() const
get file bucket handler
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void setInGrid(bool value)
mark if this AC was inserted in grid or not
static const std::string FALSE_STR
true value in string format(used for comparing boolean values in getAttribute(...))
const std::string getID() const override
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool inGrid() const
check if this AC was inserted in grid
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual GUIGlObject * getGUIGlObject()=0
get GUIGlObject associated with this AttributeCarrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
static void registerJoin(const std::set< NBNode *, ComparatorIdLess > &cluster, NBNodeCont &nc, GNEUndoList *undoList)
change attribute
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
NBConnection getNBConnection() const
get NBConnection
GNEEdge * getEdgeFrom() const
get the name of the edge the vehicles leave
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
NBNode::Crossing * getNBCrossing() const
get referente to NBode::Crossing
GNEDataSet * getDataSetParent() const
Returns a pointer to GNEDataSet parent.
const std::vector< GNEGenericData * > & getGenericDataChildren() const
get generic data children
const std::map< const double, GNEDataInterval * > & getDataIntervalChildren() const
get data interval children
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
Result getResult() const
get result to indicate if this dialog was closed accepting or rejecting changes
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNEEdge.cpp:1230
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:755
GNEEdge * getReverseEdge() const
get reverse edge (if exist)
Definition GNEEdge.cpp:1768
std::vector< GNEEdge * > getOppositeEdges() const
get opposite edges
Definition GNEEdge.cpp:689
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:87
bool wasSplit()
whether this edge was created from a split
Definition GNEEdge.cpp:1095
void copyTemplate(const GNEEdgeTemplate *edgeTemplate, GNEUndoList *undoList)
copy edge attributes from edgetemplate
Definition GNEEdge.cpp:1024
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition GNEEdge.cpp:1089
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:92
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEEdge.cpp:1101
GNEDataInterval * getDataIntervalParent() const
get data interval parent
const GNEHierarchicalContainerChildren< GNEEdge * > & getChildEdges() const
get child edges
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerChildren< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
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)
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
void clearInspection()
clear inspection
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Position getPositionInView() const
Returns position of hierarchical element in view.
bool isValid(SumoXMLAttr key, const std::string &value) override
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
NBNode * getNBNode() const
Return net build node.
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:624
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition GNELane.cpp:1938
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNELane.cpp:763
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
modul for AC Templates
void buildTemplates()
build templates
struct used for saving all attribute carriers of net, in different formats
std::vector< GNEEdge * > retrieveEdges(GNEJunction *from, GNEJunction *to) const
get all edges by from and to GNEJunction
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * >, std::hash< int > > & getDemandElements() const
get demand elements
GNEEdgeType * registerEdgeType(GNEEdgeType *edgeType)
registers a edge in containers
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
void clearDemandElements()
clear demand elements
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with containers
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * >, std::hash< int > > & getGenericDatas() const
get all generic datas
GNECrossing * retrieveCrossing(const GUIGlObject *glObject, bool hardFail=true) const
get Crossing by AC
void remapJunctionAndEdgeIds()
remap junction and edge IDs
std::string generateEdgeID() const
generate edge ID
void clearAdditionals()
clear additionals
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction in containers
const std::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * >, std::hash< int > > & getMeanDatas() const
get meanDatas
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
const std::map< const std::string, GNEDataSet * > & getDataSets() const
get demand elements
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
void addDefaultVTypes()
add default VTypes
std::vector< GNEJunction * > getSelectedJunctions() const
return selected junctions
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
const std::unordered_map< const GNEAttributeCarrier *, GNEDataInterval * > & getDataIntervals() const
get all data intervals of network
const std::map< std::string, GNEJunction * > & getJunctions() const
get junctions
const std::map< std::string, GNEEdgeType * > & getEdgeTypes() const
map with the ID and pointer to edgeTypes of net
void clearJunctions()
clear junctions
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * >, std::hash< int > > & getAdditionals() const
get additionals
GNEConnection * retrieveConnection(const std::string &id, bool hardFail=true) const
get Connection by id
class for GNEChange_ReplaceEdgeInTLS
modul for Saving status
void dataElementsSaved()
mark demand elements as saved
void demandElementsSaved()
mark demand elements as saved
void additionalsSaved()
mark additionals as saved
void TLSSaved()
mark TLS as saved
void meanDatasSaved()
mark mean data elements as saved
void networkSaved()
mark network as saved
void clearAdditionalElements(GNEUndoList *undoList)
clear additionals
Definition GNENet.cpp:2132
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition GNENet.cpp:1789
GNEPathManager * myDataPathManager
Data path manager.
Definition GNENet.h:533
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList, bool recomputeConnections)
removes edge
Definition GNENet.cpp:485
void writeAdditionalByType(OutputDevice &device, const FileBucket *fileBucket, const std::vector< SumoXMLTag > tags) const
write additional element by type and sorted by ID
Definition GNENet.cpp:2508
bool joinSelectedJunctions(GNEUndoList *undoList)
join selected junctions
Definition GNENet.cpp:1629
bool writeJuPedSimComment(OutputDevice &device, const FileBucket *fileBucket) const
write JuPedSim comment
Definition GNENet.cpp:2759
double getDataSetIntervalMaximumEnd() const
get maximum interval
Definition GNENet.cpp:2383
void deleteLane(GNELane *lane, GNEUndoList *undoList, bool recomputeConnections)
removes lane
Definition GNENet.cpp:664
static const double Z_INITIALIZED
marker for whether the z-boundary is initialized
Definition GNENet.h:639
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition GNENet.cpp:721
SUMORTree & getGrid()
Returns the RTree used for visualisation speed-up.
Definition GNENet.cpp:217
bool writeRouteProbeComment(OutputDevice &device, const FileBucket *fileBucket) const
write routeProbe comment
Definition GNENet.cpp:2674
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition GNENet.cpp:739
bool saveMeanDatas()
save meanData elements of the network
Definition GNENet.cpp:2400
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition GNENet.cpp:2878
void saveTLSPrograms(const std::string &filename)
save TLS Programs elements of the network
Definition GNENet.cpp:2825
void computeAndUpdate(OptionsCont &neteditOptions, bool volatileOptions)
recompute the network and update lane geometries
Definition GNENet.cpp:2982
NBNetBuilder * getNetBuilder() const
get net builder
Definition GNENet.cpp:168
void writeVTypeDistributions(OutputDevice &device, const FileBucket *fileBucket) const
write vTypeDistributions sorted by ID
Definition GNENet.cpp:2573
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1447
GNEPathManager * getDataPathManager()
get data path manager
Definition GNENet.cpp:204
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition GNENet.cpp:1141
bool writeTAZComment(OutputDevice &device, const FileBucket *fileBucket) const
write TAZ comment
Definition GNENet.cpp:2774
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1457
void saveJoined(const std::string &filename)
save log of joined junctions (and nothing else)
Definition GNENet.cpp:1439
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition GNENet.cpp:2200
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition GNENet.cpp:880
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:186
void enableUpdateData()
Definition GNENet.cpp:2890
void mergeJunctions(GNEJunction *moved, const GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition GNENet.cpp:1195
void writeAdditionalFileElements(OutputDevice &device, const FileBucket *fileBucket)
write additionals demand elements and meanData in output device
Definition GNENet.cpp:2426
bool myNeedRecompute
whether the net needs recomputation
Definition GNENet.h:545
void deleteDemandElement(GNEDemandElement *demandElement, GNEUndoList *undoList)
remove demand element
Definition GNENet.cpp:773
void duplicateLane(GNELane *lane, GNEUndoList *undoList, bool recomputeConnections)
duplicates lane
Definition GNENet.cpp:864
const Boundary & getZBoundary() const
Returns the Z boundary (stored in the x() coordinate) values of 0 do not affect the boundary.
Definition GNENet.cpp:270
const Boundary & getBoundary() const
returns the bounder of the network
Definition GNENet.cpp:210
void saveEdgeTypes(const std::string &filename)
save edgeTypes elements of the network
Definition GNENet.cpp:2844
void deleteNetworkElement(GNENetworkElement *networkElement, GNEUndoList *undoList)
delete network element
Definition GNENet.cpp:397
void writeMeanDatas(OutputDevice &device, const FileBucket *fileBucket, SumoXMLTag tag) const
write meanData element by type and sorted by ID
Definition GNENet.cpp:2602
bool writeStoppingPlaceComment(OutputDevice &device, const FileBucket *fileBucket) const
write stoppingPlace comment
Definition GNENet.cpp:2713
SUMORTree myGrid
the rtree which contains all GUIGlObjects (so named for historical reasons)
Definition GNENet.h:509
void clearDataElements(GNEUndoList *undoList)
clear data elements
Definition GNENet.cpp:2167
void deleteDataInterval(GNEDataInterval *dataInterval, GNEUndoList *undoList)
remove data interval
Definition GNENet.cpp:812
bool saveDataElements()
save data set elements of the network
Definition GNENet.cpp:2335
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
Definition GNENet.cpp:706
void clearDemandElements(GNEUndoList *undoList)
clear demand elements
Definition GNENet.cpp:2145
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:198
void adjustPersonPlans(GNEUndoList *undoList)
adjust person plans
Definition GNENet.cpp:1895
GNENetHelper::ACTemplate * getACTemplates() const
get all attribute carriers templates used in this net
Definition GNENet.cpp:180
void computeNetwork(GNEApplicationWindow *window, bool force=false, bool volatileOptions=false)
trigger full netbuild computation param[in] window The window to inform about delay param[in] force W...
Definition GNENet.cpp:1467
void cleanInvalidDemandElements(GNEUndoList *undoList)
clean invalid demand elements
Definition GNENet.cpp:1940
bool myUpdateDataEnabled
Flag to enable or disable update data elements after inserting or removing element in net.
Definition GNENet.h:551
void cleanUnusedRoutes(GNEUndoList *undoList)
clean unused routes
Definition GNENet.cpp:1805
NBNetBuilder * myNetBuilder
The internal netbuilder.
Definition GNENet.h:515
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition GNENet.cpp:2218
bool writeCalibratorComment(OutputDevice &device, const FileBucket *fileBucket) const
write calibrator comment
Definition GNENet.cpp:2698
void computeJunction(GNEJunction *junction)
trigger recomputation of junction shape and logic param[in] window The window to inform about delay
Definition GNENet.cpp:1599
void resetJunctionConnections(GNEJunction *junction, GNEUndoList *undoList)
reset junction's connections
Definition GNENet.cpp:2121
bool writeRouteComment(OutputDevice &device, const FileBucket *fileBucket) const
write route comment
Definition GNENet.cpp:2638
void deleteMeanData(GNEMeanData *meanData, GNEUndoList *undoList)
remove generic data
Definition GNENet.cpp:855
void replaceIncomingEdge(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replaces edge
Definition GNENet.cpp:571
void deleteGenericData(GNEGenericData *genericData, GNEUndoList *undoList)
remove generic data
Definition GNENet.cpp:825
std::pair< GNEJunction *, GNEEdge * > splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition GNENet.cpp:1000
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNENet.cpp:258
bool writeShapesComment(OutputDevice &device, const FileBucket *fileBucket) const
write shape comment
Definition GNENet.cpp:2743
bool writeMeanDataEdgeComment(OutputDevice &device, const FileBucket *fileBucket) const
write meanDataEdge comment
Definition GNENet.cpp:2801
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
void writeRoutes(OutputDevice &device, const FileBucket *fileBucket) const
write route sorted by ID
Definition GNENet.cpp:2559
bool writeMeanDataLaneComment(OutputDevice &device, const FileBucket *fileBucket) const
write Wire comment
Definition GNENet.cpp:2813
GNEEdge * addReversedEdge(GNEEdge *edge, const bool disconnected, GNEUndoList *undoList)
add reversed edge
Definition GNENet.cpp:1157
GNEApplicationWindow * getGNEApplicationWindow() const
get tag properties database
Definition GNENet.cpp:138
void changeEdgeEndpoints(GNEEdge *edge, const std::string &newSourceID, const std::string &newDestID)
modifies endpoins of the given edge
Definition GNENet.cpp:2191
bool myUpdateGeometryEnabled
Flag to enable or disable update geometry of elements after inserting or removing element in net.
Definition GNENet.h:548
void initJunctionsAndEdges()
Init Junctions and edges.
Definition GNENet.cpp:2928
void splitEdgesBidi(GNEEdge *edge, GNEEdge *oppositeEdge, const Position &pos, GNEUndoList *undoList)
split all edges at position by inserting one new junction
Definition GNENet.cpp:1117
GNENetHelper::SavingStatus * mySavingStatus
saving status module
Definition GNENet.h:524
void clearMeanDataElements(GNEUndoList *undoList)
clear meanDatas
Definition GNENet.cpp:2178
unsigned int myEdgeIDCounter
Definition GNENet.h:538
void expandBoundary(const Boundary &newBoundary)
expand boundary
Definition GNENet.cpp:264
void writeVTypes(OutputDevice &device, const FileBucket *fileBucket) const
write vTypes sorted by ID
Definition GNENet.cpp:2588
void disableUpdateData()
disable update data elements after inserting or removing an element in net
Definition GNENet.cpp:2901
bool writeRerouterComment(OutputDevice &device, const FileBucket *fileBucket) const
write rerouter comment
Definition GNENet.cpp:2650
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge *edge, GNEUndoList *undoList)
remove restricted lane
Definition GNENet.cpp:986
void deleteTAZSourceSink(GNETAZSourceSink *TAZSourceSink, GNEUndoList *undoList)
remove TAZSourceSink
Definition GNENet.cpp:764
~GNENet()
Destructor.
Definition GNENet.cpp:123
GNEApplicationWindow * myApplicationWindow
pointer to application window
Definition GNENet.h:512
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *edgeTemplate, GNEUndoList *undoList, const std::string &suggestedName="", bool wasSplit=false, bool allowDuplicateGeom=false, bool recomputeConnections=true)
creates a new edge (unless an edge with the same geometry already exists)
Definition GNENet.cpp:304
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition GNENet.h:542
bool saveAdditionals()
save additional elements
Definition GNENet.cpp:2224
const std::map< std::string, int > & getEdgesAndNumberOfLanes() const
et edges and number of lanes
Definition GNENet.cpp:222
void writeRouteDistributions(OutputDevice &device, const FileBucket *fileBucket) const
write route distributions sorted by ID
Definition GNENet.cpp:2544
void addZValueInBoundary(const double z)
add Z in net boundary
Definition GNENet.cpp:276
static const std::map< SumoXMLAttr, std::string > EMPTY_HEADER
variable used for write headers in additional, demand and data elements
Definition GNENet.h:505
bool isUpdateGeometryEnabled() const
check if update geometry after inserting or removing has to be updated
Definition GNENet.cpp:2884
bool addRestrictedLane(SUMOVehicleClass vclass, GNEEdge *edge, int index, GNEUndoList *undoList)
add restricted lane to edge
Definition GNENet.cpp:933
void saveNetwork()
save the network
Definition GNENet.cpp:1394
bool writeVTypeComment(OutputDevice &device, const FileBucket *fileBucket) const
write vType comment
Definition GNENet.cpp:2619
bool saveJuPedSimElements(const std::string &filename)
save JuPedSim elements
Definition GNENet.cpp:2269
bool checkJunctionPosition(const Position &pos)
return true if there are already a Junction in the given position, false in other case
Definition GNENet.cpp:1382
bool addGreenVergeLane(GNEEdge *edge, int index, GNEUndoList *undoList)
add restricted lane to edge
Definition GNENet.cpp:969
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database (used for simplify code)
Definition GNENet.cpp:162
bool isNetRecomputed() const
check if net require recomputing
Definition GNENet.cpp:1623
GNEPathManager * myNetworkPathManager
Network path manager.
Definition GNENet.h:527
bool isUpdateDataEnabled() const
check if update data after inserting or removing has to be updated
Definition GNENet.cpp:2907
void deleteDataSet(GNEDataSet *dataSet, GNEUndoList *undoList)
remove data set
Definition GNENet.cpp:799
static void replaceInListAttribute(GNEAttributeCarrier *ac, SumoXMLAttr key, const std::string &which, const std::string &by, GNEUndoList *undoList)
replace in list attribute
Definition GNENet.cpp:3081
bool writeWireComment(OutputDevice &device, const FileBucket *fileBucket) const
write Wire comment
Definition GNENet.cpp:2786
bool cleanInvalidCrossings(GNEUndoList *undoList)
clear invalid crossings
Definition GNENet.cpp:1747
GNEPathManager * getNetworkPathManager()
get network path manager
Definition GNENet.cpp:192
void splitJunction(GNEJunction *junction, bool reconnect, GNEUndoList *undoList)
replace the selected junction by a list of junctions for each unique edge endpoint
Definition GNENet.cpp:2024
void selectRoundabout(GNEJunction *junction, GNEUndoList *undoList)
select all roundabout edges and junctions for the current roundabout
Definition GNENet.cpp:1226
void joinRoutes(GNEUndoList *undoList)
join routes
Definition GNENet.cpp:1831
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
replace the selected junction by geometry node(s) and merge the edges
Definition GNENet.cpp:1979
void createRoundabout(GNEJunction *junction, GNEUndoList *undoList)
transform the given junction into a roundabout
Definition GNENet.cpp:1245
void requireRecompute()
inform the net about the need for recomputation
Definition GNENet.cpp:1617
GNEViewParent * getViewParent() const
get view parent (used for simplify code)
Definition GNENet.cpp:150
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition GNENet.cpp:285
void savePlain(const std::string &prefix, const OptionsCont &netconvertOptions)
save plain xml representation of the network (and nothing else)
Definition GNENet.cpp:1430
unsigned int myJunctionIDCounter
Definition GNENet.h:537
bool writeDetectorComment(OutputDevice &device, const FileBucket *fileBucket) const
write detector comment
Definition GNENet.cpp:2728
std::map< std::string, int > myEdgesAndNumberOfLanes
map with the Edges and their number of lanes
Definition GNENet.h:636
bool writeVariableSpeedSignComment(OutputDevice &device, const FileBucket *fileBucket) const
write variable speed sign comment
Definition GNENet.cpp:2662
GNEPathManager * myDemandPathManager
Demand path manager.
Definition GNENet.h:530
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition GNENet.cpp:2212
void initGNEConnections()
initialize GNEConnections
Definition GNENet.cpp:2969
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition GNENet.cpp:438
NBEdgeCont & getEdgeCont()
returns the NBEdgeCont of the underlying netbuilder
Definition GNENet.cpp:2206
GNENet()=delete
Invalidated default constructor.
unsigned int & getJunctionIDCounter()
Definition GNENet.cpp:2913
bool saveDemandElements()
save demand element elements of the network
Definition GNENet.cpp:2286
GNENetHelper::AttributeCarriers * myAttributeCarriers
attributeCarriers module
Definition GNENet.h:518
void computeDataElements(GNEApplicationWindow *window)
compute data elements param[in] window The window to inform about delay
Definition GNENet.cpp:1586
GNENetHelper::ACTemplate * myACTemplates
attributeCarriers templates
Definition GNENet.h:521
GNEUndoList * getUndoList() const
get undo list(used for simplify code)
Definition GNENet.cpp:156
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GNENet.cpp:241
void writeDemandByType(OutputDevice &device, const FileBucket *fileBucket, SumoXMLTag tag) const
write demand element by type and sorted by ID
Definition GNENet.cpp:2530
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNENet.cpp:251
int getNumberOfTLSPrograms() const
get number of TLS Programs
Definition GNENet.cpp:2838
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
bool writeVaporizerComment(OutputDevice &device, const FileBucket *fileBucket) const
write vaporizer comment
Definition GNENet.cpp:2686
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNENet.cpp:228
void enableUpdateGeometry()
Definition GNENet.cpp:2872
void clearJunctionConnections(GNEJunction *junction, GNEUndoList *undoList)
clear junction's connections
Definition GNENet.cpp:2109
Boundary myZBoundary
the z boundary (stored in the x-coordinate), values of 0 are ignored
Definition GNENet.h:633
double getDataSetIntervalMinimumBegin() const
get minimum interval
Definition GNENet.cpp:2366
void computeDemandElements(GNEApplicationWindow *window)
compute demand elements param[in] window The window to inform about delay
Definition GNENet.cpp:1566
unsigned int & getEdgeIDCounter()
Definition GNENet.cpp:2919
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this AttributeCarrier
void updatePathCalculator()
update DijkstraRouter (needed a good calculation of dijkstra path after modifying network)
bool isPathCalculatorUpdated() const
check if pathCalculator is updated
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void invalidateJunctionPath(const GNEJunction *junction)
invalidate junction path
void clearSegments()
clear segments
void invalidateLanePath(const GNELane *lane)
invalidate lane path
bool isPlacedInRTree() const
return true if Tag correspond to an element that has to be placed in RTREE
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::vector< const GNEAttributeProperties * > & getAttributeProperties() const
get all attribute properties
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
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...
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
A single child window which contains a view of the simulation area.
GNEInspectorFrame * getInspectorFrame() const
get frame for inspect elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app, bool addSeparator=true) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
A window containing a gl-object's parameter.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void destroyPopup()
destroys the popup
Stores the information about how to visualize structures.
bool parse()
parse
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const Boundary & getConvBoundary() const
Returns the converted boundary.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
The representation of a single edge during network building.
Definition NBEdge.h:92
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition NBEdge.cpp:4540
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition NBEdge.h:1047
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
Definition NBEdge.h:608
void reinitNodes(NBNode *from, NBNode *to)
Resets nodes but keeps all other values the same (used when joining)
Definition NBEdge.cpp:437
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:552
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Definition NBEdge.h:355
Lane & getLaneStruct(int lane)
Definition NBEdge.h:1451
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition NBEdge.h:789
EdgeBuildingStep getStep() const
The building step of this edge.
Definition NBEdge.h:641
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Definition NBEdge.h:618
@ LANES2LANES_RECHECK
Lanes to lanes - relationships are computed; should be rechecked.
int getNumLanes() const
Returns the number of lanes.
Definition NBEdge.h:526
void resetNodeBorder(const NBNode *node)
Definition NBEdge.cpp:761
double getTotalWidth() const
Returns the combined width of all lanes of this edge.
Definition NBEdge.cpp:4378
std::string getLaneID(int lane) const
get lane ID
Definition NBEdge.cpp:4178
int getPriority() const
Returns the priority of the edge.
Definition NBEdge.h:533
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition NBEdge.h:346
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition NBEdge.h:349
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
Definition NBEdge.cpp:613
double getFinalLength() const
get length that will be assigned to the lanes in the final network
Definition NBEdge.cpp:4891
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
A definition of a pedestrian crossing.
Definition NBNode.h:135
PositionVector customShape
optional customShape for this crossing
Definition NBNode.h:160
int customTLIndex
the custom traffic light index of this crossing (if controlled)
Definition NBNode.h:165
bool priority
whether the pedestrians have priority
Definition NBNode.h:158
EdgeVector edges
The edges being crossed.
Definition NBNode.h:142
double width
This crossing's width.
Definition NBNode.h:150
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
std::vector< std::string > getAllNames() const
get all node names
void analyzeCluster(NodeSet cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type, SumoXMLNodeType &nodeType)
Represents a single node (junction) during network building.
Definition NBNode.h:66
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
Definition NBNode.cpp:2499
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
Definition NBNode.h:345
static const double UNSPECIFIED_RADIUS
unspecified lane width
Definition NBNode.h:220
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
Definition NBNode.h:268
std::vector< std::pair< Position, std::string > > getEndPoints() const
return list of unique endpoint coordinates of all edges at this node
Definition NBNode.cpp:4373
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
get edges to join
Definition NBNode.cpp:2748
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
Definition NBNode.h:273
const Position & getPosition() const
Definition NBNode.h:260
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
Definition NBNode.h:278
void updateSurroundingGeometry()
update geometry of node and surrounding edges
Definition NBNode.cpp:1186
double getRadius() const
Returns the turning radius of this node.
Definition NBNode.h:290
bool checkIsRemovable() const
check if node is removable
Definition NBNode.cpp:2665
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition NBNode.h:336
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
A container for traffic light definitions and built programs.
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by netedit)
void writeEdgeTypes(OutputDevice &into, const std::set< std::string > &typeIDs=std::set< std::string >()) const
writes all EdgeTypes (and their lanes) as XML
void insertEdgeType(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, LaneSpreadFunction spreadType, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth, double widthResolution, double maxWidth, double minWidth)
Adds a edgeType into the list.
void clearTypes()
clear types
void insertLaneType(const std::string &edgeTypeID, int index, double maxSpeed, SVCPermissions permissions, double width, const std::set< SumoXMLAttr > &attrs)
Adds a laneType into the list.
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network stored in the given net builder.
Definition NWFrame.cpp:200
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
static void writeJoinedJunctions(const std::string &filename, NBNodeCont &nc)
Writes the joined-juncionts to file.
static void writeNetwork(const OptionsCont &oc, const std::string &prefix, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
A storage for options typed value containers)
Definition OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
void setx(double x)
set position x
Definition Position.h:67
double x() const
Returns the x-position.
Definition Position.h:52
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
void sety(double y)
set position y
Definition Position.h:72
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
void append(const PositionVector &v, double sameThreshold=2.0)
double length() const
Returns the length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::pair< PositionVector, PositionVector > splitAt(double where, bool use2D=false) const
Returns the two lists made when this list vector is splitted at the given point.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
PositionVector reverse() const
reverse position vector
A RT-tree for efficient storing of SUMO's GL-objects.
Definition SUMORTree.h:66
void addAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition SUMORTree.h:122
void removeAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition SUMORTree.h:158
static StringBijection< SumoXMLNodeType > NodeTypes
node types
bool hasString(const std::string &str) const
check if the given string exist
T get(const std::string &str) const
get key
static std::string trim(const std::string s, const std::string &t=" \t\n")
remove leading and trailing whitespace
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
Definition json.hpp:4471
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
A structure which describes a connection between edges or lanes.
Definition NBEdge.h:201
An (internal) definition of a single lane of an edge.
Definition NBEdge.h:143