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 if (!isNetRecomputed()) {
1404 computeAndUpdate(neteditOptions, false);
1405 }
1406 // clear typeContainer
1408 // now update typeContainer with edgeTypes
1409 for (const auto& edgeType : myAttributeCarriers->getEdgeTypes()) {
1410 myNetBuilder->getTypeCont().insertEdgeType(edgeType.first, edgeType.second);
1411 for (int i = 0; i < (int)edgeType.second->getLaneTypes().size(); i++) {
1412 myNetBuilder->getTypeCont().insertLaneType(edgeType.first, i,
1413 edgeType.second->getLaneTypes().at(i)->speed,
1414 edgeType.second->getLaneTypes().at(i)->permissions,
1415 edgeType.second->getLaneTypes().at(i)->width,
1416 edgeType.second->getLaneTypes().at(i)->attrs);
1417 }
1418 }
1419 // write network
1420 NWFrame::writeNetwork(neteditOptions, *myNetBuilder);
1421 // reset output file
1422 sumoOptions.resetWritable();
1423 neteditOptions.resetDefault("output-file");
1424 // mark network as saved
1426 // end save network
1427 myApplicationWindow->getApp()->endWaitCursor();
1428}
1429
1430
1431void
1432GNENet::savePlain(const std::string& prefix, const OptionsCont& netconvertOptions) {
1433 // compute without volatile options
1435 // save netconvert options
1436 NWWriter_XML::writeNetwork(netconvertOptions, prefix, *myNetBuilder);
1437}
1438
1439
1440void
1441GNENet::saveJoined(const std::string& filename) {
1442 // compute without volatile options
1445}
1446
1447
1448void
1450 // check if object must be inserted in RTREE
1451 if (AC->getTagProperty()->isPlacedInRTree() && !AC->inGrid()) {
1453 AC->setInGrid(true);
1454 }
1455}
1456
1457
1458void
1460 // check if object must be inserted in RTREE
1461 if (AC->getTagProperty()->isPlacedInRTree() && AC->inGrid()) {
1463 AC->setInGrid(false);
1464 }
1465}
1466
1467
1468void
1469GNENet::computeNetwork(GNEApplicationWindow* window, bool force, bool volatileOptions) {
1470 if (!myNeedRecompute) {
1471 if (force) {
1472 if (volatileOptions) {
1473 window->setStatusBarText(TL("Forced computing junctions with volatile options ..."));
1474 } else {
1475 window->setStatusBarText(TL("Forced computing junctions ..."));
1476 }
1477 } else {
1478 return;
1479 }
1480 } else {
1481 if (volatileOptions) {
1482 window->setStatusBarText(TL("Computing junctions with volatile options ..."));
1483 } else {
1484 window->setStatusBarText(TL("Computing junctions ..."));
1485 }
1486 }
1487 // start recomputing
1488 myApplicationWindow->getApp()->beginWaitCursor();
1489 // save current number of lanes for every edge if recomputing is with volatile options
1490 if (volatileOptions) {
1491 for (const auto& edge : myAttributeCarriers->getEdges()) {
1492 myEdgesAndNumberOfLanes[edge.second->getID()] = (int)edge.second->getChildLanes().size();
1493 }
1494 }
1495 // compute and update
1496 auto& neteditOptions = OptionsCont::getOptions();
1497 computeAndUpdate(neteditOptions, volatileOptions);
1498 // load additionals if was recomputed with volatile options
1499 if (volatileOptions) {
1501 if (bucket->getFilename().size() > 0) {
1502 // Create general handler
1503 GNEGeneralHandler generalHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1504 // Run parser
1505 if (!generalHandler.parse()) {
1506 WRITE_ERROR(TL("Loading of additional file failed: ") + bucket->getFilename());
1507 } else {
1508 WRITE_MESSAGE(TL("Loading of additional file successfully: ") + bucket->getFilename());
1509 }
1510 }
1511 }
1512 }
1513 // load demand elements if was recomputed with volatile options
1514 if (volatileOptions) {
1516 if (bucket->getFilename().size() > 0) {
1517 // Create general handler
1518 GNEGeneralHandler generalHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1519 // Run parser
1520 if (!generalHandler.parse()) {
1521 WRITE_ERROR(TL("Loading of route file failed: ") + bucket->getFilename());
1522 } else {
1523 WRITE_MESSAGE(TL("Loading of route file successfully: ") + bucket->getFilename());
1524 }
1525 }
1526 }
1527 }
1528 // load datas if was recomputed with volatile options
1529 if (volatileOptions) {
1531 if (bucket->getFilename().size() > 0) {
1532 // Create general handler
1533 GNEDataHandler dataHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1534 // Run parser
1535 if (!dataHandler.parse()) {
1536 WRITE_ERROR(TL("Loading of data file failed: ") + bucket->getFilename());
1537 } else {
1538 WRITE_MESSAGE(TL("Loading of data file successfully: ") + bucket->getFilename());
1539 }
1540 }
1541 }
1542 }
1543 // load meanDatas if was recomputed with volatile options
1544 if (volatileOptions) {
1546 if (bucket->getFilename().size() > 0) {
1547 // Create general handler
1548 GNEGeneralHandler generalHandler(this, bucket, myApplicationWindow->isUndoRedoAllowed());
1549 // Run parser
1550 if (!generalHandler.parse()) {
1551 WRITE_ERROR(TL("Loading of meandata file failed: ") + bucket->getFilename());
1552 } else {
1553 WRITE_MESSAGE(TL("Loading of meandata file successfully: ") + bucket->getFilename());
1554 }
1555 }
1556 }
1557 }
1558 // clear myEdgesAndNumberOfLanes after reload additionals
1560 // end recomputing
1561 myApplicationWindow->getApp()->endWaitCursor();
1562 // update status bar
1563 window->setStatusBarText(TL("Finished computing junctions."));
1564}
1565
1566
1567void
1569 window->setStatusBarText(TL("Computing demand elements ..."));
1570 // if we aren't in Demand mode, update path calculator
1574 }
1575 // clear demand paths
1577 // iterate over all demand elements and compute
1578 for (const auto& demandElements : myAttributeCarriers->getDemandElements()) {
1579 for (const auto& demandElement : demandElements.second) {
1580 demandElement.second->computePathElement();
1581 }
1582 }
1583 window->setStatusBarText(TL("Finished computing demand elements."));
1584}
1585
1586
1587void
1589 window->setStatusBarText(TL("Computing data elements ..."));
1590 // iterate over all demand elements and compute
1591 for (const auto& genericDataTag : myAttributeCarriers->getGenericDatas()) {
1592 for (const auto& genericData : genericDataTag.second) {
1593 genericData.second->computePathElement();
1594 }
1595 }
1596 window->setStatusBarText(TL("Finished computing data elements."));
1597}
1598
1599
1600void
1602 // recompute tl-logics
1603 auto& neteditOptions = OptionsCont::getOptions();
1605 // iterate over traffic lights definitions. Make a copy because invalid
1606 // definitions will be removed (and would otherwise destroy the iterator)
1607 const std::set<NBTrafficLightDefinition*> tlsDefs = junction->getNBNode()->getControllingTLS();
1608 for (auto it : tlsDefs) {
1609 it->setParticipantsInformation();
1610 it->setTLControllingInformation();
1611 tllCont.computeSingleLogic(neteditOptions, it);
1612 }
1613
1614 // @todo compute connections etc...
1615}
1616
1617
1618void
1622
1623
1624bool
1626 return !myNeedRecompute;
1627}
1628
1629
1630bool
1632 const auto selectedJunctions = myAttributeCarriers->getSelectedJunctions();
1633 if (selectedJunctions.size() < 2) {
1634 return false;
1635 }
1636 EdgeVector allIncoming;
1637 EdgeVector allOutgoing;
1638 std::set<NBNode*, ComparatorIdLess> cluster;
1639 for (const auto& selectedJunction : selectedJunctions) {
1640 cluster.insert(selectedJunction->getNBNode());
1641 const EdgeVector& incoming = selectedJunction->getNBNode()->getIncomingEdges();
1642 allIncoming.insert(allIncoming.end(), incoming.begin(), incoming.end());
1643 const EdgeVector& outgoing = selectedJunction->getNBNode()->getOutgoingEdges();
1644 allOutgoing.insert(allOutgoing.end(), outgoing.begin(), outgoing.end());
1645 }
1646 // create new junction
1647 Position pos;
1648 Position oldPos;
1649 bool setTL = false;
1650 std::string id = "cluster";
1651 TrafficLightType type;
1653 myNetBuilder->getNodeCont().analyzeCluster(cluster, id, pos, setTL, type, nodeType);
1654 // save position
1655 oldPos = pos;
1656 // Check that there isn't another junction in the same position as Pos but doesn't belong to cluster
1657 for (const auto& junction : myAttributeCarriers->getJunctions()) {
1658 if ((junction.second->getPositionInView() == pos) && (cluster.find(junction.second->getNBNode()) == cluster.end())) {
1659 // open dialog
1661 TL("Position of joined junction"),
1662 TL("There is another unselected junction in the same position of joined junction."),
1663 TL("It will be joined with the other selected junctions. Continue?"));
1664 // check dialog result
1665 if (questionDialog.getResult() == GNEDialog::Result::ACCEPT) {
1666 // select conflicted junction an join all again
1667 junction.second->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1668 return joinSelectedJunctions(undoList);
1669 } else {
1670 return false;
1671 }
1672 }
1673 }
1674 // use checkJunctionPosition to avoid conflicts with junction in the same position as others
1675 while (!checkJunctionPosition(pos)) {
1676 pos.setx(pos.x() + 0.1);
1677 pos.sety(pos.y() + 0.1);
1678 }
1679 // start with the join selected junctions
1680 undoList->begin(GUIIcon::JUNCTION, "Join selected " + toString(SUMO_TAG_JUNCTION) + "s");
1681 GNEJunction* joined = createJunction(pos, undoList);
1682 joined->setAttribute(SUMO_ATTR_ID, id, undoList);
1683 // id must be set before type because it is used when creating a new tls
1684 joined->setAttribute(SUMO_ATTR_TYPE, toString(nodeType), undoList); // i.e. rail crossing
1685 if (setTL) {
1686 joined->setAttribute(SUMO_ATTR_TLTYPE, toString(type), undoList);
1687 }
1689 // first remove all crossing of the involved junctions and edges
1690 // (otherwise edge removal will trigger discarding)
1691 std::vector<NBNode::Crossing> oldCrossings;
1692 for (const auto& selectedJunction : selectedJunctions) {
1693 const auto crossings = selectedJunction->getGNECrossings();
1694 for (auto crossing : crossings) {
1695 deleteCrossing(crossing, undoList);
1696 }
1697 }
1698 // preserve old connections
1699 for (const auto& selectedJunction : selectedJunctions) {
1700 selectedJunction->setLogicValid(false, undoList);
1701 }
1702 // remap edges
1703 for (const auto& incomingEdge : allIncoming) {
1704 if (std::find(allOutgoing.begin(), allOutgoing.end(), incomingEdge) == allOutgoing.end()) {
1705 GNEChange_Attribute::changeAttribute(myAttributeCarriers->getEdges().at(incomingEdge->getID()), SUMO_ATTR_TO, joined->getID(), undoList);
1706 }
1707 }
1708 EdgeSet edgesWithin;
1709 for (const auto& outgoingEdge : allOutgoing) {
1710 // delete edges within the cluster
1711 GNEEdge* edge = myAttributeCarriers->getEdges().at(outgoingEdge->getID());
1712 if (edge->getToJunction() == joined) {
1713 edgesWithin.insert(outgoingEdge);
1714 deleteEdge(edge, undoList, false);
1715 } else {
1716 GNEChange_Attribute::changeAttribute(myAttributeCarriers->getEdges().at(outgoingEdge->getID()), SUMO_ATTR_FROM, joined->getID(), undoList);
1717 }
1718 }
1719 // remap all crossing of the involved junctions and edges
1720 for (const auto& nbc : oldCrossings) {
1721 bool keep = true;
1722 for (NBEdge* e : nbc.edges) {
1723 if (edgesWithin.count(e) != 0) {
1724 keep = false;
1725 break;
1726 }
1727 };
1728 if (keep) {
1729 undoList->add(new GNEChange_Crossing(joined, nbc.edges, nbc.width,
1730 nbc.priority || joined->getNBNode()->isTLControlled(),
1731 nbc.customTLIndex, nbc.customTLIndex2, nbc.customShape,
1732 false, true), true);
1733 }
1734 }
1735 // delete original junctions
1736 for (const auto& selectedJunction : selectedJunctions) {
1737 deleteJunction(selectedJunction, undoList);
1738 }
1739 // check if joined junction had to change their original position to avoid errors
1740 if (pos != oldPos) {
1741 joined->setAttribute(SUMO_ATTR_POSITION, toString(oldPos), undoList);
1742 }
1743 undoList->end();
1744 return true;
1745}
1746
1747
1748bool
1750 // obtain current net's crossings
1751 std::vector<GNECrossing*> myNetCrossings;
1752 for (const auto& junction : myAttributeCarriers->getJunctions()) {
1753 myNetCrossings.reserve(myNetCrossings.size() + junction.second->getGNECrossings().size());
1754 myNetCrossings.insert(myNetCrossings.end(), junction.second->getGNECrossings().begin(), junction.second->getGNECrossings().end());
1755 }
1756 // obtain invalid crossings
1757 std::vector<GNECrossing*> myInvalidCrossings;
1758 for (auto i = myNetCrossings.begin(); i != myNetCrossings.end(); i++) {
1759 if (!(*i)->getNBCrossing()->valid) {
1760 myInvalidCrossings.push_back(*i);
1761 }
1762 }
1763 // continue depending of invalid crossings
1764 if (myInvalidCrossings.empty()) {
1765 // open a warning dialog informing that there isn't crossing to remove
1767 TL("Clear crossings"),
1768 TL("There are no invalid crossings to remove."));
1769 } else {
1770 std::string plural = myInvalidCrossings.size() == 1 ? ("") : ("s");
1771 // Ask confirmation to user
1772 const GNEQuestionBasicDialog questionDialog(myApplicationWindow,
1773 GNEDialog::Buttons::YES_NO, TL("Clear crossings"),
1774 TL("Crossings will be cleared. Continue?"));
1775 // 1:yes, 2:no, 4:esc
1776 if (questionDialog.getResult() == GNEDialog::Result::ACCEPT) {
1777 undoList->begin(GUIIcon::MODEDELETE, TL("clear crossings"));
1778 for (const auto& crossing : myInvalidCrossings) {
1779 deleteCrossing(crossing, undoList);
1780 }
1781 undoList->end();
1782 } else {
1783 return false;
1784 }
1785 }
1786 return true;
1787}
1788
1789
1790void
1792 undoList->begin(GUIIcon::MODEDELETE, TL("clear junctions"));
1793 std::vector<GNEJunction*> toRemove;
1794 for (auto& junction : myAttributeCarriers->getJunctions()) {
1795 if (junction.second->getNBNode()->getEdges().size() == 0) {
1796 toRemove.push_back(junction.second);
1797 }
1798 }
1799 for (auto junction : toRemove) {
1800 deleteJunction(junction, undoList);
1801 }
1802 undoList->end();
1803}
1804
1805
1806void
1808 // first declare a vector to save all routes without children
1809 std::vector<GNEDemandElement*> routesWithoutChildren;
1810 routesWithoutChildren.reserve(myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE).size());
1811 // iterate over routes
1812 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
1813 if (route.second->getChildDemandElements().empty()) {
1814 routesWithoutChildren.push_back(route.second);
1815 }
1816 }
1817 // finally remove all routesWithoutChildren
1818 if (routesWithoutChildren.size() > 0) {
1819 // begin undo list
1820 undoList->begin(GUIIcon::MODEDELETE, TL("clear unused routes"));
1821 // iterate over routesWithoutChildren
1822 for (const auto& i : routesWithoutChildren) {
1823 // due route doesn't have children, simply call GNEChange_DemandElement
1824 undoList->add(new GNEChange_DemandElement(i, false), true);
1825 }
1826 // end undo list
1827 undoList->end();
1828 }
1829}
1830
1831
1832void
1834 // first declare a sorted set of sorted route's edges in string format
1835 std::set<std::pair<std::string, GNEDemandElement*> > mySortedRoutes;
1836 // iterate over routes and save it in mySortedRoutes (only if it doesn't have Stop Children)
1837 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
1838 // first check route has stops
1839 bool hasStops = false;
1840 for (const auto& stop : route.second->getChildDemandElements()) {
1841 if (stop->getTagProperty()->isVehicleStop()) {
1842 hasStops = true;
1843 }
1844 }
1845 if (!hasStops) {
1846 mySortedRoutes.insert(std::make_pair(GNEAttributeCarrier::parseIDs(route.second->getParentEdges()), route.second));
1847 }
1848 }
1849 // now declare a matrix in which organize routes to be merged
1850 std::vector<std::vector<GNEDemandElement*> > routesToMerge;
1851 auto index = mySortedRoutes.begin();
1852 // iterate over mySortedRoutes
1853 for (auto i = mySortedRoutes.begin(); i != mySortedRoutes.end(); i++) {
1854 if (routesToMerge.empty()) {
1855 routesToMerge.push_back({i->second});
1856 } else {
1857 if (index->first == i->first) {
1858 routesToMerge.back().push_back(i->second);
1859 } else {
1860 routesToMerge.push_back({i->second});
1861 index = i;
1862 }
1863 }
1864 }
1865 // now check if there is routes to merge
1866 bool thereIsRoutesToMerge = false;
1867 for (const auto& i : routesToMerge) {
1868 if (i.size() > 1) {
1869 thereIsRoutesToMerge = true;
1870 }
1871 }
1872 // if exist
1873 if (thereIsRoutesToMerge) {
1874 // begin undo list
1875 undoList->begin(GUIIcon::ROUTE, TL("merge routes"));
1876 // iterate over route to edges
1877 for (const auto& routes : routesToMerge) {
1878 if (routes.size() > 1) {
1879 // iterate over duplicated routes
1880 for (int i = 1; i < (int)routes.size(); i++) {
1881 // move all vehicles of every duplicated route
1882 while (routes.at(i)->getChildDemandElements().size() > 0) {
1883 routes.at(i)->getChildDemandElements().front()->setAttribute(SUMO_ATTR_ROUTE, routes.at(0)->getID(), undoList);
1884 }
1885 // finally remove route
1886 undoList->add(new GNEChange_DemandElement(routes.at(i), false), true);
1887 }
1888 }
1889 }
1890 // end undo list
1891 undoList->end();
1892 }
1893}
1894
1895
1896void
1898 // declare personPlan-pos map
1899 std::map<GNEDemandElement*, std::string> personPlanMap;
1900 // iterate over persons
1901 for (const auto& persontag : {
1903 }) {
1904 for (const auto& person : myAttributeCarriers->getDemandElements().at(persontag)) {
1905 if (person.second->getChildDemandElements().size() > 0) {
1906 // get person plan
1907 GNEDemandElement* personPlan = person.second->getChildDemandElements().front();
1908 // iterate over all personPlans
1909 while (personPlan) {
1910 // check if personPlan is a stopPerson over edge
1911 if (personPlan->getTagProperty()->getTag() == GNE_TAG_STOPPERSON_EDGE) {
1912 // get previous person plan
1913 GNEDemandElement* previousPersonPlan = person.second->getPreviousChildDemandElement(personPlan);
1914 // check if arrivalPos of previous personPlan is different of endPos of stopPerson
1915 if (previousPersonPlan && previousPersonPlan->getTagProperty()->hasAttribute(SUMO_ATTR_ARRIVALPOS) &&
1916 (previousPersonPlan->getAttribute(SUMO_ATTR_ARRIVALPOS) != personPlan->getAttribute(SUMO_ATTR_ENDPOS))) {
1917 personPlanMap[previousPersonPlan] = personPlan->getAttribute(SUMO_ATTR_ENDPOS);
1918 }
1919 }
1920 // go to next person plan
1921 personPlan = person.second->getNextChildDemandElement(personPlan);
1922 }
1923 }
1924 }
1925 }
1926 // continue if there is personPlanMap to adjust
1927 if (personPlanMap.size() > 0) {
1928 // begin undo list
1929 undoList->begin(GUIIcon::MODEPERSONPLAN, TL("adjust person plans"));
1930 // iterate over invalidDemandElements
1931 for (const auto& personPlan : personPlanMap) {
1932 // set arrivalPos attribute
1933 personPlan.first->setAttribute(SUMO_ATTR_ARRIVALPOS, personPlan.second, undoList);
1934 }
1935 // end undo list
1936 undoList->end();
1937 }
1938}
1939
1940
1941void
1943 // first declare a vector to save all invalid demand elements
1944 std::vector<GNEDemandElement*> invalidDemandElements;
1945 invalidDemandElements.reserve(myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE).size() +
1948 // iterate over routes
1949 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
1950 if (route.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
1951 invalidDemandElements.push_back(route.second);
1952 }
1953 }
1954 // iterate over flows
1955 for (const auto& flow : myAttributeCarriers->getDemandElements().at(SUMO_TAG_FLOW)) {
1956 if (flow.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
1957 invalidDemandElements.push_back(flow.second);
1958 }
1959 }
1960 // iterate over trip
1961 for (const auto& trip : myAttributeCarriers->getDemandElements().at(SUMO_TAG_TRIP)) {
1962 if (trip.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
1963 invalidDemandElements.push_back(trip.second);
1964 }
1965 }
1966 // continue if there is invalidDemandElements to remove
1967 if (invalidDemandElements.size() > 0) {
1968 // begin undo list
1969 undoList->begin(GUIIcon::MODEDELETE, TL("remove invalid demand elements"));
1970 // iterate over invalidDemandElements
1971 for (const auto& invalidDemandElement : invalidDemandElements) {
1972 // simply call GNEChange_DemandElement
1973 undoList->add(new GNEChange_DemandElement(invalidDemandElement, false), true);
1974 }
1975 // end undo list
1976 undoList->end();
1977 }
1978}
1979
1980void
1982 if (junction->getNBNode()->checkIsRemovable()) {
1983 // start operation
1984 undoList->begin(junction, TL("replace junction by geometry"));
1985 // obtain Edges to join
1986 std::vector<std::pair<NBEdge*, NBEdge*> > edgesToJoin = junction->getNBNode()->getEdgesToJoin();
1987 // clear connections of junction to replace
1988 clearJunctionConnections(junction, undoList);
1989 // iterate over NBEdges to join
1990 for (auto edgePair : edgesToJoin) {
1991 // obtain GNEEdges
1992 GNEEdge* begin = myAttributeCarriers->getEdges().at(edgePair.first->getID());
1993 GNEEdge* continuation = myAttributeCarriers->getEdges().at(edgePair.second->getID());
1994 // remove connections between the edges
1995 std::vector<NBEdge::Connection> connections = begin->getNBEdge()->getConnections();
1996 for (auto con : connections) {
1997 undoList->add(new GNEChange_Connection(begin, con, false, false), true);
1998 }
1999 // fix shape of replaced edge
2000 PositionVector newShape = begin->getNBEdge()->getInnerGeometry();
2001 newShape.push_back(junction->getNBNode()->getPosition());
2002 // replace incoming edge
2003 replaceIncomingEdge(continuation, begin, undoList);
2004
2005 newShape.append(continuation->getNBEdge()->getInnerGeometry());
2006 begin->setAttribute(GNE_ATTR_SHAPE_END, "", undoList);
2007 begin->setAttribute(SUMO_ATTR_ENDOFFSET, continuation->getAttribute(SUMO_ATTR_ENDOFFSET), undoList);
2008 begin->setAttribute(SUMO_ATTR_SHAPE, toString(newShape), undoList);
2009 begin->getNBEdge()->resetNodeBorder(begin->getNBEdge()->getToNode());
2010 // fix loaded lengths
2011 if (begin->getNBEdge()->hasLoadedLength() || continuation->getNBEdge()->hasLoadedLength()) {
2012 begin->setAttribute(SUMO_ATTR_LENGTH, toString(begin->getNBEdge()->getLoadedLength() + continuation->getNBEdge()->getLoadedLength()), undoList);
2013 }
2014 }
2015 //delete replaced junction
2016 deleteJunction(junction, undoList);
2017 // finish operation
2018 undoList->end();
2019 } else {
2020 throw ProcessError(TL("Junction isn't removable"));
2021 }
2022}
2023
2024
2025void
2026GNENet::splitJunction(GNEJunction* junction, bool reconnect, GNEUndoList* undoList) {
2027 std::vector<std::pair<Position, std::string> > endpoints = junction->getNBNode()->getEndPoints();
2028 if (endpoints.size() < 2) {
2029 return;
2030 }
2031 // start operation
2032 undoList->begin(junction, TL("split junction"));
2033 // record connections
2034 std::map<std::pair<std::string, GNEEdge*>, std::vector<NBEdge::Connection>> straightConnections;
2035 for (GNEEdge* e : junction->getGNEIncomingEdges()) {
2036 for (const auto& c : e->getNBEdge()->getConnections()) {
2037 if (c.fromLane >= 0 && junction->getNBNode()->getDirection(e->getNBEdge(), c.toEdge) == LinkDirection::STRAIGHT) {
2038 straightConnections[std::make_pair(e->getID(), e)].push_back(c);
2039 }
2040 };
2041 }
2042 junction->setLogicValid(false, undoList);
2043 for (const auto& pair : endpoints) {
2044 const Position& pos = pair.first;
2045 const std::string& origID = pair.second;
2046 GNEJunction* newJunction = createJunction(pos, undoList);
2047 std::string newID = origID != "" ? origID : newJunction->getID();
2048 // make a copy because the original vectors are modified during iteration
2049 const std::vector<GNEEdge*> incoming = junction->getGNEIncomingEdges();
2050 const std::vector<GNEEdge*> outgoing = junction->getGNEOutgoingEdges();
2051 //std::cout << " checkEndpoint " << pair.first << " " << pair.second << " newID=" << newID << "\n";
2052 for (GNEEdge* e : incoming) {
2053 //std::cout << " incoming " << e->getID() << " pos=" << pos << " origTo=" << e->getNBEdge()->getParameter("origTo") << " newID=" << newID << "\n";
2054 if (e->getNBEdge()->getGeometry().back().almostSame(pos) || e->getNBEdge()->getParameter("origTo") == newID) {
2055 //std::cout << " match\n";
2056 GNEChange_Attribute::changeAttribute(e, SUMO_ATTR_TO, newJunction->getID(), undoList);
2057 }
2058 }
2059 for (GNEEdge* e : outgoing) {
2060 //std::cout << " outgoing " << e->getID() << " pos=" << pos << " origFrom=" << e->getNBEdge()->getParameter("origFrom") << " newID=" << newID << "\n";
2061 if (e->getNBEdge()->getGeometry().front().almostSame(pos) || e->getNBEdge()->getParameter("origFrom") == newID) {
2062 //std::cout << " match\n";
2063 GNEChange_Attribute::changeAttribute(e, SUMO_ATTR_FROM, newJunction->getID(), undoList);
2064 }
2065 }
2066 if (newID != newJunction->getID()) {
2067 if (newJunction->isValid(SUMO_ATTR_ID, newID)) {
2068 GNEChange_Attribute::changeAttribute(newJunction, SUMO_ATTR_ID, newID, undoList);
2069 } else {
2070 WRITE_WARNINGF(TL("Could not rename split node to '%'"), newID);
2071 }
2072 }
2073 }
2074 // recreate edges from straightConnections
2075 if (reconnect) {
2076 for (const auto& item : straightConnections) {
2077 GNEEdge* in = item.first.second;
2078 std::map<std::pair<std::string, NBEdge*>, GNEEdge*> newEdges;
2079 for (auto& c : item.second) {
2080 GNEEdge* out = myAttributeCarriers->retrieveEdge(c.toEdge->getID());
2081 GNEEdge* newEdge = nullptr;
2082 if (in->getToJunction() == out->getFromJunction()) {
2083 continue;
2084 }
2085 if (newEdges.count(std::make_pair(c.toEdge->getID(), c.toEdge)) == 0) {
2086 newEdge = createEdge(in->getToJunction(), out->getFromJunction(), in, undoList);
2087 if (newEdge) {
2088 newEdges[std::make_pair(c.toEdge->getID(), c.toEdge)] = newEdge;
2089 newEdge->setAttribute(SUMO_ATTR_NUMLANES, "1", undoList);
2090 }
2091 } else {
2092 newEdge = newEdges[std::make_pair(c.toEdge->getID(), c.toEdge)];
2093 duplicateLane(newEdge->getChildLanes().back(), undoList, true);
2094 }
2095 if (newEdge) {
2096 // copy permissions
2097 newEdge->getChildLanes().back()->setAttribute(SUMO_ATTR_ALLOW,
2098 in->getChildLanes()[c.fromLane]-> getAttribute(SUMO_ATTR_ALLOW), undoList);
2099 }
2100 }
2101 }
2102 }
2103 deleteJunction(junction, undoList);
2104 // finish operation
2105 undoList->end();
2106}
2107
2108
2109
2110void
2112 undoList->begin(GUIIcon::MODEDELETE, TL("clear junction connections"));
2113 std::vector<GNEConnection*> connections = junction->getGNEConnections();
2114 // Iterate over all connections and clear it
2115 for (auto i : connections) {
2116 deleteConnection(i, undoList);
2117 }
2118 undoList->end();
2119}
2120
2121
2122void
2124 undoList->begin(junction, TL("reset junction connections"));
2125 // first clear connections
2126 clearJunctionConnections(junction, undoList);
2127 // invalidate logic to create new connections in the next recomputing
2128 junction->setLogicValid(false, undoList);
2129 undoList->end();
2130}
2131
2132
2133void
2135 undoList->begin(GUIIcon::MODEDELETE, TL("clear additional elements"));
2136 // clear additionals
2137 for (const auto& additionalMap : myAttributeCarriers->getAdditionals()) {
2138 while (additionalMap.second.size() > 0) {
2139 deleteAdditional(additionalMap.second.begin()->second, undoList);
2140 }
2141 }
2142 undoList->end();
2143}
2144
2145
2146void
2148 undoList->begin(GUIIcon::MODEDELETE, TL("clear demand elements"));
2149 // clear demand elements
2150 for (const auto& demandElementsMap : myAttributeCarriers->getDemandElements()) {
2151 if (demandElementsMap.first != SUMO_TAG_VTYPE) {
2152 while (demandElementsMap.second.size() > 0) {
2153 deleteDemandElement(demandElementsMap.second.begin()->second, undoList);
2154 }
2155 }
2156 }
2157 // special case for vTypes
2158 const std::unordered_map<const GUIGlObject*, GNEDemandElement*> types = myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE);
2159 for (const auto& type : types) {
2160 if (type.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE) == GNEAttributeCarrier::FALSE_STR) {
2161 deleteDemandElement(type.second, undoList);
2162 }
2163 }
2164 undoList->end();
2165}
2166
2167
2168void
2170 undoList->begin(GUIIcon::MODEDELETE, TL("clear data elements"));
2171 // clear data sets
2172 while (myAttributeCarriers->getDataSets().size() > 0) {
2173 deleteDataSet(myAttributeCarriers->getDataSets().begin()->second, undoList);
2174 }
2175 undoList->end();
2176}
2177
2178
2179void
2181 undoList->begin(GUIIcon::MODEDELETE, TL("clear meanData elements"));
2182 // clear meanDatas
2183 for (const auto& meanDataMap : myAttributeCarriers->getMeanDatas()) {
2184 while (meanDataMap.second.size() > 0) {
2185 deleteMeanData(meanDataMap.second.begin()->second, undoList);
2186 }
2187 }
2188 undoList->end();
2189}
2190
2191
2192void
2193GNENet::changeEdgeEndpoints(GNEEdge* edge, const std::string& newSource, const std::string& newDest) {
2196 edge->getNBEdge()->reinitNodes(from, to);
2198}
2199
2200
2205
2206
2211
2212
2213void
2217
2218
2219void
2221 myExplicitTurnarounds.erase(id);
2222}
2223
2224
2225bool
2227 // obtain invalid additionals depending of number of their parent lanes
2228 std::vector<GNEAdditional*> invalidAdditionals;
2229 // iterate over additionals and obtain invalids
2230 for (const auto& additionalPair : myAttributeCarriers->getAdditionals()) {
2231 for (const auto& addditional : additionalPair.second) {
2232 // check if has to be fixed
2233 if (!addditional.second->isAdditionalValid()) {
2234 invalidAdditionals.push_back(addditional.second);
2235 }
2236 }
2237 }
2238 // if there are invalid additionls, open GNEFixAdditionalElementsDialog
2239 if (invalidAdditionals.size() > 0) {
2240 // open fix additional elements dialog
2241 const GNEFixAdditionalElementsDialog fixAdditionalElements(myApplicationWindow, invalidAdditionals);
2242 if (fixAdditionalElements.getResult() != GNEDialog::Result::ACCEPT) {
2243 return false;
2244 }
2245 }
2246 // Start saving additionals
2247 myApplicationWindow->getApp()->beginWaitCursor();
2248 // iterate over all elements and save files
2250 // only write buckets with elements
2251 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2252 // open file
2253 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2254 // open header
2255 device.writeXMLHeader("additional", "additional_file.xsd", EMPTY_HEADER, false);
2256 // save additionals, demand elements and meanDatas
2257 writeAdditionalFileElements(device, bucket);
2258 // close device
2259 device.close();
2260 }
2261 }
2262 // mark additionals as saved
2264 // end saving additionals
2265 myApplicationWindow->getApp()->endWaitCursor();
2266 return true;
2267}
2268
2269
2270bool
2271GNENet::saveJuPedSimElements(const std::string& filename) {
2272 OutputDevice& device = OutputDevice::getDevice(filename);
2273 // open header
2274 device.writeXMLHeader("additional", "additional_file.xsd", EMPTY_HEADER, false);
2275 // juPedSim elements
2276 writeJuPedSimComment(device, nullptr);
2278 writeAdditionalByType(device, nullptr, {GNE_TAG_JPS_OBSTACLE});
2279 // close device
2280 device.close();
2281 // set focus again in net
2282 myApplicationWindow->getViewNet()->setFocus();
2283 return true;
2284}
2285
2286
2287bool
2289 // first recompute demand elements
2291 // obtain invalid demandElements depending of number of their parent lanes
2292 std::vector<GNEDemandElement*> invalidSingleLaneDemandElements;
2293 // iterate over demandElements and obtain invalids
2294 for (const auto& demandElementSet : myAttributeCarriers->getDemandElements()) {
2295 for (const auto& demandElement : demandElementSet.second) {
2296 // compute before check if demand element is valid
2297 demandElement.second->computePathElement();
2298 // check if has to be fixed
2299 if (demandElement.second->isDemandElementValid() != GNEDemandElement::Problem::OK) {
2300 invalidSingleLaneDemandElements.push_back(demandElement.second);
2301 }
2302 }
2303 }
2304 // if there are invalid demand elements, open GNEFixDemandElementsDialog
2305 if (invalidSingleLaneDemandElements.size() > 0) {
2306 // open fix demand elements dialog
2307 const GNEFixDemandElementsDialog fixDemandElement(myApplicationWindow, invalidSingleLaneDemandElements);
2308 if (fixDemandElement.getResult() != GNEDialog::Result::ACCEPT) {
2309 return false;
2310 }
2311 }
2312 // Start saving additionals
2313 myApplicationWindow->getApp()->beginWaitCursor();
2314 // iterate over all elements and save files
2316 // only write buckets with elements
2317 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2318 // open file
2319 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2320 // open header
2321 device.writeXMLHeader("routes", "routes_file.xsd", EMPTY_HEADER, false);
2322 // save additionals, demand elements and meanDatas
2323 writeAdditionalFileElements(device, bucket);
2324 // close device
2325 device.close();
2326 }
2327 }
2328 // mark demand elements as saved
2330 // end saving additionals
2331 myApplicationWindow->getApp()->endWaitCursor();
2332 return true;
2333}
2334
2335
2336bool
2338 // first recompute data sets
2340 // Start saving data elements
2341 myApplicationWindow->getApp()->beginWaitCursor();
2342 // iterate over all elements and save files
2344 // only write buckets with elements
2345 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2346 // open file
2347 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2348 // write header
2349 device.writeXMLHeader("data", "datamode_file.xsd", EMPTY_HEADER, false);
2350 for (const auto& dataSet : myAttributeCarriers->getDataSets()) {
2351 if (dataSet.second->getFileBucket() == bucket) {
2352 dataSet.second->writeDataSet(device);
2353 }
2354 }
2355 // close device
2356 device.close();
2357 }
2358 }
2359 // mark data element as saved
2361 // end saving additionals
2362 myApplicationWindow->getApp()->endWaitCursor();
2363 return true;
2364}
2365
2366
2367double
2369 double minimumBegin = 0;
2370 // update with first minimum (if exist)
2371 if (myAttributeCarriers->getDataIntervals().size() > 0) {
2372 minimumBegin = myAttributeCarriers->getDataIntervals().begin()->second->getAttributeDouble(SUMO_ATTR_BEGIN);
2373 }
2374 // iterate over interval
2375 for (const auto& interval : myAttributeCarriers->getDataIntervals()) {
2376 if (interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) < minimumBegin) {
2377 minimumBegin = interval.second->getAttributeDouble(SUMO_ATTR_BEGIN);
2378 }
2379 }
2380 return minimumBegin;
2381}
2382
2383
2384double
2386 double maximumEnd = 0;
2387 // update with first maximum (if exist)
2388 if (myAttributeCarriers->getDataIntervals().size() > 0) {
2389 maximumEnd = myAttributeCarriers->getDataIntervals().begin()->second->getAttributeDouble(SUMO_ATTR_END);
2390 }
2391 // iterate over intervals
2392 for (const auto& interval : myAttributeCarriers->getDataIntervals()) {
2393 if (interval.second->getAttributeDouble(SUMO_ATTR_END) > maximumEnd) {
2394 maximumEnd = interval.second->getAttributeDouble(SUMO_ATTR_END);
2395 }
2396 }
2397 return maximumEnd;
2398}
2399
2400
2401bool
2403 // Start saving additionals
2404 myApplicationWindow->getApp()->beginWaitCursor();
2405 // iterate over all elements and save files
2407 // only write buckets with elements
2408 if ((bucket->getNumElements() > 0) || (bucket->isDefaultBucket() && (bucket->getFilename().size() > 0))) {
2409 // open file
2410 OutputDevice& device = OutputDevice::getDevice(bucket->getFilename());
2411 // open header
2412 device.writeXMLHeader("additional", "additional_file.xsd", EMPTY_HEADER, false);
2413 // save additionals, demand elements and meanDatas
2414 writeAdditionalFileElements(device, bucket);
2415 // close device
2416 device.close();
2417 }
2418 }
2419 // mark mean datas as saved
2421 // end saving additionals
2422 myApplicationWindow->getApp()->endWaitCursor();
2423 return true;
2424}
2425
2426
2427void
2429 // 1) stoppingPlaces
2430 writeStoppingPlaceComment(device, fileBucket);
2431 writeAdditionalByType(device, fileBucket, {SUMO_TAG_BUS_STOP});
2432 writeAdditionalByType(device, fileBucket, {SUMO_TAG_TRAIN_STOP});
2433 writeAdditionalByType(device, fileBucket, {SUMO_TAG_CONTAINER_STOP});
2434 writeAdditionalByType(device, fileBucket, {SUMO_TAG_PARKING_AREA});
2435 writeAdditionalByType(device, fileBucket, {SUMO_TAG_CHARGING_STATION});
2436 // detectors
2437 writeDetectorComment(device, fileBucket);
2438 writeAdditionalByType(device, fileBucket, {SUMO_TAG_INDUCTION_LOOP});
2442 // variable speed signs
2443 writeVariableSpeedSignComment(device, fileBucket);
2444 writeAdditionalByType(device, fileBucket, {SUMO_TAG_VSS});
2445 // routeProbes
2446 writeRouteProbeComment(device, fileBucket);
2447 writeAdditionalByType(device, fileBucket, {SUMO_TAG_ROUTEPROBE});
2448 // vaporizers
2449 writeVaporizerComment(device, fileBucket);
2450 writeAdditionalByType(device, fileBucket, {SUMO_TAG_VAPORIZER});
2451 // Wire element
2452 writeWireComment(device, fileBucket);
2456 // shapes
2457 writeShapesComment(device, fileBucket);
2458 writeAdditionalByType(device, fileBucket, {SUMO_TAG_POLY});
2460 // juPedSim elements
2461 writeJuPedSimComment(device, fileBucket);
2462 writeAdditionalByType(device, fileBucket, {GNE_TAG_JPS_WALKABLEAREA});
2463 writeAdditionalByType(device, fileBucket, {GNE_TAG_JPS_OBSTACLE});
2464 // TAZs
2465 writeTAZComment(device, fileBucket);
2466 writeAdditionalByType(device, fileBucket, {SUMO_TAG_TAZ});
2467 // vtypes
2468 writeVTypeComment(device, fileBucket);
2469 writeVTypes(device, fileBucket);
2470 writeVTypeDistributions(device, fileBucket);
2471 // now write all routes (and their associated stops), except routes with additional children (due routeProbReroutes)
2472 writeRouteComment(device, fileBucket);
2473 writeRoutes(device, fileBucket);
2474 writeRouteDistributions(device, fileBucket);
2475 // sort vehicles/persons by depart
2476 std::map<double, std::map<std::pair<SumoXMLTag, std::string>, GNEDemandElement*> > vehiclesSortedByDepart;
2477 for (const auto& demandElementTag : myAttributeCarriers->getDemandElements()) {
2478 for (const auto& demandElement : demandElementTag.second) {
2479 if ((demandElement.second->getFileBucket() == fileBucket) &&
2480 (demandElement.second->getTagProperty()->isVehicle() || demandElement.second->getTagProperty()->isPerson() || demandElement.second->getTagProperty()->isContainer())) {
2481 vehiclesSortedByDepart[demandElement.second->getAttributeDouble(SUMO_ATTR_DEPART)][std::make_pair(demandElement.second->getTagProperty()->getTag(), demandElement.second->getID())] = demandElement.second;
2482 }
2483 }
2484 }
2485 // finally write all vehicles, persons and containers sorted by depart time (and their associated stops, personPlans, etc.)
2486 if (vehiclesSortedByDepart.size() > 0) {
2487 device << (" <!-- Vehicles, persons and containers (sorted by depart) -->\n");
2488 for (const auto& vehicleTag : vehiclesSortedByDepart) {
2489 for (const auto& vehicle : vehicleTag.second) {
2490 vehicle.second->writeDemandElement(device);
2491 }
2492 }
2493 }
2494 // calibrator
2495 writeCalibratorComment(device, fileBucket);
2497 // rerouters
2498 writeRerouterComment(device, fileBucket);
2499 writeAdditionalByType(device, fileBucket, {SUMO_TAG_REROUTER});
2500 // MeanDataEdges
2501 writeMeanDataEdgeComment(device, fileBucket);
2502 writeMeanDatas(device, fileBucket, SUMO_TAG_MEANDATA_EDGE);
2503 // MeanDataLanes
2504 writeMeanDataLaneComment(device, fileBucket);
2505 writeMeanDatas(device, fileBucket, SUMO_TAG_MEANDATA_LANE);
2506}
2507
2508
2509void
2510GNENet::writeAdditionalByType(OutputDevice& device, const FileBucket* fileBucket, const std::vector<SumoXMLTag> tags) const {
2511 std::map<std::string, std::vector<GNEAdditional*> > sortedAdditionals;
2512 for (const auto& tag : tags) {
2513 for (const auto& additional : myAttributeCarriers->getAdditionals().at(tag)) {
2514 if ((fileBucket == nullptr) || (additional.second->getFileBucket() == fileBucket)) {
2515 if ((tag == SUMO_TAG_VAPORIZER) || (sortedAdditionals.count(additional.second->getID()) == 0)) {
2516 sortedAdditionals[additional.second->getID()].push_back(additional.second);
2517 } else {
2518 throw ProcessError(TL("Duplicated ID"));
2519 }
2520 }
2521 }
2522 }
2523 for (const auto& additionalVector : sortedAdditionals) {
2524 for (const auto& additional : additionalVector.second) {
2525 additional->writeAdditional(device);
2526 }
2527 }
2528}
2529
2530
2531void
2532GNENet::writeDemandByType(OutputDevice& device, const FileBucket* fileBucket, SumoXMLTag tag) const {
2533 std::map<std::string, GNEDemandElement*> sortedDemandElements;
2534 for (const auto& demandElement : myAttributeCarriers->getDemandElements().at(tag)) {
2535 if (demandElement.second->getFileBucket() == fileBucket) {
2536 sortedDemandElements[demandElement.second->getID()] = demandElement.second;
2537 }
2538 }
2539 for (const auto& demandElement : sortedDemandElements) {
2540 demandElement.second->writeDemandElement(device);
2541 }
2542}
2543
2544
2545void
2547 std::map<std::string, GNEDemandElement*> sortedElements;
2548 // first write route Distributions
2549 for (const auto& routeDistribution : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE_DISTRIBUTION)) {
2550 if (routeDistribution.second->getFileBucket() == fileBucket) {
2551 sortedElements[routeDistribution.second->getID()] = routeDistribution.second;
2552 }
2553 }
2554 for (const auto& element : sortedElements) {
2555 element.second->writeDemandElement(device);
2556 }
2557}
2558
2559
2560void
2561GNENet::writeRoutes(OutputDevice& device, const FileBucket* fileBucket) const {
2562 std::map<std::string, GNEDemandElement*> sortedRoutes;
2563 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
2564 if (route.second->getFileBucket() == fileBucket) {
2565 sortedRoutes[route.second->getID()] = route.second;
2566 }
2567 }
2568 for (const auto& route : sortedRoutes) {
2569 route.second->writeDemandElement(device);
2570 }
2571}
2572
2573
2574void
2576 std::map<std::string, GNEDemandElement*> sortedElements;
2577 // first write vType Distributions
2578 for (const auto& vTypeDistribution : myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE_DISTRIBUTION)) {
2579 if (vTypeDistribution.second->getFileBucket() == fileBucket) {
2580 sortedElements[vTypeDistribution.second->getID()] = vTypeDistribution.second;
2581 }
2582 }
2583 for (const auto& element : sortedElements) {
2584 element.second->writeDemandElement(device);
2585 }
2586}
2587
2588
2589void
2590GNENet::writeVTypes(OutputDevice& device, const FileBucket* fileBucket) const {
2591 std::map<std::string, GNEDemandElement*> sortedVTypes;
2592 for (const auto& vType : myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE)) {
2593 if (vType.second->getFileBucket() == fileBucket) {
2594 sortedVTypes[vType.second->getID()] = vType.second;
2595 }
2596 }
2597 for (const auto& vType : sortedVTypes) {
2598 vType.second->writeDemandElement(device);
2599 }
2600}
2601
2602
2603void
2604GNENet::writeMeanDatas(OutputDevice& device, const FileBucket* fileBucket, SumoXMLTag tag) const {
2605 std::map<std::string, GNEMeanData*> sortedMeanDatas;
2606 for (const auto& meanData : myAttributeCarriers->getMeanDatas().at(tag)) {
2607 if (meanData.second->getFileBucket() == fileBucket) {
2608 if (sortedMeanDatas.count(meanData.second->getID()) == 0) {
2609 sortedMeanDatas[meanData.second->getID()] = meanData.second;
2610 } else {
2611 throw ProcessError(TL("Duplicated ID"));
2612 }
2613 }
2614 }
2615 for (const auto& additional : sortedMeanDatas) {
2616 additional.second->writeMeanData(device);
2617 }
2618}
2619
2620bool
2621GNENet::writeVTypeComment(OutputDevice& device, const FileBucket* fileBucket) const {
2622 // vTypes
2623 for (const auto& vType : myAttributeCarriers->getDemandElements().at(SUMO_TAG_VTYPE)) {
2624 // special case for default vTypes
2625 const bool defaultVType = GNEAttributeCarrier::parse<bool>(vType.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE));
2626 const bool defaultVTypeModified = GNEAttributeCarrier::parse<bool>(vType.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE_MODIFIED));
2627 // only write default vType modified
2628 if ((vType.second->getParentDemandElements().size() == 0) && (!defaultVType || (defaultVType && defaultVTypeModified))) {
2629 if (vType.second->getFileBucket() == fileBucket) {
2630 device << (" <!-- VTypes -->\n");
2631 return true;
2632 }
2633 }
2634 }
2635 return false;
2636}
2637
2638
2639bool
2640GNENet::writeRouteComment(OutputDevice& device, const FileBucket* fileBucket) const {
2641 for (const auto& route : myAttributeCarriers->getDemandElements().at(SUMO_TAG_ROUTE)) {
2642 if (route.second->getFileBucket() == fileBucket) {
2643 device << (" <!-- Routes -->\n");
2644 return true;
2645 }
2646 }
2647 return false;
2648}
2649
2650
2651bool
2652GNENet::writeRerouterComment(OutputDevice& device, const FileBucket* fileBucket) const {
2653 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_REROUTER)) {
2654 if (routeProbe.second->getFileBucket() == fileBucket) {
2655 device << (" <!-- Rerouter -->\n");
2656 return true;
2657 }
2658 }
2659 return false;
2660}
2661
2662
2663bool
2665 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_VSS)) {
2666 if (routeProbe.second->getFileBucket() == fileBucket) {
2667 device << (" <!-- VariableSpeedSigns -->\n");
2668 return true;
2669 }
2670 }
2671 return false;
2672}
2673
2674
2675bool
2676GNENet::writeRouteProbeComment(OutputDevice& device, const FileBucket* fileBucket) const {
2677 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_ROUTEPROBE)) {
2678 if (routeProbe.second->getFileBucket() == fileBucket) {
2679 device << (" <!-- RouteProbes -->\n");
2680 return true;
2681 }
2682 }
2683 return false;
2684}
2685
2686
2687bool
2688GNENet::writeVaporizerComment(OutputDevice& device, const FileBucket* fileBucket) const {
2689 for (const auto& routeProbe : myAttributeCarriers->getAdditionals().at(SUMO_TAG_VAPORIZER)) {
2690 if (routeProbe.second->getFileBucket() == fileBucket) {
2691 device << (" <!-- Vaporizers -->\n");
2692 return true;
2693 }
2694 }
2695 return false;
2696}
2697
2698
2699bool
2700GNENet::writeCalibratorComment(OutputDevice& device, const FileBucket* fileBucket) const {
2701 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2702 for (const auto& additional : additionalTag.second) {
2703 if (additional.second->getTagProperty()->isCalibrator() &&
2704 (additional.second->getFileBucket() == fileBucket)) {
2705 device << (" <!-- Calibrators -->\n");
2706 return true;
2707 }
2708 }
2709 }
2710 return false;
2711}
2712
2713
2714bool
2716 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2717 for (const auto& additional : additionalTag.second) {
2718 if (additional.second->getTagProperty()->isStoppingPlace() &&
2719 (additional.second->getFileBucket() == fileBucket)) {
2720 device << (" <!-- StoppingPlaces -->\n");
2721 return true;
2722 }
2723 }
2724 }
2725 return false;
2726}
2727
2728
2729bool
2730GNENet::writeDetectorComment(OutputDevice& device, const FileBucket* fileBucket) const {
2731 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2732 for (const auto& additional : additionalTag.second) {
2733 if (additional.second->getTagProperty()->isDetector() &&
2734 (additional.second->getFileBucket() == fileBucket)) {
2735 device << (" <!-- Detectors -->\n");
2736 return true;
2737 }
2738 }
2739 }
2740 return false;
2741}
2742
2743
2744bool
2745GNENet::writeShapesComment(OutputDevice& device, const FileBucket* fileBucket) const {
2746 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2747 for (const auto& additional : additionalTag.second) {
2748 if (additional.second->getTagProperty()->isShapeElement() &&
2749 (additional.second->getFileBucket() == fileBucket) &&
2750 !additional.second->getTagProperty()->isJuPedSimElement()) {
2751 device << (" <!-- Shapes -->\n");
2752 return true;
2753 }
2754 }
2755 }
2756 return false;
2757}
2758
2759
2760bool
2761GNENet::writeJuPedSimComment(OutputDevice& device, const FileBucket* fileBucket) const {
2762 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2763 for (const auto& additional : additionalTag.second) {
2764 if (additional.second->getTagProperty()->isJuPedSimElement() &&
2765 ((fileBucket == nullptr) || (additional.second->getFileBucket() == fileBucket))) {
2766 device << (" <!-- JuPedSim elements -->\n");
2767 return true;
2768 }
2769 }
2770 }
2771 return false;
2772}
2773
2774
2775bool
2776GNENet::writeTAZComment(OutputDevice& device, const FileBucket* fileBucket) const {
2777 for (const auto& TAZ : myAttributeCarriers->getAdditionals().at(SUMO_TAG_TAZ)) {
2778 if (TAZ.second->getFileBucket() == fileBucket) {
2779 device << (" <!-- TAZs -->\n");
2780 return true;
2781 }
2782 }
2783 return false;
2784}
2785
2786
2787bool
2788GNENet::writeWireComment(OutputDevice& device, const FileBucket* fileBucket) const {
2789 for (const auto& additionalTag : myAttributeCarriers->getAdditionals()) {
2790 for (const auto& additional : additionalTag.second) {
2791 if (additional.second->getTagProperty()->isWireElement() &&
2792 (additional.second->getFileBucket() == fileBucket)) {
2793 device << (" <!-- Wires -->\n");
2794 return true;
2795 }
2796 }
2797 }
2798 return false;
2799}
2800
2801
2802bool
2804 for (const auto& meanDataEdge : myAttributeCarriers->getMeanDatas().at(SUMO_TAG_MEANDATA_EDGE)) {
2805 if (meanDataEdge.second->getFileBucket() == fileBucket) {
2806 device << (" <!-- MeanDataEdges -->\n");
2807 return true;
2808 }
2809 }
2810 return false;
2811}
2812
2813
2814bool
2816 for (const auto& meanDataLane : myAttributeCarriers->getMeanDatas().at(SUMO_TAG_MEANDATA_LANE)) {
2817 if (meanDataLane.second->getFileBucket() == fileBucket) {
2818 device << (" <!-- MeanDataLanes -->\n");
2819 return true;
2820 }
2821 }
2822 return false;
2823}
2824
2825
2826void
2827GNENet::saveTLSPrograms(const std::string& filename) {
2828 // open output device
2829 OutputDevice& device = OutputDevice::getDevice(filename);
2830 device.openTag("additionals");
2831 // write traffic lights using NWWriter
2833 device.close();
2834 // change save status
2836}
2837
2838
2839int
2841 return -1;
2842}
2843
2844
2845void
2846GNENet::saveEdgeTypes(const std::string& filename) {
2847 // first clear typeContainer
2849 // now update typeContainer with edgeTypes
2850 for (const auto& edgeType : myAttributeCarriers->getEdgeTypes()) {
2851 myNetBuilder->getTypeCont().insertEdgeType(edgeType.first, edgeType.second);
2852 for (int i = 0; i < (int)edgeType.second->getLaneTypes().size(); i++) {
2853 myNetBuilder->getTypeCont().insertLaneType(edgeType.first, i,
2854 edgeType.second->getLaneTypes().at(i)->speed,
2855 edgeType.second->getLaneTypes().at(i)->permissions,
2856 edgeType.second->getLaneTypes().at(i)->width,
2857 edgeType.second->getLaneTypes().at(i)->attrs);
2858 }
2859 }
2860 // open device
2861 OutputDevice& device = OutputDevice::getDevice(filename);
2862 // open tag
2863 device.openTag(SUMO_TAG_TYPES);
2864 // write edge types
2866 // close tag
2867 device.closeTag();
2868 // close device
2869 device.close();
2870}
2871
2872
2873void
2877
2878
2879void
2883
2884
2885bool
2889
2890
2891void
2893 myUpdateDataEnabled = true;
2894 // update data elements
2895 for (const auto& dataInterval : myAttributeCarriers->getDataIntervals()) {
2896 dataInterval.second->updateGenericDataIDs();
2897 dataInterval.second->updateAttributeColors();
2898 }
2899}
2900
2901
2902void
2906
2907
2908bool
2912
2913
2914unsigned int&
2918
2919
2920unsigned int&
2924
2925// ===========================================================================
2926// private
2927// ===========================================================================
2928
2929void
2931 // init edge types
2932 for (const auto& edgeType : myNetBuilder->getTypeCont()) {
2933 // register edge type
2934 myAttributeCarriers->registerEdgeType(new GNEEdgeType(this, edgeType.first, edgeType.second));
2935 }
2936 // init junctions (by default Crossing and walking areas aren't created)
2937 for (const auto& nodeName : myNetBuilder->getNodeCont().getAllNames()) {
2938 // create and register junction
2940 }
2941 // init edges
2942 for (const auto& edgeName : myNetBuilder->getEdgeCont().getAllNames()) {
2943 // create edge using NBEdge
2944 GNEEdge* edge = new GNEEdge(this, myNetBuilder->getEdgeCont().retrieve(edgeName), false, true);
2945 // register edge
2947 // add manually child references due initJunctionsAndEdges doesn't use undo-redo
2948 edge->getFromJunction()->addChildElement(edge);
2949 edge->getToJunction()->addChildElement(edge);
2950 // check grid
2951 if (myGrid.getWidth() > 10e16 || myGrid.getHeight() > 10e16) {
2952 throw ProcessError(TL("Network size exceeds 1 Lightyear. Please reconsider your inputs.") + std::string("\n"));
2953 }
2954 }
2955 // make sure myGrid is initialized even for an empty net. This ensure that the network starts with a zoom of 100
2956 if (myAttributeCarriers->getEdges().size() == 0) {
2957 myGrid.add(Boundary(-50, -50, 50, 50));
2958 }
2959 // recalculate all lane2lane connections
2960 for (const auto& edge : myAttributeCarriers->getEdges()) {
2961 for (const auto& lane : edge.second->getChildLanes()) {
2962 lane->updateGeometry();
2963 }
2964 }
2965 // sort nodes edges so that arrows can be drawn correctly
2967}
2968
2969
2970void
2972 for (const auto& edge : myAttributeCarriers->getEdges()) {
2973 // remake connections
2974 edge.second->remakeGNEConnections();
2975 // update geometry of connections
2976 for (const auto& connection : edge.second->getGNEConnections()) {
2977 connection->updateGeometry();
2978 }
2979 }
2980}
2981
2982
2983void
2984GNENet::computeAndUpdate(OptionsCont& neteditOptions, bool volatileOptions) {
2985 // make sure we only add turn arounds to edges which currently exist within the network
2986 std::set<std::string> liveExplicitTurnarounds;
2987 for (const auto& explicitTurnarounds : myExplicitTurnarounds) {
2988 if (myAttributeCarriers->getEdges().count(explicitTurnarounds) > 0) {
2989 liveExplicitTurnarounds.insert(explicitTurnarounds);
2990 }
2991 }
2992 // removes all junctions of grid
2993 for (const auto& junction : myAttributeCarriers->getJunctions()) {
2994 removeGLObjectFromGrid(junction.second);
2995 }
2996 // remove all edges from grid
2997 for (const auto& edge : myAttributeCarriers->getEdges()) {
2998 removeGLObjectFromGrid(edge.second);
2999 }
3000 // compute using NetBuilder
3001 myNetBuilder->compute(neteditOptions, liveExplicitTurnarounds, volatileOptions);
3002 // remap ids if necessary
3003 if (neteditOptions.getBool("numerical-ids") || neteditOptions.isSet("reserved-ids")) {
3005 }
3006 // update rtree if necessary
3007 if (!neteditOptions.getBool("offset.disable-normalization")) {
3008 for (const auto& edge : myAttributeCarriers->getEdges()) {
3009 // refresh edge geometry
3010 edge.second->updateGeometry();
3011 }
3012 }
3013 // Clear current inspected ACs in inspectorFrame if a previous net was loaded
3014 if (myApplicationWindow->getViewNet() != nullptr) {
3016 }
3017 // Reset Grid
3018 myGrid.reset();
3020 // if volatile options are true
3021 if (volatileOptions) {
3022 // check that net exist
3023 if (myApplicationWindow->getViewNet() == nullptr) {
3024 throw ProcessError("ViewNet doesn't exist");
3025 }
3026 // disable update geometry before clear undo list
3028 // destroy Popup
3030 // clear undo list (This will be remove additionals and shapes)
3032 // clear all elements (it will also removed from grid)
3037 // enable update geometry again
3039 // init again junction an edges (Additionals and shapes will be loaded after the end of this function)
3041 // init default vTypes again
3043 } else {
3044 // insert all junctions of grid again
3045 for (const auto& junction : myAttributeCarriers->getJunctions()) {
3046 // update centering boundary
3047 junction.second->updateCenteringBoundary(false);
3048 // add junction in grid again
3049 addGLObjectIntoGrid(junction.second);
3050 }
3051 // insert all edges from grid again
3052 for (const auto& edge : myAttributeCarriers->getEdges()) {
3053 // update centeting boundary
3054 edge.second->updateCenteringBoundary(false);
3055 // add edge in grid again
3056 addGLObjectIntoGrid(edge.second);
3057 }
3058 // remake connections
3059 for (const auto& edge : myAttributeCarriers->getEdges()) {
3060 edge.second->remakeGNEConnections(true);
3061 }
3062 // iterate over junctions of net
3063 for (const auto& junction : myAttributeCarriers->getJunctions()) {
3064 // undolist may not yet exist but is also not needed when just marking junctions as valid
3065 junction.second->setLogicValid(true, nullptr);
3066 // updated geometry
3067 junction.second->updateGeometryAfterNetbuild();
3068 // rebuild walking areas
3069 junction.second->rebuildGNEWalkingAreas();
3070 }
3071 // iterate over all edges of net
3072 for (const auto& edge : myAttributeCarriers->getEdges()) {
3073 // update geometry
3074 edge.second->updateGeometry();
3075 }
3076 }
3077 // net recomputed, then return false;
3078 myNeedRecompute = false;
3079}
3080
3081
3082void
3083GNENet::replaceInListAttribute(GNEAttributeCarrier* ac, SumoXMLAttr key, const std::string& which, const std::string& by, GNEUndoList* undoList) {
3084 assert(ac->getTagProperty()->getAttributeProperties(key)->isList());
3085 std::vector<std::string> values = GNEAttributeCarrier::parse<std::vector<std::string> >(ac->getAttribute(key));
3086 std::vector<std::string> newValues;
3087 bool lastBy = false;
3088 for (auto v : values) {
3089 if (v == which && !lastBy) {
3090 // avoid duplicate occurence of the 'by' edge (i.e. in routes)
3091 newValues.push_back(by);
3092 } else {
3093 newValues.push_back(v);
3094 }
3095 lastBy = v == by;
3096 }
3097 ac->setAttribute(key, toString(newValues), undoList);
3098}
3099
3100
3101/****************************************************************************/
@ 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:1241
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:766
GNEEdge * getReverseEdge() const
get reverse edge (if exist)
Definition GNEEdge.cpp:1779
std::vector< GNEEdge * > getOppositeEdges() const
get opposite edges
Definition GNEEdge.cpp:700
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:1106
void copyTemplate(const GNEEdgeTemplate *edgeTemplate, GNEUndoList *undoList)
copy edge attributes from edgetemplate
Definition GNEEdge.cpp:1035
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition GNEEdge.cpp:1100
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:1112
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:1944
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:2134
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition GNENet.cpp:1791
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:2510
bool joinSelectedJunctions(GNEUndoList *undoList)
join selected junctions
Definition GNENet.cpp:1631
bool writeJuPedSimComment(OutputDevice &device, const FileBucket *fileBucket) const
write JuPedSim comment
Definition GNENet.cpp:2761
double getDataSetIntervalMaximumEnd() const
get maximum interval
Definition GNENet.cpp:2385
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:2676
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition GNENet.cpp:739
bool saveMeanDatas()
save meanData elements of the network
Definition GNENet.cpp:2402
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition GNENet.cpp:2880
void saveTLSPrograms(const std::string &filename)
save TLS Programs elements of the network
Definition GNENet.cpp:2827
void computeAndUpdate(OptionsCont &neteditOptions, bool volatileOptions)
recompute the network and update lane geometries
Definition GNENet.cpp:2984
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:2575
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1449
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:2776
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1459
void saveJoined(const std::string &filename)
save log of joined junctions (and nothing else)
Definition GNENet.cpp:1441
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition GNENet.cpp:2202
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:2892
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:2428
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:2846
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:2604
bool writeStoppingPlaceComment(OutputDevice &device, const FileBucket *fileBucket) const
write stoppingPlace comment
Definition GNENet.cpp:2715
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:2169
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:2337
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
Definition GNENet.cpp:706
void clearDemandElements(GNEUndoList *undoList)
clear demand elements
Definition GNENet.cpp:2147
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:198
void adjustPersonPlans(GNEUndoList *undoList)
adjust person plans
Definition GNENet.cpp:1897
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:1469
void cleanInvalidDemandElements(GNEUndoList *undoList)
clean invalid demand elements
Definition GNENet.cpp:1942
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:1807
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:2220
bool writeCalibratorComment(OutputDevice &device, const FileBucket *fileBucket) const
write calibrator comment
Definition GNENet.cpp:2700
void computeJunction(GNEJunction *junction)
trigger recomputation of junction shape and logic param[in] window The window to inform about delay
Definition GNENet.cpp:1601
void resetJunctionConnections(GNEJunction *junction, GNEUndoList *undoList)
reset junction's connections
Definition GNENet.cpp:2123
bool writeRouteComment(OutputDevice &device, const FileBucket *fileBucket) const
write route comment
Definition GNENet.cpp:2640
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:2745
bool writeMeanDataEdgeComment(OutputDevice &device, const FileBucket *fileBucket) const
write meanDataEdge comment
Definition GNENet.cpp:2803
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:2561
bool writeMeanDataLaneComment(OutputDevice &device, const FileBucket *fileBucket) const
write Wire comment
Definition GNENet.cpp:2815
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:2193
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:2930
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:2180
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:2590
void disableUpdateData()
disable update data elements after inserting or removing an element in net
Definition GNENet.cpp:2903
bool writeRerouterComment(OutputDevice &device, const FileBucket *fileBucket) const
write rerouter comment
Definition GNENet.cpp:2652
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:2226
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:2546
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:2886
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:2621
bool saveJuPedSimElements(const std::string &filename)
save JuPedSim elements
Definition GNENet.cpp:2271
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:1625
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:2909
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:3083
bool writeWireComment(OutputDevice &device, const FileBucket *fileBucket) const
write Wire comment
Definition GNENet.cpp:2788
bool cleanInvalidCrossings(GNEUndoList *undoList)
clear invalid crossings
Definition GNENet.cpp:1749
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:2026
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:1833
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
replace the selected junction by geometry node(s) and merge the edges
Definition GNENet.cpp:1981
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:1619
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:1432
unsigned int myJunctionIDCounter
Definition GNENet.h:537
bool writeDetectorComment(OutputDevice &device, const FileBucket *fileBucket) const
write detector comment
Definition GNENet.cpp:2730
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:2664
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:2214
void initGNEConnections()
initialize GNEConnections
Definition GNENet.cpp:2971
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:2208
GNENet()=delete
Invalidated default constructor.
unsigned int & getJunctionIDCounter()
Definition GNENet.cpp:2915
bool saveDemandElements()
save demand element elements of the network
Definition GNENet.cpp:2288
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:1588
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:2532
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:2840
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:2688
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNENet.cpp:228
void enableUpdateGeometry()
Definition GNENet.cpp:2874
void clearJunctionConnections(GNEJunction *junction, GNEUndoList *undoList)
clear junction's connections
Definition GNENet.cpp:2111
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:2368
void computeDemandElements(GNEApplicationWindow *window)
compute demand elements param[in] window The window to inform about delay
Definition GNENet.cpp:1568
unsigned int & getEdgeIDCounter()
Definition GNENet.cpp:2921
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:4541
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:4379
std::string getLaneID(int lane) const
get lane ID
Definition NBEdge.cpp:4179
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:4892
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