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
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
38
39#include "GNENetHelper.h"
40
41// ---------------------------------------------------------------------------
42// GNENetHelper::AttributeCarriers - methods
43// ---------------------------------------------------------------------------
44
46 myNet(net),
47 myStopIndex(0) {
48 // fill additionals with tags
49 auto additionalTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::ADDITIONALELEMENT |
50 GNETagProperties::TagType::SHAPE | GNETagProperties::TagType::SYMBOL | GNETagProperties::TagType::TAZELEMENT | GNETagProperties::TagType::WIRE);
51 for (const auto& additionalTag : additionalTags) {
52 myAdditionals.insert(std::make_pair(additionalTag.getTag(), std::set<GNEAdditional*>()));
53 }
54 // fill demand elements with tags
55 auto demandElementTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::DEMANDELEMENT);
56 for (const auto& demandElementTag : demandElementTags) {
57 myDemandElements.insert(std::make_pair(demandElementTag.getTag(), std::set<GNEDemandElement*>()));
58 }
59 auto stopTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::STOP);
60 for (const auto& stopTag : stopTags) {
61 myDemandElements.insert(std::make_pair(stopTag.getTag(), std::set<GNEDemandElement*>()));
62 }
63 // fill data elements with tags
64 auto genericDataElementTags = GNEAttributeCarrier::getTagPropertiesByType(GNETagProperties::TagType::GENERICDATA);
65 for (const auto& genericDataElementTag : genericDataElementTags) {
66 myGenericDatas.insert(std::make_pair(genericDataElementTag.getTag(), std::set<GNEGenericData*>()));
67 }
68}
69
70
72 // Drop EdgeTypes
73 for (const auto& edgeType : myEdgeTypes) {
74 edgeType.second->decRef("GNENetHelper::~GNENet");
75 // show extra information for tests
76 WRITE_DEBUG("Deleting unreferenced " + edgeType.second->getTagStr() + " '" + edgeType.second->getID() + "' in AttributeCarriers destructor");
77 delete edgeType.second;
78 }
79 // Drop Edges
80 for (const auto& edge : myEdges) {
81 edge.second->decRef("GNENetHelper::~GNENet");
82 // show extra information for tests
83 WRITE_DEBUG("Deleting unreferenced " + edge.second->getTagStr() + " '" + edge.second->getID() + "' in AttributeCarriers destructor");
84 delete edge.second;
85 }
86 // Drop myJunctions
87 for (const auto& junction : myJunctions) {
88 junction.second->decRef("GNENetHelper::~GNENet");
89 // show extra information for tests
90 WRITE_DEBUG("Deleting unreferenced " + junction.second->getTagStr() + " '" + junction.second->getID() + "' in AttributeCarriers destructor");
91 delete junction.second;
92 }
93 // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
94 for (const auto& additionalTag : myAdditionals) {
95 for (const auto& additional : additionalTag.second) {
96 // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
97 additional->decRef();
98 // show extra information for tests
99 WRITE_DEBUG("Deleting unreferenced " + additional->getTagStr() + " in AttributeCarriers destructor");
100 delete additional;
101 }
102 }
103 // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
104 for (const auto& demandElementTag : myDemandElements) {
105 for (const auto& demandElement : demandElementTag.second) {
106 // decrease reference manually (because it was increased manually in GNERouteHandler)
107 demandElement->decRef();
108 // show extra information for tests
109 if (demandElement->getTagProperty().isVehicleType()) {
110 // special case for default VTypes
111 if (DEFAULT_VTYPES.count(demandElement->getID()) == 0) {
112 WRITE_DEBUG("Deleting unreferenced " + demandElement->getTagStr() + " in AttributeCarriers destructor");
113 }
114 } else {
115 WRITE_DEBUG("Deleting unreferenced " + demandElement->getTagStr() + " in AttributeCarriers destructor");
116 }
117 delete demandElement;
118 }
119 }
120 // Drop dataSets (Only used for TAZElements that were inserted without using GNEChange_DataSets)
121 for (const auto& dataSet : myDataSets) {
122 // decrease reference manually (because it was increased manually in GNEDataHandler)
123 dataSet->decRef();
124 // show extra information for tests
125 WRITE_DEBUG("Deleting unreferenced " + dataSet->getTagStr() + " in AttributeCarriers destructor");
126 delete dataSet;
127 }
128}
129
130
131void
133 std::map<std::string, GNEEdge*> newEdgeMap;
134 std::map<std::string, GNEJunction*> newJunctionMap;
135 // fill newEdgeMap
136 for (const auto& edge : myEdges) {
137 edge.second->setMicrosimID(edge.second->getNBEdge()->getID());
138 newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
139 }
140 for (const auto& junction : myJunctions) {
141 newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
142 junction.second->setMicrosimID(junction.second->getNBNode()->getID());
143 }
144 myEdges = newEdgeMap;
145 myJunctions = newJunctionMap;
146}
147
148
149bool
151 // check what type of AC
152 if (AC->getTagProperty().getTag() == SUMO_TAG_JUNCTION) {
153 // Junction
154 const GNEJunction* junction = myJunctions.at(AC->getID());
155 if (junction->getNBNode()->getShape().size() == 0) {
156 return shape.around(junction->getNBNode()->getCenter());
157 } else {
158 return (shape.overlapsWith(junction->getNBNode()->getShape()));
159 }
160 } else if (AC->getTagProperty().getTag() == SUMO_TAG_EDGE) {
161 // Edge
162 for (const auto& lane : myEdges.at(AC->getID())->getLanes()) {
163 if (shape.overlapsWith(lane->getLaneShape())) {
164 return true;
165 }
166 }
167 return false;
168 } else if (AC->getTagProperty().getTag() == SUMO_TAG_LANE) {
169 // Lane
170 return shape.overlapsWith(retrieveLane(AC->getID())->getLaneShape());
171 } else if (AC->getTagProperty().getTag() == SUMO_TAG_CONNECTION) {
172 // connection
173 return shape.overlapsWith(dynamic_cast<GNEConnection*>(AC)->getConnectionShape());
174 } else if (AC->getTagProperty().getTag() == SUMO_TAG_CROSSING) {
175 // crossing
176 return shape.overlapsWith(dynamic_cast<GNECrossing*>(AC)->getCrossingShape());
177 } else if (AC->getTagProperty().isAdditionalElement()) {
178 // Additional (including shapes and TAZs
179 const GNEAdditional* additional = retrieveAdditional(AC);
180 if (additional->getAdditionalGeometry().getShape().size() <= 1) {
181 return shape.around(additional->getPositionInView());
182 } else {
183 return shape.overlapsWith(additional->getAdditionalGeometry().getShape());
184 }
185 } else {
186 return false;
187 }
188}
189
190
193 // obtain blocked GUIGlObject
195 // Make sure that object exists
196 if (object != nullptr) {
197 // unblock and try to parse to AttributeCarrier
199 GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
200 // If was successfully parsed, return it
201 if (ac == nullptr) {
202 throw ProcessError("GUIGlObject does not match the declared type");
203 } else {
204 return ac;
205 }
206 } else if (hardFail) {
207 throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
208 } else {
209 return nullptr;
210 }
211}
212
213
214std::vector<GNEAttributeCarrier*>
216 std::vector<GNEAttributeCarrier*> result;
217 if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_JUNCTION)) {
218 for (const auto& junction : myJunctions) {
219 result.push_back(junction.second);
220 }
221 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_EDGE)) {
222 for (const auto& edge : myEdges) {
223 result.push_back(edge.second);
224 }
225 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_LANE)) {
226 for (const auto& lane : myLanes) {
227 result.push_back(lane);
228 }
229 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CONNECTION)) {
230 for (const auto& connection : myConnections) {
231 result.push_back(connection);
232 }
233 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CROSSING)) {
234 for (const auto& crossing : myCrossings) {
235 result.push_back(crossing);
236 }
237 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_WALKINGAREA)) {
238 for (const auto& walkingArea : myWalkingAreas) {
239 result.push_back(walkingArea);
240 }
241 } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isAdditionalElement())) {
242 for (const auto& additional : myAdditionals.at(tag)) {
243 result.push_back(additional);
244 }
245 } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isDemandElement())) {
246 for (const auto& demandElemet : myDemandElements.at(tag)) {
247 result.push_back(demandElemet);
248 }
249 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATASET)) {
250 for (const auto& dataSet : myDataSets) {
251 result.push_back(dataSet);
252 }
253 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATAINTERVAL)) {
254 for (const auto& dataInterval : myDataIntervals) {
255 result.push_back(dataInterval);
256 }
257 } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isGenericData())) {
258 for (const auto& genericData : myGenericDatas.at(tag)) {
259 result.push_back(genericData);
260 }
261 }
262 return result;
263}
264
265
266std::vector<GNEAttributeCarrier*>
268 std::vector<GNEAttributeCarrier*> result;
269 // continue depending of supermode
270 if (supermode == Supermode::NETWORK) {
271 // network
272 for (const auto& junction : myJunctions) {
273 if (!onlySelected || junction.second->isAttributeCarrierSelected()) {
274 result.push_back(junction.second);
275 }
276 }
277 for (const auto& crossing : myCrossings) {
278 if (!onlySelected || crossing->isAttributeCarrierSelected()) {
279 result.push_back(crossing);
280 }
281 }
282 for (const auto& edge : myEdges) {
283 if (!onlySelected || edge.second->isAttributeCarrierSelected()) {
284 result.push_back(edge.second);
285 }
286 }
287 for (const auto& lane : myLanes) {
288 if (!onlySelected || lane->isAttributeCarrierSelected()) {
289 result.push_back(lane);
290 }
291 }
292 for (const auto& connection : myConnections) {
293 if (!onlySelected || connection->isAttributeCarrierSelected()) {
294 result.push_back(connection);
295 }
296 }
297 for (const auto& additionalSet : myAdditionals) {
298 for (const auto& additional : additionalSet.second) {
299 if (!onlySelected || additional->isAttributeCarrierSelected()) {
300 result.push_back(additional);
301 }
302 }
303 }
304 } else if (supermode == Supermode::DEMAND) {
305 for (const auto& demandElementSet : myDemandElements) {
306 for (const auto& demandElement : demandElementSet.second) {
307 if (!onlySelected || demandElement->isAttributeCarrierSelected()) {
308 result.push_back(demandElement);
309 }
310 }
311 }
312 } else if (supermode == Supermode::DATA) {
313 for (const auto& dataSet : myDataSets) {
314 if (!onlySelected || dataSet->isAttributeCarrierSelected()) {
315 result.push_back(dataSet);
316 }
317 }
318 for (const auto& dataInterval : myDataIntervals) {
319 if (!onlySelected || dataInterval->isAttributeCarrierSelected()) {
320 result.push_back(dataInterval);
321 }
322 }
323 for (const auto& genericDataSet : myGenericDatas) {
324 for (const auto& genericData : genericDataSet.second) {
325 if (!onlySelected || genericData->isAttributeCarrierSelected()) {
326 result.push_back(genericData);
327 }
328 }
329 }
330 }
331 return result;
332}
333
334
335std::vector<GNEAttributeCarrier*>
337 // get modes
338 const auto& editModes = myNet->getViewNet()->getEditModes();
339 // declare vector to save result
340 std::vector<GNEAttributeCarrier*> result;
341 result.reserve(gSelected.getSelected().size());
342 // iterate over all elements of global selection
343 for (const auto& glID : gSelected.getSelected()) {
344 // obtain AC
345 GNEAttributeCarrier* AC = retrieveAttributeCarrier(glID, false);
346 // check if attribute carrier exist and is selected
347 if (AC && AC->isAttributeCarrierSelected()) {
348 bool insert = false;
349 if (ignoreCurrentSupermode) {
350 insert = true;
351 } else if (editModes.isCurrentSupermodeNetwork() && (AC->getTagProperty().isNetworkElement() || AC->getTagProperty().isAdditionalElement())) {
352 insert = true;
353 } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty().isDemandElement()) {
354 insert = true;
355 } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty().isDataElement()) {
356 insert = true;
357 }
358 if (insert) {
359 result.push_back(AC);
360 }
361 }
362 }
363 return result;
364}
365
366
368GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
369 if (myJunctions.count(id)) {
370 return myJunctions.at(id);
371 } else if (hardFail) {
372 // If junction wasn't found, throw exception
373 throw UnknownElement("Junction " + id);
374 } else {
375 return nullptr;
376 }
377}
378
379
380const std::map<std::string, GNEJunction*>&
382 return myJunctions;
383}
384
385
386std::vector<GNEJunction*>
388 std::vector<GNEJunction*> result;
389 // returns junctions depending of selection
390 for (const auto& junction : myJunctions) {
391 if (junction.second->isAttributeCarrierSelected()) {
392 result.push_back(junction.second);
393 }
394 }
395 return result;
396}
397
398
401 // increase reference
402 junction->incRef("GNENet::registerJunction");
403 junction->setResponsible(false);
404 myJunctions[junction->getMicrosimID()] = junction;
405 // expand net boundary
406 myNet->expandBoundary(junction->getCenteringBoundary());
407 // add edge into grid
408 myNet->addGLObjectIntoGrid(junction);
409 // update geometry
410 junction->updateGeometry();
411 // add z in net boundary
412 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
413 return junction;
414}
415
416
417void
419 myJunctions.clear();
420}
421
422
423void
425 if (myJunctions.count(junction->getID()) == 0) {
426 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
427 } else if (myJunctions.count(newID) != 0) {
428 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
429 } else {
430 // remove junction from container
431 myJunctions.erase(junction->getNBNode()->getID());
432 // rename in NetBuilder
433 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
434 // update microsim ID
435 junction->setMicrosimID(newID);
436 // add it into myJunctions again
437 myJunctions[junction->getID()] = junction;
438 // build crossings
439 junction->getNBNode()->buildCrossings();
440 // net has to be saved
441 myNet->requireSaveNet(true);
442 }
443}
444
445
446int
448 int counter = 0;
449 for (const auto& junction : myJunctions) {
450 if (junction.second->isAttributeCarrierSelected()) {
451 counter++;
452 }
453 }
454 return counter;
455}
456
457
460 // cast crossing
461 GNECrossing* crossing = dynamic_cast<GNECrossing*>(AC);
462 if (crossing && (myCrossings.count(crossing) > 0)) {
463 return crossing;
464 } else if (hardFail) {
465 throw UnknownElement("Crossing " + AC->getID());
466 } else {
467 return nullptr;
468 }
469}
470
471
472const std::set<GNECrossing*>&
474 return myCrossings;
475}
476
477
478std::vector<GNECrossing*>
480 std::vector<GNECrossing*> result;
481 // iterate over crossings
482 for (const auto& crossing : myCrossings) {
483 if (crossing->isAttributeCarrierSelected()) {
484 result.push_back(crossing);
485 }
486 }
487 return result;
488}
489
490
491void
493 if (myCrossings.insert(crossing).second == false) {
494 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
495 }
496}
497
498
499void
501 const auto finder = myCrossings.find(crossing);
502 if (finder == myCrossings.end()) {
503 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
504 } else {
505 myCrossings.erase(finder);
506 }
507}
508
509
510int
512 int counter = 0;
513 for (const auto& crossing : myCrossings) {
514 if (crossing->isAttributeCarrierSelected()) {
515 counter++;
516 }
517 }
518 return counter;
519}
520
521
524 // cast walkingArea
525 GNEWalkingArea* walkingArea = dynamic_cast<GNEWalkingArea*>(AC);
526 if (walkingArea && (myWalkingAreas.count(walkingArea) > 0)) {
527 return walkingArea;
528 } else if (hardFail) {
529 throw UnknownElement("WalkingArea " + AC->getID());
530 } else {
531 return nullptr;
532 }
533}
534
535
536const std::set<GNEWalkingArea*>&
538 return myWalkingAreas;
539}
540
541
542std::vector<GNEWalkingArea*>
544 std::vector<GNEWalkingArea*> result;
545 // iterate over walkingAreas
546 for (const auto& walkingArea : myWalkingAreas) {
547 if (walkingArea->isAttributeCarrierSelected()) {
548 result.push_back(walkingArea);
549 }
550 }
551 return result;
552}
553
554
555void
557 if (myWalkingAreas.insert(walkingArea).second == false) {
558 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
559 }
560}
561
562
563void
565 const auto finder = myWalkingAreas.find(walkingArea);
566 if (finder == myWalkingAreas.end()) {
567 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
568 } else {
569 myWalkingAreas.erase(finder);
570 }
571}
572
573
574int
576 int counter = 0;
577 for (const auto& walkingArea : myWalkingAreas) {
578 if (walkingArea->isAttributeCarrierSelected()) {
579 counter++;
580 }
581 }
582 return counter;
583}
584
585
587GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
588 if (myEdgeTypes.count(id) > 0) {
589 return myEdgeTypes.at(id);
590 } else if (hardFail) {
591 // If edge wasn't found, throw exception
592 throw UnknownElement("EdgeType " + id);
593 } else {
594 return nullptr;
595 }
596}
597
598
601 // increase reference
602 edgeType->incRef("GNENet::registerEdgeType");
603 // add it in container
604 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
605 return edgeType;
606}
607
608
609const std::map<std::string, GNEEdgeType*>&
611 return myEdgeTypes;
612}
613
614
616 myEdgeTypes.clear();
617}
618
619
620void
622 if (myEdgeTypes.count(edgeType->getID()) == 0) {
623 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
624 } else if (myEdgeTypes.count(newID) != 0) {
625 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
626 } else {
627 // remove edgeType from container
628 myEdgeTypes.erase(edgeType->getID());
629 // rename in typeCont
630 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
631 // update microsim ID
632 edgeType->setMicrosimID(newID);
633 // add it into myEdgeTypes again
634 myEdgeTypes[edgeType->getID()] = edgeType;
635 // net has to be saved
636 myNet->requireSaveNet(true);
637 }
638}
639
640
641std::string
643 int counter = 0;
644 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
645 counter++;
646 }
647 return ("edgeType_" + toString(counter));
648}
649
650
651GNEEdge*
652GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
653 if (myEdges.count(id) > 0) {
654 return myEdges.at(id);
655 } else if (hardFail) {
656 // If edge wasn't found, throw exception
657 throw UnknownElement("Edge " + id);
658 } else {
659 return nullptr;
660 }
661}
662
663
664std::vector<GNEEdge*>
666 if ((from == nullptr) || (to == nullptr)) {
667 throw UnknownElement("Junctions cannot be nullptr");
668 }
669 std::vector<GNEEdge*> edges;
670 // iterate over Junctions
671 for (const auto& edge : myEdges) {
672 if ((edge.second->getFromJunction() == from) && (edge.second->getToJunction() == to)) {
673 edges.push_back(edge.second);
674 }
675 }
676 return edges;
677}
678
679
680const std::map<std::string, GNEEdge*>&
682 return myEdges;
683}
684
685
686std::vector<GNEEdge*>
688 std::vector<GNEEdge*> result;
689 // returns edges depending of selection
690 for (const auto& edge : myEdges) {
691 if (edge.second->isAttributeCarrierSelected()) {
692 result.push_back(edge.second);
693 }
694 }
695 return result;
696}
697
698
699GNEEdge*
701 edge->incRef("GNENet::registerEdge");
702 edge->setResponsible(false);
703 // add edge to internal container of GNENet
704 myEdges[edge->getMicrosimID()] = edge;
705 // expand edge boundary
706 myNet->expandBoundary(edge->getCenteringBoundary());
707 // add edge into grid
708 myNet->addGLObjectIntoGrid(edge);
709 // insert all lanes
710 for (const auto& lane : edge->getLanes()) {
711 insertLane(lane);
712 }
713 // Add references into GNEJunctions
714 edge->getFromJunction()->addOutgoingGNEEdge(edge);
715 edge->getToJunction()->addIncomingGNEEdge(edge);
716 return edge;
717}
718
719
721 myEdges.clear();
722}
723
724
725void
727 if (myEdges.count(edge->getID()) == 0) {
728 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
729 } else if (myEdges.count(newID) != 0) {
730 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
731 } else {
732 // remove edge from container
733 myEdges.erase(edge->getNBEdge()->getID());
734 // rename in NetBuilder
735 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
736 // update microsim ID
737 edge->setMicrosimID(newID);
738 // add it into myEdges again
739 myEdges[edge->getID()] = edge;
740 // rename all connections related to this edge
741 for (const auto& lane : edge->getLanes()) {
742 lane->updateConnectionIDs();
743 }
744 // net has to be saved
745 myNet->requireSaveNet(true);
746 }
747}
748
749
750int
752 int counter = 0;
753 for (const auto& edge : myEdges) {
754 if (edge.second->isAttributeCarrierSelected()) {
755 counter++;
756 }
757 }
758 return counter;
759}
760
761
762GNELane*
763GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
764 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
765 const GNEEdge* edge = retrieveEdge(edge_id, false);
766 if (edge != nullptr) {
767 GNELane* lane = nullptr;
768 // search lane in lane's edges
769 for (auto laneIt : edge->getLanes()) {
770 if (laneIt->getID() == id) {
771 lane = laneIt;
772 }
773 }
774 // throw exception or return nullptr if lane wasn't found
775 if (lane == nullptr) {
776 if (hardFail) {
777 // Throw exception if hardFail is enabled
778 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
779 }
780 } else {
781 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
782 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
783 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getLanes().size()) {
784 return edge->getLanes().at(lane->getIndex() + 1);
785 }
786 return lane;
787 }
788 } else if (hardFail) {
789 // Throw exception if hardFail is enabled
790 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
791 }
792 return nullptr;
793}
794
795
796GNELane*
798 // cast lane
799 GNELane* lane = dynamic_cast<GNELane*>(AC);
800 if (lane && (myLanes.count(lane) > 0)) {
801 return lane;
802 } else if (hardFail) {
803 throw UnknownElement("Lane " + AC->getID());
804 } else {
805 return nullptr;
806 }
807}
808
809
810const std::set<GNELane*>&
812 return myLanes;
813}
814
815
816std::vector<GNELane*>
818 std::vector<GNELane*> result;
819 // returns lanes depending of selection
820 for (const auto& lane : myLanes) {
821 if (lane->isAttributeCarrierSelected()) {
822 result.push_back(lane);
823 }
824 }
825 return result;
826}
827
828
829void
831 if (myLanes.insert(lane).second == false) {
832 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
833 }
834}
835
836
837void
839 const auto finder = myLanes.find(lane);
840 if (finder == myLanes.end()) {
841 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
842 } else {
843 myLanes.erase(finder);
844 }
845}
846
847
848int
850 int counter = 0;
851 for (const auto& lane : myLanes) {
852 if (lane->isAttributeCarrierSelected()) {
853 counter++;
854 }
855 }
856 return counter;
857}
858
859
861GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
862 // iterate over connections
863 for (const auto& connection : myConnections) {
864 if (connection->getID() == id) {
865 return connection;
866 }
867 }
868 if (hardFail) {
869 // If POI wasn't found, throw exception
870 throw UnknownElement("Connection " + id);
871 } else {
872 return nullptr;
873 }
874}
875
876
879 // cast connection
880 GNEConnection* connection = dynamic_cast<GNEConnection*>(AC);
881 if (connection && (myConnections.count(connection) > 0)) {
882 return connection;
883 } else if (hardFail) {
884 throw UnknownElement("Connection " + AC->getID());
885 } else {
886 return nullptr;
887 }
888}
889
890
891const std::set<GNEConnection*>&
893 return myConnections;
894}
895
896
897std::vector<GNEConnection*>
899 std::vector<GNEConnection*> result;
900 // returns connections depending of selection
901 for (const auto& connection : myConnections) {
902 if (connection->isAttributeCarrierSelected()) {
903 result.push_back(connection);
904 }
905 }
906 return result;
907}
908
909
910void
912 if (myConnections.insert(connection).second == false) {
913 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
914 }
915}
916
917
918void
920 const auto finder = myConnections.find(connection);
921 if (finder == myConnections.end()) {
922 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
923 } else {
924 myConnections.erase(finder);
925 }
926}
927
928
929int
931 int counter = 0;
932 for (const auto& connection : myConnections) {
933 if (connection->isAttributeCarrierSelected()) {
934 counter++;
935 }
936 }
937 return counter;
938}
939
940
942GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
943 for (const auto& additional : myAdditionals.at(type)) {
944 if (additional->getID() == id) {
945 return additional;
946 }
947 }
948 if (hardFail) {
949 throw ProcessError("Attempted to retrieve non-existant additional (string)");
950 } else {
951 return nullptr;
952 }
953}
954
955
958 // cast additional
959 GNEAdditional* additional = dynamic_cast<GNEAdditional*>(AC);
960 if (additional && (myAdditionals.at(AC->getTagProperty().getTag()).count(additional) > 0)) {
961 return additional;
962 } else if (hardFail) {
963 throw ProcessError("Attempted to retrieve non-existant additional (AttributeCarrier)");
964 } else {
965 return nullptr;
966 }
967}
968
969
971GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
972 // first retrieve rerouter
973 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
974 // parse begin and end
975 const std::string beginStr = time2string(begin);
976 const std::string endStr = time2string(end);
977 // now iterate over all children and check begin and end
978 for (const auto& interval : rerouter->getChildAdditionals()) {
979 // check tag (to avoid symbols)
980 if (interval->getTagProperty().getTag() == SUMO_TAG_INTERVAL) {
981 // check begin and end
982 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
983 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
984 return interval;
985 }
986 }
987 }
988 // throw exception
989 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
990}
991
992
993const std::map<SumoXMLTag, std::set<GNEAdditional*> >&
995 return myAdditionals;
996}
997
998
999std::vector<GNEAdditional*>
1001 std::vector<GNEAdditional*> result;
1002 // returns additionals depending of selection
1003 for (const auto& additionalsTags : myAdditionals) {
1004 for (const auto& additional : additionalsTags.second) {
1005 if (additional->isAttributeCarrierSelected()) {
1006 result.push_back(additional);
1007 }
1008 }
1009 }
1010 return result;
1011}
1012
1013
1014std::vector<GNEAdditional*>
1016 std::vector<GNEAdditional*> result;
1017 // returns additionals depending of selection
1018 for (const auto& additionalsTags : myAdditionals) {
1019 for (const auto& additional : additionalsTags.second) {
1020 if (additional->getTagProperty().isShapeElement() && additional->isAttributeCarrierSelected()) {
1021 result.push_back(additional);
1022 }
1023 }
1024 }
1025 return result;
1026}
1027
1028
1029int
1031 int counter = 0;
1032 for (const auto& additionalsTag : myAdditionals) {
1033 counter += (int)additionalsTag.second.size();
1034 }
1035 return counter;
1036}
1037
1038
1039void
1041 // clear elements in grid
1042 for (const auto& additionalsTags : myAdditionals) {
1043 for (const auto& additional : additionalsTags.second) {
1044 myNet->removeGLObjectFromGrid(additional);
1045 }
1046 }
1047 // iterate over myAdditionals and clear all additionals
1048 for (auto& additionals : myAdditionals) {
1049 additionals.second.clear();
1050 }
1051}
1052
1053
1054std::string
1056 // obtain option container
1058 // get prefix
1059 std::string prefix;
1060 if (tag == SUMO_TAG_BUS_STOP) {
1061 prefix = oc.getString("busStop-prefix");
1062 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1063 prefix = oc.getString("trainStop-prefix");
1064 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1065 prefix = oc.getString("containerStop-prefix");
1066 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1067 prefix = oc.getString("chargingStation-prefix");
1068 } else if (tag == SUMO_TAG_PARKING_AREA) {
1069 prefix = oc.getString("parkingArea-prefix");
1070 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1071 prefix = oc.getString("e1Detector-prefix");
1072 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1073 prefix = oc.getString("e2Detector-prefix");
1074 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1075 prefix = oc.getString("e3Detector-prefix");
1076 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1077 prefix = oc.getString("e1InstantDetector-prefix");
1078 } else if (tag == SUMO_TAG_REROUTER) {
1079 prefix = oc.getString("rerouter-prefix");
1080 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1081 prefix = oc.getString("calibrator-prefix");
1082 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1083 prefix = oc.getString("routeProbe-prefix");
1084 } else if (tag == SUMO_TAG_VSS) {
1085 prefix = oc.getString("vss-prefix");
1086 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1087 prefix = oc.getString("tractionSubstation-prefix");
1088 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1089 prefix = oc.getString("overheadWire-prefix");
1090 } else if (tag == SUMO_TAG_POLY) {
1091 prefix = oc.getString("polygon-prefix");
1092 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1093 prefix = oc.getString("poi-prefix");
1094 } else if (tag == SUMO_TAG_TAZ) {
1095 prefix = toString(SUMO_TAG_TAZ);
1096 }
1097 int counter = 0;
1098 // special case for calibrators
1099 if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1100 while ((retrieveAdditional(SUMO_TAG_CALIBRATOR, prefix + "_" + toString(counter), false) != nullptr) ||
1101 (retrieveAdditional(GNE_TAG_CALIBRATOR_LANE, prefix + "_" + toString(counter), false) != nullptr)) {
1102 counter++;
1103 }
1104 } else if ((tag == SUMO_TAG_POLY) || (tag == SUMO_TAG_TAZ)) {
1105 // Polys and TAZs share namespace
1106 while ((retrieveAdditional(SUMO_TAG_POLY, prefix + "_" + toString(counter), false) != nullptr) ||
1107 (retrieveAdditional(SUMO_TAG_TAZ, prefix + "_" + toString(counter), false) != nullptr)) {
1108 counter++;
1109 }
1110 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1111 while ((retrieveAdditional(SUMO_TAG_POI, prefix + "_" + toString(counter), false) != nullptr) ||
1112 (retrieveAdditional(GNE_TAG_POILANE, prefix + "_" + toString(counter), false) != nullptr) ||
1113 (retrieveAdditional(GNE_TAG_POIGEO, prefix + "_" + toString(counter), false) != nullptr)) {
1114 counter++;
1115 }
1116 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1117 while ((retrieveAdditional(SUMO_TAG_LANE_AREA_DETECTOR, prefix + "_" + toString(counter), false) != nullptr) ||
1118 (retrieveAdditional(GNE_TAG_MULTI_LANE_AREA_DETECTOR, prefix + "_" + toString(counter), false) != nullptr)) {
1119 counter++;
1120 }
1121 } else {
1122 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1123 counter++;
1124 }
1125 }
1126 return (prefix + "_" + toString(counter));
1127}
1128
1129
1130int
1132 int counter = 0;
1133 for (const auto& additionalsTags : myAdditionals) {
1134 for (const auto& additional : additionalsTags.second) {
1135 if (additional->isAttributeCarrierSelected()) {
1136 counter++;
1137 }
1138 }
1139 }
1140 return counter;
1141}
1142
1143
1144int
1146 return getNumberOfSelectedAdditionals() - getNumberOfSelectedPolygons() -
1147 getNumberOfSelectedPOIs() - getNumberOfSelectedTAZs() - getNumberOfSelectedTAZSources() -
1148 getNumberOfSelectedTAZSinks() - getNumberOfSelectedWires();
1149}
1150
1151
1152int
1154 int counter = 0;
1155 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1156 if (poly->isAttributeCarrierSelected()) {
1157 counter++;
1158 }
1159 }
1160 return counter;
1161}
1162
1163
1164int
1166 int counter = 0;
1167 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1168 if (POI->isAttributeCarrierSelected()) {
1169 counter++;
1170 }
1171 }
1172 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1173 if (POILane->isAttributeCarrierSelected()) {
1174 counter++;
1175 }
1176 }
1177 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1178 if (POIGEO->isAttributeCarrierSelected()) {
1179 counter++;
1180 }
1181 }
1182 return counter;
1183}
1184
1185
1186int
1188 int counter = 0;
1189 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1190 if (TAZ->isAttributeCarrierSelected()) {
1191 counter++;
1192 }
1193 }
1194 return counter;
1195}
1196
1197
1198int
1200 int counter = 0;
1201 for (const auto& TAZSource : myAdditionals.at(SUMO_TAG_TAZSOURCE)) {
1202 if (TAZSource->isAttributeCarrierSelected()) {
1203 counter++;
1204 }
1205 }
1206 return counter;
1207}
1208
1209
1210int
1212 int counter = 0;
1213 for (const auto& TAZSink : myAdditionals.at(SUMO_TAG_TAZSINK)) {
1214 if (TAZSink->isAttributeCarrierSelected()) {
1215 counter++;
1216 }
1217 }
1218 return counter;
1219}
1220
1221
1222int
1224 int counter = 0;
1225 for (const auto& additionalsTags : myAdditionals) {
1226 for (const auto& additional : additionalsTags.second) {
1227 if (additional->isAttributeCarrierSelected() && additional->getTagProperty().isWireElement()) {
1228 counter++;
1229 }
1230 }
1231 }
1232 return counter;
1233}
1234
1235
1237GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1238 for (const auto& demandElement : myDemandElements.at(type)) {
1239 if (demandElement->getID() == id) {
1240 return demandElement;
1241 }
1242 }
1243 if (hardFail) {
1244 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1245 } else {
1246 return nullptr;
1247 }
1248}
1249
1250
1253 // cast demandElement
1254 GNEDemandElement* demandElement = dynamic_cast<GNEDemandElement*>(AC);
1255 if (demandElement && (myDemandElements.at(AC->getTagProperty().getTag()).count(demandElement) > 0)) {
1256 return demandElement;
1257 } else if (hardFail) {
1258 throw ProcessError("Attempted to retrieve non-existant demand element (AttributeCarrier)");
1259 } else {
1260 return nullptr;
1261 }
1262}
1263
1264
1265std::vector<GNEDemandElement*>
1267 std::vector<GNEDemandElement*> result;
1268 // returns demand elements depending of selection
1269 for (const auto& demandElementTag : myDemandElements) {
1270 for (const auto& demandElement : demandElementTag.second) {
1271 if (demandElement->isAttributeCarrierSelected()) {
1272 result.push_back(demandElement);
1273 }
1274 }
1275 }
1276 return result;
1277}
1278
1279
1280const std::map<SumoXMLTag, std::set<GNEDemandElement*> >&
1282 return myDemandElements;
1283}
1284
1285
1286int
1288 int counter = 0;
1289 for (const auto& demandElementTag : myDemandElements) {
1290 if (demandElementTag.first == SUMO_TAG_VTYPE) {
1291 // iterate over vehicle types to avoid default vTypes
1292 for (const auto& vType : demandElementTag.second) {
1293 if (vType->getAttribute(GNE_ATTR_DEFAULT_VTYPE) != GNEAttributeCarrier::True) {
1294 counter++;
1295 }
1296 }
1297 } else {
1298 counter += (int)demandElementTag.second.size();
1299 }
1300 }
1301 return counter;
1302}
1303
1304
1305std::string
1307 // obtain option container
1309 // get tag property
1310 const auto tagProperty = GNEAttributeCarrier::getTagProperty(tag);
1311 // get prefix
1312 std::string prefix;
1313 if (tag == SUMO_TAG_ROUTE) {
1314 prefix = oc.getString("route-prefix");
1315 } else if (tag == SUMO_TAG_VTYPE) {
1316 prefix = oc.getString("vType-prefix");
1317 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS)) {
1318 prefix = oc.getString("trip-prefix");
1319 } else if (tagProperty.isVehicle() && !tagProperty.isFlow()) {
1320 prefix = oc.getString("vehicle-prefix");
1321 } else if (tagProperty.isPerson()) {
1322 if (tagProperty.isFlow()) {
1323 prefix = oc.getString("personflow-prefix");
1324 } else {
1325 prefix = oc.getString("person-prefix");
1326 }
1327 } else if (tagProperty.isContainer()) {
1328 if (tagProperty.isFlow()) {
1329 prefix = oc.getString("containerflow-prefix");
1330 } else {
1331 prefix = oc.getString("container-prefix");
1332 }
1333 } else if (tagProperty.isFlow()) {
1334 prefix = oc.getString("flow-prefix");
1335 }
1336 // declare counter
1337 int counter = 0;
1338 if (tagProperty.isPerson()) {
1339 // special case for persons (person and personFlows share nameSpaces)
1340 while ((retrieveDemandElement(SUMO_TAG_PERSON, prefix + "_" + toString(counter), false) != nullptr) ||
1341 (retrieveDemandElement(SUMO_TAG_PERSONFLOW, prefix + "_" + toString(counter), false) != nullptr)) {
1342 counter++;
1343 }
1344 // return new person ID
1345 return (prefix + "_" + toString(counter));
1346 } else if (tagProperty.isContainer()) {
1347 // special case for containers (container and containerFlows share nameSpaces)
1348 while ((retrieveDemandElement(SUMO_TAG_CONTAINER, prefix + "_" + toString(counter), false) != nullptr) ||
1349 (retrieveDemandElement(SUMO_TAG_CONTAINERFLOW, prefix + "_" + toString(counter), false) != nullptr)) {
1350 counter++;
1351 }
1352 // return new container ID
1353 return (prefix + "_" + toString(counter));
1354 } else if (tagProperty.isVehicle() || tagProperty.isFlow()) {
1355 // check all vehicles, because share nameSpaces
1356 while ((retrieveDemandElement(SUMO_TAG_VEHICLE, prefix + "_" + toString(counter), false) != nullptr) ||
1357 (retrieveDemandElement(SUMO_TAG_TRIP, prefix + "_" + toString(counter), false) != nullptr) ||
1358 (retrieveDemandElement(GNE_TAG_VEHICLE_WITHROUTE, prefix + "_" + toString(counter), false) != nullptr) ||
1359 (retrieveDemandElement(GNE_TAG_TRIP_JUNCTIONS, prefix + "_" + toString(counter), false) != nullptr) ||
1360 (retrieveDemandElement(GNE_TAG_FLOW_ROUTE, prefix + "_" + toString(counter), false) != nullptr) ||
1361 (retrieveDemandElement(SUMO_TAG_FLOW, prefix + "_" + toString(counter), false) != nullptr) ||
1362 (retrieveDemandElement(GNE_TAG_FLOW_WITHROUTE, prefix + "_" + toString(counter), false) != nullptr) ||
1363 (retrieveDemandElement(GNE_TAG_FLOW_JUNCTIONS, prefix + "_" + toString(counter), false) != nullptr)) {
1364 counter++;
1365 }
1366 // return new vehicle ID
1367 return (prefix + "_" + toString(counter));
1368 } else {
1369 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1370 counter++;
1371 }
1372 // return new element ID
1373 return (prefix + "_" + toString(counter));
1374 }
1375}
1376
1377
1380 for (const auto& vType : myDemandElements.at(SUMO_TAG_VTYPE)) {
1381 if (vType->getID() == DEFAULT_VTYPE_ID) {
1382 return vType;
1383 }
1384 }
1385 throw ProcessError("Default vType doesn't exist");
1386}
1387
1388
1389void
1391 // clear elements in grid
1392 for (const auto& demandElementsTags : myDemandElements) {
1393 for (const auto& demandElement : demandElementsTags.second) {
1394 myNet->removeGLObjectFromGrid(demandElement);
1395 }
1396 }
1397 // iterate over myDemandElements and clear all demand elements
1398 for (auto& demandElements : myDemandElements) {
1399 demandElements.second.clear();
1400 }
1401}
1402
1403
1404void
1406 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1407 GNEVType* defaultVehicleType = new GNEVType(myNet, DEFAULT_VTYPE_ID, SVC_PASSENGER);
1408 myDemandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(defaultVehicleType);
1409 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1410
1411 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1412 GNEVType* defaultBikeType = new GNEVType(myNet, DEFAULT_BIKETYPE_ID, SVC_BICYCLE);
1413 myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(defaultBikeType);
1414 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1415
1416 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1417 GNEVType* defaultTaxiType = new GNEVType(myNet, DEFAULT_TAXITYPE_ID, SVC_TAXI);
1418 myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(defaultTaxiType);
1419 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1420
1421 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1422 GNEVType* defaultPersonType = new GNEVType(myNet, DEFAULT_PEDTYPE_ID, SVC_PEDESTRIAN);
1423 myDemandElements.at(defaultPersonType->getTagProperty().getTag()).insert(defaultPersonType);
1424 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1425
1426 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1427 GNEVType* defaultContainerType = new GNEVType(myNet, DEFAULT_CONTAINERTYPE_ID, SVC_IGNORING);
1428 myDemandElements.at(defaultContainerType->getTagProperty().getTag()).insert(defaultContainerType);
1429 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1430}
1431
1432
1434 return myStopIndex++;
1435}
1436
1437
1438int
1440 int counter = 0;
1441 for (const auto& demandElementsTags : myDemandElements) {
1442 for (const auto& demandElement : demandElementsTags.second) {
1443 if (demandElement->isAttributeCarrierSelected()) {
1444 counter++;
1445 }
1446 }
1447 }
1448 return counter;
1449}
1450
1451
1452int
1454 int counter = 0;
1455 // iterate over routes
1456 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1457 if (route->isAttributeCarrierSelected()) {
1458 counter++;
1459 }
1460 }
1461 // iterate over vehicles with embedded routes
1462 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1463 if (vehicle->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1464 counter++;
1465 }
1466 }
1467 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1468 if (flow->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1469 counter++;
1470 }
1471 }
1472 return counter;
1473}
1474
1475
1476int
1478 int counter = 0;
1479 // iterate over all vehicles and flows
1480 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1481 if (vehicle->isAttributeCarrierSelected()) {
1482 counter++;
1483 }
1484 }
1485 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1486 if (trip->isAttributeCarrierSelected()) {
1487 counter++;
1488 }
1489 }
1490 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1491 if (vehicle->isAttributeCarrierSelected()) {
1492 counter++;
1493 }
1494 }
1495 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1496 if (flow->isAttributeCarrierSelected()) {
1497 counter++;
1498 }
1499 }
1500 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1501 if (flow->isAttributeCarrierSelected()) {
1502 counter++;
1503 }
1504 }
1505 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1506 if (flow->isAttributeCarrierSelected()) {
1507 counter++;
1508 }
1509 }
1510 return counter;
1511}
1512
1513
1514int
1516 int counter = 0;
1517 // iterate over all persons
1518 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1519 if (person->isAttributeCarrierSelected()) {
1520 counter++;
1521 }
1522 }
1523 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1524 if (personFlow->isAttributeCarrierSelected()) {
1525 counter++;
1526 }
1527 }
1528 return counter;
1529}
1530
1531
1532int
1534 int counter = 0;
1535 // iterate over all person plans
1536 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1537 for (const auto& personPlan : person->getChildDemandElements()) {
1538 if (personPlan->getTagProperty().isPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1539 counter++;
1540 }
1541 }
1542 }
1543 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1544 for (const auto& personPlan : personFlow->getChildDemandElements()) {
1545 if (personPlan->getTagProperty().isPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1546 counter++;
1547 }
1548 }
1549 }
1550 return counter;
1551}
1552
1553
1554int
1556 int counter = 0;
1557 // iterate over all person plans
1558 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1559 for (const auto& personPlan : person->getChildDemandElements()) {
1560 if (personPlan->getTagProperty().isWalk() && personPlan->isAttributeCarrierSelected()) {
1561 counter++;
1562 }
1563 }
1564 }
1565 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1566 for (const auto& personPlan : personFlow->getChildDemandElements()) {
1567 if (personPlan->getTagProperty().isWalk() && personPlan->isAttributeCarrierSelected()) {
1568 counter++;
1569 }
1570 }
1571 }
1572 return counter;
1573}
1574
1575
1576int
1578 int counter = 0;
1579 // iterate over all person plans
1580 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1581 for (const auto& personPlan : person->getChildDemandElements()) {
1582 if (personPlan->getTagProperty().isRide() && personPlan->isAttributeCarrierSelected()) {
1583 counter++;
1584 }
1585 }
1586 }
1587 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1588 for (const auto& personPlan : personFlow->getChildDemandElements()) {
1589 if (personPlan->getTagProperty().isRide() && personPlan->isAttributeCarrierSelected()) {
1590 counter++;
1591 }
1592 }
1593 }
1594 return counter;
1595}
1596
1597
1598int
1600 int counter = 0;
1601 // iterate over all containers
1602 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1603 if (container->isAttributeCarrierSelected()) {
1604 counter++;
1605 }
1606 }
1607 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1608 if (containerFlow->isAttributeCarrierSelected()) {
1609 counter++;
1610 }
1611 }
1612 return counter;
1613}
1614
1615
1616int
1618 int counter = 0;
1619 // iterate over all container plans
1620 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1621 for (const auto& containerPlan : container->getChildDemandElements()) {
1622 if (containerPlan->getTagProperty().isTransportPlan() && containerPlan->isAttributeCarrierSelected()) {
1623 counter++;
1624 }
1625 }
1626 }
1627 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1628 for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
1629 if (containerPlan->getTagProperty().isTransportPlan() && containerPlan->isAttributeCarrierSelected()) {
1630 counter++;
1631 }
1632 }
1633 }
1634 return counter;
1635}
1636
1637
1638int
1640 int counter = 0;
1641 // iterate over all container plans
1642 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1643 for (const auto& containerPlan : container->getChildDemandElements()) {
1644 if (containerPlan->getTagProperty().isTranshipPlan() && containerPlan->isAttributeCarrierSelected()) {
1645 counter++;
1646 }
1647 }
1648 }
1649 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1650 for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
1651 if (containerPlan->getTagProperty().isTranshipPlan() && containerPlan->isAttributeCarrierSelected()) {
1652 counter++;
1653 }
1654 }
1655 }
1656 return counter;
1657}
1658
1659
1660int
1662 int counter = 0;
1663 // iterate over routes
1664 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1665 if (route->isAttributeCarrierSelected()) {
1666 counter++;
1667 }
1668 }
1669 // vehicles
1670 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1671 for (const auto& stop : trip->getChildDemandElements()) {
1672 if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1673 counter++;
1674 }
1675 }
1676 }
1677 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1678 for (const auto& stop : vehicle->getChildDemandElements().front()->getChildDemandElements()) {
1679 if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1680 counter++;
1681 }
1682 }
1683 }
1684 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1685 for (const auto& stop : flow->getChildDemandElements()) {
1686 if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1687 counter++;
1688 }
1689 }
1690 }
1691 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1692 for (const auto& stop : flow->getChildDemandElements().front()->getChildDemandElements()) {
1693 if (stop->getTagProperty().isStop() && stop->isAttributeCarrierSelected()) {
1694 counter++;
1695 }
1696 }
1697 }
1698 // persons
1699 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1700 for (const auto& personPlan : person->getChildDemandElements()) {
1701 if (personPlan->getTagProperty().isStopPerson() && personPlan->isAttributeCarrierSelected()) {
1702 counter++;
1703 }
1704 }
1705 }
1706 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1707 for (const auto& personPlan : personFlow->getChildDemandElements()) {
1708 if (personPlan->getTagProperty().isStopPerson() && personPlan->isAttributeCarrierSelected()) {
1709 counter++;
1710 }
1711 }
1712 }
1713 // containers
1714 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1715 for (const auto& containerPlan : container->getChildDemandElements()) {
1716 if (containerPlan->getTagProperty().isStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1717 counter++;
1718 }
1719 }
1720 }
1721 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1722 for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
1723 if (containerPlan->getTagProperty().isStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1724 counter++;
1725 }
1726 }
1727 }
1728 return counter;
1729}
1730
1731
1733GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1734 for (const auto& dataSet : myDataSets) {
1735 if (dataSet->getID() == id) {
1736 return dataSet;
1737 }
1738 }
1739 if (hardFail) {
1740 throw ProcessError("Attempted to retrieve non-existant data set");
1741 } else {
1742 return nullptr;
1743 }
1744}
1745
1746
1749 // cast dataSet
1750 GNEDataSet* dataSet = dynamic_cast<GNEDataSet*>(AC);
1751 if (dataSet && (myDataSets.count(dataSet) > 0)) {
1752 return dataSet;
1753 } else if (hardFail) {
1754 throw ProcessError("Attempted to retrieve non-existant data set");
1755 } else {
1756 return nullptr;
1757 }
1758}
1759
1760
1761const std::set<GNEDataSet*>&
1763 return myDataSets;
1764}
1765
1766
1767std::string
1769 const std::string dataSetTagStr = toString(SUMO_TAG_DATASET);
1770 int counter = 0;
1771 while (retrieveDataSet(prefix + dataSetTagStr + "_" + toString(counter), false) != nullptr) {
1772 counter++;
1773 }
1774 return (prefix + dataSetTagStr + "_" + toString(counter));
1775}
1776
1777
1780 // cast dataInterval
1781 GNEDataInterval* dataInterval = dynamic_cast<GNEDataInterval*>(AC);
1782 if (dataInterval && (myDataIntervals.count(dataInterval) > 0)) {
1783 return dataInterval;
1784 } else if (hardFail) {
1785 throw ProcessError("Attempted to retrieve non-existant data interval");
1786 } else {
1787 return nullptr;
1788 }
1789}
1790
1791
1792const std::set<GNEDataInterval*>&
1794 return myDataIntervals;
1795}
1796
1797
1798void
1800 if (myDataIntervals.insert(dataInterval).second == false) {
1801 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
1802 }
1803 // mark interval toolbar for update
1804 myNet->getViewNet()->getIntervalBar().markForUpdate();
1805}
1806
1807
1808void
1810 const auto finder = myDataIntervals.find(dataInterval);
1811 if (finder == myDataIntervals.end()) {
1812 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
1813 } else {
1814 myDataIntervals.erase(finder);
1815 }
1816 // mark interval toolbar for update
1817 myNet->getViewNet()->getIntervalBar().markForUpdate();
1818}
1819
1820
1823 // cast genericData
1824 GNEGenericData* genericData = dynamic_cast<GNEGenericData*>(AC);
1825 if (genericData && (myGenericDatas.at(AC->getTagProperty().getTag()).count(genericData) > 0)) {
1826 return genericData;
1827 } else if (hardFail) {
1828 throw ProcessError("Attempted to retrieve non-existant data set");
1829 } else {
1830 return nullptr;
1831 }
1832}
1833
1834
1835std::vector<GNEGenericData*>
1837 std::vector<GNEGenericData*> result;
1838 // returns generic datas depending of selection
1839 for (const auto& genericDataTag : myGenericDatas) {
1840 for (const auto& genericData : genericDataTag.second) {
1841 if (genericData->isAttributeCarrierSelected()) {
1842 result.push_back(genericData);
1843 }
1844 }
1845 }
1846 return result;
1847}
1848
1849
1850const std::map<SumoXMLTag, std::set<GNEGenericData*> >&
1852 return myGenericDatas;
1853}
1854
1855
1856std::vector<GNEGenericData*>
1857GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
1858 // declare generic data vector
1859 std::vector<GNEGenericData*> genericDatas;
1860 // iterate over all data sets
1861 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
1862 // check interval
1863 if ((genericData->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
1864 (genericData->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
1865 genericDatas.push_back(genericData);
1866 }
1867 }
1868 return genericDatas;
1869}
1870
1871
1872int
1874 int counter = 0;
1875 // iterate over all edgeDatas
1876 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_MEANDATA_EDGE)) {
1877 if (genericData->isAttributeCarrierSelected()) {
1878 counter++;
1879 }
1880 }
1881 return counter;
1882}
1883
1884
1885int
1887 int counter = 0;
1888 // iterate over all edgeDatas
1889 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
1890 if (genericData->isAttributeCarrierSelected()) {
1891 counter++;
1892 }
1893 }
1894 return counter;
1895}
1896
1897
1898int
1900 int counter = 0;
1901 // iterate over all edgeDatas
1902 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
1903 if (genericData->isAttributeCarrierSelected()) {
1904 counter++;
1905 }
1906 }
1907 return counter;
1908}
1909
1910
1911void
1913 if (myGenericDatas.at(genericData->getTagProperty().getTag()).insert(genericData).second == false) {
1914 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
1915 }
1916 // mark interval toolbar for update
1917 myNet->getViewNet()->getIntervalBar().markForUpdate();
1918}
1919
1920
1921void
1923 const auto finder = myGenericDatas.at(genericData->getTagProperty().getTag()).find(genericData);
1924 if (finder == myGenericDatas.at(genericData->getTagProperty().getTag()).end()) {
1925 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
1926 } else {
1927 myGenericDatas.at(genericData->getTagProperty().getTag()).erase(finder);
1928 }
1929 // mark interval toolbar for update
1930 myNet->getViewNet()->getIntervalBar().markForUpdate();
1931}
1932
1933
1934std::set<std::string>
1935GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
1936 // declare solution
1937 std::set<std::string> attributesSolution;
1938 // declare generic data vector
1939 std::vector<GNEGenericData*> genericDatas;
1940 // iterate over all data sets
1941 for (const auto& interval : myDataIntervals) {
1942 // check interval
1943 if ((interval->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval->getAttributeDouble(SUMO_ATTR_END) <= end)) {
1944 // iterate over generic datas
1945 for (const auto& genericData : interval->getGenericDataChildren()) {
1946 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
1947 genericDatas.push_back(genericData);
1948 }
1949 }
1950 }
1951 }
1952 // iterate over generic datas
1953 for (const auto& genericData : genericDatas) {
1954 for (const auto& attribute : genericData->getParametersMap()) {
1955 attributesSolution.insert(attribute.first);
1956 }
1957 }
1958 return attributesSolution;
1959}
1960
1961
1962std::set<std::string>
1963GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
1964 const std::string& beginStr, const std::string& endStr) const {
1965 // declare solution
1966 std::set<std::string> attributesSolution;
1967 // vector of data sets and intervals
1968 std::vector<GNEDataSet*> dataSets;
1969 std::vector<GNEDataInterval*> dataIntervals;
1970 // get dataSet
1971 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
1972 // if dataSetID is empty, return all parameters
1973 if (dataSetID.empty()) {
1974 // add all data sets
1975 dataSets.reserve(myDataSets.size());
1976 for (const auto& dataSet : myDataSets) {
1977 dataSets.push_back(dataSet);
1978 }
1979 } else if (retrievedDataSet) {
1980 dataSets.push_back(retrievedDataSet);
1981 } else {
1982 return attributesSolution;
1983 }
1984 // now continue with data intervals
1985 int numberOfIntervals = 0;
1986 for (const auto& dataSet : dataSets) {
1987 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
1988 }
1989 // resize dataIntervals
1990 dataIntervals.reserve(numberOfIntervals);
1991 // add intervals
1992 for (const auto& dataSet : dataSets) {
1993 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
1994 // continue depending of begin and end
1995 if (beginStr.empty() && endStr.empty()) {
1996 dataIntervals.push_back(dataInterval.second);
1997 } else if (endStr.empty()) {
1998 // parse begin
1999 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2000 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2001 dataIntervals.push_back(dataInterval.second);
2002 }
2003 } else if (beginStr.empty()) {
2004 // parse end
2005 const double end = GNEAttributeCarrier::parse<double>(endStr);
2006 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2007 dataIntervals.push_back(dataInterval.second);
2008 }
2009 } else {
2010 // parse both begin end
2011 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2012 const double end = GNEAttributeCarrier::parse<double>(endStr);
2013 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2014 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2015 dataIntervals.push_back(dataInterval.second);
2016 }
2017 }
2018 }
2019 }
2020 // finally iterate over intervals and get attributes
2021 for (const auto& dataInterval : dataIntervals) {
2022 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2023 // check generic data tag
2024 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2025 for (const auto& attribute : genericData->getParametersMap()) {
2026 attributesSolution.insert(attribute.first);
2027 }
2028 }
2029 }
2030 }
2031 return attributesSolution;
2032}
2033
2034
2035void
2037 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2038 registerJunction(junction);
2039}
2040
2041
2042void
2044 // remove it from inspected elements and GNEElementTree
2045 myNet->getViewNet()->removeFromAttributeCarrierInspected(junction);
2046 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2047 // Remove from grid and container
2048 myNet->removeGLObjectFromGrid(junction);
2049 myJunctions.erase(junction->getMicrosimID());
2050 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2051 junction->decRef("GNENet::deleteSingleJunction");
2052 junction->setResponsible(true);
2053}
2054
2055
2056bool
2058 return (myEdgeTypes.count(edgeType->getID()) > 0);
2059}
2060
2061
2062void
2064 // get pointer to create edge frame
2065 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2066 // insert in myEdgeTypes
2067 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2068 // update edge selector
2069 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
2070 myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2071 }
2072 // set current edge type inspected
2073 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2074}
2075
2076
2077void
2079 // get pointer to create edge frame
2080 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2081 // remove it from inspected elements and GNEElementTree
2082 myNet->getViewNet()->removeFromAttributeCarrierInspected(edgeType);
2083 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2084 // remove from edge types
2085 myEdgeTypes.erase(edgeType->getMicrosimID());
2086 // check if this is the selected edge type in edgeSelector
2087 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2088 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2089 }
2090 // update edge selector
2091 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2092}
2093
2094
2095void
2097 NBEdge* nbe = edge->getNBEdge();
2098 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2099 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2100 nbe->getFromNode()->addOutgoingEdge(nbe);
2101 nbe->getToNode()->addIncomingEdge(nbe);
2102 // register edge
2103 registerEdge(edge);
2104}
2105
2106
2107void
2109 // remove it from inspected elements and GNEElementTree
2110 myNet->getViewNet()->removeFromAttributeCarrierInspected(edge);
2111 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2112 // remove edge from visual grid and container
2113 myNet->removeGLObjectFromGrid(edge);
2114 myEdges.erase(edge->getMicrosimID());
2115 // remove all lanes
2116 for (const auto& lane : edge->getLanes()) {
2117 deleteLane(lane);
2118 }
2119 // extract edge of district container
2120 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2121 edge->decRef("GNENet::deleteSingleEdge");
2122 edge->setResponsible(true);
2123 // Remove refrences from GNEJunctions
2125 edge->getToJunction()->removeIncomingGNEEdge(edge);
2126 // get template editor
2127 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
2128 // check if we have to remove template
2129 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2130 templateEditor->setEdgeTemplate(nullptr);
2131 }
2132}
2133
2134
2135bool
2137 // first check that additional pointer is valid
2138 if (additional) {
2139 // get vector with this additional element type
2140 const auto& additionalElementTag = myAdditionals.at(additional->getTagProperty().getTag());
2141 // find demanElement in additionalElementTag
2142 return std::find(additionalElementTag.begin(), additionalElementTag.end(), additional) != additionalElementTag.end();
2143 } else {
2144 throw ProcessError("Invalid additional pointer");
2145 }
2146}
2147
2148
2149void
2151 // insert additional
2152 if (myAdditionals.at(additional->getTagProperty().getTag()).insert(additional).second == false) {
2153 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2154 }
2155 // add element in grid
2156 if (additional->getTagProperty().isPlacedInRTree()) {
2157 myNet->addGLObjectIntoGrid(additional);
2158 }
2159 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2160 if (myNet->isUpdateGeometryEnabled()) {
2161 additional->updateGeometry();
2162 }
2163 // additionals has to be saved
2164 myNet->requireSaveAdditionals(true);
2165}
2166
2167
2168void
2170 // find demanElement in additionalTag
2171 auto itFind = myAdditionals.at(additional->getTagProperty().getTag()).find(additional);
2172 // check if additional was previously inserted
2173 if (itFind == myAdditionals.at(additional->getTagProperty().getTag()).end()) {
2174 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2175 }
2176 // remove it from inspected elements and GNEElementTree
2177 myNet->getViewNet()->removeFromAttributeCarrierInspected(additional);
2178 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2179 // remove from container
2180 myAdditionals.at(additional->getTagProperty().getTag()).erase(itFind);
2181 // remove element from grid
2182 if (additional->getTagProperty().isPlacedInRTree()) {
2183 myNet->removeGLObjectFromGrid(additional);
2184 }
2185 // delete path element
2186 myNet->getPathManager()->removePath(additional);
2187 // additionals has to be saved
2188 myNet->requireSaveAdditionals(true);
2189}
2190
2191
2192bool
2194 // first check that demandElement pointer is valid
2195 if (demandElement) {
2196 // get vector with this demand element type
2197 const auto& demandElementTag = myDemandElements.at(demandElement->getTagProperty().getTag());
2198 // find demanElement in demandElementTag
2199 return std::find(demandElementTag.begin(), demandElementTag.end(), demandElement) != demandElementTag.end();
2200 } else {
2201 throw ProcessError("Invalid demandElement pointer");
2202 }
2203}
2204
2205
2206void
2208 // insert in demandElements container
2209 if (myDemandElements.at(demandElement->getTagProperty().getTag()).insert(demandElement).second == false) {
2210 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2211 }
2212 // add element in grid
2213 myNet->addGLObjectIntoGrid(demandElement);
2214 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2215 if (myNet->isUpdateGeometryEnabled()) {
2216 demandElement->updateGeometry();
2217 }
2218 // demandElements has to be saved
2219 myNet->requireSaveDemandElements(true);
2220}
2221
2222
2223void
2225 // find demanElement in demandElementTag
2226 auto itFind = myDemandElements.at(demandElement->getTagProperty().getTag()).find(demandElement);
2227 // check if demandElement was previously inserted
2228 if (itFind == myDemandElements.at(demandElement->getTagProperty().getTag()).end()) {
2229 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2230 }
2231 // remove it from inspected elements and GNEElementTree
2232 myNet->getViewNet()->removeFromAttributeCarrierInspected(demandElement);
2233 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2234 myNet->getViewNet()->getViewParent()->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2235 // if is the last inserted route, remove it from GNEViewNet
2236 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2237 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2238 }
2239 // erase it from container
2240 myDemandElements.at(demandElement->getTagProperty().getTag()).erase(itFind);
2241 // remove element from grid
2242 myNet->removeGLObjectFromGrid(demandElement);
2243 // delete path element
2244 myNet->getPathManager()->removePath(demandElement);
2245 // demandElements has to be saved
2246 myNet->requireSaveDemandElements(true);
2247}
2248
2249
2250bool
2252 // first check that dataSet pointer is valid
2253 if (dataSet) {
2254 if (myDataSets.find(dataSet) != myDataSets.end()) {
2255 return true;
2256 } else {
2257 return false;
2258 }
2259 } else {
2260 throw ProcessError("Invalid dataSet pointer");
2261 }
2262}
2263
2264
2265void
2267 // Check if dataSet element exists before insertion
2268 if (myDataSets.insert(dataSet).second == false) {
2269 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2270 }
2271 // dataSets has to be saved
2272 myNet->requireSaveDataElements(true);
2273 // mark interval toolbar for update
2274 myNet->getViewNet()->getIntervalBar().markForUpdate();
2275}
2276
2277
2278void
2280 // find dataSet
2281 const auto itFind = myDataSets.find(dataSet);
2282 // first check that dataSet pointer is valid
2283 if (itFind == myDataSets.end()) {
2284 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2285 }
2286 // remove it from inspected elements and GNEElementTree
2287 myNet->getViewNet()->removeFromAttributeCarrierInspected(dataSet);
2288 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2289 // obtain demand element and erase it from container
2290 myDataSets.erase(itFind);
2291 // dataSets has to be saved
2292 myNet->requireSaveDataElements(true);
2293 // mark interval toolbar for update
2294 myNet->getViewNet()->getIntervalBar().markForUpdate();
2295}
2296
2297// ---------------------------------------------------------------------------
2298// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
2299// ---------------------------------------------------------------------------
2300
2302 GNEChange(Supermode::NETWORK, true, false),
2303 myTllcont(tllcont),
2304 myReplaced(replaced),
2305 myBy(by) {
2306}
2307
2308
2310
2311
2312void
2314 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2315 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
2316}
2317
2318
2319void
2321 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2322 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
2323}
2324
2325
2326std::string
2328 return "Redo replace in TLS";
2329}
2330
2331
2332std::string
2334 return "Undo replace in TLS";
2335}
2336
2337
2338bool
2340 return myReplaced != myBy;
2341}
2342
2343/****************************************************************************/
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
@ DATA
Data mode (edgeData, LaneData etc..)
@ DEMAND
Demand mode (Routes, Vehicles etc..)
long long int SUMOTime
Definition: GUI.h:36
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GUISelectedStorage gSelected
A global holder of selected objects.
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:276
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
@ 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_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_TAG_DATAINTERVAL
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ 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.
@ SUMO_TAG_WALKINGAREA
walking area for pedestrians
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ 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_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ 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_PERSON
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ 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
@ GNE_ATTR_DEFAULT_VTYPE
Flag to check if VType is a default VType.
@ 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 belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
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.
const std::string getID() const
get ID (all Attribute Carriers have one)
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,...
static const std::string True
true value in string format (used for comparing boolean values in getAttribute(......
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:60
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 belong to GNENet but has influence in the simulation.
An Element which don't belong to GNENet but has influence in the simulation.
virtual void updateGeometry()=0
update pre-computed geometry information
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition: GNEEdge.cpp:1223
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:481
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:839
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:77
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:82
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:2079
An Element which don't belong to GNENet but has influence in the simulation.
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)
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:876
std::vector< GNEEdge * > retrieveEdges(GNEJunction *from, GNEJunction *to) const
get all edges by from and to GNEJunction
void insertWalkingArea(GNEWalkingArea *walkingArea)
insert walkingArea
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 (Including POIs, Polygons, TAZs and Wires)
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
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
std::vector< GNEAdditional * > getSelectedShapes() const
get selected shapes
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:678
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 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
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
int getStopIndex()
get (and update) stop index
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::vector< GNEWalkingArea * > getSelectedWalkingAreas() const
return all selected walkingAreas
std::map< SumoXMLTag, std::set< GNEGenericData * > > myGenericDatas
map with the tag and pointer to all generic datas
Definition: GNENetHelper.h:687
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction in GNENet containers
const std::set< GNEDataSet * > & getDataSets() const
get demand elements
int getNumberOfSelectedWalkingAreas() const
get number of selected walkingAreas
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
int getNumberOfSelectedWires() const
get number of selected Wires
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
int getNumberOfSelectedTAZs() const
get number of selected TAZs
void deleteWalkingArea(GNEWalkingArea *walkingArea)
delete walkingArea
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
int getNumberOfSelectedDemandElements() const
get number of selected demand elements
int getNumberOfSelectedPersons() const
get number of selected persons
int getNumberOfSelectedPureAdditionals() const
get number of selected pure additionals (Except POIs, Polygons, TAZs and Wires)
GNEEdgeType * retrieveEdgeType(const std::string &id, bool hardFail=true) const
get edge type by id
int getNumberOfSelectedRoutes() const
get number of selected routes
void addDefaultVTypes()
add default VTypes
int getNumberOfSelectedPOIs() const
get number of selected POIs
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
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
int getNumberOfAdditionals() const
get number of additionals
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
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
int getNumberOfSelectedTAZSources() const
get number of selected TAZSources
bool additionalExist(const GNEAdditional *additional) const
return true if given additional exist
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:675
void insertDataInterval(GNEDataInterval *dataInterval)
insert data interval
int getNumberOfSelectedTAZSinks() const
get number of selected TAZSinks
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
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
GNEWalkingArea * retrieveWalkingArea(GNEAttributeCarrier *AC, bool hardFail=true) const
get WalkingArea by AC
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
const std::set< GNEWalkingArea * > & getWalkingAreas() const
get walkingAreas
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.
void decRef(const std::string &debugMsg="")
Decrease reference.
void incRef(const std::string &debugMsg="")
Increase reference.
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 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 (note: this include TAZ, shapes and wires)
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
const PositionVector & getShape() const
The shape of the additional element.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
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:92
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:552
const std::string & getID() const
Definition: NBEdge.h:1526
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:545
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:3634
int buildCrossings()
build pedestrian crossings
Definition: NBNode.cpp:2835
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition: NBNode.cpp:469
const Position & getPosition() const
Definition: NBNode.h:250
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:2447
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:59
C++ TraCI client API implementation.
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