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 if (afterVolatile) {
477 junction->updateGeometryAfterNetbuild(false);
478 } else {
479 junction->updateGeometry();
480 }
481 // add z in net boundary
482 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
483 return junction;
484}
485
486
487void
489 myJunctions.clear();
490}
491
492
493void
495 // make a copy of junctions
496 auto junctionCopy = myJunctions;
497 // clear junctions
498 myJunctions.clear();
499 // fill junctions again
500 for (const auto& junction : junctionCopy) {
501 // update microsim ID
502 junction.second->setNetworkElementID(prefix + junction.first);
503 // insert in myJunctions again
504 myJunctions[prefix + junction.first] = junction.second;
505 }
506}
507
508
509void
511 if (myJunctions.count(junction->getID()) == 0) {
512 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
513 } else if (myJunctions.count(newID) != 0) {
514 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
515 } else {
516 // remove junction from container
517 myJunctions.erase(junction->getNBNode()->getID());
518 // rename in NetBuilder
519 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
520 // update microsim ID
521 junction->setNetworkElementID(newID);
522 // add it into myJunctions again
523 myJunctions[junction->getID()] = junction;
524 // build crossings
525 junction->getNBNode()->buildCrossings();
526 // net has to be saved
527 myNet->requireRecompute();
528 }
529}
530
531
532int
534 int counter = 0;
535 for (const auto& junction : myJunctions) {
536 if (junction.second->isAttributeCarrierSelected()) {
537 counter++;
538 }
539 }
540 return counter;
541}
542
543
546 auto it = myCrossings.find(glObject);
547 if (it != myCrossings.end()) {
548 return it->second;
549 }
550 if (hardFail) {
551 // If junction wasn't found, throw exception
552 throw UnknownElement("Attempted to retrieve non-existant crossing " + glObject->getMicrosimID());
553 } else {
554 return nullptr;
555 }
556}
557
558
559const std::unordered_map<const GUIGlObject*, GNECrossing*>&
561 return myCrossings;
562}
563
564
565std::vector<GNECrossing*>
567 std::vector<GNECrossing*> result;
568 // iterate over crossings
569 for (const auto& crossing : myCrossings) {
570 if (crossing.second->isAttributeCarrierSelected()) {
571 result.push_back(crossing.second);
572 }
573 }
574 return result;
575}
576
577
578int
580 int counter = 0;
581 for (const auto& crossing : myCrossings) {
582 if (crossing.second->isAttributeCarrierSelected()) {
583 counter++;
584 }
585 }
586 return counter;
587}
588
589
592 auto it = myWalkingAreas.find(glObject);
593 if (it != myWalkingAreas.end()) {
594 return it->second;
595 }
596 if (hardFail) {
597 // If junction wasn't found, throw exception
598 throw UnknownElement("Attempted to retrieve non-existant walkingArea " + glObject->getMicrosimID());
599 } else {
600 return nullptr;
601 }
602}
603
604
605const std::unordered_map<const GUIGlObject*, GNEWalkingArea*>&
607 return myWalkingAreas;
608}
609
610
611std::vector<GNEWalkingArea*>
613 std::vector<GNEWalkingArea*> result;
614 // iterate over walkingAreas
615 for (const auto& walkingArea : myWalkingAreas) {
616 if (walkingArea.second->isAttributeCarrierSelected()) {
617 result.push_back(walkingArea.second);
618 }
619 }
620 return result;
621}
622
623
624int
626 int counter = 0;
627 for (const auto& walkingArea : myWalkingAreas) {
628 if (walkingArea.second->isAttributeCarrierSelected()) {
629 counter++;
630 }
631 }
632 return counter;
633}
634
635
637GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
638 if (myEdgeTypes.count(id) > 0) {
639 return myEdgeTypes.at(id);
640 } else if (hardFail) {
641 // If edge wasn't found, throw exception
642 throw UnknownElement("Attempted to retrieve non-existant EdgeType " + id);
643 } else {
644 return nullptr;
645 }
646}
647
648
651 // increase reference
652 edgeType->incRef("GNENet::registerEdgeType");
653 // add it in container
654 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
655 return edgeType;
656}
657
658
659const std::map<std::string, GNEEdgeType*>&
661 return myEdgeTypes;
662}
663
664
666 myEdgeTypes.clear();
667}
668
669
670void
672 if (myEdgeTypes.count(edgeType->getID()) == 0) {
673 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
674 } else if (myEdgeTypes.count(newID) != 0) {
675 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
676 } else {
677 // remove edgeType from container
678 myEdgeTypes.erase(edgeType->getID());
679 // rename in typeCont
680 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
681 // update microsim ID
682 edgeType->setNetworkElementID(newID);
683 // add it into myEdgeTypes again
684 myEdgeTypes[edgeType->getID()] = edgeType;
685 // net has to be saved
686 myNet->requireRecompute();
687 }
688}
689
690
691std::string
693 int counter = 0;
694 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
695 counter++;
696 }
697 return ("edgeType_" + toString(counter));
698}
699
700
701GNEEdge*
702GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
703 auto it = myEdges.find(id);
704 if (it != myEdges.end()) {
705 return it->second;
706 }
707 if (hardFail) {
708 // If edge wasn't found, throw exception
709 throw UnknownElement("Attempted to retrieve non-existant edge " + id);
710 } else {
711 return nullptr;
712 }
713}
714
715
716std::vector<GNEEdge*>
718 if ((from == nullptr) || (to == nullptr)) {
719 throw UnknownElement("Junctions cannot be nullptr");
720 }
721 std::vector<GNEEdge*> edges;
722 // iterate over outgoing edges of from edge and check to junction
723 for (const auto& edgeTo : from->getGNEOutgoingEdges()) {
724 if (edgeTo->getToJunction() == to) {
725 edges.push_back(edgeTo);
726 }
727 }
728 return edges;
729}
730
731
732const std::map<std::string, GNEEdge*>&
734 return myEdges;
735}
736
737
738std::vector<GNEEdge*>
740 std::vector<GNEEdge*> result;
741 // returns edges depending of selection
742 for (const auto& edge : myEdges) {
743 if (edge.second->isAttributeCarrierSelected()) {
744 result.push_back(edge.second);
745 }
746 }
747 return result;
748}
749
750
751GNEEdge*
753 edge->incRef("GNENet::registerEdge");
754 edge->setResponsible(false);
755 // add edge to internal container of GNENet
756 myEdges[edge->getMicrosimID()] = edge;
757 myNumberOfNetworkElements++;
758 // insert all lanes
759 for (const auto& lane : edge->getChildLanes()) {
760 insertLane(lane);
761 }
762 // Add references into GNEJunctions
763 edge->getFromJunction()->addOutgoingGNEEdge(edge);
764 edge->getToJunction()->addIncomingGNEEdge(edge);
765 // update boundaries of both junctions (to remove it from Grid)
768 // update edge boundary
769 edge->updateCenteringBoundary(false);
770 // expand edge boundary
771 myNet->expandBoundary(edge->getCenteringBoundary());
772 // finally add edge into grid
773 myNet->addGLObjectIntoGrid(edge);
774 return edge;
775}
776
777
778void
782
783
784void
786 // make a copy of edges
787 auto edgeCopy = myEdges;
788 // clear edges
789 myEdges.clear();
790 // fill edges again
791 for (const auto& edge : edgeCopy) {
792 // update microsim ID
793 edge.second->setNetworkElementID(prefix + edge.first);
794 // insert in myEdges again
795 myEdges[prefix + edge.first] = edge.second;
796 }
797}
798
799
800std::string
802 // get edge prefix
803 const std::string edgePrefix = OptionsCont::getOptions().getString("prefix") + OptionsCont::getOptions().getString("edge-prefix");
804 // generate new ID
805 while (myEdges.count(edgePrefix + toString(myNet->getEdgeIDCounter())) != 0) {
806 myNet->getEdgeIDCounter()++;
807 }
808 return edgePrefix + toString(myNet->getEdgeIDCounter());
809}
810
811
812void
814 if (myEdges.count(edge->getID()) == 0) {
815 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
816 } else if (myEdges.count(newID) != 0) {
817 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
818 } else {
819 // remove edge from container
820 myEdges.erase(edge->getNBEdge()->getID());
821 // rename in NetBuilder
822 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
823 // update microsim ID
824 edge->setEdgeID(newID);
825 // add it into myEdges again
826 myEdges[edge->getID()] = edge;
827 // rename all connections related to this edge
828 for (const auto& lane : edge->getChildLanes()) {
829 lane->updateConnectionIDs();
830 }
831 // net has to be saved
832 myNet->requireRecompute();
833 }
834}
835
836
837int
839 int counter = 0;
840 for (const auto& edge : myEdges) {
841 if (edge.second->isAttributeCarrierSelected()) {
842 counter++;
843 }
844 }
845 return counter;
846}
847
848
849GNELane*
850GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
851 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
852 const GNEEdge* edge = retrieveEdge(edge_id, false);
853 if (edge != nullptr) {
854 GNELane* lane = nullptr;
855 // search lane in lane's edges
856 for (auto laneIt : edge->getChildLanes()) {
857 if (laneIt->getID() == id) {
858 lane = laneIt;
859 }
860 }
861 // throw exception or return nullptr if lane wasn't found
862 if (lane == nullptr) {
863 if (hardFail) {
864 // Throw exception if hardFail is enabled
865 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
866 }
867 } else {
868 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
869 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
870 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getChildLanes().size()) {
871 return edge->getChildLanes().at(lane->getIndex() + 1);
872 }
873 return lane;
874 }
875 } else if (hardFail) {
876 // Throw exception if hardFail is enabled
877 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
878 }
879 return nullptr;
880}
881
882
883GNELane*
884GNENetHelper::AttributeCarriers::retrieveLane(const GUIGlObject* glObject, bool hardFail) const {
885 auto it = myLanes.find(glObject);
886 if (it != myLanes.end()) {
887 return it->second;
888 }
889 if (hardFail) {
890 // If junction wasn't found, throw exception
891 throw UnknownElement("Attempted to retrieve non-existant lane " + glObject->getMicrosimID());
892 } else {
893 return nullptr;
894 }
895}
896
897
898const std::unordered_map<const GUIGlObject*, GNELane*>&
900 return myLanes;
901}
902
903
904std::vector<GNELane*>
906 std::vector<GNELane*> result;
907 // returns lanes depending of selection
908 for (const auto& lane : myLanes) {
909 if (lane.second->isAttributeCarrierSelected()) {
910 result.push_back(lane.second);
911 }
912 }
913 return result;
914}
915
916
917int
919 int counter = 0;
920 for (const auto& lane : myLanes) {
921 if (lane.second->isAttributeCarrierSelected()) {
922 counter++;
923 }
924 }
925 return counter;
926}
927
928
930GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
931 // iterate over connections
932 for (const auto& connection : myConnections) {
933 if (connection.second->getID() == id) {
934 return connection.second;
935 }
936 }
937 if (hardFail) {
938 // If POI wasn't found, throw exception
939 throw UnknownElement("Attempted to retrieve non-existant connection " + id);
940 } else {
941 return nullptr;
942 }
943}
944
945
948 auto it = myConnections.find(glObject);
949 if (it != myConnections.end()) {
950 return it->second;
951 }
952 if (hardFail) {
953 // If POI wasn't found, throw exception
954 throw UnknownElement("Attempted to retrieve non-existant connection " + glObject->getMicrosimID());
955 } else {
956 return nullptr;
957 }
958}
959
960
961const std::unordered_map<const GUIGlObject*, GNEConnection*>&
963 return myConnections;
964}
965
966
967std::vector<GNEConnection*>
969 std::vector<GNEConnection*> result;
970 // returns connections depending of selection
971 for (const auto& connection : myConnections) {
972 if (connection.second->isAttributeCarrierSelected()) {
973 result.push_back(connection.second);
974 }
975 }
976 return result;
977}
978
979
980int
982 int counter = 0;
983 for (const auto& connection : myConnections) {
984 if (connection.second->isAttributeCarrierSelected()) {
985 counter++;
986 }
987 }
988 return counter;
989}
990
991
994 auto it = myInternalLanes.find(glObject);
995 if (it != myInternalLanes.end()) {
996 return it->second;
997 }
998 if (hardFail) {
999 // If POI wasn't found, throw exception
1000 throw UnknownElement("Attempted to retrieve non-existant internalLane " + glObject->getMicrosimID());
1001 } else {
1002 return nullptr;
1003 }
1004}
1005
1006
1008GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
1009 auto it = myAdditionalIDs.at(type).find(id);
1010 if (it != myAdditionalIDs.at(type).end()) {
1011 return it->second;
1012 }
1013 if (hardFail) {
1014 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1015 } else {
1016 return nullptr;
1017 }
1018}
1019
1020
1022GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1023 for (const auto& type : types) {
1024 auto it = myAdditionalIDs.at(type).find(id);
1025 if (it != myAdditionalIDs.at(type).end()) {
1026 return it->second;
1027 }
1028 }
1029 if (hardFail) {
1030 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1031 } else {
1032 return nullptr;
1033 }
1034}
1035
1036
1039 // iterate over all additionals
1040 for (const auto& additionalTag : myAdditionals) {
1041 auto it = additionalTag.second.find(glObject);
1042 if (it != additionalTag.second.end()) {
1043 return it->second;
1044 }
1045 }
1046 if (hardFail) {
1047 throw ProcessError("Attempted to retrieve non-existant additional (glObject)");
1048 } else {
1049 return nullptr;
1050 }
1051}
1052
1053
1055GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
1056 // first retrieve rerouter
1057 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
1058 // parse begin and end
1059 const std::string beginStr = time2string(begin);
1060 const std::string endStr = time2string(end);
1061 // now iterate over all children and check begin and end
1062 for (const auto& interval : rerouter->getChildAdditionals()) {
1063 // check tag (to avoid symbols)
1064 if (interval->getTagProperty()->getTag() == SUMO_TAG_INTERVAL) {
1065 // check begin and end
1066 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
1067 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
1068 return interval;
1069 }
1070 }
1071 }
1072 // throw exception
1073 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
1074}
1075
1076
1077const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*>, std::hash<int> >&
1079 return myAdditionals;
1080}
1081
1082
1083std::vector<GNEAdditional*>
1085 std::vector<GNEAdditional*> result;
1086 // returns additionals depending of selection
1087 for (const auto& additionalsTags : myAdditionals) {
1088 for (const auto& additional : additionalsTags.second) {
1089 if (additional.second->isAttributeCarrierSelected()) {
1090 result.push_back(additional.second);
1091 }
1092 }
1093 }
1094 return result;
1095}
1096
1097
1098std::vector<GNEAdditional*>
1100 std::vector<GNEAdditional*> result;
1101 // returns additionals depending of selection
1102 for (const auto& additionalsTags : myAdditionals) {
1103 for (const auto& additional : additionalsTags.second) {
1104 if (additional.second->getTagProperty()->isShapeElement() && additional.second->isAttributeCarrierSelected()) {
1105 result.push_back(additional.second);
1106 }
1107 }
1108 }
1109 return result;
1110}
1111
1112std::vector<GNEAdditional*>
1114 std::vector<GNEAdditional*> result;
1115 // returns additionals depending of selection
1116 for (const auto& additionalsTags : myAdditionals) {
1117 for (const auto& additional : additionalsTags.second) {
1118 if (additional.second->getTagProperty()->isShapeElement() && !additional.second->isAttributeCarrierSelected()) {
1119 result.push_back(additional.second);
1120 }
1121 }
1122 }
1123 return result;
1124}
1125
1126
1127int
1129 int counter = 0;
1130 for (const auto& additionalsTag : myAdditionals) {
1131 counter += (int)additionalsTag.second.size();
1132 }
1133 return counter;
1134}
1135
1136
1137void
1139 // clear elements in grid
1140 for (const auto& additionalsTags : myAdditionals) {
1141 for (const auto& additional : additionalsTags.second) {
1142 myNet->removeGLObjectFromGrid(additional.second);
1143 }
1144 }
1145 // iterate over myAdditionals and clear all additionals
1146 for (auto& additionals : myAdditionals) {
1147 additionals.second.clear();
1148 }
1149 for (auto& additionals : myAdditionalIDs) {
1150 additionals.second.clear();
1151 }
1152}
1153
1154
1155void
1157 const auto tag = additional->getTagProperty()->getTag();
1158 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1159 if (it == myAdditionalIDs.at(tag).end()) {
1160 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1161 } else {
1162 // remove from container, set new Id, and insert it again
1163 myAdditionalIDs.at(tag).erase(it);
1164 // set microsim ID
1165 additional->setMicrosimID(newID);
1166 myAdditionalIDs.at(tag)[newID] = additional;
1167 }
1168}
1169
1170
1171std::string
1173 // obtain option container
1174 const auto& neteditOptions = OptionsCont::getOptions();
1175 // get prefix
1176 std::string prefix;
1177 if (tag == SUMO_TAG_BUS_STOP) {
1178 prefix = neteditOptions.getString("busStop-prefix");
1179 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1180 prefix = neteditOptions.getString("trainStop-prefix");
1181 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1182 prefix = neteditOptions.getString("containerStop-prefix");
1183 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1184 prefix = neteditOptions.getString("chargingStation-prefix");
1185 } else if (tag == SUMO_TAG_PARKING_AREA) {
1186 prefix = neteditOptions.getString("parkingArea-prefix");
1187 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1188 prefix = neteditOptions.getString("e1Detector-prefix");
1189 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1190 prefix = neteditOptions.getString("e2Detector-prefix");
1191 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1192 prefix = neteditOptions.getString("e3Detector-prefix");
1193 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1194 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1195 } else if (tag == SUMO_TAG_REROUTER) {
1196 prefix = neteditOptions.getString("rerouter-prefix");
1197 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1198 prefix = neteditOptions.getString("calibrator-prefix");
1199 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1200 prefix = neteditOptions.getString("routeProbe-prefix");
1201 } else if (tag == SUMO_TAG_VSS) {
1202 prefix = neteditOptions.getString("vss-prefix");
1203 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1204 prefix = neteditOptions.getString("tractionSubstation-prefix");
1205 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1206 prefix = neteditOptions.getString("overheadWire-prefix");
1207 } else if (tag == SUMO_TAG_POLY) {
1208 prefix = neteditOptions.getString("polygon-prefix");
1209 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1210 prefix = neteditOptions.getString("poi-prefix");
1211 } else if (tag == SUMO_TAG_TAZ) {
1212 prefix = toString(SUMO_TAG_TAZ);
1213 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1214 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1215 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1216 prefix = neteditOptions.getString("jps.obstacle-prefix");
1217 }
1218 int counter = 0;
1219 // check namespaces
1220 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1221 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1222 counter++;
1223 }
1224 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1225 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1226 counter++;
1227 }
1228 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1229 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1230 counter++;
1231 }
1232 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1233 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1234 counter++;
1235 }
1236 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1237 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1238 counter++;
1239 }
1240 } else {
1241 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1242 counter++;
1243 }
1244 }
1245 // return new element ID
1246 return (prefix + "_" + toString(counter));
1247}
1248
1249
1250int
1252 int counter = 0;
1253 for (const auto& additionalsTags : myAdditionals) {
1254 for (const auto& additional : additionalsTags.second) {
1255 if (additional.second->isAttributeCarrierSelected()) {
1256 counter++;
1257 }
1258 }
1259 }
1260 return counter;
1261}
1262
1263
1264int
1266 return getNumberOfSelectedAdditionals() -
1267 // shapes
1268 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1269 // JuPedSims
1270 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1271 // TAZ
1272 getNumberOfSelectedTAZs() -
1273 // wires
1274 getNumberOfSelectedWires();
1275}
1276
1277
1278int
1280 int counter = 0;
1281 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1282 if (poly.second->isAttributeCarrierSelected()) {
1283 counter++;
1284 }
1285 }
1286 return counter;
1287}
1288
1289
1290int
1292 int counter = 0;
1293 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1294 if (walkableArea.second->isAttributeCarrierSelected()) {
1295 counter++;
1296 }
1297 }
1298 return counter;
1299}
1300
1301
1302int
1304 int counter = 0;
1305 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1306 if (obstacle.second->isAttributeCarrierSelected()) {
1307 counter++;
1308 }
1309 }
1310 return counter;
1311}
1312
1313
1314int
1316 int counter = 0;
1317 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1318 if (POI.second->isAttributeCarrierSelected()) {
1319 counter++;
1320 }
1321 }
1322 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1323 if (POILane.second->isAttributeCarrierSelected()) {
1324 counter++;
1325 }
1326 }
1327 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1328 if (POIGEO.second->isAttributeCarrierSelected()) {
1329 counter++;
1330 }
1331 }
1332 return counter;
1333}
1334
1335
1336std::vector<std::string>
1338 std::set<std::string> keys;
1339 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1340 for (const auto& parameter : POI.second->getParameters()->getParametersMap()) {
1341 keys.insert(parameter.first);
1342 }
1343 }
1344 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1345 for (const auto& parameter : POILane.second->getParameters()->getParametersMap()) {
1346 keys.insert(parameter.first);
1347 }
1348 }
1349 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1350 for (const auto& parameter : POIGEO.second->getParameters()->getParametersMap()) {
1351 keys.insert(parameter.first);
1352 }
1353 }
1354 return std::vector<std::string>(keys.begin(), keys.end());
1355}
1356
1357
1358int
1360 int counter = 0;
1361 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1362 if (TAZ.second->isAttributeCarrierSelected()) {
1363 counter++;
1364 }
1365 }
1366 return counter;
1367}
1368
1369
1370int
1372 int counter = 0;
1373 for (const auto& additionalsTags : myAdditionals) {
1374 for (const auto& additional : additionalsTags.second) {
1375 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty()->isWireElement()) {
1376 counter++;
1377 }
1378 }
1379 }
1380 return counter;
1381}
1382
1383
1386 // iterate over all demand elements
1387 for (const auto& TAZSourceSinkTag : myTAZSourceSinks) {
1388 auto it = TAZSourceSinkTag.second.find(sourceSink);
1389 if (it != TAZSourceSinkTag.second.end()) {
1390 return it->second;
1391 }
1392 }
1393 if (hardFail) {
1394 throw ProcessError("Attempted to retrieve non-existant sourceSink (glObject)");
1395 } else {
1396 return nullptr;
1397 }
1398}
1399
1400
1401const std::unordered_map<SumoXMLTag, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>, std::hash<int> >&
1403 return myTAZSourceSinks;
1404}
1405
1406
1407int
1409 int counter = 0;
1410 for (const auto& sourceSinksTag : myTAZSourceSinks) {
1411 counter += (int)sourceSinksTag.second.size();
1412 }
1413 return counter;
1414}
1415
1416
1417void
1419 // iterate over myTAZSourceSinks and clear all sourceSinks
1420 for (auto& sourceSinksTags : myTAZSourceSinks) {
1421 sourceSinksTags.second.clear();
1422 }
1423}
1424
1425
1427GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1428 auto it = myDemandElementIDs.at(type).find(id);
1429 if (it != myDemandElementIDs.at(type).end()) {
1430 return it->second;
1431 }
1432 if (hardFail) {
1433 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1434 } else {
1435 return nullptr;
1436 }
1437}
1438
1439
1441GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1442 for (const auto& type : types) {
1443 auto it = myDemandElementIDs.at(type).find(id);
1444 if (it != myDemandElementIDs.at(type).end()) {
1445 return it->second;
1446 }
1447 }
1448 if (hardFail) {
1449 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1450 } else {
1451 return nullptr;
1452 }
1453}
1454
1455
1458 // iterate over all demand elements
1459 for (const auto& demandElementTag : myDemandElements) {
1460 auto it = demandElementTag.second.find(glObject);
1461 if (it != demandElementTag.second.end()) {
1462 return it->second;
1463 }
1464 }
1465 if (hardFail) {
1466 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1467 } else {
1468 return nullptr;
1469 }
1470}
1471
1472
1473std::vector<GNEDemandElement*>
1475 std::vector<GNEDemandElement*> result;
1476 // returns demand elements depending of selection
1477 for (const auto& demandElementTag : myDemandElements) {
1478 for (const auto& demandElement : demandElementTag.second) {
1479 if (demandElement.second->isAttributeCarrierSelected()) {
1480 result.push_back(demandElement.second);
1481 }
1482 }
1483 }
1484 return result;
1485}
1486
1487
1488const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*>, std::hash<int> >&
1490 return myDemandElements;
1491}
1492
1493
1494std::string
1496 // obtain option container
1497 const auto& neteditOptions = OptionsCont::getOptions();
1498 // get tag property
1499 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag, true);
1500 // get prefix
1501 std::string prefix;
1502 if (tag == SUMO_TAG_ROUTE) {
1503 prefix = neteditOptions.getString("route-prefix");
1504 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1505 prefix = neteditOptions.getString("routeDistribution-prefix");
1506 } else if (tag == SUMO_TAG_VTYPE) {
1507 prefix = neteditOptions.getString("vType-prefix");
1508 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1509 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1510 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1511 prefix = neteditOptions.getString("trip-prefix");
1512 } else if (tagProperty->isVehicle() && !tagProperty->isFlow()) {
1513 prefix = neteditOptions.getString("vehicle-prefix");
1514 } else if (tagProperty->isPerson()) {
1515 if (tagProperty->isFlow()) {
1516 prefix = neteditOptions.getString("personflow-prefix");
1517 } else {
1518 prefix = neteditOptions.getString("person-prefix");
1519 }
1520 } else if (tagProperty->isContainer()) {
1521 if (tagProperty->isFlow()) {
1522 prefix = neteditOptions.getString("containerflow-prefix");
1523 } else {
1524 prefix = neteditOptions.getString("container-prefix");
1525 }
1526 } else if (tagProperty->isFlow()) {
1527 prefix = neteditOptions.getString("flow-prefix");
1528 }
1529 // declare counter
1530 int counter = 0;
1531 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1532 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1533 counter++;
1534 }
1535 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1536 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1537 counter++;
1538 }
1539 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1540 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1541 counter++;
1542 }
1543 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1544 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1545 counter++;
1546 }
1547 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1548 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1549 counter++;
1550 }
1551 } else {
1552 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1553 counter++;
1554 }
1555 }
1556 // return new element ID
1557 return (prefix + "_" + toString(counter));
1558
1559}
1560
1561
1564 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1565 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1566 return it->second;
1567 }
1568 throw ProcessError(TL("Default vType doesn't exist"));
1569}
1570
1571
1572void
1574 // clear elements in grid
1575 for (const auto& demandElementsTags : myDemandElements) {
1576 for (const auto& demandElement : demandElementsTags.second) {
1577 myNet->removeGLObjectFromGrid(demandElement.second);
1578 }
1579 }
1580 // iterate over myDemandElements and clear all demand elements
1581 for (auto& demandElements : myDemandElements) {
1582 demandElements.second.clear();
1583 }
1584 for (auto& demandElements : myDemandElementIDs) {
1585 demandElements.second.clear();
1586 }
1587}
1588
1589
1590void
1592 const auto tag = demandElement->getTagProperty()->getTag();
1593 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1594 if (it == myDemandElementIDs.at(tag).end()) {
1595 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1596 } else {
1597 // remove from container, set new Id, and insert it again
1598 myDemandElementIDs.at(tag).erase(it);
1599 // set microsim ID
1600 demandElement->setMicrosimID(newID);
1601 myDemandElementIDs.at(tag)[newID] = demandElement;
1602 }
1603}
1604
1605
1606void
1608 // get default bucket
1609 auto bucket = myNet->getGNEApplicationWindow()->getFileBucketHandler()->getDefaultBucket(FileBucket::Type::DEMAND);
1610 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1611 GNEVType* defaultVehicleType = new GNEVType(DEFAULT_VTYPE_ID, myNet, bucket, SVC_PASSENGER);
1612 myDemandElements.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1613 myDemandElementIDs.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1614 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1615 bucket->addDefaultVType();
1616
1617 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1618 GNEVType* defaultBikeType = new GNEVType(DEFAULT_BIKETYPE_ID, myNet, bucket, SVC_BICYCLE);
1619 myDemandElements.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1620 myDemandElementIDs.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1621 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1622 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1623 bucket->addDefaultVType();
1624
1625 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1626 GNEVType* defaultTaxiType = new GNEVType(DEFAULT_TAXITYPE_ID, myNet, bucket, SVC_TAXI);
1627 myDemandElements.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1628 myDemandElementIDs.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1629 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1630 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1631 bucket->addDefaultVType();
1632
1633 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1634 GNEVType* defaultRailType = new GNEVType(DEFAULT_RAILTYPE_ID, myNet, bucket, SVC_RAIL);
1635 myDemandElements.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1636 myDemandElementIDs.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1637 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1638 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1639 bucket->addDefaultVType();
1640
1641 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1642 GNEVType* defaultPersonType = new GNEVType(DEFAULT_PEDTYPE_ID, myNet, bucket, SVC_PEDESTRIAN);
1643 myDemandElements.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1644 myDemandElementIDs.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1645 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1646 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1647 bucket->addDefaultVType();
1648
1649 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1650 GNEVType* defaultContainerType = new GNEVType(DEFAULT_CONTAINERTYPE_ID, myNet, bucket, SVC_IGNORING);
1651 myDemandElements.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1652 myDemandElementIDs.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1653 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1654 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1655 bucket->addDefaultVType();
1656}
1657
1658
1659bool
1661 if (myDemandElements.at(GNE_TAG_TRIP_JUNCTIONS).size() > 0) {
1662 return true;
1663 } else if (myDemandElements.at(GNE_TAG_FLOW_JUNCTIONS).size() > 0) {
1664 return true;
1665 } else {
1666 // iterate over all tags and check if start or ends in junctions
1667 for (const auto& mapValue : myDemandElements) {
1668 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(mapValue.first, true);
1669 if ((tagProperty->planFromJunction() || tagProperty->planToJunction()) && (myDemandElements.at(tagProperty->getTag()).size() > 0)) {
1670 return true;
1671 }
1672 }
1673 }
1674 return false;
1675}
1676
1677
1678int
1680 return myStopIndex++;
1681}
1682
1683
1684int
1686 int counter = 0;
1687 for (const auto& demandElementsTags : myDemandElements) {
1688 for (const auto& demandElement : demandElementsTags.second) {
1689 if (demandElement.second->isAttributeCarrierSelected()) {
1690 counter++;
1691 }
1692 }
1693 }
1694 return counter;
1695}
1696
1697
1698int
1700 int counter = 0;
1701 // iterate over routes
1702 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1703 if (route.second->isAttributeCarrierSelected()) {
1704 counter++;
1705 }
1706 }
1707 // iterate over vehicles with embedded routes
1708 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1709 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1710 counter++;
1711 }
1712 }
1713 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1714 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1715 counter++;
1716 }
1717 }
1718 return counter;
1719}
1720
1721
1722int
1724 int counter = 0;
1725 // iterate over all vehicles and flows
1726 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1727 if (vehicle.second->isAttributeCarrierSelected()) {
1728 counter++;
1729 }
1730 }
1731 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1732 if (trip.second->isAttributeCarrierSelected()) {
1733 counter++;
1734 }
1735 }
1736 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1737 if (vehicle.second->isAttributeCarrierSelected()) {
1738 counter++;
1739 }
1740 }
1741 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1742 if (flow.second->isAttributeCarrierSelected()) {
1743 counter++;
1744 }
1745 }
1746 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1747 if (flow.second->isAttributeCarrierSelected()) {
1748 counter++;
1749 }
1750 }
1751 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1752 if (flow.second->isAttributeCarrierSelected()) {
1753 counter++;
1754 }
1755 }
1756 return counter;
1757}
1758
1759
1760int
1762 int counter = 0;
1763 // iterate over all persons
1764 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1765 if (person.second->isAttributeCarrierSelected()) {
1766 counter++;
1767 }
1768 }
1769 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1770 if (personFlow.second->isAttributeCarrierSelected()) {
1771 counter++;
1772 }
1773 }
1774 return counter;
1775}
1776
1777
1778int
1780 int counter = 0;
1781 // iterate over all person plans
1782 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1783 for (const auto& personPlan : person.second->getChildDemandElements()) {
1784 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1785 counter++;
1786 }
1787 }
1788 }
1789 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1790 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1791 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1792 counter++;
1793 }
1794 }
1795 }
1796 return counter;
1797}
1798
1799
1800int
1802 int counter = 0;
1803 // iterate over all person plans
1804 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1805 for (const auto& personPlan : person.second->getChildDemandElements()) {
1806 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1807 counter++;
1808 }
1809 }
1810 }
1811 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1812 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1813 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1814 counter++;
1815 }
1816 }
1817 }
1818 return counter;
1819}
1820
1821
1822int
1824 int counter = 0;
1825 // iterate over all person plans
1826 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1827 for (const auto& personPlan : person.second->getChildDemandElements()) {
1828 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1829 counter++;
1830 }
1831 }
1832 }
1833 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1834 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1835 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1836 counter++;
1837 }
1838 }
1839 }
1840 return counter;
1841}
1842
1843
1844int
1846 int counter = 0;
1847 // iterate over all containers
1848 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1849 if (container.second->isAttributeCarrierSelected()) {
1850 counter++;
1851 }
1852 }
1853 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1854 if (containerFlow.second->isAttributeCarrierSelected()) {
1855 counter++;
1856 }
1857 }
1858 return counter;
1859}
1860
1861
1862int
1864 int counter = 0;
1865 // iterate over all container plans
1866 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1867 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1868 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1869 counter++;
1870 }
1871 }
1872 }
1873 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1874 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1875 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1876 counter++;
1877 }
1878 }
1879 }
1880 return counter;
1881}
1882
1883
1884int
1886 int counter = 0;
1887 // iterate over all container plans
1888 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1889 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1890 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1891 counter++;
1892 }
1893 }
1894 }
1895 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1896 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1897 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1898 counter++;
1899 }
1900 }
1901 }
1902 return counter;
1903}
1904
1905
1906int
1908 int counter = 0;
1909 // iterate over routes
1910 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1911 for (const auto& stop : route.second->getChildDemandElements()) {
1912 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1913 counter++;
1914 }
1915 }
1916 }
1917 // vehicles
1918 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1919 for (const auto& stop : trip.second->getChildDemandElements()) {
1920 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1921 counter++;
1922 }
1923 }
1924 }
1925 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1926 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1927 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1928 counter++;
1929 }
1930 }
1931 for (const auto& stop : vehicle.second->getChildDemandElements()) {
1932 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1933 counter++;
1934 }
1935 }
1936 }
1937 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1938 for (const auto& stop : flow.second->getChildDemandElements()) {
1939 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1940 counter++;
1941 }
1942 }
1943 }
1944 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1945 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1946 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1947 counter++;
1948 }
1949 }
1950 for (const auto& stop : flow.second->getChildDemandElements()) {
1951 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1952 counter++;
1953 }
1954 }
1955 }
1956 // persons
1957 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1958 for (const auto& personPlan : person.second->getChildDemandElements()) {
1959 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1960 counter++;
1961 }
1962 }
1963 }
1964 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1965 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1966 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1967 counter++;
1968 }
1969 }
1970 }
1971 // containers
1972 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1973 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1974 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1975 counter++;
1976 }
1977 }
1978 }
1979 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1980 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1981 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1982 counter++;
1983 }
1984 }
1985 }
1986 return counter;
1987}
1988
1989
1991GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1992 for (const auto& dataSet : myDataSets) {
1993 if (dataSet.second->getID() == id) {
1994 return dataSet.second;
1995 }
1996 }
1997 if (hardFail) {
1998 throw ProcessError("Attempted to retrieve non-existant data set");
1999 } else {
2000 return nullptr;
2001 }
2002}
2003
2004
2005const std::map<const std::string, GNEDataSet*>&
2007 return myDataSets;
2008}
2009
2010
2011std::string
2013 // get prefix
2014 const auto prefix = OptionsCont::getOptions().getString("dataSet-prefix");
2015 int counter = 0;
2016 while (retrieveDataSet(prefix + "_" + toString(counter), false) != nullptr) {
2017 counter++;
2018 }
2019 return (prefix + "_" + toString(counter));
2020}
2021
2022
2025 if (myDataIntervals.count(AC)) {
2026 return myDataIntervals.at(AC);
2027 } else if (hardFail) {
2028 throw ProcessError("Attempted to retrieve non-existant data interval");
2029 } else {
2030 return nullptr;
2031 }
2032}
2033
2034
2035const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
2037 return myDataIntervals;
2038}
2039
2040
2041void
2043 if (myDataIntervals.count(AC) > 0) {
2044 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
2045 } else {
2046 myDataIntervals[AC] = dataInterval;
2047 }
2048 // mark interval toolbar for update
2049 myNet->getViewNet()->getIntervalBar().markForUpdate();
2050}
2051
2052
2053void
2055 const auto finder = myDataIntervals.find(dataInterval);
2056 if (finder == myDataIntervals.end()) {
2057 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
2058 } else {
2059 myDataIntervals.erase(finder);
2060 }
2061 // remove it from inspected elements and GNEElementTree
2062 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
2063 dataInterval->unmarkForDrawingFront();
2064 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
2065 // mark interval toolbar for update
2066 myNet->getViewNet()->getIntervalBar().markForUpdate();
2067}
2068
2069
2072 // iterate over all genericDatas
2073 for (const auto& genericDataTag : myGenericDatas) {
2074 auto it = genericDataTag.second.find(glObject);
2075 if (it != genericDataTag.second.end()) {
2076 return it->second;
2077 }
2078 }
2079 if (hardFail) {
2080 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
2081 } else {
2082 return nullptr;
2083 }
2084}
2085
2086
2087std::vector<GNEGenericData*>
2089 std::vector<GNEGenericData*> result;
2090 // returns generic datas depending of selection
2091 for (const auto& genericDataTag : myGenericDatas) {
2092 for (const auto& genericData : genericDataTag.second) {
2093 if (genericData.second->isAttributeCarrierSelected()) {
2094 result.push_back(genericData.second);
2095 }
2096 }
2097 }
2098 return result;
2099}
2100
2101
2102const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> >&
2104 return myGenericDatas;
2105}
2106
2107
2108std::vector<GNEGenericData*>
2109GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2110 // declare generic data vector
2111 std::vector<GNEGenericData*> genericDatas;
2112 // iterate over all data sets
2113 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2114 // check interval
2115 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2116 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2117 genericDatas.push_back(genericData.second);
2118 }
2119 }
2120 return genericDatas;
2121}
2122
2123
2124int
2126 int counter = 0;
2127 // iterate over all generic datas
2128 for (const auto& genericDataTag : myGenericDatas) {
2129 counter += (int)genericDataTag.second.size();
2130 }
2131 return counter;
2132}
2133
2134
2135int
2137 int counter = 0;
2138 // iterate over all edgeDatas
2139 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2140 if (genericData.second->isAttributeCarrierSelected()) {
2141 counter++;
2142 }
2143 }
2144 return counter;
2145}
2146
2147
2148int
2150 int counter = 0;
2151 // iterate over all edgeDatas
2152 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2153 if (genericData.second->isAttributeCarrierSelected()) {
2154 counter++;
2155 }
2156 }
2157 return counter;
2158}
2159
2160
2161int
2163 int counter = 0;
2164 // iterate over all edgeDatas
2165 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2166 if (genericData.second->isAttributeCarrierSelected()) {
2167 counter++;
2168 }
2169 }
2170 return counter;
2171}
2172
2173
2174void
2176 if (myGenericDatas.at(genericData->getTagProperty()->getTag()).count(genericData->getGUIGlObject()) > 0) {
2177 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2178 } else {
2179 myGenericDatas.at(genericData->getTagProperty()->getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2180 }
2181 // mark interval toolbar for update
2182 myNet->getViewNet()->getIntervalBar().markForUpdate();
2183}
2184
2185
2186void
2188 const auto finder = myGenericDatas.at(genericData->getTagProperty()->getTag()).find(genericData);
2189 if (finder == myGenericDatas.at(genericData->getTagProperty()->getTag()).end()) {
2190 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2191 } else {
2192 myGenericDatas.at(genericData->getTagProperty()->getTag()).erase(finder);
2193 }
2194 // remove it from inspected elements and GNEElementTree
2195 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2196 genericData->unmarkForDrawingFront();
2197 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2198 // delete path element
2199 myNet->getDataPathManager()->removePath(genericData);
2200 // mark interval toolbar for update
2201 myNet->getViewNet()->getIntervalBar().markForUpdate();
2202}
2203
2204
2205std::set<std::string>
2206GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2207 // declare solution
2208 std::set<std::string> attributesSolution;
2209 // declare generic data vector
2210 std::vector<GNEGenericData*> genericDatas;
2211 // iterate over all data sets
2212 for (const auto& interval : myDataIntervals) {
2213 // check interval
2214 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2215 // iterate over generic datas
2216 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2217 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2218 genericDatas.push_back(genericData);
2219 }
2220 }
2221 }
2222 }
2223 // iterate over generic datas
2224 for (const auto& genericData : genericDatas) {
2225 for (const auto& attribute : genericData->getParametersMap()) {
2226 attributesSolution.insert(attribute.first);
2227 }
2228 }
2229 return attributesSolution;
2230}
2231
2232
2233std::set<std::string>
2234GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2235 const std::string& beginStr, const std::string& endStr) const {
2236 // declare solution
2237 std::set<std::string> attributesSolution;
2238 // vector of data sets and intervals
2239 std::vector<GNEDataSet*> dataSets;
2240 std::vector<GNEDataInterval*> dataIntervals;
2241 // get dataSet
2242 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2243 // if dataSetID is empty, return all parameters
2244 if (dataSetID.empty()) {
2245 // add all data sets
2246 dataSets.reserve(myDataSets.size());
2247 for (const auto& dataSet : myDataSets) {
2248 dataSets.push_back(dataSet.second);
2249 }
2250 } else if (retrievedDataSet) {
2251 dataSets.push_back(retrievedDataSet);
2252 } else {
2253 return attributesSolution;
2254 }
2255 // now continue with data intervals
2256 int numberOfIntervals = 0;
2257 for (const auto& dataSet : dataSets) {
2258 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2259 }
2260 // resize dataIntervals
2261 dataIntervals.reserve(numberOfIntervals);
2262 // add intervals
2263 for (const auto& dataSet : dataSets) {
2264 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2265 // continue depending of begin and end
2266 if (beginStr.empty() && endStr.empty()) {
2267 dataIntervals.push_back(dataInterval.second);
2268 } else if (endStr.empty()) {
2269 // parse begin
2270 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2271 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2272 dataIntervals.push_back(dataInterval.second);
2273 }
2274 } else if (beginStr.empty()) {
2275 // parse end
2276 const double end = GNEAttributeCarrier::parse<double>(endStr);
2277 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2278 dataIntervals.push_back(dataInterval.second);
2279 }
2280 } else {
2281 // parse both begin end
2282 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2283 const double end = GNEAttributeCarrier::parse<double>(endStr);
2284 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2285 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2286 dataIntervals.push_back(dataInterval.second);
2287 }
2288 }
2289 }
2290 }
2291 // finally iterate over intervals and get attributes
2292 for (const auto& dataInterval : dataIntervals) {
2293 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2294 // check generic data tag
2295 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2296 for (const auto& attribute : genericData->getParametersMap()) {
2297 attributesSolution.insert(attribute.first);
2298 }
2299 }
2300 }
2301 }
2302 return attributesSolution;
2303}
2304
2305
2307GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2308 for (const auto& meanData : myMeanDatas.at(type)) {
2309 if (meanData.second->getID() == id) {
2310 return meanData.second;
2311 }
2312 }
2313 if (hardFail) {
2314 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2315 } else {
2316 return nullptr;
2317 }
2318}
2319
2320
2321const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> >&
2323 return myMeanDatas;
2324}
2325
2326
2327int
2329 return myNumberOfMeanDataElements;
2330}
2331
2332
2333void
2335 // iterate over myMeanDatas and clear all meanDatas
2336 for (auto& meanDatas : myMeanDatas) {
2337 meanDatas.second.clear();
2338 }
2339}
2340
2341
2342void
2344 const auto tag = meanData->getTagProperty()->getTag();
2345 const auto it = myMeanDatas.at(tag).find(meanData->getID());
2346 if (it == myMeanDatas.at(tag).end()) {
2347 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' doesn't exist in AttributeCarriers.meanDatas");
2348 } else {
2349 // remove from container, set new Id, and insert it again
2350 myMeanDatas.at(tag).erase(it);
2351 myMeanDatas.at(tag)[newID] = meanData;
2352 }
2353}
2354
2355
2356std::string
2358 // obtain option container
2359 const auto& neteditOptions = OptionsCont::getOptions();
2360 // get prefix
2361 std::string prefix;
2362 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2363 prefix = neteditOptions.getString("meanDataEdge-prefix");
2364 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2365 prefix = neteditOptions.getString("meanDataLane-prefix");
2366 }
2367 int counter = 0;
2368 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2369 counter++;
2370 }
2371 return (prefix + "_" + toString(counter));
2372}
2373
2374
2375void
2377 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2378 registerJunction(junction, false);
2379}
2380
2381
2382void
2384 // remove it from inspected elements and GNEElementTree
2385 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2386 junction->unmarkForDrawingFront();
2387 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2388 // Remove from grid and container
2389 myNet->removeGLObjectFromGrid(junction);
2390 myJunctions.erase(junction->getMicrosimID());
2391 myNumberOfNetworkElements--;
2392 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2393 junction->decRef("GNENet::deleteSingleJunction");
2394 junction->setResponsible(true);
2395}
2396
2397
2398void
2400 // get pointer to create edge frame
2401 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2402 // insert in myEdgeTypes
2403 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2404 myNumberOfNetworkElements++;
2405 // update edge selector
2406 if (myNet->getViewParent()->getCreateEdgeFrame()->shown()) {
2407 myNet->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2408 }
2409 // set current edge type inspected
2410 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2411}
2412
2413
2414void
2416 // get pointer to create edge frame
2417 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2418 // remove it from inspected elements and GNEElementTree
2419 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2420 edgeType->unmarkForDrawingFront();
2421 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2422 // remove from edge types
2423 myEdgeTypes.erase(edgeType->getMicrosimID());
2424 myNumberOfNetworkElements--;
2425 // check if this is the selected edge type in edgeSelector
2426 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2427 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2428 }
2429 // update edge selector
2430 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2431}
2432
2433
2434void
2436 NBEdge* nbe = edge->getNBEdge();
2437 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2438 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2439 nbe->getFromNode()->addOutgoingEdge(nbe);
2440 nbe->getToNode()->addIncomingEdge(nbe);
2441 // register edge
2442 registerEdge(edge);
2443}
2444
2445
2446void
2448 // remove it from inspected elements and GNEElementTree
2449 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2450 edge->unmarkForDrawingFront();
2451 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2452 // remove edge from visual grid and container
2453 myNet->removeGLObjectFromGrid(edge);
2454 myEdges.erase(edge->getMicrosimID());
2455 myNumberOfNetworkElements--;
2456 // remove all lanes
2457 for (const auto& lane : edge->getChildLanes()) {
2458 deleteLane(lane);
2459 }
2460 // extract edge of district container
2461 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2462 edge->decRef("GNENet::deleteSingleEdge");
2463 edge->setResponsible(true);
2464 // Remove refrences from GNEJunctions
2466 edge->getToJunction()->removeIncomingGNEEdge(edge);
2467 // update boundaries of both junctions (to remove it from Grid)
2470 // get template editor
2471 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewParent()->getInspectorFrame()->getTemplateEditor();
2472 // check if we have to remove template
2473 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2474 templateEditor->setEdgeTemplate(nullptr);
2475 }
2476}
2477
2478
2479void
2481 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2482 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2483 } else {
2484 myLanes[lane->getGUIGlObject()] = lane;
2485 myNumberOfNetworkElements++;
2486 }
2487}
2488
2489
2490void
2492 const auto finder = myLanes.find(lane->getGUIGlObject());
2493 if (finder == myLanes.end()) {
2494 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2495 } else {
2496 myLanes.erase(finder);
2497 myNumberOfNetworkElements--;
2498 // remove it from inspected elements and GNEElementTree
2499 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2500 lane->unmarkForDrawingFront();
2501 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2502 }
2503}
2504
2505
2506void
2508 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2509 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2510 } else {
2511 myCrossings[crossing->getGUIGlObject()] = crossing;
2512 myNumberOfNetworkElements++;
2513 }
2514}
2515
2516
2517void
2519 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2520 if (finder == myCrossings.end()) {
2521 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2522 } else {
2523 myCrossings.erase(finder);
2524 myNumberOfNetworkElements--;
2525 // remove it from inspected elements and GNEElementTree
2526 if (myNet->getViewNet()) {
2527 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2528 crossing->unmarkForDrawingFront();
2529 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2530 }
2531 }
2532}
2533
2534
2535void
2537 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2538 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2539 } else {
2540 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2541 myNumberOfNetworkElements++;
2542 }
2543}
2544
2545
2546void
2548 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2549 if (finder == myWalkingAreas.end()) {
2550 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2551 } else {
2552 myWalkingAreas.erase(finder);
2553 myNumberOfNetworkElements--;
2554 // remove it from inspected elements and GNEElementTree
2555 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2556 walkingArea->unmarkForDrawingFront();
2557 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2558 }
2559}
2560
2561
2562void
2564 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2565 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2566 } else {
2567 myConnections[connection->getGUIGlObject()] = connection;
2568 myNumberOfNetworkElements++;
2569 }
2570}
2571
2572
2573void
2575 const auto finder = myConnections.find(connection->getGUIGlObject());
2576 if (finder == myConnections.end()) {
2577 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2578 } else {
2579 myConnections.erase(finder);
2580 myNumberOfNetworkElements--;
2581 // remove it from inspected elements and GNEElementTree
2582 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2583 connection->unmarkForDrawingFront();
2584 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2585 }
2586}
2587
2588
2589void
2591 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2592 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getMicrosimID() + "' already exist");
2593 } else {
2594 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2595 myNumberOfNetworkElements++;
2596 }
2597}
2598
2599
2600void
2602 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2603 if (finder == myInternalLanes.end()) {
2604 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2605 } else {
2606 myInternalLanes.erase(finder);
2607 myNumberOfNetworkElements--;
2608 }
2609}
2610
2611
2612void
2614 const auto tag = additional->getTagProperty()->getTag();
2615 if (myAdditionals.at(tag).count(additional) > 0) {
2616 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2617 } else {
2618 // insert in both containers
2619 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2620 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2621 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2622 }
2623 myNumberOfNetworkElements++;
2624 // insert AC in fileBucket (use this function ton maintain integrity in options)
2625 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(additional);
2626 // add element in grid
2627 myNet->addGLObjectIntoGrid(additional);
2628 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2629 if (myNet->isUpdateGeometryEnabled()) {
2630 additional->updateGeometry();
2631 }
2632 // additionals has to be saved
2633 myNet->getSavingStatus()->requireSaveAdditionals();
2634 }
2635}
2636
2637
2638void
2640 const auto tag = additional->getTagProperty()->getTag();
2641 // find demanElement in additionalTag
2642 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2643 // check if additional was previously inserted
2644 if (itFind == myAdditionals.at(tag).end()) {
2645 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2646 } else {
2647 // remove from both container
2648 myAdditionals.at(tag).erase(itFind);
2649 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2650 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2651 }
2652 myNumberOfNetworkElements--;
2653 // remove AC from fileBucket (use this function ton maintain integrity in options)
2654 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(additional);
2655 // remove it from inspected elements and GNEElementTree
2656 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2657 additional->unmarkForDrawingFront();
2658 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2659 // remove element from grid
2660 myNet->removeGLObjectFromGrid(additional);
2661 // delete path element
2662 myNet->getNetworkPathManager()->removePath(additional);
2663 // additionals has to be saved
2664 myNet->getSavingStatus()->requireSaveAdditionals();
2665 }
2666}
2667
2668
2669
2670
2671void
2673 const auto sourceSinkTag = sourceSink->getTagProperty()->getTag();
2674 if (myTAZSourceSinks.at(sourceSinkTag).count(sourceSink) > 0) {
2675 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' already exist");
2676 } else {
2677 myTAZSourceSinks.at(sourceSinkTag)[sourceSink] = sourceSink;
2678 myNumberOfNetworkElements++;
2679 // insert AC in fileBucket (use this function ton maintain integrity in options)
2680 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(sourceSink);
2681 // additionals has to be saved
2682 myNet->getSavingStatus()->requireSaveAdditionals();
2683 }
2684}
2685
2686
2687void
2689 const auto tag = sourceSink->getTagProperty()->getTag();
2690 // find demanElement in additionalTag
2691 auto itFind = myTAZSourceSinks.at(tag).find(sourceSink);
2692 // check if sourceSink was previously inserted
2693 if (itFind == myTAZSourceSinks.at(tag).end()) {
2694 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' wasn't previously inserted");
2695 } else {
2696 // remove from both container
2697 myTAZSourceSinks.at(tag).erase(itFind);
2698 myNumberOfNetworkElements--;
2699 // remove AC from fileBucket (use this function ton maintain integrity in options)
2700 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(sourceSink);
2701 // remove it from inspected elements and GNEElementTree
2702 myNet->getViewNet()->getInspectedElements().uninspectAC(sourceSink);
2703 sourceSink->unmarkForDrawingFront();
2704 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(sourceSink);
2705 // additionals has to be saved
2706 myNet->getSavingStatus()->requireSaveAdditionals();
2707 }
2708}
2709
2710
2711void
2713 const auto tag = demandElement->getTagProperty()->getTag();
2714 if (myDemandElements.at(tag).count(demandElement) > 0) {
2715 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2716 } else {
2717 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2718 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2719 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2720 }
2721 myNumberOfDemandElements++;
2722 // insert AC in fileBucket (use this function ton maintain integrity in options)
2723 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(demandElement);
2724 // add element in grid
2725 myNet->addGLObjectIntoGrid(demandElement);
2726 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2727 if (myNet->isUpdateGeometryEnabled()) {
2728 demandElement->updateGeometry();
2729 }
2730 // compute path element
2731 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2732 demandElement->computePathElement();
2733 }
2734 // update demand elements frames
2735 updateDemandElementFrames(demandElement->getTagProperty());
2736 // demandElements has to be saved
2737 myNet->getSavingStatus()->requireSaveDemandElements();
2738 }
2739}
2740
2741
2742void
2744 const auto tag = demandElement->getTagProperty()->getTag();
2745 auto viewParent = myNet->getViewParent();
2746 // find demanElement in demandElementTag
2747 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2748 // check if demandElement was previously inserted
2749 if (itFind == myDemandElements.at(tag).end()) {
2750 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2751 } else {
2752 // erase it from container
2753 myDemandElements.at(tag).erase(itFind);
2754 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2755 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2756 }
2757 myNumberOfDemandElements--;
2758 // remove AC from fileBucket (use this function ton maintain integrity in options)
2759 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(demandElement);
2760 // remove element from grid
2761 myNet->removeGLObjectFromGrid(demandElement);
2762 // remove it from inspected elements and GNEElementTree
2763 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2764 demandElement->unmarkForDrawingFront();
2765 // if is the last inserted route, remove it from GNEViewNet
2766 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2767 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2768 }
2769 // delete path element
2770 myNet->getDemandPathManager()->removePath(demandElement);
2771 // check if update demand elements frames
2772 if (updateFrames) {
2773 updateDemandElementFrames(demandElement->getTagProperty());
2774 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2775 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2776 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2777 // update distribution frames
2778 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2779 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2780 }
2781 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2782 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2783 }
2784 // special case for distribution references
2785 if (demandElement->getTagProperty()->getTag() == GNE_TAG_VTYPEREF) {
2786 viewParent->getTypeDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2787 }
2788 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
2789 viewParent->getRouteDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2790 }
2791 }
2792 // demandElements has to be saved
2793 myNet->getSavingStatus()->requireSaveDemandElements();
2794 }
2795}
2796
2797
2798void
2800 if (myDataSets.count(dataSet->getID()) > 0) {
2801 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2802 } else {
2803 myDataSets[dataSet->getID()] = dataSet;
2804 myNumberOfDataElements++;
2805 // insert AC in fileBucket (use this function ton maintain integrity in options)
2806 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(dataSet);
2807 // dataSets has to be saved
2808 myNet->getSavingStatus()->requireSaveDataElements();
2809 // mark interval toolbar for update
2810 myNet->getViewNet()->getIntervalBar().markForUpdate();
2811 }
2812}
2813
2814
2815void
2817 const auto finder = myDataSets.find(dataSet->getID());
2818 if (finder == myDataSets.end()) {
2819 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2820 } else {
2821 myDataSets.erase(finder);
2822 myNumberOfDataElements--;
2823 // remove AC from fileBucket (use this function ton maintain integrity in options)
2824 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(dataSet);
2825 // remove it from inspected elements and GNEElementTree
2826 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2827 dataSet->unmarkForDrawingFront();
2828 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2829 // dataSets has to be saved
2830 myNet->getSavingStatus()->requireSaveDataElements();
2831 // mark interval toolbar for update
2832 myNet->getViewNet()->getIntervalBar().markForUpdate();
2833 }
2834}
2835
2836
2837void
2839 if (myMeanDatas.at(meanData->getTagProperty()->getTag()).count(meanData->getID()) > 0) {
2840 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2841 } else {
2842 myMeanDatas.at(meanData->getTagProperty()->getTag()).insert(std::make_pair(meanData->getID(), meanData));
2843 myNumberOfMeanDataElements++;
2844 // insert AC in fileBucket (use this function ton maintain integrity in options)
2845 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(meanData);
2846 // meanDatas has to be saved
2847 myNet->getSavingStatus()->requireSaveMeanDatas();
2848 }
2849}
2850
2851
2852void
2854 // find demanElement in meanDataTag
2855 auto itFind = myMeanDatas.at(meanData->getTagProperty()->getTag()).find(meanData->getID());
2856 // check if meanData was previously inserted
2857 if (itFind == myMeanDatas.at(meanData->getTagProperty()->getTag()).end()) {
2858 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2859 } else {
2860 // remove from container
2861 myMeanDatas.at(meanData->getTagProperty()->getTag()).erase(itFind);
2862 myNumberOfMeanDataElements--;
2863 // remove AC from fileBucket (use this function ton maintain integrity in options)
2864 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(meanData);
2865 // remove it from inspected elements and GNEElementTree
2866 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2867 meanData->unmarkForDrawingFront();
2868 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2869 // remove element from grid
2870 myNet->removeGLObjectFromGrid(meanData);
2871 // meanDatas has to be saved
2872 myNet->getSavingStatus()->requireSaveMeanDatas();
2873 }
2874}
2875
2876
2877void
2879 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2880 // continue depending of demand mode
2881 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2883 if (tagProperty->isType()) {
2884 myNet->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2885 }
2886 break;
2888 if (tagProperty->isType()) {
2889 myNet->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2890 }
2891 break;
2893 if (tagProperty->isType()) {
2894 myNet->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2895 }
2896 break;
2898 if (tagProperty->isRoute()) {
2899 myNet->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2900 }
2901 break;
2903 if (tagProperty->isType()) {
2904 myNet->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2905 }
2906 break;
2908 if (tagProperty->isPerson()) {
2909 myNet->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2910 }
2911 break;
2913 if (tagProperty->isType()) {
2914 myNet->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2915 }
2916 break;
2918 if (tagProperty->isContainer()) {
2919 myNet->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2920 }
2921 break;
2923 myNet->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2924 break;
2925 default:
2926 // nothing to update
2927 break;
2928 }
2929 }
2930}
2931
2932
2933void
2935 // fill network elements
2936 if (tag->getTag() == SUMO_TAG_JUNCTION) {
2937 for (const auto& junction : myJunctions) {
2938 ACs.push_back(junction.second);
2939 }
2940 }
2941 if (tag->getTag() == SUMO_TAG_EDGE) {
2942 for (const auto& edge : myEdges) {
2943 ACs.push_back(edge.second);
2944 }
2945 }
2946 if (tag->getTag() == SUMO_TAG_LANE) {
2947 for (const auto& lane : myLanes) {
2948 ACs.push_back(lane.second);
2949 }
2950 }
2951 if (tag->getTag() == SUMO_TAG_CONNECTION) {
2952 for (const auto& connection : myConnections) {
2953 ACs.push_back(connection.second);
2954 }
2955 }
2956 if (tag->getTag() == SUMO_TAG_CROSSING) {
2957 for (const auto& crossing : myCrossings) {
2958 ACs.push_back(crossing.second);
2959 }
2960 }
2961 if (tag->getTag() == SUMO_TAG_WALKINGAREA) {
2962 for (const auto& walkingArea : myWalkingAreas) {
2963 ACs.push_back(walkingArea.second);
2964 }
2965 }
2966 // fill additional elements
2967 if (tag->isAdditionalElement()) {
2968 for (const auto& additionalTag : myAdditionals) {
2969 if (additionalTag.first == tag->getTag()) {
2970 for (const auto& additional : additionalTag.second) {
2971 ACs.push_back(additional.second);
2972 }
2973 }
2974 }
2975 }
2976 // fill demand elements
2977 if (tag->isDemandElement()) {
2978 for (const auto& demandElementTag : myDemandElements) {
2979 if (demandElementTag.first == tag->getTag()) {
2980 for (const auto& demandElemet : demandElementTag.second) {
2981 ACs.push_back(demandElemet.second);
2982 }
2983 }
2984 }
2985 }
2986 // fill data elements
2987 if (tag->isDataElement()) {
2988 if (tag->getTag() == SUMO_TAG_DATASET) {
2989 for (const auto& dataSet : myDataSets) {
2990 ACs.push_back(dataSet.second);
2991 }
2992 }
2993 if (tag->getTag() == SUMO_TAG_DATAINTERVAL) {
2994 for (const auto& dataInterval : myDataIntervals) {
2995 ACs.push_back(dataInterval.second);
2996 }
2997 }
2998 for (const auto& genericDataTag : myGenericDatas) {
2999 if (genericDataTag.first == tag->getTag()) {
3000 for (const auto& genericData : genericDataTag.second) {
3001 ACs.push_back(genericData.second);
3002 }
3003 }
3004 }
3005 for (const auto& meanDataTag : myMeanDatas) {
3006 if (meanDataTag.first == tag->getTag()) {
3007 for (const auto& meanData : meanDataTag.second) {
3008 ACs.push_back(meanData.second);
3009 }
3010 }
3011 }
3012 }
3013 // iterate over children
3014 for (const auto child : tag->getHierarchicalChildren()) {
3015 retrieveAttributeCarriersRecursively(child, ACs);
3016 }
3017}
3018
3019// ---------------------------------------------------------------------------
3020// GNENetHelper::GNETagSelector - methods
3021// ---------------------------------------------------------------------------
3022
3024 myNet(net) {
3025}
3026
3027
3028void
3030 // network
3031 myTemplates[SUMO_TAG_CROSSING] = new GNECrossing(myNet);
3032 // special case for edge type
3033 myEdgeType = new GNEEdgeType(myNet);
3034 myTemplates[SUMO_TAG_TYPE] = myEdgeType;
3035 // additionals
3036 myTemplates[SUMO_TAG_BUS_STOP] = GNEBusStop::buildBusStop(myNet);
3037 myTemplates[SUMO_TAG_TRAIN_STOP] = GNEBusStop::buildTrainStop(myNet);
3038 myTemplates[SUMO_TAG_ACCESS] = new GNEAccess(myNet);
3039 myTemplates[SUMO_TAG_CONTAINER_STOP] = new GNEContainerStop(myNet);
3040 myTemplates[SUMO_TAG_CHARGING_STATION] = new GNEChargingStation(myNet);
3041 myTemplates[SUMO_TAG_PARKING_AREA] = new GNEParkingArea(myNet);
3042 myTemplates[SUMO_TAG_PARKING_SPACE] = new GNEParkingSpace(myNet);
3043 myTemplates[SUMO_TAG_INDUCTION_LOOP] = new GNEInductionLoopDetector(myNet);
3048 myTemplates[SUMO_TAG_DET_EXIT] = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet);
3050 myTemplates[SUMO_TAG_VSS] = new GNEVariableSpeedSign(myNet);
3051 myTemplates[SUMO_TAG_STEP] = new GNEVariableSpeedSignStep(myNet);
3052 myTemplates[SUMO_TAG_CALIBRATOR] = new GNECalibrator(SUMO_TAG_CALIBRATOR, myNet);
3054 myTemplates[GNE_TAG_CALIBRATOR_FLOW] = new GNECalibratorFlow(myNet);
3055 myTemplates[SUMO_TAG_REROUTER] = new GNERerouter(myNet);
3056 myTemplates[SUMO_TAG_INTERVAL] = new GNERerouterInterval(myNet);
3057 myTemplates[SUMO_TAG_CLOSING_REROUTE] = new GNEClosingReroute(myNet);
3058 myTemplates[SUMO_TAG_CLOSING_LANE_REROUTE] = new GNEClosingLaneReroute(myNet);
3059 myTemplates[SUMO_TAG_DEST_PROB_REROUTE] = new GNEDestProbReroute(myNet);
3060 myTemplates[SUMO_TAG_PARKING_AREA_REROUTE] = new GNEParkingAreaReroute(myNet);
3061 myTemplates[SUMO_TAG_ROUTE_PROB_REROUTE] = new GNERouteProbReroute(myNet);
3062 myTemplates[SUMO_TAG_ROUTEPROBE] = new GNERouteProbe(myNet);
3063 myTemplates[SUMO_TAG_VAPORIZER] = new GNEVaporizer(myNet);
3064 // symbols
3065 myTemplates[GNE_TAG_REROUTER_SYMBOL] = new GNERerouterSymbol(myNet);
3066 myTemplates[GNE_TAG_VSS_SYMBOL] = new GNEVariableSpeedSignSymbol(myNet);
3067 // shapes
3068 myTemplates[SUMO_TAG_POLY] = new GNEPoly(SUMO_TAG_POLY, myNet);
3069 myTemplates[SUMO_TAG_POI] = new GNEPOI(SUMO_TAG_POI, myNet);
3070 myTemplates[GNE_TAG_POILANE] = new GNEPOI(GNE_TAG_POILANE, myNet);
3071 myTemplates[GNE_TAG_POIGEO] = new GNEPOI(GNE_TAG_POIGEO, myNet);
3072 // TAZs
3073 myTemplates[SUMO_TAG_TAZ] = new GNETAZ(myNet);
3074 myTemplates[SUMO_TAG_TAZSOURCE] = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, myNet);
3075 myTemplates[SUMO_TAG_TAZSINK] = new GNETAZSourceSink(SUMO_TAG_TAZSINK, myNet);
3076 // wires
3077 myTemplates[SUMO_TAG_TRACTION_SUBSTATION] = new GNETractionSubstation(myNet);
3078 myTemplates[SUMO_TAG_OVERHEAD_WIRE_SECTION] = new GNEOverheadWire(myNet);
3079 //myTemplates[SUMO_TAG_OVERHEAD_WIRE_CLAMP] = nullptr; // TMP
3080 // JuPedSim elements
3082 myTemplates[GNE_TAG_JPS_OBSTACLE] = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet);
3083 // vTypes
3084 myTemplates[SUMO_TAG_VTYPE] = new GNEVType(SUMO_TAG_VTYPE, myNet);
3085 // vType distributions
3086 myTemplates[SUMO_TAG_VTYPE_DISTRIBUTION] = new GNEVTypeDistribution(myNet);
3087 myTemplates[GNE_TAG_VTYPEREF] = new GNEVTypeRef(myNet);
3088 // routes
3089 myTemplates[SUMO_TAG_ROUTE] = new GNERoute(SUMO_TAG_ROUTE, myNet);
3090 myTemplates[GNE_TAG_ROUTE_EMBEDDED] = new GNERoute(GNE_TAG_ROUTE_EMBEDDED, myNet);
3091 // route distribution
3092 myTemplates[SUMO_TAG_ROUTE_DISTRIBUTION] = new GNERouteDistribution(myNet);
3093 myTemplates[GNE_TAG_ROUTEREF] = new GNERouteRef(myNet);
3094 // vehicles
3095 const auto vehicles = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::VEHICLE);
3096 for (const auto vehicle : vehicles) {
3097 myTemplates[vehicle->getTag()] = new GNEVehicle(vehicle->getTag(), myNet);
3098 }
3099 // persons
3100 const auto persons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSON);
3101 for (const auto person : persons) {
3102 myTemplates[person->getTag()] = new GNEPerson(person->getTag(), myNet);
3103 }
3104 // container
3105 const auto containers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::CONTAINER);
3106 for (const auto container : containers) {
3107 myTemplates[container->getTag()] = new GNEContainer(container->getTag(), myNet);
3108 }
3109 // stops and waypoints
3110 const auto stopAndWaypoints = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_VEHICLE);
3111 for (const auto stopAndWaypoint : stopAndWaypoints) {
3112 myTemplates[stopAndWaypoint->getTag()] = new GNEStop(stopAndWaypoint->getTag(), myNet);
3113 }
3114 // personTrip
3115 const auto personTrips = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSONTRIP);
3116 for (const auto personTrip : personTrips) {
3117 myTemplates[personTrip->getTag()] = new GNEPersonTrip(personTrip->getTag(), myNet);
3118 }
3119 // walk
3120 const auto walks = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::WALK);
3121 for (const auto walk : walks) {
3122 myTemplates[walk->getTag()] = new GNEWalk(walk->getTag(), myNet);
3123 }
3124 // ride
3125 const auto rides = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::RIDE);
3126 for (const auto ride : rides) {
3127 myTemplates[ride->getTag()] = new GNERide(ride->getTag(), myNet);
3128 }
3129 // stop person
3130 const auto stopPersons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_PERSON);
3131 for (const auto stopPerson : stopPersons) {
3132 myTemplates[stopPerson->getTag()] = new GNEStopPlan(stopPerson->getTag(), myNet);
3133 }
3134 // transport
3135 const auto transports = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSPORT);
3136 for (const auto transport : transports) {
3137 myTemplates[transport->getTag()] = new GNETransport(transport->getTag(), myNet);
3138 }
3139 // tranship
3140 const auto tranships = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSHIP);
3141 for (const auto tranship : tranships) {
3142 myTemplates[tranship->getTag()] = new GNETranship(tranship->getTag(), myNet);
3143 }
3144 // stop container
3145 const auto stopContainers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_CONTAINER);
3146 for (const auto stopContainer : stopContainers) {
3147 myTemplates[stopContainer->getTag()] = new GNEStopPlan(stopContainer->getTag(), myNet);
3148 }
3149 // dataSet
3150 myTemplates[SUMO_TAG_DATASET] = new GNEDataSet(myNet);
3151 // generic datas
3152 myTemplates[GNE_TAG_EDGEREL_SINGLE] = new GNEEdgeData(myNet);
3153 myTemplates[SUMO_TAG_EDGEREL] = new GNEEdgeRelData(myNet);
3154 myTemplates[SUMO_TAG_TAZREL] = new GNETAZRelData(myNet);
3155 // reset all to their default values
3156 for (const auto& AC : myTemplates) {
3157 AC.second->resetDefaultValues(false);
3158 }
3159 // fill plan templates
3160 fillPlanTemplates();
3161}
3162
3163
3165 for (auto& AC : myTemplates) {
3166 delete AC.second;
3167 }
3168}
3169
3170
3171std::map<SumoXMLTag, GNEAttributeCarrier*>
3173 return myTemplates;
3174}
3175
3176
3179 if (myTemplates.count(tag) > 0) {
3180 return myTemplates.at(tag);
3181 } else {
3182 return nullptr;
3183 }
3184}
3185
3186
3188GNENetHelper::ACTemplate::getTemplateAC(const std::string& selectorText) const {
3189 for (const auto& templateAC : myTemplates) {
3190 if (templateAC.second->getTagProperty()->getSelectorText() == selectorText) {
3191 return templateAC.second;
3192 }
3193 }
3194 return nullptr;
3195}
3196
3197
3200 return myEdgeType;
3201}
3202
3203
3204const std::vector<std::pair<GNETagProperties*, GNEDemandElement*>>&
3206 return myPlanTemplates.at(tag);
3207}
3208
3209
3210void
3212 GNETagProperties* tagProperty = nullptr;
3213 // person trip
3214 tagProperty = new GNETagProperties(SUMO_TAG_PERSONTRIP, nullptr,
3228 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEPersonTrip(GNE_TAG_PERSONTRIP_EDGE_EDGE, myNet)));
3229 // ride
3230 tagProperty = new GNETagProperties(SUMO_TAG_RIDE, nullptr,
3244 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNERide(GNE_TAG_RIDE_EDGE_EDGE, myNet)));
3245 // walk
3246 tagProperty = new GNETagProperties(SUMO_TAG_WALK, nullptr,
3260 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGE_EDGE, myNet)));
3261 // walk (edges)
3262 tagProperty = new GNETagProperties(GNE_TAG_WALK_EDGES, nullptr,
3269 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGES, myNet)));
3270 // walk (route)
3271 tagProperty = new GNETagProperties(GNE_TAG_WALK_ROUTE, nullptr,
3278 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_ROUTE, myNet)));
3279 // stop
3280 tagProperty = new GNETagProperties(GNE_TAG_PERSONSTOPS, nullptr,
3289 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPPERSON_EDGE, myNet)));
3290 // transport
3291 tagProperty = new GNETagProperties(SUMO_TAG_TRANSPORT, 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 GNETransport(GNE_TAG_TRANSPORT_EDGE_EDGE, myNet)));
3306 // tranship
3307 tagProperty = new GNETagProperties(SUMO_TAG_TRANSHIP, nullptr,
3311 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3312 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3313 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3314 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3316 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3317 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3321 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGE_EDGE, myNet)));
3322 // tranship (edges)
3323 tagProperty = new GNETagProperties(GNE_TAG_TRANSHIP_EDGES, nullptr,
3330 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGES, myNet)));
3331 // stop
3332 tagProperty = new GNETagProperties(GNE_TAG_CONTAINERSTOPS, nullptr,
3341 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPCONTAINER_EDGE, myNet)));
3342}
3343
3344// ---------------------------------------------------------------------------
3345// GNENetHelper::SavingStatus - methods
3346// ---------------------------------------------------------------------------
3347
3349 myNet(net) {
3350}
3351
3352
3353void
3355 mySumoConfigSaved = false;
3356}
3357
3358
3359void
3361 mySumoConfigSaved = true;
3362}
3363
3364
3365bool
3367 return mySumoConfigSaved;
3368}
3369
3370
3371void
3373 myNeteditConfigSaved = false;
3374}
3375
3376
3377void
3379 myNeteditConfigSaved = true;
3380}
3381
3382
3383bool
3385 return myNeteditConfigSaved;
3386}
3387
3388
3389void
3391 myNetworkSaved = false;
3392 // implies requiere save netedit config and sumo config
3393 myNeteditConfigSaved = false;
3394 mySumoConfigSaved = false;
3395}
3396
3397
3398void
3400 myNetworkSaved = true;
3401}
3402
3403
3404bool
3406 return myNetworkSaved;
3407}
3408
3409
3410void
3412 myTLSSaved = false;
3413}
3414
3415
3416void
3418 myTLSSaved = true;
3419}
3420
3421
3422bool
3424 return myTLSSaved;
3425}
3426
3427
3428void
3430 myEdgeTypeSaved = false;
3431}
3432
3433
3434void
3436 myEdgeTypeSaved = true;
3437}
3438
3439
3440bool
3442 return myEdgeTypeSaved;
3443}
3444
3445
3446void
3448 myAdditionalSaved = false;
3449 // implies requiere save netedit config and sumo config
3450 myNeteditConfigSaved = false;
3451 mySumoConfigSaved = false;
3452}
3453
3454
3455void
3457 myAdditionalSaved = true;
3458}
3459
3460
3461bool
3463 return myAdditionalSaved;
3464}
3465
3466
3467void
3469 myDemandElementSaved = false;
3470 // implies requiere save netedit config and sumo config
3471 myNeteditConfigSaved = false;
3472 mySumoConfigSaved = false;
3473}
3474
3475
3476void
3478 myDemandElementSaved = true;
3479}
3480
3481
3482bool
3484 return myDemandElementSaved;
3485}
3486
3487
3488void
3490 myDataElementSaved = false;
3491 // implies requiere save netedit config and sumo config
3492 myNeteditConfigSaved = false;
3493 mySumoConfigSaved = false;
3494}
3495
3496
3497void
3499 myDataElementSaved = true;
3500}
3501
3502
3503bool
3505 return myDataElementSaved;
3506}
3507
3508
3509void
3511 myMeanDataElementSaved = false;
3512 // implies requiere save netedit config and sumo config
3513 myNeteditConfigSaved = false;
3514 mySumoConfigSaved = false;
3515}
3516
3517
3518void
3520 myMeanDataElementSaved = true;
3521}
3522
3523
3524bool
3526 return myMeanDataElementSaved;
3527}
3528
3529
3532 auto GNEApp = myNet->getGNEApplicationWindow();
3533 // Check if there are non saved network elements
3534 if (commonResult == GNEDialog::Result::ABORT) {
3536 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3538 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3540 } else if (myNetworkSaved) {
3542 } else {
3543 // open save dialog
3544 const GNESaveDialog saveDialog(GNEApp, TL("network"));
3545 // continue depending of result
3546 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3547 commonResult = GNEDialog::Result::ABORT;
3549 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3550 commonResult = GNEDialog::Result::ACCEPT_ALL;
3552 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3553 commonResult = GNEDialog::Result::CANCEL_ALL;
3555 } else {
3556 return saveDialog.getResult();
3557 }
3558 }
3559}
3560
3561
3564 auto GNEApp = myNet->getGNEApplicationWindow();
3565 // Check if there are non saved additional elements
3566 if (commonResult == GNEDialog::Result::ABORT) {
3568 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3570 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3572 } else if (myAdditionalSaved) {
3574 } else {
3575 // open save dialog
3576 const GNESaveDialog saveDialog(GNEApp, TL("additional elements"));
3577 // continue depending of result
3578 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3579 commonResult = GNEDialog::Result::ABORT;
3581 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3582 commonResult = GNEDialog::Result::ACCEPT_ALL;
3584 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3585 commonResult = GNEDialog::Result::CANCEL_ALL;
3587 } else {
3588 return saveDialog.getResult();
3589 }
3590 }
3591}
3592
3593
3596 auto GNEApp = myNet->getGNEApplicationWindow();
3597 // Check if there are non saved demand elements
3598 if (commonResult == GNEDialog::Result::ABORT) {
3600 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3602 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3604 } else if (myDemandElementSaved) {
3606 } else {
3607 // open save dialog
3608 const GNESaveDialog saveDialog(GNEApp, TL("demand elements"));
3609 // continue depending of result
3610 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3611 commonResult = GNEDialog::Result::ABORT;
3613 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3614 commonResult = GNEDialog::Result::ACCEPT_ALL;
3616 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3617 commonResult = GNEDialog::Result::CANCEL_ALL;
3619 } else {
3620 return saveDialog.getResult();
3621 }
3622 }
3623}
3624
3625
3628 auto GNEApp = myNet->getGNEApplicationWindow();
3629 // Check if there are non saved data elements
3630 if (commonResult == GNEDialog::Result::ABORT) {
3632 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3634 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3636 } else if (myDataElementSaved) {
3638 } else {
3639 // open save dialog
3640 const GNESaveDialog saveDialog(GNEApp, TL("data elements"));
3641 // continue depending of result
3642 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3643 commonResult = GNEDialog::Result::ABORT;
3645 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3646 commonResult = GNEDialog::Result::ACCEPT_ALL;
3648 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3649 commonResult = GNEDialog::Result::CANCEL_ALL;
3651 } else {
3652 return saveDialog.getResult();
3653 }
3654 }
3655}
3656
3657
3660 auto GNEApp = myNet->getGNEApplicationWindow();
3661 // Check if there are non saved mean data elements
3662 if (commonResult == GNEDialog::Result::ABORT) {
3664 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3666 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3668 } else if (myMeanDataElementSaved) {
3670 } else {
3671 // open save dialog
3672 const GNESaveDialog saveDialog(GNEApp, TL("meanData elements"));
3673 // continue depending of result
3674 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3675 commonResult = GNEDialog::Result::ABORT;
3677 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3678 commonResult = GNEDialog::Result::ACCEPT_ALL;
3680 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3681 commonResult = GNEDialog::Result::CANCEL_ALL;
3683 } else {
3684 return saveDialog.getResult();
3685 }
3686 }
3687}
3688
3689// ---------------------------------------------------------------------------
3690// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
3691// ---------------------------------------------------------------------------
3692
3694 GNEChange(Supermode::NETWORK, true, false),
3695 myTllcont(tllcont),
3696 myReplaced(replaced),
3697 myBy(by) {
3698}
3699
3700
3702
3703
3704void
3706 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3707 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
3708}
3709
3710
3711void
3713 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3714 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
3715}
3716
3717
3718std::string
3720 return TL("Redo replace in TLS");
3721}
3722
3723
3724std::string
3726 return TL("Undo replace in TLS");
3727}
3728
3729
3730bool
3732 return myReplaced != myBy;
3733}
3734
3735/****************************************************************************/
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:652
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition GNEEdge.cpp:1523
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:773
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2263
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:646
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 updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
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:625
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.
const std::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * >, std::hash< int > > & getMeanDatas() const
get meanDatas
GNEJunction * registerJunction(GNEJunction *junction, bool afterVolatile)
registers a junction in containers
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:541
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition NBNode.cpp:4219
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:3165
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition NBNode.cpp:551
const Position & getPosition() const
Definition NBNode.h:262
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2792
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