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