Eclipse SUMO - Simulation of Urban MObility
GNENetHelper.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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Helper for GNENet
19 /****************************************************************************/
20 
21 #include <netbuild/NBAlgorithms.h>
22 #include <netbuild/NBNetBuilder.h>
23 #include <netedit/GNENet.h>
24 #include <netedit/GNEUndoList.h>
25 #include <netedit/GNEViewNet.h>
26 #include <netedit/GNEViewParent.h>
39 
40 #include "GNENetHelper.h"
41 
42 // ---------------------------------------------------------------------------
43 // GNENetHelper::AttributeCarriers - methods
44 // ---------------------------------------------------------------------------
45 
47  myNet(net),
48  myAllowUndoShapes(true) {
49  // fill additionals with tags
50  auto additionalTags = GNEAttributeCarrier::getAllowedTagsByCategory(GNETagProperties::TagType::ADDITIONALELEMENT, false);
51  for (const auto& additionalTag : additionalTags) {
52  myAdditionals.insert(std::make_pair(additionalTag.first, std::map<std::string, GNEAdditional*>()));
53  }
54  // fill shapes with tags
55  auto shapeTags = GNEAttributeCarrier::getAllowedTagsByCategory(GNETagProperties::TagType::SHAPE, false);
56  for (const auto& shapeTag : shapeTags) {
57  myShapes.insert(std::make_pair(shapeTag.first, std::map<std::string, GNEShape*>()));
58  }
59  // fill TAZElements with tags
60  auto TAZElementTags = GNEAttributeCarrier::getAllowedTagsByCategory(GNETagProperties::TagType::TAZELEMENT, false);
61  for (const auto& TAZElementTag : TAZElementTags) {
62  myTAZElements.insert(std::make_pair(TAZElementTag.first, std::map<std::string, GNETAZElement*>()));
63  }
64  // fill demand elements with tags
65  auto demandElementTags = GNEAttributeCarrier::getAllowedTagsByCategory(GNETagProperties::TagType::DEMANDELEMENT, false);
66  for (const auto& demandElementTag : demandElementTags) {
67  myDemandElements.insert(std::make_pair(demandElementTag.first, std::map<std::string, GNEDemandElement*>()));
68  }
69  auto stopTags = GNEAttributeCarrier::getAllowedTagsByCategory(GNETagProperties::TagType::STOP, false);
70  for (const auto& stopTag : stopTags) {
71  myDemandElements.insert(std::make_pair(stopTag.first, std::map<std::string, GNEDemandElement*>()));
72  }
73 }
74 
75 
77  // Drop EdgeTypes
78  for (const auto& edgeType : myEdgeTypes) {
79  edgeType.second->decRef("GNENetHelper::~GNENet");
80  // show extra information for tests
81  WRITE_DEBUG("Deleting unreferenced " + edgeType.second->getTagStr() + " '" + edgeType.second->getID() + "' in AttributeCarriers destructor");
82  delete edgeType.second;
83  }
84  // Drop Edges
85  for (const auto& edge : myEdges) {
86  edge.second->decRef("GNENetHelper::~GNENet");
87  // show extra information for tests
88  WRITE_DEBUG("Deleting unreferenced " + edge.second->getTagStr() + " '" + edge.second->getID() + "' in AttributeCarriers destructor");
89  delete edge.second;
90  }
91  // Drop myJunctions
92  for (const auto& junction : myJunctions) {
93  junction.second->decRef("GNENetHelper::~GNENet");
94  // show extra information for tests
95  WRITE_DEBUG("Deleting unreferenced " + junction.second->getTagStr() + " '" + junction.second->getID() + "' in AttributeCarriers destructor");
96  delete junction.second;
97  }
98  // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
99  for (const auto& additionalTag : myAdditionals) {
100  for (const auto& additional : additionalTag.second) {
101  // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
102  additional.second->decRef();
103  // show extra information for tests
104  WRITE_DEBUG("Deleting unreferenced " + additional.second->getTagStr() + " '" + additional.second->getID() + "' in AttributeCarriers destructor");
105  delete additional.second;
106  }
107  }
108  // Drop Shapes (Only used for shapes that were inserted without using GNEChange_Shape)
109  for (const auto& shapeTag : myShapes) {
110  for (const auto& shape : shapeTag.second) {
111  // decrease reference manually (because it was increased manually in GNEShapeHandler)
112  shape.second->decRef();
113  // show extra information for tests
114  WRITE_DEBUG("Deleting unreferenced " + shape.second->getTagStr() + " '" + shape.second->getID() + "' in AttributeCarriers destructor");
115  delete shape.second;
116  }
117  }
118  // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
119  for (const auto& demandElementTag : myDemandElements) {
120  for (const auto& demandElement : demandElementTag.second) {
121  // decrease reference manually (because it was increased manually in GNERouteHandler)
122  demandElement.second->decRef();
123  // show extra information for tests
124  WRITE_DEBUG("Deleting unreferenced " + demandElement.second->getTagStr() + " '" + demandElement.second->getID() + "' in AttributeCarriers destructor");
125  delete demandElement.second;
126  }
127  }
128 }
129 
130 
131 void
133  if (AC->getTagProperty().getTag() == SUMO_TAG_JUNCTION) {
134  updateJunctionID(AC, newID);
135  } else if (AC->getTagProperty().getTag() == SUMO_TAG_EDGE) {
136  updateEdgeID(AC, newID);
137  } else if (AC->getTagProperty().getTag() == SUMO_TAG_TYPE) {
138  updateEdgeTypeID(AC, newID);
139  } else if (AC->getTagProperty().isAdditionalElement()) {
140  updateAdditionalID(AC, newID);
141  } else if (AC->getTagProperty().isShape()) {
142  updateShapeID(AC, newID);
143  } else if (AC->getTagProperty().isTAZElement()) {
144  updateTAZElementID(AC, newID);
145  } else if (AC->getTagProperty().isDemandElement()) {
146  updateDemandElementID(AC, newID);
147  } else if (AC->getTagProperty().isDataElement()) {
148  updateDataSetID(AC, newID);
149  } else {
150  throw ProcessError("Unknow Attribute Carrier");
151  }
152 }
153 
154 
155 void
157  std::map<std::string, GNEEdge*> newEdgeMap;
158  std::map<std::string, GNEJunction*> newJunctionMap;
159  // fill newEdgeMap
160  for (const auto& edge : myEdges) {
161  edge.second->setMicrosimID(edge.second->getNBEdge()->getID());
162  newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
163  }
164  for (const auto& junction : myJunctions) {
165  newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
166  junction.second->setMicrosimID(junction.second->getNBNode()->getID());
167  }
168  myEdges = newEdgeMap;
169  myJunctions = newJunctionMap;
170 }
171 
172 
175  // increase reference
176  junction->incRef("GNENet::registerJunction");
177  junction->setResponsible(false);
178  myJunctions[junction->getMicrosimID()] = junction;
179  // expand net boundary
180  myNet->expandBoundary(junction->getCenteringBoundary());
181  // add edge into grid
182  myNet->addGLObjectIntoGrid(junction);
183  // update geometry
184  junction->updateGeometry();
185  // add z in net boundary
186  myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
187  return junction;
188 }
189 
190 
191 const std::map<std::string, GNEJunction*>&
193  return myJunctions;
194 }
195 
196 
197 void
199  myJunctions.clear();
200 }
201 
202 
205  // increase reference
206  edgeType->incRef("GNENet::registerEdgeType");
207  // add it in container
208  myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
209  return edgeType;
210 }
211 
212 
213 const std::map<std::string, GNEEdgeType*>&
215  return myEdgeTypes;
216 }
217 
218 
220  myEdgeTypes.clear();
221 }
222 
223 
224 GNEEdge*
226  edge->incRef("GNENet::registerEdge");
227  edge->setResponsible(false);
228  // add edge to internal container of GNENet
229  myEdges[edge->getMicrosimID()] = edge;
230  // expand edge boundary
231  myNet->expandBoundary(edge->getCenteringBoundary());
232  // add edge into grid
233  myNet->addGLObjectIntoGrid(edge);
234  // Add references into GNEJunctions
235  edge->getParentJunctions().front()->addOutgoingGNEEdge(edge);
236  edge->getParentJunctions().back()->addIncomingGNEEdge(edge);
237  return edge;
238 }
239 
240 
241 const std::map<std::string, GNEEdge*>&
243  return myEdges;
244 }
245 
246 
248  myEdges.clear();
249 }
250 
251 
252 bool
253 GNENetHelper::AttributeCarriers::addPolygon(const std::string& id, const std::string& type, const RGBColor& color, double layer, double angle,
254  const std::string& imgFile, bool relativePath, const PositionVector& shape, bool geo, bool fill, double lineWidth, bool /*ignorePruning*/) {
255  // check if ID is duplicated
256  if (myShapes.at(SUMO_TAG_POLY).count(id) == 0) {
257  // create poly
258  GNEPoly* poly = new GNEPoly(myNet, id, type, shape, geo, fill, lineWidth, color, layer, angle, imgFile, relativePath, false, false);
259  if (myAllowUndoShapes) {
260  myNet->getViewNet()->getUndoList()->p_begin("add " + toString(SUMO_TAG_POLY));
261  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(poly, true), true);
262  myNet->getViewNet()->getUndoList()->p_end();
263  } else {
264  // insert shape without allowing undo/redo
265  insertShape(poly);
266  poly->incRef("addPolygon");
267  }
268  return true;
269  } else {
270  return false;
271  }
272 }
273 
274 
275 bool
276 GNENetHelper::AttributeCarriers::addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,
277  const std::string& lane, double posOverLane, double posLat, double layer, double angle,
278  const std::string& imgFile, bool relativePath, double width, double height, bool /*ignorePruning*/) {
279  // check if ID is duplicated
280  if (myShapes.at(SUMO_TAG_POI).count(id) == 0) {
281  // create POI or POILane depending of parameter lane
282  if (lane.empty()) {
283  // create POI
284  GNEPOI* POI = new GNEPOI(myNet, id, type, color, pos, geo, layer, angle, imgFile, relativePath, width, height, false);
285  if (myAllowUndoShapes) {
286  myNet->getViewNet()->getUndoList()->p_begin("add " + POI->getTagStr());
287  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(POI, true), true);
288  myNet->getViewNet()->getUndoList()->p_end();
289  } else {
290  // insert shape without allowing undo/redo
291  insertShape(POI);
292  POI->incRef("addPOI");
293  }
294  return true;
295  } else {
296  // create POI over lane
297  GNELane* retrievedLane = myNet->retrieveLane(lane, false);
298  if (retrievedLane == nullptr) {
299  WRITE_ERROR("invalid lane to use within POI " + id);
300  } else {
301  GNEShape* POILane = new GNEPOI(myNet, id, type, color, layer, angle, imgFile, relativePath, retrievedLane, posOverLane, posLat, width, height, false);
302  if (myAllowUndoShapes) {
303  myNet->getViewNet()->getUndoList()->p_begin("add " + POILane->getTagStr());
304  myNet->getViewNet()->getUndoList()->add(new GNEChange_Shape(POILane, true), true);
305  myNet->getViewNet()->getUndoList()->p_end();
306  } else {
307  // insert shape without allowing undo/redo
308  insertShape(POILane);
309  retrievedLane->addChildElement(POILane);
310  POILane->incRef("addPOILane");
311  }
312  }
313  return true;
314  }
315  } else {
316  return false;
317  }
318 }
319 
320 
321 const std::map<SumoXMLTag, std::map<std::string, GNEAdditional*> >&
323  return myAdditionals;
324 }
325 
326 
327 void
329  // clear elements in grid
330  for (const auto& additionalsTags : myAdditionals) {
331  for (const auto& additional : additionalsTags.second) {
332  myNet->removeGLObjectFromGrid(additional.second);
333  }
334  }
335  // iterate over myAdditionals and clear all additionals
336  for (auto& additionals : myAdditionals) {
337  additionals.second.clear();
338  }
339 }
340 
341 
342 const std::map<SumoXMLTag, std::map<std::string, GNEShape*> >&
344  return myShapes;
345 }
346 
347 
348 void
350  // clear elements in grid
351  for (const auto& shapesTags : myShapes) {
352  for (const auto& shape : shapesTags.second) {
353  myNet->removeGLObjectFromGrid(shape.second);
354  }
355  }
356  // iterate over myShapes and clear all shapes
357  for (auto& shapes : myShapes) {
358  shapes.second.clear();
359  }
360 }
361 
362 
363 const std::map<SumoXMLTag, std::map<std::string, GNETAZElement*> >&
365  return myTAZElements;
366 }
367 
368 
369 void
371  // clear elements in grid
372  for (const auto& TAZElementsTags : myTAZElements) {
373  for (const auto& TAZElement : TAZElementsTags.second) {
374  myNet->removeGLObjectFromGrid(TAZElement.second);
375  }
376  }
377  // iterate over myTAZElements and clear all TAZElements
378  for (auto& TAZElements : myTAZElements) {
379  TAZElements.second.clear();
380  }
381 }
382 
383 
384 const std::map<SumoXMLTag, std::map<std::string, GNEDemandElement*> >&
386  return myDemandElements;
387 }
388 
389 
390 void
392  // clear elements in grid
393  for (const auto& demandElementsTags : myDemandElements) {
394  for (const auto& demandElement : demandElementsTags.second) {
395  myNet->removeGLObjectFromGrid(demandElement.second);
396  }
397  }
398  // iterate over myDemandElements and clear all demand elemnts
399  for (auto& demandElements : myDemandElements) {
400  demandElements.second.clear();
401  }
402 }
403 
404 
405 void
407  // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
408  GNEVehicleType* defaultVehicleType = new GNEVehicleType(myNet, DEFAULT_VTYPE_ID, SVC_PASSENGER, SUMO_TAG_VTYPE);
409  myDemandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
410  defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
411 
412  // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
414  myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
415  defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
416 
417  // Create default person Type (it has to be created here due myViewNet was previously nullptr)
419  myDemandElements.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
420  defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
421 }
422 
423 
424 const std::map<std::string, GNEDataSet*>&
426  return myDataSets;
427 }
428 
429 
430 void
432  // clear elements in grid
433  for (const auto& dataSet : myDataSets) {
434  for (const auto& dataInterval : dataSet.second->getDataIntervalChildren()) {
435  for (const auto& genericData : dataInterval.second->getGenericDataChildren()) {
436  myNet->removeGLObjectFromGrid(genericData);
437  }
438  }
439  }
440  // just clear myDataSets
441  myDataSets.clear();
442 }
443 
444 
445 std::vector<GNEGenericData*>
446 GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
447  // declare generic data vector
448  std::vector<GNEGenericData*> genericDatas;
449  // iterate over all data sets
450  for (const auto& dataSet : myDataSets) {
451  for (const auto& interval : dataSet.second->getDataIntervalChildren()) {
452  // check interval
453  if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
454  // iterate over generic datas
455  for (const auto& genericData : interval.second->getGenericDataChildren()) {
456  if (genericData->getTagProperty().getTag() == genericDataTag) {
457  genericDatas.push_back(genericData);
458  }
459  }
460  }
461  }
462  }
463  return genericDatas;
464 }
465 
466 
467 void
469  myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
470  registerJunction(junction);
471 }
472 
473 
474 void
476  // remove it from inspected elements and HierarchicalElementTree
477  myNet->getViewNet()->removeFromAttributeCarrierInspected(junction);
478  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
479  // Remove from grid and container
480  myNet->removeGLObjectFromGrid(junction);
481  myJunctions.erase(junction->getMicrosimID());
482  myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
483  junction->decRef("GNENet::deleteSingleJunction");
484  junction->setResponsible(true);
485 }
486 
487 
488 void
490  if (myJunctions.count(AC->getID()) == 0) {
491  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.junction");
492  } else if (myJunctions.count(newID) != 0) {
493  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in myJunctions");
494  } else {
495  // retrieve junction
496  GNEJunction* junction = myJunctions.at(AC->getID());
497  // remove junction from container
498  myJunctions.erase(junction->getNBNode()->getID());
499  // rename in NetBuilder
500  myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
501  // update microsim ID
502  junction->setMicrosimID(newID);
503  // add it into myJunctions again
504  myJunctions[AC->getID()] = junction;
505  // build crossings
506  junction->getNBNode()->buildCrossings();
507  // net has to be saved
508  myNet->requireSaveNet(true);
509  }
510 }
511 
512 
513 bool
515  return (myEdgeTypes.count(edgeType->getID()) > 0);
516 }
517 
518 
519 void
521  // insert in myEdgeTypes
522  myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
523  // update edge selector
524  if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
525  myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
526  }
527 }
528 
529 
530 void
532  // remove it from inspected elements and HierarchicalElementTree
533  myNet->getViewNet()->removeFromAttributeCarrierInspected(edgeType);
534  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
535  // remove from edge types
536  myEdgeTypes.erase(edgeType->getMicrosimID());
537  // check if this is the selected edge type in edgeSelector
538  if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
539  myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->clearEdgeTypeSelected();
540  myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
541  }
542  // update edge selector
543  if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
544  myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
545  }
546 }
547 
548 
549 void
551  if (myEdgeTypes.count(AC->getID()) == 0) {
552  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.edgeType");
553  } else if (myEdgeTypes.count(newID) != 0) {
554  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
555  } else {
556  // retrieve edgeType
557  GNEEdgeType* edgeType = myEdgeTypes.at(AC->getID());
558  // remove edgeType from container
559  myEdgeTypes.erase(edgeType->getID());
560  // rename in typeCont
561  myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
562  // update microsim ID
563  edgeType->setMicrosimID(newID);
564  // add it into myEdgeTypes again
565  myEdgeTypes[AC->getID()] = edgeType;
566  // net has to be saved
567  myNet->requireSaveNet(true);
568  }
569 }
570 
571 
572 void
574  NBEdge* nbe = edge->getNBEdge();
575  myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
576  // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
577  nbe->getFromNode()->addOutgoingEdge(nbe);
578  nbe->getToNode()->addIncomingEdge(nbe);
579  registerEdge(edge);
580 }
581 
582 
583 void
585  // remove it from inspected elements and HierarchicalElementTree
586  myNet->getViewNet()->removeFromAttributeCarrierInspected(edge);
587  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
588  // remove edge from visual grid and container
589  myNet->removeGLObjectFromGrid(edge);
590  myEdges.erase(edge->getMicrosimID());
591  // extract edge of district container
592  myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
593  edge->decRef("GNENet::deleteSingleEdge");
594  edge->setResponsible(true);
595  // Remove refrences from GNEJunctions
596  edge->getParentJunctions().front()->removeOutgoingGNEEdge(edge);
597  edge->getParentJunctions().back()->removeIncomingGNEEdge(edge);
598 }
599 
600 
601 void
603  if (myEdges.count(AC->getID()) == 0) {
604  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.edge");
605  } else if (myEdges.count(newID) != 0) {
606  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in myEdges");
607  } else {
608  // retrieve edge
609  GNEEdge* edge = myEdges.at(AC->getID());
610  // remove edge from container
611  myEdges.erase(edge->getNBEdge()->getID());
612  // rename in NetBuilder
613  myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
614  // update microsim ID
615  edge->setMicrosimID(newID);
616  // add it into myEdges again
617  myEdges[AC->getID()] = edge;
618  // rename all connections related to this edge
619  for (const auto& lane : edge->getLanes()) {
620  lane->updateConnectionIDs();
621  }
622  // net has to be saved
623  myNet->requireSaveNet(true);
624  }
625 }
626 
627 
628 bool
630  // first check that additional pointer is valid
631  if (additional) {
632  return myAdditionals.at(additional->getTagProperty().getTag()).find(additional->getID()) !=
633  myAdditionals.at(additional->getTagProperty().getTag()).end();
634  } else {
635  throw ProcessError("Invalid additional pointer");
636  }
637 }
638 
639 
640 void
642  // check if additional is a slave
643  if (!additional->getTagProperty().isSlave()) {
644  // check if previously was inserted
645  if (!additionalExist(additional)) {
646  // insert additional
647  myAdditionals.at(additional->getTagProperty().getTag()).insert(std::make_pair(additional->getID(), additional));
648  } else {
649  throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
650  }
651  }
652  // add element in grid
653  if (additional->getTagProperty().isPlacedInRTree()) {
654  myNet->addGLObjectIntoGrid(additional);
655  }
656  // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
657  if (myNet->isUpdateGeometryEnabled()) {
658  additional->updateGeometry();
659  }
660  // additionals has to be saved
661  myNet->requireSaveAdditionals(true);
662 }
663 
664 
665 void
667  // check if additional is a slave
668  if (!additional->getTagProperty().isSlave()) {
669  // check if previously was inserted
670  if (additionalExist(additional)) {
671  // remove it from inspected elements and HierarchicalElementTree
672  myNet->getViewNet()->removeFromAttributeCarrierInspected(additional);
673  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
674  // obtain additional iterator and erase it from container
675  auto it = myAdditionals.at(additional->getTagProperty().getTag()).find(additional->getID());
676  myAdditionals.at(additional->getTagProperty().getTag()).erase(it);
677  } else {
678  throw ProcessError("Invalid additional pointer");
679  }
680  }
681  // remove element from grid
682  if (additional->getTagProperty().isPlacedInRTree()) {
683  myNet->removeGLObjectFromGrid(additional);
684  }
685  // additionals has to be saved
686  myNet->requireSaveAdditionals(true);
687 }
688 
689 
690 void
692  if (myAdditionals.at(AC->getTagProperty().getTag()).count(AC->getID()) == 0) {
693  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.additionals");
694  } else if (myAdditionals.at(AC->getTagProperty().getTag()).count(newID) != 0) {
695  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in AttributeCarriers.additionals");
696  } else {
697  // retrieve additional
698  GNEAdditional* additional = myAdditionals.at(AC->getTagProperty().getTag()).at(AC->getID());
699  // remove additional from container
700  myAdditionals.at(additional->getTagProperty().getTag()).erase(additional->getID());
701  // set new ID in additional
702  additional->setMicrosimID(newID);
703  // insert additional again in container
704  myAdditionals.at(additional->getTagProperty().getTag()).insert(std::make_pair(additional->getID(), additional));
705  // additionals has to be saved
706  myNet->requireSaveAdditionals(true);
707  }
708 }
709 
710 
711 bool
713  // get tag (due POIs)
714  SumoXMLTag shapeTag = (shape->getTagProperty().getTag() == SUMO_TAG_POILANE)? SUMO_TAG_POI : shape->getTagProperty().getTag();
715  // first check that shape pointer is valid
716  if (shape) {
717  return myShapes.at(shapeTag).find(shape->getID()) != myShapes.at(shapeTag).end();
718  } else {
719  throw ProcessError("Invalid shape pointer");
720  }
721 }
722 
723 
724 void
726  // get tag (due POIs)
727  SumoXMLTag shapeTag = (shape->getTagProperty().getTag() == SUMO_TAG_POILANE)? SUMO_TAG_POI : shape->getTagProperty().getTag();
728  // Check if shape element exists before insertion
729  if (!shapeExist(shape)) {
730  myShapes.at(shapeTag).insert(std::make_pair(shape->getID(), shape));
731  // add element in grid
732  myNet->addGLObjectIntoGrid(shape);
733  // update geometry after insertion of shapes if myUpdateGeometryEnabled is enabled
734  if (myNet->isUpdateGeometryEnabled()) {
735  shape->updateGeometry();
736  }
737  // shapes has to be saved
738  myNet->requireSaveAdditionals(true);
739  } else {
740  throw ProcessError(shape->getTagStr() + " with ID='" + shape->getID() + "' already exist");
741  }
742 }
743 
744 
745 void
747  // get tag (due POIs)
748  SumoXMLTag shapeTag = (shape->getTagProperty().getTag() == SUMO_TAG_POILANE)? SUMO_TAG_POI : shape->getTagProperty().getTag();
749  // first check that shape pointer is valid
750  if (shapeExist(shape)) {
751  // remove it from inspected elements and HierarchicalElementTree
752  myNet->getViewNet()->removeFromAttributeCarrierInspected(shape);
753  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(shape);
754  // obtain demand element and erase it from container
755  auto it = myShapes.at(shapeTag).find(shape->getID());
756  myShapes.at(shapeTag).erase(it);
757  // remove element from grid
758  myNet->removeGLObjectFromGrid(shape);
759  // shapes has to be saved
760  myNet->requireSaveAdditionals(true);
761  } else {
762  throw ProcessError("Invalid shape pointer");
763  }
764 }
765 
766 
767 void
769  // get tag (due POIs)
771  // continue
772  if (myShapes.at(shapeTag).count(AC->getID()) == 0) {
773  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.shapes");
774  } else if (myShapes.at(shapeTag).count(newID) != 0) {
775  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in AttributeCarriers.shapes");
776  } else {
777  // retrieve shape
778  GNEShape* shape = myShapes.at(shapeTag).at(AC->getID());
779  // remove shape from container
780  myShapes.at(shapeTag).erase(shape->getID());
781  // set new ID in shape
782  shape->getGUIGlObject()->setMicrosimID(newID);
783  // insert shape again in container
784  myShapes.at(shapeTag).insert(std::make_pair(shape->getID(), shape));
785  // shapes has to be saved
786  myNet->requireSaveAdditionals(true);
787  }
788 }
789 
790 
791 bool
793  // first check that TAZElement pointer is valid
794  if (TAZElement) {
795  return myTAZElements.at(TAZElement->getTagProperty().getTag()).find(TAZElement->getID()) !=
796  myTAZElements.at(TAZElement->getTagProperty().getTag()).end();
797  } else {
798  throw ProcessError("Invalid TAZElement pointer");
799  }
800 }
801 
802 
803 void
805  // Check if TAZElement element exists before insertion
806  if (!TAZElementExist(TAZElement)) {
807  myTAZElements.at(TAZElement->getTagProperty().getTag()).insert(std::make_pair(TAZElement->getID(), TAZElement));
808  // add element in grid
809  myNet->addGLObjectIntoGrid(TAZElement);
810  // update geometry after insertion of TAZElements if myUpdateGeometryEnabled is enabled
811  if (myNet->isUpdateGeometryEnabled()) {
812  TAZElement->updateGeometry();
813  }
814  // TAZElements has to be saved
815  myNet->requireSaveAdditionals(true);
816  } else {
817  throw ProcessError(TAZElement->getTagStr() + " with ID='" + TAZElement->getID() + "' already exist");
818  }
819 }
820 
821 
822 void
824  // first check that TAZElement pointer is valid
825  if (TAZElementExist(TAZElement)) {
826  // remove it from inspected elements and HierarchicalElementTree
827  myNet->getViewNet()->removeFromAttributeCarrierInspected(TAZElement);
828  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(TAZElement);
829  // obtain demand element and erase it from container
830  auto it = myTAZElements.at(TAZElement->getTagProperty().getTag()).find(TAZElement->getID());
831  myTAZElements.at(TAZElement->getTagProperty().getTag()).erase(it);
832  // remove element from grid
833  myNet->removeGLObjectFromGrid(TAZElement);
834  // TAZElements has to be saved
835  myNet->requireSaveAdditionals(true);
836  } else {
837  throw ProcessError("Invalid TAZElement pointer");
838  }
839 }
840 
841 
842 void
844  if (myTAZElements.at(AC->getTagProperty().getTag()).count(AC->getID()) == 0) {
845  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.TAZElements");
846  } else if (myTAZElements.at(AC->getTagProperty().getTag()).count(newID) != 0) {
847  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in AttributeCarriers.TAZElements");
848  } else {
849  // retrieve TAZElement
850  GNETAZElement* TAZElement = myTAZElements.at(AC->getTagProperty().getTag()).at(AC->getID());
851  // remove TAZElement from container
852  myTAZElements.at(TAZElement->getTagProperty().getTag()).erase(TAZElement->getID());
853  // set new ID in TAZElement
854  TAZElement->getGUIGlObject()->setMicrosimID(newID);
855  // insert TAZElement again in container
856  myTAZElements.at(TAZElement->getTagProperty().getTag()).insert(std::make_pair(TAZElement->getID(), TAZElement));
857  // TAZElements has to be saved
858  myNet->requireSaveAdditionals(true);
859  }
860 }
861 
862 
863 bool
865  // first check that demandElement pointer is valid
866  if (demandElement) {
867  return myDemandElements.at(demandElement->getTagProperty().getTag()).find(demandElement->getID()) !=
868  myDemandElements.at(demandElement->getTagProperty().getTag()).end();
869  } else {
870  throw ProcessError("Invalid demandElement pointer");
871  }
872 }
873 
874 
875 void
877  // check if demandElement is a slave
878  if (!demandElement->getTagProperty().isSlave()) {
879  // Check if demandElement element exists before insertion
880  if (!demandElementExist(demandElement)) {
881  // insert in demandElements container
882  myDemandElements.at(demandElement->getTagProperty().getTag()).insert(std::make_pair(demandElement->getID(), demandElement));
883  } else {
884  throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
885  }
886  }
887  // add element in grid
888  myNet->addGLObjectIntoGrid(demandElement);
889  // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
890  if (myNet->isUpdateGeometryEnabled()) {
891  demandElement->updateGeometry();
892  }
893  // demandElements has to be saved
894  myNet->requireSaveDemandElements(true);
895 
896 }
897 
898 
899 void
901  // check if demandElement is a slave
902  if (!demandElement->getTagProperty().isSlave()) {
903  // first check that demandElement pointer is valid
904  if (demandElementExist(demandElement)) {
905  // remove it from inspected elements and HierarchicalElementTree
906  myNet->getViewNet()->removeFromAttributeCarrierInspected(demandElement);
907  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
908  // obtain demand element and erase it from container
909  auto it = myDemandElements.at(demandElement->getTagProperty().getTag()).find(demandElement->getID());
910  myDemandElements.at(demandElement->getTagProperty().getTag()).erase(it);
911  } else {
912  throw ProcessError("Invalid demandElement pointer");
913  }
914  }
915  // remove element from grid
916  myNet->removeGLObjectFromGrid(demandElement);
917  // demandElements has to be saved
918  myNet->requireSaveDemandElements(true);
919 }
920 
921 
922 void
924  if (myDemandElements.at(AC->getTagProperty().getTag()).count(AC->getID()) == 0) {
925  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.myDemandElements");
926  } else if (myDemandElements.at(AC->getTagProperty().getTag()).count(newID) != 0) {
927  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in AttributeCarriers.myDemandElements");
928  } else {
929  // retrieve demand element
930  GNEDemandElement* demandElement = myDemandElements.at(AC->getTagProperty().getTag()).at(AC->getID());
931  // get embebbed route
932  GNEDemandElement* embebbedRoute = nullptr;
933  if (demandElement->getTagProperty().embebbedRoute()) {
934  embebbedRoute = demandElement->getChildDemandElements().back();
935  }
936  // remove demand element from container
937  myDemandElements.at(demandElement->getTagProperty().getTag()).erase(demandElement->getID());
938  // remove embebbed route from container
939  if (embebbedRoute) {
940  myDemandElements.at(GNE_TAG_ROUTE_EMBEDDED).erase(embebbedRoute->getID());
941  }
942  // set new ID in demand
943  demandElement->setMicrosimID(newID);
944  // insert demand again in container
945  myDemandElements.at(demandElement->getTagProperty().getTag()).insert(std::make_pair(demandElement->getID(), demandElement));
946  // insert emebbed route again in container
947  if (embebbedRoute) {
948  // set new microsim ID
949  embebbedRoute->setMicrosimID(embebbedRoute->getID());
950  myDemandElements.at(GNE_TAG_ROUTE_EMBEDDED).insert(std::make_pair(embebbedRoute->getID(), embebbedRoute));
951  }
952  // myDemandElements has to be saved
953  myNet->requireSaveDemandElements(true);
954  }
955 }
956 
957 
958 bool
960  // first check that dataSet pointer is valid
961  if (dataSet) {
962  for (const auto& dataset : myDataSets) {
963  if (dataset.second == dataSet) {
964  return true;
965  }
966  }
967  return false;
968  } else {
969  throw ProcessError("Invalid dataSet pointer");
970  }
971 }
972 
973 
974 void
976  // Check if dataSet element exists before insertion
977  if (!dataSetExist(dataSet)) {
978  // insert in dataSets container
979  myDataSets.insert(std::make_pair(dataSet->getID(), dataSet));
980  // dataSets has to be saved
981  myNet->requireSaveDataElements(true);
982  // update interval toolbar
983  myNet->getViewNet()->getIntervalBar().updateIntervalBar();
984  } else {
985  throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
986  }
987 }
988 
989 
990 void
992  // first check that dataSet pointer is valid
993  if (dataSetExist(dataSet)) {
994  // remove it from inspected elements and HierarchicalElementTree
995  myNet->getViewNet()->removeFromAttributeCarrierInspected(dataSet);
996  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
997  // obtain demand element and erase it from container
998  myDataSets.erase(myDataSets.find(dataSet->getID()));
999  // dataSets has to be saved
1000  myNet->requireSaveDataElements(true);
1001  // update interval toolbar
1002  myNet->getViewNet()->getIntervalBar().updateIntervalBar();
1003  } else {
1004  throw ProcessError("Invalid dataSet pointer");
1005  }
1006 }
1007 
1008 
1009 void
1011  if (myDataSets.count(AC->getID()) == 0) {
1012  throw ProcessError(AC->getTagStr() + " with ID='" + AC->getID() + "' doesn't exist in AttributeCarriers.dataSets");
1013  } else if (myDataSets.count(newID) != 0) {
1014  throw ProcessError("There is another " + AC->getTagStr() + " with new ID='" + newID + "' in dataSets");
1015  } else {
1016  // retrieve dataSet
1017  GNEDataSet* dataSet = myDataSets.at(AC->getID());
1018  // remove dataSet from container
1019  myDataSets.erase(dataSet->getID());
1020  // set new ID in dataSet
1021  dataSet->setDataSetID(newID);
1022  // insert dataSet again in container
1023  myDataSets[dataSet->getID()] = dataSet;
1024  // data sets has to be saved
1025  myNet->requireSaveDataElements(true);
1026  // update interval toolbar
1027  myNet->getViewNet()->getIntervalBar().updateIntervalBar();
1028  }
1029 }
1030 
1031 // ---------------------------------------------------------------------------
1032 // GNENetHelper::PathCalculator - methods
1033 // ---------------------------------------------------------------------------
1034 
1036  myNet(net),
1037  myDijkstraRouter(nullptr) {
1038  // create myDijkstraRouter
1041  true, &NBRouterEdge::getTravelTimeStatic, nullptr, true);
1042 }
1043 
1044 
1046  delete myDijkstraRouter;
1047 }
1048 
1049 
1050 void
1052  // simply delete and create myDijkstraRouter again
1053  if (myDijkstraRouter) {
1054  delete myDijkstraRouter;
1055  }
1056  myDijkstraRouter = new DijkstraRouter<NBRouterEdge, NBVehicle>(
1057  myNet->getNetBuilder()->getEdgeCont().getAllRouterEdges(),
1058  true, &NBRouterEdge::getTravelTimeStatic, nullptr, true);
1059 }
1060 
1061 
1062 std::vector<GNEEdge*>
1063 GNENetHelper::PathCalculator::calculatePath(const SUMOVehicleClass vClass, const std::vector<GNEEdge*>& partialEdges) const {
1064  // declare a solution vector
1065  std::vector<GNEEdge*> solution;
1066  // calculate route depending of number of partial myEdges
1067  if (partialEdges.size() == 0) {
1068  // partial edges empty, then return a empty vector
1069  return solution;
1070  }
1071  if (partialEdges.size() == 1) {
1072  // if there is only one partialEdges, route has only one edge
1073  solution.push_back(partialEdges.front());
1074  } else {
1075  // declare temporal vehicle
1076  NBVehicle tmpVehicle("temporalNBVehicle", vClass);
1077  // obtain pointer to GNENet
1078  GNENet* net = partialEdges.front()->getNet();
1079  // iterate over every selected myEdges
1080  for (int i = 1; i < (int)partialEdges.size(); i++) {
1081  // declare a temporal route in which save route between two last myEdges
1082  std::vector<const NBRouterEdge*> partialRoute;
1083  myDijkstraRouter->compute(partialEdges.at(i - 1)->getNBEdge(), partialEdges.at(i)->getNBEdge(), &tmpVehicle, 10, partialRoute);
1084  // save partial route in solution
1085  for (const auto& edgeID : partialRoute) {
1086  solution.push_back(net->retrieveEdge(edgeID->getID()));
1087  }
1088  }
1089  }
1090  // filter solution
1091  auto solutionIt = solution.begin();
1092  // iterate over solution
1093  while (solutionIt != solution.end()) {
1094  if ((solutionIt + 1) != solution.end()) {
1095  // if next edge is the same of current edge, remove it
1096  if (*solutionIt == *(solutionIt + 1)) {
1097  solutionIt = solution.erase(solutionIt);
1098  } else {
1099  solutionIt++;
1100  }
1101  } else {
1102  solutionIt++;
1103  }
1104  }
1105  return solution;
1106 }
1107 
1108 
1109 void
1111  // first reset reachability of all lanes
1112  for (const auto& edge : originEdge->getNet()->getAttributeCarriers()->getEdges()) {
1113  for (const auto& lane : edge.second->getLanes()) {
1114  lane->resetReachability();
1115  }
1116  }
1117  // get max speed
1118  const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(vClass).maxSpeed;
1119  // declare map for reachable edges
1120  std::map<GNEEdge*, double> reachableEdges;
1121  // init first edge
1122  reachableEdges[originEdge] = 0;
1123  // declare a vector for checked edges
1124  std::vector<GNEEdge*> check;
1125  // add first edge
1126  check.push_back(originEdge);
1127  // continue while there is edges to check
1128  while (check.size() > 0) {
1129  GNEEdge* edge = check.front();
1130  check.erase(check.begin());
1131  double traveltime = reachableEdges[edge];
1132  for (const auto& lane : edge->getLanes()) {
1133  if ((edge->getNBEdge()->getLaneStruct(lane->getIndex()).permissions & vClass) == vClass) {
1134  lane->setReachability(traveltime);
1135  }
1136  }
1137  // update traveltime
1138  traveltime += edge->getNBEdge()->getLength() / MIN2(edge->getNBEdge()->getSpeed(), defaultMaxSpeed);
1139  std::vector<GNEEdge*> sucessors;
1140  // get sucessor edges
1141  for (const auto& sucessorEdge : edge->getParentJunctions().back()->getGNEOutgoingEdges()) {
1142  // check if edge is connected with sucessor edge
1143  if (consecutiveEdgesConnected(vClass, edge, sucessorEdge)) {
1144  sucessors.push_back(sucessorEdge);
1145  }
1146  }
1147  // add sucessors to check vector
1148  for (const auto& nextEdge : sucessors) {
1149  // revisit edge via faster path
1150  if ((reachableEdges.count(nextEdge) == 0) || (reachableEdges[nextEdge] > traveltime)) {
1151  reachableEdges[nextEdge] = traveltime;
1152  check.push_back(nextEdge);
1153  }
1154  }
1155  }
1156 }
1157 
1158 
1159 bool
1161  // check conditions
1162  if ((from == nullptr) || (to == nullptr)) {
1163  // myEdges cannot be null
1164  return false;
1165  } else if (from == to) {
1166  // the same edge cannot be consecutive of itself
1167  return false;
1168  } else if (vClass == SVC_PEDESTRIAN) {
1169  // for pedestrians consecutive myEdges are always connected
1170  return true;
1171  } else {
1172  // iterate over connections of from edge
1173  for (const auto& fromLane : from->getLanes()) {
1174  for (const auto& fromConnection : from->getGNEConnections()) {
1175  // within from loop, iterate ove to lanes
1176  for (const auto& toLane : to->getLanes()) {
1177  if (fromConnection->getLaneTo() == toLane) {
1178  // get lane structs for both lanes
1179  const NBEdge::Lane NBFromLane = from->getNBEdge()->getLaneStruct(fromLane->getIndex());
1180  const NBEdge::Lane NBToLane = to->getNBEdge()->getLaneStruct(toLane->getIndex());
1181  // check vClass
1182  if (((NBFromLane.permissions & vClass) == vClass) &&
1183  ((NBToLane.permissions & vClass) == vClass)) {
1184  return true;
1185  }
1186  }
1187  }
1188  }
1189  }
1190  return false;
1191  }
1192 }
1193 
1194 
1195 bool
1197  if (busStop->getTagProperty().getTag() != SUMO_TAG_BUS_STOP) {
1198  return false;
1199  }
1200  // check if busstop is placed over a pedestrian lane
1201  if ((busStop->getParentLanes().front()->getParentEdge() == edge) &&
1202  (edge->getNBEdge()->getLaneStruct(busStop->getParentLanes().front()->getIndex()).permissions & SVC_PEDESTRIAN) != 0) {
1203  // busStop is placed over an lane that supports pedestrians, then return true
1204  return true;
1205  }
1206  // obtain a list with all edge lanes that supports pedestrians
1207  std::vector<GNELane*> pedestrianLanes;
1208  for (int laneIndex = 0; laneIndex < (int)edge->getLanes().size(); laneIndex++) {
1209  if ((edge->getNBEdge()->getLaneStruct(laneIndex).permissions & SVC_PEDESTRIAN) != 0) {
1210  pedestrianLanes.push_back(edge->getLanes().at(laneIndex));
1211  }
1212  }
1213  // check if exist an access between busStop and pedestrian lanes
1214  for (const auto& access : busStop->getChildAdditionals()) {
1215  // check that child is an access
1216  if (access->getTagProperty().getTag() == SUMO_TAG_ACCESS) {
1217  for (const auto& lane : pedestrianLanes) {
1218  if (access->getParentLanes().front() == lane) {
1219  // found, then return true
1220  return true;
1221  }
1222  }
1223  }
1224  }
1225  // There isn't a valid access, then return false
1226  return false;
1227 }
1228 
1229 // ---------------------------------------------------------------------------
1230 // GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
1231 // ---------------------------------------------------------------------------
1232 
1234  GNEChange(true, false),
1235  myTllcont(tllcont),
1236  myReplaced(replaced),
1237  myBy(by) {
1238 }
1239 
1240 
1242 
1243 
1244 FXString
1246  return "Redo replace in TLS";
1247 }
1248 
1249 
1250 FXString
1252  return "Undo replace in TLS";
1253 }
1254 
1255 
1256 void
1258  // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
1259  myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
1260 }
1261 
1262 
1263 void
1265  // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
1266  myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
1267 }
1268 
1269 
1270 bool
1272  return myReplaced != myBy;
1273 }
1274 
1275 /****************************************************************************/
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
const std::string DEFAULT_BIKETYPE_ID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VTYPE
description of a vehicle type
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_POILANE
begin/end of the description of a Point of interest over Lane (used by Netedit)
@ SUMO_TAG_TYPE
type (edge)
@ SUMO_TAG_PTYPE
description of a person type (used in NETEDIT)
@ GNE_TAG_ROUTE_EMBEDDED
embedded route (used in NETEDIT)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
T MIN2(T a, T b)
Definition: StdDefs.h:73
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
Computes the shortest path through a network using the Dijkstra algorithm.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
const std::string & getID() const
get ID
virtual void updateGeometry()=0
update pre-computed geometry information
virtual const std::string & getID() const =0
return ID of object
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get Tag Property assigned to this object
static std::vector< std::pair< SumoXMLTag, const std::string > > getAllowedTagsByCategory(const int tagPropertyCategory, const bool onlyDrawables)
get tags of all editable element types using TagProperty Type (NetworkEditMode::NETWORKELEMENT,...
GNENet * getNet() const
get pointer to net
void setReachability(const double reachability)
set current reachability (traveltime)
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:65
const std::string & getID() const
get ID
Definition: GNEDataSet.cpp:119
void setDataSetID(const std::string &newID)
set new ID in dataSet
Definition: GNEDataSet.cpp:131
An Element which don't belongs to GNENet but has influency in the simulation.
virtual void updateGeometry()=0
update pre-computed geometry information
const std::string & getID() const
get ID
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:1030
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:399
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:723
const std::vector< GNEConnection * > & getGNEConnections() const
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:729
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1703
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
void addChildElement(T *element)
add child element
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
void updateGeometry()
update pre-computed geometry information (including crossings)
Definition: GNEJunction.cpp:92
NBNode * getNBNode() const
Return net build node.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
const std::map< std::string, GNEDataSet * > & getDataSets() const
void deleteDataSet(GNEDataSet *dataSet)
delete demand element element of GNENet container
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.
GNEEdgeType * registerEdgeType(GNEEdgeType *edgeType)
void insertDataSet(GNEDataSet *dataSet)
Insert a demand element element int GNENet container.
void clearDemandElements()
clear demand elements
GNEEdge * registerEdge(GNEEdge *edge)
void updateEdgeTypeID(GNEAttributeCarrier *AC, const std::string &newID)
update edgeType ID in container
void updateDataSetID(GNEAttributeCarrier *AC, const std::string &newID)
update data element ID in container
void deleteShape(GNEShape *shape)
delete shape element of GNENet container
void remapJunctionAndEdgeIds()
remap junction and edge IDs
void clearEdgeTypes()
clear edgeTypes
std::map< SumoXMLTag, std::map< std::string, GNEAdditional * > > myAdditionals
map with the ID and pointer to additional elements of net
Definition: GNENetHelper.h:403
void deleteDemandElement(GNEDemandElement *demandElement)
delete demand element element of GNENet container
void deleteEdgeType(GNEEdgeType *edgeType)
deletes edgeType
void clearAdditionals()
clear additionals
std::vector< GNEGenericData * > retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end)
bool demandElementExist(const GNEDemandElement *demandElement) const
return true if given demand element exist
void updateEdgeID(GNEAttributeCarrier *AC, const std::string &newID)
update edge ID in container
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
void insertShape(GNEShape *shape)
Insert a shape element int GNENet container.
GNEJunction * registerJunction(GNEJunction *junction)
bool dataSetExist(const GNEDataSet *dataSet) const
return true if given demand element exist
void updateDemandElementID(GNEAttributeCarrier *AC, const std::string &newID)
update demand element ID in container
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
void deleteTAZElement(GNETAZElement *TAZElement)
delete TAZElement element of GNENet container
const std::map< SumoXMLTag, std::map< std::string, GNETAZElement * > > & getTAZElements() const
void addDefaultVTypes()
add default VTypes
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
void deleteAdditional(GNEAdditional *additional)
delete additional element of GNENet container
std::map< SumoXMLTag, std::map< std::string, GNEShape * > > myShapes
map with the ID and pointer to shape elements of net
Definition: GNENetHelper.h:406
void updateID(GNEAttributeCarrier *AC, const std::string newID)
update ID
void insertEdge(GNEEdge *edge)
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element element int GNENet container.
void clearTAZElements()
clear TAZElements
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.
std::map< SumoXMLTag, std::map< std::string, GNETAZElement * > > myTAZElements
map with the ID and pointer to TAZElement elements of net
Definition: GNENetHelper.h:409
const std::map< SumoXMLTag, std::map< std::string, GNEAdditional * > > & getAdditionals() const
bool additionalExist(const GNEAdditional *additional) const
return true if given additional exist
bool shapeExist(const GNEShape *shape) const
return true if given shape exist
void insertTAZElement(GNETAZElement *TAZElement)
Insert a TAZElement element int GNENet container.
void insertAdditional(GNEAdditional *additional)
Insert a additional element int GNENet container.
void updateAdditionalID(GNEAttributeCarrier *AC, const std::string &newID)
update additional ID in container
void insertEdgeType(GNEEdgeType *edgeType)
inserts a single edgeType into the net and into the underlying netbuild-container
void clearDataSets()
clear demand elements
void insertJunction(GNEJunction *junction)
std::map< SumoXMLTag, std::map< std::string, GNEDemandElement * > > myDemandElements
map with the ID and pointer to demand elements of net
Definition: GNENetHelper.h:412
const std::map< SumoXMLTag, std::map< std::string, GNEDemandElement * > > & getDemandElements() const
const std::map< std::string, GNEJunction * > & getJunctions() const
map with the ID and pointer to junctions of net
const std::map< std::string, GNEEdgeType * > & getEdgeTypes() const
map with the ID and pointer to edgeTypes of net
bool TAZElementExist(const GNETAZElement *TAZElement) const
return true if given TAZElement exist
void clearJunctions()
clear junctions
void updateJunctionID(GNEAttributeCarrier *AC, const std::string &newID)
update junction ID in container
bool edgeTypeExist(const GNEEdgeType *edgeType) const
AttributeCarriers(GNENet *net)
constructor
const std::map< SumoXMLTag, std::map< std::string, GNEShape * > > & getShapes() const
void updateShapeID(GNEAttributeCarrier *AC, const std::string &newID)
update shape ID in container
void updateTAZElementID(GNEAttributeCarrier *AC, const std::string &newID)
update TAZElement ID in container
FXString redoName() const
get Redo name
GNEChange_ReplaceEdgeInTLS(NBTrafficLightLogicCont &tllcont, NBEdge *replaced, NBEdge *by)
constructor
bool trueChange()
wether original and new value differ
bool busStopConnected(const GNEAdditional *busStop, const GNEEdge *edge) const
check if exist a path between the given busStop and edge (Either a valid lane or an acces) for pedest...
void updatePathCalculator()
update path calculator (called when SuperModes Demand or Data is selected)
void calculateReachability(const SUMOVehicleClass vClass, GNEEdge *originEdge)
calculate reachability for given edge
PathCalculator(const GNENet *net)
constructor
SUMOAbstractRouter< NBRouterEdge, NBVehicle > * myDijkstraRouter
SUMO Abstract myDijkstraRouter.
Definition: GNENetHelper.h:460
std::vector< GNEEdge * > calculatePath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra path between a list of partial edges
const GNENet * myNet
pointer to net
Definition: GNENetHelper.h:457
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutives edges for the given VClass
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1738
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true) const
get edge by id
Definition: GNENet.cpp:1141
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
retrieve all attribute carriers of Net
Definition: GNENet.cpp:130
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string & getID() const
get ID
Definition: GNEPOI.h:41
void decRef(const std::string &debugMsg="")
Decrease reference.
void incRef(const std::string &debugMsg="")
Increarse reference.
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
Definition: GNEShape.cpp:59
const std::string & getID() const
get ID (all shapes have one)
Definition: GNEShape.cpp:53
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
const std::string & getID() const
get ID
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
bool isShape() const
return true if tag correspond to a shape
bool isTAZElement() const
return true if tag correspond to a TAZ element
bool isSlave() const
return true if tag correspond to an element slave of another element (I.e. doesn't have their own ID)
bool embebbedRoute() const
return true if tag correspond to an element that owns a embebbed route
bool isDataElement() const
return true if tag correspond to a data element
bool isPlacedInRTree() const
return true if Tag correspond to an element that has has to be placed in RTREE
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool isDemandElement() const
return true if tag correspond to a demand element
bool isAdditionalElement() const
return true if tag correspond to an additional element
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
RouterEdgeVector getAllRouterEdges() const
The representation of a single edge during network building.
Definition: NBEdge.h:91
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:563
const std::string & getID() const
Definition: NBEdge.h:1423
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:516
double getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:589
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1326
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:509
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:148
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition: NBNode.cpp:458
int buildCrossings()
build pedestrian crossings
Definition: NBNode.cpp:2642
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition: NBNode.cpp:468
const Position & getPosition() const
Definition: NBNode.h:246
static double getTravelTimeStatic(const NBRouterEdge *const edge, const NBVehicle *const, double)
Definition: NBEdge.h:81
A container for traffic light definitions and built programs.
A vehicle as used by router.
Definition: NBVehicle.h:42
const std::string & getID() const
Returns the id.
Definition: Named.h:73
C++ TraCI client API implementation.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
double z() const
Returns the z-position.
Definition: Position.h:64
A list of positions.
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:142
SVCPermissions permissions
List of vehicle types that are allowed on this lane.
Definition: NBEdge.h:153
struct for default values that depend of VClass
double maxSpeed
The vehicle type's maximum speed [m/s].