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-2026 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->requireRecompute();
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->requireRecompute();
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->requireRecompute();
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
1108std::vector<GNEAdditional*>
1110 std::vector<GNEAdditional*> result;
1111 // returns additionals depending of selection
1112 for (const auto& additionalsTags : myAdditionals) {
1113 for (const auto& additional : additionalsTags.second) {
1114 if (additional.second->getTagProperty()->isShapeElement() && !additional.second->isAttributeCarrierSelected()) {
1115 result.push_back(additional.second);
1116 }
1117 }
1118 }
1119 return result;
1120}
1121
1122
1123int
1125 int counter = 0;
1126 for (const auto& additionalsTag : myAdditionals) {
1127 counter += (int)additionalsTag.second.size();
1128 }
1129 return counter;
1130}
1131
1132
1133void
1135 // clear elements in grid
1136 for (const auto& additionalsTags : myAdditionals) {
1137 for (const auto& additional : additionalsTags.second) {
1138 myNet->removeGLObjectFromGrid(additional.second);
1139 }
1140 }
1141 // iterate over myAdditionals and clear all additionals
1142 for (auto& additionals : myAdditionals) {
1143 additionals.second.clear();
1144 }
1145 for (auto& additionals : myAdditionalIDs) {
1146 additionals.second.clear();
1147 }
1148}
1149
1150
1151void
1153 const auto tag = additional->getTagProperty()->getTag();
1154 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1155 if (it == myAdditionalIDs.at(tag).end()) {
1156 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1157 } else {
1158 // remove from container, set new Id, and insert it again
1159 myAdditionalIDs.at(tag).erase(it);
1160 // set microsim ID
1161 additional->setMicrosimID(newID);
1162 myAdditionalIDs.at(tag)[newID] = additional;
1163 }
1164}
1165
1166
1167std::string
1169 // obtain option container
1170 const auto& neteditOptions = OptionsCont::getOptions();
1171 // get prefix
1172 std::string prefix;
1173 if (tag == SUMO_TAG_BUS_STOP) {
1174 prefix = neteditOptions.getString("busStop-prefix");
1175 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1176 prefix = neteditOptions.getString("trainStop-prefix");
1177 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1178 prefix = neteditOptions.getString("containerStop-prefix");
1179 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1180 prefix = neteditOptions.getString("chargingStation-prefix");
1181 } else if (tag == SUMO_TAG_PARKING_AREA) {
1182 prefix = neteditOptions.getString("parkingArea-prefix");
1183 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1184 prefix = neteditOptions.getString("e1Detector-prefix");
1185 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1186 prefix = neteditOptions.getString("e2Detector-prefix");
1187 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1188 prefix = neteditOptions.getString("e3Detector-prefix");
1189 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1190 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1191 } else if (tag == SUMO_TAG_REROUTER) {
1192 prefix = neteditOptions.getString("rerouter-prefix");
1193 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1194 prefix = neteditOptions.getString("calibrator-prefix");
1195 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1196 prefix = neteditOptions.getString("routeProbe-prefix");
1197 } else if (tag == SUMO_TAG_VSS) {
1198 prefix = neteditOptions.getString("vss-prefix");
1199 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1200 prefix = neteditOptions.getString("tractionSubstation-prefix");
1201 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1202 prefix = neteditOptions.getString("overheadWire-prefix");
1203 } else if (tag == SUMO_TAG_POLY) {
1204 prefix = neteditOptions.getString("polygon-prefix");
1205 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1206 prefix = neteditOptions.getString("poi-prefix");
1207 } else if (tag == SUMO_TAG_TAZ) {
1208 prefix = toString(SUMO_TAG_TAZ);
1209 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1210 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1211 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1212 prefix = neteditOptions.getString("jps.obstacle-prefix");
1213 }
1214 int counter = 0;
1215 // check namespaces
1216 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1217 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1218 counter++;
1219 }
1220 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1221 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1222 counter++;
1223 }
1224 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1225 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1226 counter++;
1227 }
1228 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1229 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1230 counter++;
1231 }
1232 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1233 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1234 counter++;
1235 }
1236 } else {
1237 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1238 counter++;
1239 }
1240 }
1241 // return new element ID
1242 return (prefix + "_" + toString(counter));
1243}
1244
1245
1246int
1248 int counter = 0;
1249 for (const auto& additionalsTags : myAdditionals) {
1250 for (const auto& additional : additionalsTags.second) {
1251 if (additional.second->isAttributeCarrierSelected()) {
1252 counter++;
1253 }
1254 }
1255 }
1256 return counter;
1257}
1258
1259
1260int
1262 return getNumberOfSelectedAdditionals() -
1263 // shapes
1264 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1265 // JuPedSims
1266 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1267 // TAZ
1268 getNumberOfSelectedTAZs() -
1269 // wires
1270 getNumberOfSelectedWires();
1271}
1272
1273
1274int
1276 int counter = 0;
1277 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1278 if (poly.second->isAttributeCarrierSelected()) {
1279 counter++;
1280 }
1281 }
1282 return counter;
1283}
1284
1285
1286int
1288 int counter = 0;
1289 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1290 if (walkableArea.second->isAttributeCarrierSelected()) {
1291 counter++;
1292 }
1293 }
1294 return counter;
1295}
1296
1297
1298int
1300 int counter = 0;
1301 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1302 if (obstacle.second->isAttributeCarrierSelected()) {
1303 counter++;
1304 }
1305 }
1306 return counter;
1307}
1308
1309
1310int
1312 int counter = 0;
1313 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1314 if (POI.second->isAttributeCarrierSelected()) {
1315 counter++;
1316 }
1317 }
1318 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1319 if (POILane.second->isAttributeCarrierSelected()) {
1320 counter++;
1321 }
1322 }
1323 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1324 if (POIGEO.second->isAttributeCarrierSelected()) {
1325 counter++;
1326 }
1327 }
1328 return counter;
1329}
1330
1331
1332std::vector<std::string>
1334 std::set<std::string> keys;
1335 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1336 for (const auto& parameter : POI.second->getParameters()->getParametersMap()) {
1337 keys.insert(parameter.first);
1338 }
1339 }
1340 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1341 for (const auto& parameter : POILane.second->getParameters()->getParametersMap()) {
1342 keys.insert(parameter.first);
1343 }
1344 }
1345 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1346 for (const auto& parameter : POIGEO.second->getParameters()->getParametersMap()) {
1347 keys.insert(parameter.first);
1348 }
1349 }
1350 return std::vector<std::string>(keys.begin(), keys.end());
1351}
1352
1353
1354int
1356 int counter = 0;
1357 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1358 if (TAZ.second->isAttributeCarrierSelected()) {
1359 counter++;
1360 }
1361 }
1362 return counter;
1363}
1364
1365
1366int
1368 int counter = 0;
1369 for (const auto& additionalsTags : myAdditionals) {
1370 for (const auto& additional : additionalsTags.second) {
1371 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty()->isWireElement()) {
1372 counter++;
1373 }
1374 }
1375 }
1376 return counter;
1377}
1378
1379
1382 // iterate over all demand elements
1383 for (const auto& TAZSourceSinkTag : myTAZSourceSinks) {
1384 auto it = TAZSourceSinkTag.second.find(sourceSink);
1385 if (it != TAZSourceSinkTag.second.end()) {
1386 return it->second;
1387 }
1388 }
1389 if (hardFail) {
1390 throw ProcessError("Attempted to retrieve non-existant sourceSink (glObject)");
1391 } else {
1392 return nullptr;
1393 }
1394}
1395
1396
1397const std::unordered_map<SumoXMLTag, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>, std::hash<int> >&
1399 return myTAZSourceSinks;
1400}
1401
1402
1403int
1405 int counter = 0;
1406 for (const auto& sourceSinksTag : myTAZSourceSinks) {
1407 counter += (int)sourceSinksTag.second.size();
1408 }
1409 return counter;
1410}
1411
1412
1413void
1415 // iterate over myTAZSourceSinks and clear all sourceSinks
1416 for (auto& sourceSinksTags : myTAZSourceSinks) {
1417 sourceSinksTags.second.clear();
1418 }
1419}
1420
1421
1423GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1424 auto it = myDemandElementIDs.at(type).find(id);
1425 if (it != myDemandElementIDs.at(type).end()) {
1426 return it->second;
1427 }
1428 if (hardFail) {
1429 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1430 } else {
1431 return nullptr;
1432 }
1433}
1434
1435
1437GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1438 for (const auto& type : types) {
1439 auto it = myDemandElementIDs.at(type).find(id);
1440 if (it != myDemandElementIDs.at(type).end()) {
1441 return it->second;
1442 }
1443 }
1444 if (hardFail) {
1445 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1446 } else {
1447 return nullptr;
1448 }
1449}
1450
1451
1454 // iterate over all demand elements
1455 for (const auto& demandElementTag : myDemandElements) {
1456 auto it = demandElementTag.second.find(glObject);
1457 if (it != demandElementTag.second.end()) {
1458 return it->second;
1459 }
1460 }
1461 if (hardFail) {
1462 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1463 } else {
1464 return nullptr;
1465 }
1466}
1467
1468
1469std::vector<GNEDemandElement*>
1471 std::vector<GNEDemandElement*> result;
1472 // returns demand elements depending of selection
1473 for (const auto& demandElementTag : myDemandElements) {
1474 for (const auto& demandElement : demandElementTag.second) {
1475 if (demandElement.second->isAttributeCarrierSelected()) {
1476 result.push_back(demandElement.second);
1477 }
1478 }
1479 }
1480 return result;
1481}
1482
1483
1484const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*>, std::hash<int> >&
1486 return myDemandElements;
1487}
1488
1489
1490std::string
1492 // obtain option container
1493 const auto& neteditOptions = OptionsCont::getOptions();
1494 // get tag property
1495 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag, true);
1496 // get prefix
1497 std::string prefix;
1498 if (tag == SUMO_TAG_ROUTE) {
1499 prefix = neteditOptions.getString("route-prefix");
1500 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1501 prefix = neteditOptions.getString("routeDistribution-prefix");
1502 } else if (tag == SUMO_TAG_VTYPE) {
1503 prefix = neteditOptions.getString("vType-prefix");
1504 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1505 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1506 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1507 prefix = neteditOptions.getString("trip-prefix");
1508 } else if (tagProperty->isVehicle() && !tagProperty->isFlow()) {
1509 prefix = neteditOptions.getString("vehicle-prefix");
1510 } else if (tagProperty->isPerson()) {
1511 if (tagProperty->isFlow()) {
1512 prefix = neteditOptions.getString("personflow-prefix");
1513 } else {
1514 prefix = neteditOptions.getString("person-prefix");
1515 }
1516 } else if (tagProperty->isContainer()) {
1517 if (tagProperty->isFlow()) {
1518 prefix = neteditOptions.getString("containerflow-prefix");
1519 } else {
1520 prefix = neteditOptions.getString("container-prefix");
1521 }
1522 } else if (tagProperty->isFlow()) {
1523 prefix = neteditOptions.getString("flow-prefix");
1524 }
1525 // declare counter
1526 int counter = 0;
1527 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1528 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1529 counter++;
1530 }
1531 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1532 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1533 counter++;
1534 }
1535 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1536 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1537 counter++;
1538 }
1539 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1540 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1541 counter++;
1542 }
1543 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1544 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1545 counter++;
1546 }
1547 } else {
1548 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1549 counter++;
1550 }
1551 }
1552 // return new element ID
1553 return (prefix + "_" + toString(counter));
1554
1555}
1556
1557
1560 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1561 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1562 return it->second;
1563 }
1564 throw ProcessError(TL("Default vType doesn't exist"));
1565}
1566
1567
1568void
1570 // clear elements in grid
1571 for (const auto& demandElementsTags : myDemandElements) {
1572 for (const auto& demandElement : demandElementsTags.second) {
1573 myNet->removeGLObjectFromGrid(demandElement.second);
1574 }
1575 }
1576 // iterate over myDemandElements and clear all demand elements
1577 for (auto& demandElements : myDemandElements) {
1578 demandElements.second.clear();
1579 }
1580 for (auto& demandElements : myDemandElementIDs) {
1581 demandElements.second.clear();
1582 }
1583}
1584
1585
1586void
1588 const auto tag = demandElement->getTagProperty()->getTag();
1589 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1590 if (it == myDemandElementIDs.at(tag).end()) {
1591 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1592 } else {
1593 // remove from container, set new Id, and insert it again
1594 myDemandElementIDs.at(tag).erase(it);
1595 // set microsim ID
1596 demandElement->setMicrosimID(newID);
1597 myDemandElementIDs.at(tag)[newID] = demandElement;
1598 }
1599}
1600
1601
1602void
1604 // get default bucket
1605 auto bucket = myNet->getGNEApplicationWindow()->getFileBucketHandler()->getDefaultBucket(FileBucket::Type::DEMAND);
1606 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1607 GNEVType* defaultVehicleType = new GNEVType(DEFAULT_VTYPE_ID, myNet, bucket, SVC_PASSENGER);
1608 myDemandElements.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1609 myDemandElementIDs.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1610 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1611 bucket->addDefaultVType();
1612
1613 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1614 GNEVType* defaultBikeType = new GNEVType(DEFAULT_BIKETYPE_ID, myNet, bucket, SVC_BICYCLE);
1615 myDemandElements.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1616 myDemandElementIDs.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1617 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1618 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1619 bucket->addDefaultVType();
1620
1621 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1622 GNEVType* defaultTaxiType = new GNEVType(DEFAULT_TAXITYPE_ID, myNet, bucket, SVC_TAXI);
1623 myDemandElements.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1624 myDemandElementIDs.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1625 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1626 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1627 bucket->addDefaultVType();
1628
1629 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1630 GNEVType* defaultRailType = new GNEVType(DEFAULT_RAILTYPE_ID, myNet, bucket, SVC_RAIL);
1631 myDemandElements.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1632 myDemandElementIDs.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1633 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1634 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1635 bucket->addDefaultVType();
1636
1637 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1638 GNEVType* defaultPersonType = new GNEVType(DEFAULT_PEDTYPE_ID, myNet, bucket, SVC_PEDESTRIAN);
1639 myDemandElements.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1640 myDemandElementIDs.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1641 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1642 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1643 bucket->addDefaultVType();
1644
1645 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1646 GNEVType* defaultContainerType = new GNEVType(DEFAULT_CONTAINERTYPE_ID, myNet, bucket, SVC_IGNORING);
1647 myDemandElements.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1648 myDemandElementIDs.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1649 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1650 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1651 bucket->addDefaultVType();
1652}
1653
1654
1655bool
1657 if (myDemandElements.at(GNE_TAG_TRIP_JUNCTIONS).size() > 0) {
1658 return true;
1659 } else if (myDemandElements.at(GNE_TAG_FLOW_JUNCTIONS).size() > 0) {
1660 return true;
1661 } else {
1662 // iterate over all tags and check if start or ends in junctions
1663 for (const auto& mapValue : myDemandElements) {
1664 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(mapValue.first, true);
1665 if ((tagProperty->planFromJunction() || tagProperty->planToJunction()) && (myDemandElements.at(tagProperty->getTag()).size() > 0)) {
1666 return true;
1667 }
1668 }
1669 }
1670 return false;
1671}
1672
1673
1674int
1676 return myStopIndex++;
1677}
1678
1679
1680int
1682 int counter = 0;
1683 for (const auto& demandElementsTags : myDemandElements) {
1684 for (const auto& demandElement : demandElementsTags.second) {
1685 if (demandElement.second->isAttributeCarrierSelected()) {
1686 counter++;
1687 }
1688 }
1689 }
1690 return counter;
1691}
1692
1693
1694int
1696 int counter = 0;
1697 // iterate over routes
1698 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1699 if (route.second->isAttributeCarrierSelected()) {
1700 counter++;
1701 }
1702 }
1703 // iterate over vehicles with embedded routes
1704 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1705 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1706 counter++;
1707 }
1708 }
1709 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1710 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1711 counter++;
1712 }
1713 }
1714 return counter;
1715}
1716
1717
1718int
1720 int counter = 0;
1721 // iterate over all vehicles and flows
1722 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1723 if (vehicle.second->isAttributeCarrierSelected()) {
1724 counter++;
1725 }
1726 }
1727 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1728 if (trip.second->isAttributeCarrierSelected()) {
1729 counter++;
1730 }
1731 }
1732 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1733 if (vehicle.second->isAttributeCarrierSelected()) {
1734 counter++;
1735 }
1736 }
1737 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1738 if (flow.second->isAttributeCarrierSelected()) {
1739 counter++;
1740 }
1741 }
1742 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1743 if (flow.second->isAttributeCarrierSelected()) {
1744 counter++;
1745 }
1746 }
1747 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1748 if (flow.second->isAttributeCarrierSelected()) {
1749 counter++;
1750 }
1751 }
1752 return counter;
1753}
1754
1755
1756int
1758 int counter = 0;
1759 // iterate over all persons
1760 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1761 if (person.second->isAttributeCarrierSelected()) {
1762 counter++;
1763 }
1764 }
1765 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1766 if (personFlow.second->isAttributeCarrierSelected()) {
1767 counter++;
1768 }
1769 }
1770 return counter;
1771}
1772
1773
1774int
1776 int counter = 0;
1777 // iterate over all person plans
1778 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1779 for (const auto& personPlan : person.second->getChildDemandElements()) {
1780 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1781 counter++;
1782 }
1783 }
1784 }
1785 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1786 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1787 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1788 counter++;
1789 }
1790 }
1791 }
1792 return counter;
1793}
1794
1795
1796int
1798 int counter = 0;
1799 // iterate over all person plans
1800 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1801 for (const auto& personPlan : person.second->getChildDemandElements()) {
1802 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1803 counter++;
1804 }
1805 }
1806 }
1807 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1808 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1809 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1810 counter++;
1811 }
1812 }
1813 }
1814 return counter;
1815}
1816
1817
1818int
1820 int counter = 0;
1821 // iterate over all person plans
1822 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1823 for (const auto& personPlan : person.second->getChildDemandElements()) {
1824 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1825 counter++;
1826 }
1827 }
1828 }
1829 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1830 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1831 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1832 counter++;
1833 }
1834 }
1835 }
1836 return counter;
1837}
1838
1839
1840int
1842 int counter = 0;
1843 // iterate over all containers
1844 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1845 if (container.second->isAttributeCarrierSelected()) {
1846 counter++;
1847 }
1848 }
1849 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1850 if (containerFlow.second->isAttributeCarrierSelected()) {
1851 counter++;
1852 }
1853 }
1854 return counter;
1855}
1856
1857
1858int
1860 int counter = 0;
1861 // iterate over all container plans
1862 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1863 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1864 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1865 counter++;
1866 }
1867 }
1868 }
1869 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1870 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1871 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1872 counter++;
1873 }
1874 }
1875 }
1876 return counter;
1877}
1878
1879
1880int
1882 int counter = 0;
1883 // iterate over all container plans
1884 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1885 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1886 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1887 counter++;
1888 }
1889 }
1890 }
1891 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1892 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1893 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1894 counter++;
1895 }
1896 }
1897 }
1898 return counter;
1899}
1900
1901
1902int
1904 int counter = 0;
1905 // iterate over routes
1906 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1907 if (route.second->isAttributeCarrierSelected()) {
1908 counter++;
1909 }
1910 }
1911 // vehicles
1912 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1913 for (const auto& stop : trip.second->getChildDemandElements()) {
1914 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1915 counter++;
1916 }
1917 }
1918 }
1919 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1920 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1921 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1922 counter++;
1923 }
1924 }
1925 }
1926 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1927 for (const auto& stop : flow.second->getChildDemandElements()) {
1928 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1929 counter++;
1930 }
1931 }
1932 }
1933 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1934 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1935 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1936 counter++;
1937 }
1938 }
1939 }
1940 // persons
1941 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1942 for (const auto& personPlan : person.second->getChildDemandElements()) {
1943 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1944 counter++;
1945 }
1946 }
1947 }
1948 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1949 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1950 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1951 counter++;
1952 }
1953 }
1954 }
1955 // containers
1956 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1957 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1958 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1959 counter++;
1960 }
1961 }
1962 }
1963 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1964 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1965 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1966 counter++;
1967 }
1968 }
1969 }
1970 return counter;
1971}
1972
1973
1975GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1976 for (const auto& dataSet : myDataSets) {
1977 if (dataSet.second->getID() == id) {
1978 return dataSet.second;
1979 }
1980 }
1981 if (hardFail) {
1982 throw ProcessError("Attempted to retrieve non-existant data set");
1983 } else {
1984 return nullptr;
1985 }
1986}
1987
1988
1989const std::map<const std::string, GNEDataSet*>&
1991 return myDataSets;
1992}
1993
1994
1995std::string
1997 // get prefix
1998 const auto prefix = OptionsCont::getOptions().getString("dataSet-prefix");
1999 int counter = 0;
2000 while (retrieveDataSet(prefix + "_" + toString(counter), false) != nullptr) {
2001 counter++;
2002 }
2003 return (prefix + "_" + toString(counter));
2004}
2005
2006
2009 if (myDataIntervals.count(AC)) {
2010 return myDataIntervals.at(AC);
2011 } else if (hardFail) {
2012 throw ProcessError("Attempted to retrieve non-existant data interval");
2013 } else {
2014 return nullptr;
2015 }
2016}
2017
2018
2019const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
2021 return myDataIntervals;
2022}
2023
2024
2025void
2027 if (myDataIntervals.count(AC) > 0) {
2028 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
2029 } else {
2030 myDataIntervals[AC] = dataInterval;
2031 }
2032 // mark interval toolbar for update
2033 myNet->getViewNet()->getIntervalBar().markForUpdate();
2034}
2035
2036
2037void
2039 const auto finder = myDataIntervals.find(dataInterval);
2040 if (finder == myDataIntervals.end()) {
2041 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
2042 } else {
2043 myDataIntervals.erase(finder);
2044 }
2045 // remove it from inspected elements and GNEElementTree
2046 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
2047 dataInterval->unmarkForDrawingFront();
2048 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
2049 // mark interval toolbar for update
2050 myNet->getViewNet()->getIntervalBar().markForUpdate();
2051}
2052
2053
2056 // iterate over all genericDatas
2057 for (const auto& genericDataTag : myGenericDatas) {
2058 auto it = genericDataTag.second.find(glObject);
2059 if (it != genericDataTag.second.end()) {
2060 return it->second;
2061 }
2062 }
2063 if (hardFail) {
2064 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
2065 } else {
2066 return nullptr;
2067 }
2068}
2069
2070
2071std::vector<GNEGenericData*>
2073 std::vector<GNEGenericData*> result;
2074 // returns generic datas depending of selection
2075 for (const auto& genericDataTag : myGenericDatas) {
2076 for (const auto& genericData : genericDataTag.second) {
2077 if (genericData.second->isAttributeCarrierSelected()) {
2078 result.push_back(genericData.second);
2079 }
2080 }
2081 }
2082 return result;
2083}
2084
2085
2086const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> >&
2088 return myGenericDatas;
2089}
2090
2091
2092std::vector<GNEGenericData*>
2093GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2094 // declare generic data vector
2095 std::vector<GNEGenericData*> genericDatas;
2096 // iterate over all data sets
2097 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2098 // check interval
2099 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2100 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2101 genericDatas.push_back(genericData.second);
2102 }
2103 }
2104 return genericDatas;
2105}
2106
2107
2108int
2110 int counter = 0;
2111 // iterate over all generic datas
2112 for (const auto& genericDataTag : myGenericDatas) {
2113 counter += (int)genericDataTag.second.size();
2114 }
2115 return counter;
2116}
2117
2118
2119int
2121 int counter = 0;
2122 // iterate over all edgeDatas
2123 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2124 if (genericData.second->isAttributeCarrierSelected()) {
2125 counter++;
2126 }
2127 }
2128 return counter;
2129}
2130
2131
2132int
2134 int counter = 0;
2135 // iterate over all edgeDatas
2136 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2137 if (genericData.second->isAttributeCarrierSelected()) {
2138 counter++;
2139 }
2140 }
2141 return counter;
2142}
2143
2144
2145int
2147 int counter = 0;
2148 // iterate over all edgeDatas
2149 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2150 if (genericData.second->isAttributeCarrierSelected()) {
2151 counter++;
2152 }
2153 }
2154 return counter;
2155}
2156
2157
2158void
2160 if (myGenericDatas.at(genericData->getTagProperty()->getTag()).count(genericData->getGUIGlObject()) > 0) {
2161 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2162 } else {
2163 myGenericDatas.at(genericData->getTagProperty()->getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2164 }
2165 // mark interval toolbar for update
2166 myNet->getViewNet()->getIntervalBar().markForUpdate();
2167}
2168
2169
2170void
2172 const auto finder = myGenericDatas.at(genericData->getTagProperty()->getTag()).find(genericData);
2173 if (finder == myGenericDatas.at(genericData->getTagProperty()->getTag()).end()) {
2174 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2175 } else {
2176 myGenericDatas.at(genericData->getTagProperty()->getTag()).erase(finder);
2177 }
2178 // remove it from inspected elements and GNEElementTree
2179 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2180 genericData->unmarkForDrawingFront();
2181 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2182 // delete path element
2183 myNet->getDataPathManager()->removePath(genericData);
2184 // mark interval toolbar for update
2185 myNet->getViewNet()->getIntervalBar().markForUpdate();
2186}
2187
2188
2189std::set<std::string>
2190GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2191 // declare solution
2192 std::set<std::string> attributesSolution;
2193 // declare generic data vector
2194 std::vector<GNEGenericData*> genericDatas;
2195 // iterate over all data sets
2196 for (const auto& interval : myDataIntervals) {
2197 // check interval
2198 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2199 // iterate over generic datas
2200 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2201 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2202 genericDatas.push_back(genericData);
2203 }
2204 }
2205 }
2206 }
2207 // iterate over generic datas
2208 for (const auto& genericData : genericDatas) {
2209 for (const auto& attribute : genericData->getParametersMap()) {
2210 attributesSolution.insert(attribute.first);
2211 }
2212 }
2213 return attributesSolution;
2214}
2215
2216
2217std::set<std::string>
2218GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2219 const std::string& beginStr, const std::string& endStr) const {
2220 // declare solution
2221 std::set<std::string> attributesSolution;
2222 // vector of data sets and intervals
2223 std::vector<GNEDataSet*> dataSets;
2224 std::vector<GNEDataInterval*> dataIntervals;
2225 // get dataSet
2226 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2227 // if dataSetID is empty, return all parameters
2228 if (dataSetID.empty()) {
2229 // add all data sets
2230 dataSets.reserve(myDataSets.size());
2231 for (const auto& dataSet : myDataSets) {
2232 dataSets.push_back(dataSet.second);
2233 }
2234 } else if (retrievedDataSet) {
2235 dataSets.push_back(retrievedDataSet);
2236 } else {
2237 return attributesSolution;
2238 }
2239 // now continue with data intervals
2240 int numberOfIntervals = 0;
2241 for (const auto& dataSet : dataSets) {
2242 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2243 }
2244 // resize dataIntervals
2245 dataIntervals.reserve(numberOfIntervals);
2246 // add intervals
2247 for (const auto& dataSet : dataSets) {
2248 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2249 // continue depending of begin and end
2250 if (beginStr.empty() && endStr.empty()) {
2251 dataIntervals.push_back(dataInterval.second);
2252 } else if (endStr.empty()) {
2253 // parse begin
2254 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2255 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2256 dataIntervals.push_back(dataInterval.second);
2257 }
2258 } else if (beginStr.empty()) {
2259 // parse end
2260 const double end = GNEAttributeCarrier::parse<double>(endStr);
2261 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2262 dataIntervals.push_back(dataInterval.second);
2263 }
2264 } else {
2265 // parse both begin end
2266 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2267 const double end = GNEAttributeCarrier::parse<double>(endStr);
2268 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2269 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2270 dataIntervals.push_back(dataInterval.second);
2271 }
2272 }
2273 }
2274 }
2275 // finally iterate over intervals and get attributes
2276 for (const auto& dataInterval : dataIntervals) {
2277 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2278 // check generic data tag
2279 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2280 for (const auto& attribute : genericData->getParametersMap()) {
2281 attributesSolution.insert(attribute.first);
2282 }
2283 }
2284 }
2285 }
2286 return attributesSolution;
2287}
2288
2289
2291GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2292 for (const auto& meanData : myMeanDatas.at(type)) {
2293 if (meanData.second->getID() == id) {
2294 return meanData.second;
2295 }
2296 }
2297 if (hardFail) {
2298 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2299 } else {
2300 return nullptr;
2301 }
2302}
2303
2304
2305const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> >&
2307 return myMeanDatas;
2308}
2309
2310
2311int
2313 return myNumberOfMeanDataElements;
2314}
2315
2316
2317void
2319 // iterate over myMeanDatas and clear all meanDatas
2320 for (auto& meanDatas : myMeanDatas) {
2321 meanDatas.second.clear();
2322 }
2323}
2324
2325
2326void
2328 const auto tag = meanData->getTagProperty()->getTag();
2329 const auto it = myMeanDatas.at(tag).find(meanData->getID());
2330 if (it == myMeanDatas.at(tag).end()) {
2331 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' doesn't exist in AttributeCarriers.meanDatas");
2332 } else {
2333 // remove from container, set new Id, and insert it again
2334 myMeanDatas.at(tag).erase(it);
2335 myMeanDatas.at(tag)[newID] = meanData;
2336 }
2337}
2338
2339
2340std::string
2342 // obtain option container
2343 const auto& neteditOptions = OptionsCont::getOptions();
2344 // get prefix
2345 std::string prefix;
2346 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2347 prefix = neteditOptions.getString("meanDataEdge-prefix");
2348 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2349 prefix = neteditOptions.getString("meanDataLane-prefix");
2350 }
2351 int counter = 0;
2352 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2353 counter++;
2354 }
2355 return (prefix + "_" + toString(counter));
2356}
2357
2358
2359void
2361 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2362 registerJunction(junction);
2363}
2364
2365
2366void
2368 // remove it from inspected elements and GNEElementTree
2369 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2370 junction->unmarkForDrawingFront();
2371 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2372 // Remove from grid and container
2373 myNet->removeGLObjectFromGrid(junction);
2374 myJunctions.erase(junction->getMicrosimID());
2375 myNumberOfNetworkElements--;
2376 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2377 junction->decRef("GNENet::deleteSingleJunction");
2378 junction->setResponsible(true);
2379}
2380
2381
2382void
2384 // get pointer to create edge frame
2385 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2386 // insert in myEdgeTypes
2387 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2388 myNumberOfNetworkElements++;
2389 // update edge selector
2390 if (myNet->getViewParent()->getCreateEdgeFrame()->shown()) {
2391 myNet->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2392 }
2393 // set current edge type inspected
2394 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2395}
2396
2397
2398void
2400 // get pointer to create edge frame
2401 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2402 // remove it from inspected elements and GNEElementTree
2403 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2404 edgeType->unmarkForDrawingFront();
2405 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2406 // remove from edge types
2407 myEdgeTypes.erase(edgeType->getMicrosimID());
2408 myNumberOfNetworkElements--;
2409 // check if this is the selected edge type in edgeSelector
2410 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2411 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2412 }
2413 // update edge selector
2414 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2415}
2416
2417
2418void
2420 NBEdge* nbe = edge->getNBEdge();
2421 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2422 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2423 nbe->getFromNode()->addOutgoingEdge(nbe);
2424 nbe->getToNode()->addIncomingEdge(nbe);
2425 // register edge
2426 registerEdge(edge);
2427}
2428
2429
2430void
2432 // remove it from inspected elements and GNEElementTree
2433 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2434 edge->unmarkForDrawingFront();
2435 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2436 // remove edge from visual grid and container
2437 myNet->removeGLObjectFromGrid(edge);
2438 myEdges.erase(edge->getMicrosimID());
2439 myNumberOfNetworkElements--;
2440 // remove all lanes
2441 for (const auto& lane : edge->getChildLanes()) {
2442 deleteLane(lane);
2443 }
2444 // extract edge of district container
2445 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2446 edge->decRef("GNENet::deleteSingleEdge");
2447 edge->setResponsible(true);
2448 // Remove refrences from GNEJunctions
2450 edge->getToJunction()->removeIncomingGNEEdge(edge);
2451 // update boundaries of both junctions (to remove it from Grid)
2454 // get template editor
2455 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewParent()->getInspectorFrame()->getTemplateEditor();
2456 // check if we have to remove template
2457 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2458 templateEditor->setEdgeTemplate(nullptr);
2459 }
2460}
2461
2462
2463void
2465 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2466 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2467 } else {
2468 myLanes[lane->getGUIGlObject()] = lane;
2469 myNumberOfNetworkElements++;
2470 }
2471}
2472
2473
2474void
2476 const auto finder = myLanes.find(lane->getGUIGlObject());
2477 if (finder == myLanes.end()) {
2478 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2479 } else {
2480 myLanes.erase(finder);
2481 myNumberOfNetworkElements--;
2482 // remove it from inspected elements and GNEElementTree
2483 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2484 lane->unmarkForDrawingFront();
2485 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2486 }
2487}
2488
2489
2490void
2492 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2493 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2494 } else {
2495 myCrossings[crossing->getGUIGlObject()] = crossing;
2496 myNumberOfNetworkElements++;
2497 }
2498}
2499
2500
2501void
2503 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2504 if (finder == myCrossings.end()) {
2505 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2506 } else {
2507 myCrossings.erase(finder);
2508 myNumberOfNetworkElements--;
2509 // remove it from inspected elements and GNEElementTree
2510 if (myNet->getViewNet()) {
2511 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2512 crossing->unmarkForDrawingFront();
2513 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2514 }
2515 }
2516}
2517
2518
2519void
2521 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2522 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2523 } else {
2524 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2525 myNumberOfNetworkElements++;
2526 }
2527}
2528
2529
2530void
2532 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2533 if (finder == myWalkingAreas.end()) {
2534 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2535 } else {
2536 myWalkingAreas.erase(finder);
2537 myNumberOfNetworkElements--;
2538 // remove it from inspected elements and GNEElementTree
2539 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2540 walkingArea->unmarkForDrawingFront();
2541 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2542 }
2543}
2544
2545
2546void
2548 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2549 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2550 } else {
2551 myConnections[connection->getGUIGlObject()] = connection;
2552 myNumberOfNetworkElements++;
2553 }
2554}
2555
2556
2557void
2559 const auto finder = myConnections.find(connection->getGUIGlObject());
2560 if (finder == myConnections.end()) {
2561 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2562 } else {
2563 myConnections.erase(finder);
2564 myNumberOfNetworkElements--;
2565 // remove it from inspected elements and GNEElementTree
2566 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2567 connection->unmarkForDrawingFront();
2568 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2569 }
2570}
2571
2572
2573void
2575 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2576 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getMicrosimID() + "' already exist");
2577 } else {
2578 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2579 myNumberOfNetworkElements++;
2580 }
2581}
2582
2583
2584void
2586 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2587 if (finder == myInternalLanes.end()) {
2588 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2589 } else {
2590 myInternalLanes.erase(finder);
2591 myNumberOfNetworkElements--;
2592 }
2593}
2594
2595
2596void
2598 const auto tag = additional->getTagProperty()->getTag();
2599 if (myAdditionals.at(tag).count(additional) > 0) {
2600 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2601 } else {
2602 // insert in both containers
2603 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2604 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2605 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2606 }
2607 myNumberOfNetworkElements++;
2608 // insert AC in fileBucket (use this function ton maintain integrity in options)
2609 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(additional);
2610 // add element in grid
2611 myNet->addGLObjectIntoGrid(additional);
2612 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2613 if (myNet->isUpdateGeometryEnabled()) {
2614 additional->updateGeometry();
2615 }
2616 // additionals has to be saved
2617 myNet->getSavingStatus()->requireSaveAdditionals();
2618 }
2619}
2620
2621
2622void
2624 const auto tag = additional->getTagProperty()->getTag();
2625 // find demanElement in additionalTag
2626 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2627 // check if additional was previously inserted
2628 if (itFind == myAdditionals.at(tag).end()) {
2629 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2630 } else {
2631 // remove from both container
2632 myAdditionals.at(tag).erase(itFind);
2633 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2634 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2635 }
2636 myNumberOfNetworkElements--;
2637 // remove AC from fileBucket (use this function ton maintain integrity in options)
2638 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(additional);
2639 // remove it from inspected elements and GNEElementTree
2640 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2641 additional->unmarkForDrawingFront();
2642 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2643 // remove element from grid
2644 myNet->removeGLObjectFromGrid(additional);
2645 // delete path element
2646 myNet->getNetworkPathManager()->removePath(additional);
2647 // additionals has to be saved
2648 myNet->getSavingStatus()->requireSaveAdditionals();
2649 }
2650}
2651
2652
2653
2654
2655void
2657 const auto sourceSinkTag = sourceSink->getTagProperty()->getTag();
2658 if (myTAZSourceSinks.at(sourceSinkTag).count(sourceSink) > 0) {
2659 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' already exist");
2660 } else {
2661 myTAZSourceSinks.at(sourceSinkTag)[sourceSink] = sourceSink;
2662 myNumberOfNetworkElements++;
2663 // insert AC in fileBucket (use this function ton maintain integrity in options)
2664 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(sourceSink);
2665 // additionals has to be saved
2666 myNet->getSavingStatus()->requireSaveAdditionals();
2667 }
2668}
2669
2670
2671void
2673 const auto tag = sourceSink->getTagProperty()->getTag();
2674 // find demanElement in additionalTag
2675 auto itFind = myTAZSourceSinks.at(tag).find(sourceSink);
2676 // check if sourceSink was previously inserted
2677 if (itFind == myTAZSourceSinks.at(tag).end()) {
2678 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' wasn't previously inserted");
2679 } else {
2680 // remove from both container
2681 myTAZSourceSinks.at(tag).erase(itFind);
2682 myNumberOfNetworkElements--;
2683 // remove AC from fileBucket (use this function ton maintain integrity in options)
2684 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(sourceSink);
2685 // remove it from inspected elements and GNEElementTree
2686 myNet->getViewNet()->getInspectedElements().uninspectAC(sourceSink);
2687 sourceSink->unmarkForDrawingFront();
2688 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(sourceSink);
2689 // additionals has to be saved
2690 myNet->getSavingStatus()->requireSaveAdditionals();
2691 }
2692}
2693
2694
2695void
2697 const auto tag = demandElement->getTagProperty()->getTag();
2698 if (myDemandElements.at(tag).count(demandElement) > 0) {
2699 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2700 } else {
2701 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2702 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2703 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2704 }
2705 myNumberOfDemandElements++;
2706 // insert AC in fileBucket (use this function ton maintain integrity in options)
2707 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(demandElement);
2708 // add element in grid
2709 myNet->addGLObjectIntoGrid(demandElement);
2710 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2711 if (myNet->isUpdateGeometryEnabled()) {
2712 demandElement->updateGeometry();
2713 }
2714 // compute path element
2715 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2716 demandElement->computePathElement();
2717 }
2718 // update demand elements frames
2719 updateDemandElementFrames(demandElement->getTagProperty());
2720 // demandElements has to be saved
2721 myNet->getSavingStatus()->requireSaveDemandElements();
2722 }
2723}
2724
2725
2726void
2728 const auto tag = demandElement->getTagProperty()->getTag();
2729 auto viewParent = myNet->getViewParent();
2730 // find demanElement in demandElementTag
2731 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2732 // check if demandElement was previously inserted
2733 if (itFind == myDemandElements.at(tag).end()) {
2734 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2735 } else {
2736 // erase it from container
2737 myDemandElements.at(tag).erase(itFind);
2738 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2739 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2740 }
2741 myNumberOfDemandElements--;
2742 // remove AC from fileBucket (use this function ton maintain integrity in options)
2743 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(demandElement);
2744 // remove element from grid
2745 myNet->removeGLObjectFromGrid(demandElement);
2746 // remove it from inspected elements and GNEElementTree
2747 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2748 demandElement->unmarkForDrawingFront();
2749 // if is the last inserted route, remove it from GNEViewNet
2750 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2751 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2752 }
2753 // delete path element
2754 myNet->getDemandPathManager()->removePath(demandElement);
2755 // check if update demand elements frames
2756 if (updateFrames) {
2757 updateDemandElementFrames(demandElement->getTagProperty());
2758 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2759 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2760 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2761 // update distribution frames
2762 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2763 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2764 }
2765 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2766 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2767 }
2768 // special case for distribution references
2769 if (demandElement->getTagProperty()->getTag() == GNE_TAG_VTYPEREF) {
2770 viewParent->getTypeDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2771 }
2772 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
2773 viewParent->getRouteDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2774 }
2775 }
2776 // demandElements has to be saved
2777 myNet->getSavingStatus()->requireSaveDemandElements();
2778 }
2779}
2780
2781
2782void
2784 if (myDataSets.count(dataSet->getID()) > 0) {
2785 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2786 } else {
2787 myDataSets[dataSet->getID()] = dataSet;
2788 myNumberOfDataElements++;
2789 // insert AC in fileBucket (use this function ton maintain integrity in options)
2790 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(dataSet);
2791 // dataSets has to be saved
2792 myNet->getSavingStatus()->requireSaveDataElements();
2793 // mark interval toolbar for update
2794 myNet->getViewNet()->getIntervalBar().markForUpdate();
2795 }
2796}
2797
2798
2799void
2801 const auto finder = myDataSets.find(dataSet->getID());
2802 if (finder == myDataSets.end()) {
2803 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2804 } else {
2805 myDataSets.erase(finder);
2806 myNumberOfDataElements--;
2807 // remove AC from fileBucket (use this function ton maintain integrity in options)
2808 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(dataSet);
2809 // remove it from inspected elements and GNEElementTree
2810 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2811 dataSet->unmarkForDrawingFront();
2812 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2813 // dataSets has to be saved
2814 myNet->getSavingStatus()->requireSaveDataElements();
2815 // mark interval toolbar for update
2816 myNet->getViewNet()->getIntervalBar().markForUpdate();
2817 }
2818}
2819
2820
2821void
2823 if (myMeanDatas.at(meanData->getTagProperty()->getTag()).count(meanData->getID()) > 0) {
2824 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2825 } else {
2826 myMeanDatas.at(meanData->getTagProperty()->getTag()).insert(std::make_pair(meanData->getID(), meanData));
2827 myNumberOfMeanDataElements++;
2828 // insert AC in fileBucket (use this function ton maintain integrity in options)
2829 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(meanData);
2830 // meanDatas has to be saved
2831 myNet->getSavingStatus()->requireSaveMeanDatas();
2832 }
2833}
2834
2835
2836void
2838 // find demanElement in meanDataTag
2839 auto itFind = myMeanDatas.at(meanData->getTagProperty()->getTag()).find(meanData->getID());
2840 // check if meanData was previously inserted
2841 if (itFind == myMeanDatas.at(meanData->getTagProperty()->getTag()).end()) {
2842 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2843 } else {
2844 // remove from container
2845 myMeanDatas.at(meanData->getTagProperty()->getTag()).erase(itFind);
2846 myNumberOfMeanDataElements--;
2847 // remove AC from fileBucket (use this function ton maintain integrity in options)
2848 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(meanData);
2849 // remove it from inspected elements and GNEElementTree
2850 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2851 meanData->unmarkForDrawingFront();
2852 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2853 // remove element from grid
2854 myNet->removeGLObjectFromGrid(meanData);
2855 // meanDatas has to be saved
2856 myNet->getSavingStatus()->requireSaveMeanDatas();
2857 }
2858}
2859
2860
2861void
2863 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2864 // continue depending of demand mode
2865 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2867 if (tagProperty->isType()) {
2868 myNet->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2869 }
2870 break;
2872 if (tagProperty->isType()) {
2873 myNet->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2874 }
2875 break;
2877 if (tagProperty->isType()) {
2878 myNet->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2879 }
2880 break;
2882 if (tagProperty->isRoute()) {
2883 myNet->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2884 }
2885 break;
2887 if (tagProperty->isType()) {
2888 myNet->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2889 }
2890 break;
2892 if (tagProperty->isPerson()) {
2893 myNet->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2894 }
2895 break;
2897 if (tagProperty->isType()) {
2898 myNet->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2899 }
2900 break;
2902 if (tagProperty->isContainer()) {
2903 myNet->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2904 }
2905 break;
2907 myNet->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2908 break;
2909 default:
2910 // nothing to update
2911 break;
2912 }
2913 }
2914}
2915
2916
2917void
2919 // fill network elements
2920 if (tag->getTag() == SUMO_TAG_JUNCTION) {
2921 for (const auto& junction : myJunctions) {
2922 ACs.push_back(junction.second);
2923 }
2924 }
2925 if (tag->getTag() == SUMO_TAG_EDGE) {
2926 for (const auto& edge : myEdges) {
2927 ACs.push_back(edge.second);
2928 }
2929 }
2930 if (tag->getTag() == SUMO_TAG_LANE) {
2931 for (const auto& lane : myLanes) {
2932 ACs.push_back(lane.second);
2933 }
2934 }
2935 if (tag->getTag() == SUMO_TAG_CONNECTION) {
2936 for (const auto& connection : myConnections) {
2937 ACs.push_back(connection.second);
2938 }
2939 }
2940 if (tag->getTag() == SUMO_TAG_CROSSING) {
2941 for (const auto& crossing : myCrossings) {
2942 ACs.push_back(crossing.second);
2943 }
2944 }
2945 if (tag->getTag() == SUMO_TAG_WALKINGAREA) {
2946 for (const auto& walkingArea : myWalkingAreas) {
2947 ACs.push_back(walkingArea.second);
2948 }
2949 }
2950 // fill additional elements
2951 if (tag->isAdditionalElement()) {
2952 for (const auto& additionalTag : myAdditionals) {
2953 if (additionalTag.first == tag->getTag()) {
2954 for (const auto& additional : additionalTag.second) {
2955 ACs.push_back(additional.second);
2956 }
2957 }
2958 }
2959 }
2960 // fill demand elements
2961 if (tag->isDemandElement()) {
2962 for (const auto& demandElementTag : myDemandElements) {
2963 if (demandElementTag.first == tag->getTag()) {
2964 for (const auto& demandElemet : demandElementTag.second) {
2965 ACs.push_back(demandElemet.second);
2966 }
2967 }
2968 }
2969 }
2970 // fill data elements
2971 if (tag->isDataElement()) {
2972 if (tag->getTag() == SUMO_TAG_DATASET) {
2973 for (const auto& dataSet : myDataSets) {
2974 ACs.push_back(dataSet.second);
2975 }
2976 }
2977 if (tag->getTag() == SUMO_TAG_DATAINTERVAL) {
2978 for (const auto& dataInterval : myDataIntervals) {
2979 ACs.push_back(dataInterval.second);
2980 }
2981 }
2982 for (const auto& genericDataTag : myGenericDatas) {
2983 if (genericDataTag.first == tag->getTag()) {
2984 for (const auto& genericData : genericDataTag.second) {
2985 ACs.push_back(genericData.second);
2986 }
2987 }
2988 }
2989 for (const auto& meanDataTag : myMeanDatas) {
2990 if (meanDataTag.first == tag->getTag()) {
2991 for (const auto& meanData : meanDataTag.second) {
2992 ACs.push_back(meanData.second);
2993 }
2994 }
2995 }
2996 }
2997 // iterate over children
2998 for (const auto child : tag->getHierarchicalChildren()) {
2999 retrieveAttributeCarriersRecursively(child, ACs);
3000 }
3001}
3002
3003// ---------------------------------------------------------------------------
3004// GNENetHelper::GNETagSelector - methods
3005// ---------------------------------------------------------------------------
3006
3008 myNet(net) {
3009}
3010
3011
3012void
3014 // network
3015 myTemplates[SUMO_TAG_CROSSING] = new GNECrossing(myNet);
3016 // special case for edge type
3017 myEdgeType = new GNEEdgeType(myNet);
3018 myTemplates[SUMO_TAG_TYPE] = myEdgeType;
3019 // additionals
3020 myTemplates[SUMO_TAG_BUS_STOP] = GNEBusStop::buildBusStop(myNet);
3021 myTemplates[SUMO_TAG_TRAIN_STOP] = GNEBusStop::buildTrainStop(myNet);
3022 myTemplates[SUMO_TAG_ACCESS] = new GNEAccess(myNet);
3023 myTemplates[SUMO_TAG_CONTAINER_STOP] = new GNEContainerStop(myNet);
3024 myTemplates[SUMO_TAG_CHARGING_STATION] = new GNEChargingStation(myNet);
3025 myTemplates[SUMO_TAG_PARKING_AREA] = new GNEParkingArea(myNet);
3026 myTemplates[SUMO_TAG_PARKING_SPACE] = new GNEParkingSpace(myNet);
3027 myTemplates[SUMO_TAG_INDUCTION_LOOP] = new GNEInductionLoopDetector(myNet);
3032 myTemplates[SUMO_TAG_DET_EXIT] = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet);
3034 myTemplates[SUMO_TAG_VSS] = new GNEVariableSpeedSign(myNet);
3035 myTemplates[SUMO_TAG_STEP] = new GNEVariableSpeedSignStep(myNet);
3036 myTemplates[SUMO_TAG_CALIBRATOR] = new GNECalibrator(SUMO_TAG_CALIBRATOR, myNet);
3038 myTemplates[GNE_TAG_CALIBRATOR_FLOW] = new GNECalibratorFlow(myNet);
3039 myTemplates[SUMO_TAG_REROUTER] = new GNERerouter(myNet);
3040 myTemplates[SUMO_TAG_INTERVAL] = new GNERerouterInterval(myNet);
3041 myTemplates[SUMO_TAG_CLOSING_REROUTE] = new GNEClosingReroute(myNet);
3042 myTemplates[SUMO_TAG_CLOSING_LANE_REROUTE] = new GNEClosingLaneReroute(myNet);
3043 myTemplates[SUMO_TAG_DEST_PROB_REROUTE] = new GNEDestProbReroute(myNet);
3044 myTemplates[SUMO_TAG_PARKING_AREA_REROUTE] = new GNEParkingAreaReroute(myNet);
3045 myTemplates[SUMO_TAG_ROUTE_PROB_REROUTE] = new GNERouteProbReroute(myNet);
3046 myTemplates[SUMO_TAG_ROUTEPROBE] = new GNERouteProbe(myNet);
3047 myTemplates[SUMO_TAG_VAPORIZER] = new GNEVaporizer(myNet);
3048 // symbols
3049 myTemplates[GNE_TAG_REROUTER_SYMBOL] = new GNERerouterSymbol(myNet);
3050 myTemplates[GNE_TAG_VSS_SYMBOL] = new GNEVariableSpeedSignSymbol(myNet);
3051 // shapes
3052 myTemplates[SUMO_TAG_POLY] = new GNEPoly(SUMO_TAG_POLY, myNet);
3053 myTemplates[SUMO_TAG_POI] = new GNEPOI(SUMO_TAG_POI, myNet);
3054 myTemplates[GNE_TAG_POILANE] = new GNEPOI(GNE_TAG_POILANE, myNet);
3055 myTemplates[GNE_TAG_POIGEO] = new GNEPOI(GNE_TAG_POIGEO, myNet);
3056 // TAZs
3057 myTemplates[SUMO_TAG_TAZ] = new GNETAZ(myNet);
3058 myTemplates[SUMO_TAG_TAZSOURCE] = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, myNet);
3059 myTemplates[SUMO_TAG_TAZSINK] = new GNETAZSourceSink(SUMO_TAG_TAZSINK, myNet);
3060 // wires
3061 myTemplates[SUMO_TAG_TRACTION_SUBSTATION] = new GNETractionSubstation(myNet);
3062 myTemplates[SUMO_TAG_OVERHEAD_WIRE_SECTION] = new GNEOverheadWire(myNet);
3063 //myTemplates[SUMO_TAG_OVERHEAD_WIRE_CLAMP] = nullptr; // TMP
3064 // JuPedSim elements
3066 myTemplates[GNE_TAG_JPS_OBSTACLE] = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet);
3067 // vTypes
3068 myTemplates[SUMO_TAG_VTYPE] = new GNEVType(SUMO_TAG_VTYPE, myNet);
3069 // vType distributions
3070 myTemplates[SUMO_TAG_VTYPE_DISTRIBUTION] = new GNEVTypeDistribution(myNet);
3071 myTemplates[GNE_TAG_VTYPEREF] = new GNEVTypeRef(myNet);
3072 // routes
3073 myTemplates[SUMO_TAG_ROUTE] = new GNERoute(SUMO_TAG_ROUTE, myNet);
3074 myTemplates[GNE_TAG_ROUTE_EMBEDDED] = new GNERoute(GNE_TAG_ROUTE_EMBEDDED, myNet);
3075 // route distribution
3076 myTemplates[SUMO_TAG_ROUTE_DISTRIBUTION] = new GNERouteDistribution(myNet);
3077 myTemplates[GNE_TAG_ROUTEREF] = new GNERouteRef(myNet);
3078 // vehicles
3079 const auto vehicles = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::VEHICLE);
3080 for (const auto vehicle : vehicles) {
3081 myTemplates[vehicle->getTag()] = new GNEVehicle(vehicle->getTag(), myNet);
3082 }
3083 // persons
3084 const auto persons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSON);
3085 for (const auto person : persons) {
3086 myTemplates[person->getTag()] = new GNEPerson(person->getTag(), myNet);
3087 }
3088 // container
3089 const auto containers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::CONTAINER);
3090 for (const auto container : containers) {
3091 myTemplates[container->getTag()] = new GNEContainer(container->getTag(), myNet);
3092 }
3093 // stops and waypoints
3094 const auto stopAndWaypoints = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_VEHICLE);
3095 for (const auto stopAndWaypoint : stopAndWaypoints) {
3096 myTemplates[stopAndWaypoint->getTag()] = new GNEStop(stopAndWaypoint->getTag(), myNet);
3097 }
3098 // personTrip
3099 const auto personTrips = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSONTRIP);
3100 for (const auto personTrip : personTrips) {
3101 myTemplates[personTrip->getTag()] = new GNEPersonTrip(personTrip->getTag(), myNet);
3102 }
3103 // walk
3104 const auto walks = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::WALK);
3105 for (const auto walk : walks) {
3106 myTemplates[walk->getTag()] = new GNEWalk(walk->getTag(), myNet);
3107 }
3108 // ride
3109 const auto rides = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::RIDE);
3110 for (const auto ride : rides) {
3111 myTemplates[ride->getTag()] = new GNERide(ride->getTag(), myNet);
3112 }
3113 // stop person
3114 const auto stopPersons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_PERSON);
3115 for (const auto stopPerson : stopPersons) {
3116 myTemplates[stopPerson->getTag()] = new GNEStopPlan(stopPerson->getTag(), myNet);
3117 }
3118 // transport
3119 const auto transports = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSPORT);
3120 for (const auto transport : transports) {
3121 myTemplates[transport->getTag()] = new GNETransport(transport->getTag(), myNet);
3122 }
3123 // tranship
3124 const auto tranships = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSHIP);
3125 for (const auto tranship : tranships) {
3126 myTemplates[tranship->getTag()] = new GNETranship(tranship->getTag(), myNet);
3127 }
3128 // stop container
3129 const auto stopContainers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_CONTAINER);
3130 for (const auto stopContainer : stopContainers) {
3131 myTemplates[stopContainer->getTag()] = new GNEStopPlan(stopContainer->getTag(), myNet);
3132 }
3133 // dataSet
3134 myTemplates[SUMO_TAG_DATASET] = new GNEDataSet(myNet);
3135 // generic datas
3136 myTemplates[GNE_TAG_EDGEREL_SINGLE] = new GNEEdgeData(myNet);
3137 myTemplates[SUMO_TAG_EDGEREL] = new GNEEdgeRelData(myNet);
3138 myTemplates[SUMO_TAG_TAZREL] = new GNETAZRelData(myNet);
3139 // reset all to their default values
3140 for (const auto& AC : myTemplates) {
3141 AC.second->resetDefaultValues(false);
3142 }
3143 // fill plan templates
3144 fillPlanTemplates();
3145}
3146
3147
3149 for (auto& AC : myTemplates) {
3150 delete AC.second;
3151 }
3152}
3153
3154
3155std::map<SumoXMLTag, GNEAttributeCarrier*>
3157 return myTemplates;
3158}
3159
3160
3163 if (myTemplates.count(tag) > 0) {
3164 return myTemplates.at(tag);
3165 } else {
3166 return nullptr;
3167 }
3168}
3169
3170
3172GNENetHelper::ACTemplate::getTemplateAC(const std::string& selectorText) const {
3173 for (const auto& templateAC : myTemplates) {
3174 if (templateAC.second->getTagProperty()->getSelectorText() == selectorText) {
3175 return templateAC.second;
3176 }
3177 }
3178 return nullptr;
3179}
3180
3181
3184 return myEdgeType;
3185}
3186
3187
3188const std::vector<std::pair<GNETagProperties*, GNEDemandElement*>>&
3190 return myPlanTemplates.at(tag);
3191}
3192
3193
3194void
3196 GNETagProperties* tagProperty = nullptr;
3197 // person trip
3198 tagProperty = new GNETagProperties(SUMO_TAG_PERSONTRIP, nullptr,
3212 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEPersonTrip(GNE_TAG_PERSONTRIP_EDGE_EDGE, myNet)));
3213 // ride
3214 tagProperty = new GNETagProperties(SUMO_TAG_RIDE, nullptr,
3228 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNERide(GNE_TAG_RIDE_EDGE_EDGE, myNet)));
3229 // walk
3230 tagProperty = new GNETagProperties(SUMO_TAG_WALK, nullptr,
3244 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGE_EDGE, myNet)));
3245 // walk (edges)
3246 tagProperty = new GNETagProperties(GNE_TAG_WALK_EDGES, nullptr,
3253 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGES, myNet)));
3254 // walk (route)
3255 tagProperty = new GNETagProperties(GNE_TAG_WALK_ROUTE, nullptr,
3262 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_ROUTE, myNet)));
3263 // stop
3264 tagProperty = new GNETagProperties(GNE_TAG_PERSONSTOPS, nullptr,
3273 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPPERSON_EDGE, myNet)));
3274 // transport
3275 tagProperty = new GNETagProperties(SUMO_TAG_TRANSPORT, nullptr,
3279 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3280 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3281 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3282 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3284 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3285 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3289 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETransport(GNE_TAG_TRANSPORT_EDGE_EDGE, myNet)));
3290 // tranship
3291 tagProperty = new GNETagProperties(SUMO_TAG_TRANSHIP, nullptr,
3295 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3296 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3297 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3298 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3300 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3301 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3305 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGE_EDGE, myNet)));
3306 // tranship (edges)
3307 tagProperty = new GNETagProperties(GNE_TAG_TRANSHIP_EDGES, nullptr,
3314 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGES, myNet)));
3315 // stop
3316 tagProperty = new GNETagProperties(GNE_TAG_CONTAINERSTOPS, nullptr,
3325 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPCONTAINER_EDGE, myNet)));
3326}
3327
3328// ---------------------------------------------------------------------------
3329// GNENetHelper::SavingStatus - methods
3330// ---------------------------------------------------------------------------
3331
3333 myNet(net) {
3334}
3335
3336
3337void
3339 mySumoConfigSaved = false;
3340}
3341
3342
3343void
3345 mySumoConfigSaved = true;
3346}
3347
3348
3349bool
3351 return mySumoConfigSaved;
3352}
3353
3354
3355void
3357 myNeteditConfigSaved = false;
3358}
3359
3360
3361void
3363 myNeteditConfigSaved = true;
3364}
3365
3366
3367bool
3369 return myNeteditConfigSaved;
3370}
3371
3372
3373void
3375 myNetworkSaved = false;
3376 // implies requiere save netedit config and sumo config
3377 myNeteditConfigSaved = false;
3378 mySumoConfigSaved = false;
3379}
3380
3381
3382void
3384 myNetworkSaved = true;
3385}
3386
3387
3388bool
3390 return myNetworkSaved;
3391}
3392
3393
3394void
3396 myTLSSaved = false;
3397}
3398
3399
3400void
3402 myTLSSaved = true;
3403}
3404
3405
3406bool
3408 return myTLSSaved;
3409}
3410
3411
3412void
3414 myEdgeTypeSaved = false;
3415}
3416
3417
3418void
3420 myEdgeTypeSaved = true;
3421}
3422
3423
3424bool
3426 return myEdgeTypeSaved;
3427}
3428
3429
3430void
3432 myAdditionalSaved = false;
3433 // implies requiere save netedit config and sumo config
3434 myNeteditConfigSaved = false;
3435 mySumoConfigSaved = false;
3436}
3437
3438
3439void
3441 myAdditionalSaved = true;
3442}
3443
3444
3445bool
3447 return myAdditionalSaved;
3448}
3449
3450
3451void
3453 myDemandElementSaved = false;
3454 // implies requiere save netedit config and sumo config
3455 myNeteditConfigSaved = false;
3456 mySumoConfigSaved = false;
3457}
3458
3459
3460void
3462 myDemandElementSaved = true;
3463}
3464
3465
3466bool
3468 return myDemandElementSaved;
3469}
3470
3471
3472void
3474 myDataElementSaved = false;
3475 // implies requiere save netedit config and sumo config
3476 myNeteditConfigSaved = false;
3477 mySumoConfigSaved = false;
3478}
3479
3480
3481void
3483 myDataElementSaved = true;
3484}
3485
3486
3487bool
3489 return myDataElementSaved;
3490}
3491
3492
3493void
3495 myMeanDataElementSaved = false;
3496 // implies requiere save netedit config and sumo config
3497 myNeteditConfigSaved = false;
3498 mySumoConfigSaved = false;
3499}
3500
3501
3502void
3504 myMeanDataElementSaved = true;
3505}
3506
3507
3508bool
3510 return myMeanDataElementSaved;
3511}
3512
3513
3516 auto GNEApp = myNet->getGNEApplicationWindow();
3517 // Check if there are non saved network elements
3518 if (commonResult == GNEDialog::Result::ABORT) {
3520 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3522 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3524 } else if (myNetworkSaved) {
3526 } else {
3527 // open save dialog
3528 const GNESaveDialog saveDialog(GNEApp, TL("network"));
3529 // continue depending of result
3530 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3531 commonResult = GNEDialog::Result::ABORT;
3533 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3534 commonResult = GNEDialog::Result::ACCEPT_ALL;
3536 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3537 commonResult = GNEDialog::Result::CANCEL_ALL;
3539 } else {
3540 return saveDialog.getResult();
3541 }
3542 }
3543}
3544
3545
3548 auto GNEApp = myNet->getGNEApplicationWindow();
3549 // Check if there are non saved additional elements
3550 if (commonResult == GNEDialog::Result::ABORT) {
3552 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3554 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3556 } else if (myAdditionalSaved) {
3558 } else {
3559 // open save dialog
3560 const GNESaveDialog saveDialog(GNEApp, TL("additional elements"));
3561 // continue depending of result
3562 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3563 commonResult = GNEDialog::Result::ABORT;
3565 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3566 commonResult = GNEDialog::Result::ACCEPT_ALL;
3568 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3569 commonResult = GNEDialog::Result::CANCEL_ALL;
3571 } else {
3572 return saveDialog.getResult();
3573 }
3574 }
3575}
3576
3577
3580 auto GNEApp = myNet->getGNEApplicationWindow();
3581 // Check if there are non saved demand elements
3582 if (commonResult == GNEDialog::Result::ABORT) {
3584 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3586 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3588 } else if (myDemandElementSaved) {
3590 } else {
3591 // open save dialog
3592 const GNESaveDialog saveDialog(GNEApp, TL("demand elements"));
3593 // continue depending of result
3594 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3595 commonResult = GNEDialog::Result::ABORT;
3597 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3598 commonResult = GNEDialog::Result::ACCEPT_ALL;
3600 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3601 commonResult = GNEDialog::Result::CANCEL_ALL;
3603 } else {
3604 return saveDialog.getResult();
3605 }
3606 }
3607}
3608
3609
3612 auto GNEApp = myNet->getGNEApplicationWindow();
3613 // Check if there are non saved data elements
3614 if (commonResult == GNEDialog::Result::ABORT) {
3616 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3618 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3620 } else if (myDataElementSaved) {
3622 } else {
3623 // open save dialog
3624 const GNESaveDialog saveDialog(GNEApp, TL("data elements"));
3625 // continue depending of result
3626 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3627 commonResult = GNEDialog::Result::ABORT;
3629 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3630 commonResult = GNEDialog::Result::ACCEPT_ALL;
3632 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3633 commonResult = GNEDialog::Result::CANCEL_ALL;
3635 } else {
3636 return saveDialog.getResult();
3637 }
3638 }
3639}
3640
3641
3644 auto GNEApp = myNet->getGNEApplicationWindow();
3645 // Check if there are non saved mean data elements
3646 if (commonResult == GNEDialog::Result::ABORT) {
3648 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3650 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3652 } else if (myMeanDataElementSaved) {
3654 } else {
3655 // open save dialog
3656 const GNESaveDialog saveDialog(GNEApp, TL("meanData elements"));
3657 // continue depending of result
3658 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3659 commonResult = GNEDialog::Result::ABORT;
3661 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3662 commonResult = GNEDialog::Result::ACCEPT_ALL;
3664 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3665 commonResult = GNEDialog::Result::CANCEL_ALL;
3667 } else {
3668 return saveDialog.getResult();
3669 }
3670 }
3671}
3672
3673// ---------------------------------------------------------------------------
3674// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
3675// ---------------------------------------------------------------------------
3676
3678 GNEChange(Supermode::NETWORK, true, false),
3679 myTllcont(tllcont),
3680 myReplaced(replaced),
3681 myBy(by) {
3682}
3683
3684
3686
3687
3688void
3690 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3691 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
3692}
3693
3694
3695void
3697 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3698 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
3699}
3700
3701
3702std::string
3704 return TL("Redo replace in TLS");
3705}
3706
3707
3708std::string
3710 return TL("Undo replace in TLS");
3711}
3712
3713
3714bool
3716 return myReplaced != myBy;
3717}
3718
3719/****************************************************************************/
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:49
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:645
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition GNEEdge.cpp:1513
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:766
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2247
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:639
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::vector< GNEAdditional * > getUnselectedShapes() const
get unselected shapes
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:4213
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:3157
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:2784
A container for traffic light definitions and built programs.
const std::string & getID() const
Returns the id.
Definition Named.h:73
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:54
bool intersectWithShape(const PositionVector &shape) const
check if the given shape is within or intersect with this triangle
Definition Triangle.cpp:69