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 if (route.second->isAttributeCarrierSelected()) {
1912 counter++;
1913 }
1914 }
1915 // vehicles
1916 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1917 for (const auto& stop : trip.second->getChildDemandElements()) {
1918 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1919 counter++;
1920 }
1921 }
1922 }
1923 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1924 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1925 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1926 counter++;
1927 }
1928 }
1929 }
1930 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1931 for (const auto& stop : flow.second->getChildDemandElements()) {
1932 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1933 counter++;
1934 }
1935 }
1936 }
1937 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1938 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1939 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1940 counter++;
1941 }
1942 }
1943 }
1944 // persons
1945 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1946 for (const auto& personPlan : person.second->getChildDemandElements()) {
1947 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1948 counter++;
1949 }
1950 }
1951 }
1952 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1953 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1954 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1955 counter++;
1956 }
1957 }
1958 }
1959 // containers
1960 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1961 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1962 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1963 counter++;
1964 }
1965 }
1966 }
1967 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1968 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1969 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1970 counter++;
1971 }
1972 }
1973 }
1974 return counter;
1975}
1976
1977
1979GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1980 for (const auto& dataSet : myDataSets) {
1981 if (dataSet.second->getID() == id) {
1982 return dataSet.second;
1983 }
1984 }
1985 if (hardFail) {
1986 throw ProcessError("Attempted to retrieve non-existant data set");
1987 } else {
1988 return nullptr;
1989 }
1990}
1991
1992
1993const std::map<const std::string, GNEDataSet*>&
1995 return myDataSets;
1996}
1997
1998
1999std::string
2001 // get prefix
2002 const auto prefix = OptionsCont::getOptions().getString("dataSet-prefix");
2003 int counter = 0;
2004 while (retrieveDataSet(prefix + "_" + toString(counter), false) != nullptr) {
2005 counter++;
2006 }
2007 return (prefix + "_" + toString(counter));
2008}
2009
2010
2013 if (myDataIntervals.count(AC)) {
2014 return myDataIntervals.at(AC);
2015 } else if (hardFail) {
2016 throw ProcessError("Attempted to retrieve non-existant data interval");
2017 } else {
2018 return nullptr;
2019 }
2020}
2021
2022
2023const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
2025 return myDataIntervals;
2026}
2027
2028
2029void
2031 if (myDataIntervals.count(AC) > 0) {
2032 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
2033 } else {
2034 myDataIntervals[AC] = dataInterval;
2035 }
2036 // mark interval toolbar for update
2037 myNet->getViewNet()->getIntervalBar().markForUpdate();
2038}
2039
2040
2041void
2043 const auto finder = myDataIntervals.find(dataInterval);
2044 if (finder == myDataIntervals.end()) {
2045 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
2046 } else {
2047 myDataIntervals.erase(finder);
2048 }
2049 // remove it from inspected elements and GNEElementTree
2050 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
2051 dataInterval->unmarkForDrawingFront();
2052 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
2053 // mark interval toolbar for update
2054 myNet->getViewNet()->getIntervalBar().markForUpdate();
2055}
2056
2057
2060 // iterate over all genericDatas
2061 for (const auto& genericDataTag : myGenericDatas) {
2062 auto it = genericDataTag.second.find(glObject);
2063 if (it != genericDataTag.second.end()) {
2064 return it->second;
2065 }
2066 }
2067 if (hardFail) {
2068 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
2069 } else {
2070 return nullptr;
2071 }
2072}
2073
2074
2075std::vector<GNEGenericData*>
2077 std::vector<GNEGenericData*> result;
2078 // returns generic datas depending of selection
2079 for (const auto& genericDataTag : myGenericDatas) {
2080 for (const auto& genericData : genericDataTag.second) {
2081 if (genericData.second->isAttributeCarrierSelected()) {
2082 result.push_back(genericData.second);
2083 }
2084 }
2085 }
2086 return result;
2087}
2088
2089
2090const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> >&
2092 return myGenericDatas;
2093}
2094
2095
2096std::vector<GNEGenericData*>
2097GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2098 // declare generic data vector
2099 std::vector<GNEGenericData*> genericDatas;
2100 // iterate over all data sets
2101 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2102 // check interval
2103 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2104 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2105 genericDatas.push_back(genericData.second);
2106 }
2107 }
2108 return genericDatas;
2109}
2110
2111
2112int
2114 int counter = 0;
2115 // iterate over all generic datas
2116 for (const auto& genericDataTag : myGenericDatas) {
2117 counter += (int)genericDataTag.second.size();
2118 }
2119 return counter;
2120}
2121
2122
2123int
2125 int counter = 0;
2126 // iterate over all edgeDatas
2127 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2128 if (genericData.second->isAttributeCarrierSelected()) {
2129 counter++;
2130 }
2131 }
2132 return counter;
2133}
2134
2135
2136int
2138 int counter = 0;
2139 // iterate over all edgeDatas
2140 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2141 if (genericData.second->isAttributeCarrierSelected()) {
2142 counter++;
2143 }
2144 }
2145 return counter;
2146}
2147
2148
2149int
2151 int counter = 0;
2152 // iterate over all edgeDatas
2153 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2154 if (genericData.second->isAttributeCarrierSelected()) {
2155 counter++;
2156 }
2157 }
2158 return counter;
2159}
2160
2161
2162void
2164 if (myGenericDatas.at(genericData->getTagProperty()->getTag()).count(genericData->getGUIGlObject()) > 0) {
2165 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2166 } else {
2167 myGenericDatas.at(genericData->getTagProperty()->getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2168 }
2169 // mark interval toolbar for update
2170 myNet->getViewNet()->getIntervalBar().markForUpdate();
2171}
2172
2173
2174void
2176 const auto finder = myGenericDatas.at(genericData->getTagProperty()->getTag()).find(genericData);
2177 if (finder == myGenericDatas.at(genericData->getTagProperty()->getTag()).end()) {
2178 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2179 } else {
2180 myGenericDatas.at(genericData->getTagProperty()->getTag()).erase(finder);
2181 }
2182 // remove it from inspected elements and GNEElementTree
2183 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2184 genericData->unmarkForDrawingFront();
2185 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2186 // delete path element
2187 myNet->getDataPathManager()->removePath(genericData);
2188 // mark interval toolbar for update
2189 myNet->getViewNet()->getIntervalBar().markForUpdate();
2190}
2191
2192
2193std::set<std::string>
2194GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2195 // declare solution
2196 std::set<std::string> attributesSolution;
2197 // declare generic data vector
2198 std::vector<GNEGenericData*> genericDatas;
2199 // iterate over all data sets
2200 for (const auto& interval : myDataIntervals) {
2201 // check interval
2202 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2203 // iterate over generic datas
2204 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2205 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2206 genericDatas.push_back(genericData);
2207 }
2208 }
2209 }
2210 }
2211 // iterate over generic datas
2212 for (const auto& genericData : genericDatas) {
2213 for (const auto& attribute : genericData->getParametersMap()) {
2214 attributesSolution.insert(attribute.first);
2215 }
2216 }
2217 return attributesSolution;
2218}
2219
2220
2221std::set<std::string>
2222GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2223 const std::string& beginStr, const std::string& endStr) const {
2224 // declare solution
2225 std::set<std::string> attributesSolution;
2226 // vector of data sets and intervals
2227 std::vector<GNEDataSet*> dataSets;
2228 std::vector<GNEDataInterval*> dataIntervals;
2229 // get dataSet
2230 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2231 // if dataSetID is empty, return all parameters
2232 if (dataSetID.empty()) {
2233 // add all data sets
2234 dataSets.reserve(myDataSets.size());
2235 for (const auto& dataSet : myDataSets) {
2236 dataSets.push_back(dataSet.second);
2237 }
2238 } else if (retrievedDataSet) {
2239 dataSets.push_back(retrievedDataSet);
2240 } else {
2241 return attributesSolution;
2242 }
2243 // now continue with data intervals
2244 int numberOfIntervals = 0;
2245 for (const auto& dataSet : dataSets) {
2246 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2247 }
2248 // resize dataIntervals
2249 dataIntervals.reserve(numberOfIntervals);
2250 // add intervals
2251 for (const auto& dataSet : dataSets) {
2252 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2253 // continue depending of begin and end
2254 if (beginStr.empty() && endStr.empty()) {
2255 dataIntervals.push_back(dataInterval.second);
2256 } else if (endStr.empty()) {
2257 // parse begin
2258 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2259 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2260 dataIntervals.push_back(dataInterval.second);
2261 }
2262 } else if (beginStr.empty()) {
2263 // parse end
2264 const double end = GNEAttributeCarrier::parse<double>(endStr);
2265 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2266 dataIntervals.push_back(dataInterval.second);
2267 }
2268 } else {
2269 // parse both begin end
2270 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2271 const double end = GNEAttributeCarrier::parse<double>(endStr);
2272 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2273 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2274 dataIntervals.push_back(dataInterval.second);
2275 }
2276 }
2277 }
2278 }
2279 // finally iterate over intervals and get attributes
2280 for (const auto& dataInterval : dataIntervals) {
2281 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2282 // check generic data tag
2283 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2284 for (const auto& attribute : genericData->getParametersMap()) {
2285 attributesSolution.insert(attribute.first);
2286 }
2287 }
2288 }
2289 }
2290 return attributesSolution;
2291}
2292
2293
2295GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2296 for (const auto& meanData : myMeanDatas.at(type)) {
2297 if (meanData.second->getID() == id) {
2298 return meanData.second;
2299 }
2300 }
2301 if (hardFail) {
2302 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2303 } else {
2304 return nullptr;
2305 }
2306}
2307
2308
2309const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> >&
2311 return myMeanDatas;
2312}
2313
2314
2315int
2317 return myNumberOfMeanDataElements;
2318}
2319
2320
2321void
2323 // iterate over myMeanDatas and clear all meanDatas
2324 for (auto& meanDatas : myMeanDatas) {
2325 meanDatas.second.clear();
2326 }
2327}
2328
2329
2330void
2332 const auto tag = meanData->getTagProperty()->getTag();
2333 const auto it = myMeanDatas.at(tag).find(meanData->getID());
2334 if (it == myMeanDatas.at(tag).end()) {
2335 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' doesn't exist in AttributeCarriers.meanDatas");
2336 } else {
2337 // remove from container, set new Id, and insert it again
2338 myMeanDatas.at(tag).erase(it);
2339 myMeanDatas.at(tag)[newID] = meanData;
2340 }
2341}
2342
2343
2344std::string
2346 // obtain option container
2347 const auto& neteditOptions = OptionsCont::getOptions();
2348 // get prefix
2349 std::string prefix;
2350 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2351 prefix = neteditOptions.getString("meanDataEdge-prefix");
2352 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2353 prefix = neteditOptions.getString("meanDataLane-prefix");
2354 }
2355 int counter = 0;
2356 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2357 counter++;
2358 }
2359 return (prefix + "_" + toString(counter));
2360}
2361
2362
2363void
2365 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2366 registerJunction(junction, false);
2367}
2368
2369
2370void
2372 // remove it from inspected elements and GNEElementTree
2373 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2374 junction->unmarkForDrawingFront();
2375 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2376 // Remove from grid and container
2377 myNet->removeGLObjectFromGrid(junction);
2378 myJunctions.erase(junction->getMicrosimID());
2379 myNumberOfNetworkElements--;
2380 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2381 junction->decRef("GNENet::deleteSingleJunction");
2382 junction->setResponsible(true);
2383}
2384
2385
2386void
2388 // get pointer to create edge frame
2389 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2390 // insert in myEdgeTypes
2391 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2392 myNumberOfNetworkElements++;
2393 // update edge selector
2394 if (myNet->getViewParent()->getCreateEdgeFrame()->shown()) {
2395 myNet->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2396 }
2397 // set current edge type inspected
2398 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2399}
2400
2401
2402void
2404 // get pointer to create edge frame
2405 const auto& createEdgeFrame = myNet->getViewParent()->getCreateEdgeFrame();
2406 // remove it from inspected elements and GNEElementTree
2407 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2408 edgeType->unmarkForDrawingFront();
2409 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2410 // remove from edge types
2411 myEdgeTypes.erase(edgeType->getMicrosimID());
2412 myNumberOfNetworkElements--;
2413 // check if this is the selected edge type in edgeSelector
2414 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2415 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2416 }
2417 // update edge selector
2418 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2419}
2420
2421
2422void
2424 NBEdge* nbe = edge->getNBEdge();
2425 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2426 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2427 nbe->getFromNode()->addOutgoingEdge(nbe);
2428 nbe->getToNode()->addIncomingEdge(nbe);
2429 // register edge
2430 registerEdge(edge);
2431}
2432
2433
2434void
2436 // remove it from inspected elements and GNEElementTree
2437 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2438 edge->unmarkForDrawingFront();
2439 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2440 // remove edge from visual grid and container
2441 myNet->removeGLObjectFromGrid(edge);
2442 myEdges.erase(edge->getMicrosimID());
2443 myNumberOfNetworkElements--;
2444 // remove all lanes
2445 for (const auto& lane : edge->getChildLanes()) {
2446 deleteLane(lane);
2447 }
2448 // extract edge of district container
2449 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2450 edge->decRef("GNENet::deleteSingleEdge");
2451 edge->setResponsible(true);
2452 // Remove refrences from GNEJunctions
2454 edge->getToJunction()->removeIncomingGNEEdge(edge);
2455 // update boundaries of both junctions (to remove it from Grid)
2458 // get template editor
2459 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewParent()->getInspectorFrame()->getTemplateEditor();
2460 // check if we have to remove template
2461 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2462 templateEditor->setEdgeTemplate(nullptr);
2463 }
2464}
2465
2466
2467void
2469 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2470 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2471 } else {
2472 myLanes[lane->getGUIGlObject()] = lane;
2473 myNumberOfNetworkElements++;
2474 }
2475}
2476
2477
2478void
2480 const auto finder = myLanes.find(lane->getGUIGlObject());
2481 if (finder == myLanes.end()) {
2482 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2483 } else {
2484 myLanes.erase(finder);
2485 myNumberOfNetworkElements--;
2486 // remove it from inspected elements and GNEElementTree
2487 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2488 lane->unmarkForDrawingFront();
2489 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2490 }
2491}
2492
2493
2494void
2496 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2497 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2498 } else {
2499 myCrossings[crossing->getGUIGlObject()] = crossing;
2500 myNumberOfNetworkElements++;
2501 }
2502}
2503
2504
2505void
2507 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2508 if (finder == myCrossings.end()) {
2509 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2510 } else {
2511 myCrossings.erase(finder);
2512 myNumberOfNetworkElements--;
2513 // remove it from inspected elements and GNEElementTree
2514 if (myNet->getViewNet()) {
2515 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2516 crossing->unmarkForDrawingFront();
2517 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2518 }
2519 }
2520}
2521
2522
2523void
2525 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2526 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2527 } else {
2528 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2529 myNumberOfNetworkElements++;
2530 }
2531}
2532
2533
2534void
2536 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2537 if (finder == myWalkingAreas.end()) {
2538 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2539 } else {
2540 myWalkingAreas.erase(finder);
2541 myNumberOfNetworkElements--;
2542 // remove it from inspected elements and GNEElementTree
2543 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2544 walkingArea->unmarkForDrawingFront();
2545 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2546 }
2547}
2548
2549
2550void
2552 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2553 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2554 } else {
2555 myConnections[connection->getGUIGlObject()] = connection;
2556 myNumberOfNetworkElements++;
2557 }
2558}
2559
2560
2561void
2563 const auto finder = myConnections.find(connection->getGUIGlObject());
2564 if (finder == myConnections.end()) {
2565 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2566 } else {
2567 myConnections.erase(finder);
2568 myNumberOfNetworkElements--;
2569 // remove it from inspected elements and GNEElementTree
2570 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2571 connection->unmarkForDrawingFront();
2572 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2573 }
2574}
2575
2576
2577void
2579 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2580 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getMicrosimID() + "' already exist");
2581 } else {
2582 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2583 myNumberOfNetworkElements++;
2584 }
2585}
2586
2587
2588void
2590 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2591 if (finder == myInternalLanes.end()) {
2592 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2593 } else {
2594 myInternalLanes.erase(finder);
2595 myNumberOfNetworkElements--;
2596 }
2597}
2598
2599
2600void
2602 const auto tag = additional->getTagProperty()->getTag();
2603 if (myAdditionals.at(tag).count(additional) > 0) {
2604 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2605 } else {
2606 // insert in both containers
2607 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2608 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2609 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2610 }
2611 myNumberOfNetworkElements++;
2612 // insert AC in fileBucket (use this function ton maintain integrity in options)
2613 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(additional);
2614 // add element in grid
2615 myNet->addGLObjectIntoGrid(additional);
2616 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2617 if (myNet->isUpdateGeometryEnabled()) {
2618 additional->updateGeometry();
2619 }
2620 // additionals has to be saved
2621 myNet->getSavingStatus()->requireSaveAdditionals();
2622 }
2623}
2624
2625
2626void
2628 const auto tag = additional->getTagProperty()->getTag();
2629 // find demanElement in additionalTag
2630 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2631 // check if additional was previously inserted
2632 if (itFind == myAdditionals.at(tag).end()) {
2633 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2634 } else {
2635 // remove from both container
2636 myAdditionals.at(tag).erase(itFind);
2637 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2638 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2639 }
2640 myNumberOfNetworkElements--;
2641 // remove AC from fileBucket (use this function ton maintain integrity in options)
2642 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(additional);
2643 // remove it from inspected elements and GNEElementTree
2644 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2645 additional->unmarkForDrawingFront();
2646 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2647 // remove element from grid
2648 myNet->removeGLObjectFromGrid(additional);
2649 // delete path element
2650 myNet->getNetworkPathManager()->removePath(additional);
2651 // additionals has to be saved
2652 myNet->getSavingStatus()->requireSaveAdditionals();
2653 }
2654}
2655
2656
2657
2658
2659void
2661 const auto sourceSinkTag = sourceSink->getTagProperty()->getTag();
2662 if (myTAZSourceSinks.at(sourceSinkTag).count(sourceSink) > 0) {
2663 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' already exist");
2664 } else {
2665 myTAZSourceSinks.at(sourceSinkTag)[sourceSink] = sourceSink;
2666 myNumberOfNetworkElements++;
2667 // insert AC in fileBucket (use this function ton maintain integrity in options)
2668 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(sourceSink);
2669 // additionals has to be saved
2670 myNet->getSavingStatus()->requireSaveAdditionals();
2671 }
2672}
2673
2674
2675void
2677 const auto tag = sourceSink->getTagProperty()->getTag();
2678 // find demanElement in additionalTag
2679 auto itFind = myTAZSourceSinks.at(tag).find(sourceSink);
2680 // check if sourceSink was previously inserted
2681 if (itFind == myTAZSourceSinks.at(tag).end()) {
2682 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' wasn't previously inserted");
2683 } else {
2684 // remove from both container
2685 myTAZSourceSinks.at(tag).erase(itFind);
2686 myNumberOfNetworkElements--;
2687 // remove AC from fileBucket (use this function ton maintain integrity in options)
2688 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(sourceSink);
2689 // remove it from inspected elements and GNEElementTree
2690 myNet->getViewNet()->getInspectedElements().uninspectAC(sourceSink);
2691 sourceSink->unmarkForDrawingFront();
2692 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(sourceSink);
2693 // additionals has to be saved
2694 myNet->getSavingStatus()->requireSaveAdditionals();
2695 }
2696}
2697
2698
2699void
2701 const auto tag = demandElement->getTagProperty()->getTag();
2702 if (myDemandElements.at(tag).count(demandElement) > 0) {
2703 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2704 } else {
2705 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2706 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2707 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2708 }
2709 myNumberOfDemandElements++;
2710 // insert AC in fileBucket (use this function ton maintain integrity in options)
2711 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(demandElement);
2712 // add element in grid
2713 myNet->addGLObjectIntoGrid(demandElement);
2714 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2715 if (myNet->isUpdateGeometryEnabled()) {
2716 demandElement->updateGeometry();
2717 }
2718 // compute path element
2719 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2720 demandElement->computePathElement();
2721 }
2722 // update demand elements frames
2723 updateDemandElementFrames(demandElement->getTagProperty());
2724 // demandElements has to be saved
2725 myNet->getSavingStatus()->requireSaveDemandElements();
2726 }
2727}
2728
2729
2730void
2732 const auto tag = demandElement->getTagProperty()->getTag();
2733 auto viewParent = myNet->getViewParent();
2734 // find demanElement in demandElementTag
2735 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2736 // check if demandElement was previously inserted
2737 if (itFind == myDemandElements.at(tag).end()) {
2738 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2739 } else {
2740 // erase it from container
2741 myDemandElements.at(tag).erase(itFind);
2742 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2743 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2744 }
2745 myNumberOfDemandElements--;
2746 // remove AC from fileBucket (use this function ton maintain integrity in options)
2747 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(demandElement);
2748 // remove element from grid
2749 myNet->removeGLObjectFromGrid(demandElement);
2750 // remove it from inspected elements and GNEElementTree
2751 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2752 demandElement->unmarkForDrawingFront();
2753 // if is the last inserted route, remove it from GNEViewNet
2754 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2755 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2756 }
2757 // delete path element
2758 myNet->getDemandPathManager()->removePath(demandElement);
2759 // check if update demand elements frames
2760 if (updateFrames) {
2761 updateDemandElementFrames(demandElement->getTagProperty());
2762 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2763 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2764 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2765 // update distribution frames
2766 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2767 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2768 }
2769 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2770 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2771 }
2772 // special case for distribution references
2773 if (demandElement->getTagProperty()->getTag() == GNE_TAG_VTYPEREF) {
2774 viewParent->getTypeDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2775 }
2776 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
2777 viewParent->getRouteDistributionFrame()->getDistributionValuesEditor()->refreshRows();
2778 }
2779 }
2780 // demandElements has to be saved
2781 myNet->getSavingStatus()->requireSaveDemandElements();
2782 }
2783}
2784
2785
2786void
2788 if (myDataSets.count(dataSet->getID()) > 0) {
2789 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2790 } else {
2791 myDataSets[dataSet->getID()] = dataSet;
2792 myNumberOfDataElements++;
2793 // insert AC in fileBucket (use this function ton maintain integrity in options)
2794 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(dataSet);
2795 // dataSets has to be saved
2796 myNet->getSavingStatus()->requireSaveDataElements();
2797 // mark interval toolbar for update
2798 myNet->getViewNet()->getIntervalBar().markForUpdate();
2799 }
2800}
2801
2802
2803void
2805 const auto finder = myDataSets.find(dataSet->getID());
2806 if (finder == myDataSets.end()) {
2807 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2808 } else {
2809 myDataSets.erase(finder);
2810 myNumberOfDataElements--;
2811 // remove AC from fileBucket (use this function ton maintain integrity in options)
2812 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(dataSet);
2813 // remove it from inspected elements and GNEElementTree
2814 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2815 dataSet->unmarkForDrawingFront();
2816 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2817 // dataSets has to be saved
2818 myNet->getSavingStatus()->requireSaveDataElements();
2819 // mark interval toolbar for update
2820 myNet->getViewNet()->getIntervalBar().markForUpdate();
2821 }
2822}
2823
2824
2825void
2827 if (myMeanDatas.at(meanData->getTagProperty()->getTag()).count(meanData->getID()) > 0) {
2828 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2829 } else {
2830 myMeanDatas.at(meanData->getTagProperty()->getTag()).insert(std::make_pair(meanData->getID(), meanData));
2831 myNumberOfMeanDataElements++;
2832 // insert AC in fileBucket (use this function ton maintain integrity in options)
2833 myNet->getGNEApplicationWindow()->getFileBucketHandler()->registerAC(meanData);
2834 // meanDatas has to be saved
2835 myNet->getSavingStatus()->requireSaveMeanDatas();
2836 }
2837}
2838
2839
2840void
2842 // find demanElement in meanDataTag
2843 auto itFind = myMeanDatas.at(meanData->getTagProperty()->getTag()).find(meanData->getID());
2844 // check if meanData was previously inserted
2845 if (itFind == myMeanDatas.at(meanData->getTagProperty()->getTag()).end()) {
2846 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2847 } else {
2848 // remove from container
2849 myMeanDatas.at(meanData->getTagProperty()->getTag()).erase(itFind);
2850 myNumberOfMeanDataElements--;
2851 // remove AC from fileBucket (use this function ton maintain integrity in options)
2852 myNet->getGNEApplicationWindow()->getFileBucketHandler()->unregisterAC(meanData);
2853 // remove it from inspected elements and GNEElementTree
2854 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2855 meanData->unmarkForDrawingFront();
2856 myNet->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2857 // remove element from grid
2858 myNet->removeGLObjectFromGrid(meanData);
2859 // meanDatas has to be saved
2860 myNet->getSavingStatus()->requireSaveMeanDatas();
2861 }
2862}
2863
2864
2865void
2867 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2868 // continue depending of demand mode
2869 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2871 if (tagProperty->isType()) {
2872 myNet->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2873 }
2874 break;
2876 if (tagProperty->isType()) {
2877 myNet->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2878 }
2879 break;
2881 if (tagProperty->isType()) {
2882 myNet->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2883 }
2884 break;
2886 if (tagProperty->isRoute()) {
2887 myNet->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2888 }
2889 break;
2891 if (tagProperty->isType()) {
2892 myNet->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2893 }
2894 break;
2896 if (tagProperty->isPerson()) {
2897 myNet->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2898 }
2899 break;
2901 if (tagProperty->isType()) {
2902 myNet->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2903 }
2904 break;
2906 if (tagProperty->isContainer()) {
2907 myNet->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2908 }
2909 break;
2911 myNet->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2912 break;
2913 default:
2914 // nothing to update
2915 break;
2916 }
2917 }
2918}
2919
2920
2921void
2923 // fill network elements
2924 if (tag->getTag() == SUMO_TAG_JUNCTION) {
2925 for (const auto& junction : myJunctions) {
2926 ACs.push_back(junction.second);
2927 }
2928 }
2929 if (tag->getTag() == SUMO_TAG_EDGE) {
2930 for (const auto& edge : myEdges) {
2931 ACs.push_back(edge.second);
2932 }
2933 }
2934 if (tag->getTag() == SUMO_TAG_LANE) {
2935 for (const auto& lane : myLanes) {
2936 ACs.push_back(lane.second);
2937 }
2938 }
2939 if (tag->getTag() == SUMO_TAG_CONNECTION) {
2940 for (const auto& connection : myConnections) {
2941 ACs.push_back(connection.second);
2942 }
2943 }
2944 if (tag->getTag() == SUMO_TAG_CROSSING) {
2945 for (const auto& crossing : myCrossings) {
2946 ACs.push_back(crossing.second);
2947 }
2948 }
2949 if (tag->getTag() == SUMO_TAG_WALKINGAREA) {
2950 for (const auto& walkingArea : myWalkingAreas) {
2951 ACs.push_back(walkingArea.second);
2952 }
2953 }
2954 // fill additional elements
2955 if (tag->isAdditionalElement()) {
2956 for (const auto& additionalTag : myAdditionals) {
2957 if (additionalTag.first == tag->getTag()) {
2958 for (const auto& additional : additionalTag.second) {
2959 ACs.push_back(additional.second);
2960 }
2961 }
2962 }
2963 }
2964 // fill demand elements
2965 if (tag->isDemandElement()) {
2966 for (const auto& demandElementTag : myDemandElements) {
2967 if (demandElementTag.first == tag->getTag()) {
2968 for (const auto& demandElemet : demandElementTag.second) {
2969 ACs.push_back(demandElemet.second);
2970 }
2971 }
2972 }
2973 }
2974 // fill data elements
2975 if (tag->isDataElement()) {
2976 if (tag->getTag() == SUMO_TAG_DATASET) {
2977 for (const auto& dataSet : myDataSets) {
2978 ACs.push_back(dataSet.second);
2979 }
2980 }
2981 if (tag->getTag() == SUMO_TAG_DATAINTERVAL) {
2982 for (const auto& dataInterval : myDataIntervals) {
2983 ACs.push_back(dataInterval.second);
2984 }
2985 }
2986 for (const auto& genericDataTag : myGenericDatas) {
2987 if (genericDataTag.first == tag->getTag()) {
2988 for (const auto& genericData : genericDataTag.second) {
2989 ACs.push_back(genericData.second);
2990 }
2991 }
2992 }
2993 for (const auto& meanDataTag : myMeanDatas) {
2994 if (meanDataTag.first == tag->getTag()) {
2995 for (const auto& meanData : meanDataTag.second) {
2996 ACs.push_back(meanData.second);
2997 }
2998 }
2999 }
3000 }
3001 // iterate over children
3002 for (const auto child : tag->getHierarchicalChildren()) {
3003 retrieveAttributeCarriersRecursively(child, ACs);
3004 }
3005}
3006
3007// ---------------------------------------------------------------------------
3008// GNENetHelper::GNETagSelector - methods
3009// ---------------------------------------------------------------------------
3010
3012 myNet(net) {
3013}
3014
3015
3016void
3018 // network
3019 myTemplates[SUMO_TAG_CROSSING] = new GNECrossing(myNet);
3020 // special case for edge type
3021 myEdgeType = new GNEEdgeType(myNet);
3022 myTemplates[SUMO_TAG_TYPE] = myEdgeType;
3023 // additionals
3024 myTemplates[SUMO_TAG_BUS_STOP] = GNEBusStop::buildBusStop(myNet);
3025 myTemplates[SUMO_TAG_TRAIN_STOP] = GNEBusStop::buildTrainStop(myNet);
3026 myTemplates[SUMO_TAG_ACCESS] = new GNEAccess(myNet);
3027 myTemplates[SUMO_TAG_CONTAINER_STOP] = new GNEContainerStop(myNet);
3028 myTemplates[SUMO_TAG_CHARGING_STATION] = new GNEChargingStation(myNet);
3029 myTemplates[SUMO_TAG_PARKING_AREA] = new GNEParkingArea(myNet);
3030 myTemplates[SUMO_TAG_PARKING_SPACE] = new GNEParkingSpace(myNet);
3031 myTemplates[SUMO_TAG_INDUCTION_LOOP] = new GNEInductionLoopDetector(myNet);
3036 myTemplates[SUMO_TAG_DET_EXIT] = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet);
3038 myTemplates[SUMO_TAG_VSS] = new GNEVariableSpeedSign(myNet);
3039 myTemplates[SUMO_TAG_STEP] = new GNEVariableSpeedSignStep(myNet);
3040 myTemplates[SUMO_TAG_CALIBRATOR] = new GNECalibrator(SUMO_TAG_CALIBRATOR, myNet);
3042 myTemplates[GNE_TAG_CALIBRATOR_FLOW] = new GNECalibratorFlow(myNet);
3043 myTemplates[SUMO_TAG_REROUTER] = new GNERerouter(myNet);
3044 myTemplates[SUMO_TAG_INTERVAL] = new GNERerouterInterval(myNet);
3045 myTemplates[SUMO_TAG_CLOSING_REROUTE] = new GNEClosingReroute(myNet);
3046 myTemplates[SUMO_TAG_CLOSING_LANE_REROUTE] = new GNEClosingLaneReroute(myNet);
3047 myTemplates[SUMO_TAG_DEST_PROB_REROUTE] = new GNEDestProbReroute(myNet);
3048 myTemplates[SUMO_TAG_PARKING_AREA_REROUTE] = new GNEParkingAreaReroute(myNet);
3049 myTemplates[SUMO_TAG_ROUTE_PROB_REROUTE] = new GNERouteProbReroute(myNet);
3050 myTemplates[SUMO_TAG_ROUTEPROBE] = new GNERouteProbe(myNet);
3051 myTemplates[SUMO_TAG_VAPORIZER] = new GNEVaporizer(myNet);
3052 // symbols
3053 myTemplates[GNE_TAG_REROUTER_SYMBOL] = new GNERerouterSymbol(myNet);
3054 myTemplates[GNE_TAG_VSS_SYMBOL] = new GNEVariableSpeedSignSymbol(myNet);
3055 // shapes
3056 myTemplates[SUMO_TAG_POLY] = new GNEPoly(SUMO_TAG_POLY, myNet);
3057 myTemplates[SUMO_TAG_POI] = new GNEPOI(SUMO_TAG_POI, myNet);
3058 myTemplates[GNE_TAG_POILANE] = new GNEPOI(GNE_TAG_POILANE, myNet);
3059 myTemplates[GNE_TAG_POIGEO] = new GNEPOI(GNE_TAG_POIGEO, myNet);
3060 // TAZs
3061 myTemplates[SUMO_TAG_TAZ] = new GNETAZ(myNet);
3062 myTemplates[SUMO_TAG_TAZSOURCE] = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, myNet);
3063 myTemplates[SUMO_TAG_TAZSINK] = new GNETAZSourceSink(SUMO_TAG_TAZSINK, myNet);
3064 // wires
3065 myTemplates[SUMO_TAG_TRACTION_SUBSTATION] = new GNETractionSubstation(myNet);
3066 myTemplates[SUMO_TAG_OVERHEAD_WIRE_SECTION] = new GNEOverheadWire(myNet);
3067 //myTemplates[SUMO_TAG_OVERHEAD_WIRE_CLAMP] = nullptr; // TMP
3068 // JuPedSim elements
3070 myTemplates[GNE_TAG_JPS_OBSTACLE] = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet);
3071 // vTypes
3072 myTemplates[SUMO_TAG_VTYPE] = new GNEVType(SUMO_TAG_VTYPE, myNet);
3073 // vType distributions
3074 myTemplates[SUMO_TAG_VTYPE_DISTRIBUTION] = new GNEVTypeDistribution(myNet);
3075 myTemplates[GNE_TAG_VTYPEREF] = new GNEVTypeRef(myNet);
3076 // routes
3077 myTemplates[SUMO_TAG_ROUTE] = new GNERoute(SUMO_TAG_ROUTE, myNet);
3078 myTemplates[GNE_TAG_ROUTE_EMBEDDED] = new GNERoute(GNE_TAG_ROUTE_EMBEDDED, myNet);
3079 // route distribution
3080 myTemplates[SUMO_TAG_ROUTE_DISTRIBUTION] = new GNERouteDistribution(myNet);
3081 myTemplates[GNE_TAG_ROUTEREF] = new GNERouteRef(myNet);
3082 // vehicles
3083 const auto vehicles = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::VEHICLE);
3084 for (const auto vehicle : vehicles) {
3085 myTemplates[vehicle->getTag()] = new GNEVehicle(vehicle->getTag(), myNet);
3086 }
3087 // persons
3088 const auto persons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSON);
3089 for (const auto person : persons) {
3090 myTemplates[person->getTag()] = new GNEPerson(person->getTag(), myNet);
3091 }
3092 // container
3093 const auto containers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::CONTAINER);
3094 for (const auto container : containers) {
3095 myTemplates[container->getTag()] = new GNEContainer(container->getTag(), myNet);
3096 }
3097 // stops and waypoints
3098 const auto stopAndWaypoints = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_VEHICLE);
3099 for (const auto stopAndWaypoint : stopAndWaypoints) {
3100 myTemplates[stopAndWaypoint->getTag()] = new GNEStop(stopAndWaypoint->getTag(), myNet);
3101 }
3102 // personTrip
3103 const auto personTrips = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSONTRIP);
3104 for (const auto personTrip : personTrips) {
3105 myTemplates[personTrip->getTag()] = new GNEPersonTrip(personTrip->getTag(), myNet);
3106 }
3107 // walk
3108 const auto walks = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::WALK);
3109 for (const auto walk : walks) {
3110 myTemplates[walk->getTag()] = new GNEWalk(walk->getTag(), myNet);
3111 }
3112 // ride
3113 const auto rides = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::RIDE);
3114 for (const auto ride : rides) {
3115 myTemplates[ride->getTag()] = new GNERide(ride->getTag(), myNet);
3116 }
3117 // stop person
3118 const auto stopPersons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_PERSON);
3119 for (const auto stopPerson : stopPersons) {
3120 myTemplates[stopPerson->getTag()] = new GNEStopPlan(stopPerson->getTag(), myNet);
3121 }
3122 // transport
3123 const auto transports = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSPORT);
3124 for (const auto transport : transports) {
3125 myTemplates[transport->getTag()] = new GNETransport(transport->getTag(), myNet);
3126 }
3127 // tranship
3128 const auto tranships = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSHIP);
3129 for (const auto tranship : tranships) {
3130 myTemplates[tranship->getTag()] = new GNETranship(tranship->getTag(), myNet);
3131 }
3132 // stop container
3133 const auto stopContainers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_CONTAINER);
3134 for (const auto stopContainer : stopContainers) {
3135 myTemplates[stopContainer->getTag()] = new GNEStopPlan(stopContainer->getTag(), myNet);
3136 }
3137 // dataSet
3138 myTemplates[SUMO_TAG_DATASET] = new GNEDataSet(myNet);
3139 // generic datas
3140 myTemplates[GNE_TAG_EDGEREL_SINGLE] = new GNEEdgeData(myNet);
3141 myTemplates[SUMO_TAG_EDGEREL] = new GNEEdgeRelData(myNet);
3142 myTemplates[SUMO_TAG_TAZREL] = new GNETAZRelData(myNet);
3143 // reset all to their default values
3144 for (const auto& AC : myTemplates) {
3145 AC.second->resetDefaultValues(false);
3146 }
3147 // fill plan templates
3148 fillPlanTemplates();
3149}
3150
3151
3153 for (auto& AC : myTemplates) {
3154 delete AC.second;
3155 }
3156}
3157
3158
3159std::map<SumoXMLTag, GNEAttributeCarrier*>
3161 return myTemplates;
3162}
3163
3164
3167 if (myTemplates.count(tag) > 0) {
3168 return myTemplates.at(tag);
3169 } else {
3170 return nullptr;
3171 }
3172}
3173
3174
3176GNENetHelper::ACTemplate::getTemplateAC(const std::string& selectorText) const {
3177 for (const auto& templateAC : myTemplates) {
3178 if (templateAC.second->getTagProperty()->getSelectorText() == selectorText) {
3179 return templateAC.second;
3180 }
3181 }
3182 return nullptr;
3183}
3184
3185
3188 return myEdgeType;
3189}
3190
3191
3192const std::vector<std::pair<GNETagProperties*, GNEDemandElement*>>&
3194 return myPlanTemplates.at(tag);
3195}
3196
3197
3198void
3200 GNETagProperties* tagProperty = nullptr;
3201 // person trip
3202 tagProperty = new GNETagProperties(SUMO_TAG_PERSONTRIP, nullptr,
3216 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEPersonTrip(GNE_TAG_PERSONTRIP_EDGE_EDGE, myNet)));
3217 // ride
3218 tagProperty = new GNETagProperties(SUMO_TAG_RIDE, nullptr,
3232 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNERide(GNE_TAG_RIDE_EDGE_EDGE, myNet)));
3233 // walk
3234 tagProperty = new GNETagProperties(SUMO_TAG_WALK, nullptr,
3248 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGE_EDGE, myNet)));
3249 // walk (edges)
3250 tagProperty = new GNETagProperties(GNE_TAG_WALK_EDGES, nullptr,
3257 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGES, myNet)));
3258 // walk (route)
3259 tagProperty = new GNETagProperties(GNE_TAG_WALK_ROUTE, nullptr,
3266 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_ROUTE, myNet)));
3267 // stop
3268 tagProperty = new GNETagProperties(GNE_TAG_PERSONSTOPS, nullptr,
3277 myPlanTemplates[SUMO_TAG_PERSON].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPPERSON_EDGE, myNet)));
3278 // transport
3279 tagProperty = new GNETagProperties(SUMO_TAG_TRANSPORT, nullptr,
3283 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3284 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3285 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3286 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3288 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3289 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3293 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETransport(GNE_TAG_TRANSPORT_EDGE_EDGE, myNet)));
3294 // tranship
3295 tagProperty = new GNETagProperties(SUMO_TAG_TRANSHIP, nullptr,
3299 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
3300 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
3301 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
3302 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
3304 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
3305 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
3309 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGE_EDGE, myNet)));
3310 // tranship (edges)
3311 tagProperty = new GNETagProperties(GNE_TAG_TRANSHIP_EDGES, nullptr,
3318 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGES, myNet)));
3319 // stop
3320 tagProperty = new GNETagProperties(GNE_TAG_CONTAINERSTOPS, nullptr,
3329 myPlanTemplates[SUMO_TAG_CONTAINER].push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPCONTAINER_EDGE, myNet)));
3330}
3331
3332// ---------------------------------------------------------------------------
3333// GNENetHelper::SavingStatus - methods
3334// ---------------------------------------------------------------------------
3335
3337 myNet(net) {
3338}
3339
3340
3341void
3343 mySumoConfigSaved = false;
3344}
3345
3346
3347void
3349 mySumoConfigSaved = true;
3350}
3351
3352
3353bool
3355 return mySumoConfigSaved;
3356}
3357
3358
3359void
3361 myNeteditConfigSaved = false;
3362}
3363
3364
3365void
3367 myNeteditConfigSaved = true;
3368}
3369
3370
3371bool
3373 return myNeteditConfigSaved;
3374}
3375
3376
3377void
3379 myNetworkSaved = false;
3380 // implies requiere save netedit config and sumo config
3381 myNeteditConfigSaved = false;
3382 mySumoConfigSaved = false;
3383}
3384
3385
3386void
3388 myNetworkSaved = true;
3389}
3390
3391
3392bool
3394 return myNetworkSaved;
3395}
3396
3397
3398void
3400 myTLSSaved = false;
3401}
3402
3403
3404void
3406 myTLSSaved = true;
3407}
3408
3409
3410bool
3412 return myTLSSaved;
3413}
3414
3415
3416void
3418 myEdgeTypeSaved = false;
3419}
3420
3421
3422void
3424 myEdgeTypeSaved = true;
3425}
3426
3427
3428bool
3430 return myEdgeTypeSaved;
3431}
3432
3433
3434void
3436 myAdditionalSaved = false;
3437 // implies requiere save netedit config and sumo config
3438 myNeteditConfigSaved = false;
3439 mySumoConfigSaved = false;
3440}
3441
3442
3443void
3445 myAdditionalSaved = true;
3446}
3447
3448
3449bool
3451 return myAdditionalSaved;
3452}
3453
3454
3455void
3457 myDemandElementSaved = false;
3458 // implies requiere save netedit config and sumo config
3459 myNeteditConfigSaved = false;
3460 mySumoConfigSaved = false;
3461}
3462
3463
3464void
3466 myDemandElementSaved = true;
3467}
3468
3469
3470bool
3472 return myDemandElementSaved;
3473}
3474
3475
3476void
3478 myDataElementSaved = false;
3479 // implies requiere save netedit config and sumo config
3480 myNeteditConfigSaved = false;
3481 mySumoConfigSaved = false;
3482}
3483
3484
3485void
3487 myDataElementSaved = true;
3488}
3489
3490
3491bool
3493 return myDataElementSaved;
3494}
3495
3496
3497void
3499 myMeanDataElementSaved = false;
3500 // implies requiere save netedit config and sumo config
3501 myNeteditConfigSaved = false;
3502 mySumoConfigSaved = false;
3503}
3504
3505
3506void
3508 myMeanDataElementSaved = true;
3509}
3510
3511
3512bool
3514 return myMeanDataElementSaved;
3515}
3516
3517
3520 auto GNEApp = myNet->getGNEApplicationWindow();
3521 // Check if there are non saved network elements
3522 if (commonResult == GNEDialog::Result::ABORT) {
3524 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3526 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3528 } else if (myNetworkSaved) {
3530 } else {
3531 // open save dialog
3532 const GNESaveDialog saveDialog(GNEApp, TL("network"));
3533 // continue depending of result
3534 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3535 commonResult = GNEDialog::Result::ABORT;
3537 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3538 commonResult = GNEDialog::Result::ACCEPT_ALL;
3540 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3541 commonResult = GNEDialog::Result::CANCEL_ALL;
3543 } else {
3544 return saveDialog.getResult();
3545 }
3546 }
3547}
3548
3549
3552 auto GNEApp = myNet->getGNEApplicationWindow();
3553 // Check if there are non saved additional elements
3554 if (commonResult == GNEDialog::Result::ABORT) {
3556 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3558 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3560 } else if (myAdditionalSaved) {
3562 } else {
3563 // open save dialog
3564 const GNESaveDialog saveDialog(GNEApp, TL("additional elements"));
3565 // continue depending of result
3566 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3567 commonResult = GNEDialog::Result::ABORT;
3569 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3570 commonResult = GNEDialog::Result::ACCEPT_ALL;
3572 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3573 commonResult = GNEDialog::Result::CANCEL_ALL;
3575 } else {
3576 return saveDialog.getResult();
3577 }
3578 }
3579}
3580
3581
3584 auto GNEApp = myNet->getGNEApplicationWindow();
3585 // Check if there are non saved demand elements
3586 if (commonResult == GNEDialog::Result::ABORT) {
3588 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3590 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3592 } else if (myDemandElementSaved) {
3594 } else {
3595 // open save dialog
3596 const GNESaveDialog saveDialog(GNEApp, TL("demand elements"));
3597 // continue depending of result
3598 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3599 commonResult = GNEDialog::Result::ABORT;
3601 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3602 commonResult = GNEDialog::Result::ACCEPT_ALL;
3604 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3605 commonResult = GNEDialog::Result::CANCEL_ALL;
3607 } else {
3608 return saveDialog.getResult();
3609 }
3610 }
3611}
3612
3613
3616 auto GNEApp = myNet->getGNEApplicationWindow();
3617 // Check if there are non saved data elements
3618 if (commonResult == GNEDialog::Result::ABORT) {
3620 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3622 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3624 } else if (myDataElementSaved) {
3626 } else {
3627 // open save dialog
3628 const GNESaveDialog saveDialog(GNEApp, TL("data elements"));
3629 // continue depending of result
3630 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3631 commonResult = GNEDialog::Result::ABORT;
3633 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3634 commonResult = GNEDialog::Result::ACCEPT_ALL;
3636 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3637 commonResult = GNEDialog::Result::CANCEL_ALL;
3639 } else {
3640 return saveDialog.getResult();
3641 }
3642 }
3643}
3644
3645
3648 auto GNEApp = myNet->getGNEApplicationWindow();
3649 // Check if there are non saved mean data elements
3650 if (commonResult == GNEDialog::Result::ABORT) {
3652 } else if (commonResult == GNEDialog::Result::ACCEPT_ALL) {
3654 } else if (commonResult == GNEDialog::Result::CANCEL_ALL) {
3656 } else if (myMeanDataElementSaved) {
3658 } else {
3659 // open save dialog
3660 const GNESaveDialog saveDialog(GNEApp, TL("meanData elements"));
3661 // continue depending of result
3662 if (saveDialog.getResult() == GNEDialog::Result::ABORT) {
3663 commonResult = GNEDialog::Result::ABORT;
3665 } else if (saveDialog.getResult() == GNEDialog::Result::ACCEPT_ALL) {
3666 commonResult = GNEDialog::Result::ACCEPT_ALL;
3668 } else if (saveDialog.getResult() == GNEDialog::Result::CANCEL_ALL) {
3669 commonResult = GNEDialog::Result::CANCEL_ALL;
3671 } else {
3672 return saveDialog.getResult();
3673 }
3674 }
3675}
3676
3677// ---------------------------------------------------------------------------
3678// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
3679// ---------------------------------------------------------------------------
3680
3682 GNEChange(Supermode::NETWORK, true, false),
3683 myTllcont(tllcont),
3684 myReplaced(replaced),
3685 myBy(by) {
3686}
3687
3688
3690
3691
3692void
3694 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3695 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
3696}
3697
3698
3699void
3701 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3702 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
3703}
3704
3705
3706std::string
3708 return TL("Redo replace in TLS");
3709}
3710
3711
3712std::string
3714 return TL("Undo replace in TLS");
3715}
3716
3717
3718bool
3720 return myReplaced != myBy;
3721}
3722
3723/****************************************************************************/
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:1520
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:773
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2254
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