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-2022 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/GNEViewNet.h>
25 #include <netedit/GNEViewParent.h>
40 
41 #include "GNENetHelper.h"
42 
43 // ---------------------------------------------------------------------------
44 // GNENetHelper::AttributeCarriers - methods
45 // ---------------------------------------------------------------------------
46 
48  myNet(net) {
49  // fill additionals with tags
50  auto additionalTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::ADDITIONALELEMENT | GNETagProperties::TagType::SYMBOL);
51  for (const auto& additionalTag : additionalTags) {
52  myAdditionals.insert(std::make_pair(additionalTag.getTag(), std::set<GNEAdditional*>()));
53  }
54  // fill shapes with tags
55  auto shapeTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::SHAPE);
56  for (const auto& shapeTag : shapeTags) {
57  myShapes.insert(std::make_pair(shapeTag.getTag(), std::set<GNEShape*>()));
58  }
59  // fill TAZElements with tags
60  auto TAZElementTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::TAZELEMENT);
61  for (const auto& TAZElementTag : TAZElementTags) {
62  myTAZElements.insert(std::make_pair(TAZElementTag.getTag(), std::set<GNETAZElement*>()));
63  }
64  // fill demand elements with tags
65  auto demandElementTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::DEMANDELEMENT);
66  for (const auto& demandElementTag : demandElementTags) {
67  myDemandElements.insert(std::make_pair(demandElementTag.getTag(), std::set<GNEDemandElement*>()));
68  }
69  auto stopTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::STOP);
70  for (const auto& stopTag : stopTags) {
71  myDemandElements.insert(std::make_pair(stopTag.getTag(), std::set<GNEDemandElement*>()));
72  }
73  // fill data elements with tags
74  auto genericDataElementTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::GENERICDATA);
75  for (const auto& genericDataElementTag : genericDataElementTags) {
76  myGenericDatas.insert(std::make_pair(genericDataElementTag.getTag(), std::set<GNEGenericData*>()));
77  }
78 }
79 
80 
82  // Drop EdgeTypes
83  for (const auto& edgeType : myEdgeTypes) {
84  edgeType.second->decRef("GNENetHelper::~GNENet");
85  // show extra information for tests
86  WRITE_DEBUG("Deleting unreferenced " + edgeType.second->getTagStr() + " '" + edgeType.second->getID() + "' in AttributeCarriers destructor");
87  delete edgeType.second;
88  }
89  // Drop Edges
90  for (const auto& edge : myEdges) {
91  edge.second->decRef("GNENetHelper::~GNENet");
92  // show extra information for tests
93  WRITE_DEBUG("Deleting unreferenced " + edge.second->getTagStr() + " '" + edge.second->getID() + "' in AttributeCarriers destructor");
94  delete edge.second;
95  }
96  // Drop myJunctions
97  for (const auto& junction : myJunctions) {
98  junction.second->decRef("GNENetHelper::~GNENet");
99  // show extra information for tests
100  WRITE_DEBUG("Deleting unreferenced " + junction.second->getTagStr() + " '" + junction.second->getID() + "' in AttributeCarriers destructor");
101  delete junction.second;
102  }
103  // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
104  for (const auto& additionalTag : myAdditionals) {
105  for (const auto& additional : additionalTag.second) {
106  // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
107  additional->decRef();
108  // show extra information for tests
109  WRITE_DEBUG("Deleting unreferenced " + additional->getTagStr() + " in AttributeCarriers destructor");
110  delete additional;
111  }
112  }
113  // Drop Shapes (Only used for shapes that were inserted without using GNEChange_Shape)
114  for (const auto& shapeTag : myShapes) {
115  for (const auto& shape : shapeTag.second) {
116  // decrease reference manually (because it was increased manually in GNEShapeHandler)
117  shape->decRef();
118  // show extra information for tests
119  WRITE_DEBUG("Deleting unreferenced " + shape->getTagStr() + " in AttributeCarriers destructor");
120  delete shape;
121  }
122  }
123  // Drop TAZElements (Only used for TAZElements that were inserted without using GNEChange_TAZElement)
124  for (const auto& TAZElementTag : myTAZElements) {
125  for (const auto& TAZElement : TAZElementTag.second) {
126  // decrease reference manually (because it was increased manually in GNETAZElementHandler)
127  TAZElement->decRef();
128  // show extra information for tests
129  WRITE_DEBUG("Deleting unreferenced " + TAZElement->getTagStr() + " in AttributeCarriers destructor");
130  delete TAZElement;
131  }
132  }
133  // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
134  for (const auto& demandElementTag : myDemandElements) {
135  for (const auto& demandElement : demandElementTag.second) {
136  // decrease reference manually (because it was increased manually in GNERouteHandler)
137  demandElement->decRef();
138  // show extra information for tests (except for default IDs)
139  if (DEFAULT_VTYPES.count(demandElement->getID()) == 0) {
140  WRITE_DEBUG("Deleting unreferenced " + demandElement->getTagStr() + " in AttributeCarriers destructor");
141  }
142  delete demandElement;
143  }
144  }
145  // Drop dataSets (Only used for TAZElements that were inserted without using GNEChange_DataSets)
146  for (const auto& dataSet : myDataSets) {
147  // decrease reference manually (because it was increased manually in GNEDataHandler)
148  dataSet->decRef();
149  // show extra information for tests
150  WRITE_DEBUG("Deleting unreferenced " + dataSet->getTagStr() + " in AttributeCarriers destructor");
151  delete dataSet;
152  }
153 }
154 
155 
156 void
158  std::map<std::string, GNEEdge*> newEdgeMap;
159  std::map<std::string, GNEJunction*> newJunctionMap;
160  // fill newEdgeMap
161  for (const auto& edge : myEdges) {
162  edge.second->setMicrosimID(edge.second->getNBEdge()->getID());
163  newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
164  }
165  for (const auto& junction : myJunctions) {
166  newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
167  junction.second->setMicrosimID(junction.second->getNBNode()->getID());
168  }
169  myEdges = newEdgeMap;
170  myJunctions = newJunctionMap;
171 }
172 
173 
174 bool
176  // check what tipe of AC
177  if (AC->getTagProperty().getTag() == SUMO_TAG_JUNCTION) {
178  // Junction
179  const GNEJunction* junction = myJunctions.at(AC->getID());
180  if (junction->getNBNode()->getShape().size() == 0) {
181  return shape.around(junction->getNBNode()->getCenter());
182  } else {
183  return (shape.overlapsWith(junction->getNBNode()->getShape()));
184  }
185  } else if (AC->getTagProperty().getTag() == SUMO_TAG_EDGE) {
186  // Edge
187  for (const auto& lane : myEdges.at(AC->getID())->getLanes()) {
188  if (shape.overlapsWith(lane->getLaneShape())) {
189  return true;
190  }
191  }
192  return false;
193  } else if (AC->getTagProperty().getTag() == SUMO_TAG_LANE) {
194  // Lane
195  return shape.overlapsWith(retrieveLane(AC->getID())->getLaneShape());
196  } else if (AC->getTagProperty().getTag() == SUMO_TAG_CONNECTION) {
197  // connection
198  return shape.overlapsWith(dynamic_cast<GNEConnection*>(AC)->getConnectionShape());
199  } else if (AC->getTagProperty().getTag() == SUMO_TAG_CROSSING) {
200  // crossing
201  return shape.overlapsWith(dynamic_cast<GNECrossing*>(AC)->getCrossingShape());
202  } else if (AC->getTagProperty().isAdditionalElement()) {
203  // Additional
204  const GNEAdditional* additional = retrieveAdditional(AC);
205  if (additional->getAdditionalGeometry().getShape().size() <= 1) {
206  return shape.around(additional->getPositionInView());
207  } else {
208  return shape.overlapsWith(additional->getAdditionalGeometry().getShape());
209  }
210  } else if (AC->getTagProperty().isShape()) {
211  // shapes (Polys and POIs)
212  if (AC->getTagProperty().getTag() == SUMO_TAG_POLY) {
213  // Polygon
214  return shape.overlapsWith(dynamic_cast<GNEPoly*>(AC)->getShape());
215  } else {
216  // POI
217  return shape.around(dynamic_cast<GNEPOI*>(AC)->getPositionInView());
218  }
219  } else if (AC->getTagProperty().getTag() == SUMO_TAG_TAZ) {
220  // TAZ
221  return shape.overlapsWith(dynamic_cast<GNETAZ*>(AC)->getTAZElementShape());
222  } else {
223  return false;
224  }
225 }
226 
227 
230  // obtain blocked GUIGlObject
232  // Make sure that object exists
233  if (object != nullptr) {
234  // unblock and try to parse to AtributeCarrier
236  GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
237  // If was sucesfully parsed, return it
238  if (ac == nullptr) {
239  throw ProcessError("GUIGlObject does not match the declared type");
240  } else {
241  return ac;
242  }
243  } else if (hardFail) {
244  throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
245  } else {
246  return nullptr;
247  }
248 }
249 
250 
251 std::vector<GNEAttributeCarrier*>
253  std::vector<GNEAttributeCarrier*> result;
254  if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_JUNCTION)) {
255  for (const auto& junction : myJunctions) {
256  result.push_back(junction.second);
257  }
258  } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_EDGE)) {
259  for (const auto& edge : myEdges) {
260  result.push_back(edge.second);
261  }
262  } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_LANE)) {
263  for (const auto& lane : myLanes) {
264  result.push_back(lane);
265  }
266  } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CONNECTION)) {
267  for (const auto& connection : myConnections) {
268  result.push_back(connection);
269  }
270  } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CROSSING)) {
271  for (const auto& crossing : myCrossings) {
272  result.push_back(crossing);
273  }
274  } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isAdditionalElement())) {
275  for (const auto& additional : myAdditionals.at(tag)) {
276  result.push_back(additional);
277  }
278  } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isShape())) {
279  for (const auto& shape : myShapes.at(tag)) {
280  result.push_back(shape);
281  }
282  } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isTAZElement())) {
283  for (const auto& TAZElement : myTAZElements.at(tag)) {
284  result.push_back(TAZElement);
285  }
286  } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isDemandElement())) {
287  for (const auto& demandElemet : myDemandElements.at(tag)) {
288  result.push_back(demandElemet);
289  }
290  } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATASET)) {
291  for (const auto& dataSet : myDataSets) {
292  result.push_back(dataSet);
293  }
294  } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATAINTERVAL)) {
295  for (const auto& dataInterval : myDataIntervals) {
296  result.push_back(dataInterval);
297  }
298  } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isGenericData())) {
299  for (const auto& genericData : myGenericDatas.at(tag)) {
300  result.push_back(genericData);
301  }
302  }
303  return result;
304 }
305 
306 
307 std::vector<GNEAttributeCarrier*>
309  std::vector<GNEAttributeCarrier*> result;
310  // continue depending of supermode
311  if (supermode == Supermode::NETWORK) {
312  // network
313  for (const auto& junction : myJunctions) {
314  if (!onlySelected || junction.second->isAttributeCarrierSelected()) {
315  result.push_back(junction.second);
316  }
317  }
318  for (const auto& crossing : myCrossings) {
319  if (!onlySelected || crossing->isAttributeCarrierSelected()) {
320  result.push_back(crossing);
321  }
322  }
323  for (const auto& edge : myEdges) {
324  if (!onlySelected || edge.second->isAttributeCarrierSelected()) {
325  result.push_back(edge.second);
326  }
327  }
328  for (const auto& lane : myLanes) {
329  if (!onlySelected || lane->isAttributeCarrierSelected()) {
330  result.push_back(lane);
331  }
332  }
333  for (const auto& connection : myConnections) {
334  if (!onlySelected || connection->isAttributeCarrierSelected()) {
335  result.push_back(connection);
336  }
337  }
338  for (const auto& additionalSet : myAdditionals) {
339  for (const auto& additional : additionalSet.second) {
340  if (!onlySelected || additional->isAttributeCarrierSelected()) {
341  result.push_back(additional);
342  }
343  }
344  }
345  for (const auto& shapeSet : myShapes) {
346  for (const auto& shape : shapeSet.second) {
347  if (!onlySelected || shape->isAttributeCarrierSelected()) {
348  result.push_back(shape);
349  }
350  }
351  }
352  for (const auto& TAZSet : myTAZElements) {
353  for (const auto& TAZElement : TAZSet.second) {
354  if (!onlySelected || TAZElement->isAttributeCarrierSelected()) {
355  result.push_back(TAZElement);
356  }
357  }
358  }
359  } else if (supermode == Supermode::DEMAND) {
360  for (const auto& demandElementSet : myDemandElements) {
361  for (const auto& demandElement : demandElementSet.second) {
362  if (!onlySelected || demandElement->isAttributeCarrierSelected()) {
363  result.push_back(demandElement);
364  }
365  }
366  }
367  } else if (supermode == Supermode::DATA) {
368  for (const auto& dataSet : myDataSets) {
369  if (!onlySelected || dataSet->isAttributeCarrierSelected()) {
370  result.push_back(dataSet);
371  }
372  }
373  for (const auto& dataInterval : myDataIntervals) {
374  if (!onlySelected || dataInterval->isAttributeCarrierSelected()) {
375  result.push_back(dataInterval);
376  }
377  }
378  for (const auto& genericDataSet : myGenericDatas) {
379  for (const auto& genericData : genericDataSet.second) {
380  if (!onlySelected || genericData->isAttributeCarrierSelected()) {
381  result.push_back(genericData);
382  }
383  }
384  }
385  }
386  return result;
387 }
388 
389 
390 std::vector<GNEAttributeCarrier*>
392  // get modes
393  const auto& editModes = myNet->getViewNet()->getEditModes();
394  // declare vector to save result
395  std::vector<GNEAttributeCarrier*> result;
396  result.reserve(gSelected.getSelected().size());
397  // iterate over all elements of global selection
398  for (const auto& glID : gSelected.getSelected()) {
399  // obtain AC
400  GNEAttributeCarrier* AC = retrieveAttributeCarrier(glID, false);
401  // check if attribute carrier exist and is selected
402  if (AC && AC->isAttributeCarrierSelected()) {
403  bool insert = false;
404  if (ignoreCurrentSupermode) {
405  insert = true;
406  } else if (editModes.isCurrentSupermodeNetwork() && (AC->getTagProperty().isNetworkElement() ||
408  insert = true;
409  } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty().isDemandElement()) {
410  insert = true;
411  } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty().isDataElement()) {
412  insert = true;
413  }
414  if (insert) {
415  result.push_back(AC);
416  }
417  }
418  }
419  return result;
420 }
421 
422 
424 GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
425  if (myJunctions.count(id)) {
426  return myJunctions.at(id);
427  } else if (hardFail) {
428  // If junction wasn't found, throw exception
429  throw UnknownElement("Junction " + id);
430  } else {
431  return nullptr;
432  }
433 }
434 
435 
436 const std::map<std::string, GNEJunction*>&
438  return myJunctions;
439 }
440 
441 
442 std::vector<GNEJunction*>
444  std::vector<GNEJunction*> result;
445  // returns junctions depending of selection
446  for (const auto& junction : myJunctions) {
447  if (junction.second->isAttributeCarrierSelected()) {
448  result.push_back(junction.second);
449  }
450  }
451  return result;
452 }
453 
454 
457  // increase reference
458  junction->incRef("GNENet::registerJunction");
459  junction->setResponsible(false);
460  myJunctions[junction->getMicrosimID()] = junction;
461  // expand net boundary
462  myNet->expandBoundary(junction->getCenteringBoundary());
463  // add edge into grid
464  myNet->addGLObjectIntoGrid(junction);
465  // update geometry
466  junction->updateGeometry();
467  // add z in net boundary
468  myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
469  return junction;
470 }
471 
472 
473 void
475  myJunctions.clear();
476 }
477 
478 
479 void
481  if (myJunctions.count(junction->getID()) == 0) {
482  throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
483  } else if (myJunctions.count(newID) != 0) {
484  throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
485  } else {
486  // remove junction from container
487  myJunctions.erase(junction->getNBNode()->getID());
488  // rename in NetBuilder
489  myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
490  // update microsim ID
491  junction->setMicrosimID(newID);
492  // add it into myJunctions again
493  myJunctions[junction->getID()] = junction;
494  // build crossings
495  junction->getNBNode()->buildCrossings();
496  // net has to be saved
497  myNet->requireSaveNet(true);
498  }
499 }
500 
501 
502 int
504  int counter = 0;
505  for (const auto& junction : myJunctions) {
506  if (junction.second->isAttributeCarrierSelected()) {
507  counter++;
508  }
509  }
510  return counter;
511 }
512 
513 
516  // cast crossing
517  GNECrossing* crossing = dynamic_cast<GNECrossing*>(AC);
518  if (crossing && (myCrossings.count(crossing) > 0)) {
519  return crossing;
520  } else if (hardFail) {
521  throw UnknownElement("Crossing " + AC->getID());
522  } else {
523  return nullptr;
524  }
525 }
526 
527 
528 const std::set<GNECrossing*>&
530  return myCrossings;
531 }
532 
533 
534 std::vector<GNECrossing*>
536  std::vector<GNECrossing*> result;
537  // iterate over crossings
538  for (const auto& crossing : myCrossings) {
539  if (crossing->isAttributeCarrierSelected()) {
540  result.push_back(crossing);
541  }
542  }
543  return result;
544 }
545 
546 
547 void
549  if (myCrossings.insert(crossing).second == false) {
550  throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
551  }
552 }
553 
554 
555 void
557  const auto finder = myCrossings.find(crossing);
558  if (finder == myCrossings.end()) {
559  throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
560  } else {
561  myCrossings.erase(finder);
562  }
563 }
564 
565 
566 int
568  int counter = 0;
569  for (const auto& crossing : myCrossings) {
570  if (crossing->isAttributeCarrierSelected()) {
571  counter++;
572  }
573  }
574  return counter;
575 }
576 
577 
579 GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
580  if (myEdgeTypes.count(id) > 0) {
581  return myEdgeTypes.at(id);
582  } else if (hardFail) {
583  // If edge wasn't found, throw exception
584  throw UnknownElement("EdgeType " + id);
585  } else {
586  return nullptr;
587  }
588 }
589 
590 
593  // increase reference
594  edgeType->incRef("GNENet::registerEdgeType");
595  // add it in container
596  myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
597  return edgeType;
598 }
599 
600 
601 const std::map<std::string, GNEEdgeType*>&
603  return myEdgeTypes;
604 }
605 
606 
608  myEdgeTypes.clear();
609 }
610 
611 
612 void
614  if (myEdgeTypes.count(edgeType->getID()) == 0) {
615  throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
616  } else if (myEdgeTypes.count(newID) != 0) {
617  throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
618  } else {
619  // remove edgeType from container
620  myEdgeTypes.erase(edgeType->getID());
621  // rename in typeCont
622  myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
623  // update microsim ID
624  edgeType->setMicrosimID(newID);
625  // add it into myEdgeTypes again
626  myEdgeTypes[edgeType->getID()] = edgeType;
627  // net has to be saved
628  myNet->requireSaveNet(true);
629  }
630 }
631 
632 
633 std::string
635  int counter = 0;
636  while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
637  counter++;
638  }
639  return ("edgeType_" + toString(counter));
640 }
641 
642 
643 GNEEdge*
644 GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
645  if (myEdges.count(id) > 0) {
646  return myEdges.at(id);
647  } else if (hardFail) {
648  // If edge wasn't found, throw exception
649  throw UnknownElement("Edge " + id);
650  } else {
651  return nullptr;
652  }
653 }
654 
655 
656 GNEEdge*
658  if ((from == nullptr) || (to == nullptr)) {
659  throw UnknownElement("Junctions cannot be nullptr");
660  }
661  // iterate over Junctions
662  for (const auto& edge : myEdges) {
663  if ((edge.second->getFromJunction() == from) && (edge.second->getToJunction() == to)) {
664  return edge.second;
665  }
666  }
667  // if edge wasn't found, throw exception or return nullptr
668  if (hardFail) {
669  throw UnknownElement("Edge with from='" + from->getID() + "' and to='" + to->getID() + "'");
670  } else {
671  return nullptr;
672  }
673 }
674 
675 
676 const std::map<std::string, GNEEdge*>&
678  return myEdges;
679 }
680 
681 
682 std::vector<GNEEdge*>
684  std::vector<GNEEdge*> result;
685  // returns edges depending of selection
686  for (const auto& edge : myEdges) {
687  if (edge.second->isAttributeCarrierSelected()) {
688  result.push_back(edge.second);
689  }
690  }
691  return result;
692 }
693 
694 
695 GNEEdge*
697  edge->incRef("GNENet::registerEdge");
698  edge->setResponsible(false);
699  // add edge to internal container of GNENet
700  myEdges[edge->getMicrosimID()] = edge;
701  // expand edge boundary
702  myNet->expandBoundary(edge->getCenteringBoundary());
703  // add edge into grid
704  myNet->addGLObjectIntoGrid(edge);
705  // insert all lanes
706  for (const auto& lane : edge->getLanes()) {
707  insertLane(lane);
708  }
709  // Add references into GNEJunctions
710  edge->getFromJunction()->addOutgoingGNEEdge(edge);
711  edge->getToJunction()->addIncomingGNEEdge(edge);
712  return edge;
713 }
714 
715 
717  myEdges.clear();
718 }
719 
720 
721 void
722 GNENetHelper::AttributeCarriers::updateEdgeID(GNEEdge* edge, const std::string& newID) {
723  if (myEdges.count(edge->getID()) == 0) {
724  throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
725  } else if (myEdges.count(newID) != 0) {
726  throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
727  } else {
728  // remove edge from container
729  myEdges.erase(edge->getNBEdge()->getID());
730  // rename in NetBuilder
731  myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
732  // update microsim ID
733  edge->setMicrosimID(newID);
734  // add it into myEdges again
735  myEdges[edge->getID()] = edge;
736  // rename all connections related to this edge
737  for (const auto& lane : edge->getLanes()) {
738  lane->updateConnectionIDs();
739  }
740  // net has to be saved
741  myNet->requireSaveNet(true);
742  }
743 }
744 
745 
746 int
748  int counter = 0;
749  for (const auto& edge : myEdges) {
750  if (edge.second->isAttributeCarrierSelected()) {
751  counter++;
752  }
753  }
754  return counter;
755 }
756 
757 
758 GNELane*
759 GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
760  const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
761  const GNEEdge* edge = retrieveEdge(edge_id, false);
762  if (edge != nullptr) {
763  GNELane* lane = nullptr;
764  // search lane in lane's edges
765  for (auto laneIt : edge->getLanes()) {
766  if (laneIt->getID() == id) {
767  lane = laneIt;
768  }
769  }
770  // throw exception or return nullptr if lane wasn't found
771  if (lane == nullptr) {
772  if (hardFail) {
773  // Throw exception if hardFail is enabled
774  throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
775  }
776  } else {
777  // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
778  if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
779  myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getLanes().size()) {
780  return edge->getLanes().at(lane->getIndex() + 1);
781  }
782  return lane;
783  }
784  } else if (hardFail) {
785  // Throw exception if hardFail is enabled
786  throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
787  }
788  return nullptr;
789 }
790 
791 
792 GNELane*
794  // cast lane
795  GNELane* lane = dynamic_cast<GNELane*>(AC);
796  if (lane && (myLanes.count(lane) > 0)) {
797  return lane;
798  } else if (hardFail) {
799  throw UnknownElement("Lane " + AC->getID());
800  } else {
801  return nullptr;
802  }
803 }
804 
805 
806 const std::set<GNELane*>&
808  return myLanes;
809 }
810 
811 
812 std::vector<GNELane*>
814  std::vector<GNELane*> result;
815  // returns lanes depending of selection
816  for (const auto& lane : myLanes) {
817  if (lane->isAttributeCarrierSelected()) {
818  result.push_back(lane);
819  }
820  }
821  return result;
822 }
823 
824 
825 void
827  if (myLanes.insert(lane).second == false) {
828  throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
829  }
830 }
831 
832 
833 void
835  const auto finder = myLanes.find(lane);
836  if (finder == myLanes.end()) {
837  throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
838  } else {
839  myLanes.erase(finder);
840  }
841 }
842 
843 
844 int
846  int counter = 0;
847  for (const auto& lane : myLanes) {
848  if (lane->isAttributeCarrierSelected()) {
849  counter++;
850  }
851  }
852  return counter;
853 }
854 
855 
857 GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
858  // iterate over connections
859  for (const auto& connection : myConnections) {
860  if (connection->getID() == id) {
861  return connection;
862  }
863  }
864  if (hardFail) {
865  // If POI wasn't found, throw exception
866  throw UnknownElement("Connection " + id);
867  } else {
868  return nullptr;
869  }
870 }
871 
872 
875  // cast connection
876  GNEConnection* connection = dynamic_cast<GNEConnection*>(AC);
877  if (connection && (myConnections.count(connection) > 0)) {
878  return connection;
879  } else if (hardFail) {
880  throw UnknownElement("Connection " + AC->getID());
881  } else {
882  return nullptr;
883  }
884 }
885 
886 
887 const std::set<GNEConnection*>&
889  return myConnections;
890 }
891 
892 
893 std::vector<GNEConnection*>
895  std::vector<GNEConnection*> result;
896  // returns connections depending of selection
897  for (const auto& connection : myConnections) {
898  if (connection->isAttributeCarrierSelected()) {
899  result.push_back(connection);
900  }
901  }
902  return result;
903 }
904 
905 
906 void
908  if (myConnections.insert(connection).second == false) {
909  throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
910  }
911 }
912 
913 
914 void
916  const auto finder = myConnections.find(connection);
917  if (finder == myConnections.end()) {
918  throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
919  } else {
920  myConnections.erase(finder);
921  }
922 }
923 
924 
925 int
927  int counter = 0;
928  for (const auto& connection : myConnections) {
929  if (connection->isAttributeCarrierSelected()) {
930  counter++;
931  }
932  }
933  return counter;
934 }
935 
936 
938 GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
939  for (const auto& additional : myAdditionals.at(type)) {
940  if (additional->getID() == id) {
941  return additional;
942  }
943  }
944  if (hardFail) {
945  throw ProcessError("Attempted to retrieve non-existant additional (string)");
946  } else {
947  return nullptr;
948  }
949 }
950 
951 
954  // cast additional
955  GNEAdditional* additional = dynamic_cast<GNEAdditional*>(AC);
956  if (additional && (myAdditionals.at(AC->getTagProperty().getTag()).count(additional) > 0)) {
957  return additional;
958  } else if (hardFail) {
959  throw ProcessError("Attempted to retrieve non-existant additional (AttributeCarrier)");
960  } else {
961  return nullptr;
962  }
963 }
964 
965 
967 GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
968  // first retrieve rerouter
969  const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
970  // parse begin and end
971  const std::string beginStr = time2string(begin);
972  const std::string endStr = time2string(end);
973  // now iterate over all children and check begin and end
974  for (const auto& interval : rerouter->getChildAdditionals()) {
975  // check tag (to avoid symbols)
976  if (interval->getTagProperty().getTag() == SUMO_TAG_INTERVAL) {
977  // check begin and end
978  if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
979  (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
980  return interval;
981  }
982  }
983  }
984  // throw exception
985  throw ProcessError("Attempted to retrieve non-existant rerouter interval");
986 }
987 
988 
989 const std::map<SumoXMLTag, std::set<GNEAdditional*> >&
991  return myAdditionals;
992 }
993 
994 
995 std::vector<GNEAdditional*>
997  std::vector<GNEAdditional*> result;
998  // returns additionals depending of selection
999  for (const auto& additionalsTags : myAdditionals) {
1000  for (const auto& additional : additionalsTags.second) {
1001  if (additional->isAttributeCarrierSelected()) {
1002  result.push_back(additional);
1003  }
1004  }
1005  }
1006  return result;
1007 }
1008 
1009 
1010 int
1012  int counter = 0;
1013  for (const auto& additionalsTag : myAdditionals) {
1014  counter += (int)additionalsTag.second.size();
1015  }
1016  return counter;
1017 }
1018 
1019 
1020 void
1022  // clear elements in grid
1023  for (const auto& additionalsTags : myAdditionals) {
1024  for (const auto& additional : additionalsTags.second) {
1025  myNet->removeGLObjectFromGrid(additional);
1026  }
1027  }
1028  // iterate over myAdditionals and clear all additionals
1029  for (auto& additionals : myAdditionals) {
1030  additionals.second.clear();
1031  }
1032 }
1033 
1034 
1035 int
1037  int counter = 0;
1038  for (const auto& additionalsTags : myAdditionals) {
1039  for (const auto& additional : additionalsTags.second) {
1040  if (additional->isAttributeCarrierSelected()) {
1041  counter++;
1042  }
1043  }
1044  }
1045  return counter;
1046 }
1047 
1048 
1049 std::string
1051  // obtain option container
1053  // get prefix
1054  std::string prefix;
1055  if (tag == SUMO_TAG_BUS_STOP) {
1056  prefix = oc.getString("busStop-prefix");
1057  } else if (tag == SUMO_TAG_TRAIN_STOP) {
1058  prefix = oc.getString("trainStop-prefix");
1059  } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1060  prefix = oc.getString("containerStop-prefix");
1061  } else if (tag == SUMO_TAG_CHARGING_STATION) {
1062  prefix = oc.getString("chargingStation-prefix");
1063  } else if (tag == SUMO_TAG_PARKING_AREA) {
1064  prefix = oc.getString("parkingArea-prefix");
1065  } else if (tag == SUMO_TAG_E1DETECTOR) {
1066  prefix = oc.getString("e1Detector-prefix");
1067  } else if ((tag == SUMO_TAG_E2DETECTOR) || (tag == GNE_TAG_E2DETECTOR_MULTILANE)) {
1068  prefix = oc.getString("e2Detector-prefix");
1069  } else if (tag == SUMO_TAG_E3DETECTOR) {
1070  prefix = oc.getString("e3Detector-prefix");
1071  } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1072  prefix = oc.getString("e1InstantDetector-prefix");
1073  } else if (tag == SUMO_TAG_REROUTER) {
1074  prefix = oc.getString("rerouter-prefix");
1075  } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == SUMO_TAG_LANECALIBRATOR)) {
1076  prefix = oc.getString("calibrator-prefix");
1077  } else if (tag == SUMO_TAG_ROUTEPROBE) {
1078  prefix = oc.getString("routeProbe-prefix");
1079  } else if (tag == SUMO_TAG_VSS) {
1080  prefix = oc.getString("vss-prefix");
1081  }
1082  int counter = 0;
1083  // special case for calibrators
1084  if ((tag == SUMO_TAG_CALIBRATOR) || (tag == SUMO_TAG_LANECALIBRATOR)) {
1085  while ((retrieveAdditional(SUMO_TAG_CALIBRATOR, prefix + "_" + toString(counter), false) != nullptr) ||
1086  (retrieveAdditional(SUMO_TAG_LANECALIBRATOR, prefix + "_" + toString(counter), false) != nullptr)) {
1087  counter++;
1088  }
1089  } else {
1090  while ((retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr)) {
1091  counter++;
1092  }
1093  }
1094  return (prefix + "_" + toString(counter));
1095 }
1096 
1097 
1098 GNEShape*
1099 GNENetHelper::AttributeCarriers::retrieveShape(SumoXMLTag type, const std::string& id, bool hardFail) const {
1100  for (const auto& shape : myShapes.at(type)) {
1101  if (shape->getID() == id) {
1102  return shape;
1103  }
1104  }
1105  if (hardFail) {
1106  throw ProcessError("Attempted to retrieve non-existant shape");
1107  } else {
1108  return nullptr;
1109  }
1110 }
1111 
1112 
1113 GNEShape*
1115  // cast shape
1116  GNEShape* shape = dynamic_cast<GNEShape*>(AC);
1117  if (shape && (myShapes.at(AC->getTagProperty().getTag()).count(shape) > 0)) {
1118  return shape;
1119  } else if (hardFail) {
1120  throw ProcessError("Attempted to retrieve non-existant shape");
1121  } else {
1122  return nullptr;
1123  }
1124 }
1125 
1126 
1127 std::vector<GNEShape*>
1129  std::vector<GNEShape*> result;
1130  // return all polygons and POIs
1131  for (const auto& shapeTag : myShapes) {
1132  for (const auto& shape : shapeTag.second) {
1133  if (shape->isAttributeCarrierSelected()) {
1134  result.push_back(shape);
1135  }
1136  }
1137  }
1138  return result;
1139 }
1140 
1141 
1142 const std::map<SumoXMLTag, std::set<GNEShape*> >&
1144  return myShapes;
1145 }
1146 
1147 
1148 std::string
1150  int counter = 0;
1151  // obtain option container
1153  // get prefix
1154  std::string prefix;
1155  if (tag == SUMO_TAG_POLY) {
1156  prefix = oc.getString("polygon-prefix");
1157  } else {
1158  prefix = oc.getString("poi-prefix");
1159  }
1160  // generate tag depending of shape tag
1161  if (tag == SUMO_TAG_POLY) {
1162  // Polys and TAZs share namespace
1163  while ((retrieveShape(SUMO_TAG_POLY, prefix + "_" + toString(counter), false) != nullptr) ||
1164  (retrieveTAZElement(SUMO_TAG_TAZ, prefix + "_" + toString(counter), false) != nullptr)) {
1165  counter++;
1166  }
1167  return (prefix + "_" + toString(counter));
1168  } else {
1169  while ((retrieveShape(SUMO_TAG_POI, prefix + "_" + toString(counter), false) != nullptr) ||
1170  (retrieveShape(GNE_TAG_POILANE, prefix + "_" + toString(counter), false) != nullptr) ||
1171  (retrieveShape(GNE_TAG_POIGEO, prefix + "_" + toString(counter), false) != nullptr)) {
1172  counter++;
1173  }
1174  return (prefix + "_" + toString(counter));
1175  }
1176 }
1177 
1178 
1179 int
1181  int counter = 0;
1182  for (const auto& shapeTag : myShapes) {
1183  counter += (int)shapeTag.second.size();
1184  }
1185  return counter;
1186 }
1187 
1188 
1189 void
1191  // clear elements in grid
1192  for (const auto& shapesTags : myShapes) {
1193  for (const auto& shape : shapesTags.second) {
1194  myNet->removeGLObjectFromGrid(shape);
1195  }
1196  }
1197  // iterate over myShapes and clear all shapes
1198  for (auto& shapes : myShapes) {
1199  shapes.second.clear();
1200  }
1201 }
1202 
1203 
1204 int
1206  int counter = 0;
1207  for (const auto& poly : myShapes.at(SUMO_TAG_POLY)) {
1208  if (poly->isAttributeCarrierSelected()) {
1209  counter++;
1210  }
1211  }
1212  return counter;
1213 }
1214 
1215 
1216 int
1218  int counter = 0;
1219  for (const auto& POI : myShapes.at(SUMO_TAG_POI)) {
1220  if (POI->isAttributeCarrierSelected()) {
1221  counter++;
1222  }
1223  }
1224  for (const auto& POILane : myShapes.at(GNE_TAG_POILANE)) {
1225  if (POILane->isAttributeCarrierSelected()) {
1226  counter++;
1227  }
1228  }
1229  for (const auto& POIGEO : myShapes.at(GNE_TAG_POIGEO)) {
1230  if (POIGEO->isAttributeCarrierSelected()) {
1231  counter++;
1232  }
1233  }
1234  return counter;
1235 }
1236 
1237 
1239 GNENetHelper::AttributeCarriers::retrieveTAZElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1240  for (const auto& TAZElement : myTAZElements.at(type)) {
1241  if (TAZElement->getID() == id) {
1242  return TAZElement;
1243  }
1244  }
1245  if (hardFail) {
1246  throw ProcessError("Attempted to retrieve non-existant TAZElement");
1247  } else {
1248  return nullptr;
1249  }
1250 }
1251 
1252 
1255  // cast TAZElement
1256  GNETAZElement* TAZElement = dynamic_cast<GNETAZElement*>(AC);
1257  if (TAZElement && (myTAZElements.at(AC->getTagProperty().getTag()).count(TAZElement) > 0)) {
1258  return TAZElement;
1259  } else if (hardFail) {
1260  throw ProcessError("Attempted to retrieve non-existant TAZElement");
1261  } else {
1262  return nullptr;
1263  }
1264 }
1265 
1266 
1267 std::vector<GNETAZElement*>
1269  std::vector<GNETAZElement*> result;
1270  // returns TAZElements depending of selection
1271  for (const auto& TAZElementTags : myTAZElements) {
1272  for (const auto& TAZElement : TAZElementTags.second) {
1273  if (TAZElement->isAttributeCarrierSelected()) {
1274  result.push_back(TAZElement);
1275  }
1276  }
1277  }
1278  return result;
1279 }
1280 
1281 
1282 const std::map<SumoXMLTag, std::set<GNETAZElement*> >&
1284  return myTAZElements;
1285 }
1286 
1287 
1288 void
1290  // clear elements in grid
1291  for (const auto& TAZElementsTags : myTAZElements) {
1292  for (const auto& TAZElement : TAZElementsTags.second) {
1293  myNet->removeGLObjectFromGrid(TAZElement);
1294  }
1295  }
1296  // iterate over myTAZElements and clear all TAZElements
1297  for (auto& TAZElements : myTAZElements) {
1298  TAZElements.second.clear();
1299  }
1300 }
1301 
1302 
1303 int
1305  int counter = 0;
1306  for (const auto& TAZElementsTag : myTAZElements) {
1307  counter += (int)TAZElementsTag.second.size();
1308  }
1309  return counter;
1310 }
1311 
1312 
1313 int
1315  int counter = 0;
1316  for (const auto& poly : myTAZElements.at(SUMO_TAG_TAZ)) {
1317  if (poly->isAttributeCarrierSelected()) {
1318  counter++;
1319  }
1320  }
1321  return counter;
1322 }
1323 
1324 
1325 bool
1327  // first check that TAZElement pointer is valid
1328  if (TAZElement) {
1329  // get vector with this TAZ element type
1330  const auto& TAZElementTag = myTAZElements.at(TAZElement->getTagProperty().getTag());
1331  // find demanElement in TAZElementTag
1332  return std::find(TAZElementTag.begin(), TAZElementTag.end(), TAZElement) != TAZElementTag.end();
1333  } else {
1334  throw ProcessError("Invalid TAZElement pointer");
1335  }
1336 }
1337 
1338 
1339 std::string
1341  int counter = 0;
1342  // generate tag depending of shape tag
1343  if (tag == SUMO_TAG_TAZ) {
1344  // Polys and TAZs share namespace
1345  while ((retrieveShape(SUMO_TAG_POLY, toString(tag) + "_" + toString(counter), false) != nullptr) ||
1346  (retrieveTAZElement(SUMO_TAG_TAZ, toString(tag) + "_" + toString(counter), false) != nullptr)) {
1347  counter++;
1348  }
1349  return (toString(tag) + "_" + toString(counter));
1350  } else {
1351  while (retrieveTAZElement(tag, toString(tag) + "_" + toString(counter)) != nullptr) {
1352  counter++;
1353  }
1354  return (toString(tag) + "_" + toString(counter));
1355  }
1356 }
1357 
1358 
1360 GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1361  for (const auto& demandElement : myDemandElements.at(type)) {
1362  if (demandElement->getID() == id) {
1363  return demandElement;
1364  }
1365  }
1366  if (hardFail) {
1367  throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1368  } else {
1369  return nullptr;
1370  }
1371 }
1372 
1373 
1376  // cast demandElement
1377  GNEDemandElement* demandElement = dynamic_cast<GNEDemandElement*>(AC);
1378  if (demandElement && (myDemandElements.at(AC->getTagProperty().getTag()).count(demandElement) > 0)) {
1379  return demandElement;
1380  } else if (hardFail) {
1381  throw ProcessError("Attempted to retrieve non-existant demand element (AttributeCarrier)");
1382  } else {
1383  return nullptr;
1384  }
1385 }
1386 
1387 
1388 std::vector<GNEDemandElement*>
1390  std::vector<GNEDemandElement*> result;
1391  // returns demand elements depending of selection
1392  for (const auto& demandElementTag : myDemandElements) {
1393  for (const auto& demandElement : demandElementTag.second) {
1394  if (demandElement->isAttributeCarrierSelected()) {
1395  result.push_back(demandElement);
1396  }
1397  }
1398  }
1399  return result;
1400 }
1401 
1402 
1403 const std::map<SumoXMLTag, std::set<GNEDemandElement*> >&
1405  return myDemandElements;
1406 }
1407 
1408 
1409 int
1411  int counter = 0;
1412  for (const auto& demandElementTag : myDemandElements) {
1413  counter += (int)demandElementTag.second.size();
1414  }
1415  return counter;
1416 }
1417 
1418 
1419 std::string
1421  // obtain option container
1423  // get tag property
1424  const auto tagProperty = GNEAttributeCarrier::getTagProperty(tag);
1425  // get prefix
1426  std::string prefix;
1427  if (tag == SUMO_TAG_ROUTE) {
1428  prefix = oc.getString("route-prefix");
1429  } else if (tag == SUMO_TAG_VTYPE) {
1430  prefix = oc.getString("vType-prefix");
1431  } else if (tag == SUMO_TAG_TRIP) {
1432  prefix = oc.getString("trip-prefix");
1433  } else if (tagProperty.isVehicle() && !tagProperty.isFlow()) {
1434  prefix = oc.getString("vehicle-prefix");
1435  } else if (tagProperty.isFlow()) {
1436  prefix = oc.getString("flow-prefix");
1437  } else if (tagProperty.isPerson()) {
1438  prefix = oc.getString("person-prefix");
1439  } else if (tagProperty.isContainer()) {
1440  prefix = oc.getString("container-prefix");
1441  }
1442  // declare counter
1443  int counter = 0;
1444  if (tagProperty.isVehicle() || tagProperty.isFlow()) {
1445  // check all vehicles, because share nameSpaces
1446  while ((retrieveDemandElement(SUMO_TAG_VEHICLE, prefix + "_" + toString(counter), false) != nullptr) ||
1447  (retrieveDemandElement(SUMO_TAG_TRIP, prefix + "_" + toString(counter), false) != nullptr) ||
1448  (retrieveDemandElement(GNE_TAG_VEHICLE_WITHROUTE, prefix + "_" + toString(counter), false) != nullptr) ||
1449  (retrieveDemandElement(GNE_TAG_TRIP_JUNCTIONS, prefix + "_" + toString(counter), false) != nullptr) ||
1450  (retrieveDemandElement(GNE_TAG_FLOW_ROUTE, prefix + "_" + toString(counter), false) != nullptr) ||
1451  (retrieveDemandElement(SUMO_TAG_FLOW, prefix + "_" + toString(counter), false) != nullptr) ||
1452  (retrieveDemandElement(GNE_TAG_FLOW_WITHROUTE, prefix + "_" + toString(counter), false) != nullptr) ||
1453  (retrieveDemandElement(GNE_TAG_FLOW_JUNCTIONS, prefix + "_" + toString(counter), false) != nullptr)) {
1454  counter++;
1455  }
1456  // return new vehicle ID
1457  return (prefix + "_" + toString(counter));
1458  } else if (tagProperty.isPerson()) {
1459  // special case for persons (person and personFlows share nameSpaces)
1460  while ((retrieveDemandElement(SUMO_TAG_PERSON, prefix + "_" + toString(counter), false) != nullptr) ||
1461  (retrieveDemandElement(SUMO_TAG_PERSONFLOW, prefix + "_" + toString(counter), false) != nullptr)) {
1462  counter++;
1463  }
1464  // return new person ID
1465  return (prefix + "_" + toString(counter));
1466  } else if (tagProperty.isContainer()) {
1467  // special case for containers (container and containerFlows share nameSpaces)
1468  while ((retrieveDemandElement(SUMO_TAG_CONTAINER, prefix + "_" + toString(counter), false) != nullptr) ||
1469  (retrieveDemandElement(SUMO_TAG_CONTAINERFLOW, prefix + "_" + toString(counter), false) != nullptr)) {
1470  counter++;
1471  }
1472  // return new container ID
1473  return (prefix + "_" + toString(counter));
1474  } else {
1475  while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1476  counter++;
1477  }
1478  // return new element ID
1479  return (prefix + "_" + toString(counter));
1480  }
1481 }
1482 
1483 
1486  for (const auto& vType : myDemandElements.at(SUMO_TAG_VTYPE)) {
1487  if (vType->getID() == DEFAULT_VTYPE_ID) {
1488  return vType;
1489  }
1490  }
1491  throw ProcessError("Default vType doesn't exist");
1492 }
1493 
1494 
1495 void
1497  // clear elements in grid
1498  for (const auto& demandElementsTags : myDemandElements) {
1499  for (const auto& demandElement : demandElementsTags.second) {
1500  myNet->removeGLObjectFromGrid(demandElement);
1501  }
1502  }
1503  // iterate over myDemandElements and clear all demand elemnts
1504  for (auto& demandElements : myDemandElements) {
1505  demandElements.second.clear();
1506  }
1507 }
1508 
1509 
1510 void
1512  // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1513  GNEVType* defaultVehicleType = new GNEVType(myNet, DEFAULT_VTYPE_ID, SVC_PASSENGER);
1514  myDemandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(defaultVehicleType);
1515  defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1516 
1517  // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1518  GNEVType* defaultBikeType = new GNEVType(myNet, DEFAULT_BIKETYPE_ID, SVC_BICYCLE);
1519  myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(defaultBikeType);
1520  defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1521 
1522  // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1523  GNEVType* defaultTaxiType = new GNEVType(myNet, DEFAULT_TAXITYPE_ID, SVC_TAXI);
1524  myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(defaultTaxiType);
1525  defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1526 
1527  // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1528  GNEVType* defaultPersonType = new GNEVType(myNet, DEFAULT_PEDTYPE_ID, SVC_PEDESTRIAN);
1529  myDemandElements.at(defaultPersonType->getTagProperty().getTag()).insert(defaultPersonType);
1530  defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1531 
1532  // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1533  GNEVType* defaultContainerType = new GNEVType(myNet, DEFAULT_CONTAINERTYPE_ID, SVC_IGNORING);
1534  myDemandElements.at(defaultContainerType->getTagProperty().getTag()).insert(defaultContainerType);
1535  defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1536 }
1537 
1538 
1539 int
1541  int counter = 0;
1542  for (const auto& demandElementsTags : myDemandElements) {
1543  for (const auto& demandElement : demandElementsTags.second) {
1544  if (demandElement->isAttributeCarrierSelected()) {
1545  counter++;
1546  }
1547  }
1548  }
1549  return counter;
1550 }
1551 
1552 
1553 int
1555  int counter = 0;
1556  // iterate over routes
1557  for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1558  if (route->isAttributeCarrierSelected()) {
1559  counter++;
1560  }
1561  }
1562  // iterate over vehicles with embedded routes
1563  for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1564  if (vehicle->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1565  counter++;
1566  }
1567  }
1568  for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1569  if (flow->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1570  counter++;
1571  }
1572  }
1573  return counter;
1574 }
1575 
1576 
1577 int
1579  int counter = 0;
1580  // iterate over all vehicles and flows
1581  for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1582  if (vehicle->isAttributeCarrierSelected()) {
1583  counter++;
1584  }
1585  }
1586  for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1587  if (trip->isAttributeCarrierSelected()) {
1588  counter++;
1589  }
1590  }
1591  for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1592  if (vehicle->isAttributeCarrierSelected()) {
1593  counter++;
1594  }
1595  }
1596  for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1597  if (flow->isAttributeCarrierSelected()) {
1598  counter++;
1599  }
1600  }
1601  for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1602  if (flow->isAttributeCarrierSelected()) {
1603  counter++;
1604  }
1605  }
1606  for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1607  if (flow->isAttributeCarrierSelected()) {
1608  counter++;
1609  }
1610  }
1611  return counter;
1612 }
1613 
1614 
1615 int
1617  int counter = 0;
1618  // iterate over all persons
1619  for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1620  if (person->isAttributeCarrierSelected()) {
1621  counter++;
1622  }
1623  }
1624  for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1625  if (personFlow->isAttributeCarrierSelected()) {
1626  counter++;
1627  }
1628  }
1629  return counter;
1630 }
1631 
1632 
1633 int
1635  int counter = 0;
1636  // iterate over all person plans
1637  for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1638  for (const auto& personPlan : person->getChildDemandElements()) {
1639  if (personPlan->getTagProperty().isPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1640  counter++;
1641  }
1642  }
1643  }
1644  for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1645  for (const auto& personPlan : personFlow->getChildDemandElements()) {
1646  if (personPlan->getTagProperty().isPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1647  counter++;
1648  }
1649  }
1650  }
1651  return counter;
1652 }
1653 
1654 
1655 int
1657  int counter = 0;
1658  // iterate over all person plans
1659  for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1660  for (const auto& personPlan : person->getChildDemandElements()) {
1661  if (personPlan->getTagProperty().isWalk() && personPlan->isAttributeCarrierSelected()) {
1662  counter++;
1663  }
1664  }
1665  }
1666  for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1667  for (const auto& personPlan : personFlow->getChildDemandElements()) {
1668  if (personPlan->getTagProperty().isWalk() && personPlan->isAttributeCarrierSelected()) {
1669  counter++;
1670  }
1671  }
1672  }
1673  return counter;
1674 }
1675 
1676 
1677 int
1679  int counter = 0;
1680  // iterate over all person plans
1681  for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1682  for (const auto& personPlan : person->getChildDemandElements()) {
1683  if (personPlan->getTagProperty().isRide() && personPlan->isAttributeCarrierSelected()) {
1684  counter++;
1685  }
1686  }
1687  }
1688  for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1689  for (const auto& personPlan : personFlow->getChildDemandElements()) {
1690  if (personPlan->getTagProperty().isRide() && personPlan->isAttributeCarrierSelected()) {
1691  counter++;
1692  }
1693  }
1694  }
1695  return counter;
1696 }
1697 
1698 
1699 int
1701  int counter = 0;
1702  // iterate over all containers
1703  for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1704  if (container->isAttributeCarrierSelected()) {
1705  counter++;
1706  }
1707  }
1708  for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1709  if (containerFlow->isAttributeCarrierSelected()) {
1710  counter++;
1711  }
1712  }
1713  return counter;
1714 }
1715 
1716 
1717 int
1719  int counter = 0;
1720  // iterate over all container plans
1721  for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1722  for (const auto& containerPlan : container->getChildDemandElements()) {
1723  if (containerPlan->getTagProperty().isTransportPlan() && containerPlan->isAttributeCarrierSelected()) {
1724  counter++;
1725  }
1726  }
1727  }
1728  for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1729  for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
1730  if (containerPlan->getTagProperty().isTransportPlan() && containerPlan->isAttributeCarrierSelected()) {
1731  counter++;
1732  }
1733  }
1734  }
1735  return counter;
1736 }
1737 
1738 
1739 int
1741  int counter = 0;
1742  // iterate over all container plans
1743  for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1744  for (const auto& containerPlan : container->getChildDemandElements()) {
1745  if (containerPlan->getTagProperty().isTranshipPlan() && containerPlan->isAttributeCarrierSelected()) {
1746  counter++;
1747  }
1748  }
1749  }
1750  for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1751  for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
1752  if (containerPlan->getTagProperty().isTranshipPlan() && containerPlan->isAttributeCarrierSelected()) {
1753  counter++;
1754  }
1755  }
1756  }
1757  return counter;
1758 }
1759 
1760 
1761 int
1763  int counter = 0;
1764  // iterate over routes
1765  for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1766  if (route->isAttributeCarrierSelected()) {
1767  counter++;
1768  }
1769  }
1770  // vehicles
1771  for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1772  for (const auto& stop : trip->getChildDemandElements()) {
1773  if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1774  counter++;
1775  }
1776  }
1777  }
1778  for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1779  for (const auto& stop : vehicle->getChildDemandElements().front()->getChildDemandElements()) {
1780  if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1781  counter++;
1782  }
1783  }
1784  }
1785  for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1786  for (const auto& stop : flow->getChildDemandElements()) {
1787  if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1788  counter++;
1789  }
1790  }
1791  }
1792  for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1793  for (const auto& stop : flow->getChildDemandElements().front()->getChildDemandElements()) {
1794  if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1795  counter++;
1796  }
1797  }
1798  }
1799  // persons
1800  for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1801  for (const auto& personPlan : person->getChildDemandElements()) {
1802  if (personPlan->getTagProperty().isStopPerson() && personPlan->isAttributeCarrierSelected()) {
1803  counter++;
1804  }
1805  }
1806  }
1807  for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1808  for (const auto& personPlan : personFlow->getChildDemandElements()) {
1809  if (personPlan->getTagProperty().isStopPerson() && personPlan->isAttributeCarrierSelected()) {
1810  counter++;
1811  }
1812  }
1813  }
1814  // containers
1815  for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1816  for (const auto& containerPlan : container->getChildDemandElements()) {
1817  if (containerPlan->getTagProperty().isStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1818  counter++;
1819  }
1820  }
1821  }
1822  for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1823  for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
1824  if (containerPlan->getTagProperty().isStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1825  counter++;
1826  }
1827  }
1828  }
1829  return counter;
1830 }
1831 
1832 
1833 GNEDataSet*
1834 GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1835  for (const auto& dataSet : myDataSets) {
1836  if (dataSet->getID() == id) {
1837  return dataSet;
1838  }
1839  }
1840  if (hardFail) {
1841  throw ProcessError("Attempted to retrieve non-existant data set");
1842  } else {
1843  return nullptr;
1844  }
1845 }
1846 
1847 
1848 GNEDataSet*
1850  // cast dataSet
1851  GNEDataSet* dataSet = dynamic_cast<GNEDataSet*>(AC);
1852  if (dataSet && (myDataSets.count(dataSet) > 0)) {
1853  return dataSet;
1854  } else if (hardFail) {
1855  throw ProcessError("Attempted to retrieve non-existant data set");
1856  } else {
1857  return nullptr;
1858  }
1859 }
1860 
1861 
1862 const std::set<GNEDataSet*>&
1864  return myDataSets;
1865 }
1866 
1867 
1868 std::string
1869 GNENetHelper::AttributeCarriers::generateDataSetID(const std::string& prefix) const {
1870  const std::string dataSetTagStr = toString(SUMO_TAG_DATASET);
1871  int counter = 0;
1872  while (retrieveDataSet(prefix + dataSetTagStr + "_" + toString(counter), false) != nullptr) {
1873  counter++;
1874  }
1875  return (prefix + dataSetTagStr + "_" + toString(counter));
1876 }
1877 
1878 
1881  // cast dataInterval
1882  GNEDataInterval* dataInterval = dynamic_cast<GNEDataInterval*>(AC);
1883  if (dataInterval && (myDataIntervals.count(dataInterval) > 0)) {
1884  return dataInterval;
1885  } else if (hardFail) {
1886  throw ProcessError("Attempted to retrieve non-existant data interval");
1887  } else {
1888  return nullptr;
1889  }
1890 }
1891 
1892 
1893 const std::set<GNEDataInterval*>&
1895  return myDataIntervals;
1896 }
1897 
1898 
1899 void
1901  if (myDataIntervals.insert(dataInterval).second == false) {
1902  throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
1903  }
1904 }
1905 
1906 
1907 void
1909  const auto finder = myDataIntervals.find(dataInterval);
1910  if (finder == myDataIntervals.end()) {
1911  throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
1912  } else {
1913  myDataIntervals.erase(finder);
1914  }
1915 }
1916 
1917 
1920  // cast genericData
1921  GNEGenericData* genericData = dynamic_cast<GNEGenericData*>(AC);
1922  if (genericData && (myGenericDatas.at(AC->getTagProperty().getTag()).count(genericData) > 0)) {
1923  return genericData;
1924  } else if (hardFail) {
1925  throw ProcessError("Attempted to retrieve non-existant data set");
1926  } else {
1927  return nullptr;
1928  }
1929 }
1930 
1931 
1932 std::vector<GNEGenericData*>
1934  std::vector<GNEGenericData*> result;
1935  // returns generic datas depending of selection
1936  for (const auto& genericDataTag : myGenericDatas) {
1937  for (const auto& genericData : genericDataTag.second) {
1938  if (genericData->isAttributeCarrierSelected()) {
1939  result.push_back(genericData);
1940  }
1941  }
1942  }
1943  return result;
1944 }
1945 
1946 
1947 const std::map<SumoXMLTag, std::set<GNEGenericData*> >&
1949  return myGenericDatas;
1950 }
1951 
1952 
1953 std::vector<GNEGenericData*>
1954 GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
1955  // declare generic data vector
1956  std::vector<GNEGenericData*> genericDatas;
1957  // iterate over all data sets
1958  for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
1959  // check interval
1960  if ((genericData->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
1961  (genericData->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
1962  genericDatas.push_back(genericData);
1963  }
1964  }
1965  return genericDatas;
1966 }
1967 
1968 
1969 int
1971  int counter = 0;
1972  // iterate over all edgeDatas
1973  for (const auto& genericData : myGenericDatas.at(SUMO_TAG_MEANDATA_EDGE)) {
1974  if (genericData->isAttributeCarrierSelected()) {
1975  counter++;
1976  }
1977  }
1978  return counter;
1979 }
1980 
1981 
1982 int
1984  int counter = 0;
1985  // iterate over all edgeDatas
1986  for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
1987  if (genericData->isAttributeCarrierSelected()) {
1988  counter++;
1989  }
1990  }
1991  return counter;
1992 }
1993 
1994 
1995 int
1997  int counter = 0;
1998  // iterate over all edgeDatas
1999  for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2000  if (genericData->isAttributeCarrierSelected()) {
2001  counter++;
2002  }
2003  }
2004  return counter;
2005 }
2006 
2007 
2008 void
2010  if (myGenericDatas.at(genericData->getTagProperty().getTag()).insert(genericData).second == false) {
2011  throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2012  }
2013 }
2014 
2015 
2016 void
2018  const auto finder = myGenericDatas.at(genericData->getTagProperty().getTag()).find(genericData);
2019  if (finder == myGenericDatas.at(genericData->getTagProperty().getTag()).end()) {
2020  throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2021  } else {
2022  myGenericDatas.at(genericData->getTagProperty().getTag()).erase(finder);
2023  }
2024 }
2025 
2026 
2027 std::set<std::string>
2028 GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2029  // declare solution
2030  std::set<std::string> attributesSolution;
2031  // declare generic data vector
2032  std::vector<GNEGenericData*> genericDatas;
2033  // iterate over all data sets
2034  for (const auto& interval : myDataIntervals) {
2035  // check interval
2036  if ((interval->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2037  // iterate over generic datas
2038  for (const auto& genericData : interval->getGenericDataChildren()) {
2039  if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2040  genericDatas.push_back(genericData);
2041  }
2042  }
2043  }
2044  }
2045  // iterate over generic datas
2046  for (const auto& genericData : genericDatas) {
2047  for (const auto& attribute : genericData->getParametersMap()) {
2048  attributesSolution.insert(attribute.first);
2049  }
2050  }
2051  return attributesSolution;
2052 }
2053 
2054 
2055 std::set<std::string>
2056 GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2057  const std::string& beginStr, const std::string& endStr) const {
2058  // declare solution
2059  std::set<std::string> attributesSolution;
2060  // vector of data sets and intervals
2061  std::vector<GNEDataSet*> dataSets;
2062  std::vector<GNEDataInterval*> dataIntervals;
2063  // get dataSet
2064  GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2065  // if dataSetID is empty, return all parameters
2066  if (dataSetID.empty()) {
2067  // add all data sets
2068  dataSets.reserve(myDataSets.size());
2069  for (const auto& dataSet : myDataSets) {
2070  dataSets.push_back(dataSet);
2071  }
2072  } else if (retrievedDataSet) {
2073  dataSets.push_back(retrievedDataSet);
2074  } else {
2075  return attributesSolution;
2076  }
2077  // now continue with data intervals
2078  int numberOfIntervals = 0;
2079  for (const auto& dataSet : dataSets) {
2080  numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2081  }
2082  // resize dataIntervals
2083  dataIntervals.reserve(numberOfIntervals);
2084  // add intervals
2085  for (const auto& dataSet : dataSets) {
2086  for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2087  // continue depending of begin and end
2088  if (beginStr.empty() && endStr.empty()) {
2089  dataIntervals.push_back(dataInterval.second);
2090  } else if (endStr.empty()) {
2091  // parse begin
2092  const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2093  if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2094  dataIntervals.push_back(dataInterval.second);
2095  }
2096  } else if (beginStr.empty()) {
2097  // parse end
2098  const double end = GNEAttributeCarrier::parse<double>(endStr);
2099  if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2100  dataIntervals.push_back(dataInterval.second);
2101  }
2102  } else {
2103  // parse both begin end
2104  const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2105  const double end = GNEAttributeCarrier::parse<double>(endStr);
2106  if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2107  (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2108  dataIntervals.push_back(dataInterval.second);
2109  }
2110  }
2111  }
2112  }
2113  // finally iterate over intervals and get attributes
2114  for (const auto& dataInterval : dataIntervals) {
2115  for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2116  // check generic data tag
2117  if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2118  for (const auto& attribute : genericData->getParametersMap()) {
2119  attributesSolution.insert(attribute.first);
2120  }
2121  }
2122  }
2123  }
2124  return attributesSolution;
2125 }
2126 
2127 
2128 void
2130  myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2131  registerJunction(junction);
2132 }
2133 
2134 
2135 void
2137  // remove it from inspected elements and HierarchicalElementTree
2138  myNet->getViewNet()->removeFromAttributeCarrierInspected(junction);
2139  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2140  // Remove from grid and container
2141  myNet->removeGLObjectFromGrid(junction);
2142  myJunctions.erase(junction->getMicrosimID());
2143  myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2144  junction->decRef("GNENet::deleteSingleJunction");
2145  junction->setResponsible(true);
2146 }
2147 
2148 
2149 bool
2151  return (myEdgeTypes.count(edgeType->getID()) > 0);
2152 }
2153 
2154 
2155 void
2157  // get pointer to create edge frame
2158  const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2159  // insert in myEdgeTypes
2160  myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2161  // update edge selector
2162  if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
2163  myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2164  }
2165  // set current edge type inspected
2166  createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2167 }
2168 
2169 
2170 void
2172  // get pointer to create edge frame
2173  const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2174  // remove it from inspected elements and HierarchicalElementTree
2175  myNet->getViewNet()->removeFromAttributeCarrierInspected(edgeType);
2176  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2177  // remove from edge types
2178  myEdgeTypes.erase(edgeType->getMicrosimID());
2179  // check if this is the selected edge type in edgeSelector
2180  if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2181  createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2182  }
2183  // update edge selector
2184  createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2185 }
2186 
2187 
2188 void
2190  NBEdge* nbe = edge->getNBEdge();
2191  myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2192  // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2193  nbe->getFromNode()->addOutgoingEdge(nbe);
2194  nbe->getToNode()->addIncomingEdge(nbe);
2195  // register edge
2196  registerEdge(edge);
2197 }
2198 
2199 
2200 void
2202  // remove it from inspected elements and HierarchicalElementTree
2203  myNet->getViewNet()->removeFromAttributeCarrierInspected(edge);
2204  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2205  // remove edge from visual grid and container
2206  myNet->removeGLObjectFromGrid(edge);
2207  myEdges.erase(edge->getMicrosimID());
2208  // remove all lanes
2209  for (const auto& lane : edge->getLanes()) {
2210  deleteLane(lane);
2211  }
2212  // extract edge of district container
2213  myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2214  edge->decRef("GNENet::deleteSingleEdge");
2215  edge->setResponsible(true);
2216  // Remove refrences from GNEJunctions
2217  edge->getFromJunction()->removeOutgoingGNEEdge(edge);
2218  edge->getToJunction()->removeIncomingGNEEdge(edge);
2219  // get template editor
2220  GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
2221  // check if we have to remove template
2222  if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2223  templateEditor->setEdgeTemplate(nullptr);
2224  }
2225 }
2226 
2227 
2228 bool
2230  // first check that additional pointer is valid
2231  if (additional) {
2232  // get vector with this additional element type
2233  const auto& additionalElementTag = myAdditionals.at(additional->getTagProperty().getTag());
2234  // find demanElement in additionalElementTag
2235  return std::find(additionalElementTag.begin(), additionalElementTag.end(), additional) != additionalElementTag.end();
2236  } else {
2237  throw ProcessError("Invalid additional pointer");
2238  }
2239 }
2240 
2241 
2242 void
2244  // insert additional
2245  if (myAdditionals.at(additional->getTagProperty().getTag()).insert(additional).second == false) {
2246  throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2247  }
2248  // add element in grid
2249  if (additional->getTagProperty().isPlacedInRTree()) {
2250  myNet->addGLObjectIntoGrid(additional);
2251  }
2252  // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2253  if (myNet->isUpdateGeometryEnabled()) {
2254  additional->updateGeometry();
2255  }
2256  // additionals has to be saved
2257  myNet->requireSaveAdditionals(true);
2258 }
2259 
2260 
2261 void
2263  // find demanElement in additionalTag
2264  auto itFind = myAdditionals.at(additional->getTagProperty().getTag()).find(additional);
2265  // check if additional was previously inserted
2266  if (itFind == myAdditionals.at(additional->getTagProperty().getTag()).end()) {
2267  throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2268  }
2269  // remove it from inspected elements and HierarchicalElementTree
2270  myNet->getViewNet()->removeFromAttributeCarrierInspected(additional);
2271  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2272  // remove from container
2273  myAdditionals.at(additional->getTagProperty().getTag()).erase(itFind);
2274  // remove element from grid
2275  if (additional->getTagProperty().isPlacedInRTree()) {
2276  myNet->removeGLObjectFromGrid(additional);
2277  }
2278  // delete path element
2279  myNet->getPathManager()->removePath(additional);
2280  // additionals has to be saved
2281  myNet->requireSaveAdditionals(true);
2282 }
2283 
2284 
2285 bool
2287  // first check that shape pointer is valid
2288  if (shape) {
2289  // get vector with this shape element type
2290  const auto& shapeElementTag = myShapes.at(shape->getTagProperty().getTag());
2291  // find demanElement in shapeElementTag
2292  return std::find(shapeElementTag.begin(), shapeElementTag.end(), shape) != shapeElementTag.end();
2293  } else {
2294  throw ProcessError("Invalid shape pointer");
2295  }
2296 }
2297 
2298 
2299 void
2301  // insert shape
2302  if (myShapes.at(shape->getTagProperty().getTag()).insert(shape).second == false) {
2303  throw ProcessError(shape->getTagStr() + " with ID='" + shape->getID() + "' already exist");
2304  }
2305  // add element in grid
2306  myNet->addGLObjectIntoGrid(shape);
2307  // update geometry after insertion of shapes if myUpdateGeometryEnabled is enabled
2308  if (myNet->isUpdateGeometryEnabled()) {
2309  shape->updateGeometry();
2310  }
2311  // shapes has to be saved
2312  myNet->requireSaveAdditionals(true);
2313 }
2314 
2315 
2316 void
2318  // find demanElement in shapeTag
2319  auto itFind = myShapes.at(shape->getTagProperty().getTag()).find(shape);
2320  // check if shape was previously inserted
2321  if (itFind == myShapes.at(shape->getTagProperty().getTag()).end()) {
2322  throw ProcessError(shape->getTagStr() + " with ID='" + shape->getID() + "' wasn't previously inserted");
2323  }
2324  // remove it from inspected elements and HierarchicalElementTree
2325  myNet->getViewNet()->removeFromAttributeCarrierInspected(shape);
2326  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(shape);
2327  // remove it from container
2328  myShapes.at(shape->getTagProperty().getTag()).erase(itFind);
2329  // remove element from grid
2330  myNet->removeGLObjectFromGrid(shape);
2331  // shapes has to be saved
2332  myNet->requireSaveAdditionals(true);
2333 }
2334 
2335 
2336 void
2338  // insert TAZElement
2339  if (myTAZElements.at(TAZElement->getTagProperty().getTag()).insert(TAZElement).second == false) {
2340  throw ProcessError(TAZElement->getTagStr() + " with ID='" + TAZElement->getID() + "' already exist");
2341  }
2342  // add element in grid
2343  myNet->addGLObjectIntoGrid(TAZElement);
2344  // update geometry after insertion of TAZElements if myUpdateGeometryEnabled is enabled
2345  if (myNet->isUpdateGeometryEnabled()) {
2346  TAZElement->updateGeometry();
2347  }
2348  // TAZElements has to be saved
2349  myNet->requireSaveAdditionals(true);
2350 }
2351 
2352 
2353 void
2355  // find demanElement in TAZElementTag
2356  auto itFind = myTAZElements.at(TAZElement->getTagProperty().getTag()).find(TAZElement);
2357  // check if myTAZElements.at(TAZElement->getTagProperty().getTag()) was previously inserted
2358  if (itFind == myTAZElements.at(TAZElement->getTagProperty().getTag()).end()) {
2359  throw ProcessError(TAZElement->getTagStr() + " with ID='" + TAZElement->getID() + "' wasn't previously inserted");
2360  }
2361  // remove it from inspected elements and HierarchicalElementTree
2362  myNet->getViewNet()->removeFromAttributeCarrierInspected(TAZElement);
2363  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(TAZElement);
2364  // remove it from container
2365  myTAZElements.at(TAZElement->getTagProperty().getTag()).erase(itFind);
2366  // remove element from grid
2367  myNet->removeGLObjectFromGrid(TAZElement);
2368  // TAZElements has to be saved
2369  myNet->requireSaveAdditionals(true);
2370 }
2371 
2372 
2373 bool
2375  // first check that demandElement pointer is valid
2376  if (demandElement) {
2377  // get vector with this demand element type
2378  const auto& demandElementTag = myDemandElements.at(demandElement->getTagProperty().getTag());
2379  // find demanElement in demandElementTag
2380  return std::find(demandElementTag.begin(), demandElementTag.end(), demandElement) != demandElementTag.end();
2381  } else {
2382  throw ProcessError("Invalid demandElement pointer");
2383  }
2384 }
2385 
2386 
2387 void
2389  // insert in demandElements container
2390  if (myDemandElements.at(demandElement->getTagProperty().getTag()).insert(demandElement).second == false) {
2391  throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2392  }
2393  // add element in grid
2394  myNet->addGLObjectIntoGrid(demandElement);
2395  // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2396  if (myNet->isUpdateGeometryEnabled()) {
2397  demandElement->updateGeometry();
2398  }
2399  // demandElements has to be saved
2400  myNet->requireSaveDemandElements(true);
2401 }
2402 
2403 
2404 void
2406  // find demanElement in demandElementTag
2407  auto itFind = myDemandElements.at(demandElement->getTagProperty().getTag()).find(demandElement);
2408  // check if demandElement was previously inserted
2409  if (itFind == myDemandElements.at(demandElement->getTagProperty().getTag()).end()) {
2410  throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2411  }
2412  // remove it from inspected elements and HierarchicalElementTree
2413  myNet->getViewNet()->removeFromAttributeCarrierInspected(demandElement);
2414  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2415  // erase it from container
2416  myDemandElements.at(demandElement->getTagProperty().getTag()).erase(itFind);
2417  // remove element from grid
2418  myNet->removeGLObjectFromGrid(demandElement);
2419  // delete path element
2420  myNet->getPathManager()->removePath(demandElement);
2421  // demandElements has to be saved
2422  myNet->requireSaveDemandElements(true);
2423 }
2424 
2425 
2426 bool
2428  // first check that dataSet pointer is valid
2429  if (dataSet) {
2430  if (myDataSets.find(dataSet) != myDataSets.end()) {
2431  return true;
2432  } else {
2433  return false;
2434  }
2435  } else {
2436  throw ProcessError("Invalid dataSet pointer");
2437  }
2438 }
2439 
2440 
2441 void
2443  // Check if dataSet element exists before insertion
2444  if (myDataSets.insert(dataSet).second == false) {
2445  throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2446  }
2447  // dataSets has to be saved
2448  myNet->requireSaveDataElements(true);
2449  // update interval toolbar
2450  myNet->getViewNet()->getIntervalBar().updateIntervalBar();
2451 }
2452 
2453 
2454 void
2456  // find dataSet
2457  const auto itFind = myDataSets.find(dataSet);
2458  // first check that dataSet pointer is valid
2459  if (itFind == myDataSets.end()) {
2460  throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2461  }
2462  // remove it from inspected elements and HierarchicalElementTree
2463  myNet->getViewNet()->removeFromAttributeCarrierInspected(dataSet);
2464  myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2465  // obtain demand element and erase it from container
2466  myDataSets.erase(itFind);
2467  // dataSets has to be saved
2468  myNet->requireSaveDataElements(true);
2469  // update interval toolbar
2470  myNet->getViewNet()->getIntervalBar().updateIntervalBar();
2471 }
2472 
2473 // ---------------------------------------------------------------------------
2474 // GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
2475 // ---------------------------------------------------------------------------
2476 
2478  GNEChange(Supermode::NETWORK, true, false),
2479  myTllcont(tllcont),
2480  myReplaced(replaced),
2481  myBy(by) {
2482 }
2483 
2484 
2486 
2487 
2488 void
2490  // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2491  myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
2492 }
2493 
2494 
2495 void
2497  // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2498  myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
2499 }
2500 
2501 
2502 std::string
2504  return "Redo replace in TLS";
2505 }
2506 
2507 
2508 std::string
2510  return "Undo replace in TLS";
2511 }
2512 
2513 
2514 bool
2516  return myReplaced != myBy;
2517 }
2518 
2519 /****************************************************************************/
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
@ DATA
Data mode (edgeData, LaneData etc..)
@ DEMAND
Demand mode (Routes, Vehicles etc..)
unsigned int GUIGlID
Definition: GUIGlObject.h:40
GUISelectedStorage gSelected
A global holder of selected objects.
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:290
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
long long int SUMOTime
Definition: SUMOTime.h:32
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_PEDTYPE_ID
const std::set< std::string > DEFAULT_VTYPES
const std::string DEFAULT_VTYPE_ID
const std::string DEFAULT_CONTAINERTYPE_ID
const std::string DEFAULT_BIKETYPE_ID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions (used in NETEDIT)
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_TAG_DATAINTERVAL
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_LANECALIBRATOR
A calibrator placed over lane (used in netedit)
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route (used in NETEDIT)
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions (used in NETEDIT)
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_CONNECTION
connectio between two lanes
@ SUMO_TAG_PARKING_AREA
A parking area.
@ GNE_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_MEANDATA_EDGE
an edge based mean data detector
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ GNE_TAG_POILANE
Point of interest over Lane.
@ SUMO_TAG_DATASET
@ SUMO_TAG_E1DETECTOR
an e1 detector
@ SUMO_TAG_PERSON
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_E3DETECTOR
an e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ 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
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
const std::string & getID() const
get ID
virtual void updateGeometry()=0
update pre-computed geometry information
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
virtual Position getPositionInView() const =0
Returns position of additional in view.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
static const std::vector< GNETagProperties > getTagPropertiesByType(const int tagPropertyCategory)
get tagProperties associated to the given GNETagProperties::TagType (NETWORKELEMENT,...
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 tagProperty associated with this Attribute Carrier
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:64
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:42
An Element which don't belongs to GNENet but has influency in the simulation.
const std::string & getID() const
get ID
const std::string & getID() const
get ID
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:53
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:77
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition: GNEEdge.cpp:1138
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:435
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:82
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:782
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:1946
const std::string & getID() const
return ID of object
An Element which don't belongs to GNENet but has influency in the simulation.
const std::string & getID() const
get ID
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
void setEdgeTemplate(const GNEEdge *edge)
set edge template
GNEEdgeTemplate * getEdgeTemplate() const
get edge template (to copy attributes from)
void setResponsible(bool newVal)
set responsibility for deleting internal structures
void updateGeometry()
update pre-computed geometry information (including crossings)
Definition: GNEJunction.cpp:95
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
NBNode * getNBNode() const
Return net build node.
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:797
GNEAttributeCarrier * retrieveAttributeCarrier(const GUIGlID id, bool hardFail=true) const
get a single attribute carrier based on a GLID
int getNumberOfSelectedAdditionals() const
get number of selected additionals
const std::map< SumoXMLTag, std::set< GNEGenericData * > > & getGenericDatas() const
get all generic datas
const std::set< GNELane * > & getLanes() const
get lanes
const std::set< GNEConnection * > & getConnections() const
get connections
int getNumberOfSelectedConnections() const
get number of selected connections
void deleteDataSet(GNEDataSet *dataSet)
delete demand element element of GNENet container
GNETAZElement * retrieveTAZElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named TAZElement.
void insertLane(GNELane *lane)
insert lane
int getNumberOfSelectedEdgeRelDatas() const
get number of selected edge rel datas
int getNumberOfSelectedCrossings() const
get number of selected crossings
GNEEdgeType * registerEdgeType(GNEEdgeType *edgeType)
registers a edge in GNENet containers
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
std::map< SumoXMLTag, std::set< GNEDemandElement * > > myDemandElements
map with the tag and pointer to demand elements of net
Definition: GNENetHelper.h:737
const std::map< SumoXMLTag, std::set< GNEDemandElement * > > & getDemandElements() const
get demand elements
void insertDataSet(GNEDataSet *dataSet)
Insert a demand element element int GNENet container.
bool dataSetExist(GNEDataSet *dataSet) const
return true if given demand element exist
int getNumberOfTAZElements() const
Returns the number of TAZElements of the net.
int getNumberOfSelectedRides() const
get number of selected rides
void clearDemandElements()
clear demand elements
void insertGenericData(GNEGenericData *genericData)
insert generic data
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with GNENet containers
bool demandElementExist(GNEDemandElement *demandElement) const
return true if given demand element exist
GNEShape * retrieveShape(SumoXMLTag, const std::string &id, bool hardFail=true) const
Returns the named shape.
void deleteShape(GNEShape *shape)
delete shape element of GNENet container
int getNumberOfSelectedPersonTrips() const
get number of selected person trips
std::string generateDemandElementID(SumoXMLTag tag) const
generate demand element id
void remapJunctionAndEdgeIds()
remap junction and edge IDs
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(SumoXMLTag tag=SUMO_TAG_NOTHING)
get the attribute carriers based on Type
void clearEdgeTypes()
clear edgeTypes
int getNumberOfSelectedTranships() const
get number of selected tranships
int getNumberOfSelectedVehicles() const
get number of selected vehicles
int getNumberOfSelectedWalks() const
get number of selected walks
void deleteDemandElement(GNEDemandElement *demandElement)
delete demand element element of GNENet container
void deleteEdgeType(GNEEdgeType *edgeType)
deletes edgeType
std::string generateDataSetID(const std::string &prefix) const
generate data set id
void deleteConnection(GNEConnection *connection)
delete connection
void clearAdditionals()
clear additionals
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
std::vector< GNEGenericData * > retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end)
retrieve generic datas within the given interval
std::set< std::string > retrieveGenericDataParameters(const std::string &genericDataTag, const double begin, const double end) const
return a set of parameters for the given data Interval
std::map< SumoXMLTag, std::set< GNEGenericData * > > myGenericDatas
map with the tag and pointer to all generic datas
Definition: GNENetHelper.h:746
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
void insertShape(GNEShape *shape)
Insert a shape element int GNENet container.
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction in GNENet containers
const std::set< GNEDataSet * > & getDataSets() const
get demand elements
bool isNetworkElementAroundShape(GNEAttributeCarrier *AC, const PositionVector &shape) const
check if shape of given AC (network element) is around the given shape
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
void updateJunctionID(GNEJunction *junction, const std::string &newID)
update junction ID in container
void deleteGenericData(GNEGenericData *genericData)
delete generic data
void insertCrossing(GNECrossing *crossing)
insert crossing
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
int getNumberOfSelectedTAZs() const
get number of selected TAZs
int getNumberOfSelectedTransport() const
get number of selected transports
GNEDataInterval * retrieveDataInterval(GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
std::vector< GNELane * > getSelectedLanes() const
get selected lanes
void insertConnection(GNEConnection *connection)
insert connection
std::vector< GNEAdditional * > getSelectedAdditionals() const
get selected additionals
int getNumberOfSelectedJunctions() const
get number of selected junctions
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
std::string generateTAZElementID(SumoXMLTag TAZElementTag) const
generate TAZElement ID
int getNumberOfSelectedDemandElements() const
get number of selected demand elements
int getNumberOfSelectedPersons() const
get number of selected persons
GNEEdgeType * retrieveEdgeType(const std::string &id, bool hardFail=true) const
get edge type by id
std::map< SumoXMLTag, std::set< GNEShape * > > myShapes
map with the tag and pointer to shape elements of net
Definition: GNENetHelper.h:731
int getNumberOfSelectedRoutes() const
get number of selected routes
void addDefaultVTypes()
add default VTypes
int getNumberOfShapes() const
Returns the number of shapes.
int getNumberOfSelectedPOIs() const
get number of selected POIs
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
const std::map< SumoXMLTag, std::set< GNETAZElement * > > & getTAZElements() const
get TAZElements
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
const std::set< GNEDataInterval * > & getDataIntervals() const
get all data intervals of network
void deleteAdditional(GNEAdditional *additional)
delete additional element of GNENet container
int getNumberOfDemandElements() const
Return the number of demand elements.
int getNumberOfSelectedPolygons() const
get number of selected polygons
std::vector< GNEJunction * > getSelectedJunctions() const
return selected junctions
std::vector< GNETAZElement * > getSelectedTAZElements() const
get selected TAZElements
std::string generateShapeID(SumoXMLTag shapeTag) const
generate Shape ID
const std::map< SumoXMLTag, std::set< GNEShape * > > & getShapes() const
get shapes
int getNumberOfAdditionals() const
get number of additonals
const std::set< GNECrossing * > & getCrossings() const
get crossings
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element element int GNENet container.
const std::map< SumoXMLTag, std::set< GNEAdditional * > > & getAdditionals() const
get additionals
std::vector< GNEShape * > getSelectedShapes()
get selected shapes
void clearTAZElements()
clear TAZElements
void updateEdgeID(GNEEdge *edge, const std::string &newID)
update edge ID in container
std::vector< GNECrossing * > getSelectedCrossings() const
return all selected crossings
int getNumberOfSelectedLanes() const
get number of selected lanes
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
int getNumberOfSelectedEdgeDatas() const
get number of selected edge datas
void updateEdgeTypeID(GNEEdgeType *edgeType, const std::string &newID)
update edgeType ID in container
std::map< SumoXMLTag, std::set< GNETAZElement * > > myTAZElements
map with the tag and pointer to TAZElement elements of net
Definition: GNENetHelper.h:734
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 insertEdgeType(GNEEdgeType *edgeType)
inserts a single edgeType into the net and into the underlying netbuild-container
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
int getNumberOfSelectedEdgeTAZRel() const
get number of selected edge TAZ Rels
std::vector< GNEGenericData * > getSelectedGenericDatas() const
get selected generic datas
void deleteLane(GNELane *lane)
delete lane
void insertJunction(GNEJunction *junction)
std::vector< GNEEdge * > getSelectedEdges() const
return all edges
std::map< SumoXMLTag, std::set< GNEAdditional * > > myAdditionals
map with the tag and pointer to additional elements of net
Definition: GNENetHelper.h:728
void insertDataInterval(GNEDataInterval *dataInterval)
insert data interval
const std::map< std::string, GNEJunction * > & getJunctions() const
get junctions
int getNumberOfSelectedEdges() const
get number of selected edges
const std::map< std::string, GNEEdgeType * > & getEdgeTypes() const
map with the ID and pointer to edgeTypes of net
GNECrossing * retrieveCrossing(GNEAttributeCarrier *AC, bool hardFail=true) const
get Crossing by AC
bool TAZElementExist(const GNETAZElement *TAZElement) const
return true if given TAZElement exist
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
std::vector< GNEConnection * > getSelectedConnections() const
get selected connections
void clearJunctions()
clear junctions
void deleteCrossing(GNECrossing *crossing)
delete crossing
GNEGenericData * retrieveGenericData(GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the generic data.
GNEDemandElement * getDefaultType() const
get default type
bool edgeTypeExist(const GNEEdgeType *edgeType) const
std::vector< GNEAttributeCarrier * > getSelectedAttributeCarriers(const bool ignoreCurrentSupermode)
get all selected attribute carriers (or only relative to current supermode
int getNumberOfSelectedStops() const
get number of selected stops
AttributeCarriers(GNENet *net)
constructor
std::string generateEdgeTypeID() const
generate edgeType id
void deleteDataInterval(GNEDataInterval *dataInterval)
delete data interval
GNEConnection * retrieveConnection(const std::string &id, bool hardFail=true) const
get Connection by id
int getNumberOfSelectedContainers() const
get number of selected containers
std::string undoName() const
undo name
GNEChange_ReplaceEdgeInTLS(NBTrafficLightLogicCont &tllcont, NBEdge *replaced, NBEdge *by)
constructor
std::string redoName() const
get Redo name
bool trueChange()
wether original and new value differ
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
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:43
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
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
Definition: GNETAZ.h:34
bool isShape() const
return true if tag correspond to a shape
bool isTAZElement() const
return true if tag correspond to a TAZ element
bool isNetworkElement() const
return true if tag correspond to a network element
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
const PositionVector & getShape() const
The shape of the 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.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
The representation of a single edge during network building.
Definition: NBEdge.h:91
const std::string & getID() const
Definition: NBEdge.h:1465
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:541
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:534
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition: NBNode.cpp:459
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition: NBNode.cpp:3499
int buildCrossings()
build pedestrian crossings
Definition: NBNode.cpp:2782
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition: NBNode.cpp:469
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:2418
const Position & getPosition() const
Definition: NBNode.h:248
A container for traffic light definitions and built programs.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A storage for options typed value containers)
Definition: OptionsCont.h:89
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
C++ TraCI client API implementation.
Definition: GUI.h:31
double z() const
Returns the z-position.
Definition: Position.h:65
A list of positions.
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID