Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNENetHelper.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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>
49
50#include "GNENetHelper.h"
51
52// ---------------------------------------------------------------------------
53// GNENetHelper::AttributeCarriers - methods
54// ---------------------------------------------------------------------------
55
57 myNet(net),
58 myStopIndex(0) {
59 // fill additionals with tags
62 for (const auto& additionalTagProperty : additionalTagProperties) {
63 myAdditionals.insert(std::make_pair(additionalTagProperty.getTag(), std::unordered_map<const GUIGlObject*, GNEAdditional*>()));
64 if (additionalTagProperty.hasAttribute(SUMO_ATTR_ID)) {
65 myAdditionalIDs.insert(std::make_pair(additionalTagProperty.getTag(), std::map<const std::string, GNEAdditional*>()));
66 }
67 }
68 // fill demand elements with tags
70 for (const auto& demandElementTagProperty : demandElementTagProperties) {
71 myDemandElements.insert(std::make_pair(demandElementTagProperty.getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
72 if (demandElementTagProperty.hasAttribute(SUMO_ATTR_ID)) {
73 myDemandElementIDs.insert(std::make_pair(demandElementTagProperty.getTag(), std::map<const std::string, GNEDemandElement*>()));
74 }
75 }
77 for (const auto& stopTagProperty : stopTagProperties) {
78 myDemandElements.insert(std::make_pair(stopTagProperty.getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
79 }
80 // fill data elements with tags
82 for (const auto& genericDataElementTagProperty : genericDataElementTagProperties) {
83 myGenericDatas.insert(std::make_pair(genericDataElementTagProperty.getTag(), std::unordered_map<const GUIGlObject*, GNEGenericData*>()));
84 }
85 // fill meanDatas with tags
87 for (const auto& meanDataTagProperty : meanDataTagProperties) {
88 myMeanDatas.insert(std::make_pair(meanDataTagProperty.getTag(), std::map<const std::string, GNEMeanData*>()));
89 }
90}
91
92
94 // Drop EdgeTypes
95 for (const auto& edgeType : myEdgeTypes) {
96 edgeType.second->decRef("GNENetHelper::~GNENet");
97 // show extra information for tests
98 WRITE_DEBUG("Deleting unreferenced " + edgeType.second->getTagStr() + " '" + edgeType.second->getID() + "' in AttributeCarriers destructor");
99 delete edgeType.second;
100 }
101 // Drop Edges
102 for (const auto& edge : myEdges) {
103 edge.second->decRef("GNENetHelper::~GNENet");
104 // show extra information for tests
105 WRITE_DEBUG("Deleting unreferenced " + edge.second->getTagStr() + " '" + edge.second->getID() + "' in AttributeCarriers destructor");
106 delete edge.second;
107 }
108 // Drop myJunctions
109 for (const auto& junction : myJunctions) {
110 junction.second->decRef("GNENetHelper::~GNENet");
111 // show extra information for tests
112 WRITE_DEBUG("Deleting unreferenced " + junction.second->getTagStr() + " '" + junction.second->getID() + "' in AttributeCarriers destructor");
113 delete junction.second;
114 }
115 // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
116 for (const auto& additionalTag : myAdditionals) {
117 for (const auto& additional : additionalTag.second) {
118 // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
119 additional.second->decRef();
120 // show extra information for tests
121 WRITE_DEBUG("Deleting unreferenced " + additional.second->getTagStr() + " in AttributeCarriers destructor");
122 delete additional.second;
123 }
124 }
125 // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
126 for (const auto& demandElementTag : myDemandElements) {
127 for (const auto& demandElement : demandElementTag.second) {
128 // decrease reference manually (because it was increased manually in GNERouteHandler)
129 demandElement.second->decRef();
130 // show extra information for tests
131 if (demandElement.second->getTagProperty().isType()) {
132 // special case for default VTypes
133 if (DEFAULT_VTYPES.count(demandElement.second->getID()) == 0) {
134 WRITE_DEBUG("Deleting unreferenced " + demandElement.second->getTagStr() + " in AttributeCarriers destructor");
135 }
136 } else {
137 WRITE_DEBUG("Deleting unreferenced " + demandElement.second->getTagStr() + " in AttributeCarriers destructor");
138 }
139 delete demandElement.second;
140 }
141 }
142 // Drop dataSets (Only used for TAZElements that were inserted without using GNEChange_DataSets)
143 for (const auto& dataSet : myDataSets) {
144 // decrease reference manually (because it was increased manually in GNEDataHandler)
145 dataSet.second->decRef();
146 // show extra information for tests
147 WRITE_DEBUG("Deleting unreferenced " + dataSet.second->getTagStr() + " in AttributeCarriers destructor");
148 delete dataSet.second;
149 }
150 // Drop MeanDatas (Only used for meanDatas that were inserted without using GNEChange_MeanData)
151 for (const auto& meanDataTag : myMeanDatas) {
152 for (const auto& meanData : meanDataTag.second) {
153 // decrease reference manually (because it was increased manually in GNEMeanDataHandler)
154 meanData.second->decRef();
155 // show extra information for tests
156 WRITE_DEBUG("Deleting unreferenced " + meanData.second->getTagStr() + " in AttributeCarriers destructor");
157 delete meanData.second;
158 }
159 }
160}
161
162
163void
165 std::map<std::string, GNEEdge*> newEdgeMap;
166 std::map<std::string, GNEJunction*> newJunctionMap;
167 // fill newEdgeMap
168 for (const auto& edge : myEdges) {
169 edge.second->setEdgeID(edge.second->getNBEdge()->getID());
170 newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
171 }
172 for (const auto& junction : myJunctions) {
173 newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
174 junction.second->setNetworkElementID(junction.second->getNBNode()->getID());
175 }
176 myEdges = newEdgeMap;
177 myJunctions = newJunctionMap;
178}
179
180
181bool
183 // check what type of AC
184 if (AC->getTagProperty().getTag() == SUMO_TAG_JUNCTION) {
185 // Junction
186 const GNEJunction* junction = myJunctions.at(AC->getID());
187 if (junction->getNBNode()->getShape().size() == 0) {
188 return shape.around(junction->getNBNode()->getCenter());
189 } else {
190 return (shape.overlapsWith(junction->getNBNode()->getShape()));
191 }
192 } else if (AC->getTagProperty().getTag() == SUMO_TAG_EDGE) {
193 // Edge
194 for (const auto& lane : myEdges.at(AC->getID())->getLanes()) {
195 if (shape.overlapsWith(lane->getLaneShape())) {
196 return true;
197 }
198 }
199 return false;
200 } else if (AC->getTagProperty().getTag() == SUMO_TAG_LANE) {
201 // Lane
202 return shape.overlapsWith(retrieveLane(AC->getID())->getLaneShape());
203 } else if (AC->getTagProperty().getTag() == SUMO_TAG_CONNECTION) {
204 // connection
205 return shape.overlapsWith(myConnections.at(AC->getGUIGlObject())->getConnectionShape());
206 } else if (AC->getTagProperty().getTag() == SUMO_TAG_CROSSING) {
207 // crossing
208 return shape.overlapsWith(myCrossings.at(AC->getGUIGlObject())->getCrossingShape());
209 } else if (AC->getTagProperty().isAdditionalElement()) {
210 // Additional (including shapes and TAZs
211 const GNEAdditional* additional = retrieveAdditional(AC->getGUIGlObject());
212 if (additional->getAdditionalGeometry().getShape().size() <= 1) {
213 return shape.around(additional->getPositionInView());
214 } else {
215 return shape.overlapsWith(additional->getAdditionalGeometry().getShape());
216 }
217 } else {
218 return false;
219 }
220}
221
222
223int
225 return myNumberOfNetworkElements;
226}
227
228
229int
231 return myNumberOfDemandElements;
232}
233
234
235int
237 return myNumberOfDataElements;
238}
239
240
243 // obtain blocked GUIGlObject
245 // Make sure that object exists
246 if (object != nullptr) {
247 // unblock and try to parse to AttributeCarrier
249 GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
250 // If was successfully parsed, return it
251 if (ac == nullptr) {
252 throw ProcessError("GUIGlObject does not match the declared type");
253 } else {
254 return ac;
255 }
256 } else if (hardFail) {
257 throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
258 } else {
259 return nullptr;
260 }
261}
262
263
264std::vector<GNEAttributeCarrier*>
266 std::vector<GNEAttributeCarrier*> result;
267 if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_JUNCTION)) {
268 for (const auto& junction : myJunctions) {
269 result.push_back(junction.second);
270 }
271 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_EDGE)) {
272 for (const auto& edge : myEdges) {
273 result.push_back(edge.second);
274 }
275 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_LANE)) {
276 for (const auto& lane : myLanes) {
277 result.push_back(lane.second);
278 }
279 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CONNECTION)) {
280 for (const auto& connection : myConnections) {
281 result.push_back(connection.second);
282 }
283 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CROSSING)) {
284 for (const auto& crossing : myCrossings) {
285 result.push_back(crossing.second);
286 }
287 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_WALKINGAREA)) {
288 for (const auto& walkingArea : myWalkingAreas) {
289 result.push_back(walkingArea.second);
290 }
292 for (const auto& additional : myAdditionals.at(tag)) {
293 result.push_back(additional.second);
294 }
297 if (mergingPlans.size() > 0) {
298 for (const auto& mergingPlan : mergingPlans) {
299 for (const auto& demandElemet : myDemandElements.at(mergingPlan.getTag())) {
300 result.push_back(demandElemet.second);
301 }
302 }
303 } else {
304 for (const auto& demandElemet : myDemandElements.at(tag)) {
305 result.push_back(demandElemet.second);
306 }
307 }
308 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATASET)) {
309 for (const auto& dataSet : myDataSets) {
310 result.push_back(dataSet.second);
311 }
312 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATAINTERVAL)) {
313 for (const auto& dataInterval : myDataIntervals) {
314 result.push_back(dataInterval.second);
315 }
317 for (const auto& genericData : myGenericDatas.at(tag)) {
318 result.push_back(genericData.second);
319 }
320 } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isMeanData())) {
321 for (const auto& meanData : myMeanDatas.at(tag)) {
322 result.push_back(meanData.second);
323 }
324 }
325 return result;
326}
327
328
329std::vector<GNEAttributeCarrier*>
331 std::vector<GNEAttributeCarrier*> result;
332 // continue depending of supermode
333 if (supermode == Supermode::NETWORK) {
334 // network
335 for (const auto& junction : myJunctions) {
336 if (!onlySelected || junction.second->isAttributeCarrierSelected()) {
337 result.push_back(junction.second);
338 }
339 }
340 for (const auto& crossing : myCrossings) {
341 if (!onlySelected || crossing.second->isAttributeCarrierSelected()) {
342 result.push_back(crossing.second);
343 }
344 }
345 for (const auto& edge : myEdges) {
346 if (!onlySelected || edge.second->isAttributeCarrierSelected()) {
347 result.push_back(edge.second);
348 }
349 }
350 for (const auto& lane : myLanes) {
351 if (!onlySelected || lane.second->isAttributeCarrierSelected()) {
352 result.push_back(lane.second);
353 }
354 }
355 for (const auto& connection : myConnections) {
356 if (!onlySelected || connection.second->isAttributeCarrierSelected()) {
357 result.push_back(connection.second);
358 }
359 }
360 for (const auto& additionalSet : myAdditionals) {
361 for (const auto& additional : additionalSet.second) {
362 if (!onlySelected || additional.second->isAttributeCarrierSelected()) {
363 result.push_back(additional.second);
364 }
365 }
366 }
367 } else if (supermode == Supermode::DEMAND) {
368 for (const auto& demandElementSet : myDemandElements) {
369 for (const auto& demandElement : demandElementSet.second) {
370 if (!onlySelected || demandElement.second->isAttributeCarrierSelected()) {
371 result.push_back(demandElement.second);
372 }
373 }
374 }
375 } else if (supermode == Supermode::DATA) {
376 for (const auto& dataSet : myDataSets) {
377 if (!onlySelected || dataSet.second->isAttributeCarrierSelected()) {
378 result.push_back(dataSet.second);
379 }
380 }
381 for (const auto& dataInterval : myDataIntervals) {
382 if (!onlySelected || dataInterval.second->isAttributeCarrierSelected()) {
383 result.push_back(dataInterval.second);
384 }
385 }
386 for (const auto& genericDataSet : myGenericDatas) {
387 for (const auto& genericData : genericDataSet.second) {
388 if (!onlySelected || genericData.second->isAttributeCarrierSelected()) {
389 result.push_back(genericData.second);
390 }
391 }
392 }
393 for (const auto& meanDataSet : myMeanDatas) {
394 for (const auto& meanData : meanDataSet.second) {
395 if (!onlySelected || meanData.second->isAttributeCarrierSelected()) {
396 result.push_back(meanData.second);
397 }
398 }
399 }
400 }
401 return result;
402}
403
404
405std::vector<GNEAttributeCarrier*>
407 // get modes
408 const auto& editModes = myNet->getViewNet()->getEditModes();
409 // declare vector to save result
410 std::vector<GNEAttributeCarrier*> result;
411 result.reserve(gSelected.getSelected().size());
412 // iterate over all elements of global selection
413 for (const auto& glID : gSelected.getSelected()) {
414 // obtain AC
415 GNEAttributeCarrier* AC = retrieveAttributeCarrier(glID, false);
416 // check if attribute carrier exist and is selected
417 if (AC && AC->isAttributeCarrierSelected()) {
418 if (ignoreCurrentSupermode) {
419 result.push_back(AC);
420 } else if (editModes.isCurrentSupermodeNetwork() && (AC->getTagProperty().isNetworkElement() ||
422 result.push_back(AC);
423 } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty().isDemandElement()) {
424 result.push_back(AC);
425 } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty().isDataElement()) {
426 result.push_back(AC);
427 }
428 }
429 }
430 return result;
431}
432
433
435GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
436 auto it = myJunctions.find(id);
437 if (it != myJunctions.end()) {
438 return it->second;
439 }
440 if (hardFail) {
441 // If junction wasn't found, throw exception
442 throw UnknownElement("Attempted to retrieve non-existant junction " + id);
443 } else {
444 return nullptr;
445 }
446}
447
448
449const std::map<std::string, GNEJunction*>&
451 return myJunctions;
452}
453
454
455std::vector<GNEJunction*>
457 std::vector<GNEJunction*> result;
458 // returns junctions depending of selection
459 for (const auto& junction : myJunctions) {
460 if (junction.second->isAttributeCarrierSelected()) {
461 result.push_back(junction.second);
462 }
463 }
464 return result;
465}
466
467
470 // increase reference
471 junction->incRef("GNENet::registerJunction");
472 junction->setResponsible(false);
473 myJunctions[junction->getMicrosimID()] = junction;
474 myNumberOfNetworkElements++;
475 // expand net boundary
476 myNet->expandBoundary(junction->getCenteringBoundary());
477 // add edge into grid
478 myNet->addGLObjectIntoGrid(junction);
479 // update geometry
480 junction->updateGeometry();
481 // add z in net boundary
482 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
483 return junction;
484}
485
486
487void
489 myJunctions.clear();
490}
491
492
493void
495 // make a copy of junctions
496 auto junctionCopy = myJunctions;
497 // clear junctions
498 myJunctions.clear();
499 // fill junctions again
500 for (const auto& junction : junctionCopy) {
501 // update microsim ID
502 junction.second->setNetworkElementID(prefix + junction.first);
503 // insert in myJunctions again
504 myJunctions[prefix + junction.first] = junction.second;
505 }
506}
507
508
509void
511 if (myJunctions.count(junction->getID()) == 0) {
512 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
513 } else if (myJunctions.count(newID) != 0) {
514 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
515 } else {
516 // remove junction from container
517 myJunctions.erase(junction->getNBNode()->getID());
518 // rename in NetBuilder
519 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
520 // update microsim ID
521 junction->setNetworkElementID(newID);
522 // add it into myJunctions again
523 myJunctions[junction->getID()] = junction;
524 // build crossings
525 junction->getNBNode()->buildCrossings();
526 // net has to be saved
527 myNet->getSavingStatus()->requireSaveNetwork();
528 }
529}
530
531
532int
534 int counter = 0;
535 for (const auto& junction : myJunctions) {
536 if (junction.second->isAttributeCarrierSelected()) {
537 counter++;
538 }
539 }
540 return counter;
541}
542
543
546 auto it = myCrossings.find(glObject);
547 if (it != myCrossings.end()) {
548 return it->second;
549 }
550 if (hardFail) {
551 // If junction wasn't found, throw exception
552 throw UnknownElement("Attempted to retrieve non-existant crossing " + glObject->getMicrosimID());
553 } else {
554 return nullptr;
555 }
556}
557
558
559const std::unordered_map<const GUIGlObject*, GNECrossing*>&
561 return myCrossings;
562}
563
564
565std::vector<GNECrossing*>
567 std::vector<GNECrossing*> result;
568 // iterate over crossings
569 for (const auto& crossing : myCrossings) {
570 if (crossing.second->isAttributeCarrierSelected()) {
571 result.push_back(crossing.second);
572 }
573 }
574 return result;
575}
576
577
578int
580 int counter = 0;
581 for (const auto& crossing : myCrossings) {
582 if (crossing.second->isAttributeCarrierSelected()) {
583 counter++;
584 }
585 }
586 return counter;
587}
588
589
592 auto it = myWalkingAreas.find(glObject);
593 if (it != myWalkingAreas.end()) {
594 return it->second;
595 }
596 if (hardFail) {
597 // If junction wasn't found, throw exception
598 throw UnknownElement("Attempted to retrieve non-existant walkingArea " + glObject->getMicrosimID());
599 } else {
600 return nullptr;
601 }
602}
603
604
605const std::unordered_map<const GUIGlObject*, GNEWalkingArea*>&
607 return myWalkingAreas;
608}
609
610
611std::vector<GNEWalkingArea*>
613 std::vector<GNEWalkingArea*> result;
614 // iterate over walkingAreas
615 for (const auto& walkingArea : myWalkingAreas) {
616 if (walkingArea.second->isAttributeCarrierSelected()) {
617 result.push_back(walkingArea.second);
618 }
619 }
620 return result;
621}
622
623
624int
626 int counter = 0;
627 for (const auto& walkingArea : myWalkingAreas) {
628 if (walkingArea.second->isAttributeCarrierSelected()) {
629 counter++;
630 }
631 }
632 return counter;
633}
634
635
637GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
638 if (myEdgeTypes.count(id) > 0) {
639 return myEdgeTypes.at(id);
640 } else if (hardFail) {
641 // If edge wasn't found, throw exception
642 throw UnknownElement("Attempted to retrieve non-existant EdgeType " + id);
643 } else {
644 return nullptr;
645 }
646}
647
648
651 // increase reference
652 edgeType->incRef("GNENet::registerEdgeType");
653 // add it in container
654 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
655 return edgeType;
656}
657
658
659const std::map<std::string, GNEEdgeType*>&
661 return myEdgeTypes;
662}
663
664
666 myEdgeTypes.clear();
667}
668
669
670void
672 if (myEdgeTypes.count(edgeType->getID()) == 0) {
673 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
674 } else if (myEdgeTypes.count(newID) != 0) {
675 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
676 } else {
677 // remove edgeType from container
678 myEdgeTypes.erase(edgeType->getID());
679 // rename in typeCont
680 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
681 // update microsim ID
682 edgeType->setNetworkElementID(newID);
683 // add it into myEdgeTypes again
684 myEdgeTypes[edgeType->getID()] = edgeType;
685 // net has to be saved
686 myNet->getSavingStatus()->requireSaveNetwork();
687 }
688}
689
690
691std::string
693 int counter = 0;
694 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
695 counter++;
696 }
697 return ("edgeType_" + toString(counter));
698}
699
700
701GNEEdge*
702GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
703 auto it = myEdges.find(id);
704 if (it != myEdges.end()) {
705 return it->second;
706 }
707 if (hardFail) {
708 // If edge wasn't found, throw exception
709 throw UnknownElement("Attempted to retrieve non-existant edge " + id);
710 } else {
711 return nullptr;
712 }
713}
714
715
716std::vector<GNEEdge*>
718 if ((from == nullptr) || (to == nullptr)) {
719 throw UnknownElement("Junctions cannot be nullptr");
720 }
721 std::vector<GNEEdge*> edges;
722 // iterate over outgoing edges of from edge and check to junction
723 for (const auto& edgeTo : from->getGNEOutgoingEdges()) {
724 if (edgeTo->getToJunction() == to) {
725 edges.push_back(edgeTo);
726 }
727 }
728 return edges;
729}
730
731
732const std::map<std::string, GNEEdge*>&
734 return myEdges;
735}
736
737
738std::vector<GNEEdge*>
740 std::vector<GNEEdge*> result;
741 // returns edges depending of selection
742 for (const auto& edge : myEdges) {
743 if (edge.second->isAttributeCarrierSelected()) {
744 result.push_back(edge.second);
745 }
746 }
747 return result;
748}
749
750
751GNEEdge*
753 edge->incRef("GNENet::registerEdge");
754 edge->setResponsible(false);
755 // add edge to internal container of GNENet
756 myEdges[edge->getMicrosimID()] = edge;
757 myNumberOfNetworkElements++;
758 // insert all lanes
759 for (const auto& lane : edge->getLanes()) {
760 insertLane(lane);
761 }
762 // Add references into GNEJunctions
763 edge->getFromJunction()->addOutgoingGNEEdge(edge);
764 edge->getToJunction()->addIncomingGNEEdge(edge);
765 // update boundaries of both junctions (to remove it from Grid)
768 // update edge boundary
769 edge->updateCenteringBoundary(false);
770 // expand edge boundary
771 myNet->expandBoundary(edge->getCenteringBoundary());
772 // finally add edge into grid
773 myNet->addGLObjectIntoGrid(edge);
774 return edge;
775}
776
777
778void
782
783
784void
786 // make a copy of edges
787 auto edgeCopy = myEdges;
788 // clear edges
789 myEdges.clear();
790 // fill edges again
791 for (const auto& edge : edgeCopy) {
792 // update microsim ID
793 edge.second->setNetworkElementID(prefix + edge.first);
794 // insert in myEdges again
795 myEdges[prefix + edge.first] = edge.second;
796 }
797}
798
799
800void
802 if (myEdges.count(edge->getID()) == 0) {
803 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
804 } else if (myEdges.count(newID) != 0) {
805 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
806 } else {
807 // remove edge from container
808 myEdges.erase(edge->getNBEdge()->getID());
809 // rename in NetBuilder
810 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
811 // update microsim ID
812 edge->setEdgeID(newID);
813 // add it into myEdges again
814 myEdges[edge->getID()] = edge;
815 // rename all connections related to this edge
816 for (const auto& lane : edge->getLanes()) {
817 lane->updateConnectionIDs();
818 }
819 // net has to be saved
820 myNet->getSavingStatus()->requireSaveNetwork();
821 }
822}
823
824
825int
827 int counter = 0;
828 for (const auto& edge : myEdges) {
829 if (edge.second->isAttributeCarrierSelected()) {
830 counter++;
831 }
832 }
833 return counter;
834}
835
836
837GNELane*
838GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
839 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
840 const GNEEdge* edge = retrieveEdge(edge_id, false);
841 if (edge != nullptr) {
842 GNELane* lane = nullptr;
843 // search lane in lane's edges
844 for (auto laneIt : edge->getLanes()) {
845 if (laneIt->getID() == id) {
846 lane = laneIt;
847 }
848 }
849 // throw exception or return nullptr if lane wasn't found
850 if (lane == nullptr) {
851 if (hardFail) {
852 // Throw exception if hardFail is enabled
853 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
854 }
855 } else {
856 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
857 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
858 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getLanes().size()) {
859 return edge->getLanes().at(lane->getIndex() + 1);
860 }
861 return lane;
862 }
863 } else if (hardFail) {
864 // Throw exception if hardFail is enabled
865 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
866 }
867 return nullptr;
868}
869
870
871GNELane*
872GNENetHelper::AttributeCarriers::retrieveLane(const GUIGlObject* glObject, bool hardFail) const {
873 auto it = myLanes.find(glObject);
874 if (it != myLanes.end()) {
875 return it->second;
876 }
877 if (hardFail) {
878 // If junction wasn't found, throw exception
879 throw UnknownElement("Attempted to retrieve non-existant lane " + glObject->getMicrosimID());
880 } else {
881 return nullptr;
882 }
883}
884
885
886const std::unordered_map<const GUIGlObject*, GNELane*>&
888 return myLanes;
889}
890
891
892std::vector<GNELane*>
894 std::vector<GNELane*> result;
895 // returns lanes depending of selection
896 for (const auto& lane : myLanes) {
897 if (lane.second->isAttributeCarrierSelected()) {
898 result.push_back(lane.second);
899 }
900 }
901 return result;
902}
903
904
905int
907 int counter = 0;
908 for (const auto& lane : myLanes) {
909 if (lane.second->isAttributeCarrierSelected()) {
910 counter++;
911 }
912 }
913 return counter;
914}
915
916
918GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
919 // iterate over connections
920 for (const auto& connection : myConnections) {
921 if (connection.second->getID() == id) {
922 return connection.second;
923 }
924 }
925 if (hardFail) {
926 // If POI wasn't found, throw exception
927 throw UnknownElement("Attempted to retrieve non-existant connection " + id);
928 } else {
929 return nullptr;
930 }
931}
932
933
936 auto it = myConnections.find(glObject);
937 if (it != myConnections.end()) {
938 return it->second;
939 }
940 if (hardFail) {
941 // If POI wasn't found, throw exception
942 throw UnknownElement("Attempted to retrieve non-existant connection " + glObject->getMicrosimID());
943 } else {
944 return nullptr;
945 }
946}
947
948
949const std::unordered_map<const GUIGlObject*, GNEConnection*>&
951 return myConnections;
952}
953
954
955std::vector<GNEConnection*>
957 std::vector<GNEConnection*> result;
958 // returns connections depending of selection
959 for (const auto& connection : myConnections) {
960 if (connection.second->isAttributeCarrierSelected()) {
961 result.push_back(connection.second);
962 }
963 }
964 return result;
965}
966
967
968int
970 int counter = 0;
971 for (const auto& connection : myConnections) {
972 if (connection.second->isAttributeCarrierSelected()) {
973 counter++;
974 }
975 }
976 return counter;
977}
978
979
982 auto it = myInternalLanes.find(glObject);
983 if (it != myInternalLanes.end()) {
984 return it->second;
985 }
986 if (hardFail) {
987 // If POI wasn't found, throw exception
988 throw UnknownElement("Attempted to retrieve non-existant internalLane " + glObject->getMicrosimID());
989 } else {
990 return nullptr;
991 }
992}
993
994
996GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
997 auto it = myAdditionalIDs.at(type).find(id);
998 if (it != myAdditionalIDs.at(type).end()) {
999 return it->second;
1000 }
1001 if (hardFail) {
1002 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1003 } else {
1004 return nullptr;
1005 }
1006}
1007
1008
1010GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1011 for (const auto& type : types) {
1012 auto it = myAdditionalIDs.at(type).find(id);
1013 if (it != myAdditionalIDs.at(type).end()) {
1014 return it->second;
1015 }
1016 }
1017 if (hardFail) {
1018 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1019 } else {
1020 return nullptr;
1021 }
1022}
1023
1024
1027 // iterate over all additionals
1028 for (const auto& additionalTag : myAdditionals) {
1029 auto it = additionalTag.second.find(glObject);
1030 if (it != additionalTag.second.end()) {
1031 return it->second;
1032 }
1033 }
1034 if (hardFail) {
1035 throw ProcessError("Attempted to retrieve non-existant additional (glObject)");
1036 } else {
1037 return nullptr;
1038 }
1039}
1040
1041
1043GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
1044 // first retrieve rerouter
1045 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
1046 // parse begin and end
1047 const std::string beginStr = time2string(begin);
1048 const std::string endStr = time2string(end);
1049 // now iterate over all children and check begin and end
1050 for (const auto& interval : rerouter->getChildAdditionals()) {
1051 // check tag (to avoid symbols)
1052 if (interval->getTagProperty().getTag() == SUMO_TAG_INTERVAL) {
1053 // check begin and end
1054 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
1055 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
1056 return interval;
1057 }
1058 }
1059 }
1060 // throw exception
1061 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
1062}
1063
1064
1065const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*> >&
1067 return myAdditionals;
1068}
1069
1070
1071std::vector<GNEAdditional*>
1073 std::vector<GNEAdditional*> result;
1074 // returns additionals depending of selection
1075 for (const auto& additionalsTags : myAdditionals) {
1076 for (const auto& additional : additionalsTags.second) {
1077 if (additional.second->isAttributeCarrierSelected()) {
1078 result.push_back(additional.second);
1079 }
1080 }
1081 }
1082 return result;
1083}
1084
1085
1086std::vector<GNEAdditional*>
1088 std::vector<GNEAdditional*> result;
1089 // returns additionals depending of selection
1090 for (const auto& additionalsTags : myAdditionals) {
1091 for (const auto& additional : additionalsTags.second) {
1092 if (additional.second->getTagProperty().isShapeElement() && additional.second->isAttributeCarrierSelected()) {
1093 result.push_back(additional.second);
1094 }
1095 }
1096 }
1097 return result;
1098}
1099
1100
1101int
1103 int counter = 0;
1104 for (const auto& additionalsTag : myAdditionals) {
1105 counter += (int)additionalsTag.second.size();
1106 }
1107 return counter;
1108}
1109
1110
1111void
1113 // clear elements in grid
1114 for (const auto& additionalsTags : myAdditionals) {
1115 for (const auto& additional : additionalsTags.second) {
1116 myNet->removeGLObjectFromGrid(additional.second);
1117 }
1118 }
1119 // iterate over myAdditionals and clear all additionals
1120 for (auto& additionals : myAdditionals) {
1121 additionals.second.clear();
1122 }
1123 for (auto& additionals : myAdditionalIDs) {
1124 additionals.second.clear();
1125 }
1126}
1127
1128
1129void
1131 const auto tag = additional->getTagProperty().getTag();
1132 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1133 if (it == myAdditionalIDs.at(tag).end()) {
1134 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1135 } else {
1136 // remove from container, set new Id, and insert it again
1137 myAdditionalIDs.at(tag).erase(it);
1138 // set microsim ID
1139 additional->setMicrosimID(newID);
1140 myAdditionalIDs.at(tag)[newID] = additional;
1141 }
1142}
1143
1144
1145std::string
1147 // obtain option container
1148 const auto& neteditOptions = OptionsCont::getOptions();
1149 // get prefix
1150 std::string prefix;
1151 if (tag == SUMO_TAG_BUS_STOP) {
1152 prefix = neteditOptions.getString("busStop-prefix");
1153 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1154 prefix = neteditOptions.getString("trainStop-prefix");
1155 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1156 prefix = neteditOptions.getString("containerStop-prefix");
1157 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1158 prefix = neteditOptions.getString("chargingStation-prefix");
1159 } else if (tag == SUMO_TAG_PARKING_AREA) {
1160 prefix = neteditOptions.getString("parkingArea-prefix");
1161 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1162 prefix = neteditOptions.getString("e1Detector-prefix");
1163 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1164 prefix = neteditOptions.getString("e2Detector-prefix");
1165 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1166 prefix = neteditOptions.getString("e3Detector-prefix");
1167 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1168 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1169 } else if (tag == SUMO_TAG_REROUTER) {
1170 prefix = neteditOptions.getString("rerouter-prefix");
1171 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1172 prefix = neteditOptions.getString("calibrator-prefix");
1173 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1174 prefix = neteditOptions.getString("routeProbe-prefix");
1175 } else if (tag == SUMO_TAG_VSS) {
1176 prefix = neteditOptions.getString("vss-prefix");
1177 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1178 prefix = neteditOptions.getString("tractionSubstation-prefix");
1179 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1180 prefix = neteditOptions.getString("overheadWire-prefix");
1181 } else if (tag == SUMO_TAG_POLY) {
1182 prefix = neteditOptions.getString("polygon-prefix");
1183 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1184 prefix = neteditOptions.getString("poi-prefix");
1185 } else if (tag == SUMO_TAG_TAZ) {
1186 prefix = toString(SUMO_TAG_TAZ);
1187 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1188 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1189 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1190 prefix = neteditOptions.getString("jps.obstacle-prefix");
1191 }
1192 int counter = 0;
1193 // check namespaces
1194 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1195 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1196 counter++;
1197 }
1198 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1199 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1200 counter++;
1201 }
1202 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1203 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1204 counter++;
1205 }
1206 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1207 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1208 counter++;
1209 }
1210 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1211 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1212 counter++;
1213 }
1214 } else {
1215 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1216 counter++;
1217 }
1218 }
1219 // return new element ID
1220 return (prefix + "_" + toString(counter));
1221}
1222
1223
1224int
1226 int counter = 0;
1227 for (const auto& additionalsTags : myAdditionals) {
1228 for (const auto& additional : additionalsTags.second) {
1229 if (additional.second->isAttributeCarrierSelected()) {
1230 counter++;
1231 }
1232 }
1233 }
1234 return counter;
1235}
1236
1237
1238int
1240 return getNumberOfSelectedAdditionals() -
1241 // shapes
1242 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1243 // JuPedSims
1244 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1245 // TAZ
1246 getNumberOfSelectedTAZs() - getNumberOfSelectedTAZSources() - getNumberOfSelectedTAZSinks() -
1247 // wires
1248 getNumberOfSelectedWires();
1249}
1250
1251
1252int
1254 int counter = 0;
1255 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1256 if (poly.second->isAttributeCarrierSelected()) {
1257 counter++;
1258 }
1259 }
1260 return counter;
1261}
1262
1263
1264int
1266 int counter = 0;
1267 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1268 if (walkableArea.second->isAttributeCarrierSelected()) {
1269 counter++;
1270 }
1271 }
1272 return counter;
1273}
1274
1275
1276int
1278 int counter = 0;
1279 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1280 if (obstacle.second->isAttributeCarrierSelected()) {
1281 counter++;
1282 }
1283 }
1284 return counter;
1285}
1286
1287
1288int
1290 int counter = 0;
1291 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1292 if (POI.second->isAttributeCarrierSelected()) {
1293 counter++;
1294 }
1295 }
1296 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1297 if (POILane.second->isAttributeCarrierSelected()) {
1298 counter++;
1299 }
1300 }
1301 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1302 if (POIGEO.second->isAttributeCarrierSelected()) {
1303 counter++;
1304 }
1305 }
1306 return counter;
1307}
1308
1309
1310int
1312 int counter = 0;
1313 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1314 if (TAZ.second->isAttributeCarrierSelected()) {
1315 counter++;
1316 }
1317 }
1318 return counter;
1319}
1320
1321
1322int
1324 int counter = 0;
1325 for (const auto& TAZSource : myAdditionals.at(SUMO_TAG_TAZSOURCE)) {
1326 if (TAZSource.second->isAttributeCarrierSelected()) {
1327 counter++;
1328 }
1329 }
1330 return counter;
1331}
1332
1333
1334int
1336 int counter = 0;
1337 for (const auto& TAZSink : myAdditionals.at(SUMO_TAG_TAZSINK)) {
1338 if (TAZSink.second->isAttributeCarrierSelected()) {
1339 counter++;
1340 }
1341 }
1342 return counter;
1343}
1344
1345
1346int
1348 int counter = 0;
1349 for (const auto& additionalsTags : myAdditionals) {
1350 for (const auto& additional : additionalsTags.second) {
1351 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty().isWireElement()) {
1352 counter++;
1353 }
1354 }
1355 }
1356 return counter;
1357}
1358
1359
1361GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1362 auto it = myDemandElementIDs.at(type).find(id);
1363 if (it != myDemandElementIDs.at(type).end()) {
1364 return it->second;
1365 }
1366 if (hardFail) {
1367 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1368 } else {
1369 return nullptr;
1370 }
1371}
1372
1373
1375GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1376 for (const auto& type : types) {
1377 auto it = myDemandElementIDs.at(type).find(id);
1378 if (it != myDemandElementIDs.at(type).end()) {
1379 return it->second;
1380 }
1381 }
1382 if (hardFail) {
1383 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1384 } else {
1385 return nullptr;
1386 }
1387}
1388
1389
1392 // iterate over all demand elements
1393 for (const auto& demandElementTag : myDemandElements) {
1394 auto it = demandElementTag.second.find(glObject);
1395 if (it != demandElementTag.second.end()) {
1396 return it->second;
1397 }
1398 }
1399 if (hardFail) {
1400 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1401 } else {
1402 return nullptr;
1403 }
1404}
1405
1406
1407std::vector<GNEDemandElement*>
1409 std::vector<GNEDemandElement*> result;
1410 // returns demand elements depending of selection
1411 for (const auto& demandElementTag : myDemandElements) {
1412 for (const auto& demandElement : demandElementTag.second) {
1413 if (demandElement.second->isAttributeCarrierSelected()) {
1414 result.push_back(demandElement.second);
1415 }
1416 }
1417 }
1418 return result;
1419}
1420
1421
1422const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*> >&
1424 return myDemandElements;
1425}
1426
1427
1428std::string
1430 // obtain option container
1431 const auto& neteditOptions = OptionsCont::getOptions();
1432 // get tag property
1433 const auto tagProperty = GNEAttributeCarrier::getTagProperty(tag);
1434 // get prefix
1435 std::string prefix;
1436 if (tag == SUMO_TAG_ROUTE) {
1437 prefix = neteditOptions.getString("route-prefix");
1438 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1439 prefix = neteditOptions.getString("routeDistribution-prefix");
1440 } else if (tag == SUMO_TAG_VTYPE) {
1441 prefix = neteditOptions.getString("vType-prefix");
1442 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1443 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1444 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1445 prefix = neteditOptions.getString("trip-prefix");
1446 } else if (tagProperty.isVehicle() && !tagProperty.isFlow()) {
1447 prefix = neteditOptions.getString("vehicle-prefix");
1448 } else if (tagProperty.isPerson()) {
1449 if (tagProperty.isFlow()) {
1450 prefix = neteditOptions.getString("personflow-prefix");
1451 } else {
1452 prefix = neteditOptions.getString("person-prefix");
1453 }
1454 } else if (tagProperty.isContainer()) {
1455 if (tagProperty.isFlow()) {
1456 prefix = neteditOptions.getString("containerflow-prefix");
1457 } else {
1458 prefix = neteditOptions.getString("container-prefix");
1459 }
1460 } else if (tagProperty.isFlow()) {
1461 prefix = neteditOptions.getString("flow-prefix");
1462 }
1463 // declare counter
1464 int counter = 0;
1465 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1466 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1467 counter++;
1468 }
1469 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1470 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1471 counter++;
1472 }
1473 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1474 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1475 counter++;
1476 }
1477 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1478 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1479 counter++;
1480 }
1481 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1482 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1483 counter++;
1484 }
1485 } else {
1486 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1487 counter++;
1488 }
1489 }
1490 // return new element ID
1491 return (prefix + "_" + toString(counter));
1492
1493}
1494
1495
1498 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1499 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1500 return it->second;
1501 }
1502 throw ProcessError(TL("Default vType doesn't exist"));
1503}
1504
1505
1506void
1508 // clear elements in grid
1509 for (const auto& demandElementsTags : myDemandElements) {
1510 for (const auto& demandElement : demandElementsTags.second) {
1511 myNet->removeGLObjectFromGrid(demandElement.second);
1512 }
1513 }
1514 // iterate over myDemandElements and clear all demand elements
1515 for (auto& demandElements : myDemandElements) {
1516 demandElements.second.clear();
1517 }
1518 for (auto& demandElements : myDemandElementIDs) {
1519 demandElements.second.clear();
1520 }
1521}
1522
1523
1524void
1526 const auto tag = demandElement->getTagProperty().getTag();
1527 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1528 if (it == myDemandElementIDs.at(tag).end()) {
1529 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1530 } else {
1531 // remove from container, set new Id, and insert it again
1532 myDemandElementIDs.at(tag).erase(it);
1533 // set microsim ID
1534 demandElement->setMicrosimID(newID);
1535 myDemandElementIDs.at(tag)[newID] = demandElement;
1536 }
1537}
1538
1539
1540void
1542 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1543 GNEVType* defaultVehicleType = new GNEVType(myNet, DEFAULT_VTYPE_ID, SVC_PASSENGER);
1544 myDemandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1545 myDemandElementIDs.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1546 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1547
1548 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1549 GNEVType* defaultBikeType = new GNEVType(myNet, DEFAULT_BIKETYPE_ID, SVC_BICYCLE);
1550 myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1551 myDemandElementIDs.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1552 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1553 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1554
1555 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1556 GNEVType* defaultTaxiType = new GNEVType(myNet, DEFAULT_TAXITYPE_ID, SVC_TAXI);
1557 myDemandElements.at(defaultTaxiType->getTagProperty().getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1558 myDemandElementIDs.at(defaultTaxiType->getTagProperty().getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1559 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1560 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1561
1562 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1563 GNEVType* defaultRailType = new GNEVType(myNet, DEFAULT_RAILTYPE_ID, SVC_RAIL);
1564 myDemandElements.at(defaultRailType->getTagProperty().getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1565 myDemandElementIDs.at(defaultRailType->getTagProperty().getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1566 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1567 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1568
1569 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1570 GNEVType* defaultPersonType = new GNEVType(myNet, DEFAULT_PEDTYPE_ID, SVC_PEDESTRIAN);
1571 myDemandElements.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1572 myDemandElementIDs.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1573 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1574 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1575
1576 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1577 GNEVType* defaultContainerType = new GNEVType(myNet, DEFAULT_CONTAINERTYPE_ID, SVC_IGNORING);
1578 myDemandElements.at(defaultContainerType->getTagProperty().getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1579 myDemandElementIDs.at(defaultContainerType->getTagProperty().getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1580 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1581 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1582}
1583
1584
1585int
1587 return myStopIndex++;
1588}
1589
1590
1591int
1593 int counter = 0;
1594 for (const auto& demandElementsTags : myDemandElements) {
1595 for (const auto& demandElement : demandElementsTags.second) {
1596 if (demandElement.second->isAttributeCarrierSelected()) {
1597 counter++;
1598 }
1599 }
1600 }
1601 return counter;
1602}
1603
1604
1605int
1607 int counter = 0;
1608 // iterate over routes
1609 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1610 if (route.second->isAttributeCarrierSelected()) {
1611 counter++;
1612 }
1613 }
1614 // iterate over vehicles with embedded routes
1615 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1616 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1617 counter++;
1618 }
1619 }
1620 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1621 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1622 counter++;
1623 }
1624 }
1625 return counter;
1626}
1627
1628
1629int
1631 int counter = 0;
1632 // iterate over all vehicles and flows
1633 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1634 if (vehicle.second->isAttributeCarrierSelected()) {
1635 counter++;
1636 }
1637 }
1638 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1639 if (trip.second->isAttributeCarrierSelected()) {
1640 counter++;
1641 }
1642 }
1643 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1644 if (vehicle.second->isAttributeCarrierSelected()) {
1645 counter++;
1646 }
1647 }
1648 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1649 if (flow.second->isAttributeCarrierSelected()) {
1650 counter++;
1651 }
1652 }
1653 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1654 if (flow.second->isAttributeCarrierSelected()) {
1655 counter++;
1656 }
1657 }
1658 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1659 if (flow.second->isAttributeCarrierSelected()) {
1660 counter++;
1661 }
1662 }
1663 return counter;
1664}
1665
1666
1667int
1669 int counter = 0;
1670 // iterate over all persons
1671 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1672 if (person.second->isAttributeCarrierSelected()) {
1673 counter++;
1674 }
1675 }
1676 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1677 if (personFlow.second->isAttributeCarrierSelected()) {
1678 counter++;
1679 }
1680 }
1681 return counter;
1682}
1683
1684
1685int
1687 int counter = 0;
1688 // iterate over all person plans
1689 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1690 for (const auto& personPlan : person.second->getChildDemandElements()) {
1691 if (personPlan->getTagProperty().isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1692 counter++;
1693 }
1694 }
1695 }
1696 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1697 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1698 if (personPlan->getTagProperty().isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1699 counter++;
1700 }
1701 }
1702 }
1703 return counter;
1704}
1705
1706
1707int
1709 int counter = 0;
1710 // iterate over all person plans
1711 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1712 for (const auto& personPlan : person.second->getChildDemandElements()) {
1713 if (personPlan->getTagProperty().isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1714 counter++;
1715 }
1716 }
1717 }
1718 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1719 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1720 if (personPlan->getTagProperty().isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1721 counter++;
1722 }
1723 }
1724 }
1725 return counter;
1726}
1727
1728
1729int
1731 int counter = 0;
1732 // iterate over all person plans
1733 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1734 for (const auto& personPlan : person.second->getChildDemandElements()) {
1735 if (personPlan->getTagProperty().isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1736 counter++;
1737 }
1738 }
1739 }
1740 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1741 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1742 if (personPlan->getTagProperty().isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1743 counter++;
1744 }
1745 }
1746 }
1747 return counter;
1748}
1749
1750
1751int
1753 int counter = 0;
1754 // iterate over all containers
1755 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1756 if (container.second->isAttributeCarrierSelected()) {
1757 counter++;
1758 }
1759 }
1760 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1761 if (containerFlow.second->isAttributeCarrierSelected()) {
1762 counter++;
1763 }
1764 }
1765 return counter;
1766}
1767
1768
1769int
1771 int counter = 0;
1772 // iterate over all container plans
1773 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1774 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1775 if (containerPlan->getTagProperty().isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1776 counter++;
1777 }
1778 }
1779 }
1780 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1781 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1782 if (containerPlan->getTagProperty().isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1783 counter++;
1784 }
1785 }
1786 }
1787 return counter;
1788}
1789
1790
1791int
1793 int counter = 0;
1794 // iterate over all container plans
1795 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1796 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1797 if (containerPlan->getTagProperty().isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1798 counter++;
1799 }
1800 }
1801 }
1802 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1803 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1804 if (containerPlan->getTagProperty().isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1805 counter++;
1806 }
1807 }
1808 }
1809 return counter;
1810}
1811
1812
1813int
1815 int counter = 0;
1816 // iterate over routes
1817 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1818 if (route.second->isAttributeCarrierSelected()) {
1819 counter++;
1820 }
1821 }
1822 // vehicles
1823 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1824 for (const auto& stop : trip.second->getChildDemandElements()) {
1825 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1826 counter++;
1827 }
1828 }
1829 }
1830 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1831 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1832 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1833 counter++;
1834 }
1835 }
1836 }
1837 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1838 for (const auto& stop : flow.second->getChildDemandElements()) {
1839 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1840 counter++;
1841 }
1842 }
1843 }
1844 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1845 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1846 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1847 counter++;
1848 }
1849 }
1850 }
1851 // persons
1852 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1853 for (const auto& personPlan : person.second->getChildDemandElements()) {
1854 if (personPlan->getTagProperty().isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1855 counter++;
1856 }
1857 }
1858 }
1859 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1860 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1861 if (personPlan->getTagProperty().isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1862 counter++;
1863 }
1864 }
1865 }
1866 // containers
1867 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1868 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1869 if (containerPlan->getTagProperty().isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1870 counter++;
1871 }
1872 }
1873 }
1874 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1875 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1876 if (containerPlan->getTagProperty().isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1877 counter++;
1878 }
1879 }
1880 }
1881 return counter;
1882}
1883
1884
1886GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1887 for (const auto& dataSet : myDataSets) {
1888 if (dataSet.second->getID() == id) {
1889 return dataSet.second;
1890 }
1891 }
1892 if (hardFail) {
1893 throw ProcessError("Attempted to retrieve non-existant data set");
1894 } else {
1895 return nullptr;
1896 }
1897}
1898
1899
1900const std::map<const std::string, GNEDataSet*>&
1902 return myDataSets;
1903}
1904
1905
1906std::string
1908 const std::string dataSetTagStr = toString(SUMO_TAG_DATASET);
1909 int counter = 0;
1910 while (retrieveDataSet(prefix + dataSetTagStr + "_" + toString(counter), false) != nullptr) {
1911 counter++;
1912 }
1913 return (prefix + dataSetTagStr + "_" + toString(counter));
1914}
1915
1916
1919 if (myDataIntervals.count(AC)) {
1920 return myDataIntervals.at(AC);
1921 } else if (hardFail) {
1922 throw ProcessError("Attempted to retrieve non-existant data interval");
1923 } else {
1924 return nullptr;
1925 }
1926}
1927
1928
1929const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
1931 return myDataIntervals;
1932}
1933
1934
1935void
1937 if (myDataIntervals.count(AC) > 0) {
1938 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
1939 } else {
1940 myDataIntervals[AC] = dataInterval;
1941 }
1942 // mark interval toolbar for update
1943 myNet->getViewNet()->getIntervalBar().markForUpdate();
1944}
1945
1946
1947void
1949 const auto finder = myDataIntervals.find(dataInterval);
1950 if (finder == myDataIntervals.end()) {
1951 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
1952 } else {
1953 myDataIntervals.erase(finder);
1954 }
1955 // remove it from inspected elements and GNEElementTree
1956 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
1957 dataInterval->unmarkForDrawingFront();
1958 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
1959 // mark interval toolbar for update
1960 myNet->getViewNet()->getIntervalBar().markForUpdate();
1961}
1962
1963
1966 // iterate over all genericDatas
1967 for (const auto& genericDataTag : myGenericDatas) {
1968 auto it = genericDataTag.second.find(glObject);
1969 if (it != genericDataTag.second.end()) {
1970 return it->second;
1971 }
1972 }
1973 if (hardFail) {
1974 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
1975 } else {
1976 return nullptr;
1977 }
1978}
1979
1980
1981std::vector<GNEGenericData*>
1983 std::vector<GNEGenericData*> result;
1984 // returns generic datas depending of selection
1985 for (const auto& genericDataTag : myGenericDatas) {
1986 for (const auto& genericData : genericDataTag.second) {
1987 if (genericData.second->isAttributeCarrierSelected()) {
1988 result.push_back(genericData.second);
1989 }
1990 }
1991 }
1992 return result;
1993}
1994
1995
1996const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*> >&
1998 return myGenericDatas;
1999}
2000
2001
2002std::vector<GNEGenericData*>
2003GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2004 // declare generic data vector
2005 std::vector<GNEGenericData*> genericDatas;
2006 // iterate over all data sets
2007 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2008 // check interval
2009 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2010 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2011 genericDatas.push_back(genericData.second);
2012 }
2013 }
2014 return genericDatas;
2015}
2016
2017
2018int
2020 int counter = 0;
2021 // iterate over all generic datas
2022 for (const auto& genericDataTag : myGenericDatas) {
2023 counter += (int)genericDataTag.second.size();
2024 }
2025 return counter;
2026}
2027
2028
2029int
2031 int counter = 0;
2032 // iterate over all edgeDatas
2033 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2034 if (genericData.second->isAttributeCarrierSelected()) {
2035 counter++;
2036 }
2037 }
2038 return counter;
2039}
2040
2041
2042int
2044 int counter = 0;
2045 // iterate over all edgeDatas
2046 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2047 if (genericData.second->isAttributeCarrierSelected()) {
2048 counter++;
2049 }
2050 }
2051 return counter;
2052}
2053
2054
2055int
2057 int counter = 0;
2058 // iterate over all edgeDatas
2059 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2060 if (genericData.second->isAttributeCarrierSelected()) {
2061 counter++;
2062 }
2063 }
2064 return counter;
2065}
2066
2067
2068void
2070 if (myGenericDatas.at(genericData->getTagProperty().getTag()).count(genericData->getGUIGlObject()) > 0) {
2071 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2072 } else {
2073 myGenericDatas.at(genericData->getTagProperty().getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2074 }
2075 // mark interval toolbar for update
2076 myNet->getViewNet()->getIntervalBar().markForUpdate();
2077}
2078
2079
2080void
2082 const auto finder = myGenericDatas.at(genericData->getTagProperty().getTag()).find(genericData);
2083 if (finder == myGenericDatas.at(genericData->getTagProperty().getTag()).end()) {
2084 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2085 } else {
2086 myGenericDatas.at(genericData->getTagProperty().getTag()).erase(finder);
2087 }
2088 // remove it from inspected elements and GNEElementTree
2089 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2090 genericData->unmarkForDrawingFront();
2091 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2092 // delete path element
2093 myNet->getDataPathManager()->removePath(genericData);
2094 // mark interval toolbar for update
2095 myNet->getViewNet()->getIntervalBar().markForUpdate();
2096}
2097
2098
2099std::set<std::string>
2100GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2101 // declare solution
2102 std::set<std::string> attributesSolution;
2103 // declare generic data vector
2104 std::vector<GNEGenericData*> genericDatas;
2105 // iterate over all data sets
2106 for (const auto& interval : myDataIntervals) {
2107 // check interval
2108 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2109 // iterate over generic datas
2110 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2111 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2112 genericDatas.push_back(genericData);
2113 }
2114 }
2115 }
2116 }
2117 // iterate over generic datas
2118 for (const auto& genericData : genericDatas) {
2119 for (const auto& attribute : genericData->getParametersMap()) {
2120 attributesSolution.insert(attribute.first);
2121 }
2122 }
2123 return attributesSolution;
2124}
2125
2126
2127std::set<std::string>
2128GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2129 const std::string& beginStr, const std::string& endStr) const {
2130 // declare solution
2131 std::set<std::string> attributesSolution;
2132 // vector of data sets and intervals
2133 std::vector<GNEDataSet*> dataSets;
2134 std::vector<GNEDataInterval*> dataIntervals;
2135 // get dataSet
2136 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2137 // if dataSetID is empty, return all parameters
2138 if (dataSetID.empty()) {
2139 // add all data sets
2140 dataSets.reserve(myDataSets.size());
2141 for (const auto& dataSet : myDataSets) {
2142 dataSets.push_back(dataSet.second);
2143 }
2144 } else if (retrievedDataSet) {
2145 dataSets.push_back(retrievedDataSet);
2146 } else {
2147 return attributesSolution;
2148 }
2149 // now continue with data intervals
2150 int numberOfIntervals = 0;
2151 for (const auto& dataSet : dataSets) {
2152 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2153 }
2154 // resize dataIntervals
2155 dataIntervals.reserve(numberOfIntervals);
2156 // add intervals
2157 for (const auto& dataSet : dataSets) {
2158 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2159 // continue depending of begin and end
2160 if (beginStr.empty() && endStr.empty()) {
2161 dataIntervals.push_back(dataInterval.second);
2162 } else if (endStr.empty()) {
2163 // parse begin
2164 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2165 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2166 dataIntervals.push_back(dataInterval.second);
2167 }
2168 } else if (beginStr.empty()) {
2169 // parse end
2170 const double end = GNEAttributeCarrier::parse<double>(endStr);
2171 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2172 dataIntervals.push_back(dataInterval.second);
2173 }
2174 } else {
2175 // parse both begin end
2176 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2177 const double end = GNEAttributeCarrier::parse<double>(endStr);
2178 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2179 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2180 dataIntervals.push_back(dataInterval.second);
2181 }
2182 }
2183 }
2184 }
2185 // finally iterate over intervals and get attributes
2186 for (const auto& dataInterval : dataIntervals) {
2187 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2188 // check generic data tag
2189 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2190 for (const auto& attribute : genericData->getParametersMap()) {
2191 attributesSolution.insert(attribute.first);
2192 }
2193 }
2194 }
2195 }
2196 return attributesSolution;
2197}
2198
2199
2201GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2202 for (const auto& meanData : myMeanDatas.at(type)) {
2203 if (meanData.second->getID() == id) {
2204 return meanData.second;
2205 }
2206 }
2207 if (hardFail) {
2208 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2209 } else {
2210 return nullptr;
2211 }
2212}
2213
2214
2215const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*> >&
2217 return myMeanDatas;
2218}
2219
2220
2221int
2223 return myNumberOfMeanDataElements;
2224}
2225
2226
2227void
2229 // iterate over myMeanDatas and clear all meanDatas
2230 for (auto& meanDatas : myMeanDatas) {
2231 meanDatas.second.clear();
2232 }
2233}
2234
2235
2236void
2238 const auto tag = meanData->getTagProperty().getTag();
2239 const auto it = myMeanDatas.at(tag).find(meanData->getID());
2240 if (it == myMeanDatas.at(tag).end()) {
2241 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' doesn't exist in AttributeCarriers.meanDatas");
2242 } else {
2243 // remove from container, set new Id, and insert it again
2244 myMeanDatas.at(tag).erase(it);
2245 myMeanDatas.at(tag)[newID] = meanData;
2246 }
2247}
2248
2249
2250std::string
2252 // obtain option container
2253 const auto& neteditOptions = OptionsCont::getOptions();
2254 // get prefix
2255 std::string prefix;
2256 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2257 prefix = neteditOptions.getString("meanDataEdge-prefix");
2258 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2259 prefix = neteditOptions.getString("meanDataLane-prefix");
2260 }
2261 int counter = 0;
2262 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2263 counter++;
2264 }
2265 return (prefix + "_" + toString(counter));
2266}
2267
2268
2269void
2271 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2272 registerJunction(junction);
2273}
2274
2275
2276void
2278 // remove it from inspected elements and GNEElementTree
2279 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2280 junction->unmarkForDrawingFront();
2281 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2282 // Remove from grid and container
2283 myNet->removeGLObjectFromGrid(junction);
2284 myJunctions.erase(junction->getMicrosimID());
2285 myNumberOfNetworkElements--;
2286 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2287 junction->decRef("GNENet::deleteSingleJunction");
2288 junction->setResponsible(true);
2289}
2290
2291
2292void
2294 // get pointer to create edge frame
2295 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2296 // insert in myEdgeTypes
2297 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2298 myNumberOfNetworkElements++;
2299 // update edge selector
2300 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
2301 myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2302 }
2303 // set current edge type inspected
2304 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2305}
2306
2307
2308void
2310 // get pointer to create edge frame
2311 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2312 // remove it from inspected elements and GNEElementTree
2313 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2314 edgeType->unmarkForDrawingFront();
2315 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2316 // remove from edge types
2317 myEdgeTypes.erase(edgeType->getMicrosimID());
2318 myNumberOfNetworkElements--;
2319 // check if this is the selected edge type in edgeSelector
2320 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2321 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2322 }
2323 // update edge selector
2324 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2325}
2326
2327
2328void
2330 NBEdge* nbe = edge->getNBEdge();
2331 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2332 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2333 nbe->getFromNode()->addOutgoingEdge(nbe);
2334 nbe->getToNode()->addIncomingEdge(nbe);
2335 // register edge
2336 registerEdge(edge);
2337}
2338
2339
2340void
2342 // remove it from inspected elements and GNEElementTree
2343 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2344 edge->unmarkForDrawingFront();
2345 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2346 // remove edge from visual grid and container
2347 myNet->removeGLObjectFromGrid(edge);
2348 myEdges.erase(edge->getMicrosimID());
2349 myNumberOfNetworkElements--;
2350 // remove all lanes
2351 for (const auto& lane : edge->getLanes()) {
2352 deleteLane(lane);
2353 }
2354 // extract edge of district container
2355 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2356 edge->decRef("GNENet::deleteSingleEdge");
2357 edge->setResponsible(true);
2358 // Remove refrences from GNEJunctions
2360 edge->getToJunction()->removeIncomingGNEEdge(edge);
2361 // update boundaries of both junctions (to remove it from Grid)
2364 // get template editor
2365 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
2366 // check if we have to remove template
2367 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2368 templateEditor->setEdgeTemplate(nullptr);
2369 }
2370}
2371
2372
2373void
2375 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2376 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2377 } else {
2378 myLanes[lane->getGUIGlObject()] = lane;
2379 myNumberOfNetworkElements++;
2380 }
2381}
2382
2383
2384void
2386 const auto finder = myLanes.find(lane->getGUIGlObject());
2387 if (finder == myLanes.end()) {
2388 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2389 } else {
2390 myLanes.erase(finder);
2391 myNumberOfNetworkElements--;
2392 // remove it from inspected elements and GNEElementTree
2393 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2394 lane->unmarkForDrawingFront();
2395 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2396 }
2397}
2398
2399
2400void
2402 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2403 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2404 } else {
2405 myCrossings[crossing->getGUIGlObject()] = crossing;
2406 myNumberOfNetworkElements++;
2407 }
2408}
2409
2410
2411void
2413 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2414 if (finder == myCrossings.end()) {
2415 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2416 } else {
2417 myCrossings.erase(finder);
2418 myNumberOfNetworkElements--;
2419 // remove it from inspected elements and GNEElementTree
2420 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2421 crossing->unmarkForDrawingFront();;
2422 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2423 }
2424}
2425
2426
2427void
2429 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2430 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2431 } else {
2432 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2433 myNumberOfNetworkElements++;
2434 }
2435}
2436
2437
2438void
2440 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2441 if (finder == myWalkingAreas.end()) {
2442 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2443 } else {
2444 myWalkingAreas.erase(finder);
2445 myNumberOfNetworkElements--;
2446 // remove it from inspected elements and GNEElementTree
2447 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2448 walkingArea->unmarkForDrawingFront();
2449 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2450 }
2451}
2452
2453
2454void
2456 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2457 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2458 } else {
2459 myConnections[connection->getGUIGlObject()] = connection;
2460 myNumberOfNetworkElements++;
2461 }
2462}
2463
2464
2465void
2467 const auto finder = myConnections.find(connection->getGUIGlObject());
2468 if (finder == myConnections.end()) {
2469 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2470 } else {
2471 myConnections.erase(finder);
2472 myNumberOfNetworkElements--;
2473 // remove it from inspected elements and GNEElementTree
2474 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2475 connection->unmarkForDrawingFront();
2476 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2477 }
2478}
2479
2480
2481void
2483 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2484 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' already exist");
2485 } else {
2486 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2487 myNumberOfNetworkElements++;
2488 }
2489}
2490
2491
2492void
2494 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2495 if (finder == myInternalLanes.end()) {
2496 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2497 } else {
2498 myInternalLanes.erase(finder);
2499 myNumberOfNetworkElements--;
2500 }
2501}
2502
2503
2504void
2506 const auto tag = additional->getTagProperty().getTag();
2507 if (myAdditionals.at(tag).count(additional) > 0) {
2508 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2509 } else {
2510 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2511 if (additional->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2512 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2513 }
2514 myNumberOfNetworkElements++;
2515 // add element in grid
2516 if (additional->getTagProperty().isPlacedInRTree()) {
2517 myNet->addGLObjectIntoGrid(additional);
2518 }
2519 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2520 if (myNet->isUpdateGeometryEnabled()) {
2521 additional->updateGeometry();
2522 }
2523 // additionals has to be saved
2524 myNet->getSavingStatus()->requireSaveAdditionals();
2525 }
2526}
2527
2528
2529void
2531 const auto tag = additional->getTagProperty().getTag();
2532 // find demanElement in additionalTag
2533 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2534 // check if additional was previously inserted
2535 if (itFind == myAdditionals.at(tag).end()) {
2536 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2537 } else {
2538 // remove from both container
2539 myAdditionals.at(tag).erase(itFind);
2540 if (additional->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2541 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2542 }
2543 myNumberOfNetworkElements--;
2544 // remove it from inspected elements and GNEElementTree
2545 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2546 additional->unmarkForDrawingFront();
2547 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2548 // remove element from grid
2549 if (additional->getTagProperty().isPlacedInRTree()) {
2550 myNet->removeGLObjectFromGrid(additional);
2551 }
2552 // delete path element
2553 myNet->getNetworkPathManager()->removePath(additional);
2554 // additionals has to be saved
2555 myNet->getSavingStatus()->requireSaveAdditionals();
2556 }
2557}
2558
2559
2560void
2562 const auto tag = demandElement->getTagProperty().getTag();
2563 if (myDemandElements.at(tag).count(demandElement) > 0) {
2564 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2565 } else {
2566 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2567 myNumberOfDemandElements++;
2568 if (demandElement->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2569 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2570 }
2571 // add element in grid
2572 myNet->addGLObjectIntoGrid(demandElement);
2573 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2574 if (myNet->isUpdateGeometryEnabled()) {
2575 demandElement->updateGeometry();
2576 }
2577 // compute path element
2578 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2579 demandElement->computePathElement();
2580 }
2581 // update demand elements frames
2582 updateDemandElementFrames(demandElement->getTagProperty());
2583 // demandElements has to be saved
2584 myNet->getSavingStatus()->requireSaveDemandElements();
2585 }
2586}
2587
2588
2589void
2591 const auto tag = demandElement->getTagProperty().getTag();
2592 auto viewParent = myNet->getViewNet()->getViewParent();
2593 // find demanElement in demandElementTag
2594 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2595 // check if demandElement was previously inserted
2596 if (itFind == myDemandElements.at(tag).end()) {
2597 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2598 } else {
2599 // erase it from container
2600 myDemandElements.at(tag).erase(itFind);
2601 if (demandElement->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2602 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2603 }
2604 myNumberOfDemandElements--;
2605 // remove element from grid
2606 myNet->removeGLObjectFromGrid(demandElement);
2607 // remove it from inspected elements and GNEElementTree
2608 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2609 demandElement->unmarkForDrawingFront();
2610 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2611 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2612 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2613 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2614 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2615 }
2616 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2617 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2618 }
2619 // if is the last inserted route, remove it from GNEViewNet
2620 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2621 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2622 }
2623 // delete path element
2624 myNet->getDemandPathManager()->removePath(demandElement);
2625 // check if update demand elements frames
2626 if (updateFrames) {
2627 updateDemandElementFrames(demandElement->getTagProperty());
2628 }
2629 // demandElements has to be saved
2630 myNet->getSavingStatus()->requireSaveDemandElements();
2631 }
2632}
2633
2634
2635void
2637 if (myDataSets.count(dataSet->getID()) > 0) {
2638 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2639 } else {
2640 myDataSets[dataSet->getID()] = dataSet;
2641 myNumberOfDataElements++;
2642 // dataSets has to be saved
2643 myNet->getSavingStatus()->requireSaveDataElements();
2644 // mark interval toolbar for update
2645 myNet->getViewNet()->getIntervalBar().markForUpdate();
2646 }
2647}
2648
2649
2650void
2652 const auto finder = myDataSets.find(dataSet->getID());
2653 if (finder == myDataSets.end()) {
2654 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2655 } else {
2656 myDataSets.erase(finder);
2657 myNumberOfDataElements--;
2658 // remove it from inspected elements and GNEElementTree
2659 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2660 dataSet->unmarkForDrawingFront();
2661 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2662 // dataSets has to be saved
2663 myNet->getSavingStatus()->requireSaveDataElements();
2664 // mark interval toolbar for update
2665 myNet->getViewNet()->getIntervalBar().markForUpdate();
2666 }
2667}
2668
2669
2670void
2672 if (myMeanDatas.at(meanData->getTagProperty().getTag()).count(meanData->getID()) > 0) {
2673 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2674 } else {
2675 myMeanDatas.at(meanData->getTagProperty().getTag()).insert(std::make_pair(meanData->getID(), meanData));
2676 myNumberOfMeanDataElements++;
2677 // meanDatas has to be saved
2678 myNet->getSavingStatus()->requireSaveMeanDatas();
2679 }
2680}
2681
2682
2683void
2685 // find demanElement in meanDataTag
2686 auto itFind = myMeanDatas.at(meanData->getTagProperty().getTag()).find(meanData->getID());
2687 // check if meanData was previously inserted
2688 if (itFind == myMeanDatas.at(meanData->getTagProperty().getTag()).end()) {
2689 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2690 } else {
2691 // remove it from inspected elements and GNEElementTree
2692 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2693 meanData->unmarkForDrawingFront();
2694 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2695 // remove from container
2696 myMeanDatas.at(meanData->getTagProperty().getTag()).erase(itFind);
2697 myNumberOfMeanDataElements--;
2698 // remove element from grid
2699 if (meanData->getTagProperty().isPlacedInRTree()) {
2700 myNet->removeGLObjectFromGrid(meanData);
2701 }
2702 // meanDatas has to be saved
2703 myNet->getSavingStatus()->requireSaveMeanDatas();
2704 }
2705}
2706
2707
2708void
2710 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2711 // continue depending of demand mode
2712 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2714 if (tagProperty.isType()) {
2715 myNet->getViewNet()->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2716 }
2717 break;
2719 if (tagProperty.isType()) {
2720 myNet->getViewNet()->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2721 }
2722 break;
2724 if (tagProperty.isType()) {
2725 myNet->getViewNet()->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2726 }
2727 break;
2729 if (tagProperty.isRoute()) {
2730 myNet->getViewNet()->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2731 }
2732 break;
2734 if (tagProperty.isType()) {
2735 myNet->getViewNet()->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2736 }
2737 break;
2739 if (tagProperty.isPerson()) {
2740 myNet->getViewNet()->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2741 }
2742 break;
2744 if (tagProperty.isType()) {
2745 myNet->getViewNet()->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2746 }
2747 break;
2749 if (tagProperty.isContainer()) {
2750 myNet->getViewNet()->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2751 }
2752 break;
2754 myNet->getViewNet()->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2755 break;
2756 default:
2757 // nothing to update
2758 break;
2759 }
2760 }
2761}
2762
2763// ---------------------------------------------------------------------------
2764// GNENetHelper::SavingStatus - methods
2765// ---------------------------------------------------------------------------
2766
2769
2770
2771void
2773 mySumoConfigSaved = false;
2774}
2775
2776
2777void
2779 mySumoConfigSaved = true;
2780}
2781
2782
2783bool
2785 return mySumoConfigSaved;
2786}
2787
2788
2789
2790void
2792 myNeteditConfigSaved = false;
2793}
2794
2795
2796void
2798 myNeteditConfigSaved = true;
2799}
2800
2801
2802bool
2804 return myNeteditConfigSaved;
2805}
2806
2807
2808void
2810 myNetworkSaved = false;
2811 // implies requiere save netedit config and sumo config
2812 myNeteditConfigSaved = false;
2813 mySumoConfigSaved = false;
2814}
2815
2816
2817void
2819 myNetworkSaved = true;
2820}
2821
2822
2823bool
2825 return myNetworkSaved;
2826}
2827
2828
2829void
2831 myTLSSaved = false;
2832}
2833
2834
2835void
2837 myTLSSaved = true;
2838}
2839
2840
2841bool
2843 return myTLSSaved;
2844}
2845
2846
2847void
2849 myEdgeTypeSaved = false;
2850}
2851
2852
2853void
2855 myEdgeTypeSaved = true;
2856}
2857
2858
2859bool
2861 return myEdgeTypeSaved;
2862}
2863
2864
2865void
2867 myAdditionalSaved = false;
2868 // implies requiere save netedit config and sumo config
2869 myNeteditConfigSaved = false;
2870 mySumoConfigSaved = false;
2871}
2872
2873
2874void
2876 myAdditionalSaved = true;
2877}
2878
2879
2880bool
2882 return myAdditionalSaved;
2883}
2884
2885
2886void
2888 myDemandElementSaved = false;
2889 // implies requiere save netedit config and sumo config
2890 myNeteditConfigSaved = false;
2891 mySumoConfigSaved = false;
2892}
2893
2894
2895void
2897 myDemandElementSaved = true;
2898}
2899
2900
2901bool
2903 return myDemandElementSaved;
2904}
2905
2906
2907void
2909 myDataElementSaved = false;
2910 // implies requiere save netedit config and sumo config
2911 myNeteditConfigSaved = false;
2912 mySumoConfigSaved = false;
2913}
2914
2915
2916void
2918 myDataElementSaved = true;
2919}
2920
2921
2922bool
2924 return myDataElementSaved;
2925}
2926
2927
2928void
2930 myMeanDataElementSaved = false;
2931 // implies requiere save netedit config and sumo config
2932 myNeteditConfigSaved = false;
2933 mySumoConfigSaved = false;
2934}
2935
2936
2937void
2939 myMeanDataElementSaved = true;
2940}
2941
2942
2943bool
2945 return myMeanDataElementSaved;
2946}
2947
2948// ---------------------------------------------------------------------------
2949// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
2950// ---------------------------------------------------------------------------
2951
2953 GNEChange(Supermode::NETWORK, true, false),
2954 myTllcont(tllcont),
2955 myReplaced(replaced),
2956 myBy(by) {
2957}
2958
2959
2961
2962
2963void
2965 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2966 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
2967}
2968
2969
2970void
2972 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2973 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
2974}
2975
2976
2977std::string
2979 return TL("Redo replace in TLS");
2980}
2981
2982
2983std::string
2985 return TL("Undo replace in TLS");
2986}
2987
2988
2989bool
2991 return myReplaced != myBy;
2992}
2993
2994/****************************************************************************/
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
@ DATA
Data mode (edgeData, LaneData etc..)
@ DEMAND
Demand mode (Routes, Vehicles etc..)
@ DEMAND_PERSONPLAN
Mode for editing person plan.
@ DEMAND_CONTAINER
Mode for editing container.
@ DEMAND_ROUTEDISTRIBUTION
Mode for editing route distributions.
@ DEMAND_PERSON
Mode for editing person.
@ DEMAND_TYPEDISTRIBUTION
Mode for editing type distributions.
@ DEMAND_VEHICLE
Mode for editing vehicles.
@ DEMAND_STOP
Mode for editing stops.
@ DEMAND_CONTAINERPLAN
Mode for editing container plan.
@ DEMAND_TYPE
Mode for editing types.
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:306
#define TL(string)
Definition MsgHandler.h:315
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
const long long int VTYPEPARS_VEHICLECLASS_SET
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_RAILTYPE_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
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_RAIL
vehicle is a not electrified rail
@ 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_BIKETYPE_ID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ 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, must be the last one
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ GNE_TAG_EDGEREL_SINGLE
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_MEANDATA_LANE
a lane based mean data detector
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_PARKING_AREA
A parking area.
@ 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_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_POILANE
Point of interest over Lane.
@ SUMO_TAG_DATASET
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ 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
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
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.
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
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, const bool mergeCommonPlans)
get tagProperties associated to the given GNETagProperties::TagType (NETWORKELEMENT,...
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
void unmarkForDrawingFront()
unmark for drawing front
static const std::vector< GNETagProperties > getTagPropertiesByMergingTag(SumoXMLTag mergingTag)
get tagProperties associated to the given merging tag
virtual GUIGlObject * getGUIGlObject()=0
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition GNECrossing.h:44
An Element which don't belong to GNENet but has influence in the simulation.
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
virtual void computePathElement()=0
compute pathElement
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNEEdge.cpp:660
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition GNEEdge.cpp:1528
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:781
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:1118
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2316
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
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:654
An Element which don't belong to GNENet but has influence in the simulation.
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
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)
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
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
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
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:620
An Element which don't belong to GNENet but has influence in the simulation.
Definition GNEMeanData.h:33
std::vector< GNEEdge * > retrieveEdges(GNEJunction *from, GNEJunction *to) const
get all edges by from and to GNEJunction
void insertWalkingArea(GNEWalkingArea *walkingArea)
insert walkingArea in container
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::unordered_map< const GUIGlObject *, GNEConnection * > & getConnections() const
get connections
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * > > & getDemandElements() const
get demand elements
int getNumberOfSelectedJpsObstacles() const
get number of selected obstacles
int getNumberOfSelectedConnections() const
get number of selected connections
void deleteDataSet(GNEDataSet *dataSet)
delete data set of container
void addPrefixToJunctions(const std::string &prefix)
add prefix to all junctions
void insertLane(GNELane *lane)
insert lane in container
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 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::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * > > myMeanDatas
map with the tag and pointer to meanData elements of net
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * > > & getAdditionals() const
get additionals
void insertDataSet(GNEDataSet *dataSet)
Insert a data set in container.
int getNumberOfSelectedRides() const
get number of selected rides
void clearDemandElements()
clear demand elements
const std::unordered_map< const GUIGlObject *, GNECrossing * > & getCrossings() const
get crossings
void insertGenericData(GNEGenericData *genericData)
insert generic data in container
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with containers
void deleteDemandElement(GNEDemandElement *demandElement, const bool updateFrames)
delete demand element of container
void insertDataInterval(const GNEAttributeCarrier *AC, GNEDataInterval *dataInterval)
insert data interval in container
int getNumberOfSelectedPersonTrips() const
get number of selected person trips
std::string generateDemandElementID(SumoXMLTag tag) const
generate demand element id
int getNumberOfMeanDatas() const
get number of meanDatas
GNECrossing * retrieveCrossing(const GUIGlObject *glObject, bool hardFail=true) const
get Crossing by AC
void addPrefixToEdges(const std::string &prefix)
add prefix to all edges
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 deleteEdgeType(GNEEdgeType *edgeType)
delete edge type from container
int getNumberOfSelectedJpsWalkableAreas() const
get number of selected walkable areas
std::string generateDataSetID(const std::string &prefix) const
generate data set id
void deleteInternalLane(GNEInternalLane *internalLane)
delete internalLane from container
void deleteConnection(GNEConnection *connection)
delete connection from container
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
void insertInternalLane(GNEInternalLane *internalLane)
insert internalLane in container
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
void deleteSingleJunction(GNEJunction *junction)
delete junction from container
GNEMeanData * retrieveMeanData(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named meanData.
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction in containers
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * > > & getGenericDatas() const
get all generic datas
int getNumberOfSelectedWalkingAreas() const
get number of selected walkingAreas
GNEWalkingArea * retrieveWalkingArea(const GUIGlObject *glObject, bool hardFail=true) const
get WalkingArea by GlObject
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
const std::map< const std::string, GNEDataSet * > & getDataSets() const
get demand elements
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 of container
void insertCrossing(GNECrossing *crossing)
insert crossing in container
int getNumberOfSelectedWires() const
get number of selected Wires
std::string generateMeanDataID(SumoXMLTag type) const
generate meanData id
void insertMeanData(GNEMeanData *meanData)
Insert a meanData element in container.
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 from container
int getNumberOfSelectedTransport() const
get number of selected transports
void updateMeanDataID(GNEMeanData *meanData, const std::string &newID)
update meanData ID in container
std::vector< GNELane * > getSelectedLanes() const
get selected lanes
void insertConnection(GNEConnection *connection)
insert connection in container
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 getNumberOfDataElements() const
get number of current data elements saved in AttributeCarriers
int getNumberOfGenericDatas() const
Return the number of generic datas.
void updateAdditionalID(GNEAdditional *additional, const std::string &newID)
update additional ID in container
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
void deleteMeanData(GNEMeanData *meanData)
delete meanData element of container
GNEAdditional * retrieveAdditionals(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named additional.
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)
delete edge from container
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
void deleteAdditional(GNEAdditional *additional)
delete additional element of container
int getNumberOfDemandElements() const
get number of current demand elements saved in AttributeCarriers (default vTypes are NOT included)
const std::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * > > & getMeanDatas() const
get meanDatas
int getNumberOfSelectedPolygons() const
get number of selected polygons
std::vector< GNEJunction * > getSelectedJunctions() const
return selected junctions
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEAdditional * > > myAdditionalIDs
map with the tag and pointer to additional elements of net, sorted by IDs
int getNumberOfAdditionals() const
get number of additionals
void updateDemandElementID(GNEDemandElement *demandElement, const std::string &newID)
update demand element ID in container
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element in container.
void updateEdgeID(GNEEdge *edge, const std::string &newID)
update edge ID in container
GNEDataInterval * retrieveDataInterval(const GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
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
GNEInternalLane * retrieveInternalLane(const GUIGlObject *glObject, bool hardFail=true) const
get InternalLane by GUIGlObject
int getNumberOfSelectedTAZSources() const
get number of selected TAZSources
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * > > myDemandElements
map with the tag and pointer to additional elements of net
void insertEdgeType(GNEEdgeType *edgeType)
insert edge type in container
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
const std::unordered_map< const GUIGlObject *, GNELane * > & getLanes() const
get lanes
const std::unordered_map< const GNEAttributeCarrier *, GNEDataInterval * > & getDataIntervals() const
get all data intervals of network
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 from container
void insertJunction(GNEJunction *junction)
insert junction in container
std::vector< GNEEdge * > getSelectedEdges() const
return all edges
int getNumberOfNetworkElements() const
functions related with number of elements sorted by categories
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEDemandElement * > > myDemandElementIDs
map with the tag and pointer to demand elements of net, sorted by IDs
int getNumberOfSelectedTAZSinks() const
get number of selected TAZSinks
void updateDemandElementFrames(const GNETagProperties &tagProperty)
update demand element frames (called after insert/delete demand element)
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
void clearMeanDatas()
clear meanDatas
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
const std::unordered_map< const GUIGlObject *, GNEWalkingArea * > & getWalkingAreas() const
get walkingAreas
void deleteCrossing(GNECrossing *crossing)
delete crossing from container
GNEDemandElement * getDefaultType() const
get default type
GNEGenericData * retrieveGenericData(const GUIGlObject *glObject, bool hardFail=true) const
Returns the generic data.
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
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * > > myGenericDatas
map with the tag and pointer to all generic datas
void deleteDataInterval(GNEDataInterval *dataInterval)
delete data interval of container
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * > > myAdditionals
map with the tag and pointer to additional elements of net
GNEConnection * retrieveConnection(const std::string &id, bool hardFail=true) const
get Connection by id
int getNumberOfSelectedContainers() const
get number of selected containers
std::string undoName() const
undo name
GNEChange_ReplaceEdgeInTLS(NBTrafficLightLogicCont &tllcont, NBEdge *replaced, NBEdge *by)
constructor
std::string redoName() const
get Redo name
bool trueChange()
wether original and new value differ
void requireSaveTLS()
inform that TLS has to be saved
void dataElementsSaved()
mark demand elements as saved
bool isEdgeTypeSaved() const
check if edgeType are saved
void requireSaveNetwork()
inform that network has to be saved
void requireSaveEdgeType()
inform that edgeType has to be saved
bool isTLSSaved() const
check if TLS are saved
void demandElementsSaved()
mark demand elements as saved
void SumoConfigSaved()
mark SumoConfig as saved
void additionalsSaved()
mark additionals as saved
void requireSaveNeteditConfig()
inform that netedit config has to be saved
void requireSaveSumoConfig()
inform that SumoConfig has to be saved
void TLSSaved()
mark TLS as saved
bool isSumoConfigSaved() const
check if SumoConfig is saved
void neteditConfigSaved()
mark netedit config as saved
void requireSaveMeanDatas()
inform that mean data elements has to be saved
void meanDatasSaved()
mark mean data elements as saved
bool isDemandElementsSaved() const
check if demand elements are saved
void requireSaveAdditionals()
inform that additionals has to be saved
bool isDataElementsSaved() const
check if data elements are saved
bool isNetworkSaved() const
check if network is saved
bool isMeanDatasSaved() const
check if mean data elements are saved
void requireSaveDataElements()
inform that data elements has to be saved
bool isNeteditConfigSaved() const
check if netedit config is saved
void networkSaved()
mark network as saved
bool isAdditionalsSaved() const
check if additionals are saved
void requireSaveDemandElements()
inform that demand elements has to be saved
void edgeTypeSaved()
mark edgeType as saved
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void setNetworkElementID(const std::string &newID)
set network element id
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void decRef(const std::string &debugMsg="")
Decrease reference.
void incRef(const std::string &debugMsg="")
Increase reference.
bool isMeanData() const
return true if tag correspond to a mean data element
bool isContainer() const
return true if tag correspond to a container element
bool isGenericData() const
data elements
bool isNetworkElement() const
element sets
bool isDataElement() const
return true if tag correspond to a data element
bool isType() const
demand elements
bool isRoute() const
return true if tag correspond to a route 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)
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
bool isPerson() const
return true if tag correspond to a person element
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.
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::unordered_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:546
const std::string & getID() const
Definition NBEdge.h:1528
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:539
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition NBNode.cpp:490
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition NBNode.cpp:4019
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:3040
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition NBNode.cpp:500
const Position & getPosition() const
Definition NBNode.h:260
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2667
A container for traffic light definitions and built programs.
const std::string & getID() const
Returns the id.
Definition Named.h:74
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > busStops
busStops namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static const std::vector< SumoXMLTag > laneAreaDetectors
lane area detectors namespace
static const std::vector< SumoXMLTag > POIs
POIs namespace.
static const std::vector< SumoXMLTag > routes
route namespace
static const std::vector< SumoXMLTag > persons
persons namespace
static const std::vector< SumoXMLTag > calibrators
calibrators namespace
static const std::vector< SumoXMLTag > polygons
polygon namespace
static const std::vector< SumoXMLTag > containers
containers namespace
static OptionsCont & getOptions()
Retrieves the options.
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.
long long int parametersSet
Information for the router which parameter were set.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID