Eclipse SUMO - Simulation of Urban MObility
GNENet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A visual container for GNE-network-components such as GNEEdge and GNEJunction.
15 // GNE components wrap netbuild-components and supply visualisation and editing
16 // capabilities (adapted from GUINet)
17 //
18 // WorkrouteFlow (rough draft)
19 // use NILoader to fill
20 // do netedit stuff
21 // call compute to save results
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #include <netbuild/NBAlgorithms.h>
30 #include <netbuild/NBNetBuilder.h>
54 #include <netwrite/NWFrame.h>
55 #include <netwrite/NWWriter_SUMO.h>
56 #include <netwrite/NWWriter_XML.h>
62 #include <utils/xml/XMLSubSys.h>
63 
64 #include "GNEApplicationWindow.h"
65 #include "GNENet.h"
66 #include "GNEViewNet.h"
67 #include "GNEUndoList.h"
68 #include "GNEViewParent.h"
69 
70 
71 // ===========================================================================
72 // FOX callback mapping
73 // ===========================================================================
74 
75 FXIMPLEMENT_ABSTRACT(GNENet::GNEChange_ReplaceEdgeInTLS, GNEChange, nullptr, 0)
76 
77 // ===========================================================================
78 // static members
79 // ===========================================================================
80 
81 const double GNENet::Z_INITIALIZED = 1;
82 
83 // ===========================================================================
84 // member method definitions
85 // ===========================================================================
86 
87 GNENet::GNENet(NBNetBuilder* netBuilder) :
90  myViewNet(nullptr),
91  myNetBuilder(netBuilder),
92  myEdgeIDSupplier("gneE", netBuilder->getEdgeCont().getAllNames()),
93  myJunctionIDSupplier("gneJ", netBuilder->getNodeCont().getAllNames()),
94  myNeedRecompute(true),
95  myNetSaved(true),
96  myAdditionalsSaved(true),
97  myTLSProgramsSaved(true),
98  myDemandElementsSaved(true),
99  myUpdateGeometryEnabled(true),
100  myAllowUndoShapes(true) {
101  // set net in gIDStorage
103  // Write GL debug information
104  WRITE_GLDEBUG("initJunctionsAndEdges function called in GNENet constructor");
105  // init junction and edges
106  initJunctionsAndEdges();
107  // check Z boundary
108  if (myZBoundary.ymin() != Z_INITIALIZED) {
109  myZBoundary.add(0, 0);
110  }
111  // fill additionals with tags (note: this include the TAZS)
112  auto listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_ADDITIONAL, false);
113  for (auto i : listOfTags) {
114  myAttributeCarriers.additionals.insert(std::make_pair(i, std::map<std::string, GNEAdditional*>()));
115  }
116  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_TAZ, false);
117  for (auto i : listOfTags) {
118  myAttributeCarriers.additionals.insert(std::make_pair(i, std::map<std::string, GNEAdditional*>()));
119  }
120 
121  // fill demand elements with tags
122  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_DEMANDELEMENT, false);
123  for (auto i : listOfTags) {
124  myAttributeCarriers.demandElements.insert(std::make_pair(i, std::map<std::string, GNEDemandElement*>()));
125  }
126  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_STOP, false);
127  for (auto i : listOfTags) {
128  myAttributeCarriers.demandElements.insert(std::make_pair(i, std::map<std::string, GNEDemandElement*>()));
129  }
130 }
131 
132 
134  // Decrease reference of Polys (needed after volatile recomputing)
135  for (auto i : myPolygons) {
136  dynamic_cast<GNEAttributeCarrier*>(i.second)->decRef("GNENet::~GNENet");
137  }
138  // Decrease reference of POIs (needed after volatile recomputing)
139  for (auto i : myPOIs) {
140  dynamic_cast<GNEAttributeCarrier*>(i.second)->decRef("GNENet::~GNENet");
141  }
142  // Drop Edges
143  for (auto it : myAttributeCarriers.edges) {
144  it.second->decRef("GNENet::~GNENet");
145  // show extra information for tests
146  WRITE_DEBUG("Deleting unreferenced " + it.second->getTagStr() + " '" + it.second->getID() + "' in GNENet destructor");
147  delete it.second;
148  }
149  // Drop junctions
150  for (auto it : myAttributeCarriers.junctions) {
151  it.second->decRef("GNENet::~GNENet");
152  // show extra information for tests
153  WRITE_DEBUG("Deleting unreferenced " + it.second->getTagStr() + " '" + it.second->getID() + "' in GNENet destructor");
154  delete it.second;
155  }
156  // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
157  for (auto it : myAttributeCarriers.additionals) {
158  for (auto j : it.second) {
159  // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
160  j.second->decRef();
161  // show extra information for tests
162  WRITE_DEBUG("Deleting unreferenced " + j.second->getTagStr() + " '" + j.second->getID() + "' in GNENet destructor");
163  delete j.second;
164  }
165  }
166  // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
167  for (auto it : myAttributeCarriers.demandElements) {
168  for (auto j : it.second) {
169  // decrease reference manually (because it was increased manually in GNERouteHandler)
170  j.second->decRef();
171  // show extra information for tests
172  WRITE_DEBUG("Deleting unreferenced " + j.second->getTagStr() + " '" + j.second->getID() + "' in GNENet destructor");
173  delete j.second;
174  }
175  }
176  // delete RouteCalculator instance of GNEDemandElement
178  // show extra information for tests
179  WRITE_DEBUG("Deleting net builder in GNENet destructor");
180  delete myNetBuilder;
181 }
182 
183 
184 const Boundary&
186  // SUMORTree is also a Boundary
187  return myGrid;
188 }
189 
190 
193  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
194  buildPopupHeader(ret, app);
196  buildPositionCopyEntry(ret, false);
197  return ret;
198 }
199 
200 
203  // Nets lanes don't have attributes
204  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 2);
205  // close building
206  ret->closeBuilding();
207  return ret;
208 }
209 
210 
211 void
213 }
214 
215 
216 bool
217 GNENet::addPolygon(const std::string& id, const std::string& type, const RGBColor& color, double layer, double angle,
218  const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill, double lineWidth, bool /*ignorePruning*/) {
219  // check if ID is duplicated
220  if (myPolygons.get(id) == nullptr) {
221  // create poly
222  GNEPoly* poly = new GNEPoly(this, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, false, false);
223  if (myAllowUndoShapes) {
225  myViewNet->getUndoList()->add(new GNEChange_Shape(poly, true), true);
227  } else {
228  // insert shape without allowing undo/redo
229  insertShape(poly, true);
230  poly->incRef("addPolygon");
231  }
232  return true;
233  } else {
234  return false;
235  }
236 }
237 
238 
239 bool
240 GNENet::addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,
241  const std::string& lane, double posOverLane, double posLat, double layer, double angle,
242  const std::string& imgFile, bool relativePath, double width, double height, bool /*ignorePruning*/) {
243  // check if ID is duplicated
244  if (myPOIs.get(id) == nullptr) {
245  // create POI or POILane depending of parameter lane
246  if (lane == "") {
247  // create POI
248  GNEPOI* poi = new GNEPOI(this, id, type, color, pos, geo, layer, angle, imgFile, relativePath, width, height, false);
249  if (myPOIs.add(poi->getID(), poi)) {
250  if (myAllowUndoShapes) {
251  myViewNet->getUndoList()->p_begin("add " + poi->getTagStr());
252  myViewNet->getUndoList()->add(new GNEChange_Shape(poi, true), true);
254  } else {
255  // insert shape without allowing undo/redo
256  insertShape(poi, true);
257  poi->incRef("addPOI");
258  }
259  return true;
260  } else {
261  throw ProcessError("Error adding GNEPOI into shapeContainer");
262  }
263  } else {
264  // create POI over lane
265  GNELane* retrievedLane = retrieveLane(lane);
266  GNEPOI* poi = new GNEPOI(this, id, type, color, layer, angle, imgFile, relativePath, retrievedLane, posOverLane, posLat, width, height, false);
267  if (myPOIs.add(poi->getID(), poi)) {
268  if (myAllowUndoShapes) {
269  myViewNet->getUndoList()->p_begin("add " + poi->getTagStr());
270  myViewNet->getUndoList()->add(new GNEChange_Shape(poi, true), true);
272  } else {
273  // insert shape without allowing undo/redo
274  insertShape(poi, true);
275  poi->incRef("addPOI");
276  }
277  return true;
278  } else {
279  throw ProcessError("Error adding GNEPOI over lane into shapeContainer");
280  }
281  }
282  } else {
283  return false;
284  }
285 }
286 
287 
288 Boundary
290  return getBoundary();
291 }
292 
293 
294 const Boundary&
296  return myZBoundary;
297 }
298 
299 
300 SUMORTree&
302  return myGrid;
303 }
304 
305 
306 const SUMORTree&
308  return myGrid;
309 }
310 
311 
314  std::string id = myJunctionIDSupplier.getNext();
315  // create new NBNode
316  NBNode* nbn = new NBNode(id, pos);
317  // create GNEJunciton
318  GNEJunction* junction = new GNEJunction(this, nbn);
319  undoList->add(new GNEChange_Junction(junction, true), true);
320  assert(myAttributeCarriers.junctions[id]);
321  return junction;
322 }
323 
324 
325 GNEEdge*
327  GNEJunction* src, GNEJunction* dest, GNEEdge* tpl, GNEUndoList* undoList,
328  const std::string& suggestedName,
329  bool wasSplit,
330  bool allowDuplicateGeom,
331  bool recomputeConnections) {
332  // prevent duplicate edge (same geometry)
333  const EdgeVector& outgoing = src->getNBNode()->getOutgoingEdges();
334  for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
335  if ((*it)->getToNode() == dest->getNBNode() && (*it)->getGeometry().size() == 2) {
336  if (!allowDuplicateGeom) {
337  return nullptr;
338  }
339  }
340  }
341 
342  std::string id;
343  if (suggestedName != "" && !retrieveEdge(suggestedName, false)) {
344  id = suggestedName;
345  reserveEdgeID(id);
346  } else {
347  id = myEdgeIDSupplier.getNext();
348  }
349 
350  GNEEdge* edge;
351  if (tpl) {
352  NBEdge* nbeTpl = tpl->getNBEdge();
353  NBEdge* nbe = new NBEdge(id, src->getNBNode(), dest->getNBNode(), nbeTpl);
354  edge = new GNEEdge(this, nbe, wasSplit);
355  } else {
356  // default if no template is given
357  const OptionsCont& oc = OptionsCont::getOptions();
358  double defaultSpeed = oc.getFloat("default.speed");
359  std::string defaultType = oc.getString("default.type");
360  int defaultNrLanes = oc.getInt("default.lanenumber");
361  int defaultPriority = oc.getInt("default.priority");
362  double defaultWidth = NBEdge::UNSPECIFIED_WIDTH;
363  double defaultOffset = NBEdge::UNSPECIFIED_OFFSET;
364  NBEdge* nbe = new NBEdge(id, src->getNBNode(), dest->getNBNode(),
365  defaultType, defaultSpeed,
366  defaultNrLanes, defaultPriority,
367  defaultWidth,
368  defaultOffset);
369  edge = new GNEEdge(this, nbe, wasSplit);
370  }
371  undoList->p_begin("create " + toString(SUMO_TAG_EDGE));
372  undoList->add(new GNEChange_Edge(edge, true), true);
373  if (recomputeConnections) {
374  src->setLogicValid(false, undoList);
375  dest->setLogicValid(false, undoList);
376  }
378  undoList->p_end();
379  assert(myAttributeCarriers.edges[id]);
380  return edge;
381 }
382 
383 
384 void
386  // we have to delete all incident edges because they cannot exist without that junction
387  // all deletions must be undone/redone together so we start a new command group
388  // @todo if any of those edges are dead-ends should we remove their orphan junctions as well?
389  undoList->p_begin("delete " + toString(SUMO_TAG_JUNCTION));
390 
391  // delete all crossings vinculated with junction
392  while (junction->getGNECrossings().size() > 0) {
393  deleteCrossing(junction->getGNECrossings().front(), undoList);
394  }
395 
396  // find all crossings of neightbour junctions that shares an edge of this junction
397  std::vector<GNECrossing*> crossingsToRemove;
398  std::vector<GNEJunction*> junctionNeighbours = junction->getJunctionNeighbours();
399  for (auto i : junctionNeighbours) {
400  // iterate over crossing of neighbour juntion
401  for (auto j : i->getGNECrossings()) {
402  // if at least one of the edges of junction to remove belongs to a crossing of the neighbour junction, delete it
403  if (j->checkEdgeBelong(junction->getGNEEdges())) {
404  crossingsToRemove.push_back(j);
405  }
406  }
407  }
408 
409  // delete crossings top remove
410  for (auto i : crossingsToRemove) {
411  deleteCrossing(i, undoList);
412  }
413 
414  // deleting edges changes in the underlying EdgeVector so we have to make a copy
415  const EdgeVector incident = junction->getNBNode()->getEdges();
416  for (auto it : incident) {
417  deleteEdge(myAttributeCarriers.edges[it->getID()], undoList, true);
418  }
419 
420  // remove any traffic lights from the traffic light container (avoids lots of warnings)
421  junction->setAttribute(SUMO_ATTR_TYPE, toString(NODETYPE_PRIORITY), undoList);
422 
423  // delete edge
424  undoList->add(new GNEChange_Junction(junction, false), true);
425  undoList->p_end();
426 }
427 
428 
429 void
430 GNENet::deleteEdge(GNEEdge* edge, GNEUndoList* undoList, bool recomputeConnections) {
431  undoList->p_begin("delete " + toString(SUMO_TAG_EDGE));
432  // delete all shapes children of edge
433  while (edge->getChildShapes().size() > 0) {
434  deleteShape(edge->getChildShapes().front(), undoList);
435  }
436  // delete all shapes children of lane
437  for (auto i : edge->getLanes()) {
438  while (i->getChildShapes().size() > 0) {
439  deleteShape(i->getChildShapes().front(), undoList);
440  }
441  }
442  // delete all child edge demand elements
443  while (edge->getChildDemandElements().size() > 0) {
444  deleteDemandElement(edge->getChildDemandElements().front(), undoList);
445  }
446  // delete all child demand elementss of edge's lanes
447  for (auto i : edge->getLanes()) {
448  while (i->getChildDemandElements().size() > 0) {
449  deleteDemandElement(i->getChildDemandElements().front(), undoList);
450  }
451  }
452  // delete all child edge additional
453  while (edge->getChildAdditionals().size() > 0) {
454  deleteAdditional(edge->getChildAdditionals().front(), undoList);
455  }
456  // delete all child additional of edge's lanes
457  for (auto i : edge->getLanes()) {
458  while (i->getChildAdditionals().size() > 0) {
459  deleteAdditional(i->getChildAdditionals().front(), undoList);
460  }
461  }
462  // invalidate path element childrens
464  // remove edge from crossings related with this edge
465  edge->getGNEJunctionSource()->removeEdgeFromCrossings(edge, undoList);
466  edge->getGNEJunctionDestiny()->removeEdgeFromCrossings(edge, undoList);
467  // update affected connections
468  if (recomputeConnections) {
469  edge->getGNEJunctionSource()->setLogicValid(false, undoList);
470  edge->getGNEJunctionDestiny()->setLogicValid(false, undoList);
471  } else {
472  edge->getGNEJunctionSource()->removeConnectionsTo(edge, undoList, true);
473  edge->getGNEJunctionSource()->removeConnectionsFrom(edge, undoList, true);
474  }
475  // if junction source is a TLS and after deletion will have only an edge, remove TLS
476  if (edge->getGNEJunctionSource()->getNBNode()->isTLControlled() && (edge->getGNEJunctionSource()->getGNEOutgoingEdges().size() <= 1)) {
478  }
479  // if junction destiny is a TLS and after deletion will have only an edge, remove TLS
480  if (edge->getGNEJunctionDestiny()->getNBNode()->isTLControlled() && (edge->getGNEJunctionDestiny()->getGNEIncomingEdges().size() <= 1)) {
482  }
483  // Delete edge
484  undoList->add(new GNEChange_Edge(edge, false), true);
485  // remove edge requires always a recompute (due geometry and connections)
487  // finish delete edge
488  undoList->p_end();
489 }
490 
491 
492 void
494  undoList->p_begin("replace " + toString(SUMO_TAG_EDGE));
495  undoList->p_add(new GNEChange_Attribute(by, this, SUMO_ATTR_TO, which->getAttribute(SUMO_ATTR_TO)));
496  // replace in additionals children of edge
497  while (which->getChildAdditionals().size() > 0) {
498  undoList->p_add(new GNEChange_Attribute(which->getChildAdditionals().front(), this, SUMO_ATTR_EDGE, by->getID()));
499  }
500  // replace in additionals children of lane
501  for (auto i : which->getLanes()) {
502  std::vector<GNEAdditional*> copyOfLaneAdditionals = i->getChildAdditionals();
503  for (auto j : copyOfLaneAdditionals) {
504  undoList->p_add(new GNEChange_Attribute(j, this, SUMO_ATTR_LANE, by->getNBEdge()->getLaneID(i->getIndex())));
505  }
506  }
507  // replace in demand elements children of edge
508  while (which->getChildDemandElements().size() > 0) {
509  undoList->p_add(new GNEChange_Attribute(which->getChildDemandElements().front(), this, SUMO_ATTR_EDGE, by->getID()));
510  }
511  // replace in demand elements children of lane
512  for (auto i : which->getLanes()) {
513  std::vector<GNEDemandElement*> copyOfLaneDemandElements = i->getChildDemandElements();
514  for (auto j : copyOfLaneDemandElements) {
515  undoList->p_add(new GNEChange_Attribute(j, this, SUMO_ATTR_LANE, by->getNBEdge()->getLaneID(i->getIndex())));
516  }
517  }
518  // replace in shapes children of lane
519  for (auto i : which->getLanes()) {
520  std::vector<GNEShape*> copyOfLaneShapes = i->getChildShapes();
521  for (auto j : copyOfLaneShapes) {
522  undoList->p_add(new GNEChange_Attribute(j, this, SUMO_ATTR_LANE, by->getNBEdge()->getLaneID(i->getIndex())));
523  }
524  }
525  // replace in rerouters
526  for (auto rerouter : which->getParentAdditionals()) {
527  replaceInListAttribute(rerouter, SUMO_ATTR_EDGES, which->getID(), by->getID(), undoList);
528  }
529  // replace in crossings
530  for (auto crossing : which->getGNEJunctionDestiny()->getGNECrossings()) {
531  // if at least one of the edges of junction to remove belongs to a crossing of the source junction, delete it
532  replaceInListAttribute(crossing, SUMO_ATTR_EDGES, which->getID(), by->getID(), undoList);
533  }
534  // fix connections (make a copy because they will be modified
535  std::vector<NBEdge::Connection> connections = which->getNBEdge()->getConnections();
536  for (auto con : connections) {
537  undoList->add(new GNEChange_Connection(which, con, false, false), true);
538  undoList->add(new GNEChange_Connection(by, con, false, true), true);
539  }
540  undoList->add(new GNEChange_ReplaceEdgeInTLS(getTLLogicCont(), which->getNBEdge(), by->getNBEdge()), true);
541  // Delete edge
542  undoList->add(new GNEChange_Edge(which, false), true);
543  // finish replace edge
544  undoList->p_end();
545 }
546 
547 
548 void
549 GNENet::deleteLane(GNELane* lane, GNEUndoList* undoList, bool recomputeConnections) {
550  GNEEdge* edge = lane->getParentEdge();
551  if (edge->getNBEdge()->getNumLanes() == 1) {
552  // remove the whole edge instead
553  deleteEdge(edge, undoList, recomputeConnections);
554  } else {
555  undoList->p_begin("delete " + toString(SUMO_TAG_LANE));
556  // delete additionals children of lane
557  while (lane->getChildAdditionals().size() > 0) {
558  deleteAdditional(lane->getChildAdditionals().front(), undoList);
559  }
560  // delete child demand elements of lane
561  while (lane->getChildDemandElements().size() > 0) {
562  deleteDemandElement(lane->getChildDemandElements().front(), undoList);
563  }
564  // delete POIShapes of Lane
565  while (lane->getChildShapes().size() > 0) {
566  undoList->add(new GNEChange_Shape(lane->getChildShapes().front(), false), true);
567  }
568  // update affected connections
569  if (recomputeConnections) {
570  edge->getGNEJunctionSource()->setLogicValid(false, undoList);
571  edge->getGNEJunctionDestiny()->setLogicValid(false, undoList);
572  } else {
573  edge->getGNEJunctionSource()->removeConnectionsTo(edge, undoList, true, lane->getIndex());
574  edge->getGNEJunctionSource()->removeConnectionsFrom(edge, undoList, true, lane->getIndex());
575  }
576  // delete lane
577  const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
578  undoList->add(new GNEChange_Lane(edge, lane, laneAttrs, false, recomputeConnections), true);
579  // remove lane requires always a recompute (due geometry and connections)
581  undoList->p_end();
582  }
583 }
584 
585 
586 void
588  undoList->p_begin("delete " + toString(SUMO_TAG_CONNECTION));
589  // obtain NBConnection to remove
590  NBConnection deleted = connection->getNBConnection();
591  GNEJunction* junctionDestiny = connection->getEdgeFrom()->getGNEJunctionDestiny();
592  junctionDestiny->markAsModified(undoList);
593  undoList->add(new GNEChange_Connection(connection->getEdgeFrom(), connection->getNBEdgeConnection(), connection->isAttributeCarrierSelected(), false), true);
594  junctionDestiny->invalidateTLS(undoList, deleted);
595  // remove connection requires always a recompute (due geometry and connections)
597  undoList->p_end();
598 }
599 
600 
601 void
603  undoList->p_begin("delete crossing");
604  // remove it using GNEChange_Crossing
605  undoList->add(new GNEChange_Crossing(crossing->getParentJunction(), crossing->getNBCrossing()->edges,
606  crossing->getNBCrossing()->width, crossing->getNBCrossing()->priority,
607  crossing->getNBCrossing()->customTLIndex,
608  crossing->getNBCrossing()->customTLIndex2,
609  crossing->getNBCrossing()->customShape,
610  crossing->isAttributeCarrierSelected(),
611  false), true);
612  // remove crossing requires always a recompute (due geometry and connections)
614  undoList->p_end();
615 }
616 
617 
618 void
620  undoList->p_begin("delete " + shape->getTagStr());
621  // delete shape
622  undoList->add(new GNEChange_Shape(shape, false), true);
623  undoList->p_end();
624 }
625 
626 
627 void
629  undoList->p_begin("delete " + additional->getTagStr());
630  // first remove all child demand elements of this additional calling this function recursively
631  while (additional->getChildDemandElements().size() > 0) {
632  deleteDemandElement(additional->getChildDemandElements().front(), undoList);
633  }
634  // first remove all child additional of this additional calling this function recursively
635  while (additional->getChildAdditionals().size() > 0) {
636  deleteAdditional(additional->getChildAdditionals().front(), undoList);
637  }
638  // remove additional
639  undoList->add(new GNEChange_Additional(additional, false), true);
640  undoList->p_end();
641 }
642 
643 
644 void
646  // check that default VTypes aren't removed
647  if ((demandElement->getTagProperty().getTag() == SUMO_TAG_VTYPE) && (GNEAttributeCarrier::parse<bool>(demandElement->getAttribute(GNE_ATTR_DEFAULT_VTYPE)))) {
648  throw ProcessError("Trying to delete a default Vehicle Type");
649  } else {
650  undoList->p_begin("delete " + demandElement->getTagStr());
651  // first remove all child demand elements of this demandElement calling this function recursively
652  while (demandElement->getChildDemandElements().size() > 0) {
653  deleteDemandElement(demandElement->getChildDemandElements().front(), undoList);
654  }
655  // we need an special case for person
656  if (demandElement->getTagProperty().isPersonPlan() && (demandElement->getParentDemandElements().front()->getChildDemandElements().size() == 1)) {
657  // obtain person
658  GNEDemandElement* person = demandElement->getParentDemandElements().front();
659  // remove demandElement
660  undoList->add(new GNEChange_DemandElement(demandElement, false), true);
661  // und now remove person
662  undoList->add(new GNEChange_DemandElement(person, false), true);
663  } else {
664  // remove demandElement
665  undoList->add(new GNEChange_DemandElement(demandElement, false), true);
666 
667  }
668  undoList->p_end();
669  }
670 }
671 
672 
673 void
674 GNENet::duplicateLane(GNELane* lane, GNEUndoList* undoList, bool recomputeConnections) {
675  undoList->p_begin("duplicate " + toString(SUMO_TAG_LANE));
676  GNEEdge* edge = lane->getParentEdge();
677  const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
678  if (recomputeConnections) {
679  edge->getGNEJunctionSource()->setLogicValid(false, undoList);
680  edge->getGNEJunctionSource()->setLogicValid(false, undoList);
681  }
682  GNELane* newLane = new GNELane(edge, lane->getIndex());
683  undoList->add(new GNEChange_Lane(edge, newLane, laneAttrs, true, recomputeConnections), true);
685  undoList->p_end();
686 }
687 
688 
689 bool
691  bool addRestriction = true;
692  if (vclass == SVC_PEDESTRIAN) {
693  GNEEdge* edge = lane->getParentEdge();
694  for (const auto lane : edge->getLanes()) {
695  if (lane->isRestricted(SVC_PEDESTRIAN)) {
696  // prevent adding a 2nd sidewalk
697  addRestriction = false;
698  } else {
699  // ensure that the sidewalk is used exclusively
700  const SVCPermissions allOldWithoutPeds = edge->getNBEdge()->getPermissions(lane->getIndex()) & ~SVC_PEDESTRIAN;
701  lane->setAttribute(SUMO_ATTR_ALLOW, getVehicleClassNames(allOldWithoutPeds), undoList);
702  }
703  }
704  }
705  // restrict the lane
706  if (addRestriction) {
707  const double width = (vclass == SVC_PEDESTRIAN || vclass == SVC_BICYCLE
708  ? OptionsCont::getOptions().getFloat("default.sidewalk-width")
709  : OptionsCont::getOptions().getFloat("default.lanewidth"));
710  lane->setAttribute(SUMO_ATTR_ALLOW, toString(vclass), undoList);
711  lane->setAttribute(SUMO_ATTR_WIDTH, toString(width), undoList);
712  return true;
713  } else {
714  return false;
715  }
716 }
717 
718 
719 bool
720 GNENet::addRestrictedLane(SUMOVehicleClass vclass, GNEEdge* edge, int index, GNEUndoList* undoList) {
721  // First check that edge don't have a restricted lane of the given vclass
722  for (const auto& lane : edge->getLanes()) {
723  if (lane->isRestricted(vclass)) {
724  return false;
725  }
726  }
727  // check that index is correct (index == size adds to the left of the leftmost lane)
728  const int numLanes = (int)edge->getLanes().size();
729  if (index > numLanes) {
730  return false;
731  }
732  if (index < 0) {
733  // guess index from vclass
734  if (vclass == SVC_PEDESTRIAN) {
735  index = 0;
736  } else if (vclass == SVC_BICYCLE) {
737  // add bikelanes to the left of an existing sidewalk
738  index = edge->getLanes()[0]->isRestricted(SVC_PEDESTRIAN) ? 1 : 0;
739  } else if (vclass == SVC_IGNORING || vclass == SVC_BUS) {
740  // add greenVerge to the left of an existing sidewalk or bikeLane
741  // add busLane to the left of an existing sidewalk, bikeLane or greenVerge
742  index = 0;
743  while (index < numLanes && (edge->getNBEdge()->getPermissions(index) & ~(SVC_PEDESTRIAN | SVC_BICYCLE)) == 0) {
744  index++;
745  }
746  }
747  }
748  // duplicate selected lane
749  duplicateLane(edge->getLanes().at(MIN2(index, numLanes - 1)), undoList, true);
750  // transform the created lane
751  return restrictLane(vclass, edge->getLanes().at(index), undoList);
752 }
753 
754 
755 bool
757  // iterate over lanes of edge
758  for (const auto& lane : edge->getLanes()) {
759  if (lane->isRestricted(vclass)) {
760  // Delete lane
761  deleteLane(lane, undoList, true);
762  return true;
763  }
764  }
765  return false;
766 }
767 
768 
770 GNENet::splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction) {
771  // begin undo list
772  undoList->p_begin("split " + toString(SUMO_TAG_EDGE));
773  // check if we have to create a new edge
774  if (newJunction == nullptr) {
775  newJunction = createJunction(pos, undoList);
776  }
777  // obtain edge geometry and split position
778  const PositionVector& oldEdgeGeometry = edge->getNBEdge()->getGeometry();
779  const double edgeSplitPosition = oldEdgeGeometry.nearest_offset_to_point2D(pos, false);
780  // obtain lane geometry and split position (needed for adjust additional and demand childs)
781  const PositionVector& oldLaneGeometry = edge->getLanes().front()->getLaneShape();
782  const double laneSplitPosition = oldLaneGeometry.nearest_offset_to_point2D(pos, false);
783  // split edge geometry in two new geometries using edgeSplitPosition
784  std::pair<PositionVector, PositionVector> newGeoms = oldEdgeGeometry.splitAt(edgeSplitPosition);
785  // get shape end
786  const std::string shapeEnd = edge->getAttribute(GNE_ATTR_SHAPE_END);
787  // figure out the new name
788  int posBase = 0;
789  // set baseName
790  std::string baseName = edge->getMicrosimID();
791  if (edge->wasSplit()) {
792  const std::string::size_type sep_index = baseName.rfind('.');
793  // edge may have been renamed in between
794  if (sep_index != std::string::npos) {
795  std::string posString = baseName.substr(sep_index + 1);
796  if (GNEAttributeCarrier::canParse<int>(posString.c_str())) {
797  ;
798  posBase = GNEAttributeCarrier::parse<int>(posString.c_str());
799  baseName = baseName.substr(0, sep_index); // includes the .
800  }
801  }
802  }
803  baseName += '.';
804  // create a new edge from the new junction to the previous destination
805  GNEEdge* secondPart = createEdge(newJunction, edge->getGNEJunctionDestiny(), edge,
806  undoList, baseName + toString(posBase + (int)edgeSplitPosition), true, false, false);
807  // fix connections from the split edge (must happen before changing SUMO_ATTR_TO)
808  edge->getGNEJunctionDestiny()->replaceIncomingConnections(edge, secondPart, undoList);
809  // remove affected crossings from junction (must happen before changing SUMO_ATTR_TO)
810  std::vector<NBNode::Crossing> affectedCrossings;
811  for (GNECrossing* crossing : edge->getGNEJunctionDestiny()->getGNECrossings()) {
812  if (crossing->checkEdgeBelong(edge)) {
813  NBNode::Crossing nbC = *crossing->getNBCrossing();
814  undoList->add(new GNEChange_Crossing(edge->getGNEJunctionDestiny(), nbC, false), true);
815  EdgeVector newEdges;
816  for (NBEdge* nbEdge : nbC.edges) {
817  if (nbEdge == edge->getNBEdge()) {
818  newEdges.push_back(secondPart->getNBEdge());
819  } else {
820  newEdges.push_back(nbEdge);
821  }
822  }
823  nbC.edges = newEdges;
824  affectedCrossings.push_back(nbC);
825  }
826  }
827  // modify the edge so that it ends at the new junction (and all incoming connections are preserved
828  undoList->p_add(new GNEChange_Attribute(edge, this, SUMO_ATTR_TO, newJunction->getID()));
829  // set first part of geometry
830  newGeoms.first.pop_back();
831  newGeoms.first.erase(newGeoms.first.begin());
832  edge->setAttribute(GNE_ATTR_SHAPE_END, "", undoList);
833  edge->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.first), undoList);
834  // set second part of geometry
835  secondPart->setAttribute(GNE_ATTR_SHAPE_END, shapeEnd, undoList);
836  newGeoms.second.pop_back();
837  newGeoms.second.erase(newGeoms.second.begin());
838  secondPart->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.second), undoList);
839  // reconnect across the split
840  for (int i = 0; i < (int)edge->getLanes().size(); ++i) {
841  undoList->add(new GNEChange_Connection(edge, NBEdge::Connection(i, secondPart->getNBEdge(), i), false, true), true);
842  }
843  // re-add modified crossings
844  for (const auto& nbC : affectedCrossings) {
845  undoList->add(new GNEChange_Crossing(secondPart->getGNEJunctionDestiny(), nbC, true), true);
846  }
847  // Split geometry of all child additional
848  for (const auto& additional : edge->getChildAdditionals()) {
849  additional->splitEdgeGeometry(edgeSplitPosition, edge, secondPart, undoList);
850  }
851  // Split geometry of all child lane additional
852  for (int i = 0; i < (int)edge->getLanes().size(); i++) {
853  for (const auto& additional : edge->getLanes().at(i)->getChildAdditionals()) {
854  additional->splitEdgeGeometry(laneSplitPosition, edge->getLanes().at(i), secondPart->getLanes().at(i), undoList);
855  }
856  }
857  // Split geometry of all child demand elements
858  for (const auto& demandElement : edge->getChildDemandElements()) {
859  demandElement->splitEdgeGeometry(edgeSplitPosition, edge, secondPart, undoList);
860  }
861  // Split geometry of all child lane demand elements
862  for (int i = 0; i < (int)edge->getLanes().size(); i++) {
863  for (const auto& demandElement : edge->getLanes().at(i)->getChildDemandElements()) {
864  demandElement->splitEdgeGeometry(laneSplitPosition, edge->getLanes().at(i), secondPart->getLanes().at(i), undoList);
865  }
866  }
867  // finish undo list
868  undoList->p_end();
869  // return new junction
870  return newJunction;
871 }
872 
873 
874 void
875 GNENet::splitEdgesBidi(GNEEdge* edge, GNEEdge* oppositeEdge, const Position& pos, GNEUndoList* undoList) {
876  GNEJunction* newJunction = nullptr;
877  undoList->p_begin("split " + toString(SUMO_TAG_EDGE) + "s");
878  // split edge and save created junction
879  newJunction = splitEdge(edge, pos, undoList, newJunction);
880  // split second edge
881  splitEdge(oppositeEdge, pos, undoList, newJunction);
882  undoList->p_end();
883 }
884 
885 
886 void
888  undoList->p_begin("reverse " + toString(SUMO_TAG_EDGE));
889  deleteEdge(edge, undoList, false); // still exists. we delete it so we can reuse the name in case of resplit
890  GNEEdge* reversed = createEdge(edge->getGNEJunctionDestiny(), edge->getGNEJunctionSource(), edge, undoList, edge->getID(), false, true);
891  assert(reversed != 0);
892  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
895  undoList->p_end();
896 }
897 
898 
899 GNEEdge*
901  undoList->p_begin("add reversed " + toString(SUMO_TAG_EDGE));
902  GNEEdge* reversed = nullptr;
904  // for rail edges, we assume bi-directional tracks are wanted
905  reversed = createEdge(edge->getGNEJunctionDestiny(), edge->getGNEJunctionSource(), edge, undoList, "-" + edge->getID(), false, true);
906  assert(reversed != 0);
907  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
910  } else {
911  // if the edge is centered it should probably connect somewhere else
912  // make it easy to move and reconnect it
913  PositionVector orig = edge->getNBEdge()->getGeometry();
914  PositionVector origInner = edge->getNBEdge()->getInnerGeometry();
915  const double tentativeShift = edge->getNBEdge()->getTotalWidth() + 2;
916  orig.move2side(-tentativeShift);
917  origInner.move2side(-tentativeShift);
918  GNEJunction* src = createJunction(orig.back(), undoList);
919  GNEJunction* dest = createJunction(orig.front(), undoList);
920  reversed = createEdge(src, dest, edge, undoList, "-" + edge->getID(), false, true);
921  assert(reversed != 0);
922  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(origInner.reverse()), undoList);
923  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(origInner.reverse()), undoList);
924  // select the new edge and its nodes
925  reversed->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
926  src->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
927  dest->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
928  }
929  undoList->p_end();
930  return reversed;
931 }
932 
933 
934 void
936  undoList->p_begin("merge " + toString(SUMO_TAG_JUNCTION) + "s");
937  // place moved junction in the same position of target junction
939  // deleting edges changes in the underlying EdgeVector so we have to make a copy
940  const EdgeVector incoming = moved->getNBNode()->getIncomingEdges();
941  for (NBEdge* edge : incoming) {
942  // delete edges between the merged junctions
943  GNEEdge* e = myAttributeCarriers.edges[edge->getID()];
944  assert(e != 0);
945  if (e->getGNEJunctionSource() == target) {
946  deleteEdge(e, undoList, false);
947  } else {
948  undoList->p_add(new GNEChange_Attribute(e, this, SUMO_ATTR_TO, target->getID()));
949  }
950  }
951  // deleting edges changes in the underlying EdgeVector so we have to make a copy
952  const EdgeVector outgoing = moved->getNBNode()->getOutgoingEdges();
953  for (NBEdge* edge : outgoing) {
954  // delete edges between the merged junctions
955  GNEEdge* e = myAttributeCarriers.edges[edge->getID()];
956  assert(e != 0);
957  if (e->getGNEJunctionDestiny() == target) {
958  deleteEdge(e, undoList, false);
959  } else {
960  undoList->p_add(new GNEChange_Attribute(e, this, SUMO_ATTR_FROM, target->getID()));
961  }
962  }
963  // deleted moved junction
964  deleteJunction(moved, undoList);
965  undoList->p_end();
966 }
967 
968 
969 bool
971  // Check that there isn't another junction in the same position as Pos
972  for (auto i : myAttributeCarriers.junctions) {
973  if (i.second->getPositionInView() == pos) {
974  return false;
975  }
976  }
977  return true;
978 }
979 
980 
981 void
983  if (myNetSaved == true) {
984  WRITE_DEBUG("net has to be saved");
985  std::string additionalsSaved = (myAdditionalsSaved ? "saved" : "unsaved");
986  std::string demandElementsSaved = (myDemandElementsSaved ? "saved" : "unsaved");
987  WRITE_DEBUG("Current saving Status: net unsaved, additionals " + additionalsSaved + ", demand elements " + demandElementsSaved);
988  }
989  myNetSaved = !value;
990 }
991 
992 
993 bool
995  return myNetSaved;
996 }
997 
998 
999 void
1001  // compute without volatile options and update network
1002  computeAndUpdate(oc, false);
1003  // write network
1005  myNetSaved = true;
1006 }
1007 
1008 
1009 void
1011  // compute without volatile options
1012  computeAndUpdate(oc, false);
1014 }
1015 
1016 
1017 void
1019  // compute without volatile options
1020  computeAndUpdate(oc, false);
1022 }
1023 
1024 
1025 void
1027  myViewNet = viewNet;
1028 
1029  // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1031  myAttributeCarriers.demandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1032  defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1033 
1034  // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1036  myAttributeCarriers.demandElements.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1037  defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1038 
1039  // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1041  myAttributeCarriers.demandElements.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1042  defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1043 
1044  // create instance of RouteCalculator
1046 }
1047 
1048 
1049 GNEJunction*
1050 GNENet::retrieveJunction(const std::string& id, bool failHard) {
1051  if (myAttributeCarriers.junctions.count(id)) {
1052  return myAttributeCarriers.junctions[id];
1053  } else if (failHard) {
1054  // If junction wasn't found, throw exception
1055  throw UnknownElement("Junction " + id);
1056  } else {
1057  return nullptr;
1058  }
1059 }
1060 
1061 
1064  return myAttributeCarriers;
1065 }
1066 
1067 
1068 GNEEdge*
1069 GNENet::retrieveEdge(const std::string& id, bool failHard) {
1070  auto i = myAttributeCarriers.edges.find(id);
1071  // If edge was found
1072  if (i != myAttributeCarriers.edges.end()) {
1073  return i->second;
1074  } else if (failHard) {
1075  // If edge wasn't found, throw exception
1076  throw UnknownElement("Edge " + id);
1077  } else {
1078  return nullptr;
1079  }
1080 }
1081 
1082 
1083 GNEEdge*
1084 GNENet::retrieveEdge(GNEJunction* from, GNEJunction* to, bool failHard) {
1085  assert((from != nullptr) && (to != nullptr));
1086  // iterate over Junctions of net
1087  for (auto i : myAttributeCarriers.edges) {
1088  if ((i.second->getGNEJunctionSource() == from) && (i.second->getGNEJunctionDestiny() == to)) {
1089  return i.second;
1090  }
1091  }
1092  // if edge wasn' found, throw exception or return nullptr
1093  if (failHard) {
1094  throw UnknownElement("Edge with from='" + from->getID() + "' and to='" + to->getID() + "'");
1095  } else {
1096  return nullptr;
1097  }
1098 }
1099 
1100 
1101 GNEPoly*
1102 GNENet::retrievePolygon(const std::string& id, bool failHard) const {
1103  if (myPolygons.get(id) != 0) {
1104  return reinterpret_cast<GNEPoly*>(myPolygons.get(id));
1105  } else if (failHard) {
1106  // If Polygon wasn't found, throw exception
1107  throw UnknownElement("Polygon " + id);
1108  } else {
1109  return nullptr;
1110  }
1111 }
1112 
1113 
1114 GNEPOI*
1115 GNENet::retrievePOI(const std::string& id, bool failHard) const {
1116  if (myPOIs.get(id) != 0) {
1117  return reinterpret_cast<GNEPOI*>(myPOIs.get(id));
1118  } else if (failHard) {
1119  // If POI wasn't found, throw exception
1120  throw UnknownElement("POI " + id);
1121  } else {
1122  return nullptr;
1123  }
1124 }
1125 
1126 
1128 GNENet::retrieveConnection(const std::string& id, bool failHard) const {
1129  // iterate over junctions
1130  for (auto i : myAttributeCarriers.junctions) {
1131  // iterate over connections
1132  for (auto j : i.second->getGNEConnections()) {
1133  if (j->getID() == id) {
1134  return j;
1135  }
1136  }
1137  }
1138  if (failHard) {
1139  // If POI wasn't found, throw exception
1140  throw UnknownElement("Connection " + id);
1141  } else {
1142  return nullptr;
1143  }
1144 }
1145 
1146 
1147 std::vector<GNEConnection*>
1148 GNENet::retrieveConnections(bool onlySelected) const {
1149  std::vector<GNEConnection*> result;
1150  // iterate over junctions
1151  for (auto i : myAttributeCarriers.junctions) {
1152  // iterate over connections
1153  for (auto j : i.second->getGNEConnections()) {
1154  if (!onlySelected || j->isAttributeCarrierSelected()) {
1155  result.push_back(j);
1156  }
1157  }
1158  }
1159  return result;
1160 }
1161 
1162 
1163 GNECrossing*
1164 GNENet::retrieveCrossing(const std::string& id, bool failHard) const {
1165  // iterate over junctions
1166  for (auto i : myAttributeCarriers.junctions) {
1167  // iterate over crossings
1168  for (auto j : i.second->getGNECrossings()) {
1169  if (j->getID() == id) {
1170  return j;
1171  }
1172  }
1173  }
1174  if (failHard) {
1175  // If POI wasn't found, throw exception
1176  throw UnknownElement("Crossing " + id);
1177  } else {
1178  return nullptr;
1179  }
1180 }
1181 
1182 
1183 std::vector<GNECrossing*>
1184 GNENet::retrieveCrossings(bool onlySelected) const {
1185  std::vector<GNECrossing*> result;
1186  // iterate over junctions
1187  for (auto i : myAttributeCarriers.junctions) {
1188  // iterate over crossings
1189  for (auto j : i.second->getGNECrossings()) {
1190  if (!onlySelected || j->isAttributeCarrierSelected()) {
1191  result.push_back(j);
1192  }
1193  }
1194  }
1195  return result;
1196 }
1197 
1198 
1199 std::vector<GNEEdge*>
1200 GNENet::retrieveEdges(bool onlySelected) {
1201  std::vector<GNEEdge*> result;
1202  // returns edges depending of selection
1203  for (auto i : myAttributeCarriers.edges) {
1204  if (!onlySelected || i.second->isAttributeCarrierSelected()) {
1205  result.push_back(i.second);
1206  }
1207  }
1208  return result;
1209 }
1210 
1211 
1212 std::vector<GNELane*>
1213 GNENet::retrieveLanes(bool onlySelected) {
1214  std::vector<GNELane*> result;
1215  // returns lanes depending of selection
1216  for (auto i : myAttributeCarriers.edges) {
1217  for (auto j : i.second->getLanes()) {
1218  if (!onlySelected || j->isAttributeCarrierSelected()) {
1219  result.push_back(j);
1220  }
1221  }
1222  }
1223  return result;
1224 }
1225 
1226 
1227 GNELane*
1228 GNENet::retrieveLane(const std::string& id, bool failHard, bool checkVolatileChange) {
1229  const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
1230  GNEEdge* edge = retrieveEdge(edge_id, failHard);
1231  if (edge != nullptr) {
1232  GNELane* lane = nullptr;
1233  // search lane in lane's edges
1234  for (auto it : edge->getLanes()) {
1235  if (it->getID() == id) {
1236  lane = it;
1237  }
1238  }
1239  // throw exception or return nullptr if lane wasn't found
1240  if (lane == nullptr) {
1241  if (failHard) {
1242  // Throw exception if failHard is enabled
1243  throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
1244  }
1245  } else {
1246  // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
1247  if (checkVolatileChange && (myEdgesAndNumberOfLanes.count(edge_id) == 1) && myEdgesAndNumberOfLanes[edge_id] != (int)edge->getLanes().size()) {
1248  return edge->getLanes().at(lane->getIndex() + 1);
1249  }
1250  return lane;
1251  }
1252  } else if (failHard) {
1253  // Throw exception if failHard is enabled
1254  throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
1255  }
1256  return nullptr;
1257 }
1258 
1259 
1260 std::vector<GNEJunction*>
1261 GNENet::retrieveJunctions(bool onlySelected) {
1262  std::vector<GNEJunction*> result;
1263  // returns junctions depending of selection
1264  for (auto i : myAttributeCarriers.junctions) {
1265  if (!onlySelected || i.second->isAttributeCarrierSelected()) {
1266  result.push_back(i.second);
1267  }
1268  }
1269  return result;
1270 }
1271 
1272 
1273 std::vector<GNEShape*>
1274 GNENet::retrieveShapes(SumoXMLTag shapeTag, bool onlySelected) {
1275  std::vector<GNEShape*> result;
1276  // return dependingn of shape type
1277  if (shapeTag == SUMO_TAG_POLY) {
1278  // return all polys depending of onlySelected
1279  for (auto it : getPolygons()) {
1280  GNEShape* shape = dynamic_cast<GNEShape*>(it.second);
1281  if (!onlySelected || shape->isAttributeCarrierSelected()) {
1282  result.push_back(shape);
1283  }
1284  }
1285  } else {
1286  // check if we need to return a POI or POILane
1287  for (auto it : getPOIs()) {
1288  GNEPOI* poi = dynamic_cast<GNEPOI*>(it.second);
1289  if (poi && (poi->getTagProperty().getTag() == shapeTag)) {
1290  // return all POIs or POILanes depending of onlySelected
1291  if (!onlySelected || poi->isAttributeCarrierSelected()) {
1292  result.push_back(poi);
1293  }
1294  }
1295  }
1296  }
1297  return result;
1298 }
1299 
1300 
1301 std::vector<GNEShape*>
1302 GNENet::retrieveShapes(bool onlySelected) {
1303  std::vector<GNEShape*> result;
1304  // return all polygons and POIs
1305  for (const auto& it : getPolygons()) {
1306  GNEPoly* poly = dynamic_cast<GNEPoly*>(it.second);
1307  if (!onlySelected || poly->isAttributeCarrierSelected()) {
1308  result.push_back(poly);
1309  }
1310  }
1311  for (const auto& it : getPOIs()) {
1312  GNEPOI* poi = dynamic_cast<GNEPOI*>(it.second);
1313  if (!onlySelected || poi->isAttributeCarrierSelected()) {
1314  result.push_back(poi);
1315  }
1316  }
1317  return result;
1318 }
1319 
1320 
1321 void
1324 }
1325 
1326 
1327 void
1330 }
1331 
1332 
1335  // obtain blocked GUIGlObject
1337  // Make sure that object exists
1338  if (object != nullptr) {
1339  // unblock and try to parse to AtributeCarrier
1341  GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
1342  // If was sucesfully parsed, return it
1343  if (ac == nullptr) {
1344  throw ProcessError("GUIGlObject does not match the declared type");
1345  } else {
1346  return ac;
1347  }
1348  } else if (failHard) {
1349  throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
1350  } else {
1351  return nullptr;
1352  }
1353 }
1354 
1355 
1356 std::vector<GNEAttributeCarrier*>
1358  std::vector<GNEAttributeCarrier*> result;
1359  if (type == SUMO_TAG_NOTHING) {
1360  // return all elements
1361  for (auto i : myAttributeCarriers.junctions) {
1362  result.push_back(i.second);
1363  for (auto j : i.second->getGNECrossings()) {
1364  result.push_back(j);
1365  }
1366  }
1367  for (auto i : myAttributeCarriers.edges) {
1368  result.push_back(i.second);
1369  for (auto j : i.second->getLanes()) {
1370  result.push_back(j);
1371  }
1372  for (auto j : i.second->getGNEConnections()) {
1373  result.push_back(j);
1374  }
1375  }
1376  for (auto i : myAttributeCarriers.additionals) {
1377  for (auto j : i.second) {
1378  result.push_back(j.second);
1379  }
1380  }
1381  for (auto i : myPolygons) {
1382  result.push_back(dynamic_cast<GNEPoly*>(i.second));
1383  }
1384  for (auto i : myPOIs) {
1385  result.push_back(dynamic_cast<GNEPOI*>(i.second));
1386  }
1387  for (auto i : myAttributeCarriers.demandElements) {
1388  for (auto j : i.second) {
1389  result.push_back(j.second);
1390  }
1391  }
1392  } else if (GNEAttributeCarrier::getTagProperties(type).isAdditional() || GNEAttributeCarrier::getTagProperties(type).isTAZ()) {
1393  // only returns additionals of a certain type.
1394  for (auto i : myAttributeCarriers.additionals.at(type)) {
1395  result.push_back(i.second);
1396  }
1397  } else if (GNEAttributeCarrier::getTagProperties(type).isDemandElement() || GNEAttributeCarrier::getTagProperties(type).isStop()) {
1398  // only returns demand elements of a certain type.
1399  for (auto i : myAttributeCarriers.demandElements.at(type)) {
1400  result.push_back(i.second);
1401  }
1402  } else {
1403  // return only a part of elements, depending of type
1404  switch (type) {
1405  case SUMO_TAG_JUNCTION:
1406  for (auto i : myAttributeCarriers.junctions) {
1407  result.push_back(i.second);
1408  }
1409  break;
1410  case SUMO_TAG_EDGE:
1411  for (auto i : myAttributeCarriers.edges) {
1412  result.push_back(i.second);
1413  }
1414  break;
1415  case SUMO_TAG_LANE:
1416  for (auto i : myAttributeCarriers.edges) {
1417  for (auto j : i.second->getLanes()) {
1418  result.push_back(j);
1419  }
1420  }
1421  break;
1422  case SUMO_TAG_CONNECTION:
1423  for (auto i : myAttributeCarriers.edges) {
1424  for (auto j : i.second->getGNEConnections()) {
1425  result.push_back(j);
1426  }
1427  }
1428  break;
1429  case SUMO_TAG_CROSSING:
1430  for (auto i : myAttributeCarriers.junctions) {
1431  for (auto j : i.second->getGNECrossings()) {
1432  result.push_back(j);
1433  }
1434  }
1435  break;
1436  case SUMO_TAG_POLY:
1437  for (auto i : myPolygons) {
1438  result.push_back(dynamic_cast<GNEPoly*>(i.second));
1439  }
1440  break;
1441  case SUMO_TAG_POI:
1442  case SUMO_TAG_POILANE:
1443  for (auto i : myPOIs) {
1444  result.push_back(dynamic_cast<GNEPOI*>(i.second));
1445  }
1446  break;
1447  default:
1448  // return nothing
1449  break;
1450  }
1451  }
1452  return result;
1453 }
1454 
1455 
1456 void
1457 GNENet::computeNetwork(GNEApplicationWindow* window, bool force, bool volatileOptions, std::string additionalPath, std::string demandPath) {
1458  if (!myNeedRecompute) {
1459  if (force) {
1460  if (volatileOptions) {
1461  window->setStatusBarText("Forced computing junctions with volatile options ...");
1462  } else {
1463  window->setStatusBarText("Forced computing junctions ...");
1464  }
1465  } else {
1466  return;
1467  }
1468  } else {
1469  if (volatileOptions) {
1470  window->setStatusBarText("Computing junctions with volatile options ...");
1471  } else {
1472  window->setStatusBarText("Computing junctions ...");
1473  }
1474  }
1475  // save current number of lanes for every edge if recomputing is with volatile options
1476  if (volatileOptions) {
1477  for (auto it : myAttributeCarriers.edges) {
1478  myEdgesAndNumberOfLanes[it.second->getID()] = (int)it.second->getLanes().size();
1479  }
1480  }
1481 
1482  // compute and update
1484  computeAndUpdate(oc, volatileOptions);
1485 
1486  // load additionals if was recomputed with volatile options
1487  if (additionalPath != "") {
1488  // fill additionals with tags
1489  auto listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_ADDITIONAL, false);
1490  for (auto i : listOfTags) {
1491  myAttributeCarriers.additionals.insert(std::make_pair(i, std::map<std::string, GNEAdditional*>()));
1492  }
1493  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_TAZ, false);
1494  for (auto i : listOfTags) {
1495  myAttributeCarriers.additionals.insert(std::make_pair(i, std::map<std::string, GNEAdditional*>()));
1496  }
1497  // Create additional handler
1498  GNEAdditionalHandler additionalHandler(additionalPath, myViewNet);
1499  // Run parser
1500  if (!XMLSubSys::runParser(additionalHandler, additionalPath, false)) {
1501  WRITE_MESSAGE("Loading of " + additionalPath + " failed.");
1502  } else {
1503  // update view
1504  update();
1505  }
1506  // clear myEdgesAndNumberOfLanes after reload additionals
1507  myEdgesAndNumberOfLanes.clear();
1508  }
1509  // load demand elements if was recomputed with volatile options
1510  if (demandPath != "") {
1511  // fill demandElements with tags
1512  auto listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_DEMANDELEMENT, false);
1513  for (auto i : listOfTags) {
1514  myAttributeCarriers.demandElements.insert(std::make_pair(i, std::map<std::string, GNEDemandElement*>()));
1515  }
1516  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_STOP, false);
1517  for (auto i : listOfTags) {
1518  myAttributeCarriers.demandElements.insert(std::make_pair(i, std::map<std::string, GNEDemandElement*>()));
1519  }
1520  // Create demandElement handler
1521  GNERouteHandler demandElementHandler(demandPath, myViewNet, false);
1522  // Run parser
1523  if (!XMLSubSys::runParser(demandElementHandler, demandPath, false)) {
1524  WRITE_MESSAGE("Loading of " + demandPath + " failed.");
1525  } else {
1526  // update view
1527  update();
1528  }
1529  // clear myEdgesAndNumberOfLanes after reload demandElements
1530  myEdgesAndNumberOfLanes.clear();
1531  }
1532  window->getApp()->endWaitCursor();
1533  window->setStatusBarText("Finished computing junctions.");
1534 }
1535 
1536 
1537 void
1539  window->setStatusBarText("Computing demand elements ...");
1540  // iterate over all demand elements and compute
1541  for (const auto& i : myAttributeCarriers.demandElements) {
1542  for (const auto& j : i.second) {
1543  j.second->computePath();
1544  }
1545  }
1546  window->setStatusBarText("Finished computing demand elements.");
1547 }
1548 
1549 
1550 void
1552  // recompute tl-logics
1555  // iterate over traffic lights definitions. Make a copy because invalid
1556  // definitions will be removed (and would otherwise destroy the iterator)
1557  const std::set<NBTrafficLightDefinition*> tlsDefs = junction->getNBNode()->getControllingTLS();
1558  for (auto it : tlsDefs) {
1559  it->setParticipantsInformation();
1560  it->setTLControllingInformation();
1561  tllCont.computeSingleLogic(oc, it);
1562  }
1563 
1564  // @todo compute connections etc...
1565 }
1566 
1567 
1568 void
1570  myNeedRecompute = true;
1571 }
1572 
1573 
1574 bool
1576  for (auto n : myAttributeCarriers.junctions) {
1577  if (n.second->getGNECrossings().size() > 0) {
1578  return true;
1579  }
1580  }
1581  return false;
1582 }
1583 
1584 
1585 FXApp*
1587  return myViewNet->getApp();
1588 }
1589 
1590 
1591 NBNetBuilder*
1593  return myNetBuilder;
1594 }
1595 
1596 
1597 bool
1599  std::vector<GNEJunction*> selectedJunctions = retrieveJunctions(true);
1600  if (selectedJunctions.size() < 2) {
1601  return false;
1602  }
1603  EdgeVector allIncoming;
1604  EdgeVector allOutgoing;
1605  std::set<NBNode*, ComparatorIdLess> cluster;
1606  for (auto it : selectedJunctions) {
1607  cluster.insert(it->getNBNode());
1608  const EdgeVector& incoming = it->getNBNode()->getIncomingEdges();
1609  allIncoming.insert(allIncoming.end(), incoming.begin(), incoming.end());
1610  const EdgeVector& outgoing = it->getNBNode()->getOutgoingEdges();
1611  allOutgoing.insert(allOutgoing.end(), outgoing.begin(), outgoing.end());
1612  }
1613  // create new junction
1614  Position pos;
1615  Position oldPos;
1616  bool setTL;
1617  std::string id = "cluster";
1618  TrafficLightType type;
1619  SumoXMLNodeType nodeType = NODETYPE_UNKNOWN;
1620  myNetBuilder->getNodeCont().analyzeCluster(cluster, id, pos, setTL, type, nodeType);
1621  // save position
1622  oldPos = pos;
1623 
1624  // Check that there isn't another junction in the same position as Pos but doesn't belong to cluster
1625  for (auto i : myAttributeCarriers.junctions) {
1626  if ((i.second->getPositionInView() == pos) && (cluster.find(i.second->getNBNode()) == cluster.end())) {
1627  // show warning in gui testing debug mode
1628  WRITE_DEBUG("Opening FXMessageBox 'Join non-selected junction'");
1629  // Ask confirmation to user
1630  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1631  ("Position of joined " + toString(SUMO_TAG_JUNCTION)).c_str(), "%s",
1632  ("There is another unselected " + toString(SUMO_TAG_JUNCTION) + " in the same position of joined " + toString(SUMO_TAG_JUNCTION) +
1633  + ".\nIt will be joined with the other selected " + toString(SUMO_TAG_JUNCTION) + "s. Continue?").c_str());
1634  if (answer != 1) { // 1:yes, 2:no, 4:esc
1635  // write warning if netedit is running in testing mode
1636  if (answer == 2) {
1637  WRITE_DEBUG("Closed FXMessageBox 'Join non-selected junction' with 'No'");
1638  } else if (answer == 4) {
1639  WRITE_DEBUG("Closed FXMessageBox 'Join non-selected junction' with 'ESC'");
1640  }
1641  return false;
1642  } else {
1643  // write warning if netedit is running in testing mode
1644  WRITE_DEBUG("Closed FXMessageBox 'Join non-selected junction' with 'Yes'");
1645  // select conflicted junction an join all again
1646  i.second->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
1647  return joinSelectedJunctions(undoList);
1648  }
1649  }
1650  }
1651 
1652  // use checkJunctionPosition to avoid conflicts with junction in the same position as others
1653  while (checkJunctionPosition(pos) == false) {
1654  pos.setx(pos.x() + 0.1);
1655  pos.sety(pos.y() + 0.1);
1656  }
1657 
1658  // start with the join selected junctions
1659  undoList->p_begin("Join selected " + toString(SUMO_TAG_JUNCTION) + "s");
1660  GNEJunction* joined = createJunction(pos, undoList);
1661  joined->setAttribute(SUMO_ATTR_TYPE, toString(nodeType), undoList); // i.e. rail crossing
1662  if (setTL) {
1663  joined->setAttribute(SUMO_ATTR_TLTYPE, toString(type), undoList);
1664  }
1665 
1666  // #3128 this is not undone when calling 'undo'
1668 
1669  // first remove all crossing of the involved junctions and edges
1670  // (otherwise edge removal will trigger discarding)
1671  std::vector<NBNode::Crossing> oldCrossings;
1672  for (auto i : selectedJunctions) {
1673  while (i->getGNECrossings().size() > 0) {
1674  GNECrossing* crossing = i->getGNECrossings().front();
1675  oldCrossings.push_back(*crossing->getNBCrossing());
1676  deleteCrossing(crossing, undoList);
1677  }
1678  }
1679 
1680  // preserve old connections
1681  for (auto it : selectedJunctions) {
1682  it->setLogicValid(false, undoList);
1683  }
1684  // remap edges
1685  for (auto it : allIncoming) {
1686  undoList->p_add(new GNEChange_Attribute(myAttributeCarriers.edges[it->getID()], this, SUMO_ATTR_TO, joined->getID()));
1687  }
1688 
1689  EdgeSet edgesWithin;
1690  for (auto it : allOutgoing) {
1691  // delete edges within the cluster
1692  GNEEdge* e = myAttributeCarriers.edges[it->getID()];
1693  assert(e != 0);
1694  if (e->getGNEJunctionDestiny() == joined) {
1695  edgesWithin.insert(it);
1696  deleteEdge(e, undoList, false);
1697  } else {
1698  undoList->p_add(new GNEChange_Attribute(myAttributeCarriers.edges[it->getID()], this, SUMO_ATTR_FROM, joined->getID()));
1699  }
1700  }
1701 
1702  // remap all crossing of the involved junctions and edges
1703  for (auto nbc : oldCrossings) {
1704  bool keep = true;
1705  for (NBEdge* e : nbc.edges) {
1706  if (edgesWithin.count(e) != 0) {
1707  keep = false;
1708  break;
1709  }
1710  };
1711  if (keep) {
1712  undoList->add(new GNEChange_Crossing(joined, nbc.edges, nbc.width,
1713  nbc.priority || joined->getNBNode()->isTLControlled(),
1714  nbc.customTLIndex, nbc.customTLIndex2, nbc.customShape,
1715  false, true), true);
1716  }
1717  }
1718 
1719  // delete original junctions
1720  for (auto it : selectedJunctions) {
1721  deleteJunction(it, undoList);
1722  }
1723  joined->setAttribute(SUMO_ATTR_ID, id, undoList);
1724 
1725 
1726  // check if joined junction had to change their original position to avoid errors
1727  if (pos != oldPos) {
1728  joined->setAttribute(SUMO_ATTR_POSITION, toString(oldPos), undoList);
1729  }
1730  undoList->p_end();
1731  return true;
1732 }
1733 
1734 
1735 bool
1737  // obtain current net's crossings
1738  std::vector<GNECrossing*> myNetCrossings;
1739  for (auto it : myAttributeCarriers.junctions) {
1740  myNetCrossings.reserve(myNetCrossings.size() + it.second->getGNECrossings().size());
1741  myNetCrossings.insert(myNetCrossings.end(), it.second->getGNECrossings().begin(), it.second->getGNECrossings().end());
1742  }
1743  // obtain invalid crossigns
1744  std::vector<GNECrossing*> myInvalidCrossings;
1745  for (auto i = myNetCrossings.begin(); i != myNetCrossings.end(); i++) {
1746  if ((*i)->getNBCrossing()->valid == false) {
1747  myInvalidCrossings.push_back(*i);
1748  }
1749  }
1750 
1751  if (myInvalidCrossings.empty()) {
1752  // show warning in gui testing debug mode
1753  WRITE_DEBUG("Opening FXMessageBox 'No crossing to remove'");
1754  // open a dialog informing that there isn't crossing to remove
1755  FXMessageBox::warning(getApp(), MBOX_OK,
1756  ("Clear " + toString(SUMO_TAG_CROSSING) + "s").c_str(), "%s",
1757  ("There is no invalid " + toString(SUMO_TAG_CROSSING) + "s to remove").c_str());
1758  // show warning in gui testing debug mode
1759  WRITE_DEBUG("Closed FXMessageBox 'No crossing to remove' with 'OK'");
1760  } else {
1761  std::string plural = myInvalidCrossings.size() == 1 ? ("") : ("s");
1762  // show warning in gui testing debug mode
1763  WRITE_DEBUG("Opening FXMessageBox 'clear crossings'");
1764  // Ask confirmation to user
1765  FXuint answer = FXMessageBox::question(getApp(), MBOX_YES_NO,
1766  ("Clear " + toString(SUMO_TAG_CROSSING) + "s").c_str(), "%s",
1767  ("Clear " + toString(SUMO_TAG_CROSSING) + plural + " will be removed. Continue?").c_str());
1768  if (answer != 1) { // 1:yes, 2:no, 4:esc
1769  // write warning if netedit is running in testing mode
1770  if (answer == 2) {
1771  WRITE_DEBUG("Closed FXMessageBox 'clear crossings' with 'No'");
1772  } else if (answer == 4) {
1773  WRITE_DEBUG("Closed FXMessageBox 'clear crossings' with 'ESC'");
1774  }
1775  } else {
1776  undoList->p_begin("Clean " + toString(SUMO_TAG_CROSSING) + "s");
1777  for (auto i = myInvalidCrossings.begin(); i != myInvalidCrossings.end(); i++) {
1778  deleteCrossing((*i), undoList);
1779  }
1780  undoList->p_end();
1781  }
1782  }
1783  return 1;
1784 }
1785 
1786 
1787 void
1789  undoList->p_begin("Clean " + toString(SUMO_TAG_JUNCTION) + "s");
1790  std::vector<GNEJunction*> toRemove;
1791  for (auto it : myAttributeCarriers.junctions) {
1792  GNEJunction* junction = it.second;
1793  if (junction->getNBNode()->getEdges().size() == 0) {
1794  toRemove.push_back(junction);
1795  }
1796  }
1797  for (auto it : toRemove) {
1798  deleteJunction(it, undoList);
1799  }
1800  undoList->p_end();
1801 }
1802 
1803 
1804 void
1806  // first declare a vector to save all routes without children
1807  std::vector<GNEDemandElement*> routesWithoutChildren;
1808  routesWithoutChildren.reserve(myAttributeCarriers.demandElements.at(SUMO_TAG_ROUTE).size());
1809  // iterate over routes
1810  for (const auto& i : myAttributeCarriers.demandElements.at(SUMO_TAG_ROUTE)) {
1811  if (i.second->getChildDemandElements().empty()) {
1812  routesWithoutChildren.push_back(i.second);
1813  }
1814  }
1815  // finally remove all routesWithoutChildren
1816  if (routesWithoutChildren.size() > 0) {
1817  // begin undo list
1818  undoList->p_begin("clean unused routes");
1819  // iterate over routesWithoutChildren
1820  for (const auto& i : routesWithoutChildren) {
1821  // due route doesn't have children, simply call GNEChange_DemandElement
1822  undoList->add(new GNEChange_DemandElement(i, false), true);
1823  }
1824  // update view
1825  myViewNet->update();
1826  // end undo list
1827  undoList->p_end();
1828  }
1829 }
1830 
1831 
1832 void
1834  // first declare a sorted set of sorted route's edges in string format
1835  std::set<std::pair<std::string, GNEDemandElement*> > mySortedRoutes;
1836  // iterate over routes and save it in mySortedRoutes (only if it doesn't have Stop Children)
1837  for (const auto& i : myAttributeCarriers.demandElements.at(SUMO_TAG_ROUTE)) {
1838  // first check route has stops
1839  bool hasStops = false;
1840  for (const auto& j : i.second->getChildDemandElements()) {
1841  if (j->getTagProperty().isStop()) {
1842  hasStops = true;
1843  }
1844  }
1845  if (!hasStops) {
1846  mySortedRoutes.insert(std::make_pair(GNEAttributeCarrier::parseIDs(i.second->getParentEdges()), i.second));
1847  }
1848  }
1849  // now declare a matrix in which organice routes to be merged
1850  std::vector<std::vector<GNEDemandElement*> > routesToMerge;
1851  auto index = mySortedRoutes.begin();
1852  // iterate over mySortedRoutes
1853  for (auto i = mySortedRoutes.begin(); i != mySortedRoutes.end(); i++) {
1854  if (routesToMerge.empty()) {
1855  routesToMerge.push_back({i->second});
1856  } else {
1857  if (index->first == i->first) {
1858  routesToMerge.back().push_back(i->second);
1859  } else {
1860  routesToMerge.push_back({i->second});
1861  index = i;
1862  }
1863  }
1864  }
1865  // now check if there is routes to merge
1866  bool thereIsRoutesToMerge = false;
1867  for (const auto& i : routesToMerge) {
1868  if (i.size() > 1) {
1869  thereIsRoutesToMerge = true;
1870  }
1871  }
1872  // if exist
1873  if (thereIsRoutesToMerge) {
1874  // begin undo list
1875  undoList->p_begin("merge routes");
1876  // iterate over route to edges
1877  for (const auto& i : routesToMerge) {
1878  if (i.size() > 1) {
1879  // iterate over duplicated routes
1880  for (int j = 1; j < (int)i.size(); j++) {
1881  // move all vehicles of every duplicated route
1882  while (i.at(j)->getChildDemandElements().size() > 0) {
1883  i.at(j)->getChildDemandElements().front()->setAttribute(SUMO_ATTR_ROUTE, i.at(0)->getID(), undoList);
1884  }
1885  // finally remove route
1886  undoList->add(new GNEChange_DemandElement(i.at(j), false), true);
1887  }
1888  }
1889  }
1890  // update view
1891  myViewNet->update();
1892  // end undo list
1893  undoList->p_end();
1894  }
1895 }
1896 
1897 
1898 void
1900  // first declare a vector to save all invalid demand elements
1901  std::vector<GNEDemandElement*> invalidDemandElements;
1902  invalidDemandElements.reserve(myAttributeCarriers.demandElements.at(SUMO_TAG_ROUTE).size() +
1905  // iterate over routes
1906  for (const auto& i : myAttributeCarriers.demandElements.at(SUMO_TAG_ROUTE)) {
1907  if (!i.second->isDemandElementValid()) {
1908  invalidDemandElements.push_back(i.second);
1909  }
1910  }
1911  // iterate over flows
1912  for (const auto& i : myAttributeCarriers.demandElements.at(SUMO_TAG_FLOW)) {
1913  if (!i.second->isDemandElementValid()) {
1914  invalidDemandElements.push_back(i.second);
1915  }
1916  }
1917  // iterate over trip
1918  for (const auto& i : myAttributeCarriers.demandElements.at(SUMO_TAG_TRIP)) {
1919  if (!i.second->isDemandElementValid()) {
1920  invalidDemandElements.push_back(i.second);
1921  }
1922  }
1923  // continue if there is invalidDemandElements to remove
1924  if (invalidDemandElements.size() > 0) {
1925  // begin undo list
1926  undoList->p_begin("remove invalid demand elements");
1927  // iterate over invalidDemandElements
1928  for (const auto& i : invalidDemandElements) {
1929  // simply call GNEChange_DemandElement
1930  undoList->add(new GNEChange_DemandElement(i, false), true);
1931  }
1932  // update view
1933  myViewNet->update();
1934  // end undo list
1935  undoList->p_end();
1936  }
1937 }
1938 
1939 void
1941  assert(junction->getNBNode()->checkIsRemovable());
1942  // start operation
1943  undoList->p_begin("Replace junction by geometry");
1944  // obtain Edges to join
1945  std::vector<std::pair<NBEdge*, NBEdge*> > toJoin = junction->getNBNode()->getEdgesToJoin();
1946  // clear connections of junction to replace
1947  clearJunctionConnections(junction, undoList);
1948  // iterate over NBEdges to join
1949  for (auto j : toJoin) {
1950  // obtain GNEEdges
1951  GNEEdge* begin = myAttributeCarriers.edges[j.first->getID()];
1952  GNEEdge* continuation = myAttributeCarriers.edges[j.second->getID()];
1953  // remove connections between the edges
1954  std::vector<NBEdge::Connection> connections = begin->getNBEdge()->getConnections();
1955  for (auto con : connections) {
1956  undoList->add(new GNEChange_Connection(begin, con, false, false), true);
1957  }
1958  // fix shape of replaced edge
1959  PositionVector newShape = begin->getNBEdge()->getInnerGeometry();
1960  if (begin->getNBEdge()->hasDefaultGeometryEndpointAtNode(begin->getNBEdge()->getToNode())) {
1961  newShape.push_back(junction->getNBNode()->getPosition());
1962  } else {
1963  newShape.push_back(begin->getNBEdge()->getGeometry()[-1]);
1964  }
1965  if (continuation->getNBEdge()->hasDefaultGeometryEndpointAtNode(begin->getNBEdge()->getToNode())) {
1966  newShape.push_back_noDoublePos(junction->getNBNode()->getPosition());
1967  } else {
1968  newShape.push_back_noDoublePos(continuation->getNBEdge()->getGeometry()[0]);
1969  }
1970  // replace incoming edge
1971  replaceIncomingEdge(continuation, begin, undoList);
1972 
1973  newShape.append(continuation->getNBEdge()->getInnerGeometry());
1974  begin->setAttribute(GNE_ATTR_SHAPE_END, continuation->getAttribute(GNE_ATTR_SHAPE_END), undoList);
1975  begin->setAttribute(SUMO_ATTR_ENDOFFSET, continuation->getAttribute(SUMO_ATTR_ENDOFFSET), undoList);
1976  begin->setAttribute(SUMO_ATTR_SHAPE, toString(newShape), undoList);
1977  begin->getNBEdge()->resetNodeBorder(begin->getNBEdge()->getToNode());
1978  }
1979  //delete replaced junction
1980  deleteJunction(junction, undoList);
1981  // finish operation
1982  undoList->p_end();
1983 }
1984 
1985 
1986 void
1987 GNENet::splitJunction(GNEJunction* junction, bool reconnect, GNEUndoList* undoList) {
1988  std::vector<std::pair<Position, std::string> > endpoints = junction->getNBNode()->getEndPoints();
1989  if (endpoints.size() < 2) {
1990  return;
1991  }
1992  // start operation
1993  undoList->p_begin("Split junction");
1994  // record connections
1995  std::map<GNEEdge*, std::vector<NBEdge::Connection>> straightConnections;
1996  for (GNEEdge* e : junction->getGNEIncomingEdges()) {
1997  for (const auto& c : e->getNBEdge()->getConnections()) {
1998  if (c.fromLane >= 0 && junction->getNBNode()->getDirection(e->getNBEdge(), c.toEdge) == LINKDIR_STRAIGHT) {
1999  straightConnections[e].push_back(c);
2000  }
2001  };
2002  }
2003  //std::cout << "split junction at endpoints:\n";
2004 
2005  junction->setLogicValid(false, undoList);
2006  for (const auto& pair : endpoints) {
2007  const Position& pos = pair.first;
2008  const std::string& origID = pair.second;
2009  GNEJunction* newJunction = createJunction(pos, undoList);
2010  std::string newID = origID != "" ? origID : newJunction->getID();
2011  // make a copy because the original vectors are modified during iteration
2012  const std::vector<GNEEdge*> incoming = junction->getGNEIncomingEdges();
2013  const std::vector<GNEEdge*> outgoing = junction->getGNEOutgoingEdges();
2014  //std::cout << " checkEndpoint " << pair.first << " " << pair.second << " newID=" << newID << "\n";
2015  for (GNEEdge* e : incoming) {
2016  //std::cout << " incoming " << e->getID() << " pos=" << pos << " origTo=" << e->getNBEdge()->getParameter("origTo") << " newID=" << newID << "\n";
2017  if (e->getNBEdge()->getGeometry().back().almostSame(pos) || e->getNBEdge()->getParameter("origTo") == newID) {
2018  //std::cout << " match\n";
2019  undoList->p_add(new GNEChange_Attribute(e, this, SUMO_ATTR_TO, newJunction->getID()));
2020  }
2021  }
2022  for (GNEEdge* e : outgoing) {
2023  //std::cout << " outgoing " << e->getID() << " pos=" << pos << " origFrom=" << e->getNBEdge()->getParameter("origFrom") << " newID=" << newID << "\n";
2024  if (e->getNBEdge()->getGeometry().front().almostSame(pos) || e->getNBEdge()->getParameter("origFrom") == newID) {
2025  //std::cout << " match\n";
2026  undoList->p_add(new GNEChange_Attribute(e, this, SUMO_ATTR_FROM, newJunction->getID()));
2027  }
2028  }
2029  if (newID != newJunction->getID()) {
2030  if (newJunction->isValid(SUMO_ATTR_ID, newID)) {
2031  undoList->p_add(new GNEChange_Attribute(newJunction, this, SUMO_ATTR_ID, newID));
2032  } else {
2033  WRITE_WARNING("Could not rename split node to '" + newID + "'");
2034  }
2035  }
2036  }
2037  // recreate edges from straightConnections
2038  if (reconnect) {
2039  for (const auto& item : straightConnections) {
2040  GNEEdge* in = item.first;
2041  std::map<NBEdge*, GNEEdge*> newEdges;
2042  for (auto& c : item.second) {
2043  GNEEdge* out = retrieveEdge(c.toEdge->getID());
2044  GNEEdge* newEdge = nullptr;
2045  if (in->getGNEJunctionDestiny() == out->getGNEJunctionSource()) {
2046  continue;
2047  }
2048  if (newEdges.count(c.toEdge) == 0) {
2049  newEdge = createEdge(in->getGNEJunctionDestiny(), out->getGNEJunctionSource(), in, undoList);
2050  newEdges[c.toEdge] = newEdge;
2051  newEdge->setAttribute(SUMO_ATTR_NUMLANES, "1", undoList);
2052  } else {
2053  newEdge = newEdges[c.toEdge];
2054  duplicateLane(newEdge->getLanes().back(), undoList, true);
2055  }
2056  // copy permissions
2057  newEdge->getLanes().back()->setAttribute(SUMO_ATTR_ALLOW,
2058  in->getLanes()[c.fromLane]-> getAttribute(SUMO_ATTR_ALLOW), undoList);
2059  }
2060  }
2061  }
2062 
2063  deleteJunction(junction, undoList);
2064  // finish operation
2065  undoList->p_end();
2066 }
2067 
2068 
2069 
2070 void
2072  undoList->p_begin("clear junction connections");
2073  std::vector<GNEConnection*> connections = junction->getGNEConnections();
2074  // Iterate over all connections and clear it
2075  for (auto i : connections) {
2076  deleteConnection(i, undoList);
2077  }
2078  undoList->p_end();
2079 }
2080 
2081 
2082 void
2084  undoList->p_begin("reset junction connections");
2085  // first clear connections
2086  clearJunctionConnections(junction, undoList);
2087  // invalidate logic to create new connections in the next recomputing
2088  junction->setLogicValid(false, undoList);
2089  undoList->p_end();
2090 }
2091 
2092 
2093 void
2094 GNENet::renameEdge(GNEEdge* edge, const std::string& newID) {
2095  myAttributeCarriers.edges.erase(edge->getNBEdge()->getID());
2096  myNetBuilder->getEdgeCont().rename(edge->getNBEdge(), newID);
2097  edge->setMicrosimID(newID);
2098  myAttributeCarriers.edges[newID] = edge;
2099  // rename all connections related to this edge
2100  for (auto i : edge->getLanes()) {
2101  i->updateConnectionIDs();
2102  }
2103 }
2104 
2105 
2106 void
2107 GNENet::changeEdgeEndpoints(GNEEdge* edge, const std::string& newSource, const std::string& newDest) {
2108  NBNode* from = retrieveJunction(newSource)->getNBNode();
2109  NBNode* to = retrieveJunction(newDest)->getNBNode();
2110  edge->getNBEdge()->reinitNodes(from, to);
2111  requireRecompute();
2112  update();
2113 }
2114 
2115 
2116 GNEViewNet*
2118  return myViewNet;
2119 }
2120 
2121 
2122 std::vector<GNEAttributeCarrier*>
2123 GNENet::getSelectedAttributeCarriers(bool ignoreCurrentSupermode) {
2124  // declare vector to save result
2125  std::vector<GNEAttributeCarrier*> result;
2126  result.reserve(gSelected.getSelected().size());
2127  // iterate over all elements of global selection
2128  for (auto i : gSelected.getSelected()) {
2129  // obtain AC
2131  // check if attribute carrier exist and is selected
2132  if (AC && AC->isAttributeCarrierSelected()) {
2133  // now check if selected supermode is correct
2134  if (ignoreCurrentSupermode ||
2137  // add it into result vector
2138  result.push_back(AC);
2139  }
2140  }
2141  }
2142  return result;
2143 }
2144 
2145 
2148  return myNetBuilder->getTLLogicCont();
2149 }
2150 
2151 
2152 NBEdgeCont&
2154  return myNetBuilder->getEdgeCont();
2155 }
2156 
2157 
2158 void
2159 GNENet::renameJunction(GNEJunction* junction, const std::string& newID) {
2160  std::string oldID = junction->getID();
2161  myAttributeCarriers.junctions.erase(junction->getNBNode()->getID());
2162  myNetBuilder->getNodeCont().rename(junction->getNBNode(), newID);
2163  junction->setMicrosimID(newID);
2164  myAttributeCarriers.junctions[newID] = junction;
2165  // build crossings
2166  junction->getNBNode()->buildCrossings();
2167 }
2168 
2169 
2170 void
2172  myExplicitTurnarounds.insert(id);
2173 }
2174 
2175 
2176 void
2178  myExplicitTurnarounds.erase(id);
2179 }
2180 
2181 
2183 GNENet::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
2184  if ((myAttributeCarriers.additionals.count(type) > 0) && (myAttributeCarriers.additionals.at(type).count(id) != 0)) {
2185  return myAttributeCarriers.additionals.at(type).at(id);
2186  } else if (hardFail) {
2187  throw ProcessError("Attempted to retrieve non-existant additional");
2188  } else {
2189  return nullptr;
2190  }
2191 }
2192 
2193 
2194 std::vector<GNEAdditional*>
2195 GNENet::retrieveAdditionals(bool onlySelected) const {
2196  std::vector<GNEAdditional*> result;
2197  // returns additionals depending of selection
2198  for (auto i : myAttributeCarriers.additionals) {
2199  for (auto j : i.second) {
2200  if (!onlySelected || j.second->isAttributeCarrierSelected()) {
2201  result.push_back(j.second);
2202  }
2203  }
2204  }
2205  return result;
2206 }
2207 
2208 
2209 int
2211  int counter = 0;
2212  for (auto i : myAttributeCarriers.additionals) {
2213  if ((type == SUMO_TAG_NOTHING) || (type == i.first)) {
2214  counter += (int)i.second.size();
2215  }
2216  }
2217  return counter;
2218 }
2219 
2220 
2221 void
2222 GNENet::updateAdditionalID(const std::string& oldID, GNEAdditional* additional) {
2223  if (myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).count(oldID) == 0) {
2224  throw ProcessError(additional->getTagStr() + " with old ID='" + oldID + "' doesn't exist");
2225  } else {
2226  // remove an insert additional again into container
2227  myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).erase(oldID);
2228  myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).insert(std::make_pair(additional->getID(), additional));
2229  // additionals has to be saved
2230  requireSaveAdditionals(true);
2231  }
2232 }
2233 
2234 
2235 void
2237  if (myAdditionalsSaved) {
2238  WRITE_DEBUG("Additionals has to be saved");
2239  std::string netSaved = (myNetSaved ? "saved" : "unsaved");
2240  std::string demandElementsSaved = (myDemandElementsSaved ? "saved" : "unsaved");
2241  WRITE_DEBUG("Current saving Status: net " + netSaved + ", additionals unsaved, demand elements " + demandElementsSaved);
2242  }
2243  myAdditionalsSaved = !value;
2244  if (myViewNet != nullptr) {
2245  if (myAdditionalsSaved) {
2247  } else {
2249  }
2250  }
2251 }
2252 
2253 
2254 void
2255 GNENet::saveAdditionals(const std::string& filename) {
2256  // obtain invalid additionals depending of number of their parent lanes
2257  std::vector<GNEAdditional*> invalidSingleLaneAdditionals;
2258  std::vector<GNEAdditional*> invalidMultiLaneAdditionals;
2259  // iterate over additionals and obtain invalids
2260  for (auto i : myAttributeCarriers.additionals) {
2261  for (auto j : i.second) {
2262  // check if has to be fixed
2263  if (j.second->getTagProperty().hasAttribute(SUMO_ATTR_LANE) && !j.second->isAdditionalValid()) {
2264  invalidSingleLaneAdditionals.push_back(j.second);
2265  } else if (j.second->getTagProperty().hasAttribute(SUMO_ATTR_LANES) && !j.second->isAdditionalValid()) {
2266  invalidMultiLaneAdditionals.push_back(j.second);
2267  }
2268  }
2269  }
2270  // if there are invalid StoppingPlaces or detectors, open GNEFixAdditionalElements
2271  if (invalidSingleLaneAdditionals.size() > 0 || invalidMultiLaneAdditionals.size() > 0) {
2272  // 0 -> Canceled Saving, with or whithout selecting invalid stopping places and E2
2273  // 1 -> Invalid stoppingPlaces and E2 fixed, friendlyPos enabled, or saved with invalid positions
2274  GNEFixAdditionalElements fixAdditionalElementsDialog(myViewNet, invalidSingleLaneAdditionals, invalidMultiLaneAdditionals);
2275  if (fixAdditionalElementsDialog.execute() == 0) {
2276  // show debug information
2277  WRITE_DEBUG("Additionals saving aborted");
2278  } else {
2279  saveAdditionalsConfirmed(filename);
2280  // change value of flag
2281  myAdditionalsSaved = true;
2282  // show debug information
2283  WRITE_DEBUG("Additionals saved after dialog");
2284  }
2285  // update view
2286  myViewNet->update();
2287  // set focus again in viewNet
2288  myViewNet->setFocus();
2289  } else {
2290  saveAdditionalsConfirmed(filename);
2291  // change value of flag
2292  myAdditionalsSaved = true;
2293  // show debug information
2294  WRITE_DEBUG("Additionals saved");
2295  }
2296 }
2297 
2298 
2299 bool
2301  return myAdditionalsSaved;
2302 }
2303 
2304 
2305 std::string
2307  int counter = 0;
2308  while (myAttributeCarriers.additionals.at(type).count(toString(type) + "_" + toString(counter)) != 0) {
2309  counter++;
2310  }
2311  return (toString(type) + "_" + toString(counter));
2312 }
2313 
2314 
2316 GNENet::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
2317  if ((myAttributeCarriers.demandElements.count(type) > 0) && (myAttributeCarriers.demandElements.at(type).count(id) != 0)) {
2318  return myAttributeCarriers.demandElements.at(type).at(id);
2319  } else if (hardFail) {
2320  throw ProcessError("Attempted to retrieve non-existant demand element");
2321  } else {
2322  return nullptr;
2323  }
2324 }
2325 
2326 
2327 std::vector<GNEDemandElement*>
2328 GNENet::retrieveDemandElements(bool onlySelected) const {
2329  std::vector<GNEDemandElement*> result;
2330  // returns demand elements depending of selection
2331  for (auto i : myAttributeCarriers.demandElements) {
2332  for (auto j : i.second) {
2333  if (!onlySelected || j.second->isAttributeCarrierSelected()) {
2334  result.push_back(j.second);
2335  }
2336  }
2337  }
2338  return result;
2339 }
2340 
2341 
2342 int
2344  int counter = 0;
2345  for (auto i : myAttributeCarriers.demandElements) {
2346  if ((type == SUMO_TAG_NOTHING) || (type == i.first)) {
2347  counter += (int)i.second.size();
2348  }
2349  }
2350  return counter;
2351 }
2352 
2353 
2354 void
2355 GNENet::updateDemandElementID(const std::string& oldID, GNEDemandElement* demandElement) {
2356  if (myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).count(oldID) == 0) {
2357  throw ProcessError(demandElement->getTagStr() + " with old ID='" + oldID + "' doesn't exist");
2358  } else {
2359  // remove an insert demand element again into container
2360  myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).erase(oldID);
2361  myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).insert(std::make_pair(demandElement->getID(), demandElement));
2362  // remove an insert demand element again into vehicleDepartures container
2363  if (demandElement->getTagProperty().isVehicle()) {
2364  if (myAttributeCarriers.vehicleDepartures.count(demandElement->getBegin() + "_" + oldID) == 0) {
2365  throw ProcessError(demandElement->getTagStr() + " with old ID='" + oldID + "' doesn't exist");
2366  } else {
2367  myAttributeCarriers.vehicleDepartures.erase(demandElement->getBegin() + "_" + oldID);
2368  myAttributeCarriers.vehicleDepartures.insert(std::make_pair(demandElement->getBegin() + "_" + demandElement->getID(), demandElement));
2369  }
2370  }
2371  // demand elements has to be saved
2373  }
2374 }
2375 
2376 
2377 void
2378 GNENet::updateDemandElementBegin(const std::string& oldBegin, GNEDemandElement* demandElement) {
2379  if (myAttributeCarriers.vehicleDepartures.count(oldBegin + "_" + demandElement->getID()) == 0) {
2380  throw ProcessError(demandElement->getTagStr() + " with old begin='" + oldBegin + "' doesn't exist");
2381  } else {
2382  // remove an insert demand element again into vehicleDepartures container
2383  if (demandElement->getTagProperty().isVehicle()) {
2384  myAttributeCarriers.vehicleDepartures.erase(oldBegin + "_" + demandElement->getID());
2385  myAttributeCarriers.vehicleDepartures.insert(std::make_pair(demandElement->getBegin() + "_" + demandElement->getID(), demandElement));
2386  }
2387  }
2388 }
2389 
2390 
2391 void
2393  if (myDemandElementsSaved == true) {
2394  WRITE_DEBUG("DemandElements has to be saved");
2395  std::string netSaved = (myNetSaved ? "saved" : "unsaved");
2396  std::string additionalsSaved = (myAdditionalsSaved ? "saved" : "unsaved");
2397  WRITE_DEBUG("Current saving Status: net " + netSaved + ", additionals " + additionalsSaved + ", demand elements unsaved");
2398  }
2399  myDemandElementsSaved = !value;
2400  if (myViewNet != nullptr) {
2401  if (myDemandElementsSaved) {
2403  } else {
2405  }
2406  }
2407 }
2408 
2409 
2410 void
2411 GNENet::saveDemandElements(const std::string& filename) {
2412  // first recompute demand elements
2414  // obtain invalid demandElements depending of number of their parent lanes
2415  std::vector<GNEDemandElement*> invalidSingleLaneDemandElements;
2416  // iterate over demandElements and obtain invalids
2417  for (auto i : myAttributeCarriers.demandElements) {
2418  for (auto j : i.second) {
2419  // check if has to be fixed
2420  if (!j.second->isDemandElementValid()) {
2421  invalidSingleLaneDemandElements.push_back(j.second);
2422  }
2423  }
2424  }
2425  // if there are invalid demand elements, open GNEFixDemandElements
2426  if (invalidSingleLaneDemandElements.size() > 0) {
2427  // 0 -> Canceled Saving, with or whithout selecting invalid demand elements
2428  // 1 -> Invalid demand elements fixed, friendlyPos enabled, or saved with invalid positions
2429  GNEFixDemandElements fixDemandElementsDialog(myViewNet, invalidSingleLaneDemandElements);
2430  if (fixDemandElementsDialog.execute() == 0) {
2431  // show debug information
2432  WRITE_DEBUG("demand elements saving aborted");
2433  } else {
2434  saveDemandElementsConfirmed(filename);
2435  // change value of flag
2436  myDemandElementsSaved = true;
2437  // show debug information
2438  WRITE_DEBUG("demand elements saved after dialog");
2439  }
2440  // update view
2441  myViewNet->update();
2442  // set focus again in viewNet
2443  myViewNet->setFocus();
2444  } else {
2445  saveDemandElementsConfirmed(filename);
2446  // change value of flag
2447  myDemandElementsSaved = true;
2448  // show debug information
2449  WRITE_DEBUG("demand elements saved");
2450  }
2451 }
2452 
2453 
2454 bool
2456  return myDemandElementsSaved;
2457 }
2458 
2459 
2460 std::string
2461 GNENet::generateDemandElementID(const std::string& prefix, SumoXMLTag type) const {
2462  int counter = 0;
2463  if ((type == SUMO_TAG_VEHICLE) || (type == SUMO_TAG_TRIP) || (type == SUMO_TAG_ROUTEFLOW) || (type == SUMO_TAG_FLOW)) {
2464  // special case for vehicles (Vehicles, Flows, Trips and routeFlows share nameSpaces)
2465  while ((myAttributeCarriers.demandElements.at(SUMO_TAG_VEHICLE).count(prefix + toString(type) + "_" + toString(counter)) != 0) ||
2466  (myAttributeCarriers.demandElements.at(SUMO_TAG_TRIP).count(prefix + toString(type) + "_" + toString(counter)) != 0) ||
2467  (myAttributeCarriers.demandElements.at(SUMO_TAG_ROUTEFLOW).count(prefix + toString(type) + "_" + toString(counter)) != 0) ||
2468  (myAttributeCarriers.demandElements.at(SUMO_TAG_FLOW).count(prefix + toString(type) + "_" + toString(counter)) != 0)) {
2469  counter++;
2470  }
2471  } else if ((type == SUMO_TAG_PERSON) || (type == SUMO_TAG_PERSONFLOW)) {
2472  // special case for persons (person and personFlows share nameSpaces)
2473  while ((myAttributeCarriers.demandElements.at(SUMO_TAG_PERSON).count(prefix + toString(type) + "_" + toString(counter)) != 0) ||
2474  (myAttributeCarriers.demandElements.at(SUMO_TAG_PERSONFLOW).count(prefix + toString(type) + "_" + toString(counter)) != 0)) {
2475  counter++;
2476  }
2477  } else {
2478  while (myAttributeCarriers.demandElements.at(type).count(prefix + toString(type) + "_" + toString(counter)) != 0) {
2479  counter++;
2480  }
2481  }
2482  return (prefix + toString(type) + "_" + toString(counter));
2483 }
2484 
2485 
2486 void
2487 GNENet::saveAdditionalsConfirmed(const std::string& filename) {
2488  OutputDevice& device = OutputDevice::getDevice(filename);
2489  device.writeXMLHeader("additional", "additional_file.xsd");
2490  // now write all route probes (see Ticket #4058)
2491  for (auto i : myAttributeCarriers.additionals) {
2492  if (i.first == SUMO_TAG_ROUTEPROBE) {
2493  for (auto j : i.second) {
2494  j.second->writeAdditional(device);
2495  }
2496  }
2497  }
2498  // now write all stoppingPlaces
2499  for (auto i : myAttributeCarriers.additionals) {
2501  for (auto j : i.second) {
2502  // only save stoppingPlaces that doesn't have Additional parents, because they are automatically writed by writeAdditional(...) parent's function
2503  if (j.second->getParentAdditionals().empty()) {
2504  j.second->writeAdditional(device);
2505  }
2506  }
2507  }
2508  }
2509  // now write all detectors
2510  for (auto i : myAttributeCarriers.additionals) {
2512  for (auto j : i.second) {
2513  // only save Detectors that doesn't have Additional parents, because they are automatically writed by writeAdditional(...) parent's function
2514  if (j.second->getParentAdditionals().empty()) {
2515  j.second->writeAdditional(device);
2516  }
2517  }
2518  }
2519  }
2520  // now write rest of additionals
2521  for (auto i : myAttributeCarriers.additionals) {
2522  const auto& tagValue = GNEAttributeCarrier::getTagProperties(i.first);
2523  if (!tagValue.isStoppingPlace() && !tagValue.isDetector() && (i.first != SUMO_TAG_ROUTEPROBE) && (i.first != SUMO_TAG_VTYPE) && (i.first != SUMO_TAG_ROUTE)) {
2524  for (auto j : i.second) {
2525  // only save additionals that doesn't have Additional parents, because they are automatically writed by writeAdditional(...) parent's function
2526  if (j.second->getParentAdditionals().empty()) {
2527  j.second->writeAdditional(device);
2528  }
2529  }
2530  }
2531  }
2532  // now write shapes and POIs
2533  for (const auto& i : myPolygons) {
2534  dynamic_cast<GNEShape*>(i.second)->writeShape(device);
2535  }
2536  for (const auto& i : myPOIs) {
2537  dynamic_cast<GNEShape*>(i.second)->writeShape(device);
2538  }
2539  device.close();
2540 }
2541 
2542 
2543 void
2544 GNENet::saveDemandElementsConfirmed(const std::string& filename) {
2545  OutputDevice& device = OutputDevice::getDevice(filename);
2546  device.writeXMLHeader("routes", "routes_file.xsd");
2547  // first write all vehicle types
2549  i.second->writeDemandElement(device);
2550  }
2551  // first write all person types
2553  i.second->writeDemandElement(device);
2554  }
2555  // now write all routes (and their associated stops)
2557  i.second->writeDemandElement(device);
2558  }
2559  // finally write all vehicles and persons sorted by depart time (and their associated stops, personPlans, etc.)
2560  for (auto i : myAttributeCarriers.vehicleDepartures) {
2561  i.second->writeDemandElement(device);
2562  }
2563  device.close();
2564 }
2565 
2566 
2567 GNEPoly*
2568 GNENet::addPolygonForEditShapes(GNENetElement* netElement, const PositionVector& shape, bool fill, RGBColor col) {
2569  if (shape.size() > 0) {
2570  // create poly for edit shapes
2571  GNEPoly* shapePoly = new GNEPoly(this, "edit_shape", "edit_shape", shape, false, fill, 0.3, col, GLO_POLYGON, 0, "", false, false, false);
2572  shapePoly->setShapeEditedElement(netElement);
2573  myGrid.addAdditionalGLObject(shapePoly);
2574  myViewNet->update();
2575  return shapePoly;
2576  } else {
2577  throw ProcessError("shape cannot be empty");
2578  }
2579 }
2580 
2581 
2582 void
2584  if (polygon) {
2585  // remove it from Inspector Frame
2587  // Remove from grid
2589  myViewNet->update();
2590  } else {
2591  throw ProcessError("Polygon for edit shapes has to be inicializated");
2592  }
2593 }
2594 
2595 
2596 std::string
2598  // generate tag depending of type of shape
2599  if (shapeTag == SUMO_TAG_POLY) {
2600  int counter = 0;
2601  std::string newID = "poly_" + toString(counter);
2602  // generate new IDs to find a non-assigned ID
2603  while (myPolygons.get(newID) != nullptr) {
2604  counter++;
2605  newID = "poly_" + toString(counter);
2606  }
2607  return newID;
2608  } else {
2609  int counter = 0;
2610  std::string newID = "POI_" + toString(counter);
2611  // generate new IDs to find a non-assigned ID
2612  while (myPOIs.get(newID) != nullptr) {
2613  counter++;
2614  newID = "POI_" + toString(counter);
2615  }
2616  return newID;
2617  }
2618 }
2619 
2620 
2621 void
2622 GNENet::changeShapeID(GNEShape* s, const std::string& OldID) {
2623  if (s->getTagProperty().getTag() == SUMO_TAG_POLY) {
2624  if (myPolygons.get(OldID) == 0) {
2625  throw UnknownElement("Polygon " + OldID);
2626  } else {
2627  myPolygons.changeID(OldID, s->getID());
2628  }
2629  } else {
2630  if (myPOIs.get(OldID) == 0) {
2631  throw UnknownElement("POI " + OldID);
2632  } else {
2633  myPOIs.changeID(OldID, s->getID());
2634  }
2635  }
2636 }
2637 
2638 
2639 int
2641  return (int)(myPolygons.size() + myPOIs.size());
2642 }
2643 
2644 
2645 void
2647  if (myTLSProgramsSaved == true) {
2648  WRITE_DEBUG("TLSPrograms has to be saved");
2649  }
2650  myTLSProgramsSaved = false;
2652 }
2653 
2654 
2655 void
2656 GNENet::saveTLSPrograms(const std::string& filename) {
2657  // open output device
2658  OutputDevice& device = OutputDevice::getDevice(filename);
2659  device.openTag("additionals");
2660  // write traffic lights using NWWriter
2662  device.close();
2663  // change flag to true
2664  myTLSProgramsSaved = true;
2665  // show debug information
2666  WRITE_DEBUG("TLSPrograms saved");
2667 }
2668 
2669 
2670 int
2672  return -1;
2673 }
2674 
2675 void
2677  myUpdateGeometryEnabled = true;
2678 }
2679 
2680 
2681 void
2683  myUpdateGeometryEnabled = false;
2684 }
2685 
2686 
2687 bool
2689  return myUpdateGeometryEnabled;
2690 }
2691 
2692 // ---------------------------------------------------------------------------
2693 // GNENet - protected methods
2694 // ---------------------------------------------------------------------------
2695 
2696 bool
2698  // first check that additional pointer is valid
2699  if (additional) {
2700  return myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).find(additional->getID()) !=
2701  myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).end();
2702  } else {
2703  throw ProcessError("Invalid additional pointer");
2704  }
2705 }
2706 
2707 
2708 void
2710  // Check if additional element exists before insertion
2711  if (!additionalExist(additional)) {
2712  myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).insert(std::make_pair(additional->getID(), additional));
2713  // only add drawable elements in grid
2714  if (additional->getTagProperty().isDrawable() && additional->getTagProperty().isPlacedInRTree()) {
2715  myGrid.addAdditionalGLObject(additional);
2716  }
2717  // check if additional is selected
2718  if (additional->isAttributeCarrierSelected()) {
2719  additional->selectAttributeCarrier(false);
2720  }
2721  // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2723  additional->updateGeometry();
2724  }
2725  // additionals has to be saved
2726  requireSaveAdditionals(true);
2727  } else {
2728  throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2729  }
2730 }
2731 
2732 
2733 bool
2734 GNENet::deleteAdditional(GNEAdditional* additional, bool updateViewAfterDeleting) {
2735  // first check that additional pointer is valid
2736  if (additionalExist(additional)) {
2737  // obtain demand element and erase it from container
2738  auto it = myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).find(additional->getID());
2739  myAttributeCarriers.additionals.at(additional->getTagProperty().getTag()).erase(it);
2740  // remove it from Inspector Frame
2742  // only remove drawable elements of grid
2743  if (additional->getTagProperty().isDrawable() && additional->getTagProperty().isPlacedInRTree()) {
2744  myGrid.removeAdditionalGLObject(additional);
2745  }
2746  // check if additional is selected
2747  if (additional->isAttributeCarrierSelected()) {
2748  additional->unselectAttributeCarrier(false);
2749  }
2750  // check if view has to be updated
2751  if (updateViewAfterDeleting) {
2752  myViewNet->update();
2753  }
2754  // additionals has to be saved
2755  requireSaveAdditionals(true);
2756  // additional removed, then return true
2757  return true;
2758  } else {
2759  throw ProcessError("Invalid additional pointer");
2760  }
2761 }
2762 
2763 
2764 bool
2766  // first check that demandElement pointer is valid
2767  if (demandElement) {
2768  return myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).find(demandElement->getID()) !=
2769  myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).end();
2770  } else {
2771  throw ProcessError("Invalid demandElement pointer");
2772  }
2773 }
2774 
2775 
2776 void
2778  // Check if demandElement element exists before insertion
2779  if (!demandElementExist(demandElement)) {
2780  // insert in demandElements container
2781  myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).insert(std::make_pair(demandElement->getID(), demandElement));
2782  // also insert in vehicleDepartures container if it's either a vehicle or a person
2783  if (demandElement->getTagProperty().isVehicle() || demandElement->getTagProperty().isPerson()) {
2784  if (myAttributeCarriers.vehicleDepartures.count(demandElement->getBegin() + "_" + demandElement->getID()) != 0) {
2785  throw ProcessError(demandElement->getTagStr() + " with departure ='" + demandElement->getBegin() + "_" + demandElement->getID() + "' already inserted");
2786  } else {
2787  myAttributeCarriers.vehicleDepartures.insert(std::make_pair(demandElement->getBegin() + "_" + demandElement->getID(), demandElement));
2788  }
2789  }
2790  // only add drawable elements in grid
2791  if (demandElement->getTagProperty().isDrawable() && demandElement->getTagProperty().isPlacedInRTree()) {
2792  myGrid.addAdditionalGLObject(demandElement);
2793  }
2794  // check if demandElement is selected
2795  if (demandElement->isAttributeCarrierSelected()) {
2796  demandElement->selectAttributeCarrier(false);
2797  }
2798  // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2800  demandElement->updateGeometry();
2801  }
2802  // demandElements has to be saved
2804  } else {
2805  throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2806  }
2807 }
2808 
2809 
2810 bool
2811 GNENet::deleteDemandElement(GNEDemandElement* demandElement, bool updateViewAfterDeleting) {
2812  // first check that demandElement pointer is valid
2813  if (demandElementExist(demandElement)) {
2814  // obtain demand element and erase it from container
2815  auto it = myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).find(demandElement->getID());
2816  myAttributeCarriers.demandElements.at(demandElement->getTagProperty().getTag()).erase(it);
2817  // remove it from Inspector Frame
2819  // also remove fromvehicleDepartures container if it's either a vehicle or a person
2820  if (demandElement->getTagProperty().isVehicle() || demandElement->getTagProperty().isPerson()) {
2821  if (myAttributeCarriers.vehicleDepartures.count(demandElement->getBegin() + "_" + demandElement->getID()) == 0) {
2822  throw ProcessError(demandElement->getTagStr() + " with departure ='" + demandElement->getBegin() + "_" + demandElement->getID() + "' doesn't exist");
2823  } else {
2824  myAttributeCarriers.vehicleDepartures.erase(demandElement->getBegin() + "_" + demandElement->getID());
2825  }
2826  }
2827  // only remove drawable elements of grid
2828  if (demandElement->getTagProperty().isDrawable() && demandElement->getTagProperty().isPlacedInRTree()) {
2829  myGrid.removeAdditionalGLObject(demandElement);
2830  }
2831  // check if demandElement is selected
2832  if (demandElement->isAttributeCarrierSelected()) {
2833  demandElement->unselectAttributeCarrier(false);
2834  }
2835  // check if view has to be updated
2836  if (updateViewAfterDeleting) {
2837  myViewNet->update();
2838  }
2839  // demandElements has to be saved
2841  // demandElement removed, then return true
2842  return true;
2843  } else {
2844  throw ProcessError("Invalid demandElement pointer");
2845  }
2846 }
2847 
2848 // ===========================================================================
2849 // private
2850 // ===========================================================================
2851 
2852 void
2854  // init junctions (by default Crossing and walking areas aren't created)
2855  NBNodeCont& nodeContainer = myNetBuilder->getNodeCont();
2856  for (auto name_it : nodeContainer.getAllNames()) {
2857  NBNode* nbn = nodeContainer.retrieve(name_it);
2858  registerJunction(new GNEJunction(this, nbn, true));
2859  }
2860 
2861  // init edges
2863  for (auto name_it : ec.getAllNames()) {
2864  NBEdge* nbe = ec.retrieve(name_it);
2865  registerEdge(new GNEEdge(this, nbe, false, true));
2866  if (myGrid.getWidth() > 10e16 || myGrid.getHeight() > 10e16) {
2867  throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
2868  }
2869  }
2870 
2871  // make sure myGrid is initialized even for an empty net
2872  if (myAttributeCarriers.edges.size() == 0) {
2873  myGrid.add(Boundary(0, 0, 100, 100));
2874  }
2875 
2876  // recalculate all lane2lane connections
2877  for (const auto& i : myAttributeCarriers.edges) {
2878  for (const auto& j : i.second->getLanes()) {
2879  j->updateGeometry();
2880  }
2881  }
2882 
2883  // sort nodes edges so that arrows can be drawn correctly
2884  NBNodesEdgesSorter::sortNodesEdges(nodeContainer);
2885 }
2886 
2887 
2888 void
2890  myNetBuilder->getNodeCont().insert(junction->getNBNode());
2891  registerJunction(junction);
2892 }
2893 
2894 
2895 void
2897  NBEdge* nbe = edge->getNBEdge();
2898  myNetBuilder->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2899  // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2900  nbe->getFromNode()->addOutgoingEdge(nbe);
2901  nbe->getToNode()->addIncomingEdge(nbe);
2902  registerEdge(edge);
2903 }
2904 
2905 
2906 GNEJunction*
2908  // increase reference
2909  junction->incRef("GNENet::registerJunction");
2910  junction->setResponsible(false);
2911  myAttributeCarriers.junctions[junction->getMicrosimID()] = junction;
2912  // add it into grid
2913  myGrid.add(junction->getCenteringBoundary());
2914  myGrid.addAdditionalGLObject(junction);
2915  // update geometry
2916  junction->updateGeometry();
2917  // check if junction is selected
2918  if (junction->isAttributeCarrierSelected()) {
2919  junction->selectAttributeCarrier(false);
2920  }
2921  // @todo let Boundary class track z-coordinate natively
2922  const double z = junction->getNBNode()->getPosition().z();
2923  if (z != 0) {
2925  }
2926  update();
2927  return junction;
2928 }
2929 
2930 
2931 GNEEdge*
2933  edge->incRef("GNENet::registerEdge");
2934  edge->setResponsible(false);
2935  // add edge to internal container of GNENet
2936  myAttributeCarriers.edges[edge->getMicrosimID()] = edge;
2937  // add edge to grid
2938  myGrid.add(edge->getCenteringBoundary());
2940  // check if edge is selected
2941  if (edge->isAttributeCarrierSelected()) {
2942  edge->selectAttributeCarrier(false);
2943  }
2944  // Add references into GNEJunctions
2947  // update view
2948  update();
2949  return edge;
2950 }
2951 
2952 
2953 void
2954 GNENet::deleteSingleJunction(GNEJunction* junction, bool updateViewAfterDeleting) {
2955  // remove it from Inspector Frame
2957  // Remove from grid and container
2958  myGrid.removeAdditionalGLObject(junction);
2959  // check if junction is selected
2960  if (junction->isAttributeCarrierSelected()) {
2961  junction->unselectAttributeCarrier(false);
2962  }
2963  myAttributeCarriers.junctions.erase(junction->getMicrosimID());
2964  myNetBuilder->getNodeCont().extract(junction->getNBNode());
2965  junction->decRef("GNENet::deleteSingleJunction");
2966  junction->setResponsible(true);
2967  // check if view has to be updated
2968  if (updateViewAfterDeleting) {
2969  myViewNet->update();
2970  }
2971 }
2972 
2973 
2974 void
2975 GNENet::deleteSingleEdge(GNEEdge* edge, bool updateViewAfterDeleting) {
2976  // remove it from Inspector Frame
2978  // remove edge from visual grid and container
2980  // check if junction is selected
2981  if (edge->isAttributeCarrierSelected()) {
2982  edge->unselectAttributeCarrier(false);
2983  }
2984  myAttributeCarriers.edges.erase(edge->getMicrosimID());
2985  // extract edge of district container
2987  edge->decRef("GNENet::deleteSingleEdge");
2988  edge->setResponsible(true);
2989  // Remove refrences from GNEJunctions
2992  // check if view has to be updated
2993  if (updateViewAfterDeleting) {
2994  myViewNet->update();
2995  }
2996 }
2997 
2998 
2999 void
3000 GNENet::insertShape(GNEShape* shape, bool updateViewAfterDeleting) {
3001  // add shape depending of their type and if is selected
3002  if (shape->getTagProperty().getTag() == SUMO_TAG_POLY) {
3003  GUIPolygon* poly = dynamic_cast<GUIPolygon*>(shape);
3004  // all polys are placed over RTree
3006  myPolygons.add(shape->getID(), poly);
3007  } else {
3008  GUIPointOfInterest* poi = dynamic_cast<GUIPointOfInterest*>(shape);
3009  // Only certain POIs are placed in RTrees
3010  if (shape->getTagProperty().isPlacedInRTree()) {
3012  }
3013  myPOIs.add(shape->getID(), poi);
3014 
3015  }
3016  // check if shape has to be selected
3017  if (shape->isAttributeCarrierSelected()) {
3018  shape->selectAttributeCarrier(false);
3019  }
3020  // insert shape requires always save additionals
3021  requireSaveAdditionals(true);
3022  // after inserting, update geometry (needed for POILanes
3023  shape->updateGeometry();
3024  // check if view has to be updated
3025  if (updateViewAfterDeleting) {
3026  myViewNet->update();
3027  }
3028 }
3029 
3030 
3031 void
3032 GNENet::removeShape(GNEShape* shape, bool updateViewAfterDeleting) {
3033  // remove it from Inspector Frame
3035  if (shape->getTagProperty().getTag() == SUMO_TAG_POLY) {
3036  GUIPolygon* poly = dynamic_cast<GUIPolygon*>(shape);
3038  myPolygons.remove(shape->getID(), false);
3039  } else {
3040  GUIPointOfInterest* poi = dynamic_cast<GUIPointOfInterest*>(shape);
3041  // only certain POIS are placed in RTREE
3042  if (shape->getTagProperty().isPlacedInRTree()) {
3044  }
3045  myPOIs.remove(shape->getID(), false);
3046  }
3047  // check if shape has to be unselected
3048  if (shape->isAttributeCarrierSelected()) {
3049  shape->unselectAttributeCarrier(false);
3050  }
3051  // remove shape requires always save additionals
3052  requireSaveAdditionals(true);
3053  // check if view has to be updated
3054  if (updateViewAfterDeleting) {
3055  myViewNet->update();
3056  }
3057 }
3058 
3059 
3060 void
3062  if (myViewNet) {
3063  myViewNet->update();
3064  }
3065 }
3066 
3067 
3068 void
3069 GNENet::reserveEdgeID(const std::string& id) {
3070  myEdgeIDSupplier.avoid(id);
3071 }
3072 
3073 
3074 void
3075 GNENet::reserveJunctionID(const std::string& id) {
3077 }
3078 
3079 
3080 void
3082  for (const auto& i : myAttributeCarriers.edges) {
3083  // remake connections
3084  i.second->remakeGNEConnections();
3085  // update geometry of connections
3086  for (const auto& j : i.second->getGNEConnections()) {
3087  j->updateGeometry();
3088  }
3089  }
3090 }
3091 
3092 
3093 void
3094 GNENet::computeAndUpdate(OptionsCont& oc, bool volatileOptions) {
3095  // make sure we only add turn arounds to edges which currently exist within the network
3096  std::set<std::string> liveExplicitTurnarounds;
3097  for (auto it : myExplicitTurnarounds) {
3098  if (myAttributeCarriers.edges.count(it) > 0) {
3099  liveExplicitTurnarounds.insert(it);
3100  }
3101  }
3102  // removes all junctions of grid
3103  WRITE_GLDEBUG("Removing junctions during recomputing");
3104  for (const auto& it : myAttributeCarriers.junctions) {
3105  myGrid.removeAdditionalGLObject(it.second);
3106  }
3107  // remove all edges from grid
3108  WRITE_GLDEBUG("Removing edges during recomputing");
3109  for (const auto& it : myAttributeCarriers.edges) {
3110  myGrid.removeAdditionalGLObject(it.second);
3111  }
3112  // compute using NetBuilder
3113  myNetBuilder->compute(oc, liveExplicitTurnarounds, volatileOptions);
3114  // update ids if necessary
3115  if (oc.getBool("numerical-ids") || oc.isSet("reserved-ids")) {
3116  std::map<std::string, GNEEdge*> newEdgeMap;
3117  std::map<std::string, GNEJunction*> newJunctionMap;
3118  // fill newEdgeMap
3119  for (auto it : myAttributeCarriers.edges) {
3120  it.second->setMicrosimID(it.second->getNBEdge()->getID());
3121  newEdgeMap[it.second->getNBEdge()->getID()] = it.second;
3122  }
3123  for (auto it : myAttributeCarriers.junctions) {
3124  newJunctionMap[it.second->getNBNode()->getID()] = it.second;
3125  it.second->setMicrosimID(it.second->getNBNode()->getID());
3126  }
3127  myAttributeCarriers.edges = newEdgeMap;
3128  myAttributeCarriers.junctions = newJunctionMap;
3129  }
3130  // update rtree if necessary
3131  if (!oc.getBool("offset.disable-normalization")) {
3132  for (auto it : myAttributeCarriers.edges) {
3133  // refresh edge geometry
3134  it.second->updateGeometry();
3135  }
3136  }
3137  // Clear current inspected ACs in inspectorFrame if a previous net was loaded
3138  if (myViewNet != nullptr) {
3140  }
3141  // Reset Grid
3142  myGrid.reset();
3143  myGrid.add(GeoConvHelper::getFinal().getConvBoundary());
3144  // if volatile options are true
3145  if (volatileOptions) {
3146  // check that viewNet exist
3147  if (myViewNet == nullptr) {
3148  throw ProcessError("ViewNet doesn't exist");
3149  }
3150  // disable update geometry before clear undo list
3151  myUpdateGeometryEnabled = false;
3152  // clear undo list (This will be remove additionals and shapes)
3154  // remove all edges of net (It was already removed from grid)
3155  auto copyOfEdges = myAttributeCarriers.edges;
3156  for (auto it : copyOfEdges) {
3157  myAttributeCarriers.edges.erase(it.second->getMicrosimID());
3158  }
3159  // removes all junctions of net (It was already removed from grid)
3160  auto copyOfJunctions = myAttributeCarriers.junctions;
3161  for (auto it : copyOfJunctions) {
3162  myAttributeCarriers.junctions.erase(it.second->getMicrosimID());
3163  }
3164  // clear rest of additional that weren't removed during cleaning of undo list
3165  for (const auto& it : myAttributeCarriers.additionals) {
3166  for (const auto& j : it.second) {
3167  // only remove drawable additionals
3168  if (j.second->getTagProperty().isDrawable()) {
3169  myGrid.removeAdditionalGLObject(j.second);
3170  }
3171  }
3172  }
3174  // fill additionals with tags (note: this include the TAZS)
3175  auto listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_ADDITIONAL, false);
3176  for (auto i : listOfTags) {
3177  myAttributeCarriers.additionals.insert(std::make_pair(i, std::map<std::string, GNEAdditional*>()));
3178  }
3179  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_TAZ, false);
3180  for (auto i : listOfTags) {
3181  myAttributeCarriers.additionals.insert(std::make_pair(i, std::map<std::string, GNEAdditional*>()));
3182  }
3183  // clear rest of polygons that weren't removed during cleaning of undo list
3184  for (const auto& it : myPolygons) {
3185  myGrid.removeAdditionalGLObject(dynamic_cast<GUIGlObject*>(it.second));
3186  }
3187  myPolygons.clear();
3188  // clear rest of POIs that weren't removed during cleaning of undo list
3189  for (const auto& it : myPOIs) {
3190  myGrid.removeAdditionalGLObject(dynamic_cast<GUIGlObject*>(it.second));
3191  }
3192  myPOIs.clear();
3193  // clear rest of demand elements that weren't removed during cleaning of undo list
3194  for (const auto& it : myAttributeCarriers.demandElements) {
3195  for (const auto& j : it.second) {
3196  // only remove drawable additionals
3197  if (j.second->getTagProperty().isDrawable()) {
3198  myGrid.removeAdditionalGLObject(j.second);
3199  }
3200  }
3201  }
3203  // fill demand elements with tags
3204  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_DEMANDELEMENT, false);
3205  for (auto i : listOfTags) {
3206  myAttributeCarriers.demandElements.insert(std::make_pair(i, std::map<std::string, GNEDemandElement*>()));
3207  }
3208  listOfTags = GNEAttributeCarrier::allowedTagsByCategory(GNEAttributeCarrier::TagType::TAGTYPE_STOP, false);
3209  for (auto i : listOfTags) {
3210  myAttributeCarriers.demandElements.insert(std::make_pair(i, std::map<std::string, GNEDemandElement*>()));
3211  }
3212  // enable update geometry again
3213  myUpdateGeometryEnabled = true;
3214  // Write GL debug information
3215  WRITE_GLDEBUG("initJunctionsAndEdges function called in computeAndUpdate(...) due recomputing with volatile options");
3216  // init again junction an edges (Additionals and shapes will be loaded after the end of this function)
3218  } else {
3219  // insert all junctions of grid again
3220  WRITE_GLDEBUG("Add junctions during recomputing after calling myNetBuilder->compute(...)");
3221  for (const auto& it : myAttributeCarriers.junctions) {
3222  myGrid.addAdditionalGLObject(it.second);
3223  }
3224  // insert all edges from grid again
3225  WRITE_GLDEBUG("Add egdges during recomputing after calling myNetBuilder->compute(...)");
3226  for (const auto& it : myAttributeCarriers.edges) {
3227  myGrid.addAdditionalGLObject(it.second);
3228  }
3229  // remake connections
3230  for (auto it : myAttributeCarriers.edges) {
3231  it.second->remakeGNEConnections();
3232  }
3233  // iterate over junctions of net
3234  for (const auto& it : myAttributeCarriers.junctions) {
3235  // undolist may not yet exist but is also not needed when just marking junctions as valid
3236  it.second->setLogicValid(true, nullptr);
3237  // updated geometry
3238  it.second->updateGeometryAfterNetbuild();
3239  }
3240  // iterate over all edges of net
3241  for (const auto& it : myAttributeCarriers.edges) {
3242  // update geometry
3243  it.second->updateGeometry();
3244  }
3245  }
3246  // net recomputed, then return false;
3247  myNeedRecompute = false;
3248 }
3249 
3250 
3251 void
3252 GNENet::replaceInListAttribute(GNEAttributeCarrier* ac, SumoXMLAttr key, const std::string& which, const std::string& by, GNEUndoList* undoList) {
3253  assert(ac->getTagProperty().getAttributeProperties(key).isList());
3254  std::vector<std::string> values = GNEAttributeCarrier::parse<std::vector<std::string> >(ac->getAttribute(key));
3255  std::vector<std::string> newValues;
3256  for (auto v : values) {
3257  newValues.push_back(v == which ? by : v);
3258  }
3259  ac->setAttribute(key, toString(newValues), undoList);
3260 }
3261 
3262 /****************************************************************************/
GNENet::insertAdditional
void insertAdditional(GNEAdditional *additional)
Insert a additional element int GNENet container.
Definition: GNENet.cpp:2709
SUMO_ATTR_ENDOFFSET
Definition: SUMOXMLDefinitions.h:414
GNENet::requireSaveNet
void requireSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:982
GNEAttributeCarrier::TagProperties::isPerson
bool isPerson() const
return true if tag correspond to a person element
Definition: GNEAttributeCarrier.cpp:756
NBEdge::reinitNodes
void reinitNodes(NBNode *from, NBNode *to)
Resets nodes but keeps all other values the same (used when joining)
Definition: NBEdge.cpp:422
GNENet::myUpdateGeometryEnabled
bool myUpdateGeometryEnabled
Flag to enable or disable update geometry of elements after inserting or removing element in net.
Definition: GNENet.h:767
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:135
SUMO_ATTR_TYPE
Definition: SUMOXMLDefinitions.h:381
NODETYPE_PRIORITY
Definition: SUMOXMLDefinitions.h:1061
GNEUndoList::p_clear
void p_clear()
clears the undo list (implies abort)
Definition: GNEUndoList.cpp:86
NBEdge::UNSPECIFIED_OFFSET
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:318
GNENet::getAttributeCarriers
const AttributeCarriers & getAttributeCarriers() const
retrieve all attribute carriers of Net
Definition: GNENet.cpp:1063
SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:156
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNENet::retrieveAdditional
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:2183
OptionsCont::getInt
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
Definition: OptionsCont.cpp:215
GNENet::myJunctionIDSupplier
IDSupplier myJunctionIDSupplier
Definition: GNENet.h:745
XMLSubSys::runParser
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:112
GNEInspectorFrame::clearInspectedAC
void clearInspectedAC()
Clear all current inspected ACs.
Definition: GNEInspectorFrame.cpp:319
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNENetElement::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNENetElement.cpp:99
GNEDemandElement::createRouteCalculatorInstance
static void createRouteCalculatorInstance(GNENet *net)
create instance of RouteCalculator
Definition: GNEDemandElement.cpp:259
GNERouteHandler
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
Definition: GNERouteHandler.h:50
GNENet::initJunctionsAndEdges
void initJunctionsAndEdges()
Init Junctions and edges.
Definition: GNENet.cpp:2853
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
NWFrame.h
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GNENet::Z_INITIALIZED
static const double Z_INITIALIZED
marker for whether the z-boundary is initialized
Definition: GNENet.h:857
GNEAdditional.h
NWWriter_SUMO::writeTrafficLights
static void writeTrafficLights(OutputDevice &into, const NBTrafficLightLogicCont &tllCont)
writes the traffic light logics to the given device
Definition: NWWriter_SUMO.cpp:910
GNENet::replaceInListAttribute
static void replaceInListAttribute(GNEAttributeCarrier *ac, SumoXMLAttr key, const std::string &which, const std::string &by, GNEUndoList *undoList)
Definition: GNENet.cpp:3252
GNENet::generateAdditionalID
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
Definition: GNENet.cpp:2306
GNENet::myDemandElementsSaved
bool myDemandElementsSaved
Flag to check if demand elements has to be saved.
Definition: GNENet.h:764
NBNode::addOutgoingEdge
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition: NBNode.cpp:461
GNENet::removeShape
void removeShape(GNEShape *shape, bool updateViewAfterDeleting)
remove created shape (but NOT delete)
Definition: GNENet.cpp:3032
GNENet::GNEChange_Additional
friend class GNEChange_Additional
Definition: GNENet.h:88
NBEdgeCont::retrieve
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:246
GNENet::AttributeCarriers::junctions
std::map< std::string, GNEJunction * > junctions
map with the name and pointer to junctions of net
Definition: GNENet.h:95
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1289
GNENet::cleanInvalidDemandElements
void cleanInvalidDemandElements(GNEUndoList *undoList)
clean invalid demand elements
Definition: GNENet.cpp:1899
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
GNENet::getNumberOfTLSPrograms
int getNumberOfTLSPrograms() const
get number of TLS Programs
Definition: GNENet.cpp:2671
GNENet::removeExplicitTurnaround
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition: GNENet.cpp:2177
GNENet::retrievePOI
GNEPOI * retrievePOI(const std::string &id, bool failHard=true) const
get POI by id
Definition: GNENet.cpp:1115
GNENet::deleteEdge
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList, bool recomputeConnections)
removes edge
Definition: GNENet.cpp:430
GNENet::netHasGNECrossings
bool netHasGNECrossings() const
check if net has GNECrossings
Definition: GNENet.cpp:1575
SUMO_TAG_POLY
begin/end of the description of a polygon
Definition: SUMOXMLDefinitions.h:57
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
NBEdgeCont
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:60
NBNodeCont::rename
void rename(NBNode *node, const std::string &newID)
Renames the node. Throws exception if newID already exists.
Definition: NBNodeCont.cpp:1809
GNEAttributeCarrier::TagProperties::isPlacedInRTree
bool isPlacedInRTree() const
return true if Tag correspond to an element that has has to be placed in RTREE
Definition: GNEAttributeCarrier.cpp:865
DEFAULT_PEDTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
GNEChange_DemandElement.h
GUIParameterTableWindow.h
GNENet::deleteShape
void deleteShape(GNEShape *shape, GNEUndoList *undoList)
remove shape
Definition: GNENet.cpp:619
NBNetBuilder
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
GNEHierarchicalChildElements::getChildDemandElements
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
Definition: GNEHierarchicalChildElements.cpp:296
SUMO_ATTR_TLTYPE
node: the type of traffic light
Definition: SUMOXMLDefinitions.h:684
GNENet::computeNetwork
void computeNetwork(GNEApplicationWindow *window, bool force=false, bool volatileOptions=false, std::string additionalPath="", std::string demandPath="")
trigger full netbuild computation param[in] window The window to inform about delay param[in] force W...
Definition: GNENet.cpp:1457
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:57
WRITE_GLDEBUG
#define WRITE_GLDEBUG(msg)
Definition: MsgHandler.h:285
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNEAttributeCarrier::TagProperties::isStoppingPlace
bool isStoppingPlace() const
return true if tag correspond to a detector (Only used to group all stoppingPlaces in the output XML)
Definition: GNEAttributeCarrier.cpp:721
GNELane::isRestricted
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:809
GNENet::resetJunctionConnections
void resetJunctionConnections(GNEJunction *junction, GNEUndoList *undoList)
reset junction's connections
Definition: GNENet.cpp:2083
GNEShape::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEShape.cpp:108
GNEUndoList::p_end
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:79
Position::z
double z() const
Returns the z-position.
Definition: Position.h:66
GNEJunction::removeEdgeFromCrossings
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
Definition: GNEJunction.cpp:864
GNELane::getParentEdge
GNEEdge * getParentEdge() const
Returns underlying parent edge.
Definition: GNELane.cpp:1371
GNEAttributeCarrier::parseIDs
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
OptionsCont.h
GNENet::removeGLObjectFromGrid
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1328
GNENet::reserveEdgeID
void reserveEdgeID(const std::string &id)
reserve edge ID (To avoid duplicates)
Definition: GNENet.cpp:3069
GNENet::disableUpdateGeometry
void disableUpdateGeometry()
disable update geometry of elements after inserting or removing an element in net
Definition: GNENet.cpp:2682
GNEPOI
Definition: GNEPOI.h:44
GNEEdge::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:448
GNEDemandElement::selectAttributeCarrier
virtual void selectAttributeCarrier(bool changeFlag=true)=0
LANESPREAD_RIGHT
Definition: SUMOXMLDefinitions.h:1098
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GNEJunction::getJunctionNeighbours
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
Definition: GNEJunction.cpp:404
GNEFixAdditionalElements
Dialog for edit rerouters.
Definition: GNEFixAdditionalElements.h:42
GNENet::GNEChange_Connection
friend class GNEChange_Connection
Definition: GNENet.h:85
GNENet::insertEdge
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:2896
Position::setx
void setx(double x)
set position x
Definition: Position.h:71
GNEFrameAttributesModuls::AttributesEditor::removeEditedAC
void removeEditedAC(GNEAttributeCarrier *AC)
remove edited ACs
Definition: GNEFrameAttributesModuls.cpp:1650
EdgeVector
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
GNENet::AttributeCarriers::vehicleDepartures
std::map< std::string, GNEDemandElement * > vehicleDepartures
special map used for saving Demand Elements of type "Vehicle" (Vehicles, routeFlows,...
Definition: GNENet.h:107
GNENet::saveJoined
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:1018
GUIGLObjectPopupMenu.h
GNEEdge::invalidatePathChildElementss
void invalidatePathChildElementss()
invalidate path element childs
Definition: GNEEdge.cpp:1495
NBNodeCont::insert
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:78
GNENet::myEdgeIDSupplier
IDSupplier myEdgeIDSupplier
Definition: GNENet.h:744
GUIGlobalSelection.h
GNEEdge::setMicrosimID
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1885
GNENet::updateAdditionalID
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
Definition: GNENet.cpp:2222
NBNodeCont::getAllNames
std::vector< std::string > getAllNames() const
get all node names
Definition: NBNodeCont.cpp:1799
GNENet::deleteSingleEdge
void deleteSingleEdge(GNEEdge *edge, bool updateViewAfterDeleting)
deletes a single edge
Definition: GNENet.cpp:2975
SUMO_ATTR_NUMLANES
Definition: SUMOXMLDefinitions.h:383
GNENet::reverseEdge
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:887
OptionsCont::getString
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Definition: OptionsCont.cpp:201
GNEPoly
Definition: GNEPoly.h:45
NBNode::getOutgoingEdges
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
Definition: NBNode.h:260
GNEJunction::getGNEOutgoingEdges
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:487
GNENet::deleteAdditional
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition: GNENet.cpp:628
SUMO_TAG_PERSON
Definition: SUMOXMLDefinitions.h:295
GNEJunction::getGNEConnections
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
Definition: GNEJunction.cpp:499
GNENet::getSelectedAttributeCarriers
std::vector< GNEAttributeCarrier * > getSelectedAttributeCarriers(bool ignoreCurrentSupermode)
get all selected attribute carriers (or only relative to current supermode
Definition: GNENet.cpp:2123
SUMO_TAG_LANE
begin/end of the description of a single lane
Definition: SUMOXMLDefinitions.h:49
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1197
GNENet::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENet.cpp:202
GNENet::myNeedRecompute
bool myNeedRecompute
whether the net needs recomputation
Definition: GNENet.h:752
SUMO_ATTR_EDGE
Definition: SUMOXMLDefinitions.h:423
GNEJunction::removeIncomingGNEEdge
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
Definition: GNEJunction.cpp:447
GNENet::splitEdgesBidi
void splitEdgesBidi(GNEEdge *edge, GNEEdge *oppositeEdge, const Position &pos, GNEUndoList *undoList)
split all edges at position by inserting one new junction
Definition: GNENet.cpp:875
ShapeContainer
Storage for geometrical objects.
Definition: ShapeContainer.h:49
GNENet::retrieveDemandElement
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
Definition: GNENet.cpp:2316
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:222
SUMO_TAG_PTYPE
description of a person type (used in NETEDIT)
Definition: SUMOXMLDefinitions.h:123
GNENet::requireSaveTLSPrograms
void requireSaveTLSPrograms()
Definition: GNENet.cpp:2646
GNEJunction::getGNECrossings
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
Definition: GNEJunction.cpp:493
GNENet::getApp
FXApp * getApp()
get pointer to the main App
Definition: GNENet.cpp:1586
NODETYPE_UNKNOWN
Definition: SUMOXMLDefinitions.h:1055
GNEFixAdditionalElements.h
SVC_BICYCLE
vehicle is a bicycle
Definition: SUMOVehicleClass.h:179
Boundary::getHeight
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:160
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
GNENet::myAllowUndoShapes
bool myAllowUndoShapes
flag used to indicate if shaped created can be undo
Definition: GNENet.h:863
GNENet::cleanInvalidCrossings
bool cleanInvalidCrossings(GNEUndoList *undoList)
clear invalid crossings
Definition: GNENet.cpp:1736
SUMO_TAG_POI
begin/end of the description of a Point of interest
Definition: SUMOXMLDefinitions.h:53
GNEViewNet
Definition: GNEViewNet.h:42
GNEApplicationWindow
The main window of the Netedit.
Definition: GNEApplicationWindow.h:58
GNEJunction::markAsModified
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
Definition: GNEJunction.cpp:804
GNENet::replaceIncomingEdge
void replaceIncomingEdge(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replaces edge
Definition: GNENet.cpp:493
GNENet::update
void update()
notify myViewNet
Definition: GNENet.cpp:3061
NWWriter_XML::writeNetwork
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
Definition: NWWriter_XML.cpp:52
GNENet::changeShapeID
void changeShapeID(GNEShape *s, const std::string &OldID)
change Shape ID
Definition: GNENet.cpp:2622
GNENet::restrictLane
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition: GNENet.cpp:690
GNE_ATTR_SHAPE_END
last coordinate of edge shape
Definition: SUMOXMLDefinitions.h:977
GNENet::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNENet.cpp:212
GNENet::insertJunction
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container
Definition: GNENet.cpp:2889
NBNode::buildCrossings
int buildCrossings()
build pedestrian crossings
Definition: NBNode.cpp:2499
NBEdgeCont::insert
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:153
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
NBNodesEdgesSorter::sortNodesEdges
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
Definition: NBAlgorithms.cpp:136
GNEChange_Edge.h
SUMO_TAG_NOTHING
invalid tag
Definition: SUMOXMLDefinitions.h:43
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:637
NBEdge::getPermissions
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:3404
GNENet::getVisualisationSpeedUp
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:301
SUMO_TAG_VTYPE
description of a vehicle type
Definition: SUMOXMLDefinitions.h:121
GNEJunction::setResponsible
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEJunction.cpp:1193
GNEApplicationWindow::disableSaveDemandElementsMenu
void disableSaveDemandElementsMenu()
disable save demand elements
Definition: GNEApplicationWindow.cpp:1980
GNEViewNet::update
void update() const
Mark the entire GNEViewNet to be repainted later.
Definition: GNEViewNet.cpp:299
GNENet::addExplicitTurnaround
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:2171
GNENet::retrieveConnections
std::vector< GNEConnection * > retrieveConnections(bool onlySelected=false) const
return all connections
Definition: GNENet.cpp:1148
PositionVector
A list of positions.
Definition: PositionVector.h:45
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
NWWriter_SUMO.h
GNENet::AttributeCarriers::additionals
std::map< SumoXMLTag, std::map< std::string, GNEAdditional * > > additionals
map with the name and pointer to additional elements of net
Definition: GNENet.h:101
GNEAdditional::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEAdditional.cpp:532
OutputDevice::close
void close()
Closes the device and removes it from the dictionary.
Definition: OutputDevice.cpp:207
NBEdge::hasDefaultGeometryEndpointAtNode
bool hasDefaultGeometryEndpointAtNode(const NBNode *node) const
Returns whether the geometry is terminated by the node positions This default may be violated by init...
Definition: NBEdge.cpp:571
GNENet::myViewNet
GNEViewNet * myViewNet
The viewNet to be notofied of about changes.
Definition: GNENet.h:734
GNENet::GNEChange_Shape
friend class GNEChange_Shape
Definition: GNENet.h:86
GNENet::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNENet.cpp:289
GNENet::reserveJunctionID
void reserveJunctionID(const std::string &id)
reserve junction ID (To avoid duplicates)
Definition: GNENet.cpp:3075
GNENet::GNEChange_Lane
friend class GNEChange_Lane
Definition: GNENet.h:84
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:219
GNEFixDemandElements.h
NBNodeCont
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:59
NBNetBuilder::getEdgeCont
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:150
NWWriter_XML::writeJoinedJunctions
static void writeJoinedJunctions(const OptionsCont &oc, NBNodeCont &nc)
Writes the joined-juncionts to file.
Definition: NWWriter_XML.cpp:380
GNEAttributeCarrier::TagProperties::getTag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
Definition: GNEAttributeCarrier.cpp:523
GNENet::deleteCrossing
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition: GNENet.cpp:602
GNEAttributeCarrier::AttributeProperties::isList
bool isList() const
return true if atribute is a list
Definition: GNEAttributeCarrier.cpp:430
GNEJunction::updateGeometry
void updateGeometry()
update pre-computed geometry information (including crossings)
Definition: GNEJunction.cpp:109
GUIGlObjectStorage.h
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
GLO_POLYGON
a polygon
Definition: GUIGlObjectTypes.h:104
GNENet::deleteLane
void deleteLane(GNELane *lane, GNEUndoList *undoList, bool recomputeConnections)
removes lane
Definition: GNENet.cpp:549
GNEJunction.h
SUMO_ATTR_TO
Definition: SUMOXMLDefinitions.h:640
IDSupplier::avoid
void avoid(const std::string &id)
make sure that the given id is never supplied
Definition: IDSupplier.cpp:59
GNENet::generateShapeID
std::string generateShapeID(SumoXMLTag shapeTag) const
generate Shape ID
Definition: GNENet.cpp:2597
GNEChange_Additional.h
GNELane::getIndex
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:774
NBNode::addIncomingEdge
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition: NBNode.cpp:451
GNENet::setViewNet
void setViewNet(GNEViewNet *viewNet)
Set the viewNet to be notified of network changes.
Definition: GNENet.cpp:1026
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNENet::splitEdge
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:770
GNENet::getZBoundary
const Boundary & getZBoundary() const
Returns the Z boundary (stored in the x() coordinate) values of 0 do not affect the boundary.
Definition: GNENet.cpp:295
GNECrossing::getNBCrossing
NBNode::Crossing * getNBCrossing() const
get referente to NBode::Crossing
Definition: GNECrossing.cpp:104
GNENet::retrievePolygon
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
Definition: GNENet.cpp:1102
GNEEdge::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:892
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:131
GNENet::AttributeCarriers::edges
std::map< std::string, GNEEdge * > edges
map with the name and pointer to edges of net
Definition: GNENet.h:98
SUMORTree
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:68
NBNode::getPosition
const Position & getPosition() const
Definition: NBNode.h:247
GNE_ATTR_SHAPE_START
first coordinate of edge shape
Definition: SUMOXMLDefinitions.h:975
NBNodeCont::analyzeCluster
void analyzeCluster(NodeSet cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type, SumoXMLNodeType &nodeType)
Definition: NBNodeCont.cpp:1269
GNEHierarchicalParentElements::getParentAdditionals
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
Definition: GNEHierarchicalParentElements.cpp:85
GNENet::myNetBuilder
NBNetBuilder * myNetBuilder
The internal netbuilder.
Definition: GNENet.h:737
NBNode::checkIsRemovable
bool checkIsRemovable() const
check if node is removable
Definition: NBNode.cpp:2044
GNENet::joinSelectedJunctions
bool joinSelectedJunctions(GNEUndoList *undoList)
join selected junctions
Definition: GNENet.cpp:1598
GNEJunction::getNBNode
NBNode * getNBNode() const
Return net build node.
Definition: GNEJunction.cpp:398
GNEAdditional::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEAdditional.cpp:548
NBNode::getEdgesToJoin
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
get edges to join
Definition: NBNode.cpp:2117
PositionVector::nearest_offset_to_point2D
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Definition: PositionVector.cpp:817
GNENet::registerEdge
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with GNENet containers
Definition: GNENet.cpp:2932
GNEAttributeCarrier::TagProperties::isVehicle
bool isVehicle() const
return true if tag correspond to a vehicle element
Definition: GNEAttributeCarrier.cpp:739
RGBColor
Definition: RGBColor.h:39
GUIGlObject::setMicrosimID
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
Definition: GUIGlObject.cpp:173
SUMO_TAG_ROUTEFLOW
a flow definition nusing a route instead of a from-to edges route (used in NETEDIT)
Definition: SUMOXMLDefinitions.h:151
GNENet::getNetBuilder
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1592
GNENet::retrieveLanes
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:1213
Boundary::reset
void reset()
Resets the boundary.
Definition: Boundary.cpp:66
LINKDIR_STRAIGHT
The link is a straight direction.
Definition: SUMOXMLDefinitions.h:1178
NBEdge::getToNode
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:498
NBNode::isTLControlled
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:313
GNEDemandElement::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GUIPointOfInterest
Definition: GUIPointOfInterest.h:45
GNENet::joinRoutes
void joinRoutes(GNEUndoList *undoList)
join routes
Definition: GNENet.cpp:1833
NWFrame::writeNetwork
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network stored in the given net builder.
Definition: NWFrame.cpp:175
NBEdge::getGeometry
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:692
NamedObjectCont::size
int size() const
Returns the number of stored items within the container.
Definition: NamedObjectCont.h:116
PositionVector::push_back_noDoublePos
void push_back_noDoublePos(const Position &p)
insert in back a non double position
Definition: PositionVector.cpp:1295
SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
Definition: SUMOXMLDefinitions.h:149
GNECrossing
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:44
GUIGlObjectStorage::setNetObject
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
Definition: GUIGlObjectStorage.h:125
GNEJunction::invalidateTLS
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
Definition: GNEJunction.cpp:815
GNEAttributeCarrier::getTagProperty
const TagProperties & getTagProperty() const
get Tag Property assigned to this object
Definition: GNEAttributeCarrier.cpp:1273
GNEApplicationWindow::enableSaveDemandElementsMenu
void enableSaveDemandElementsMenu()
enable save demand elements
Definition: GNEApplicationWindow.cpp:1973
GNEHierarchicalParentElements::getParentDemandElements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
Definition: GNEHierarchicalParentElements.cpp:114
GNENet::deleteSingleJunction
void deleteSingleJunction(GNEJunction *junction, bool updateViewAfterDeleting)
deletes a single junction
Definition: GNENet.cpp:2954
GNEJunction::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEJunction.cpp:253
GNENet::myEdgesAndNumberOfLanes
std::map< std::string, int > myEdgesAndNumberOfLanes
map with the Edges and their number of lanes
Definition: GNENet.h:860
GNENet::AttributeCarriers
struct used for saving all attribute carriers of net, in different formats
Definition: GNENet.h:93
GNEShape
Definition: GNEShape.h:34
GeoConvHelper::getFinal
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: GeoConvHelper.h:105
GNENet::computeAndUpdate
void computeAndUpdate(OptionsCont &oc, bool volatileOptions)
recompute the network and update lane geometries
Definition: GNENet.cpp:3094
GNEJunction::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEJunction.cpp:933
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
GNEChange_Shape.h
GNENet::getEdgeCont
NBEdgeCont & getEdgeCont()
returns the NBEdgeCont of the underlying netbuilder
Definition: GNENet.cpp:2153
GNEAttributeCarrier::allowedTagsByCategory
static std::vector< SumoXMLTag > allowedTagsByCategory(int tagPropertyCategory, bool onlyDrawables)
get tags of all editable element types using TagProperty Type (TAGTYPE_NETELEMENT,...
Definition: GNEAttributeCarrier.cpp:1333
GNENet::requireSaveAdditionals
void requireSaveAdditionals(bool value)
inform that additionals has to be saved
Definition: GNENet.cpp:2236
SUMO_TAG_POILANE
begin/end of the description of a Point of interest over Lane (used by Netedit)
Definition: SUMOXMLDefinitions.h:55
GNENet::isAdditionalsSaved
bool isAdditionalsSaved() const
check if additionals are saved
Definition: GNENet.cpp:2300
NamedObjectCont::remove
bool remove(const std::string &id, const bool del=true)
Removes an item.
Definition: NamedObjectCont.h:78
GNEDemandElement::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEConnection::getEdgeFrom
GNEEdge * getEdgeFrom() const
get the name of the edge the vehicles leave
Definition: GNEConnection.cpp:166
GNEVehicleType
Definition: GNEVehicleType.h:36
GNEEdge::getNBEdge
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:631
GNEJunction::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEJunction.cpp:987
GNENet::requireSaveDemandElements
void requireSaveDemandElements(bool value)
inform that demand elements has to be saved
Definition: GNENet.cpp:2392
GNEJunction::addIncomingGNEEdge
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
Definition: GNEJunction.cpp:418
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1054
GNEConnection::getNBEdgeConnection
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
Definition: GNEConnection.cpp:202
NBEdge::getLaneID
std::string getLaneID(int lane) const
get lane ID
Definition: NBEdge.cpp:3093
GNEHierarchicalChildElements::getChildShapes
const std::vector< GNEShape * > & getChildShapes() const
get child shapes
Definition: GNEHierarchicalChildElements.cpp:444
NBNode::getEndPoints
std::vector< std::pair< Position, std::string > > getEndPoints() const
return list of unique endpoint coordinates of all edges at this node
Definition: NBNode.cpp:3355
GNEAdditional::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEAdditional.cpp:517
GNEAttributeCarrier::TagProperties::isDemandElement
bool isDemandElement() const
return true if tag correspond to a demand element
Definition: GNEAttributeCarrier.cpp:715
EdgeSet
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:49
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
GNENet::splitJunction
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:1987
SUMORTree::removeAdditionalGLObject
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:156
GNEViewNet.h
NBNode::getDirection
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:1933
GNEAdditionalHandler.h
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:159
SUMO_ATTR_WIDTH
Definition: SUMOXMLDefinitions.h:386
GNENet::retrieveDemandElements
std::vector< GNEDemandElement * > retrieveDemandElements(bool onlySelected=false) const
return all demand elements
Definition: GNENet.cpp:2328
GNENet::addPolygonForEditShapes
GNEPoly * addPolygonForEditShapes(GNENetElement *netElement, const PositionVector &shape, bool fill, RGBColor col)
Builds a special polygon used for edit Junctions's shapes.
Definition: GNENet.cpp:2568
SUMO_ATTR_ROUTE
Definition: SUMOXMLDefinitions.h:440
NBEdge::getInnerGeometry
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
Definition: NBEdge.cpp:552
GNENet::retrieveShapes
std::vector< GNEShape * > retrieveShapes(SumoXMLTag shapeTag, bool onlySelected=false)
return shape by type shapes
Definition: GNENet.cpp:1274
NBNode::Crossing::priority
bool priority
whether the pedestrians have priority
Definition: NBNode.h:151
GNENet::enableUpdateGeometry
void enableUpdateGeometry()
Definition: GNENet.cpp:2676
SUMO_ATTR_EDGES
the edges of a route
Definition: SUMOXMLDefinitions.h:427
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNENet::getNumberOfDemandElements
int getNumberOfDemandElements(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of demand elements of the net.
Definition: GNENet.cpp:2343
GNELane::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:862
NBEdge::getNumLanes
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:477
Boundary::getWidth
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:154
GNEApplicationWindow::enableSaveTLSProgramsMenu
void enableSaveTLSProgramsMenu()
enable save TLS Programs
Definition: GNEApplicationWindow.cpp:1967
GNENet::renameJunction
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:2159
SUMO_TAG_EDGE
begin/end of the description of an edge
Definition: SUMOXMLDefinitions.h:47
NBNetBuilder.h
GNENet::createEdge
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *tpl, 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:326
GNENet::myAdditionalsSaved
bool myAdditionalsSaved
Flag to check if additionals has to be saved.
Definition: GNENet.h:758
GNE_SUPERMODE_NETWORK
Network mode (Edges, junctions, etc..)
Definition: GNEViewNetHelper.h:46
ProcessError
Definition: UtilExceptions.h:39
GNENet::retrieveJunction
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
Definition: GNENet.cpp:1050
GNEViewNetHelper::EditModes::currentSupermode
Supermode currentSupermode
the current supermode
Definition: GNEViewNetHelper.h:305
GNENet::addRestrictedLane
bool addRestrictedLane(SUMOVehicleClass vclass, GNEEdge *edge, int index, GNEUndoList *undoList)
add restricted lane to edge
Definition: GNENet.cpp:720
getVehicleClassNames
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
Definition: SUMOVehicleClass.cpp:168
isRailway
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
Definition: SUMOVehicleClass.cpp:363
GNEViewParent::getInspectorFrame
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_NMODE_INSPECT
Definition: GNEViewParent.cpp:180
GNENet::retrieveAttributeCarrier
GNEAttributeCarrier * retrieveAttributeCarrier(const GUIGlID id, bool failHard=true)
get a single attribute carrier based on a GLID
Definition: GNENet.cpp:1334
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEApplicationWindow.h
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
GNEEdge.h
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:1020
GNENet::initGNEConnections
void initGNEConnections()
initialize GNEConnections
Definition: GNENet.cpp:3081
GNEDemandElement::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEDemandElement.cpp:552
PositionVector::append
void append(const PositionVector &v, double sameThreshold=2.0)
Definition: PositionVector.cpp:696
GNENetElement::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNENetElement.cpp:114
ShapeContainer::myPOIs
POIs myPOIs
stored POIs
Definition: ShapeContainer.h:215
NBEdge::getTotalWidth
double getTotalWidth() const
Returns the combined width of all lanes of this edge.
Definition: NBEdge.cpp:3276
GNENet::save
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:1000
GNENet::duplicateLane
void duplicateLane(GNELane *lane, GNEUndoList *undoList, bool recomputeConnections)
duplicates lane
Definition: GNENet.cpp:674
GNEApplicationWindow::enableSaveAdditionalsMenu
void enableSaveAdditionalsMenu()
enable save additionals
Definition: GNEApplicationWindow.cpp:1953
GNENet::retrieveCrossings
std::vector< GNECrossing * > retrieveCrossings(bool onlySelected=false) const
return all crossings
Definition: GNENet.cpp:1184
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NBNode::getEdges
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
Definition: NBNode.h:265
NBEdge::getLaneStruct
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1287
GNENetElement
Definition: GNENetElement.h:43
GNENet::updateDemandElementBegin
void updateDemandElementBegin(const std::string &oldBegin, GNEDemandElement *demandElement)
update demand element begin in container
Definition: GNENet.cpp:2378
GNE_ATTR_DEFAULT_VTYPE
Flag to check if VType is a default VType.
Definition: SUMOXMLDefinitions.h:1005
GUIGlObjectStorage::getObjectBlocking
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
Definition: GUIGlObjectStorage.cpp:62
GNEJunction::addOutgoingGNEEdge
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
Definition: GNEJunction.cpp:433
GUIGlObject
Definition: GUIGlObject.h:65
NBConnection
Definition: NBConnection.h:43
GNENet::saveDemandElementsConfirmed
void saveDemandElementsConfirmed(const std::string &filename)
save demand elements after confirming invalid objects
Definition: GNENet.cpp:2544
GNENet::GNEChange_DemandElement
friend class GNEChange_DemandElement
Definition: GNENet.h:89
NBEdge::resetNodeBorder
void resetNodeBorder(const NBNode *node)
Definition: NBEdge.cpp:680
GNEReferenceCounter::decRef
void decRef(const std::string &debugMsg="")
Decrease reference.
Definition: GNEReferenceCounter.h:52
GNEEdge::getGNEJunctionDestiny
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:493
GNENet::registerJunction
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction with GNENet containers
Definition: GNENet.cpp:2907
GNECrossing.h
GNENet::updateDemandElementID
void updateDemandElementID(const std::string &oldID, GNEDemandElement *demandElement)
update demand element ID in container
Definition: GNENet.cpp:2355
GNEEdge::getLanes
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:874
GNENet::AttributeCarriers::demandElements
std::map< SumoXMLTag, std::map< std::string, GNEDemandElement * > > demandElements
map with the name and pointer to demand elements of net
Definition: GNENet.h:104
GNENet::myNetSaved
bool myNetSaved
Flag to check if net has to be saved.
Definition: GNENet.h:755
SUMO_TAG_VEHICLE
description of a vehicle
Definition: SUMOXMLDefinitions.h:119
GNENet::deleteConnection
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
Definition: GNENet.cpp:587
GNELane.h
GNENet::isDemandElementsSaved
bool isDemandElementsSaved() const
check if demand elements are saved
Definition: GNENet.cpp:2455
GNENet::addPolygon
bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false)
Builds a polygon using the given values and adds it to the container.
Definition: GNENet.cpp:217
GNEJunction::removeConnectionsFrom
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
Definition: GNEJunction.cpp:682
GNENet::retrieveAdditionals
std::vector< GNEAdditional * > retrieveAdditionals(bool onlySelected=false) const
return all additionals
Definition: GNENet.cpp:2195
SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:660
PositionVector::splitAt
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.
Definition: PositionVector.cpp:552
NBNodeCont::retrieve
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:107
GNEJunction::setLogicValid
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
Definition: GNEJunction.cpp:659
GNENet::GNEChange_Edge
friend class GNEChange_Edge
Definition: GNENet.h:83
GNEInspectorFrame::getAttributesEditor
GNEFrameAttributesModuls::AttributesEditor * getAttributesEditor() const
get AttributesEditor
Definition: GNEInspectorFrame.cpp:330
GNENet::getViewNet
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2117
NBNode::Crossing::customTLIndex
int customTLIndex
the custom traffic light index of this crossing (if controlled)
Definition: NBNode.h:158
GUIGlObject::buildPopupHeader
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
Definition: GUIGlObject.cpp:207
GNENet::createJunction
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:313
GNENet::myAttributeCarriers
AttributeCarriers myAttributeCarriers
AttributeCarriers of net.
Definition: GNENet.h:740
SUMO_ATTR_FROM
Definition: SUMOXMLDefinitions.h:639
ShapeContainer::getPOIs
const POIs & getPOIs() const
Returns all pois.
Definition: ShapeContainer.h:154
GNENet::replaceJunctionByGeometry
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
replace the selected junction by geometry node(s) and merge the edges
Definition: GNENet.cpp:1940
SUMO_ATTR_LANES
Definition: SUMOXMLDefinitions.h:638
GNENet::mergeJunctions
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:935
GNEAttributeCarrier::isAttributeCarrierSelected
virtual bool isAttributeCarrierSelected() const =0
check if attribute carrier is selected
GNEEdge::setResponsible
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1177
NBEdgeCont::getAllNames
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:689
GNENet::additionalExist
bool additionalExist(GNEAdditional *additional) const
return true if additional exist (use pointer instead ID)
Definition: GNENet.cpp:2697
GNEJunction::getGNEIncomingEdges
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
Definition: GNEJunction.cpp:481
GNENet::retrieveAttributeCarriers
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(SumoXMLTag type=SUMO_TAG_NOTHING)
get the attribute carriers based on Type
Definition: GNENet.cpp:1357
GNEViewParent.h
GNENet::retrieveJunctions
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:1261
GNENet::myExplicitTurnarounds
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition: GNENet.h:749
GNENet::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNENet.cpp:192
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:208
GNENet::getBoundary
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:185
GNEEdge::getGNEJunctionSource
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:487
GUIGlObjectStorage::unblockObject
void unblockObject(GUIGlID id)
Marks an object as unblocked.
Definition: GUIGlObjectStorage.cpp:119
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
GNENet::retrieveCrossing
GNECrossing * retrieveCrossing(const std::string &id, bool failHard=true) const
get Crossing by id
Definition: GNENet.cpp:1164
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GNEPoly.h
GNEAttributeCarrier::TagProperties::isPersonPlan
bool isPersonPlan() const
return true if tag correspond to a person plan
Definition: GNEAttributeCarrier.cpp:762
GNEConnection::getNBConnection
NBConnection getNBConnection() const
get NBConnection
Definition: GNEConnection.cpp:208
GNENet::deleteJunction
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:385
GNENet::addGLObjectIntoGrid
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1322
GNENet::~GNENet
~GNENet()
Destructor.
Definition: GNENet.cpp:133
GNEFixDemandElements
Dialog for edit rerouters.
Definition: GNEFixDemandElements.h:41
NWWriter_XML.h
OutputDevice::getDevice
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Definition: OutputDevice.cpp:54
GNENet::getTLLogicCont
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:2147
GNEApplicationWindow::disableSaveAdditionalsMenu
void disableSaveAdditionalsMenu()
disable save additionals
Definition: GNEApplicationWindow.cpp:1960
GNENet::saveAdditionals
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:2255
GNECrossing::getParentJunction
GNEJunction * getParentJunction() const
get parent Junction
Definition: GNECrossing.cpp:92
GNEViewParent::getGNEAppWindows
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
Definition: GNEViewParent.cpp:314
NBNode::Crossing::width
double width
This crossing's width.
Definition: NBNode.h:143
GUIMainWindow
Definition: GUIMainWindow.h:46
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
GNENet::savePlain
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:1010
UnknownElement
Definition: UtilExceptions.h:147
SUMO_TAG_CROSSING
crossing between edges for pedestrians
Definition: SUMOXMLDefinitions.h:226
GNEChange_Crossing
Definition: GNEChange_Crossing.h:48
GNENet::requireRecompute
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:1569
GNENet::saveTLSPrograms
void saveTLSPrograms(const std::string &filename)
save TLS Programs elements of the network
Definition: GNENet.cpp:2656
NBNode::Crossing::customShape
PositionVector customShape
optional customShape for this crossing
Definition: NBNode.h:153
GNEJunction::getGNEEdges
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
Definition: GNEJunction.cpp:475
NBEdgeCont::rename
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:399
GNENet::GNEChange_Junction
friend class GNEChange_Junction
Definition: GNENet.h:82
GNENet::addReversedEdge
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:900
PositionVector::reverse
PositionVector reverse() const
reverse position vector
Definition: PositionVector.cpp:1086
NBNetBuilder::getTLLogicCont
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
Definition: NBNetBuilder.h:165
GNENet::removeSolitaryJunctions
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition: GNENet.cpp:1788
GNE_SUPERMODE_DEMAND
Demanding mode (Routes, Vehicles etc..)
Definition: GNEViewNetHelper.h:48
GNENet::saveAdditionalsConfirmed
void saveAdditionalsConfirmed(const std::string &filename)
save additionals after confirming invalid objects
Definition: GNENet.cpp:2487
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:42
NBNode::getControllingTLS
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:318
GNENet::removeRestrictedLane
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge *edge, GNEUndoList *undoList)
remove restricted lane
Definition: GNENet.cpp:756
GNENet::myGrid
SUMORTree myGrid
the rtree which contains all GUIGlObjects (so named for historical reasons)
Definition: GNENet.h:731
NBEdge::Lane
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:142
NBNode::Crossing::customTLIndex2
int customTLIndex2
Definition: NBNode.h:159
NamedObjectCont::changeID
bool changeID(const std::string &oldId, const std::string &newId)
change ID of a stored object
Definition: NamedObjectCont.h:130
SUMOXMLDefinitions::getEdgeIDFromLane
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
Definition: SUMOXMLDefinitions.cpp:961
NBNode::getIncomingEdges
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
Definition: NBNode.h:255
GNEAttributeCarrier::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEApplicationWindow::setStatusBarText
void setStatusBarText(const std::string &statusBarText)
set text of the statusBar
Definition: GNEApplicationWindow.cpp:1792
GNEDemandElement::unselectAttributeCarrier
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
NamedObjectCont::get
T get(const std::string &id) const
Retrieves an item.
Definition: NamedObjectCont.h:98
GNEShape::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
NBEdgeCont::extract
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
Definition: NBEdgeCont.cpp:387
GNENet::clearJunctionConnections
void clearJunctionConnections(GNEJunction *junction, GNEUndoList *undoList)
clear junction's connections
Definition: GNENet.cpp:2071
GNENet::retrieveEdges
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:1200
GNEReferenceCounter::incRef
void incRef(const std::string &debugMsg="")
Increarse reference.
Definition: GNEReferenceCounter.h:67
GUIGlObjectStorage::gIDStorage
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
Definition: GUIGlObjectStorage.h:140
NBNodeCont::registerJoinedCluster
void registerJoinedCluster(const NodeSet &cluster)
gets all joined clusters (see doc for myClusters2Join)
Definition: NBNodeCont.cpp:1259
NBNetBuilder::getDistrictCont
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
Definition: NBNetBuilder.h:170
SUMO_ATTR_ALLOW
Definition: SUMOXMLDefinitions.h:782
SUMO_TAG_CONNECTION
connectio between two lanes
Definition: SUMOXMLDefinitions.h:202
IDSupplier::getNext
std::string getNext()
Returns the next id.
Definition: IDSupplier.cpp:51
GNEAttributeCarrier::TagProperties::isDrawable
bool isDrawable() const
return true if tag correspond to a drawable element
Definition: GNEAttributeCarrier.cpp:792
GNEAttributeCarrier::TagProperties::isDetector
bool isDetector() const
return true if tag correspond to a shape (Only used to group all detectors in the XML)
Definition: GNEAttributeCarrier.cpp:727
GNEPoly::setShapeEditedElement
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:480
gSelected
GUISelectedStorage gSelected
A global holder of selected objects.
Definition: GUIGlobalSelection.cpp:33
GUIGlObject::buildCenterPopupEntry
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
Definition: GUIGlObject.cpp:216
NBEdge::UNSPECIFIED_WIDTH
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:315
GUIGlObject::buildPositionCopyEntry
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
Definition: GUIGlObject.cpp:266
GNENet::addPOI
bool addPOI(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, double posLat, double layer, double angle, const std::string &imgFile, bool relativePath, double width, double height, bool ignorePruning=false)
Builds a POI using the given values and adds it to the container.
Definition: GNENet.cpp:240
SUMO_TAG_ROUTEPROBE
a routeprobe detector
Definition: SUMOXMLDefinitions.h:115
GNENet::retrieveEdge
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:1069
NBNode::Crossing::edges
EdgeVector edges
The edges being crossed.
Definition: NBNode.h:137
NBNetBuilder::compute
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
Definition: NBNetBuilder.cpp:77
GNEConnection
Definition: GNEConnection.h:38
GNENet::computeJunction
void computeJunction(GNEJunction *junction)
trigger recomputation of junction shape and logic param[in] window The window to inform about delay
Definition: GNENet.cpp:1551
SUMORTree::addAdditionalGLObject
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:126
SUMO_TAG_ROUTE
begin/end of the description of a route
Definition: SUMOXMLDefinitions.h:125
GNENet::retrieveLane
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1228
GNEDemandElement::deleteRouteCalculatorInstance
static void deleteRouteCalculatorInstance()
delete instance of RouteCalculator
Definition: GNEDemandElement.cpp:269
NBNodeCont::extract
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
Definition: NBNodeCont.cpp:148
NamedObjectCont::clear
void clear()
Removes all items from the container (deletes them, too)
Definition: NamedObjectCont.h:108
GNENet::getNumberOfShapes
int getNumberOfShapes() const
get number of shapes
Definition: GNENet.cpp:2640
GNEAttributeCarrier::TagProperties::getAttributeProperties
const AttributeProperties & getAttributeProperties(SumoXMLAttr attr) const
get attribute (throw error if doesn't exist)
Definition: GNEAttributeCarrier.cpp:623
GNEAttributeCarrier::getTagProperties
static const TagProperties & getTagProperties(SumoXMLTag tag)
get Tag Properties
Definition: GNEAttributeCarrier.cpp:1298
GNENet::renameEdge
void renameEdge(GNEEdge *edge, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:2094
GNENet::retrieveConnection
GNEConnection * retrieveConnection(const std::string &id, bool failHard=true) const
get Connection by id
Definition: GNENet.cpp:1128
SUMO_TAG_PERSONFLOW
Definition: SUMOXMLDefinitions.h:299
GNEAttributeCarrier::setAttribute
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
NBTrafficLightLogicCont::computeSingleLogic
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
Definition: NBTrafficLightLogicCont.cpp:160
GNEChange_Lane.h
SVC_BUS
vehicle is a bus
Definition: SUMOVehicleClass.h:165
GNEVehicleType.h
GNENet::isUpdateGeometryEnabled
bool isUpdateGeometryEnabled() const
check if update geometry after inserting or removing has to be updated
Definition: GNENet.cpp:2688
GNENet::GNEChange_ReplaceEdgeInTLS
class for GNEChange_ReplaceEdgeInTLS
Definition: GNENet.h:866
GNEJunction::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEJunction.cpp:1138
GNE_ATTR_SELECTED
element is selected
Definition: SUMOXMLDefinitions.h:971
GNEViewNet::getEditModes
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:434
GNENet::myZBoundary
Boundary myZBoundary
the z boundary (stored in the x-coordinate), values of 0 are ignored
Definition: GNENet.h:854
GNEChange_Attribute
the function-object for an editing operation (abstract base)
Definition: GNEChange_Attribute.h:47
GNEChange_Crossing.h
GNENet::demandElementExist
bool demandElementExist(GNEDemandElement *demandElement) const
return true if demand element exist (use pointer instead ID)
Definition: GNENet.cpp:2765
GNENetElement::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
Definition: GNENetElement.cpp:83
GNENet::removePolygonForEditShapes
void removePolygonForEditShapes(GNEPoly *polygon)
remove Polygon for edit shapes
Definition: GNENet.cpp:2583
GNEInspectorFrame.h
GNEPOI.h
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1267
GNENet::generateDemandElementID
std::string generateDemandElementID(const std::string &prefix, SumoXMLTag type) const
generate demand element id
Definition: GNENet.cpp:2461
OutputDevice::writeXMLHeader
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
Definition: OutputDevice.cpp:227
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
GNEUndoList
Definition: GNEUndoList.h:48
ShapeContainer::getPolygons
const Polygons & getPolygons() const
Returns all polygons.
Definition: ShapeContainer.h:149
GNEDemandElement::getBegin
virtual std::string getBegin() const
get begin time of demand element
Definition: GNEDemandElement.cpp:247
GNEEdge::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:974
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GUISelectedStorage::getSelected
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
Definition: GUISelectedStorage.cpp:164
NBAlgorithms.h
GNEAdditionalHandler
Builds additional objects for GNENet (busStops, chargingStations, detectors, etc.....
Definition: GNEAdditionalHandler.h:47
GNEJunction
Definition: GNEJunction.h:47
GNEJunction::removeConnectionsTo
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
Definition: GNEJunction.cpp:711
GNENet::deleteDemandElement
void deleteDemandElement(GNEDemandElement *demandElement, GNEUndoList *undoList)
remove demand element
Definition: GNENet.cpp:645
NBNetBuilder::getNodeCont
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:155
Position::sety
void sety(double y)
set position y
Definition: Position.h:76
NBNode::Crossing
A definition of a pedestrian crossing.
Definition: NBNode.h:131
NBEdge::Connection
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:189
GNEUndoList::p_begin
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:72
GNENet::insertDemandElement
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element element int GNENet container.
Definition: GNENet.cpp:2777
GNENet::computeDemandElements
void computeDemandElements(GNEApplicationWindow *window)
compute demand elements param[in] window The window to inform about delay
Definition: GNENet.cpp:1538
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:135
DEFAULT_BIKETYPE_ID
const std::string DEFAULT_BIKETYPE_ID
GNEAdditional::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GNENet::getNumberOfAdditionals
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of additionals of the net.
Definition: GNENet.cpp:2210
GNENet::checkJunctionPosition
bool checkJunctionPosition(const Position &pos)
return true if there are already a Junction in the given position, false in other case
Definition: GNENet.cpp:970
GNEJunction::replaceIncomingConnections
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
Definition: GNEJunction.cpp:769
SUMO_ATTR_SHAPE
edge: the shape in xml-definition
Definition: SUMOXMLDefinitions.h:690
GNEChange
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:42
GUIGlObject::getMicrosimID
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.cpp:163
GNENet::myTLSProgramsSaved
bool myTLSProgramsSaved
Flag to check if shapes has to be saved.
Definition: GNENet.h:761
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
ShapeContainer::myPolygons
Polygons myPolygons
stored Polygons
Definition: ShapeContainer.h:199
GNENet::isNetSaved
bool isNetSaved() const
return if net has to be saved
Definition: GNENet.cpp:994
GNENet::cleanUnusedRoutes
void cleanUnusedRoutes(GNEUndoList *undoList)
clean unused routes
Definition: GNENet.cpp:1805
NBEdge::getConnections
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:934
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
NBEdge::getFromNode
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:491
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
WRITE_DEBUG
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:284
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEHierarchicalChildElements::getChildAdditionals
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
Definition: GNEHierarchicalChildElements.cpp:131
GNENet::saveDemandElements
void saveDemandElements(const std::string &filename)
save demand element elements of the network
Definition: GNENet.cpp:2411
GNEShape::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEShape.cpp:123
GUIPolygon
Definition: GUIPolygon.h:41
GNEChange_Attribute.h
GNENet.h
PositionVector::move2side
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Definition: PositionVector.cpp:1103
SUMO_TAG_TRIP
a single trip definition (used by router)
Definition: SUMOXMLDefinitions.h:145
GLO_NETWORK
The network - empty.
Definition: GUIGlObjectTypes.h:41
GNEViewNet::getViewParent
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:1008
GNEShape::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEShape.cpp:138
GNENet::changeEdgeEndpoints
void changeEdgeEndpoints(GNEEdge *edge, const std::string &newSourceID, const std::string &newDestID)
modifies endpoins of the given edge
Definition: GNENet.cpp:2107
GNERouteHandler.h
GNEJunction::removeOutgoingGNEEdge
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
Definition: GNEJunction.cpp:461
SUMO_TAG_JUNCTION
begin/end of the description of a junction
Definition: SUMOXMLDefinitions.h:59
XMLSubSys.h
GNEUndoList.h
GNEChange_Junction.h
GNENet::insertShape
void insertShape(GNEShape *shape, bool updateViewAfterDeleting)
insert shape
Definition: GNENet.cpp:3000
NBEdge::getLaneSpreadFunction
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Definition: NBEdge.h:777
GNEChange_Connection.h
NamedObjectCont::add
bool add(const std::string &id, T item)
Adds an item.
Definition: NamedObjectCont.h:65
GNEEdge::wasSplit
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:886
NBEdge::getID
const std::string & getID() const
Definition: NBEdge.h:1380
GNEConnection.h