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<const std::string, GNEEdge*> newEdgeMap;
166 std::map<const 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() || AC->getTagProperty().isAdditionalElement())) {
421 result.push_back(AC);
422 } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty().isDemandElement()) {
423 result.push_back(AC);
424 } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty().isDataElement()) {
425 result.push_back(AC);
426 }
427 }
428 }
429 return result;
430}
431
432
434GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
435 auto it = myJunctions.find(id);
436 if (it != myJunctions.end()) {
437 return it->second;
438 }
439 if (hardFail) {
440 // If junction wasn't found, throw exception
441 throw UnknownElement("Attempted to retrieve non-existant junction " + id);
442 } else {
443 return nullptr;
444 }
445}
446
447
448const std::map<const std::string, GNEJunction*>&
450 return myJunctions;
451}
452
453
454std::vector<GNEJunction*>
456 std::vector<GNEJunction*> result;
457 // returns junctions depending of selection
458 for (const auto& junction : myJunctions) {
459 if (junction.second->isAttributeCarrierSelected()) {
460 result.push_back(junction.second);
461 }
462 }
463 return result;
464}
465
466
469 // increase reference
470 junction->incRef("GNENet::registerJunction");
471 junction->setResponsible(false);
472 myJunctions[junction->getMicrosimID()] = junction;
473 myNumberOfNetworkElements++;
474 // expand net boundary
475 myNet->expandBoundary(junction->getCenteringBoundary());
476 // add edge into grid
477 myNet->addGLObjectIntoGrid(junction);
478 // update geometry
479 junction->updateGeometry();
480 // add z in net boundary
481 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
482 return junction;
483}
484
485
486void
488 myJunctions.clear();
489}
490
491
492void
494 // make a copy of junctions
495 auto junctionCopy = myJunctions;
496 // clear junctions
497 myJunctions.clear();
498 // fill junctions again
499 for (const auto& junction : junctionCopy) {
500 // update microsim ID
501 junction.second->setNetworkElementID(prefix + junction.first);
502 // insert in myJunctions again
503 myJunctions[prefix + junction.first] = junction.second;
504 }
505}
506
507
508void
510 if (myJunctions.count(junction->getID()) == 0) {
511 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
512 } else if (myJunctions.count(newID) != 0) {
513 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
514 } else {
515 // remove junction from container
516 myJunctions.erase(junction->getNBNode()->getID());
517 // rename in NetBuilder
518 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
519 // update microsim ID
520 junction->setNetworkElementID(newID);
521 // add it into myJunctions again
522 myJunctions[junction->getID()] = junction;
523 // build crossings
524 junction->getNBNode()->buildCrossings();
525 // net has to be saved
526 myNet->getSavingStatus()->requireSaveNetwork();
527 }
528}
529
530
531int
533 int counter = 0;
534 for (const auto& junction : myJunctions) {
535 if (junction.second->isAttributeCarrierSelected()) {
536 counter++;
537 }
538 }
539 return counter;
540}
541
542
545 auto it = myCrossings.find(glObject);
546 if (it != myCrossings.end()) {
547 return it->second;
548 }
549 if (hardFail) {
550 // If junction wasn't found, throw exception
551 throw UnknownElement("Attempted to retrieve non-existant crossing " + glObject->getMicrosimID());
552 } else {
553 return nullptr;
554 }
555}
556
557
558const std::unordered_map<const GUIGlObject*, GNECrossing*>&
560 return myCrossings;
561}
562
563
564std::vector<GNECrossing*>
566 std::vector<GNECrossing*> result;
567 // iterate over crossings
568 for (const auto& crossing : myCrossings) {
569 if (crossing.second->isAttributeCarrierSelected()) {
570 result.push_back(crossing.second);
571 }
572 }
573 return result;
574}
575
576
577int
579 int counter = 0;
580 for (const auto& crossing : myCrossings) {
581 if (crossing.second->isAttributeCarrierSelected()) {
582 counter++;
583 }
584 }
585 return counter;
586}
587
588
591 auto it = myWalkingAreas.find(glObject);
592 if (it != myWalkingAreas.end()) {
593 return it->second;
594 }
595 if (hardFail) {
596 // If junction wasn't found, throw exception
597 throw UnknownElement("Attempted to retrieve non-existant walkingArea " + glObject->getMicrosimID());
598 } else {
599 return nullptr;
600 }
601}
602
603
604const std::unordered_map<const GUIGlObject*, GNEWalkingArea*>&
606 return myWalkingAreas;
607}
608
609
610std::vector<GNEWalkingArea*>
612 std::vector<GNEWalkingArea*> result;
613 // iterate over walkingAreas
614 for (const auto& walkingArea : myWalkingAreas) {
615 if (walkingArea.second->isAttributeCarrierSelected()) {
616 result.push_back(walkingArea.second);
617 }
618 }
619 return result;
620}
621
622
623int
625 int counter = 0;
626 for (const auto& walkingArea : myWalkingAreas) {
627 if (walkingArea.second->isAttributeCarrierSelected()) {
628 counter++;
629 }
630 }
631 return counter;
632}
633
634
636GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
637 if (myEdgeTypes.count(id) > 0) {
638 return myEdgeTypes.at(id);
639 } else if (hardFail) {
640 // If edge wasn't found, throw exception
641 throw UnknownElement("Attempted to retrieve non-existant EdgeType " + id);
642 } else {
643 return nullptr;
644 }
645}
646
647
650 // increase reference
651 edgeType->incRef("GNENet::registerEdgeType");
652 // add it in container
653 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
654 return edgeType;
655}
656
657
658const std::map<const std::string, GNEEdgeType*>&
660 return myEdgeTypes;
661}
662
663
665 myEdgeTypes.clear();
666}
667
668
669void
671 if (myEdgeTypes.count(edgeType->getID()) == 0) {
672 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
673 } else if (myEdgeTypes.count(newID) != 0) {
674 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
675 } else {
676 // remove edgeType from container
677 myEdgeTypes.erase(edgeType->getID());
678 // rename in typeCont
679 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
680 // update microsim ID
681 edgeType->setNetworkElementID(newID);
682 // add it into myEdgeTypes again
683 myEdgeTypes[edgeType->getID()] = edgeType;
684 // net has to be saved
685 myNet->getSavingStatus()->requireSaveNetwork();
686 }
687}
688
689
690std::string
692 int counter = 0;
693 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
694 counter++;
695 }
696 return ("edgeType_" + toString(counter));
697}
698
699
700GNEEdge*
701GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
702 auto it = myEdges.find(id);
703 if (it != myEdges.end()) {
704 return it->second;
705 }
706 if (hardFail) {
707 // If edge wasn't found, throw exception
708 throw UnknownElement("Attempted to retrieve non-existant edge " + id);
709 } else {
710 return nullptr;
711 }
712}
713
714
715std::vector<GNEEdge*>
717 if ((from == nullptr) || (to == nullptr)) {
718 throw UnknownElement("Junctions cannot be nullptr");
719 }
720 std::vector<GNEEdge*> edges;
721 // iterate over outgoing edges of from edge and check to junction
722 for (const auto& edgeTo : from->getGNEOutgoingEdges()) {
723 if (edgeTo->getToJunction() == to) {
724 edges.push_back(edgeTo);
725 }
726 }
727 return edges;
728}
729
730
731const std::map<const std::string, GNEEdge*>&
733 return myEdges;
734}
735
736
737std::vector<GNEEdge*>
739 std::vector<GNEEdge*> result;
740 // returns edges depending of selection
741 for (const auto& edge : myEdges) {
742 if (edge.second->isAttributeCarrierSelected()) {
743 result.push_back(edge.second);
744 }
745 }
746 return result;
747}
748
749
750GNEEdge*
752 edge->incRef("GNENet::registerEdge");
753 edge->setResponsible(false);
754 // add edge to internal container of GNENet
755 myEdges[edge->getMicrosimID()] = edge;
756 myNumberOfNetworkElements++;
757 // insert all lanes
758 for (const auto& lane : edge->getLanes()) {
759 insertLane(lane);
760 }
761 // Add references into GNEJunctions
762 edge->getFromJunction()->addOutgoingGNEEdge(edge);
763 edge->getToJunction()->addIncomingGNEEdge(edge);
764 // update boundaries of both junctions (to remove it from Grid)
767 // update edge boundary
768 edge->updateCenteringBoundary(false);
769 // expand edge boundary
770 myNet->expandBoundary(edge->getCenteringBoundary());
771 // finally add edge into grid
772 myNet->addGLObjectIntoGrid(edge);
773 return edge;
774}
775
776
777void
781
782
783void
785 // make a copy of edges
786 auto edgeCopy = myEdges;
787 // clear edges
788 myEdges.clear();
789 // fill edges again
790 for (const auto& edge : edgeCopy) {
791 // update microsim ID
792 edge.second->setNetworkElementID(prefix + edge.first);
793 // insert in myEdges again
794 myEdges[prefix + edge.first] = edge.second;
795 }
796}
797
798
799void
801 if (myEdges.count(edge->getID()) == 0) {
802 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
803 } else if (myEdges.count(newID) != 0) {
804 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
805 } else {
806 // remove edge from container
807 myEdges.erase(edge->getNBEdge()->getID());
808 // rename in NetBuilder
809 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
810 // update microsim ID
811 edge->setEdgeID(newID);
812 // add it into myEdges again
813 myEdges[edge->getID()] = edge;
814 // rename all connections related to this edge
815 for (const auto& lane : edge->getLanes()) {
816 lane->updateConnectionIDs();
817 }
818 // net has to be saved
819 myNet->getSavingStatus()->requireSaveNetwork();
820 }
821}
822
823
824int
826 int counter = 0;
827 for (const auto& edge : myEdges) {
828 if (edge.second->isAttributeCarrierSelected()) {
829 counter++;
830 }
831 }
832 return counter;
833}
834
835
836GNELane*
837GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
838 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
839 const GNEEdge* edge = retrieveEdge(edge_id, false);
840 if (edge != nullptr) {
841 GNELane* lane = nullptr;
842 // search lane in lane's edges
843 for (auto laneIt : edge->getLanes()) {
844 if (laneIt->getID() == id) {
845 lane = laneIt;
846 }
847 }
848 // throw exception or return nullptr if lane wasn't found
849 if (lane == nullptr) {
850 if (hardFail) {
851 // Throw exception if hardFail is enabled
852 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
853 }
854 } else {
855 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
856 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
857 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getLanes().size()) {
858 return edge->getLanes().at(lane->getIndex() + 1);
859 }
860 return lane;
861 }
862 } else if (hardFail) {
863 // Throw exception if hardFail is enabled
864 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
865 }
866 return nullptr;
867}
868
869
870GNELane*
871GNENetHelper::AttributeCarriers::retrieveLane(const GUIGlObject* glObject, bool hardFail) const {
872 auto it = myLanes.find(glObject);
873 if (it != myLanes.end()) {
874 return it->second;
875 }
876 if (hardFail) {
877 // If junction wasn't found, throw exception
878 throw UnknownElement("Attempted to retrieve non-existant lane " + glObject->getMicrosimID());
879 } else {
880 return nullptr;
881 }
882}
883
884
885const std::unordered_map<const GUIGlObject*, GNELane*>&
887 return myLanes;
888}
889
890
891std::vector<GNELane*>
893 std::vector<GNELane*> result;
894 // returns lanes depending of selection
895 for (const auto& lane : myLanes) {
896 if (lane.second->isAttributeCarrierSelected()) {
897 result.push_back(lane.second);
898 }
899 }
900 return result;
901}
902
903
904int
906 int counter = 0;
907 for (const auto& lane : myLanes) {
908 if (lane.second->isAttributeCarrierSelected()) {
909 counter++;
910 }
911 }
912 return counter;
913}
914
915
917GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
918 // iterate over connections
919 for (const auto& connection : myConnections) {
920 if (connection.second->getID() == id) {
921 return connection.second;
922 }
923 }
924 if (hardFail) {
925 // If POI wasn't found, throw exception
926 throw UnknownElement("Attempted to retrieve non-existant connection " + id);
927 } else {
928 return nullptr;
929 }
930}
931
932
935 auto it = myConnections.find(glObject);
936 if (it != myConnections.end()) {
937 return it->second;
938 }
939 if (hardFail) {
940 // If POI wasn't found, throw exception
941 throw UnknownElement("Attempted to retrieve non-existant connection " + glObject->getMicrosimID());
942 } else {
943 return nullptr;
944 }
945}
946
947
948const std::unordered_map<const GUIGlObject*, GNEConnection*>&
950 return myConnections;
951}
952
953
954std::vector<GNEConnection*>
956 std::vector<GNEConnection*> result;
957 // returns connections depending of selection
958 for (const auto& connection : myConnections) {
959 if (connection.second->isAttributeCarrierSelected()) {
960 result.push_back(connection.second);
961 }
962 }
963 return result;
964}
965
966
967int
969 int counter = 0;
970 for (const auto& connection : myConnections) {
971 if (connection.second->isAttributeCarrierSelected()) {
972 counter++;
973 }
974 }
975 return counter;
976}
977
978
981 auto it = myInternalLanes.find(glObject);
982 if (it != myInternalLanes.end()) {
983 return it->second;
984 }
985 if (hardFail) {
986 // If POI wasn't found, throw exception
987 throw UnknownElement("Attempted to retrieve non-existant internalLane " + glObject->getMicrosimID());
988 } else {
989 return nullptr;
990 }
991}
992
993
995GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
996 auto it = myAdditionalIDs.at(type).find(id);
997 if (it != myAdditionalIDs.at(type).end()) {
998 return it->second;
999 }
1000 if (hardFail) {
1001 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1002 } else {
1003 return nullptr;
1004 }
1005}
1006
1007
1009GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1010 for (const auto& type : types) {
1011 auto it = myAdditionalIDs.at(type).find(id);
1012 if (it != myAdditionalIDs.at(type).end()) {
1013 return it->second;
1014 }
1015 }
1016 if (hardFail) {
1017 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1018 } else {
1019 return nullptr;
1020 }
1021}
1022
1023
1026 // iterate over all additionals
1027 for (const auto& additionalTag : myAdditionals) {
1028 auto it = additionalTag.second.find(glObject);
1029 if (it != additionalTag.second.end()) {
1030 return it->second;
1031 }
1032 }
1033 if (hardFail) {
1034 throw ProcessError("Attempted to retrieve non-existant additional (glObject)");
1035 } else {
1036 return nullptr;
1037 }
1038}
1039
1040
1042GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
1043 // first retrieve rerouter
1044 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
1045 // parse begin and end
1046 const std::string beginStr = time2string(begin);
1047 const std::string endStr = time2string(end);
1048 // now iterate over all children and check begin and end
1049 for (const auto& interval : rerouter->getChildAdditionals()) {
1050 // check tag (to avoid symbols)
1051 if (interval->getTagProperty().getTag() == SUMO_TAG_INTERVAL) {
1052 // check begin and end
1053 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
1054 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
1055 return interval;
1056 }
1057 }
1058 }
1059 // throw exception
1060 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
1061}
1062
1063
1064const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*> >&
1066 return myAdditionals;
1067}
1068
1069
1070std::vector<GNEAdditional*>
1072 std::vector<GNEAdditional*> result;
1073 // returns additionals depending of selection
1074 for (const auto& additionalsTags : myAdditionals) {
1075 for (const auto& additional : additionalsTags.second) {
1076 if (additional.second->isAttributeCarrierSelected()) {
1077 result.push_back(additional.second);
1078 }
1079 }
1080 }
1081 return result;
1082}
1083
1084
1085std::vector<GNEAdditional*>
1087 std::vector<GNEAdditional*> result;
1088 // returns additionals depending of selection
1089 for (const auto& additionalsTags : myAdditionals) {
1090 for (const auto& additional : additionalsTags.second) {
1091 if (additional.second->getTagProperty().isShapeElement() && additional.second->isAttributeCarrierSelected()) {
1092 result.push_back(additional.second);
1093 }
1094 }
1095 }
1096 return result;
1097}
1098
1099
1100int
1102 int counter = 0;
1103 for (const auto& additionalsTag : myAdditionals) {
1104 counter += (int)additionalsTag.second.size();
1105 }
1106 return counter;
1107}
1108
1109
1110void
1112 // clear elements in grid
1113 for (const auto& additionalsTags : myAdditionals) {
1114 for (const auto& additional : additionalsTags.second) {
1115 myNet->removeGLObjectFromGrid(additional.second);
1116 }
1117 }
1118 // iterate over myAdditionals and clear all additionals
1119 for (auto& additionals : myAdditionals) {
1120 additionals.second.clear();
1121 }
1122 for (auto& additionals : myAdditionalIDs) {
1123 additionals.second.clear();
1124 }
1125}
1126
1127
1128void
1130 const auto tag = additional->getTagProperty().getTag();
1131 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1132 if (it == myAdditionalIDs.at(tag).end()) {
1133 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1134 } else {
1135 // remove from container, set new Id, and insert it again
1136 myAdditionalIDs.at(tag).erase(it);
1137 // set microsim ID
1138 additional->setMicrosimID(newID);
1139 myAdditionalIDs.at(tag)[newID] = additional;
1140 }
1141}
1142
1143
1144std::string
1146 // obtain option container
1147 const auto& neteditOptions = OptionsCont::getOptions();
1148 // get prefix
1149 std::string prefix;
1150 if (tag == SUMO_TAG_BUS_STOP) {
1151 prefix = neteditOptions.getString("busStop-prefix");
1152 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1153 prefix = neteditOptions.getString("trainStop-prefix");
1154 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1155 prefix = neteditOptions.getString("containerStop-prefix");
1156 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1157 prefix = neteditOptions.getString("chargingStation-prefix");
1158 } else if (tag == SUMO_TAG_PARKING_AREA) {
1159 prefix = neteditOptions.getString("parkingArea-prefix");
1160 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1161 prefix = neteditOptions.getString("e1Detector-prefix");
1162 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1163 prefix = neteditOptions.getString("e2Detector-prefix");
1164 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1165 prefix = neteditOptions.getString("e3Detector-prefix");
1166 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1167 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1168 } else if (tag == SUMO_TAG_REROUTER) {
1169 prefix = neteditOptions.getString("rerouter-prefix");
1170 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1171 prefix = neteditOptions.getString("calibrator-prefix");
1172 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1173 prefix = neteditOptions.getString("routeProbe-prefix");
1174 } else if (tag == SUMO_TAG_VSS) {
1175 prefix = neteditOptions.getString("vss-prefix");
1176 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1177 prefix = neteditOptions.getString("tractionSubstation-prefix");
1178 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1179 prefix = neteditOptions.getString("overheadWire-prefix");
1180 } else if (tag == SUMO_TAG_POLY) {
1181 prefix = neteditOptions.getString("polygon-prefix");
1182 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1183 prefix = neteditOptions.getString("poi-prefix");
1184 } else if (tag == SUMO_TAG_TAZ) {
1185 prefix = toString(SUMO_TAG_TAZ);
1186 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1187 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1188 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1189 prefix = neteditOptions.getString("jps.obstacle-prefix");
1190 }
1191 int counter = 0;
1192 // check namespaces
1193 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1194 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1195 counter++;
1196 }
1197 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1198 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1199 counter++;
1200 }
1201 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1202 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1203 counter++;
1204 }
1205 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1206 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1207 counter++;
1208 }
1209 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1210 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1211 counter++;
1212 }
1213 } else {
1214 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1215 counter++;
1216 }
1217 }
1218 // return new element ID
1219 return (prefix + "_" + toString(counter));
1220}
1221
1222
1223int
1225 int counter = 0;
1226 for (const auto& additionalsTags : myAdditionals) {
1227 for (const auto& additional : additionalsTags.second) {
1228 if (additional.second->isAttributeCarrierSelected()) {
1229 counter++;
1230 }
1231 }
1232 }
1233 return counter;
1234}
1235
1236
1237int
1239 return getNumberOfSelectedAdditionals() -
1240 // shapes
1241 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1242 // JuPedSims
1243 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1244 // TAZ
1245 getNumberOfSelectedTAZs() - getNumberOfSelectedTAZSources() - getNumberOfSelectedTAZSinks() -
1246 // wires
1247 getNumberOfSelectedWires();
1248}
1249
1250
1251int
1253 int counter = 0;
1254 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1255 if (poly.second->isAttributeCarrierSelected()) {
1256 counter++;
1257 }
1258 }
1259 return counter;
1260}
1261
1262
1263int
1265 int counter = 0;
1266 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1267 if (walkableArea.second->isAttributeCarrierSelected()) {
1268 counter++;
1269 }
1270 }
1271 return counter;
1272}
1273
1274
1275int
1277 int counter = 0;
1278 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1279 if (obstacle.second->isAttributeCarrierSelected()) {
1280 counter++;
1281 }
1282 }
1283 return counter;
1284}
1285
1286
1287int
1289 int counter = 0;
1290 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1291 if (POI.second->isAttributeCarrierSelected()) {
1292 counter++;
1293 }
1294 }
1295 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1296 if (POILane.second->isAttributeCarrierSelected()) {
1297 counter++;
1298 }
1299 }
1300 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1301 if (POIGEO.second->isAttributeCarrierSelected()) {
1302 counter++;
1303 }
1304 }
1305 return counter;
1306}
1307
1308
1309int
1311 int counter = 0;
1312 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1313 if (TAZ.second->isAttributeCarrierSelected()) {
1314 counter++;
1315 }
1316 }
1317 return counter;
1318}
1319
1320
1321int
1323 int counter = 0;
1324 for (const auto& TAZSource : myAdditionals.at(SUMO_TAG_TAZSOURCE)) {
1325 if (TAZSource.second->isAttributeCarrierSelected()) {
1326 counter++;
1327 }
1328 }
1329 return counter;
1330}
1331
1332
1333int
1335 int counter = 0;
1336 for (const auto& TAZSink : myAdditionals.at(SUMO_TAG_TAZSINK)) {
1337 if (TAZSink.second->isAttributeCarrierSelected()) {
1338 counter++;
1339 }
1340 }
1341 return counter;
1342}
1343
1344
1345int
1347 int counter = 0;
1348 for (const auto& additionalsTags : myAdditionals) {
1349 for (const auto& additional : additionalsTags.second) {
1350 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty().isWireElement()) {
1351 counter++;
1352 }
1353 }
1354 }
1355 return counter;
1356}
1357
1358
1360GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1361 auto it = myDemandElementIDs.at(type).find(id);
1362 if (it != myDemandElementIDs.at(type).end()) {
1363 return it->second;
1364 }
1365 if (hardFail) {
1366 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1367 } else {
1368 return nullptr;
1369 }
1370}
1371
1372
1374GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1375 for (const auto& type : types) {
1376 auto it = myDemandElementIDs.at(type).find(id);
1377 if (it != myDemandElementIDs.at(type).end()) {
1378 return it->second;
1379 }
1380 }
1381 if (hardFail) {
1382 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1383 } else {
1384 return nullptr;
1385 }
1386}
1387
1388
1391 // iterate over all demand elements
1392 for (const auto& demandElementTag : myDemandElements) {
1393 auto it = demandElementTag.second.find(glObject);
1394 if (it != demandElementTag.second.end()) {
1395 return it->second;
1396 }
1397 }
1398 if (hardFail) {
1399 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1400 } else {
1401 return nullptr;
1402 }
1403}
1404
1405
1406std::vector<GNEDemandElement*>
1408 std::vector<GNEDemandElement*> result;
1409 // returns demand elements depending of selection
1410 for (const auto& demandElementTag : myDemandElements) {
1411 for (const auto& demandElement : demandElementTag.second) {
1412 if (demandElement.second->isAttributeCarrierSelected()) {
1413 result.push_back(demandElement.second);
1414 }
1415 }
1416 }
1417 return result;
1418}
1419
1420
1421const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*> >&
1423 return myDemandElements;
1424}
1425
1426
1427std::string
1429 // obtain option container
1430 const auto& neteditOptions = OptionsCont::getOptions();
1431 // get tag property
1432 const auto tagProperty = GNEAttributeCarrier::getTagProperty(tag);
1433 // get prefix
1434 std::string prefix;
1435 if (tag == SUMO_TAG_ROUTE) {
1436 prefix = neteditOptions.getString("route-prefix");
1437 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1438 prefix = neteditOptions.getString("routeDistribution-prefix");
1439 } else if (tag == SUMO_TAG_VTYPE) {
1440 prefix = neteditOptions.getString("vType-prefix");
1441 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1442 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1443 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1444 prefix = neteditOptions.getString("trip-prefix");
1445 } else if (tagProperty.isVehicle() && !tagProperty.isFlow()) {
1446 prefix = neteditOptions.getString("vehicle-prefix");
1447 } else if (tagProperty.isPerson()) {
1448 if (tagProperty.isFlow()) {
1449 prefix = neteditOptions.getString("personflow-prefix");
1450 } else {
1451 prefix = neteditOptions.getString("person-prefix");
1452 }
1453 } else if (tagProperty.isContainer()) {
1454 if (tagProperty.isFlow()) {
1455 prefix = neteditOptions.getString("containerflow-prefix");
1456 } else {
1457 prefix = neteditOptions.getString("container-prefix");
1458 }
1459 } else if (tagProperty.isFlow()) {
1460 prefix = neteditOptions.getString("flow-prefix");
1461 }
1462 // declare counter
1463 int counter = 0;
1464 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1465 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1466 counter++;
1467 }
1468 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1469 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1470 counter++;
1471 }
1472 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1473 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1474 counter++;
1475 }
1476 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1477 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1478 counter++;
1479 }
1480 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1481 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1482 counter++;
1483 }
1484 } else {
1485 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1486 counter++;
1487 }
1488 }
1489 // return new element ID
1490 return (prefix + "_" + toString(counter));
1491
1492}
1493
1494
1497 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1498 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1499 return it->second;
1500 }
1501 throw ProcessError(TL("Default vType doesn't exist"));
1502}
1503
1504
1505void
1507 // clear elements in grid
1508 for (const auto& demandElementsTags : myDemandElements) {
1509 for (const auto& demandElement : demandElementsTags.second) {
1510 myNet->removeGLObjectFromGrid(demandElement.second);
1511 }
1512 }
1513 // iterate over myDemandElements and clear all demand elements
1514 for (auto& demandElements : myDemandElements) {
1515 demandElements.second.clear();
1516 }
1517 for (auto& demandElements : myDemandElementIDs) {
1518 demandElements.second.clear();
1519 }
1520}
1521
1522
1523void
1525 const auto tag = demandElement->getTagProperty().getTag();
1526 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1527 if (it == myDemandElementIDs.at(tag).end()) {
1528 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1529 } else {
1530 // remove from container, set new Id, and insert it again
1531 myDemandElementIDs.at(tag).erase(it);
1532 // set microsim ID
1533 demandElement->setMicrosimID(newID);
1534 myDemandElementIDs.at(tag)[newID] = demandElement;
1535 }
1536}
1537
1538
1539void
1541 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1542 GNEVType* defaultVehicleType = new GNEVType(myNet, DEFAULT_VTYPE_ID, SVC_PASSENGER);
1543 myDemandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1544 myDemandElementIDs.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1545 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1546
1547 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1548 GNEVType* defaultBikeType = new GNEVType(myNet, DEFAULT_BIKETYPE_ID, SVC_BICYCLE);
1549 myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1550 myDemandElementIDs.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1551 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1552 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1553
1554 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1555 GNEVType* defaultTaxiType = new GNEVType(myNet, DEFAULT_TAXITYPE_ID, SVC_TAXI);
1556 myDemandElements.at(defaultTaxiType->getTagProperty().getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1557 myDemandElementIDs.at(defaultTaxiType->getTagProperty().getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1558 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1559 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1560
1561 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1562 GNEVType* defaultRailType = new GNEVType(myNet, DEFAULT_RAILTYPE_ID, SVC_RAIL);
1563 myDemandElements.at(defaultRailType->getTagProperty().getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1564 myDemandElementIDs.at(defaultRailType->getTagProperty().getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1565 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1566 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1567
1568 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1569 GNEVType* defaultPersonType = new GNEVType(myNet, DEFAULT_PEDTYPE_ID, SVC_PEDESTRIAN);
1570 myDemandElements.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1571 myDemandElementIDs.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1572 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1573 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1574
1575 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1576 GNEVType* defaultContainerType = new GNEVType(myNet, DEFAULT_CONTAINERTYPE_ID, SVC_IGNORING);
1577 myDemandElements.at(defaultContainerType->getTagProperty().getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1578 myDemandElementIDs.at(defaultContainerType->getTagProperty().getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1579 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1580 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1581}
1582
1583
1584int
1586 return myStopIndex++;
1587}
1588
1589
1590int
1592 int counter = 0;
1593 for (const auto& demandElementsTags : myDemandElements) {
1594 for (const auto& demandElement : demandElementsTags.second) {
1595 if (demandElement.second->isAttributeCarrierSelected()) {
1596 counter++;
1597 }
1598 }
1599 }
1600 return counter;
1601}
1602
1603
1604int
1606 int counter = 0;
1607 // iterate over routes
1608 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1609 if (route.second->isAttributeCarrierSelected()) {
1610 counter++;
1611 }
1612 }
1613 // iterate over vehicles with embedded routes
1614 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1615 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1616 counter++;
1617 }
1618 }
1619 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1620 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1621 counter++;
1622 }
1623 }
1624 return counter;
1625}
1626
1627
1628int
1630 int counter = 0;
1631 // iterate over all vehicles and flows
1632 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1633 if (vehicle.second->isAttributeCarrierSelected()) {
1634 counter++;
1635 }
1636 }
1637 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1638 if (trip.second->isAttributeCarrierSelected()) {
1639 counter++;
1640 }
1641 }
1642 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1643 if (vehicle.second->isAttributeCarrierSelected()) {
1644 counter++;
1645 }
1646 }
1647 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1648 if (flow.second->isAttributeCarrierSelected()) {
1649 counter++;
1650 }
1651 }
1652 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1653 if (flow.second->isAttributeCarrierSelected()) {
1654 counter++;
1655 }
1656 }
1657 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1658 if (flow.second->isAttributeCarrierSelected()) {
1659 counter++;
1660 }
1661 }
1662 return counter;
1663}
1664
1665
1666int
1668 int counter = 0;
1669 // iterate over all persons
1670 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1671 if (person.second->isAttributeCarrierSelected()) {
1672 counter++;
1673 }
1674 }
1675 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1676 if (personFlow.second->isAttributeCarrierSelected()) {
1677 counter++;
1678 }
1679 }
1680 return counter;
1681}
1682
1683
1684int
1686 int counter = 0;
1687 // iterate over all person plans
1688 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1689 for (const auto& personPlan : person.second->getChildDemandElements()) {
1690 if (personPlan->getTagProperty().isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1691 counter++;
1692 }
1693 }
1694 }
1695 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1696 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1697 if (personPlan->getTagProperty().isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1698 counter++;
1699 }
1700 }
1701 }
1702 return counter;
1703}
1704
1705
1706int
1708 int counter = 0;
1709 // iterate over all person plans
1710 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1711 for (const auto& personPlan : person.second->getChildDemandElements()) {
1712 if (personPlan->getTagProperty().isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1713 counter++;
1714 }
1715 }
1716 }
1717 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1718 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1719 if (personPlan->getTagProperty().isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1720 counter++;
1721 }
1722 }
1723 }
1724 return counter;
1725}
1726
1727
1728int
1730 int counter = 0;
1731 // iterate over all person plans
1732 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1733 for (const auto& personPlan : person.second->getChildDemandElements()) {
1734 if (personPlan->getTagProperty().isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1735 counter++;
1736 }
1737 }
1738 }
1739 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1740 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1741 if (personPlan->getTagProperty().isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1742 counter++;
1743 }
1744 }
1745 }
1746 return counter;
1747}
1748
1749
1750int
1752 int counter = 0;
1753 // iterate over all containers
1754 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1755 if (container.second->isAttributeCarrierSelected()) {
1756 counter++;
1757 }
1758 }
1759 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1760 if (containerFlow.second->isAttributeCarrierSelected()) {
1761 counter++;
1762 }
1763 }
1764 return counter;
1765}
1766
1767
1768int
1770 int counter = 0;
1771 // iterate over all container plans
1772 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1773 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1774 if (containerPlan->getTagProperty().isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1775 counter++;
1776 }
1777 }
1778 }
1779 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1780 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1781 if (containerPlan->getTagProperty().isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1782 counter++;
1783 }
1784 }
1785 }
1786 return counter;
1787}
1788
1789
1790int
1792 int counter = 0;
1793 // iterate over all container plans
1794 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1795 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1796 if (containerPlan->getTagProperty().isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1797 counter++;
1798 }
1799 }
1800 }
1801 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1802 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1803 if (containerPlan->getTagProperty().isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1804 counter++;
1805 }
1806 }
1807 }
1808 return counter;
1809}
1810
1811
1812int
1814 int counter = 0;
1815 // iterate over routes
1816 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1817 if (route.second->isAttributeCarrierSelected()) {
1818 counter++;
1819 }
1820 }
1821 // vehicles
1822 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1823 for (const auto& stop : trip.second->getChildDemandElements()) {
1824 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1825 counter++;
1826 }
1827 }
1828 }
1829 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1830 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1831 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1832 counter++;
1833 }
1834 }
1835 }
1836 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1837 for (const auto& stop : flow.second->getChildDemandElements()) {
1838 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1839 counter++;
1840 }
1841 }
1842 }
1843 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1844 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1845 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1846 counter++;
1847 }
1848 }
1849 }
1850 // persons
1851 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1852 for (const auto& personPlan : person.second->getChildDemandElements()) {
1853 if (personPlan->getTagProperty().isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1854 counter++;
1855 }
1856 }
1857 }
1858 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1859 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1860 if (personPlan->getTagProperty().isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1861 counter++;
1862 }
1863 }
1864 }
1865 // containers
1866 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1867 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1868 if (containerPlan->getTagProperty().isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1869 counter++;
1870 }
1871 }
1872 }
1873 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1874 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1875 if (containerPlan->getTagProperty().isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1876 counter++;
1877 }
1878 }
1879 }
1880 return counter;
1881}
1882
1883
1885GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1886 for (const auto& dataSet : myDataSets) {
1887 if (dataSet.second->getID() == id) {
1888 return dataSet.second;
1889 }
1890 }
1891 if (hardFail) {
1892 throw ProcessError("Attempted to retrieve non-existant data set");
1893 } else {
1894 return nullptr;
1895 }
1896}
1897
1898
1899const std::map<const std::string, GNEDataSet*>&
1901 return myDataSets;
1902}
1903
1904
1905std::string
1907 const std::string dataSetTagStr = toString(SUMO_TAG_DATASET);
1908 int counter = 0;
1909 while (retrieveDataSet(prefix + dataSetTagStr + "_" + toString(counter), false) != nullptr) {
1910 counter++;
1911 }
1912 return (prefix + dataSetTagStr + "_" + toString(counter));
1913}
1914
1915
1918 if (myDataIntervals.count(AC)) {
1919 return myDataIntervals.at(AC);
1920 } else if (hardFail) {
1921 throw ProcessError("Attempted to retrieve non-existant data interval");
1922 } else {
1923 return nullptr;
1924 }
1925}
1926
1927
1928const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
1930 return myDataIntervals;
1931}
1932
1933
1934void
1936 if (myDataIntervals.count(AC) > 0) {
1937 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
1938 } else {
1939 myDataIntervals[AC] = dataInterval;
1940 }
1941 // mark interval toolbar for update
1942 myNet->getViewNet()->getIntervalBar().markForUpdate();
1943}
1944
1945
1946void
1948 const auto finder = myDataIntervals.find(dataInterval);
1949 if (finder == myDataIntervals.end()) {
1950 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
1951 } else {
1952 myDataIntervals.erase(finder);
1953 }
1954 // remove it from inspected elements and GNEElementTree
1955 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
1956 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
1957 // mark interval toolbar for update
1958 myNet->getViewNet()->getIntervalBar().markForUpdate();
1959}
1960
1961
1964 // iterate over all genericDatas
1965 for (const auto& genericDataTag : myGenericDatas) {
1966 auto it = genericDataTag.second.find(glObject);
1967 if (it != genericDataTag.second.end()) {
1968 return it->second;
1969 }
1970 }
1971 if (hardFail) {
1972 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
1973 } else {
1974 return nullptr;
1975 }
1976}
1977
1978
1979std::vector<GNEGenericData*>
1981 std::vector<GNEGenericData*> result;
1982 // returns generic datas depending of selection
1983 for (const auto& genericDataTag : myGenericDatas) {
1984 for (const auto& genericData : genericDataTag.second) {
1985 if (genericData.second->isAttributeCarrierSelected()) {
1986 result.push_back(genericData.second);
1987 }
1988 }
1989 }
1990 return result;
1991}
1992
1993
1994const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*> >&
1996 return myGenericDatas;
1997}
1998
1999
2000std::vector<GNEGenericData*>
2001GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2002 // declare generic data vector
2003 std::vector<GNEGenericData*> genericDatas;
2004 // iterate over all data sets
2005 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2006 // check interval
2007 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2008 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2009 genericDatas.push_back(genericData.second);
2010 }
2011 }
2012 return genericDatas;
2013}
2014
2015
2016int
2018 int counter = 0;
2019 // iterate over all generic datas
2020 for (const auto& genericDataTag : myGenericDatas) {
2021 counter += (int)genericDataTag.second.size();
2022 }
2023 return counter;
2024}
2025
2026
2027int
2029 int counter = 0;
2030 // iterate over all edgeDatas
2031 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2032 if (genericData.second->isAttributeCarrierSelected()) {
2033 counter++;
2034 }
2035 }
2036 return counter;
2037}
2038
2039
2040int
2042 int counter = 0;
2043 // iterate over all edgeDatas
2044 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2045 if (genericData.second->isAttributeCarrierSelected()) {
2046 counter++;
2047 }
2048 }
2049 return counter;
2050}
2051
2052
2053int
2055 int counter = 0;
2056 // iterate over all edgeDatas
2057 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2058 if (genericData.second->isAttributeCarrierSelected()) {
2059 counter++;
2060 }
2061 }
2062 return counter;
2063}
2064
2065
2066void
2068 if (myGenericDatas.at(genericData->getTagProperty().getTag()).count(genericData->getGUIGlObject()) > 0) {
2069 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2070 } else {
2071 myGenericDatas.at(genericData->getTagProperty().getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2072 }
2073 // mark interval toolbar for update
2074 myNet->getViewNet()->getIntervalBar().markForUpdate();
2075}
2076
2077
2078void
2080 const auto finder = myGenericDatas.at(genericData->getTagProperty().getTag()).find(genericData);
2081 if (finder == myGenericDatas.at(genericData->getTagProperty().getTag()).end()) {
2082 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2083 } else {
2084 myGenericDatas.at(genericData->getTagProperty().getTag()).erase(finder);
2085 }
2086 // remove it from inspected elements and GNEElementTree
2087 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2088 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2089 // delete path element
2090 myNet->getDataPathManager()->removePath(genericData);
2091 // mark interval toolbar for update
2092 myNet->getViewNet()->getIntervalBar().markForUpdate();
2093}
2094
2095
2096std::set<std::string>
2097GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2098 // declare solution
2099 std::set<std::string> attributesSolution;
2100 // declare generic data vector
2101 std::vector<GNEGenericData*> genericDatas;
2102 // iterate over all data sets
2103 for (const auto& interval : myDataIntervals) {
2104 // check interval
2105 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2106 // iterate over generic datas
2107 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2108 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2109 genericDatas.push_back(genericData);
2110 }
2111 }
2112 }
2113 }
2114 // iterate over generic datas
2115 for (const auto& genericData : genericDatas) {
2116 for (const auto& attribute : genericData->getParametersMap()) {
2117 attributesSolution.insert(attribute.first);
2118 }
2119 }
2120 return attributesSolution;
2121}
2122
2123
2124std::set<std::string>
2125GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2126 const std::string& beginStr, const std::string& endStr) const {
2127 // declare solution
2128 std::set<std::string> attributesSolution;
2129 // vector of data sets and intervals
2130 std::vector<GNEDataSet*> dataSets;
2131 std::vector<GNEDataInterval*> dataIntervals;
2132 // get dataSet
2133 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2134 // if dataSetID is empty, return all parameters
2135 if (dataSetID.empty()) {
2136 // add all data sets
2137 dataSets.reserve(myDataSets.size());
2138 for (const auto& dataSet : myDataSets) {
2139 dataSets.push_back(dataSet.second);
2140 }
2141 } else if (retrievedDataSet) {
2142 dataSets.push_back(retrievedDataSet);
2143 } else {
2144 return attributesSolution;
2145 }
2146 // now continue with data intervals
2147 int numberOfIntervals = 0;
2148 for (const auto& dataSet : dataSets) {
2149 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2150 }
2151 // resize dataIntervals
2152 dataIntervals.reserve(numberOfIntervals);
2153 // add intervals
2154 for (const auto& dataSet : dataSets) {
2155 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2156 // continue depending of begin and end
2157 if (beginStr.empty() && endStr.empty()) {
2158 dataIntervals.push_back(dataInterval.second);
2159 } else if (endStr.empty()) {
2160 // parse begin
2161 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2162 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2163 dataIntervals.push_back(dataInterval.second);
2164 }
2165 } else if (beginStr.empty()) {
2166 // parse end
2167 const double end = GNEAttributeCarrier::parse<double>(endStr);
2168 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2169 dataIntervals.push_back(dataInterval.second);
2170 }
2171 } else {
2172 // parse both begin end
2173 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2174 const double end = GNEAttributeCarrier::parse<double>(endStr);
2175 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2176 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2177 dataIntervals.push_back(dataInterval.second);
2178 }
2179 }
2180 }
2181 }
2182 // finally iterate over intervals and get attributes
2183 for (const auto& dataInterval : dataIntervals) {
2184 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2185 // check generic data tag
2186 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2187 for (const auto& attribute : genericData->getParametersMap()) {
2188 attributesSolution.insert(attribute.first);
2189 }
2190 }
2191 }
2192 }
2193 return attributesSolution;
2194}
2195
2196
2198GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2199 for (const auto& meanData : myMeanDatas.at(type)) {
2200 if (meanData.second->getID() == id) {
2201 return meanData.second;
2202 }
2203 }
2204 if (hardFail) {
2205 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2206 } else {
2207 return nullptr;
2208 }
2209}
2210
2211
2212const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*> >&
2214 return myMeanDatas;
2215}
2216
2217
2218int
2220 int counter = 0;
2221 for (const auto& meanDatasTag : myMeanDatas) {
2222 counter += (int)meanDatasTag.second.size();
2223 }
2224 return counter;
2225}
2226
2227
2228void
2230 // iterate over myMeanDatas and clear all meanDatas
2231 for (auto& meanDatas : myMeanDatas) {
2232 meanDatas.second.clear();
2233 }
2234}
2235
2236
2237std::string
2239 // obtain option container
2240 const auto& neteditOptions = OptionsCont::getOptions();
2241 // get prefix
2242 std::string prefix;
2243 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2244 prefix = neteditOptions.getString("meanDataEdge-prefix");
2245 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2246 prefix = neteditOptions.getString("meanDataLane-prefix");
2247 }
2248 int counter = 0;
2249 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2250 counter++;
2251 }
2252 return (prefix + "_" + toString(counter));
2253}
2254
2255
2256void
2258 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2259 registerJunction(junction);
2260}
2261
2262
2263void
2265 // remove it from inspected elements and GNEElementTree
2266 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2267 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2268 // Remove from grid and container
2269 myNet->removeGLObjectFromGrid(junction);
2270 myJunctions.erase(junction->getMicrosimID());
2271 myNumberOfNetworkElements--;
2272 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2273 junction->decRef("GNENet::deleteSingleJunction");
2274 junction->setResponsible(true);
2275}
2276
2277
2278void
2280 // get pointer to create edge frame
2281 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2282 // insert in myEdgeTypes
2283 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2284 myNumberOfNetworkElements++;
2285 // update edge selector
2286 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
2287 myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2288 }
2289 // set current edge type inspected
2290 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2291}
2292
2293
2294void
2296 // get pointer to create edge frame
2297 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2298 // remove it from inspected elements and GNEElementTree
2299 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2300 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2301 // remove from edge types
2302 myEdgeTypes.erase(edgeType->getMicrosimID());
2303 myNumberOfNetworkElements--;
2304 // check if this is the selected edge type in edgeSelector
2305 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2306 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2307 }
2308 // update edge selector
2309 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2310}
2311
2312
2313void
2315 NBEdge* nbe = edge->getNBEdge();
2316 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2317 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2318 nbe->getFromNode()->addOutgoingEdge(nbe);
2319 nbe->getToNode()->addIncomingEdge(nbe);
2320 // register edge
2321 registerEdge(edge);
2322}
2323
2324
2325void
2327 // remove it from inspected elements and GNEElementTree
2328 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2329 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2330 // remove edge from visual grid and container
2331 myNet->removeGLObjectFromGrid(edge);
2332 myEdges.erase(edge->getMicrosimID());
2333 myNumberOfNetworkElements--;
2334 // remove all lanes
2335 for (const auto& lane : edge->getLanes()) {
2336 deleteLane(lane);
2337 }
2338 // extract edge of district container
2339 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2340 edge->decRef("GNENet::deleteSingleEdge");
2341 edge->setResponsible(true);
2342 // Remove refrences from GNEJunctions
2344 edge->getToJunction()->removeIncomingGNEEdge(edge);
2345 // update boundaries of both junctions (to remove it from Grid)
2348 // get template editor
2349 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
2350 // check if we have to remove template
2351 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2352 templateEditor->setEdgeTemplate(nullptr);
2353 }
2354}
2355
2356
2357void
2359 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2360 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2361 } else {
2362 myLanes[lane->getGUIGlObject()] = lane;
2363 myNumberOfNetworkElements++;
2364 }
2365}
2366
2367
2368void
2370 const auto finder = myLanes.find(lane->getGUIGlObject());
2371 if (finder == myLanes.end()) {
2372 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2373 } else {
2374 myLanes.erase(finder);
2375 myNumberOfNetworkElements--;
2376 // remove it from inspected elements and GNEElementTree
2377 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2378 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2379 }
2380}
2381
2382
2383void
2385 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2386 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2387 } else {
2388 myCrossings[crossing->getGUIGlObject()] = crossing;
2389 myNumberOfNetworkElements++;
2390 }
2391}
2392
2393
2394void
2396 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2397 if (finder == myCrossings.end()) {
2398 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2399 } else {
2400 myCrossings.erase(finder);
2401 myNumberOfNetworkElements--;
2402 // remove it from inspected elements and GNEElementTree
2403 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2404 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2405 }
2406}
2407
2408
2409void
2411 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2412 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2413 } else {
2414 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2415 myNumberOfNetworkElements++;
2416 }
2417}
2418
2419
2420void
2422 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2423 if (finder == myWalkingAreas.end()) {
2424 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2425 } else {
2426 myWalkingAreas.erase(finder);
2427 myNumberOfNetworkElements--;
2428 // remove it from inspected elements and GNEElementTree
2429 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2430 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2431 }
2432}
2433
2434
2435void
2437 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2438 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2439 } else {
2440 myConnections[connection->getGUIGlObject()] = connection;
2441 myNumberOfNetworkElements++;
2442 }
2443}
2444
2445
2446void
2448 const auto finder = myConnections.find(connection->getGUIGlObject());
2449 if (finder == myConnections.end()) {
2450 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2451 } else {
2452 myConnections.erase(finder);
2453 myNumberOfNetworkElements--;
2454 // remove it from inspected elements and GNEElementTree
2455 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2456 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2457 }
2458}
2459
2460
2461void
2463 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2464 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' already exist");
2465 } else {
2466 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2467 myNumberOfNetworkElements++;
2468 }
2469}
2470
2471
2472void
2474 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2475 if (finder == myInternalLanes.end()) {
2476 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2477 } else {
2478 myInternalLanes.erase(finder);
2479 myNumberOfNetworkElements--;
2480 }
2481}
2482
2483
2484void
2486 const auto tag = additional->getTagProperty().getTag();
2487 if (myAdditionals.at(tag).count(additional) > 0) {
2488 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2489 } else {
2490 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2491 if (additional->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2492 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2493 }
2494 myNumberOfNetworkElements++;
2495 // add element in grid
2496 if (additional->getTagProperty().isPlacedInRTree()) {
2497 myNet->addGLObjectIntoGrid(additional);
2498 }
2499 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2500 if (myNet->isUpdateGeometryEnabled()) {
2501 additional->updateGeometry();
2502 }
2503 // additionals has to be saved
2504 myNet->getSavingStatus()->requireSaveAdditionals();
2505 }
2506}
2507
2508
2509void
2511 const auto tag = additional->getTagProperty().getTag();
2512 // find demanElement in additionalTag
2513 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2514 // check if additional was previously inserted
2515 if (itFind == myAdditionals.at(tag).end()) {
2516 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2517 } else {
2518 // remove from both container
2519 myAdditionals.at(tag).erase(itFind);
2520 if (additional->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2521 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2522 }
2523 myNumberOfNetworkElements--;
2524 // remove it from inspected elements and GNEElementTree
2525 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2526 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2527 // remove element from grid
2528 if (additional->getTagProperty().isPlacedInRTree()) {
2529 myNet->removeGLObjectFromGrid(additional);
2530 }
2531 // delete path element
2532 myNet->getNetworkPathManager()->removePath(additional);
2533 // additionals has to be saved
2534 myNet->getSavingStatus()->requireSaveAdditionals();
2535 }
2536}
2537
2538
2539void
2541 const auto tag = demandElement->getTagProperty().getTag();
2542 if (myDemandElements.at(tag).count(demandElement) > 0) {
2543 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2544 } else {
2545 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2546 myNumberOfDemandElements++;
2547 if (demandElement->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2548 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2549 }
2550 // add element in grid
2551 myNet->addGLObjectIntoGrid(demandElement);
2552 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2553 if (myNet->isUpdateGeometryEnabled()) {
2554 demandElement->updateGeometry();
2555 }
2556 // compute path element
2557 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2558 demandElement->computePathElement();
2559 }
2560 // update demand elements frames
2561 updateDemandElementFrames(demandElement->getTagProperty());
2562 // demandElements has to be saved
2563 myNet->getSavingStatus()->requireSaveDemandElements();
2564 }
2565}
2566
2567
2568void
2570 const auto tag = demandElement->getTagProperty().getTag();
2571 auto viewParent = myNet->getViewNet()->getViewParent();
2572 // find demanElement in demandElementTag
2573 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2574 // check if demandElement was previously inserted
2575 if (itFind == myDemandElements.at(tag).end()) {
2576 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2577 } else {
2578 // erase it from container
2579 myDemandElements.at(tag).erase(itFind);
2580 if (demandElement->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2581 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2582 }
2583 myNumberOfDemandElements--;
2584 // remove element from grid
2585 myNet->removeGLObjectFromGrid(demandElement);
2586 // remove it from inspected elements and GNEElementTree
2587 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2588 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2589 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2590 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2591 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2592 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2593 }
2594 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2595 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2596 }
2597 // if is the last inserted route, remove it from GNEViewNet
2598 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2599 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2600 }
2601 // delete path element
2602 myNet->getDemandPathManager()->removePath(demandElement);
2603 // check if update demand elements frames
2604 if (updateFrames) {
2605 updateDemandElementFrames(demandElement->getTagProperty());
2606 }
2607 // demandElements has to be saved
2608 myNet->getSavingStatus()->requireSaveDemandElements();
2609 }
2610}
2611
2612
2613void
2615 if (myDataSets.count(dataSet->getID()) > 0) {
2616 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2617 } else {
2618 myDataSets[dataSet->getID()] = dataSet;
2619 myNumberOfDataElements++;
2620 // dataSets has to be saved
2621 myNet->getSavingStatus()->requireSaveDataElements();
2622 // mark interval toolbar for update
2623 myNet->getViewNet()->getIntervalBar().markForUpdate();
2624 }
2625}
2626
2627
2628void
2630 const auto finder = myDataSets.find(dataSet->getID());
2631 if (finder == myDataSets.end()) {
2632 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2633 } else {
2634 myDataSets.erase(finder);
2635 myNumberOfDataElements--;
2636 // remove it from inspected elements and GNEElementTree
2637 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2638 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2639 // dataSets has to be saved
2640 myNet->getSavingStatus()->requireSaveDataElements();
2641 // mark interval toolbar for update
2642 myNet->getViewNet()->getIntervalBar().markForUpdate();
2643 }
2644}
2645
2646
2647void
2649 if (myMeanDatas.at(meanData->getTagProperty().getTag()).count(meanData->getID()) > 0) {
2650 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2651 } else {
2652 myMeanDatas.at(meanData->getTagProperty().getTag()).insert(std::make_pair(meanData->getID(), meanData));
2653 myNumberOfDataElements++;
2654 // meanDatas has to be saved
2655 myNet->getSavingStatus()->requireSaveMeanDatas();
2656 }
2657}
2658
2659
2660void
2662 // find demanElement in meanDataTag
2663 auto itFind = myMeanDatas.at(meanData->getTagProperty().getTag()).find(meanData->getID());
2664 // check if meanData was previously inserted
2665 if (itFind == myMeanDatas.at(meanData->getTagProperty().getTag()).end()) {
2666 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2667 } else {
2668 // remove it from inspected elements and GNEElementTree
2669 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2670 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2671 // remove from container
2672 myMeanDatas.at(meanData->getTagProperty().getTag()).erase(itFind);
2673 myNumberOfDataElements--;
2674 // remove element from grid
2675 if (meanData->getTagProperty().isPlacedInRTree()) {
2676 myNet->removeGLObjectFromGrid(meanData);
2677 }
2678 // meanDatas has to be saved
2679 myNet->getSavingStatus()->requireSaveMeanDatas();
2680 }
2681}
2682
2683
2684void
2686 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2687 // continue depending of demand mode
2688 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2690 if (tagProperty.isType()) {
2691 myNet->getViewNet()->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2692 }
2693 break;
2695 if (tagProperty.isType()) {
2696 myNet->getViewNet()->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2697 }
2698 break;
2700 if (tagProperty.isType()) {
2701 myNet->getViewNet()->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2702 }
2703 break;
2705 if (tagProperty.isRoute()) {
2706 myNet->getViewNet()->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2707 }
2708 break;
2710 if (tagProperty.isType()) {
2711 myNet->getViewNet()->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2712 }
2713 break;
2715 if (tagProperty.isPerson()) {
2716 myNet->getViewNet()->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2717 }
2718 break;
2720 if (tagProperty.isType()) {
2721 myNet->getViewNet()->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2722 }
2723 break;
2725 if (tagProperty.isContainer()) {
2726 myNet->getViewNet()->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2727 }
2728 break;
2730 myNet->getViewNet()->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2731 break;
2732 default:
2733 // nothing to update
2734 break;
2735 }
2736 }
2737}
2738
2739// ---------------------------------------------------------------------------
2740// GNENetHelper::SavingStatus - methods
2741// ---------------------------------------------------------------------------
2742
2745
2746
2747void
2749 mySumoConfigSaved = false;
2750}
2751
2752
2753void
2755 mySumoConfigSaved = true;
2756}
2757
2758
2759bool
2761 return mySumoConfigSaved;
2762}
2763
2764
2765
2766void
2768 myNeteditConfigSaved = false;
2769}
2770
2771
2772void
2774 myNeteditConfigSaved = true;
2775}
2776
2777
2778bool
2780 return myNeteditConfigSaved;
2781}
2782
2783
2784void
2786 myNetworkSaved = false;
2787 // implies requiere save netedit config and sumo config
2788 myNeteditConfigSaved = false;
2789 mySumoConfigSaved = false;
2790}
2791
2792
2793void
2795 myNetworkSaved = true;
2796}
2797
2798
2799bool
2801 return myNetworkSaved;
2802}
2803
2804
2805void
2807 myTLSSaved = false;
2808}
2809
2810
2811void
2813 myTLSSaved = true;
2814}
2815
2816
2817bool
2819 return myTLSSaved;
2820}
2821
2822
2823void
2825 myEdgeTypeSaved = false;
2826}
2827
2828
2829void
2831 myEdgeTypeSaved = true;
2832}
2833
2834
2835bool
2837 return myEdgeTypeSaved;
2838}
2839
2840
2841void
2843 myAdditionalSaved = false;
2844 // implies requiere save netedit config and sumo config
2845 myNeteditConfigSaved = false;
2846 mySumoConfigSaved = false;
2847}
2848
2849
2850void
2852 myAdditionalSaved = true;
2853}
2854
2855
2856bool
2858 return myAdditionalSaved;
2859}
2860
2861
2862void
2864 myDemandElementSaved = false;
2865 // implies requiere save netedit config and sumo config
2866 myNeteditConfigSaved = false;
2867 mySumoConfigSaved = false;
2868}
2869
2870
2871void
2873 myDemandElementSaved = true;
2874}
2875
2876
2877bool
2879 return myDemandElementSaved;
2880}
2881
2882
2883void
2885 myDataElementSaved = false;
2886 // implies requiere save netedit config and sumo config
2887 myNeteditConfigSaved = false;
2888 mySumoConfigSaved = false;
2889}
2890
2891
2892void
2894 myDataElementSaved = true;
2895}
2896
2897
2898bool
2900 return myDataElementSaved;
2901}
2902
2903
2904void
2906 myMeanDataElementSaved = false;
2907 // implies requiere save netedit config and sumo config
2908 myNeteditConfigSaved = false;
2909 mySumoConfigSaved = false;
2910}
2911
2912
2913void
2915 myMeanDataElementSaved = true;
2916}
2917
2918
2919bool
2921 return myMeanDataElementSaved;
2922}
2923
2924// ---------------------------------------------------------------------------
2925// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
2926// ---------------------------------------------------------------------------
2927
2929 GNEChange(Supermode::NETWORK, true, false),
2930 myTllcont(tllcont),
2931 myReplaced(replaced),
2932 myBy(by) {
2933}
2934
2935
2937
2938
2939void
2941 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2942 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
2943}
2944
2945
2946void
2948 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2949 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
2950}
2951
2952
2953std::string
2955 return TL("Redo replace in TLS");
2956}
2957
2958
2959std::string
2961 return TL("Undo replace in TLS");
2962}
2963
2964
2965bool
2967 return myReplaced != myBy;
2968}
2969
2970/****************************************************************************/
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
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:1532
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:2326
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
const std::map< const std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
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
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
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.
const std::map< const std::string, GNEJunction * > & getJunctions() const
get junctions
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)
int getNumberOfSelectedEdges() const
get number of selected edges
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
const std::map< const std::string, GNEEdgeType * > & getEdgeTypes() const
map with the ID and pointer to edgeTypes of net
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:3966
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:2987
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:2616
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