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-2025 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
97#include <netedit/GNENet.h>
99#include <netedit/GNEViewNet.h>
105
106#include "GNENetHelper.h"
107
108// ---------------------------------------------------------------------------
109// GNENetHelper::AttributeCarriers - methods
110// ---------------------------------------------------------------------------
111
113 myNet(net),
114 myStopIndex(0) {
115 // fill additionals with tags
118 for (const auto& additionalTagProperty : additionalTagProperties) {
119 myAdditionals.insert(std::make_pair(additionalTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEAdditional*>()));
120 if (additionalTagProperty->hasAttribute(SUMO_ATTR_ID) || (additionalTagProperty->getTag() == SUMO_TAG_VAPORIZER)) {
121 myAdditionalIDs.insert(std::make_pair(additionalTagProperty->getTag(), std::map<const std::string, GNEAdditional*>()));
122 }
123 }
124 myTAZSourceSinks.insert(std::make_pair(SUMO_TAG_TAZSOURCE, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>()));
125 myTAZSourceSinks.insert(std::make_pair(SUMO_TAG_TAZSINK, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>()));
126 // fill demand elements with tags
128 for (const auto& demandElementTagProperty : demandElementTagProperties) {
129 myDemandElements.insert(std::make_pair(demandElementTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
130 if (demandElementTagProperty->hasAttribute(SUMO_ATTR_ID)) {
131 myDemandElementIDs.insert(std::make_pair(demandElementTagProperty->getTag(), std::map<const std::string, GNEDemandElement*>()));
132 }
133 }
135 for (const auto& stopTagProperty : stopTagProperties) {
136 myDemandElements.insert(std::make_pair(stopTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
137 }
138 // fill data elements with tags
140 for (const auto& genericDataElementTagProperty : genericDataElementTagProperties) {
141 myGenericDatas.insert(std::make_pair(genericDataElementTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEGenericData*>()));
142 }
143 // fill meanDatas with tags
145 for (const auto& meanDataTagProperty : meanDataTagProperties) {
146 myMeanDatas.insert(std::make_pair(meanDataTagProperty->getTag(), std::map<const std::string, GNEMeanData*>()));
147 }
148}
149
150
152 // Drop EdgeTypes
153 for (const auto& edgeType : myEdgeTypes) {
154 edgeType.second->decRef("GNENetHelper::~GNENet");
155 delete edgeType.second;
156 }
157 // Drop Edges
158 for (const auto& edge : myEdges) {
159 edge.second->decRef("GNENetHelper::~GNENet");
160 delete edge.second;
161 }
162 // Drop myJunctions
163 for (const auto& junction : myJunctions) {
164 junction.second->decRef("GNENetHelper::~GNENet");
165 delete junction.second;
166 }
167 // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
168 for (const auto& additionalTag : myAdditionals) {
169 for (const auto& additional : additionalTag.second) {
170 // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
171 additional.second->decRef();
172 delete additional.second;
173 }
174 }
175 // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
176 for (const auto& demandElementTag : myDemandElements) {
177 for (const auto& demandElement : demandElementTag.second) {
178 // decrease reference manually (because it was increased manually in GNERouteHandler)
179 demandElement.second->decRef();
180 delete demandElement.second;
181 }
182 }
183 // Drop dataSets (Only used for TAZElements that were inserted without using GNEChange_DataSets)
184 for (const auto& dataSet : myDataSets) {
185 // decrease reference manually (because it was increased manually in GNEDataHandler)
186 dataSet.second->decRef();
187 delete dataSet.second;
188 }
189 // Drop MeanDatas (Only used for meanDatas that were inserted without using GNEChange_MeanData)
190 for (const auto& meanDataTag : myMeanDatas) {
191 for (const auto& meanData : meanDataTag.second) {
192 // decrease reference manually (because it was increased manually in GNEMeanDataHandler)
193 meanData.second->decRef();
194 delete meanData.second;
195 }
196 }
197}
198
199
200void
202 std::map<std::string, GNEEdge*> newEdgeMap;
203 std::map<std::string, GNEJunction*> newJunctionMap;
204 // fill newEdgeMap
205 for (const auto& edge : myEdges) {
206 edge.second->setEdgeID(edge.second->getNBEdge()->getID());
207 newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
208 }
209 for (const auto& junction : myJunctions) {
210 newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
211 junction.second->setNetworkElementID(junction.second->getNBNode()->getID());
212 }
213 myEdges = newEdgeMap;
214 myJunctions = newJunctionMap;
215}
216
217
218bool
220 // check what type of AC
221 if (AC->getTagProperty()->getTag() == SUMO_TAG_JUNCTION) {
222 // Junction
223 const GNEJunction* junction = myJunctions.at(AC->getID());
224 if (junction->getNBNode()->getShape().size() == 0) {
225 return triangle.isPositionWithin(junction->getNBNode()->getCenter());
226 } else {
227 return (triangle.intersectWithShape(junction->getNBNode()->getShape()));
228 }
229 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_EDGE) {
230 // Edge
231 for (const auto& lane : myEdges.at(AC->getID())->getChildLanes()) {
232 if (triangle.intersectWithShape(lane->getLaneShape())) {
233 return true;
234 }
235 }
236 return false;
237 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_LANE) {
238 // Lane
239 return triangle.intersectWithShape(retrieveLane(AC->getID())->getLaneShape());
240 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_CONNECTION) {
241 // connection
242 return triangle.intersectWithShape(myConnections.at(AC->getGUIGlObject())->getConnectionShape());
243 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_CROSSING) {
244 // crossing
245 return triangle.intersectWithShape(myCrossings.at(AC->getGUIGlObject())->getCrossingShape());
246 } else if (AC->getTagProperty()->isAdditionalElement()) {
247 // Additional (including shapes and TAZs
248 const GNEAdditional* additional = retrieveAdditional(AC->getGUIGlObject());
249 if (additional->getAdditionalGeometry().getShape().size() <= 1) {
250 return triangle.isPositionWithin(additional->getPositionInView());
251 } else {
252 return triangle.intersectWithShape(additional->getAdditionalGeometry().getShape());
253 }
254 } else {
255 return false;
256 }
257}
258
259
260int
262 return myNumberOfNetworkElements;
263}
264
265
266int
268 return myNumberOfDemandElements;
269}
270
271
272int
274 return myNumberOfDataElements;
275}
276
277
280 // obtain blocked GUIGlObject
282 // Make sure that object exists
283 if (object != nullptr) {
284 // unblock and try to parse to AttributeCarrier
286 GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
287 // If was successfully parsed, return it
288 if (ac == nullptr) {
289 throw ProcessError("GUIGlObject does not match the declared type");
290 } else {
291 return ac;
292 }
293 } else if (hardFail) {
294 throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
295 } else {
296 return nullptr;
297 }
298}
299
300
301std::vector<GNEAttributeCarrier*>
303 std::vector<GNEAttributeCarrier*> ACs;
304 // first check if we have to return all ACs
305 if (tag == SUMO_TAG_NOTHING) {
306 const auto rootTagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(SUMO_TAG_ROOTFILE, true);
307 ACs.reserve(myNumberOfNetworkElements + myNumberOfDemandElements + myNumberOfDataElements);
308 retrieveAttributeCarriersRecursively(rootTagProperty, ACs);
309 } else {
310 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag, true);
311 // reserve space
312 if (tagProperty->getSupermode() == Supermode::NETWORK) {
313 ACs.reserve(myNumberOfNetworkElements);
314 } else if (tagProperty->getSupermode() == Supermode::DEMAND) {
315 ACs.reserve(myNumberOfDemandElements);
316 } else if (tagProperty->getSupermode() == Supermode::DATA) {
317 ACs.reserve(myNumberOfDataElements + myNumberOfMeanDataElements);
318 }
319 retrieveAttributeCarriersRecursively(tagProperty, ACs);
320 }
321 return ACs;
322}
323
324
325std::vector<GNEAttributeCarrier*>
327 std::vector<GNEAttributeCarrier*> result;
328 // continue depending of supermode
329 if (supermode == Supermode::NETWORK) {
330 // network
331 for (const auto& junction : myJunctions) {
332 if (!onlySelected || junction.second->isAttributeCarrierSelected()) {
333 result.push_back(junction.second);
334 }
335 }
336 for (const auto& crossing : myCrossings) {
337 if (!onlySelected || crossing.second->isAttributeCarrierSelected()) {
338 result.push_back(crossing.second);
339 }
340 }
341 for (const auto& edge : myEdges) {
342 if (!onlySelected || edge.second->isAttributeCarrierSelected()) {
343 result.push_back(edge.second);
344 }
345 }
346 for (const auto& lane : myLanes) {
347 if (!onlySelected || lane.second->isAttributeCarrierSelected()) {
348 result.push_back(lane.second);
349 }
350 }
351 for (const auto& connection : myConnections) {
352 if (!onlySelected || connection.second->isAttributeCarrierSelected()) {
353 result.push_back(connection.second);
354 }
355 }
356 for (const auto& additionalSet : myAdditionals) {
357 for (const auto& additional : additionalSet.second) {
358 if (!onlySelected || additional.second->isAttributeCarrierSelected()) {
359 result.push_back(additional.second);
360 }
361 }
362 }
363 } else if (supermode == Supermode::DEMAND) {
364 for (const auto& demandElementSet : myDemandElements) {
365 for (const auto& demandElement : demandElementSet.second) {
366 if (!onlySelected || demandElement.second->isAttributeCarrierSelected()) {
367 result.push_back(demandElement.second);
368 }
369 }
370 }
371 } else if (supermode == Supermode::DATA) {
372 for (const auto& dataSet : myDataSets) {
373 if (!onlySelected || dataSet.second->isAttributeCarrierSelected()) {
374 result.push_back(dataSet.second);
375 }
376 }
377 for (const auto& dataInterval : myDataIntervals) {
378 if (!onlySelected || dataInterval.second->isAttributeCarrierSelected()) {
379 result.push_back(dataInterval.second);
380 }
381 }
382 for (const auto& genericDataSet : myGenericDatas) {
383 for (const auto& genericData : genericDataSet.second) {
384 if (!onlySelected || genericData.second->isAttributeCarrierSelected()) {
385 result.push_back(genericData.second);
386 }
387 }
388 }
389 for (const auto& meanDataSet : myMeanDatas) {
390 for (const auto& meanData : meanDataSet.second) {
391 if (!onlySelected || meanData.second->isAttributeCarrierSelected()) {
392 result.push_back(meanData.second);
393 }
394 }
395 }
396 }
397 return result;
398}
399
400
401std::vector<GNEAttributeCarrier*>
403 // get modes
404 const auto& editModes = myNet->getViewNet()->getEditModes();
405 // declare vector to save result
406 std::vector<GNEAttributeCarrier*> result;
407 result.reserve(gSelected.getSelected().size());
408 // iterate over all elements of global selection
409 for (const auto& glID : gSelected.getSelected()) {
410 // obtain AC
411 GNEAttributeCarrier* AC = retrieveAttributeCarrier(glID, false);
412 // check if attribute carrier exist and is selected
413 if (AC && AC->isAttributeCarrierSelected()) {
414 if (ignoreCurrentSupermode) {
415 result.push_back(AC);
416 } else if (editModes.isCurrentSupermodeNetwork() && (AC->getTagProperty()->isNetworkElement() ||
418 result.push_back(AC);
419 } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty()->isDemandElement()) {
420 result.push_back(AC);
421 } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty()->isDataElement()) {
422 result.push_back(AC);
423 }
424 }
425 }
426 return result;
427}
428
429
431GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
432 auto it = myJunctions.find(id);
433 if (it != myJunctions.end()) {
434 return it->second;
435 }
436 if (hardFail) {
437 // If junction wasn't found, throw exception
438 throw UnknownElement("Attempted to retrieve non-existant junction " + id);
439 } else {
440 return nullptr;
441 }
442}
443
444
445const std::map<std::string, GNEJunction*>&
447 return myJunctions;
448}
449
450
451std::vector<GNEJunction*>
453 std::vector<GNEJunction*> result;
454 // returns junctions depending of selection
455 for (const auto& junction : myJunctions) {
456 if (junction.second->isAttributeCarrierSelected()) {
457 result.push_back(junction.second);
458 }
459 }
460 return result;
461}
462
463
466 // increase reference
467 junction->incRef("GNENet::registerJunction");
468 junction->setResponsible(false);
469 myJunctions[junction->getMicrosimID()] = junction;
470 myNumberOfNetworkElements++;
471 // expand net boundary
472 myNet->expandBoundary(junction->getCenteringBoundary());
473 // add edge into grid
474 myNet->addGLObjectIntoGrid(junction);
475 // update geometry
476 junction->updateGeometry();
477 // add z in net boundary
478 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
479 return junction;
480}
481
482
483void
485 myJunctions.clear();
486}
487
488
489void
491 // make a copy of junctions
492 auto junctionCopy = myJunctions;
493 // clear junctions
494 myJunctions.clear();
495 // fill junctions again
496 for (const auto& junction : junctionCopy) {
497 // update microsim ID
498 junction.second->setNetworkElementID(prefix + junction.first);
499 // insert in myJunctions again
500 myJunctions[prefix + junction.first] = junction.second;
501 }
502}
503
504
505void
507 if (myJunctions.count(junction->getID()) == 0) {
508 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
509 } else if (myJunctions.count(newID) != 0) {
510 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
511 } else {
512 // remove junction from container
513 myJunctions.erase(junction->getNBNode()->getID());
514 // rename in NetBuilder
515 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
516 // update microsim ID
517 junction->setNetworkElementID(newID);
518 // add it into myJunctions again
519 myJunctions[junction->getID()] = junction;
520 // build crossings
521 junction->getNBNode()->buildCrossings();
522 // net has to be saved
523 myNet->getSavingStatus()->requireSaveNetwork();
524 }
525}
526
527
528int
530 int counter = 0;
531 for (const auto& junction : myJunctions) {
532 if (junction.second->isAttributeCarrierSelected()) {
533 counter++;
534 }
535 }
536 return counter;
537}
538
539
542 auto it = myCrossings.find(glObject);
543 if (it != myCrossings.end()) {
544 return it->second;
545 }
546 if (hardFail) {
547 // If junction wasn't found, throw exception
548 throw UnknownElement("Attempted to retrieve non-existant crossing " + glObject->getMicrosimID());
549 } else {
550 return nullptr;
551 }
552}
553
554
555const std::unordered_map<const GUIGlObject*, GNECrossing*>&
557 return myCrossings;
558}
559
560
561std::vector<GNECrossing*>
563 std::vector<GNECrossing*> result;
564 // iterate over crossings
565 for (const auto& crossing : myCrossings) {
566 if (crossing.second->isAttributeCarrierSelected()) {
567 result.push_back(crossing.second);
568 }
569 }
570 return result;
571}
572
573
574int
576 int counter = 0;
577 for (const auto& crossing : myCrossings) {
578 if (crossing.second->isAttributeCarrierSelected()) {
579 counter++;
580 }
581 }
582 return counter;
583}
584
585
588 auto it = myWalkingAreas.find(glObject);
589 if (it != myWalkingAreas.end()) {
590 return it->second;
591 }
592 if (hardFail) {
593 // If junction wasn't found, throw exception
594 throw UnknownElement("Attempted to retrieve non-existant walkingArea " + glObject->getMicrosimID());
595 } else {
596 return nullptr;
597 }
598}
599
600
601const std::unordered_map<const GUIGlObject*, GNEWalkingArea*>&
603 return myWalkingAreas;
604}
605
606
607std::vector<GNEWalkingArea*>
609 std::vector<GNEWalkingArea*> result;
610 // iterate over walkingAreas
611 for (const auto& walkingArea : myWalkingAreas) {
612 if (walkingArea.second->isAttributeCarrierSelected()) {
613 result.push_back(walkingArea.second);
614 }
615 }
616 return result;
617}
618
619
620int
622 int counter = 0;
623 for (const auto& walkingArea : myWalkingAreas) {
624 if (walkingArea.second->isAttributeCarrierSelected()) {
625 counter++;
626 }
627 }
628 return counter;
629}
630
631
633GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
634 if (myEdgeTypes.count(id) > 0) {
635 return myEdgeTypes.at(id);
636 } else if (hardFail) {
637 // If edge wasn't found, throw exception
638 throw UnknownElement("Attempted to retrieve non-existant EdgeType " + id);
639 } else {
640 return nullptr;
641 }
642}
643
644
647 // increase reference
648 edgeType->incRef("GNENet::registerEdgeType");
649 // add it in container
650 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
651 return edgeType;
652}
653
654
655const std::map<std::string, GNEEdgeType*>&
657 return myEdgeTypes;
658}
659
660
662 myEdgeTypes.clear();
663}
664
665
666void
668 if (myEdgeTypes.count(edgeType->getID()) == 0) {
669 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
670 } else if (myEdgeTypes.count(newID) != 0) {
671 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
672 } else {
673 // remove edgeType from container
674 myEdgeTypes.erase(edgeType->getID());
675 // rename in typeCont
676 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
677 // update microsim ID
678 edgeType->setNetworkElementID(newID);
679 // add it into myEdgeTypes again
680 myEdgeTypes[edgeType->getID()] = edgeType;
681 // net has to be saved
682 myNet->getSavingStatus()->requireSaveNetwork();
683 }
684}
685
686
687std::string
689 int counter = 0;
690 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
691 counter++;
692 }
693 return ("edgeType_" + toString(counter));
694}
695
696
697GNEEdge*
698GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
699 auto it = myEdges.find(id);
700 if (it != myEdges.end()) {
701 return it->second;
702 }
703 if (hardFail) {
704 // If edge wasn't found, throw exception
705 throw UnknownElement("Attempted to retrieve non-existant edge " + id);
706 } else {
707 return nullptr;
708 }
709}
710
711
712std::vector<GNEEdge*>
714 if ((from == nullptr) || (to == nullptr)) {
715 throw UnknownElement("Junctions cannot be nullptr");
716 }
717 std::vector<GNEEdge*> edges;
718 // iterate over outgoing edges of from edge and check to junction
719 for (const auto& edgeTo : from->getGNEOutgoingEdges()) {
720 if (edgeTo->getToJunction() == to) {
721 edges.push_back(edgeTo);
722 }
723 }
724 return edges;
725}
726
727
728const std::map<std::string, GNEEdge*>&
730 return myEdges;
731}
732
733
734std::vector<GNEEdge*>
736 std::vector<GNEEdge*> result;
737 // returns edges depending of selection
738 for (const auto& edge : myEdges) {
739 if (edge.second->isAttributeCarrierSelected()) {
740 result.push_back(edge.second);
741 }
742 }
743 return result;
744}
745
746
747GNEEdge*
749 edge->incRef("GNENet::registerEdge");
750 edge->setResponsible(false);
751 // add edge to internal container of GNENet
752 myEdges[edge->getMicrosimID()] = edge;
753 myNumberOfNetworkElements++;
754 // insert all lanes
755 for (const auto& lane : edge->getChildLanes()) {
756 insertLane(lane);
757 }
758 // Add references into GNEJunctions
759 edge->getFromJunction()->addOutgoingGNEEdge(edge);
760 edge->getToJunction()->addIncomingGNEEdge(edge);
761 // update boundaries of both junctions (to remove it from Grid)
764 // update edge boundary
765 edge->updateCenteringBoundary(false);
766 // expand edge boundary
767 myNet->expandBoundary(edge->getCenteringBoundary());
768 // finally add edge into grid
769 myNet->addGLObjectIntoGrid(edge);
770 return edge;
771}
772
773
774void
778
779
780void
782 // make a copy of edges
783 auto edgeCopy = myEdges;
784 // clear edges
785 myEdges.clear();
786 // fill edges again
787 for (const auto& edge : edgeCopy) {
788 // update microsim ID
789 edge.second->setNetworkElementID(prefix + edge.first);
790 // insert in myEdges again
791 myEdges[prefix + edge.first] = edge.second;
792 }
793}
794
795
796std::string
798 // get edge prefix
799 const std::string edgePrefix = OptionsCont::getOptions().getString("prefix") + OptionsCont::getOptions().getString("edge-prefix");
800 // generate new ID
801 while (myEdges.count(edgePrefix + toString(myNet->getEdgeIDCounter())) != 0) {
802 myNet->getEdgeIDCounter()++;
803 }
804 return edgePrefix + toString(myNet->getEdgeIDCounter());
805}
806
807
808void
810 if (myEdges.count(edge->getID()) == 0) {
811 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
812 } else if (myEdges.count(newID) != 0) {
813 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
814 } else {
815 // remove edge from container
816 myEdges.erase(edge->getNBEdge()->getID());
817 // rename in NetBuilder
818 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
819 // update microsim ID
820 edge->setEdgeID(newID);
821 // add it into myEdges again
822 myEdges[edge->getID()] = edge;
823 // rename all connections related to this edge
824 for (const auto& lane : edge->getChildLanes()) {
825 lane->updateConnectionIDs();
826 }
827 // net has to be saved
828 myNet->getSavingStatus()->requireSaveNetwork();
829 }
830}
831
832
833int
835 int counter = 0;
836 for (const auto& edge : myEdges) {
837 if (edge.second->isAttributeCarrierSelected()) {
838 counter++;
839 }
840 }
841 return counter;
842}
843
844
845GNELane*
846GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
847 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
848 const GNEEdge* edge = retrieveEdge(edge_id, false);
849 if (edge != nullptr) {
850 GNELane* lane = nullptr;
851 // search lane in lane's edges
852 for (auto laneIt : edge->getChildLanes()) {
853 if (laneIt->getID() == id) {
854 lane = laneIt;
855 }
856 }
857 // throw exception or return nullptr if lane wasn't found
858 if (lane == nullptr) {
859 if (hardFail) {
860 // Throw exception if hardFail is enabled
861 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
862 }
863 } else {
864 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
865 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
866 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getChildLanes().size()) {
867 return edge->getChildLanes().at(lane->getIndex() + 1);
868 }
869 return lane;
870 }
871 } else if (hardFail) {
872 // Throw exception if hardFail is enabled
873 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
874 }
875 return nullptr;
876}
877
878
879GNELane*
880GNENetHelper::AttributeCarriers::retrieveLane(const GUIGlObject* glObject, bool hardFail) const {
881 auto it = myLanes.find(glObject);
882 if (it != myLanes.end()) {
883 return it->second;
884 }
885 if (hardFail) {
886 // If junction wasn't found, throw exception
887 throw UnknownElement("Attempted to retrieve non-existant lane " + glObject->getMicrosimID());
888 } else {
889 return nullptr;
890 }
891}
892
893
894const std::unordered_map<const GUIGlObject*, GNELane*>&
896 return myLanes;
897}
898
899
900std::vector<GNELane*>
902 std::vector<GNELane*> result;
903 // returns lanes depending of selection
904 for (const auto& lane : myLanes) {
905 if (lane.second->isAttributeCarrierSelected()) {
906 result.push_back(lane.second);
907 }
908 }
909 return result;
910}
911
912
913int
915 int counter = 0;
916 for (const auto& lane : myLanes) {
917 if (lane.second->isAttributeCarrierSelected()) {
918 counter++;
919 }
920 }
921 return counter;
922}
923
924
926GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
927 // iterate over connections
928 for (const auto& connection : myConnections) {
929 if (connection.second->getID() == id) {
930 return connection.second;
931 }
932 }
933 if (hardFail) {
934 // If POI wasn't found, throw exception
935 throw UnknownElement("Attempted to retrieve non-existant connection " + id);
936 } else {
937 return nullptr;
938 }
939}
940
941
944 auto it = myConnections.find(glObject);
945 if (it != myConnections.end()) {
946 return it->second;
947 }
948 if (hardFail) {
949 // If POI wasn't found, throw exception
950 throw UnknownElement("Attempted to retrieve non-existant connection " + glObject->getMicrosimID());
951 } else {
952 return nullptr;
953 }
954}
955
956
957const std::unordered_map<const GUIGlObject*, GNEConnection*>&
959 return myConnections;
960}
961
962
963std::vector<GNEConnection*>
965 std::vector<GNEConnection*> result;
966 // returns connections depending of selection
967 for (const auto& connection : myConnections) {
968 if (connection.second->isAttributeCarrierSelected()) {
969 result.push_back(connection.second);
970 }
971 }
972 return result;
973}
974
975
976int
978 int counter = 0;
979 for (const auto& connection : myConnections) {
980 if (connection.second->isAttributeCarrierSelected()) {
981 counter++;
982 }
983 }
984 return counter;
985}
986
987
990 auto it = myInternalLanes.find(glObject);
991 if (it != myInternalLanes.end()) {
992 return it->second;
993 }
994 if (hardFail) {
995 // If POI wasn't found, throw exception
996 throw UnknownElement("Attempted to retrieve non-existant internalLane " + glObject->getMicrosimID());
997 } else {
998 return nullptr;
999 }
1000}
1001
1002
1004GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
1005 auto it = myAdditionalIDs.at(type).find(id);
1006 if (it != myAdditionalIDs.at(type).end()) {
1007 return it->second;
1008 }
1009 if (hardFail) {
1010 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1011 } else {
1012 return nullptr;
1013 }
1014}
1015
1016
1018GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1019 for (const auto& type : types) {
1020 auto it = myAdditionalIDs.at(type).find(id);
1021 if (it != myAdditionalIDs.at(type).end()) {
1022 return it->second;
1023 }
1024 }
1025 if (hardFail) {
1026 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1027 } else {
1028 return nullptr;
1029 }
1030}
1031
1032
1035 // iterate over all additionals
1036 for (const auto& additionalTag : myAdditionals) {
1037 auto it = additionalTag.second.find(glObject);
1038 if (it != additionalTag.second.end()) {
1039 return it->second;
1040 }
1041 }
1042 if (hardFail) {
1043 throw ProcessError("Attempted to retrieve non-existant additional (glObject)");
1044 } else {
1045 return nullptr;
1046 }
1047}
1048
1049
1051GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
1052 // first retrieve rerouter
1053 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
1054 // parse begin and end
1055 const std::string beginStr = time2string(begin);
1056 const std::string endStr = time2string(end);
1057 // now iterate over all children and check begin and end
1058 for (const auto& interval : rerouter->getChildAdditionals()) {
1059 // check tag (to avoid symbols)
1060 if (interval->getTagProperty()->getTag() == SUMO_TAG_INTERVAL) {
1061 // check begin and end
1062 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
1063 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
1064 return interval;
1065 }
1066 }
1067 }
1068 // throw exception
1069 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
1070}
1071
1072
1073const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*>, std::hash<int> >&
1075 return myAdditionals;
1076}
1077
1078
1079std::vector<GNEAdditional*>
1081 std::vector<GNEAdditional*> result;
1082 // returns additionals depending of selection
1083 for (const auto& additionalsTags : myAdditionals) {
1084 for (const auto& additional : additionalsTags.second) {
1085 if (additional.second->isAttributeCarrierSelected()) {
1086 result.push_back(additional.second);
1087 }
1088 }
1089 }
1090 return result;
1091}
1092
1093
1094std::vector<GNEAdditional*>
1096 std::vector<GNEAdditional*> result;
1097 // returns additionals depending of selection
1098 for (const auto& additionalsTags : myAdditionals) {
1099 for (const auto& additional : additionalsTags.second) {
1100 if (additional.second->getTagProperty()->isShapeElement() && additional.second->isAttributeCarrierSelected()) {
1101 result.push_back(additional.second);
1102 }
1103 }
1104 }
1105 return result;
1106}
1107
1108
1109int
1111 int counter = 0;
1112 for (const auto& additionalsTag : myAdditionals) {
1113 counter += (int)additionalsTag.second.size();
1114 }
1115 return counter;
1116}
1117
1118
1119void
1121 // clear elements in grid
1122 for (const auto& additionalsTags : myAdditionals) {
1123 for (const auto& additional : additionalsTags.second) {
1124 myNet->removeGLObjectFromGrid(additional.second);
1125 }
1126 }
1127 // iterate over myAdditionals and clear all additionals
1128 for (auto& additionals : myAdditionals) {
1129 additionals.second.clear();
1130 }
1131 for (auto& additionals : myAdditionalIDs) {
1132 additionals.second.clear();
1133 }
1134}
1135
1136
1137void
1139 const auto tag = additional->getTagProperty()->getTag();
1140 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1141 if (it == myAdditionalIDs.at(tag).end()) {
1142 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1143 } else {
1144 // remove from container, set new Id, and insert it again
1145 myAdditionalIDs.at(tag).erase(it);
1146 // set microsim ID
1147 additional->setMicrosimID(newID);
1148 myAdditionalIDs.at(tag)[newID] = additional;
1149 }
1150}
1151
1152
1153std::string
1155 // obtain option container
1156 const auto& neteditOptions = OptionsCont::getOptions();
1157 // get prefix
1158 std::string prefix;
1159 if (tag == SUMO_TAG_BUS_STOP) {
1160 prefix = neteditOptions.getString("busStop-prefix");
1161 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1162 prefix = neteditOptions.getString("trainStop-prefix");
1163 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1164 prefix = neteditOptions.getString("containerStop-prefix");
1165 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1166 prefix = neteditOptions.getString("chargingStation-prefix");
1167 } else if (tag == SUMO_TAG_PARKING_AREA) {
1168 prefix = neteditOptions.getString("parkingArea-prefix");
1169 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1170 prefix = neteditOptions.getString("e1Detector-prefix");
1171 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1172 prefix = neteditOptions.getString("e2Detector-prefix");
1173 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1174 prefix = neteditOptions.getString("e3Detector-prefix");
1175 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1176 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1177 } else if (tag == SUMO_TAG_REROUTER) {
1178 prefix = neteditOptions.getString("rerouter-prefix");
1179 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1180 prefix = neteditOptions.getString("calibrator-prefix");
1181 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1182 prefix = neteditOptions.getString("routeProbe-prefix");
1183 } else if (tag == SUMO_TAG_VSS) {
1184 prefix = neteditOptions.getString("vss-prefix");
1185 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1186 prefix = neteditOptions.getString("tractionSubstation-prefix");
1187 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1188 prefix = neteditOptions.getString("overheadWire-prefix");
1189 } else if (tag == SUMO_TAG_POLY) {
1190 prefix = neteditOptions.getString("polygon-prefix");
1191 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1192 prefix = neteditOptions.getString("poi-prefix");
1193 } else if (tag == SUMO_TAG_TAZ) {
1194 prefix = toString(SUMO_TAG_TAZ);
1195 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1196 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1197 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1198 prefix = neteditOptions.getString("jps.obstacle-prefix");
1199 }
1200 int counter = 0;
1201 // check namespaces
1202 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1203 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1204 counter++;
1205 }
1206 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1207 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1208 counter++;
1209 }
1210 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1211 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1212 counter++;
1213 }
1214 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1215 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1216 counter++;
1217 }
1218 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1219 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1220 counter++;
1221 }
1222 } else {
1223 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1224 counter++;
1225 }
1226 }
1227 // return new element ID
1228 return (prefix + "_" + toString(counter));
1229}
1230
1231
1232int
1234 int counter = 0;
1235 for (const auto& additionalsTags : myAdditionals) {
1236 for (const auto& additional : additionalsTags.second) {
1237 if (additional.second->isAttributeCarrierSelected()) {
1238 counter++;
1239 }
1240 }
1241 }
1242 return counter;
1243}
1244
1245
1246int
1248 return getNumberOfSelectedAdditionals() -
1249 // shapes
1250 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1251 // JuPedSims
1252 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1253 // TAZ
1254 getNumberOfSelectedTAZs() -
1255 // wires
1256 getNumberOfSelectedWires();
1257}
1258
1259
1260int
1262 int counter = 0;
1263 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1264 if (poly.second->isAttributeCarrierSelected()) {
1265 counter++;
1266 }
1267 }
1268 return counter;
1269}
1270
1271
1272int
1274 int counter = 0;
1275 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1276 if (walkableArea.second->isAttributeCarrierSelected()) {
1277 counter++;
1278 }
1279 }
1280 return counter;
1281}
1282
1283
1284int
1286 int counter = 0;
1287 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1288 if (obstacle.second->isAttributeCarrierSelected()) {
1289 counter++;
1290 }
1291 }
1292 return counter;
1293}
1294
1295
1296int
1298 int counter = 0;
1299 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1300 if (POI.second->isAttributeCarrierSelected()) {
1301 counter++;
1302 }
1303 }
1304 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1305 if (POILane.second->isAttributeCarrierSelected()) {
1306 counter++;
1307 }
1308 }
1309 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1310 if (POIGEO.second->isAttributeCarrierSelected()) {
1311 counter++;
1312 }
1313 }
1314 return counter;
1315}
1316
1317
1318std::vector<std::string>
1320 std::set<std::string> keys;
1321 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1322 for (const auto& parameter : POI.second->getParameters()->getParametersMap()) {
1323 keys.insert(parameter.first);
1324 }
1325 }
1326 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1327 for (const auto& parameter : POILane.second->getParameters()->getParametersMap()) {
1328 keys.insert(parameter.first);
1329 }
1330 }
1331 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1332 for (const auto& parameter : POIGEO.second->getParameters()->getParametersMap()) {
1333 keys.insert(parameter.first);
1334 }
1335 }
1336 return std::vector<std::string>(keys.begin(), keys.end());
1337}
1338
1339
1340int
1342 int counter = 0;
1343 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1344 if (TAZ.second->isAttributeCarrierSelected()) {
1345 counter++;
1346 }
1347 }
1348 return counter;
1349}
1350
1351
1352int
1354 int counter = 0;
1355 for (const auto& additionalsTags : myAdditionals) {
1356 for (const auto& additional : additionalsTags.second) {
1357 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty()->isWireElement()) {
1358 counter++;
1359 }
1360 }
1361 }
1362 return counter;
1363}
1364
1365
1368 // iterate over all demand elements
1369 for (const auto& TAZSourceSinkTag : myTAZSourceSinks) {
1370 auto it = TAZSourceSinkTag.second.find(sourceSink);
1371 if (it != TAZSourceSinkTag.second.end()) {
1372 return it->second;
1373 }
1374 }
1375 if (hardFail) {
1376 throw ProcessError("Attempted to retrieve non-existant sourceSink (glObject)");
1377 } else {
1378 return nullptr;
1379 }
1380}
1381
1382
1383const std::unordered_map<SumoXMLTag, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>, std::hash<int> >&
1385 return myTAZSourceSinks;
1386}
1387
1388
1389int
1391 int counter = 0;
1392 for (const auto& sourceSinksTag : myTAZSourceSinks) {
1393 counter += (int)sourceSinksTag.second.size();
1394 }
1395 return counter;
1396}
1397
1398
1399void
1401 // iterate over myTAZSourceSinks and clear all sourceSinks
1402 for (auto& sourceSinksTags : myTAZSourceSinks) {
1403 sourceSinksTags.second.clear();
1404 }
1405}
1406
1407
1409GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1410 auto it = myDemandElementIDs.at(type).find(id);
1411 if (it != myDemandElementIDs.at(type).end()) {
1412 return it->second;
1413 }
1414 if (hardFail) {
1415 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1416 } else {
1417 return nullptr;
1418 }
1419}
1420
1421
1423GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1424 for (const auto& type : types) {
1425 auto it = myDemandElementIDs.at(type).find(id);
1426 if (it != myDemandElementIDs.at(type).end()) {
1427 return it->second;
1428 }
1429 }
1430 if (hardFail) {
1431 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1432 } else {
1433 return nullptr;
1434 }
1435}
1436
1437
1440 // iterate over all demand elements
1441 for (const auto& demandElementTag : myDemandElements) {
1442 auto it = demandElementTag.second.find(glObject);
1443 if (it != demandElementTag.second.end()) {
1444 return it->second;
1445 }
1446 }
1447 if (hardFail) {
1448 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1449 } else {
1450 return nullptr;
1451 }
1452}
1453
1454
1455std::vector<GNEDemandElement*>
1457 std::vector<GNEDemandElement*> result;
1458 // returns demand elements depending of selection
1459 for (const auto& demandElementTag : myDemandElements) {
1460 for (const auto& demandElement : demandElementTag.second) {
1461 if (demandElement.second->isAttributeCarrierSelected()) {
1462 result.push_back(demandElement.second);
1463 }
1464 }
1465 }
1466 return result;
1467}
1468
1469
1470const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*>, std::hash<int> >&
1472 return myDemandElements;
1473}
1474
1475
1476std::string
1478 // obtain option container
1479 const auto& neteditOptions = OptionsCont::getOptions();
1480 // get tag property
1481 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag, true);
1482 // get prefix
1483 std::string prefix;
1484 if (tag == SUMO_TAG_ROUTE) {
1485 prefix = neteditOptions.getString("route-prefix");
1486 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1487 prefix = neteditOptions.getString("routeDistribution-prefix");
1488 } else if (tag == SUMO_TAG_VTYPE) {
1489 prefix = neteditOptions.getString("vType-prefix");
1490 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1491 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1492 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1493 prefix = neteditOptions.getString("trip-prefix");
1494 } else if (tagProperty->isVehicle() && !tagProperty->isFlow()) {
1495 prefix = neteditOptions.getString("vehicle-prefix");
1496 } else if (tagProperty->isPerson()) {
1497 if (tagProperty->isFlow()) {
1498 prefix = neteditOptions.getString("personflow-prefix");
1499 } else {
1500 prefix = neteditOptions.getString("person-prefix");
1501 }
1502 } else if (tagProperty->isContainer()) {
1503 if (tagProperty->isFlow()) {
1504 prefix = neteditOptions.getString("containerflow-prefix");
1505 } else {
1506 prefix = neteditOptions.getString("container-prefix");
1507 }
1508 } else if (tagProperty->isFlow()) {
1509 prefix = neteditOptions.getString("flow-prefix");
1510 }
1511 // declare counter
1512 int counter = 0;
1513 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1514 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1515 counter++;
1516 }
1517 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1518 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1519 counter++;
1520 }
1521 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1522 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1523 counter++;
1524 }
1525 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1526 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1527 counter++;
1528 }
1529 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1530 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1531 counter++;
1532 }
1533 } else {
1534 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1535 counter++;
1536 }
1537 }
1538 // return new element ID
1539 return (prefix + "_" + toString(counter));
1540
1541}
1542
1543
1546 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1547 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1548 return it->second;
1549 }
1550 throw ProcessError(TL("Default vType doesn't exist"));
1551}
1552
1553
1554void
1556 // clear elements in grid
1557 for (const auto& demandElementsTags : myDemandElements) {
1558 for (const auto& demandElement : demandElementsTags.second) {
1559 myNet->removeGLObjectFromGrid(demandElement.second);
1560 }
1561 }
1562 // iterate over myDemandElements and clear all demand elements
1563 for (auto& demandElements : myDemandElements) {
1564 demandElements.second.clear();
1565 }
1566 for (auto& demandElements : myDemandElementIDs) {
1567 demandElements.second.clear();
1568 }
1569}
1570
1571
1572void
1574 const auto tag = demandElement->getTagProperty()->getTag();
1575 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1576 if (it == myDemandElementIDs.at(tag).end()) {
1577 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1578 } else {
1579 // remove from container, set new Id, and insert it again
1580 myDemandElementIDs.at(tag).erase(it);
1581 // set microsim ID
1582 demandElement->setMicrosimID(newID);
1583 myDemandElementIDs.at(tag)[newID] = demandElement;
1584 }
1585}
1586
1587
1588void
1590 // get default bucket
1591 auto bucket = myNet->getGNEApplicationWindow()->getFileBucketHandler()->getDefaultBucket(FileBucket::Type::DEMAND);
1592 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1593 GNEVType* defaultVehicleType = new GNEVType(DEFAULT_VTYPE_ID, myNet, bucket, SVC_PASSENGER);
1594 myDemandElements.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1595 myDemandElementIDs.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1596 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1597 bucket->addDefaultVType();
1598
1599 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1600 GNEVType* defaultBikeType = new GNEVType(DEFAULT_BIKETYPE_ID, myNet, bucket, SVC_BICYCLE);
1601 myDemandElements.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1602 myDemandElementIDs.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1603 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1604 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1605 bucket->addDefaultVType();
1606
1607 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1608 GNEVType* defaultTaxiType = new GNEVType(DEFAULT_TAXITYPE_ID, myNet, bucket, SVC_TAXI);
1609 myDemandElements.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1610 myDemandElementIDs.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1611 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1612 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1613 bucket->addDefaultVType();
1614
1615 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1616 GNEVType* defaultRailType = new GNEVType(DEFAULT_RAILTYPE_ID, myNet, bucket, SVC_RAIL);
1617 myDemandElements.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1618 myDemandElementIDs.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1619 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1620 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1621 bucket->addDefaultVType();
1622
1623 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1624 GNEVType* defaultPersonType = new GNEVType(DEFAULT_PEDTYPE_ID, myNet, bucket, SVC_PEDESTRIAN);
1625 myDemandElements.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1626 myDemandElementIDs.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1627 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1628 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1629 bucket->addDefaultVType();
1630
1631 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1632 GNEVType* defaultContainerType = new GNEVType(DEFAULT_CONTAINERTYPE_ID, myNet, bucket, SVC_IGNORING);
1633 myDemandElements.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1634 myDemandElementIDs.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1635 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1636 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1637 bucket->addDefaultVType();
1638}
1639
1640
1641bool
1643 if (myDemandElements.at(GNE_TAG_TRIP_JUNCTIONS).size() > 0) {
1644 return true;
1645 } else if (myDemandElements.at(GNE_TAG_FLOW_JUNCTIONS).size() > 0) {
1646 return true;
1647 } else {
1648 // iterate over all tags and check if start or ends in junctions
1649 for (const auto& mapValue : myDemandElements) {
1650 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(mapValue.first, true);
1651 if ((tagProperty->planFromJunction() || tagProperty->planToJunction()) && (myDemandElements.at(tagProperty->getTag()).size() > 0)) {
1652 return true;
1653 }
1654 }
1655 }
1656 return false;
1657}
1658
1659
1660int
1662 return myStopIndex++;
1663}
1664
1665
1666int
1668 int counter = 0;
1669 for (const auto& demandElementsTags : myDemandElements) {
1670 for (const auto& demandElement : demandElementsTags.second) {
1671 if (demandElement.second->isAttributeCarrierSelected()) {
1672 counter++;
1673 }
1674 }
1675 }
1676 return counter;
1677}
1678
1679
1680int
1682 int counter = 0;
1683 // iterate over routes
1684 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1685 if (route.second->isAttributeCarrierSelected()) {
1686 counter++;
1687 }
1688 }
1689 // iterate over vehicles with embedded routes
1690 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1691 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1692 counter++;
1693 }
1694 }
1695 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1696 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1697 counter++;
1698 }
1699 }
1700 return counter;
1701}
1702
1703
1704int
1706 int counter = 0;
1707 // iterate over all vehicles and flows
1708 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1709 if (vehicle.second->isAttributeCarrierSelected()) {
1710 counter++;
1711 }
1712 }
1713 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1714 if (trip.second->isAttributeCarrierSelected()) {
1715 counter++;
1716 }
1717 }
1718 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1719 if (vehicle.second->isAttributeCarrierSelected()) {
1720 counter++;
1721 }
1722 }
1723 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1724 if (flow.second->isAttributeCarrierSelected()) {
1725 counter++;
1726 }
1727 }
1728 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1729 if (flow.second->isAttributeCarrierSelected()) {
1730 counter++;
1731 }
1732 }
1733 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1734 if (flow.second->isAttributeCarrierSelected()) {
1735 counter++;
1736 }
1737 }
1738 return counter;
1739}
1740
1741
1742int
1744 int counter = 0;
1745 // iterate over all persons
1746 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1747 if (person.second->isAttributeCarrierSelected()) {
1748 counter++;
1749 }
1750 }
1751 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1752 if (personFlow.second->isAttributeCarrierSelected()) {
1753 counter++;
1754 }
1755 }
1756 return counter;
1757}
1758
1759
1760int
1762 int counter = 0;
1763 // iterate over all person plans
1764 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1765 for (const auto& personPlan : person.second->getChildDemandElements()) {
1766 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1767 counter++;
1768 }
1769 }
1770 }
1771 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1772 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1773 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1774 counter++;
1775 }
1776 }
1777 }
1778 return counter;
1779}
1780
1781
1782int
1784 int counter = 0;
1785 // iterate over all person plans
1786 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1787 for (const auto& personPlan : person.second->getChildDemandElements()) {
1788 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1789 counter++;
1790 }
1791 }
1792 }
1793 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1794 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1795 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1796 counter++;
1797 }
1798 }
1799 }
1800 return counter;
1801}
1802
1803
1804int
1806 int counter = 0;
1807 // iterate over all person plans
1808 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1809 for (const auto& personPlan : person.second->getChildDemandElements()) {
1810 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1811 counter++;
1812 }
1813 }
1814 }
1815 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1816 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1817 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1818 counter++;
1819 }
1820 }
1821 }
1822 return counter;
1823}
1824
1825
1826int
1828 int counter = 0;
1829 // iterate over all containers
1830 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1831 if (container.second->isAttributeCarrierSelected()) {
1832 counter++;
1833 }
1834 }
1835 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1836 if (containerFlow.second->isAttributeCarrierSelected()) {
1837 counter++;
1838 }
1839 }
1840 return counter;
1841}
1842
1843
1844int
1846 int counter = 0;
1847 // iterate over all container plans
1848 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1849 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1850 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1851 counter++;
1852 }
1853 }
1854 }
1855 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1856 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1857 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1858 counter++;
1859 }
1860 }
1861 }
1862 return counter;
1863}
1864
1865
1866int
1868 int counter = 0;
1869 // iterate over all container plans
1870 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1871 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1872 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1873 counter++;
1874 }
1875 }
1876 }
1877 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1878 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1879 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1880 counter++;
1881 }
1882 }
1883 }
1884 return counter;
1885}
1886
1887
1888int
1890 int counter = 0;
1891 // iterate over routes
1892 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1893 if (route.second->isAttributeCarrierSelected()) {
1894 counter++;
1895 }
1896 }
1897 // vehicles
1898 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1899 for (const auto& stop : trip.second->getChildDemandElements()) {
1900 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1901 counter++;
1902 }
1903 }
1904 }
1905 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1906 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1907 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1908 counter++;
1909 }
1910 }
1911 }
1912 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1913 for (const auto& stop : flow.second->getChildDemandElements()) {
1914 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1915 counter++;
1916 }
1917 }
1918 }
1919 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1920 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1921 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1922 counter++;
1923 }
1924 }
1925 }
1926 // persons
1927 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1928 for (const auto& personPlan : person.second->getChildDemandElements()) {
1929 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1930 counter++;
1931 }
1932 }
1933 }
1934 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1935 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1936 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1937 counter++;
1938 }
1939 }
1940 }
1941 // containers
1942 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1943 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1944 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1945 counter++;
1946 }
1947 }
1948 }
1949 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1950 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1951 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1952 counter++;
1953 }
1954 }
1955 }
1956 return counter;
1957}
1958
1959
1961GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1962 for (const auto& dataSet : myDataSets) {
1963 if (dataSet.second->getID() == id) {
1964 return dataSet.second;
1965 }
1966 }
1967 if (hardFail) {
1968 throw ProcessError("Attempted to retrieve non-existant data set");
1969 } else {
1970 return nullptr;
1971 }
1972}
1973
1974
1975const std::map<const std::string, GNEDataSet*>&
1977 return myDataSets;
1978}
1979
1980
1981std::string
1983 // get prefix
1984 const auto prefix = OptionsCont::getOptions().getString("dataSet-prefix");
1985 int counter = 0;
1986 while (retrieveDataSet(prefix + "_" + toString(counter), false) != nullptr) {
1987 counter++;
1988 }
1989 return (prefix + "_" + toString(counter));
1990}
1991
1992
1995 if (myDataIntervals.count(AC)) {
1996 return myDataIntervals.at(AC);
1997 } else if (hardFail) {
1998 throw ProcessError("Attempted to retrieve non-existant data interval");
1999 } else {
2000 return nullptr;
2001 }
2002}
2003
2004
2005const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
2007 return myDataIntervals;
2008}
2009
2010
2011void
2013 if (myDataIntervals.count(AC) > 0) {
2014 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
2015 } else {
2016 myDataIntervals[AC] = dataInterval;
2017 }
2018 // mark interval toolbar for update
2019 myNet->getViewNet()->getIntervalBar().markForUpdate();
2020}
2021
2022
2023void
2025 const auto finder = myDataIntervals.find(dataInterval);
2026 if (finder == myDataIntervals.end()) {
2027 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
2028 } else {
2029 myDataIntervals.erase(finder);
2030 }
2031 // remove it from inspected elements and GNEElementTree
2032 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
2033 dataInterval->unmarkForDrawingFront();
2034 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
2035 // mark interval toolbar for update
2036 myNet->getViewNet()->getIntervalBar().markForUpdate();
2037}
2038
2039
2042 // iterate over all genericDatas
2043 for (const auto& genericDataTag : myGenericDatas) {
2044 auto it = genericDataTag.second.find(glObject);
2045 if (it != genericDataTag.second.end()) {
2046 return it->second;
2047 }
2048 }
2049 if (hardFail) {
2050 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
2051 } else {
2052 return nullptr;
2053 }
2054}
2055
2056
2057std::vector<GNEGenericData*>
2059 std::vector<GNEGenericData*> result;
2060 // returns generic datas depending of selection
2061 for (const auto& genericDataTag : myGenericDatas) {
2062 for (const auto& genericData : genericDataTag.second) {
2063 if (genericData.second->isAttributeCarrierSelected()) {
2064 result.push_back(genericData.second);
2065 }
2066 }
2067 }
2068 return result;
2069}
2070
2071
2072const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> >&
2074 return myGenericDatas;
2075}
2076
2077
2078std::vector<GNEGenericData*>
2079GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2080 // declare generic data vector
2081 std::vector<GNEGenericData*> genericDatas;
2082 // iterate over all data sets
2083 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2084 // check interval
2085 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2086 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2087 genericDatas.push_back(genericData.second);
2088 }
2089 }
2090 return genericDatas;
2091}
2092
2093
2094int
2096 int counter = 0;
2097 // iterate over all generic datas
2098 for (const auto& genericDataTag : myGenericDatas) {
2099 counter += (int)genericDataTag.second.size();
2100 }
2101 return counter;
2102}
2103
2104
2105int
2107 int counter = 0;
2108 // iterate over all edgeDatas
2109 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2110 if (genericData.second->isAttributeCarrierSelected()) {
2111 counter++;
2112 }
2113 }
2114 return counter;
2115}
2116
2117
2118int
2120 int counter = 0;
2121 // iterate over all edgeDatas
2122 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2123 if (genericData.second->isAttributeCarrierSelected()) {
2124 counter++;
2125 }
2126 }
2127 return counter;
2128}
2129
2130
2131int
2133 int counter = 0;
2134 // iterate over all edgeDatas
2135 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2136 if (genericData.second->isAttributeCarrierSelected()) {
2137 counter++;
2138 }
2139 }
2140 return counter;
2141}
2142
2143
2144void
2146 if (myGenericDatas.at(genericData->getTagProperty()->getTag()).count(genericData->getGUIGlObject()) > 0) {
2147 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2148 } else {
2149 myGenericDatas.at(genericData->getTagProperty()->getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2150 }
2151 // mark interval toolbar for update
2152 myNet->getViewNet()->getIntervalBar().markForUpdate();
2153}
2154
2155
2156void
2158 const auto finder = myGenericDatas.at(genericData->getTagProperty()->getTag()).find(genericData);
2159 if (finder == myGenericDatas.at(genericData->getTagProperty()->getTag()).end()) {
2160 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2161 } else {
2162 myGenericDatas.at(genericData->getTagProperty()->getTag()).erase(finder);
2163 }
2164 // remove it from inspected elements and GNEElementTree
2165 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2166 genericData->unmarkForDrawingFront();
2167 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2168 // delete path element
2169 myNet->getDataPathManager()->removePath(genericData);
2170 // mark interval toolbar for update
2171 myNet->getViewNet()->getIntervalBar().markForUpdate();
2172}
2173
2174
2175std::set<std::string>
2176GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2177 // declare solution
2178 std::set<std::string> attributesSolution;
2179 // declare generic data vector
2180 std::vector<GNEGenericData*> genericDatas;
2181 // iterate over all data sets
2182 for (const auto& interval : myDataIntervals) {
2183 // check interval
2184 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2185 // iterate over generic datas
2186 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2187 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2188 genericDatas.push_back(genericData);
2189 }
2190 }
2191 }
2192 }
2193 // iterate over generic datas
2194 for (const auto& genericData : genericDatas) {
2195 for (const auto& attribute : genericData->getParametersMap()) {
2196 attributesSolution.insert(attribute.first);
2197 }
2198 }
2199 return attributesSolution;
2200}
2201
2202
2203std::set<std::string>
2204GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2205 const std::string& beginStr, const std::string& endStr) const {
2206 // declare solution
2207 std::set<std::string> attributesSolution;
2208 // vector of data sets and intervals
2209 std::vector<GNEDataSet*> dataSets;
2210 std::vector<GNEDataInterval*> dataIntervals;
2211 // get dataSet
2212 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2213 // if dataSetID is empty, return all parameters
2214 if (dataSetID.empty()) {
2215 // add all data sets
2216 dataSets.reserve(myDataSets.size());
2217 for (const auto& dataSet : myDataSets) {
2218 dataSets.push_back(dataSet.second);
2219 }
2220 } else if (retrievedDataSet) {
2221 dataSets.push_back(retrievedDataSet);
2222 } else {
2223 return attributesSolution;
2224 }
2225 // now continue with data intervals
2226 int numberOfIntervals = 0;
2227 for (const auto& dataSet : dataSets) {
2228 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2229 }
2230 // resize dataIntervals
2231 dataIntervals.reserve(numberOfIntervals);
2232 // add intervals
2233 for (const auto& dataSet : dataSets) {
2234 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2235 // continue depending of begin and end
2236 if (beginStr.empty() && endStr.empty()) {
2237 dataIntervals.push_back(dataInterval.second);
2238 } else if (endStr.empty()) {
2239 // parse begin
2240 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2241 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2242 dataIntervals.push_back(dataInterval.second);
2243 }
2244 } else if (beginStr.empty()) {
2245 // parse end
2246 const double end = GNEAttributeCarrier::parse<double>(endStr);
2247 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2248 dataIntervals.push_back(dataInterval.second);
2249 }
2250 } else {
2251 // parse both begin end
2252 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2253 const double end = GNEAttributeCarrier::parse<double>(endStr);
2254 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2255 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2256 dataIntervals.push_back(dataInterval.second);
2257 }
2258 }
2259 }
2260 }
2261 // finally iterate over intervals and get attributes
2262 for (const auto& dataInterval : dataIntervals) {
2263 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2264 // check generic data tag
2265 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2266 for (const auto& attribute : genericData->getParametersMap()) {
2267 attributesSolution.insert(attribute.first);
2268 }
2269 }
2270 }
2271 }
2272 return attributesSolution;
2273}
2274
2275
2277GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2278 for (const auto& meanData : myMeanDatas.at(type)) {
2279 if (meanData.second->getID() == id) {
2280 return meanData.second;
2281 }
2282 }
2283 if (hardFail) {
2284 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2285 } else {
2286 return nullptr;
2287 }
2288}
2289
2290
2291const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> >&
2293 return myMeanDatas;
2294}
2295
2296
2297int
2299 return myNumberOfMeanDataElements;
2300}
2301
2302
2303void
2305 // iterate over myMeanDatas and clear all meanDatas
2306 for (auto& meanDatas : myMeanDatas) {
2307 meanDatas.second.clear();
2308 }
2309}
2310
2311
2312void
2314 const auto tag = meanData->getTagProperty()->getTag();
2315 const auto it = myMeanDatas.at(tag).find(meanData->getID());
2316 if (it == myMeanDatas.at(tag).end()) {
2317 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' doesn't exist in AttributeCarriers.meanDatas");
2318 } else {
2319 // remove from container, set new Id, and insert it again
2320 myMeanDatas.at(tag).erase(it);
2321 myMeanDatas.at(tag)[newID] = meanData;
2322 }
2323}
2324
2325
2326std::string
2328 // obtain option container
2329 const auto& neteditOptions = OptionsCont::getOptions();
2330 // get prefix
2331 std::string prefix;
2332 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2333 prefix = neteditOptions.getString("meanDataEdge-prefix");
2334 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2335 prefix = neteditOptions.getString("meanDataLane-prefix");
2336 }
2337 int counter = 0;
2338 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2339 counter++;
2340 }
2341 return (prefix + "_" + toString(counter));
2342}
2343
2344
2345void
2347 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2348 registerJunction(junction);
2349}
2350
2351
2352void
2354 // remove it from inspected elements and GNEElementTree
2355 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2356 junction->unmarkForDrawingFront();
2357 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2358 // Remove from grid and container
2359 myNet->removeGLObjectFromGrid(junction);
2360 myJunctions.erase(junction->getMicrosimID());
2361 myNumberOfNetworkElements--;
2362 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2363 junction->decRef("GNENet::deleteSingleJunction");
2364 junction->setResponsible(true);
2365}
2366
2367
2368void
2370 // get pointer to create edge frame
2371 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2372 // insert in myEdgeTypes
2373 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2374 myNumberOfNetworkElements++;
2375 // update edge selector
2376 if (myNet->getViewParent()->getCreateEdgeFrame()->shown()) {
2377 myNet->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2378 }
2379 // set current edge type inspected
2380 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2381}
2382
2383
2384void
2386 // get pointer to create edge frame
2387 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2388 // remove it from inspected elements and GNEElementTree
2389 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2390 edgeType->unmarkForDrawingFront();
2391 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2392 // remove from edge types
2393 myEdgeTypes.erase(edgeType->getMicrosimID());
2394 myNumberOfNetworkElements--;
2395 // check if this is the selected edge type in edgeSelector
2396 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2397 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2398 }
2399 // update edge selector
2400 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2401}
2402
2403
2404void
2406 NBEdge* nbe = edge->getNBEdge();
2407 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2408 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2409 nbe->getFromNode()->addOutgoingEdge(nbe);
2410 nbe->getToNode()->addIncomingEdge(nbe);
2411 // register edge
2412 registerEdge(edge);
2413}
2414
2415
2416void
2418 // remove it from inspected elements and GNEElementTree
2419 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2420 edge->unmarkForDrawingFront();
2421 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2422 // remove edge from visual grid and container
2423 myNet->removeGLObjectFromGrid(edge);
2424 myEdges.erase(edge->getMicrosimID());
2425 myNumberOfNetworkElements--;
2426 // remove all lanes
2427 for (const auto& lane : edge->getChildLanes()) {
2428 deleteLane(lane);
2429 }
2430 // extract edge of district container
2431 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2432 edge->decRef("GNENet::deleteSingleEdge");
2433 edge->setResponsible(true);
2434 // Remove refrences from GNEJunctions
2436 edge->getToJunction()->removeIncomingGNEEdge(edge);
2437 // update boundaries of both junctions (to remove it from Grid)
2440 // get template editor
2441 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewParent()->getInspectorFrame()->getTemplateEditor();
2442 // check if we have to remove template
2443 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2444 templateEditor->setEdgeTemplate(nullptr);
2445 }
2446}
2447
2448
2449void
2451 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2452 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2453 } else {
2454 myLanes[lane->getGUIGlObject()] = lane;
2455 myNumberOfNetworkElements++;
2456 }
2457}
2458
2459
2460void
2462 const auto finder = myLanes.find(lane->getGUIGlObject());
2463 if (finder == myLanes.end()) {
2464 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2465 } else {
2466 myLanes.erase(finder);
2467 myNumberOfNetworkElements--;
2468 // remove it from inspected elements and GNEElementTree
2469 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2470 lane->unmarkForDrawingFront();
2471 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2472 }
2473}
2474
2475
2476void
2478 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2479 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2480 } else {
2481 myCrossings[crossing->getGUIGlObject()] = crossing;
2482 myNumberOfNetworkElements++;
2483 }
2484}
2485
2486
2487void
2489 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2490 if (finder == myCrossings.end()) {
2491 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2492 } else {
2493 myCrossings.erase(finder);
2494 myNumberOfNetworkElements--;
2495 // remove it from inspected elements and GNEElementTree
2496 if (myNet->getViewNet()) {
2497 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2498 crossing->unmarkForDrawingFront();
2499 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2500 }
2501 }
2502}
2503
2504
2505void
2507 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2508 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2509 } else {
2510 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2511 myNumberOfNetworkElements++;
2512 }
2513}
2514
2515
2516void
2518 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2519 if (finder == myWalkingAreas.end()) {
2520 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2521 } else {
2522 myWalkingAreas.erase(finder);
2523 myNumberOfNetworkElements--;
2524 // remove it from inspected elements and GNEElementTree
2525 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2526 walkingArea->unmarkForDrawingFront();
2527 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2528 }
2529}
2530
2531
2532void
2534 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2535 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2536 } else {
2537 myConnections[connection->getGUIGlObject()] = connection;
2538 myNumberOfNetworkElements++;
2539 }
2540}
2541
2542
2543void
2545 const auto finder = myConnections.find(connection->getGUIGlObject());
2546 if (finder == myConnections.end()) {
2547 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2548 } else {
2549 myConnections.erase(finder);
2550 myNumberOfNetworkElements--;
2551 // remove it from inspected elements and GNEElementTree
2552 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2553 connection->unmarkForDrawingFront();
2554 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2555 }
2556}
2557
2558
2559void
2561 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2562 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getMicrosimID() + "' already exist");
2563 } else {
2564 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2565 myNumberOfNetworkElements++;
2566 }
2567}
2568
2569
2570void
2572 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2573 if (finder == myInternalLanes.end()) {
2574 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2575 } else {
2576 myInternalLanes.erase(finder);
2577 myNumberOfNetworkElements--;
2578 }
2579}
2580
2581
2582void
2584 const auto tag = additional->getTagProperty()->getTag();
2585 if (myAdditionals.at(tag).count(additional) > 0) {
2586 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2587 } else {
2588 // insert in both containers
2589 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2590 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2591 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2592 }
2593 myNumberOfNetworkElements++;
2594 // insert AC in fileBucket (use this function ton maintain integrity in options)
2595 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(additional);
2596 // add element in grid
2597 myNet->addGLObjectIntoGrid(additional);
2598 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2599 if (myNet->isUpdateGeometryEnabled()) {
2600 additional->updateGeometry();
2601 }
2602 // additionals has to be saved
2603 myNet->getSavingStatus()->requireSaveAdditionals();
2604 }
2605}
2606
2607
2608void
2610 const auto tag = additional->getTagProperty()->getTag();
2611 // find demanElement in additionalTag
2612 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2613 // check if additional was previously inserted
2614 if (itFind == myAdditionals.at(tag).end()) {
2615 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2616 } else {
2617 // remove from both container
2618 myAdditionals.at(tag).erase(itFind);
2619 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2620 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2621 }
2622 myNumberOfNetworkElements--;
2623 // remove AC from fileBucket (use this function ton maintain integrity in options)
2624 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(additional);
2625 // remove it from inspected elements and GNEElementTree
2626 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2627 additional->unmarkForDrawingFront();
2628 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2629 // remove element from grid
2630 myNet->removeGLObjectFromGrid(additional);
2631 // delete path element
2632 myNet->getNetworkPathManager()->removePath(additional);
2633 // additionals has to be saved
2634 myNet->getSavingStatus()->requireSaveAdditionals();
2635 }
2636}
2637
2638
2639
2640
2641void
2643 const auto sourceSinkTag = sourceSink->getTagProperty()->getTag();
2644 if (myTAZSourceSinks.at(sourceSinkTag).count(sourceSink) > 0) {
2645 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' already exist");
2646 } else {
2647 myTAZSourceSinks.at(sourceSinkTag)[sourceSink] = sourceSink;
2648 myNumberOfNetworkElements++;
2649 // insert AC in fileBucket (use this function ton maintain integrity in options)
2650 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(sourceSink);
2651 // additionals has to be saved
2652 myNet->getSavingStatus()->requireSaveAdditionals();
2653 }
2654}
2655
2656
2657void
2659 const auto tag = sourceSink->getTagProperty()->getTag();
2660 // find demanElement in additionalTag
2661 auto itFind = myTAZSourceSinks.at(tag).find(sourceSink);
2662 // check if sourceSink was previously inserted
2663 if (itFind == myTAZSourceSinks.at(tag).end()) {
2664 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' wasn't previously inserted");
2665 } else {
2666 // remove from both container
2667 myTAZSourceSinks.at(tag).erase(itFind);
2668 myNumberOfNetworkElements--;
2669 // remove AC from fileBucket (use this function ton maintain integrity in options)
2670 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(sourceSink);
2671 // remove it from inspected elements and GNEElementTree
2672 myNet->getViewNet()->getInspectedElements().uninspectAC(sourceSink);
2673 sourceSink->unmarkForDrawingFront();
2674 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(sourceSink);
2675 // additionals has to be saved
2676 myNet->getSavingStatus()->requireSaveAdditionals();
2677 }
2678}
2679
2680
2681void
2683 const auto tag = demandElement->getTagProperty()->getTag();
2684 if (myDemandElements.at(tag).count(demandElement) > 0) {
2685 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2686 } else {
2687 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2688 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2689 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2690 }
2691 myNumberOfDemandElements++;
2692 // insert AC in fileBucket (use this function ton maintain integrity in options)
2693 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(demandElement);
2694 // add element in grid
2695 myNet->addGLObjectIntoGrid(demandElement);
2696 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2697 if (myNet->isUpdateGeometryEnabled()) {
2698 demandElement->updateGeometry();
2699 }
2700 // compute path element
2701 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2702 demandElement->computePathElement();
2703 }
2704 // update demand elements frames
2705 updateDemandElementFrames(demandElement->getTagProperty());
2706 // demandElements has to be saved
2707 myNet->getSavingStatus()->requireSaveDemandElements();
2708 }
2709}
2710
2711
2712void
2714 const auto tag = demandElement->getTagProperty()->getTag();
2715 auto viewParent = myNet->getViewParent();
2716 // find demanElement in demandElementTag
2717 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2718 // check if demandElement was previously inserted
2719 if (itFind == myDemandElements.at(tag).end()) {
2720 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2721 } else {
2722 // erase it from container
2723 myDemandElements.at(tag).erase(itFind);
2724 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2725 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2726 }
2727 myNumberOfDemandElements--;
2728 // remove AC from fileBucket (use this function ton maintain integrity in options)
2729 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(demandElement);
2730 // remove element from grid
2731 myNet->removeGLObjectFromGrid(demandElement);
2732 // remove it from inspected elements and GNEElementTree
2733 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2734 demandElement->unmarkForDrawingFront();
2735 // if is the last inserted route, remove it from GNEViewNet
2736 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2737 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2738 }
2739 // delete path element
2740 myNet->getDemandPathManager()->removePath(demandElement);
2741 // check if update demand elements frames
2742 if (updateFrames) {
2743 updateDemandElementFrames(demandElement->getTagProperty());
2744 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2745 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2746 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2747 // update distribution frames
2748 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2749 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2750 }
2751 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2752 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2753 }
2754 // special case for distribution references
2755 if (demandElement->getTagProperty()->getTag() == GNE_TAG_VTYPEREF) {
2756 viewParent->getTypeDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2757 }
2758 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
2759 viewParent->getRouteDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2760 }
2761 }
2762 // demandElements has to be saved
2763 myNet->getSavingStatus()->requireSaveDemandElements();
2764 }
2765}
2766
2767
2768void
2770 if (myDataSets.count(dataSet->getID()) > 0) {
2771 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2772 } else {
2773 myDataSets[dataSet->getID()] = dataSet;
2774 myNumberOfDataElements++;
2775 // insert AC in fileBucket (use this function ton maintain integrity in options)
2776 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(dataSet);
2777 // dataSets has to be saved
2778 myNet->getSavingStatus()->requireSaveDataElements();
2779 // mark interval toolbar for update
2780 myNet->getViewNet()->getIntervalBar().markForUpdate();
2781 }
2782}
2783
2784
2785void
2787 const auto finder = myDataSets.find(dataSet->getID());
2788 if (finder == myDataSets.end()) {
2789 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2790 } else {
2791 myDataSets.erase(finder);
2792 myNumberOfDataElements--;
2793 // remove AC from fileBucket (use this function ton maintain integrity in options)
2794 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(dataSet);
2795 // remove it from inspected elements and GNEElementTree
2796 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2797 dataSet->unmarkForDrawingFront();
2798 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2799 // dataSets has to be saved
2800 myNet->getSavingStatus()->requireSaveDataElements();
2801 // mark interval toolbar for update
2802 myNet->getViewNet()->getIntervalBar().markForUpdate();
2803 }
2804}
2805
2806
2807void
2809 if (myMeanDatas.at(meanData->getTagProperty()->getTag()).count(meanData->getID()) > 0) {
2810 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2811 } else {
2812 myMeanDatas.at(meanData->getTagProperty()->getTag()).insert(std::make_pair(meanData->getID(), meanData));
2813 myNumberOfMeanDataElements++;
2814 // insert AC in fileBucket (use this function ton maintain integrity in options)
2815 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(meanData);
2816 // meanDatas has to be saved
2817 myNet->getSavingStatus()->requireSaveMeanDatas();
2818 }
2819}
2820
2821
2822void
2824 // find demanElement in meanDataTag
2825 auto itFind = myMeanDatas.at(meanData->getTagProperty()->getTag()).find(meanData->getID());
2826 // check if meanData was previously inserted
2827 if (itFind == myMeanDatas.at(meanData->getTagProperty()->getTag()).end()) {
2828 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2829 } else {
2830 // remove from container
2831 myMeanDatas.at(meanData->getTagProperty()->getTag()).erase(itFind);
2832 myNumberOfMeanDataElements--;
2833 // remove AC from fileBucket (use this function ton maintain integrity in options)
2834 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(meanData);
2835 // remove it from inspected elements and GNEElementTree
2836 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2837 meanData->unmarkForDrawingFront();
2838 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2839 // remove element from grid
2840 myNet->removeGLObjectFromGrid(meanData);
2841 // meanDatas has to be saved
2842 myNet->getSavingStatus()->requireSaveMeanDatas();
2843 }
2844}
2845
2846
2847void
2849 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2850 // continue depending of demand mode
2851 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2853 if (tagProperty->isType()) {
2854 myNet->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2855 }
2856 break;
2858 if (tagProperty->isType()) {
2859 myNet->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2860 }
2861 break;
2863 if (tagProperty->isType()) {
2864 myNet->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2865 }
2866 break;
2868 if (tagProperty->isRoute()) {
2869 myNet->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2870 }
2871 break;
2873 if (tagProperty->isType()) {
2874 myNet->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2875 }
2876 break;
2878 if (tagProperty->isPerson()) {
2879 myNet->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2880 }
2881 break;
2883 if (tagProperty->isType()) {
2884 myNet->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2885 }
2886 break;
2888 if (tagProperty->isContainer()) {
2889 myNet->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2890 }
2891 break;
2893 myNet->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2894 break;
2895 default:
2896 // nothing to update
2897 break;
2898 }
2899 }
2900}
2901
2902
2903void
2905 // fill network elements
2906 if (tag->getTag() == SUMO_TAG_JUNCTION) {
2907 for (const auto& junction : myJunctions) {
2908 ACs.push_back(junction.second);
2909 }
2910 }
2911 if (tag->getTag() == SUMO_TAG_EDGE) {
2912 for (const auto& edge : myEdges) {
2913 ACs.push_back(edge.second);
2914 }
2915 }
2916 if (tag->getTag() == SUMO_TAG_LANE) {
2917 for (const auto& lane : myLanes) {
2918 ACs.push_back(lane.second);
2919 }
2920 }
2921 if (tag->getTag() == SUMO_TAG_CONNECTION) {
2922 for (const auto& connection : myConnections) {
2923 ACs.push_back(connection.second);
2924 }
2925 }
2926 if (tag->getTag() == SUMO_TAG_CROSSING) {
2927 for (const auto& crossing : myCrossings) {
2928 ACs.push_back(crossing.second);
2929 }
2930 }
2931 if (tag->getTag() == SUMO_TAG_WALKINGAREA) {
2932 for (const auto& walkingArea : myWalkingAreas) {
2933 ACs.push_back(walkingArea.second);
2934 }
2935 }
2936 // fill additional elements
2937 if (tag->isAdditionalElement()) {
2938 for (const auto& additionalTag : myAdditionals) {
2939 if (additionalTag.first == tag->getTag()) {
2940 for (const auto& additional : additionalTag.second) {
2941 ACs.push_back(additional.second);
2942 }
2943 }
2944 }
2945 }
2946 // fill demand elements
2947 if (tag->isDemandElement()) {
2948 for (const auto& demandElementTag : myDemandElements) {
2949 if (demandElementTag.first == tag->getTag()) {
2950 for (const auto& demandElemet : demandElementTag.second) {
2951 ACs.push_back(demandElemet.second);
2952 }
2953 }
2954 }
2955 }
2956 // fill data elements
2957 if (tag->isDataElement()) {
2958 if (tag->getTag() == SUMO_TAG_DATASET) {
2959 for (const auto& dataSet : myDataSets) {
2960 ACs.push_back(dataSet.second);
2961 }
2962 }
2963 if (tag->getTag() == SUMO_TAG_DATAINTERVAL) {
2964 for (const auto& dataInterval : myDataIntervals) {
2965 ACs.push_back(dataInterval.second);
2966 }
2967 }
2968 for (const auto& genericDataTag : myGenericDatas) {
2969 if (genericDataTag.first == tag->getTag()) {
2970 for (const auto& genericData : genericDataTag.second) {
2971 ACs.push_back(genericData.second);
2972 }
2973 }
2974 }
2975 for (const auto& meanDataTag : myMeanDatas) {
2976 if (meanDataTag.first == tag->getTag()) {
2977 for (const auto& meanData : meanDataTag.second) {
2978 ACs.push_back(meanData.second);
2979 }
2980 }
2981 }
2982 }
2983 // iterate over children
2984 for (const auto child : tag->getHierarchicalChildren()) {
2985 retrieveAttributeCarriersRecursively(child, ACs);
2986 }
2987}
2988
2989// ---------------------------------------------------------------------------
2990// GNENetHelper::GNETagSelector - methods
2991// ---------------------------------------------------------------------------
2992
2994 myNet(net) {
2995}
2996
2997
2998void
3000 // network
3001 myTemplates[SUMO_TAG_CROSSING] = new GNECrossing(myNet);
3002 // special case for edge type
3003 myEdgeType = new GNEEdgeType(myNet);
3004 myTemplates[SUMO_TAG_TYPE] = myEdgeType;
3005 // additionals
3006 myTemplates[SUMO_TAG_BUS_STOP] = GNEBusStop::buildBusStop(myNet);
3007 myTemplates[SUMO_TAG_TRAIN_STOP] = GNEBusStop::buildTrainStop(myNet);
3008 myTemplates[SUMO_TAG_ACCESS] = new GNEAccess(myNet);
3009 myTemplates[SUMO_TAG_CONTAINER_STOP] = new GNEContainerStop(myNet);
3010 myTemplates[SUMO_TAG_CHARGING_STATION] = new GNEChargingStation(myNet);
3011 myTemplates[SUMO_TAG_PARKING_AREA] = new GNEParkingArea(myNet);
3012 myTemplates[SUMO_TAG_PARKING_SPACE] = new GNEParkingSpace(myNet);
3013 myTemplates[SUMO_TAG_INDUCTION_LOOP] = new GNEInductionLoopDetector(myNet);
3018 myTemplates[SUMO_TAG_DET_EXIT] = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet);
3020 myTemplates[SUMO_TAG_VSS] = new GNEVariableSpeedSign(myNet);
3021 myTemplates[SUMO_TAG_STEP] = new GNEVariableSpeedSignStep(myNet);
3022 myTemplates[SUMO_TAG_CALIBRATOR] = new GNECalibrator(SUMO_TAG_CALIBRATOR, myNet);
3024 myTemplates[GNE_TAG_CALIBRATOR_FLOW] = new GNECalibratorFlow(myNet);
3025 myTemplates[SUMO_TAG_REROUTER] = new GNERerouter(myNet);
3026 myTemplates[SUMO_TAG_INTERVAL] = new GNERerouterInterval(myNet);
3027 myTemplates[SUMO_TAG_CLOSING_REROUTE] = new GNEClosingReroute(myNet);
3028 myTemplates[SUMO_TAG_CLOSING_LANE_REROUTE] = new GNEClosingLaneReroute(myNet);
3029 myTemplates[SUMO_TAG_DEST_PROB_REROUTE] = new GNEDestProbReroute(myNet);
3030 myTemplates[SUMO_TAG_PARKING_AREA_REROUTE] = new GNEParkingAreaReroute(myNet);
3031 myTemplates[SUMO_TAG_ROUTE_PROB_REROUTE] = new GNERouteProbReroute(myNet);
3032 myTemplates[SUMO_TAG_ROUTEPROBE] = new GNERouteProbe(myNet);
3033 myTemplates[SUMO_TAG_VAPORIZER] = new GNEVaporizer(myNet);
3034 // symbols
3035 myTemplates[GNE_TAG_REROUTER_SYMBOL] = new GNERerouterSymbol(myNet);
3036 myTemplates[GNE_TAG_VSS_SYMBOL] = new GNEVariableSpeedSignSymbol(myNet);
3037 // shapes
3038 myTemplates[SUMO_TAG_POLY] = new GNEPoly(SUMO_TAG_POLY, myNet);
3039 myTemplates[SUMO_TAG_POI] = new GNEPOI(SUMO_TAG_POI, myNet);
3040 myTemplates[GNE_TAG_POILANE] = new GNEPOI(GNE_TAG_POILANE, myNet);
3041 myTemplates[GNE_TAG_POIGEO] = new GNEPOI(GNE_TAG_POIGEO, myNet);
3042 // TAZs
3043 myTemplates[SUMO_TAG_TAZ] = new GNETAZ(myNet);
3044 myTemplates[SUMO_TAG_TAZSOURCE] = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, myNet);
3045 myTemplates[SUMO_TAG_TAZSINK] = new GNETAZSourceSink(SUMO_TAG_TAZSINK, myNet);
3046 // wires
3047 myTemplates[SUMO_TAG_TRACTION_SUBSTATION] = new GNETractionSubstation(myNet);
3048 myTemplates[SUMO_TAG_OVERHEAD_WIRE_SECTION] = new GNEOverheadWire(myNet);
3049 //myTemplates[SUMO_TAG_OVERHEAD_WIRE_CLAMP] = nullptr; // TMP
3050 // JuPedSim elements
3052 myTemplates[GNE_TAG_JPS_OBSTACLE] = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet);
3053 // vTypes
3054 myTemplates[SUMO_TAG_VTYPE] = new GNEVType(SUMO_TAG_VTYPE, myNet);
3055 // vType distributions
3056 myTemplates[SUMO_TAG_VTYPE_DISTRIBUTION] = new GNEVTypeDistribution(myNet);
3057 myTemplates[GNE_TAG_VTYPEREF] = new GNEVTypeRef(myNet);
3058 // routes
3059 myTemplates[SUMO_TAG_ROUTE] = new GNERoute(SUMO_TAG_ROUTE, myNet);
3060 myTemplates[GNE_TAG_ROUTE_EMBEDDED] = new GNERoute(GNE_TAG_ROUTE_EMBEDDED, myNet);
3061 // route distribution
3062 myTemplates[SUMO_TAG_ROUTE_DISTRIBUTION] = new GNERouteDistribution(myNet);
3063 myTemplates[GNE_TAG_ROUTEREF] = new GNERouteRef(myNet);
3064 // vehicles
3065 const auto vehicles = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::VEHICLE);
3066 for (const auto vehicle : vehicles) {
3067 myTemplates[vehicle->getTag()] = new GNEVehicle(vehicle->getTag(), myNet);
3068 }
3069 // persons
3070 const auto persons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSON);
3071 for (const auto person : persons) {
3072 myTemplates[person->getTag()] = new GNEPerson(person->getTag(), myNet);
3073 }
3074 // container
3075 const auto containers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::CONTAINER);
3076 for (const auto container : containers) {
3077 myTemplates[container->getTag()] = new GNEContainer(container->getTag(), myNet);
3078 }
3079 // stops and waypoints
3080 const auto stopAndWaypoints = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_VEHICLE);
3081 for (const auto stopAndWaypoint : stopAndWaypoints) {
3082 myTemplates[stopAndWaypoint->getTag()] = new GNEStop(stopAndWaypoint->getTag(), myNet);
3083 }
3084 // personTrip
3085 const auto personTrips = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSONTRIP);
3086 for (const auto personTrip : personTrips) {
3087 myTemplates[personTrip->getTag()] = new GNEPersonTrip(personTrip->getTag(), myNet);
3088 }
3089 // walk
3090 const auto walks = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::WALK);
3091 for (const auto walk : walks) {
3092 myTemplates[walk->getTag()] = new GNEWalk(walk->getTag(), myNet);
3093 }
3094 // ride
3095 const auto rides = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::RIDE);
3096 for (const auto ride : rides) {
3097 myTemplates[ride->getTag()] = new GNERide(ride->getTag(), myNet);
3098 }
3099 // stop person
3100 const auto stopPersons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_PERSON);
3101 for (const auto stopPerson : stopPersons) {
3102 myTemplates[stopPerson->getTag()] = new GNEStopPlan(stopPerson->getTag(), myNet);
3103 }
3104 // transport
3105 const auto transports = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSPORT);
3106 for (const auto transport : transports) {
3107 myTemplates[transport->getTag()] = new GNETransport(transport->getTag(), myNet);
3108 }
3109 // tranship
3110 const auto tranships = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSHIP);
3111 for (const auto tranship : tranships) {
3112 myTemplates[tranship->getTag()] = new GNETranship(tranship->getTag(), myNet);
3113 }
3114 // stop container
3115 const auto stopContainers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_CONTAINER);
3116 for (const auto stopContainer : stopContainers) {
3117 myTemplates[stopContainer->getTag()] = new GNEStopPlan(stopContainer->getTag(), myNet);
3118 }
3119 // dataSet
3120 myTemplates[SUMO_TAG_DATASET] = new GNEDataSet(myNet);
3121 // generic datas
3122 myTemplates[GNE_TAG_EDGEREL_SINGLE] = new GNEEdgeData(myNet);
3123 myTemplates[SUMO_TAG_EDGEREL] = new GNEEdgeRelData(myNet);
3124 myTemplates[SUMO_TAG_TAZREL] = new GNETAZRelData(myNet);
3125 // reset all to their default values
3126 for (const auto& AC : myTemplates) {
3127 AC.second->resetDefaultValues(false);
3128 }
3129 // fill plan templates
3130 fillPlanTemplates();
3131}
3132
3133
3135 for (auto& AC : myTemplates) {
3136 delete AC.second;
3137 }
3138}
3139
3140
3141std::map<SumoXMLTag, GNEAttributeCarrier*>
3143 return myTemplates;
3144}
3145
3146
3149 if (myTemplates.count(tag) > 0) {
3150 return myTemplates.at(tag);
3151 } else {
3152 return nullptr;
3153 }
3154}
3155
3156
3158GNENetHelper::ACTemplate::getTemplateAC(const std::string& selectorText) const {
3159 for (const auto& templateAC : myTemplates) {
3160 if (templateAC.second->getTagProperty()->getSelectorText() == selectorText) {
3161 return templateAC.second;
3162 }
3163 }
3164 return nullptr;
3165}
3166
3167
3170 return myEdgeType;
3171}
3172
3173
3174const std::vector<std::pair<GNETagProperties*, GNEDemandElement*>>&
3176 return myPlanTemplates.at(tag);
3177}
3178
3179
3180void
3182 GNETagProperties* tagProperty = nullptr;
3183 // person trip
3184 tagProperty = new GNETagProperties(SUMO_TAG_PERSONTRIP, nullptr,
3198 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEPersonTrip(GNE_TAG_PERSONTRIP_EDGE_EDGE, myNet)));
3199 // ride
3200 tagProperty = new GNETagProperties(SUMO_TAG_RIDE, nullptr,
3214 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNERide(GNE_TAG_RIDE_EDGE_EDGE, myNet)));
3215 // walk
3216 tagProperty = new GNETagProperties(SUMO_TAG_WALK, nullptr,
3230 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGE_EDGE, myNet)));
3231 // walk (edges)
3232 tagProperty = new GNETagProperties(GNE_TAG_WALK_EDGES, nullptr,
3239 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGES, myNet)));
3240 // walk (route)
3241 tagProperty = new GNETagProperties(GNE_TAG_WALK_ROUTE, nullptr,
3248 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_ROUTE, myNet)));
3249 // stop
3250 tagProperty = new GNETagProperties(GNE_TAG_PERSONSTOPS, nullptr,
3259 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPPERSON_EDGE, myNet)));
3260 // transport
3261 tagProperty = new GNETagProperties(SUMO_TAG_TRANSPORT, nullptr,
3265 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3266 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3267 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3268 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3270 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3271 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3275 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETransport(GNE_TAG_TRANSPORT_EDGE_EDGE, myNet)));
3276 // tranship
3277 tagProperty = new GNETagProperties(SUMO_TAG_TRANSHIP, nullptr,
3281 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3282 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3283 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3284 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3286 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3287 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3291 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGE_EDGE, myNet)));
3292 // tranship (edges)
3293 tagProperty = new GNETagProperties(GNE_TAG_TRANSHIP_EDGES, nullptr,
3300 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGES, myNet)));
3301 // stop
3302 tagProperty = new GNETagProperties(GNE_TAG_CONTAINERSTOPS, nullptr,
3311 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPCONTAINER_EDGE, myNet)));
3312}
3313
3314// ---------------------------------------------------------------------------
3315// GNENetHelper::SavingStatus - methods
3316// ---------------------------------------------------------------------------
3317
3319 myNet(net) {
3320}
3321
3322
3323void
3325 mySumoConfigSaved = false;
3326}
3327
3328
3329void
3331 mySumoConfigSaved = true;
3332}
3333
3334
3335bool
3337 return mySumoConfigSaved;
3338}
3339
3340
3341void
3343 myNeteditConfigSaved = false;
3344}
3345
3346
3347void
3349 myNeteditConfigSaved = true;
3350}
3351
3352
3353bool
3355 return myNeteditConfigSaved;
3356}
3357
3358
3359void
3361 myNetworkSaved = false;
3362 // implies requiere save netedit config and sumo config
3363 myNeteditConfigSaved = false;
3364 mySumoConfigSaved = false;
3365}
3366
3367
3368void
3370 myNetworkSaved = true;
3371}
3372
3373
3374bool
3376 return myNetworkSaved;
3377}
3378
3379
3380void
3382 myTLSSaved = false;
3383}
3384
3385
3386void
3388 myTLSSaved = true;
3389}
3390
3391
3392bool
3394 return myTLSSaved;
3395}
3396
3397
3398void
3400 myEdgeTypeSaved = false;
3401}
3402
3403
3404void
3406 myEdgeTypeSaved = true;
3407}
3408
3409
3410bool
3412 return myEdgeTypeSaved;
3413}
3414
3415
3416void
3418 myAdditionalSaved = false;
3419 // implies requiere save netedit config and sumo config
3420 myNeteditConfigSaved = false;
3421 mySumoConfigSaved = false;
3422}
3423
3424
3425void
3427 myAdditionalSaved = true;
3428}
3429
3430
3431bool
3433 return myAdditionalSaved;
3434}
3435
3436
3437void
3439 myDemandElementSaved = false;
3440 // implies requiere save netedit config and sumo config
3441 myNeteditConfigSaved = false;
3442 mySumoConfigSaved = false;
3443}
3444
3445
3446void
3448 myDemandElementSaved = true;
3449}
3450
3451
3452bool
3454 return myDemandElementSaved;
3455}
3456
3457
3458void
3460 myDataElementSaved = false;
3461 // implies requiere save netedit config and sumo config
3462 myNeteditConfigSaved = false;
3463 mySumoConfigSaved = false;
3464}
3465
3466
3467void
3469 myDataElementSaved = true;
3470}
3471
3472
3473bool
3475 return myDataElementSaved;
3476}
3477
3478
3479void
3481 myMeanDataElementSaved = false;
3482 // implies requiere save netedit config and sumo config
3483 myNeteditConfigSaved = false;
3484 mySumoConfigSaved = false;
3485}
3486
3487
3488void
3490 myMeanDataElementSaved = true;
3491}
3492
3493
3494bool
3496 return myMeanDataElementSaved;
3497}
3498
3499
3502 auto GNEApp = myNet->getGNEApplicationWindow();
3503 // Check if there are non saved network elements
3504 if (commonResult == GNEDialog::Result::ABORT) {
3506 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3508 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3510 } else if (myNetworkSaved) {
3512 } else {
3513 // open save dialog
3514 const GNESaveDialog saveDialog(GNEApp, TL("network"));
3515 // continue depending of result
3516 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3517 commonResult = GNEDialog::Result::ABORT;
3519 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3520 commonResult = GNEDialog::Result::ACCEPT_ALL;
3522 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3523 commonResult = GNEDialog::Result::CANCEL_ALL;
3525 } else {
3526 return saveDialog.getResult();
3527 }
3528 }
3529}
3530
3531
3534 auto GNEApp = myNet->getGNEApplicationWindow();
3535 // Check if there are non saved additional elements
3536 if (commonResult == GNEDialog::Result::ABORT) {
3538 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3540 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3542 } else if (myAdditionalSaved) {
3544 } else {
3545 // open save dialog
3546 const GNESaveDialog saveDialog(GNEApp, TL("additional elements"));
3547 // continue depending of result
3548 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3549 commonResult = GNEDialog::Result::ABORT;
3551 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3552 commonResult = GNEDialog::Result::ACCEPT_ALL;
3554 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3555 commonResult = GNEDialog::Result::CANCEL_ALL;
3557 } else {
3558 return saveDialog.getResult();
3559 }
3560 }
3561}
3562
3563
3566 auto GNEApp = myNet->getGNEApplicationWindow();
3567 // Check if there are non saved demand elements
3568 if (commonResult == GNEDialog::Result::ABORT) {
3570 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3572 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3574 } else if (myDemandElementSaved) {
3576 } else {
3577 // open save dialog
3578 const GNESaveDialog saveDialog(GNEApp, TL("demand elements"));
3579 // continue depending of result
3580 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3581 commonResult = GNEDialog::Result::ABORT;
3583 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3584 commonResult = GNEDialog::Result::ACCEPT_ALL;
3586 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3587 commonResult = GNEDialog::Result::CANCEL_ALL;
3589 } else {
3590 return saveDialog.getResult();
3591 }
3592 }
3593}
3594
3595
3598 auto GNEApp = myNet->getGNEApplicationWindow();
3599 // Check if there are non saved data elements
3600 if (commonResult == GNEDialog::Result::ABORT) {
3602 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3604 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3606 } else if (myDataElementSaved) {
3608 } else {
3609 // open save dialog
3610 const GNESaveDialog saveDialog(GNEApp, TL("data elements"));
3611 // continue depending of result
3612 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3613 commonResult = GNEDialog::Result::ABORT;
3615 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3616 commonResult = GNEDialog::Result::ACCEPT_ALL;
3618 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3619 commonResult = GNEDialog::Result::CANCEL_ALL;
3621 } else {
3622 return saveDialog.getResult();
3623 }
3624 }
3625}
3626
3627
3630 auto GNEApp = myNet->getGNEApplicationWindow();
3631 // Check if there are non saved mean data elements
3632 if (commonResult == GNEDialog::Result::ABORT) {
3634 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3636 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3638 } else if (myMeanDataElementSaved) {
3640 } else {
3641 // open save dialog
3642 const GNESaveDialog saveDialog(GNEApp, TL("meanData elements"));
3643 // continue depending of result
3644 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3645 commonResult = GNEDialog::Result::ABORT;
3647 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3648 commonResult = GNEDialog::Result::ACCEPT_ALL;
3650 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3651 commonResult = GNEDialog::Result::CANCEL_ALL;
3653 } else {
3654 return saveDialog.getResult();
3655 }
3656 }
3657}
3658
3659// ---------------------------------------------------------------------------
3660// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
3661// ---------------------------------------------------------------------------
3662
3664 GNEChange(Supermode::NETWORK, true, false),
3665 myTllcont(tllcont),
3666 myReplaced(replaced),
3667 myBy(by) {
3668}
3669
3670
3672
3673
3674void
3676 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3677 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
3678}
3679
3680
3681void
3683 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3684 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
3685}
3686
3687
3688std::string
3690 return TL("Redo replace in TLS");
3691}
3692
3693
3694std::string
3696 return TL("Undo replace in TLS");
3697}
3698
3699
3700bool
3702 return myReplaced != myBy;
3703}
3704
3705/****************************************************************************/
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:44
@ GLO_TRANSHIP
a container tranship
@ GLO_WALK
a walk
@ GLO_CONTAINER_STOP
a containerStop
@ GLO_RIDE
a ride
@ GLO_PERSONTRIP
a person trip
@ GLO_TRANSPORT
a container transport
@ GLO_STOP
a stop
GUISelectedStorage gSelected
A global holder of selected objects.
#define TL(string)
Definition MsgHandler.h:304
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
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::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
@ GNE_TAG_PERSONTRIP_EDGE_EDGE
@ GNE_TAG_VTYPEREF
reference to a vType (used in VType distributions)
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ 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_ACCESS
An access point for a train stop.
@ SUMO_TAG_WALK
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ GNE_TAG_TRANSHIP_EDGE_EDGE
@ SUMO_TAG_TRANSHIP
@ GNE_TAG_WALK_EDGES
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_ROOTFILE
root file
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ GNE_TAG_EDGEREL_SINGLE
@ GNE_TAG_STOPCONTAINER_EDGE
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_MEANDATA_LANE
a lane based mean data detector
@ SUMO_TAG_STEP
trigger: a step description
@ 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_VSS_SYMBOL
VSS Symbol.
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ GNE_TAG_TRANSHIP_EDGES
@ 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_TRANSPORT
@ GNE_TAG_RIDE_EDGE_EDGE
@ SUMO_TAG_WALKINGAREA
walking area for pedestrians
@ GNE_TAG_TRANSPORT_EDGE_EDGE
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ GNE_TAG_WALK_EDGE_EDGE
@ SUMO_TAG_ROUTE
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_RIDE
@ 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_CALIBRATOR_FLOW
a flow definition within in Calibrator
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ 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_DET_EXIT
an e3 exit point
@ SUMO_TAG_PERSONTRIP
@ SUMO_TAG_TYPE
type (edge)
@ GNE_TAG_CONTAINERSTOPS
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ GNE_TAG_REROUTER_SYMBOL
Rerouter Symbol.
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ GNE_TAG_ROUTEREF
virtual element used to reference routes with distributions
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ 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
@ GNE_TAG_PERSONSTOPS
@ SUMO_TAG_VSS
A variable speed sign.
@ GNE_TAG_STOPPERSON_EDGE
@ GNE_TAG_WALK_ROUTE
@ 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
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this additional
virtual Position getPositionInView() const =0
Returns position of additional in view.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string getID() const override
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
void unmarkForDrawingFront()
unmark for drawing front
virtual void updateGeometry()=0
update pre-computed geometry information
virtual GUIGlObject * getGUIGlObject()=0
get GUIGlObject associated with this AttributeCarrier
static GNEBusStop * buildTrainStop(GNENet *net)
default constructor
static GNEBusStop * buildBusStop(GNENet *net)
default constructor
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this GNEDemandElement
Result getResult() const
get result to indicate if this dialog was closed accepting or rejecting changes
Result
list of possible results when closing the dialog
Definition GNEDialog.h:70
An Element which don't belong to GNENet but has influence in the simulation.
Definition GNEEdgeData.h:32
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNEEdge.cpp:634
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition GNEEdge.cpp:1498
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:755
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2229
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:87
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:628
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:92
An Element which don't belong to GNENet but has influence in the simulation.
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this genericData
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
void setEdgeTemplate(const GNEEdge *edge)
set edge template
GNEEdgeTemplate * getEdgeTemplate() const
get edge template (to copy attributes from)
void setResponsible(bool newVal)
set responsibility for deleting internal structures
void updateGeometry() override
update pre-computed geometry information (including crossings)
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
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
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:624
std::map< SumoXMLTag, GNEAttributeCarrier * > getACTemplates() const
get all AC templates
void buildTemplates()
build templates
ACTemplate()=delete
Invalidated default constructor.
GNEAttributeCarrier * getTemplateAC(const SumoXMLTag tag) const
get template AC by tag
const std::vector< std::pair< GNETagProperties *, GNEDemandElement * > > & getPlanTemplates(SumoXMLTag tag) const
get plan templates
void fillPlanTemplates()
fill plan templates
GNEEdgeType * getDefaultEdgeType() const
get default edge type
std::vector< GNEEdge * > retrieveEdges(GNEJunction *from, GNEJunction *to) const
get all edges by from and to GNEJunction
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * >, std::hash< int > > & getDemandElements() const
get demand elements
GNETAZSourceSink * retrieveTAZSourceSink(const GNEAttributeCarrier *sourceSink, bool hardFail=true) const
Returns the named sourceSink.
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
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
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * >, std::hash< int > > myGenericDatas
map with the tag and pointer to all generic datas
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
void insertDataSet(GNEDataSet *dataSet)
Insert a data set in container.
int getNumberOfSelectedRides() const
get number of selected rides
void clearDemandElements()
clear demand elements
void clearTAZSourceSinks()
clear sourceSinks
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
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * >, std::hash< int > > & getGenericDatas() const
get all generic datas
int getNumberOfSelectedPersonTrips() const
get number of selected person trips
std::string generateDemandElementID(SumoXMLTag tag) const
generate demand element id
int getNumberOfMeanDatas() const
get number of meanDatas
GNECrossing * retrieveCrossing(const GUIGlObject *glObject, bool hardFail=true) const
get Crossing by AC
void addPrefixToEdges(const std::string &prefix)
add prefix to all edges
void remapJunctionAndEdgeIds()
remap junction and edge IDs
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(SumoXMLTag tag=SUMO_TAG_NOTHING)
get the attribute carriers based on Type
AttributeCarriers()=delete
Invalidated default constructor.
void clearEdgeTypes()
clear edgeTypes
std::string generateEdgeID() const
generate edge ID
int getNumberOfSelectedTranships() const
get number of selected tranships
const std::unordered_map< SumoXMLTag, std::unordered_map< const GNEAttributeCarrier *, GNETAZSourceSink * >, std::hash< int > > & getTAZSourceSinks() const
get sourceSinks
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
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
GNENet * myNet
pointer to net
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::map< const std::string, GNEMeanData * >, std::hash< int > > & getMeanDatas() const
get meanDatas
int getNumberOfSelectedWalkingAreas() const
get number of selected walkingAreas
GNEWalkingArea * retrieveWalkingArea(const GUIGlObject *glObject, bool hardFail=true) const
get WalkingArea by GlObject
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
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * >, std::hash< int > > myMeanDatas
map with the tag and pointer to meanData elements of net
void insertMeanData(GNEMeanData *meanData)
Insert a meanData element in container.
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
int getNumberOfSelectedTAZs() const
get number of selected TAZs
void deleteWalkingArea(GNEWalkingArea *walkingArea)
delete walkingArea from container
int getNumberOfSelectedTransport() const
get number of selected transports
void updateMeanDataID(GNEMeanData *meanData, const std::string &newID)
update meanData ID in container
std::vector< GNELane * > getSelectedLanes() const
get selected lanes
void insertConnection(GNEConnection *connection)
insert connection in container
std::vector< GNEAdditional * > getSelectedAdditionals() const
get selected additionals
int getNumberOfSelectedJunctions() const
get number of selected junctions
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEAdditional * >, std::hash< int > > myAdditionalIDs
map with the tag and pointer to additional elements of net, sorted by IDs
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
std::unordered_map< SumoXMLTag, std::unordered_map< const GNEAttributeCarrier *, GNETAZSourceSink * >, std::hash< int > > myTAZSourceSinks
map with the tag and pointer to TAZSourceSinks elements of net
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)
int getNumberOfSelectedPolygons() const
get number of selected polygons
std::vector< GNEJunction * > getSelectedJunctions() const
return selected junctions
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * >, std::hash< int > > myAdditionals
map with the tag and pointer to additional elements of net
int getNumberOfAdditionals() const
get number of additionals
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEDemandElement * >, std::hash< int > > myDemandElementIDs
map with the tag and pointer to demand elements of net, sorted by IDs
void updateDemandElementID(GNEDemandElement *demandElement, const std::string &newID)
update demand element ID in container
bool isNetworkElementAroundTriangle(GNEAttributeCarrier *AC, const Triangle &triangle) const
check if shape of given AC (network element) is around the given triangle
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element in container.
void insertTAZSourceSink(GNETAZSourceSink *sourceSink)
Insert a sourceSink element in container.
void updateEdgeID(GNEEdge *edge, const std::string &newID)
update edge ID in container
GNEDataInterval * retrieveDataInterval(const GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
std::vector< GNECrossing * > getSelectedCrossings() const
return all selected crossings
int getNumberOfSelectedLanes() const
get number of selected lanes
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
int getNumberOfSelectedEdgeDatas() const
get number of selected edge datas
void updateEdgeTypeID(GNEEdgeType *edgeType, const std::string &newID)
update edgeType ID in container
GNEInternalLane * retrieveInternalLane(const GUIGlObject *glObject, bool hardFail=true) const
get InternalLane by GUIGlObject
void updateDemandElementFrames(const GNETagProperties *tagProperty)
update demand element frames (called after insert/delete demand element)
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
void retrieveAttributeCarriersRecursively(const GNETagProperties *tag, std::vector< GNEAttributeCarrier * > &ACs)
retrieve attribute carriers recursively
bool requireJunctionTazOption() const
check if we have elements that requires the option junction-taz
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
const std::map< std::string, GNEJunction * > & getJunctions() const
get junctions
int getNumberOfSelectedEdges() const
get number of selected edges
const std::map< std::string, GNEEdgeType * > & getEdgeTypes() const
map with the ID and pointer to edgeTypes of net
void clearMeanDatas()
clear meanDatas
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
std::vector< GNEConnection * > getSelectedConnections() const
get selected connections
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * >, std::hash< int > > myDemandElements
map with the tag and pointer to demand elements elements of net
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::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * >, std::hash< int > > & getAdditionals() const
get additionals
std::vector< std::string > getPOIParamKeys() const
return list of available POI parameters
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
std::string generateEdgeTypeID() const
generate edgeType id
void deleteDataInterval(GNEDataInterval *dataInterval)
delete data interval of container
GNEConnection * retrieveConnection(const std::string &id, bool hardFail=true) const
get Connection by id
void deleteTAZSourceSink(GNETAZSourceSink *sourceSink)
delete sourceSink element of container
int getNumberOfSelectedContainers() const
get number of selected containers
std::string generateDataSetID() const
generate data set id
int getNumberOfTAZSourceSinks() const
get number of TAZSourceSinks
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
GNEDialog::Result askSaveMeanDataElements(GNEDialog::Result &commonResult) const
warns about unsaved changes in meanData elements and gives the user the option to abort
void dataElementsSaved()
mark demand elements as saved
bool isEdgeTypeSaved() const
check if edgeType are saved
GNEDialog::Result askSaveDemandElements(GNEDialog::Result &commonResult) const
warns about unsaved changes in demand elements and gives the user the option to abort
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
GNEDialog::Result askSaveAdditionalElements(GNEDialog::Result &commonResult) const
warns about unsaved changes in additionals and gives the user the option to abort
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
GNEDialog::Result askSaveNetwork(GNEDialog::Result &commonResult) const
warns about unsaved changes in network and gives the user the option to abort
bool isAdditionalsSaved() const
check if additionals are saved
SavingStatus()=delete
invalidate default constructor
void requireSaveDemandElements()
inform that demand elements has to be saved
void edgeTypeSaved()
mark edgeType as saved
GNEDialog::Result askSaveDataElements(GNEDialog::Result &commonResult) const
warns about unsaved changes in data elements and gives the user the option to abort
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database (used for simplify code)
Definition GNENet.cpp:162
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this AttributeCarrier
void setNetworkElementID(const std::string &newID)
set network element id
virtual void computePathElement()=0
implement in children+
void decRef(const std::string &debugMsg="")
Decrease reference.
void incRef(const std::string &debugMsg="")
Increase reference.
An Element which don't belong to GNENet but has influence in the simulation.
const std::vector< const GNETagProperties * > getTagPropertiesByType(const GNETagProperties::Type type) const
get tagProperties associated to the given GNETagProperties::Type (NETWORKELEMENT, ADDITIONALELEMENT,...
bool isContainer() const
return true if tag correspond to a container element
bool isNetworkElement() const
network elements
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
const std::vector< const GNETagProperties * > & getHierarchicalChildren() const
get children of this tag property
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
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:552
const std::string & getID() const
Definition NBEdge.h:1551
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:545
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition NBNode.cpp:533
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition NBNode.cpp:4212
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:3156
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition NBNode.cpp:543
const Position & getPosition() const
Definition NBNode.h:260
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2783
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
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
C++ TraCI client API implementation.
double z() const
Returns the z-position.
Definition Position.h:62
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
A simple triangle defined in 3D.
Definition Triangle.h:35
bool isPositionWithin(const Position &pos) const
check if the given position is within this triangle
Definition Triangle.cpp:53
bool intersectWithShape(const PositionVector &shape) const
check if the given shape is within or intersect with this triangle
Definition Triangle.cpp:68