Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNENetHelper.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Helper for GNENet
19/****************************************************************************/
20
21
24#include <netedit/GNENet.h>
26#include <netedit/GNEViewNet.h>
102
103#include "GNENetHelper.h"
104
105// ---------------------------------------------------------------------------
106// GNENetHelper::AttributeCarriers - methods
107// ---------------------------------------------------------------------------
108
110 myNet(net),
111 myStopIndex(0) {
112 // fill additionals with tags
115 for (const auto& additionalTagProperty : additionalTagProperties) {
116 myAdditionals.insert(std::make_pair(additionalTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEAdditional*>()));
117 if (additionalTagProperty->hasAttribute(SUMO_ATTR_ID) || (additionalTagProperty->getTag() == SUMO_TAG_VAPORIZER)) {
118 myAdditionalIDs.insert(std::make_pair(additionalTagProperty->getTag(), std::map<const std::string, GNEAdditional*>()));
119 }
120 }
121 myTAZSourceSinks.insert(std::make_pair(SUMO_TAG_TAZSOURCE, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>()));
122 myTAZSourceSinks.insert(std::make_pair(SUMO_TAG_TAZSINK, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>()));
123 // fill demand elements with tags
125 for (const auto& demandElementTagProperty : demandElementTagProperties) {
126 myDemandElements.insert(std::make_pair(demandElementTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
127 if (demandElementTagProperty->hasAttribute(SUMO_ATTR_ID)) {
128 myDemandElementIDs.insert(std::make_pair(demandElementTagProperty->getTag(), std::map<const std::string, GNEDemandElement*>()));
129 }
130 }
132 for (const auto& stopTagProperty : stopTagProperties) {
133 myDemandElements.insert(std::make_pair(stopTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEDemandElement*>()));
134 }
135 // fill data elements with tags
137 for (const auto& genericDataElementTagProperty : genericDataElementTagProperties) {
138 myGenericDatas.insert(std::make_pair(genericDataElementTagProperty->getTag(), std::unordered_map<const GUIGlObject*, GNEGenericData*>()));
139 }
140 // fill meanDatas with tags
142 for (const auto& meanDataTagProperty : meanDataTagProperties) {
143 myMeanDatas.insert(std::make_pair(meanDataTagProperty->getTag(), std::map<const std::string, GNEMeanData*>()));
144 }
145}
146
147
149 // Drop EdgeTypes
150 for (const auto& edgeType : myEdgeTypes) {
151 edgeType.second->decRef("GNENetHelper::~GNENet");
152 delete edgeType.second;
153 }
154 // Drop Edges
155 for (const auto& edge : myEdges) {
156 edge.second->decRef("GNENetHelper::~GNENet");
157 delete edge.second;
158 }
159 // Drop myJunctions
160 for (const auto& junction : myJunctions) {
161 junction.second->decRef("GNENetHelper::~GNENet");
162 delete junction.second;
163 }
164 // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
165 for (const auto& additionalTag : myAdditionals) {
166 for (const auto& additional : additionalTag.second) {
167 // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
168 additional.second->decRef();
169 delete additional.second;
170 }
171 }
172 // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
173 for (const auto& demandElementTag : myDemandElements) {
174 for (const auto& demandElement : demandElementTag.second) {
175 // decrease reference manually (because it was increased manually in GNERouteHandler)
176 demandElement.second->decRef();
177 delete demandElement.second;
178 }
179 }
180 // Drop dataSets (Only used for TAZElements that were inserted without using GNEChange_DataSets)
181 for (const auto& dataSet : myDataSets) {
182 // decrease reference manually (because it was increased manually in GNEDataHandler)
183 dataSet.second->decRef();
184 delete dataSet.second;
185 }
186 // Drop MeanDatas (Only used for meanDatas that were inserted without using GNEChange_MeanData)
187 for (const auto& meanDataTag : myMeanDatas) {
188 for (const auto& meanData : meanDataTag.second) {
189 // decrease reference manually (because it was increased manually in GNEMeanDataHandler)
190 meanData.second->decRef();
191 delete meanData.second;
192 }
193 }
194}
195
196
197void
199 std::map<std::string, GNEEdge*> newEdgeMap;
200 std::map<std::string, GNEJunction*> newJunctionMap;
201 // fill newEdgeMap
202 for (const auto& edge : myEdges) {
203 edge.second->setEdgeID(edge.second->getNBEdge()->getID());
204 newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
205 }
206 for (const auto& junction : myJunctions) {
207 newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
208 junction.second->setNetworkElementID(junction.second->getNBNode()->getID());
209 }
210 myEdges = newEdgeMap;
211 myJunctions = newJunctionMap;
212}
213
214
215bool
217 // check what type of AC
218 if (AC->getTagProperty()->getTag() == SUMO_TAG_JUNCTION) {
219 // Junction
220 const GNEJunction* junction = myJunctions.at(AC->getID());
221 if (junction->getNBNode()->getShape().size() == 0) {
222 return triangle.isPositionWithin(junction->getNBNode()->getCenter());
223 } else {
224 return (triangle.intersectWithShape(junction->getNBNode()->getShape()));
225 }
226 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_EDGE) {
227 // Edge
228 for (const auto& lane : myEdges.at(AC->getID())->getChildLanes()) {
229 if (triangle.intersectWithShape(lane->getLaneShape())) {
230 return true;
231 }
232 }
233 return false;
234 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_LANE) {
235 // Lane
236 return triangle.intersectWithShape(retrieveLane(AC->getID())->getLaneShape());
237 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_CONNECTION) {
238 // connection
239 return triangle.intersectWithShape(myConnections.at(AC->getGUIGlObject())->getConnectionShape());
240 } else if (AC->getTagProperty()->getTag() == SUMO_TAG_CROSSING) {
241 // crossing
242 return triangle.intersectWithShape(myCrossings.at(AC->getGUIGlObject())->getCrossingShape());
243 } else if (AC->getTagProperty()->isAdditionalElement()) {
244 // Additional (including shapes and TAZs
245 const GNEAdditional* additional = retrieveAdditional(AC->getGUIGlObject());
246 if (additional->getAdditionalGeometry().getShape().size() <= 1) {
247 return triangle.isPositionWithin(additional->getPositionInView());
248 } else {
249 return triangle.intersectWithShape(additional->getAdditionalGeometry().getShape());
250 }
251 } else {
252 return false;
253 }
254}
255
256
257int
259 return myNumberOfNetworkElements;
260}
261
262
263int
265 return myNumberOfDemandElements;
266}
267
268
269int
271 return myNumberOfDataElements;
272}
273
274
277 // obtain blocked GUIGlObject
279 // Make sure that object exists
280 if (object != nullptr) {
281 // unblock and try to parse to AttributeCarrier
283 GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
284 // If was successfully parsed, return it
285 if (ac == nullptr) {
286 throw ProcessError("GUIGlObject does not match the declared type");
287 } else {
288 return ac;
289 }
290 } else if (hardFail) {
291 throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
292 } else {
293 return nullptr;
294 }
295}
296
297
298std::vector<GNEAttributeCarrier*>
300 std::vector<GNEAttributeCarrier*> ACs;
301 // first check if we have to return all ACs
302 if (tag == SUMO_TAG_NOTHING) {
303 const auto rootTagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(SUMO_TAG_ROOTFILE, true);
304 ACs.reserve(myNumberOfNetworkElements + myNumberOfDemandElements + myNumberOfDataElements);
305 retrieveAttributeCarriersRecursively(rootTagProperty, ACs);
306 } else {
307 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag, true);
308 // reserve space
309 if (tagProperty->getSupermode() == Supermode::NETWORK) {
310 ACs.reserve(myNumberOfNetworkElements);
311 } else if (tagProperty->getSupermode() == Supermode::DEMAND) {
312 ACs.reserve(myNumberOfDemandElements);
313 } else if (tagProperty->getSupermode() == Supermode::DATA) {
314 ACs.reserve(myNumberOfDataElements + myNumberOfMeanDataElements);
315 }
316 retrieveAttributeCarriersRecursively(tagProperty, ACs);
317 }
318 return ACs;
319}
320
321
322std::vector<GNEAttributeCarrier*>
324 std::vector<GNEAttributeCarrier*> result;
325 // continue depending of supermode
326 if (supermode == Supermode::NETWORK) {
327 // network
328 for (const auto& junction : myJunctions) {
329 if (!onlySelected || junction.second->isAttributeCarrierSelected()) {
330 result.push_back(junction.second);
331 }
332 }
333 for (const auto& crossing : myCrossings) {
334 if (!onlySelected || crossing.second->isAttributeCarrierSelected()) {
335 result.push_back(crossing.second);
336 }
337 }
338 for (const auto& edge : myEdges) {
339 if (!onlySelected || edge.second->isAttributeCarrierSelected()) {
340 result.push_back(edge.second);
341 }
342 }
343 for (const auto& lane : myLanes) {
344 if (!onlySelected || lane.second->isAttributeCarrierSelected()) {
345 result.push_back(lane.second);
346 }
347 }
348 for (const auto& connection : myConnections) {
349 if (!onlySelected || connection.second->isAttributeCarrierSelected()) {
350 result.push_back(connection.second);
351 }
352 }
353 for (const auto& additionalSet : myAdditionals) {
354 for (const auto& additional : additionalSet.second) {
355 if (!onlySelected || additional.second->isAttributeCarrierSelected()) {
356 result.push_back(additional.second);
357 }
358 }
359 }
360 } else if (supermode == Supermode::DEMAND) {
361 for (const auto& demandElementSet : myDemandElements) {
362 for (const auto& demandElement : demandElementSet.second) {
363 if (!onlySelected || demandElement.second->isAttributeCarrierSelected()) {
364 result.push_back(demandElement.second);
365 }
366 }
367 }
368 } else if (supermode == Supermode::DATA) {
369 for (const auto& dataSet : myDataSets) {
370 if (!onlySelected || dataSet.second->isAttributeCarrierSelected()) {
371 result.push_back(dataSet.second);
372 }
373 }
374 for (const auto& dataInterval : myDataIntervals) {
375 if (!onlySelected || dataInterval.second->isAttributeCarrierSelected()) {
376 result.push_back(dataInterval.second);
377 }
378 }
379 for (const auto& genericDataSet : myGenericDatas) {
380 for (const auto& genericData : genericDataSet.second) {
381 if (!onlySelected || genericData.second->isAttributeCarrierSelected()) {
382 result.push_back(genericData.second);
383 }
384 }
385 }
386 for (const auto& meanDataSet : myMeanDatas) {
387 for (const auto& meanData : meanDataSet.second) {
388 if (!onlySelected || meanData.second->isAttributeCarrierSelected()) {
389 result.push_back(meanData.second);
390 }
391 }
392 }
393 }
394 return result;
395}
396
397
398std::vector<GNEAttributeCarrier*>
400 // get modes
401 const auto& editModes = myNet->getViewNet()->getEditModes();
402 // declare vector to save result
403 std::vector<GNEAttributeCarrier*> result;
404 result.reserve(gSelected.getSelected().size());
405 // iterate over all elements of global selection
406 for (const auto& glID : gSelected.getSelected()) {
407 // obtain AC
408 GNEAttributeCarrier* AC = retrieveAttributeCarrier(glID, false);
409 // check if attribute carrier exist and is selected
410 if (AC && AC->isAttributeCarrierSelected()) {
411 if (ignoreCurrentSupermode) {
412 result.push_back(AC);
413 } else if (editModes.isCurrentSupermodeNetwork() && (AC->getTagProperty()->isNetworkElement() ||
415 result.push_back(AC);
416 } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty()->isDemandElement()) {
417 result.push_back(AC);
418 } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty()->isDataElement()) {
419 result.push_back(AC);
420 }
421 }
422 }
423 return result;
424}
425
426
428GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
429 auto it = myJunctions.find(id);
430 if (it != myJunctions.end()) {
431 return it->second;
432 }
433 if (hardFail) {
434 // If junction wasn't found, throw exception
435 throw UnknownElement("Attempted to retrieve non-existant junction " + id);
436 } else {
437 return nullptr;
438 }
439}
440
441
442const std::map<std::string, GNEJunction*>&
444 return myJunctions;
445}
446
447
448std::vector<GNEJunction*>
450 std::vector<GNEJunction*> result;
451 // returns junctions depending of selection
452 for (const auto& junction : myJunctions) {
453 if (junction.second->isAttributeCarrierSelected()) {
454 result.push_back(junction.second);
455 }
456 }
457 return result;
458}
459
460
463 // increase reference
464 junction->incRef("GNENet::registerJunction");
465 junction->setResponsible(false);
466 myJunctions[junction->getMicrosimID()] = junction;
467 myNumberOfNetworkElements++;
468 // expand net boundary
469 myNet->expandBoundary(junction->getCenteringBoundary());
470 // add edge into grid
471 myNet->addGLObjectIntoGrid(junction);
472 // update geometry
473 junction->updateGeometry();
474 // add z in net boundary
475 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
476 return junction;
477}
478
479
480void
482 myJunctions.clear();
483}
484
485
486void
488 // make a copy of junctions
489 auto junctionCopy = myJunctions;
490 // clear junctions
491 myJunctions.clear();
492 // fill junctions again
493 for (const auto& junction : junctionCopy) {
494 // update microsim ID
495 junction.second->setNetworkElementID(prefix + junction.first);
496 // insert in myJunctions again
497 myJunctions[prefix + junction.first] = junction.second;
498 }
499}
500
501
502void
504 if (myJunctions.count(junction->getID()) == 0) {
505 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
506 } else if (myJunctions.count(newID) != 0) {
507 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
508 } else {
509 // remove junction from container
510 myJunctions.erase(junction->getNBNode()->getID());
511 // rename in NetBuilder
512 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
513 // update microsim ID
514 junction->setNetworkElementID(newID);
515 // add it into myJunctions again
516 myJunctions[junction->getID()] = junction;
517 // build crossings
518 junction->getNBNode()->buildCrossings();
519 // net has to be saved
520 myNet->getSavingStatus()->requireSaveNetwork();
521 }
522}
523
524
525int
527 int counter = 0;
528 for (const auto& junction : myJunctions) {
529 if (junction.second->isAttributeCarrierSelected()) {
530 counter++;
531 }
532 }
533 return counter;
534}
535
536
539 auto it = myCrossings.find(glObject);
540 if (it != myCrossings.end()) {
541 return it->second;
542 }
543 if (hardFail) {
544 // If junction wasn't found, throw exception
545 throw UnknownElement("Attempted to retrieve non-existant crossing " + glObject->getMicrosimID());
546 } else {
547 return nullptr;
548 }
549}
550
551
552const std::unordered_map<const GUIGlObject*, GNECrossing*>&
554 return myCrossings;
555}
556
557
558std::vector<GNECrossing*>
560 std::vector<GNECrossing*> result;
561 // iterate over crossings
562 for (const auto& crossing : myCrossings) {
563 if (crossing.second->isAttributeCarrierSelected()) {
564 result.push_back(crossing.second);
565 }
566 }
567 return result;
568}
569
570
571int
573 int counter = 0;
574 for (const auto& crossing : myCrossings) {
575 if (crossing.second->isAttributeCarrierSelected()) {
576 counter++;
577 }
578 }
579 return counter;
580}
581
582
585 auto it = myWalkingAreas.find(glObject);
586 if (it != myWalkingAreas.end()) {
587 return it->second;
588 }
589 if (hardFail) {
590 // If junction wasn't found, throw exception
591 throw UnknownElement("Attempted to retrieve non-existant walkingArea " + glObject->getMicrosimID());
592 } else {
593 return nullptr;
594 }
595}
596
597
598const std::unordered_map<const GUIGlObject*, GNEWalkingArea*>&
600 return myWalkingAreas;
601}
602
603
604std::vector<GNEWalkingArea*>
606 std::vector<GNEWalkingArea*> result;
607 // iterate over walkingAreas
608 for (const auto& walkingArea : myWalkingAreas) {
609 if (walkingArea.second->isAttributeCarrierSelected()) {
610 result.push_back(walkingArea.second);
611 }
612 }
613 return result;
614}
615
616
617int
619 int counter = 0;
620 for (const auto& walkingArea : myWalkingAreas) {
621 if (walkingArea.second->isAttributeCarrierSelected()) {
622 counter++;
623 }
624 }
625 return counter;
626}
627
628
630GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
631 if (myEdgeTypes.count(id) > 0) {
632 return myEdgeTypes.at(id);
633 } else if (hardFail) {
634 // If edge wasn't found, throw exception
635 throw UnknownElement("Attempted to retrieve non-existant EdgeType " + id);
636 } else {
637 return nullptr;
638 }
639}
640
641
644 // increase reference
645 edgeType->incRef("GNENet::registerEdgeType");
646 // add it in container
647 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
648 return edgeType;
649}
650
651
652const std::map<std::string, GNEEdgeType*>&
654 return myEdgeTypes;
655}
656
657
659 myEdgeTypes.clear();
660}
661
662
663void
665 if (myEdgeTypes.count(edgeType->getID()) == 0) {
666 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
667 } else if (myEdgeTypes.count(newID) != 0) {
668 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
669 } else {
670 // remove edgeType from container
671 myEdgeTypes.erase(edgeType->getID());
672 // rename in typeCont
673 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
674 // update microsim ID
675 edgeType->setNetworkElementID(newID);
676 // add it into myEdgeTypes again
677 myEdgeTypes[edgeType->getID()] = edgeType;
678 // net has to be saved
679 myNet->getSavingStatus()->requireSaveNetwork();
680 }
681}
682
683
684std::string
686 int counter = 0;
687 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
688 counter++;
689 }
690 return ("edgeType_" + toString(counter));
691}
692
693
694GNEEdge*
695GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
696 auto it = myEdges.find(id);
697 if (it != myEdges.end()) {
698 return it->second;
699 }
700 if (hardFail) {
701 // If edge wasn't found, throw exception
702 throw UnknownElement("Attempted to retrieve non-existant edge " + id);
703 } else {
704 return nullptr;
705 }
706}
707
708
709std::vector<GNEEdge*>
711 if ((from == nullptr) || (to == nullptr)) {
712 throw UnknownElement("Junctions cannot be nullptr");
713 }
714 std::vector<GNEEdge*> edges;
715 // iterate over outgoing edges of from edge and check to junction
716 for (const auto& edgeTo : from->getGNEOutgoingEdges()) {
717 if (edgeTo->getToJunction() == to) {
718 edges.push_back(edgeTo);
719 }
720 }
721 return edges;
722}
723
724
725const std::map<std::string, GNEEdge*>&
727 return myEdges;
728}
729
730
731std::vector<GNEEdge*>
733 std::vector<GNEEdge*> result;
734 // returns edges depending of selection
735 for (const auto& edge : myEdges) {
736 if (edge.second->isAttributeCarrierSelected()) {
737 result.push_back(edge.second);
738 }
739 }
740 return result;
741}
742
743
744GNEEdge*
746 edge->incRef("GNENet::registerEdge");
747 edge->setResponsible(false);
748 // add edge to internal container of GNENet
749 myEdges[edge->getMicrosimID()] = edge;
750 myNumberOfNetworkElements++;
751 // insert all lanes
752 for (const auto& lane : edge->getChildLanes()) {
753 insertLane(lane);
754 }
755 // Add references into GNEJunctions
756 edge->getFromJunction()->addOutgoingGNEEdge(edge);
757 edge->getToJunction()->addIncomingGNEEdge(edge);
758 // update boundaries of both junctions (to remove it from Grid)
761 // update edge boundary
762 edge->updateCenteringBoundary(false);
763 // expand edge boundary
764 myNet->expandBoundary(edge->getCenteringBoundary());
765 // finally add edge into grid
766 myNet->addGLObjectIntoGrid(edge);
767 return edge;
768}
769
770
771void
775
776
777void
779 // make a copy of edges
780 auto edgeCopy = myEdges;
781 // clear edges
782 myEdges.clear();
783 // fill edges again
784 for (const auto& edge : edgeCopy) {
785 // update microsim ID
786 edge.second->setNetworkElementID(prefix + edge.first);
787 // insert in myEdges again
788 myEdges[prefix + edge.first] = edge.second;
789 }
790}
791
792
793std::string
795 // get edge prefix
796 const std::string edgePrefix = OptionsCont::getOptions().getString("prefix") + OptionsCont::getOptions().getString("edge-prefix");
797 // generate new ID
798 while (myEdges.count(edgePrefix + toString(myNet->getEdgeIDCounter())) != 0) {
799 myNet->getEdgeIDCounter()++;
800 }
801 return edgePrefix + toString(myNet->getEdgeIDCounter());
802}
803
804
805void
807 if (myEdges.count(edge->getID()) == 0) {
808 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
809 } else if (myEdges.count(newID) != 0) {
810 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
811 } else {
812 // remove edge from container
813 myEdges.erase(edge->getNBEdge()->getID());
814 // rename in NetBuilder
815 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
816 // update microsim ID
817 edge->setEdgeID(newID);
818 // add it into myEdges again
819 myEdges[edge->getID()] = edge;
820 // rename all connections related to this edge
821 for (const auto& lane : edge->getChildLanes()) {
822 lane->updateConnectionIDs();
823 }
824 // net has to be saved
825 myNet->getSavingStatus()->requireSaveNetwork();
826 }
827}
828
829
830int
832 int counter = 0;
833 for (const auto& edge : myEdges) {
834 if (edge.second->isAttributeCarrierSelected()) {
835 counter++;
836 }
837 }
838 return counter;
839}
840
841
842GNELane*
843GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
844 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
845 const GNEEdge* edge = retrieveEdge(edge_id, false);
846 if (edge != nullptr) {
847 GNELane* lane = nullptr;
848 // search lane in lane's edges
849 for (auto laneIt : edge->getChildLanes()) {
850 if (laneIt->getID() == id) {
851 lane = laneIt;
852 }
853 }
854 // throw exception or return nullptr if lane wasn't found
855 if (lane == nullptr) {
856 if (hardFail) {
857 // Throw exception if hardFail is enabled
858 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
859 }
860 } else {
861 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
862 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
863 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getChildLanes().size()) {
864 return edge->getChildLanes().at(lane->getIndex() + 1);
865 }
866 return lane;
867 }
868 } else if (hardFail) {
869 // Throw exception if hardFail is enabled
870 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
871 }
872 return nullptr;
873}
874
875
876GNELane*
877GNENetHelper::AttributeCarriers::retrieveLane(const GUIGlObject* glObject, bool hardFail) const {
878 auto it = myLanes.find(glObject);
879 if (it != myLanes.end()) {
880 return it->second;
881 }
882 if (hardFail) {
883 // If junction wasn't found, throw exception
884 throw UnknownElement("Attempted to retrieve non-existant lane " + glObject->getMicrosimID());
885 } else {
886 return nullptr;
887 }
888}
889
890
891const std::unordered_map<const GUIGlObject*, GNELane*>&
893 return myLanes;
894}
895
896
897std::vector<GNELane*>
899 std::vector<GNELane*> result;
900 // returns lanes depending of selection
901 for (const auto& lane : myLanes) {
902 if (lane.second->isAttributeCarrierSelected()) {
903 result.push_back(lane.second);
904 }
905 }
906 return result;
907}
908
909
910int
912 int counter = 0;
913 for (const auto& lane : myLanes) {
914 if (lane.second->isAttributeCarrierSelected()) {
915 counter++;
916 }
917 }
918 return counter;
919}
920
921
923GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
924 // iterate over connections
925 for (const auto& connection : myConnections) {
926 if (connection.second->getID() == id) {
927 return connection.second;
928 }
929 }
930 if (hardFail) {
931 // If POI wasn't found, throw exception
932 throw UnknownElement("Attempted to retrieve non-existant connection " + id);
933 } else {
934 return nullptr;
935 }
936}
937
938
941 auto it = myConnections.find(glObject);
942 if (it != myConnections.end()) {
943 return it->second;
944 }
945 if (hardFail) {
946 // If POI wasn't found, throw exception
947 throw UnknownElement("Attempted to retrieve non-existant connection " + glObject->getMicrosimID());
948 } else {
949 return nullptr;
950 }
951}
952
953
954const std::unordered_map<const GUIGlObject*, GNEConnection*>&
956 return myConnections;
957}
958
959
960std::vector<GNEConnection*>
962 std::vector<GNEConnection*> result;
963 // returns connections depending of selection
964 for (const auto& connection : myConnections) {
965 if (connection.second->isAttributeCarrierSelected()) {
966 result.push_back(connection.second);
967 }
968 }
969 return result;
970}
971
972
973int
975 int counter = 0;
976 for (const auto& connection : myConnections) {
977 if (connection.second->isAttributeCarrierSelected()) {
978 counter++;
979 }
980 }
981 return counter;
982}
983
984
987 auto it = myInternalLanes.find(glObject);
988 if (it != myInternalLanes.end()) {
989 return it->second;
990 }
991 if (hardFail) {
992 // If POI wasn't found, throw exception
993 throw UnknownElement("Attempted to retrieve non-existant internalLane " + glObject->getMicrosimID());
994 } else {
995 return nullptr;
996 }
997}
998
999
1001GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
1002 auto it = myAdditionalIDs.at(type).find(id);
1003 if (it != myAdditionalIDs.at(type).end()) {
1004 return it->second;
1005 }
1006 if (hardFail) {
1007 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1008 } else {
1009 return nullptr;
1010 }
1011}
1012
1013
1015GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1016 for (const auto& type : types) {
1017 auto it = myAdditionalIDs.at(type).find(id);
1018 if (it != myAdditionalIDs.at(type).end()) {
1019 return it->second;
1020 }
1021 }
1022 if (hardFail) {
1023 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1024 } else {
1025 return nullptr;
1026 }
1027}
1028
1029
1032 // iterate over all additionals
1033 for (const auto& additionalTag : myAdditionals) {
1034 auto it = additionalTag.second.find(glObject);
1035 if (it != additionalTag.second.end()) {
1036 return it->second;
1037 }
1038 }
1039 if (hardFail) {
1040 throw ProcessError("Attempted to retrieve non-existant additional (glObject)");
1041 } else {
1042 return nullptr;
1043 }
1044}
1045
1046
1048GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
1049 // first retrieve rerouter
1050 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
1051 // parse begin and end
1052 const std::string beginStr = time2string(begin);
1053 const std::string endStr = time2string(end);
1054 // now iterate over all children and check begin and end
1055 for (const auto& interval : rerouter->getChildAdditionals()) {
1056 // check tag (to avoid symbols)
1057 if (interval->getTagProperty()->getTag() == SUMO_TAG_INTERVAL) {
1058 // check begin and end
1059 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
1060 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
1061 return interval;
1062 }
1063 }
1064 }
1065 // throw exception
1066 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
1067}
1068
1069
1070const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEAdditional*>, std::hash<int> >&
1072 return myAdditionals;
1073}
1074
1075
1076std::vector<GNEAdditional*>
1078 std::vector<GNEAdditional*> result;
1079 // returns additionals depending of selection
1080 for (const auto& additionalsTags : myAdditionals) {
1081 for (const auto& additional : additionalsTags.second) {
1082 if (additional.second->isAttributeCarrierSelected()) {
1083 result.push_back(additional.second);
1084 }
1085 }
1086 }
1087 return result;
1088}
1089
1090
1091std::vector<GNEAdditional*>
1093 std::vector<GNEAdditional*> result;
1094 // returns additionals depending of selection
1095 for (const auto& additionalsTags : myAdditionals) {
1096 for (const auto& additional : additionalsTags.second) {
1097 if (additional.second->getTagProperty()->isShapeElement() && additional.second->isAttributeCarrierSelected()) {
1098 result.push_back(additional.second);
1099 }
1100 }
1101 }
1102 return result;
1103}
1104
1105
1106int
1108 int counter = 0;
1109 for (const auto& additionalsTag : myAdditionals) {
1110 counter += (int)additionalsTag.second.size();
1111 }
1112 return counter;
1113}
1114
1115
1116void
1118 // clear elements in grid
1119 for (const auto& additionalsTags : myAdditionals) {
1120 for (const auto& additional : additionalsTags.second) {
1121 myNet->removeGLObjectFromGrid(additional.second);
1122 }
1123 }
1124 // iterate over myAdditionals and clear all additionals
1125 for (auto& additionals : myAdditionals) {
1126 additionals.second.clear();
1127 }
1128 for (auto& additionals : myAdditionalIDs) {
1129 additionals.second.clear();
1130 }
1131}
1132
1133
1134void
1136 const auto tag = additional->getTagProperty()->getTag();
1137 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1138 if (it == myAdditionalIDs.at(tag).end()) {
1139 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1140 } else {
1141 // remove from container, set new Id, and insert it again
1142 myAdditionalIDs.at(tag).erase(it);
1143 // set microsim ID
1144 additional->setMicrosimID(newID);
1145 myAdditionalIDs.at(tag)[newID] = additional;
1146 }
1147}
1148
1149
1150std::string
1152 // obtain option container
1153 const auto& neteditOptions = OptionsCont::getOptions();
1154 // get prefix
1155 std::string prefix;
1156 if (tag == SUMO_TAG_BUS_STOP) {
1157 prefix = neteditOptions.getString("busStop-prefix");
1158 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1159 prefix = neteditOptions.getString("trainStop-prefix");
1160 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1161 prefix = neteditOptions.getString("containerStop-prefix");
1162 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1163 prefix = neteditOptions.getString("chargingStation-prefix");
1164 } else if (tag == SUMO_TAG_PARKING_AREA) {
1165 prefix = neteditOptions.getString("parkingArea-prefix");
1166 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1167 prefix = neteditOptions.getString("e1Detector-prefix");
1168 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1169 prefix = neteditOptions.getString("e2Detector-prefix");
1170 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1171 prefix = neteditOptions.getString("e3Detector-prefix");
1172 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1173 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1174 } else if (tag == SUMO_TAG_REROUTER) {
1175 prefix = neteditOptions.getString("rerouter-prefix");
1176 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1177 prefix = neteditOptions.getString("calibrator-prefix");
1178 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1179 prefix = neteditOptions.getString("routeProbe-prefix");
1180 } else if (tag == SUMO_TAG_VSS) {
1181 prefix = neteditOptions.getString("vss-prefix");
1182 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1183 prefix = neteditOptions.getString("tractionSubstation-prefix");
1184 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1185 prefix = neteditOptions.getString("overheadWire-prefix");
1186 } else if (tag == SUMO_TAG_POLY) {
1187 prefix = neteditOptions.getString("polygon-prefix");
1188 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1189 prefix = neteditOptions.getString("poi-prefix");
1190 } else if (tag == SUMO_TAG_TAZ) {
1191 prefix = toString(SUMO_TAG_TAZ);
1192 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1193 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1194 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1195 prefix = neteditOptions.getString("jps.obstacle-prefix");
1196 }
1197 int counter = 0;
1198 // check namespaces
1199 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1200 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1201 counter++;
1202 }
1203 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1204 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1205 counter++;
1206 }
1207 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1208 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1209 counter++;
1210 }
1211 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1212 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1213 counter++;
1214 }
1215 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1216 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1217 counter++;
1218 }
1219 } else {
1220 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1221 counter++;
1222 }
1223 }
1224 // return new element ID
1225 return (prefix + "_" + toString(counter));
1226}
1227
1228
1229int
1231 int counter = 0;
1232 for (const auto& additionalsTags : myAdditionals) {
1233 for (const auto& additional : additionalsTags.second) {
1234 if (additional.second->isAttributeCarrierSelected()) {
1235 counter++;
1236 }
1237 }
1238 }
1239 return counter;
1240}
1241
1242
1243int
1245 return getNumberOfSelectedAdditionals() -
1246 // shapes
1247 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1248 // JuPedSims
1249 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1250 // TAZ
1251 getNumberOfSelectedTAZs() -
1252 // wires
1253 getNumberOfSelectedWires();
1254}
1255
1256
1257int
1259 int counter = 0;
1260 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1261 if (poly.second->isAttributeCarrierSelected()) {
1262 counter++;
1263 }
1264 }
1265 return counter;
1266}
1267
1268
1269int
1271 int counter = 0;
1272 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1273 if (walkableArea.second->isAttributeCarrierSelected()) {
1274 counter++;
1275 }
1276 }
1277 return counter;
1278}
1279
1280
1281int
1283 int counter = 0;
1284 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1285 if (obstacle.second->isAttributeCarrierSelected()) {
1286 counter++;
1287 }
1288 }
1289 return counter;
1290}
1291
1292
1293int
1295 int counter = 0;
1296 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1297 if (POI.second->isAttributeCarrierSelected()) {
1298 counter++;
1299 }
1300 }
1301 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1302 if (POILane.second->isAttributeCarrierSelected()) {
1303 counter++;
1304 }
1305 }
1306 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1307 if (POIGEO.second->isAttributeCarrierSelected()) {
1308 counter++;
1309 }
1310 }
1311 return counter;
1312}
1313
1314
1315int
1317 int counter = 0;
1318 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1319 if (TAZ.second->isAttributeCarrierSelected()) {
1320 counter++;
1321 }
1322 }
1323 return counter;
1324}
1325
1326
1327int
1329 int counter = 0;
1330 for (const auto& additionalsTags : myAdditionals) {
1331 for (const auto& additional : additionalsTags.second) {
1332 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty()->isWireElement()) {
1333 counter++;
1334 }
1335 }
1336 }
1337 return counter;
1338}
1339
1340
1343 // iterate over all demand elements
1344 for (const auto& TAZSourceSinkTag : myTAZSourceSinks) {
1345 auto it = TAZSourceSinkTag.second.find(sourceSink);
1346 if (it != TAZSourceSinkTag.second.end()) {
1347 return it->second;
1348 }
1349 }
1350 if (hardFail) {
1351 throw ProcessError("Attempted to retrieve non-existant sourceSink (glObject)");
1352 } else {
1353 return nullptr;
1354 }
1355}
1356
1357
1358const std::unordered_map<SumoXMLTag, std::unordered_map<const GNEAttributeCarrier*, GNETAZSourceSink*>, std::hash<int> >&
1360 return myTAZSourceSinks;
1361}
1362
1363
1364int
1366 int counter = 0;
1367 for (const auto& sourceSinksTag : myTAZSourceSinks) {
1368 counter += (int)sourceSinksTag.second.size();
1369 }
1370 return counter;
1371}
1372
1373
1374void
1376 // iterate over myTAZSourceSinks and clear all sourceSinks
1377 for (auto& sourceSinksTags : myTAZSourceSinks) {
1378 sourceSinksTags.second.clear();
1379 }
1380}
1381
1382
1384GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1385 auto it = myDemandElementIDs.at(type).find(id);
1386 if (it != myDemandElementIDs.at(type).end()) {
1387 return it->second;
1388 }
1389 if (hardFail) {
1390 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1391 } else {
1392 return nullptr;
1393 }
1394}
1395
1396
1398GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1399 for (const auto& type : types) {
1400 auto it = myDemandElementIDs.at(type).find(id);
1401 if (it != myDemandElementIDs.at(type).end()) {
1402 return it->second;
1403 }
1404 }
1405 if (hardFail) {
1406 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1407 } else {
1408 return nullptr;
1409 }
1410}
1411
1412
1415 // iterate over all demand elements
1416 for (const auto& demandElementTag : myDemandElements) {
1417 auto it = demandElementTag.second.find(glObject);
1418 if (it != demandElementTag.second.end()) {
1419 return it->second;
1420 }
1421 }
1422 if (hardFail) {
1423 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1424 } else {
1425 return nullptr;
1426 }
1427}
1428
1429
1430std::vector<GNEDemandElement*>
1432 std::vector<GNEDemandElement*> result;
1433 // returns demand elements depending of selection
1434 for (const auto& demandElementTag : myDemandElements) {
1435 for (const auto& demandElement : demandElementTag.second) {
1436 if (demandElement.second->isAttributeCarrierSelected()) {
1437 result.push_back(demandElement.second);
1438 }
1439 }
1440 }
1441 return result;
1442}
1443
1444
1445const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEDemandElement*>, std::hash<int> >&
1447 return myDemandElements;
1448}
1449
1450
1451std::string
1453 // obtain option container
1454 const auto& neteditOptions = OptionsCont::getOptions();
1455 // get tag property
1456 const auto tagProperty = myNet->getTagPropertiesDatabase()->getTagProperty(tag, true);
1457 // get prefix
1458 std::string prefix;
1459 if (tag == SUMO_TAG_ROUTE) {
1460 prefix = neteditOptions.getString("route-prefix");
1461 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1462 prefix = neteditOptions.getString("routeDistribution-prefix");
1463 } else if (tag == SUMO_TAG_VTYPE) {
1464 prefix = neteditOptions.getString("vType-prefix");
1465 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1466 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1467 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1468 prefix = neteditOptions.getString("trip-prefix");
1469 } else if (tagProperty->isVehicle() && !tagProperty->isFlow()) {
1470 prefix = neteditOptions.getString("vehicle-prefix");
1471 } else if (tagProperty->isPerson()) {
1472 if (tagProperty->isFlow()) {
1473 prefix = neteditOptions.getString("personflow-prefix");
1474 } else {
1475 prefix = neteditOptions.getString("person-prefix");
1476 }
1477 } else if (tagProperty->isContainer()) {
1478 if (tagProperty->isFlow()) {
1479 prefix = neteditOptions.getString("containerflow-prefix");
1480 } else {
1481 prefix = neteditOptions.getString("container-prefix");
1482 }
1483 } else if (tagProperty->isFlow()) {
1484 prefix = neteditOptions.getString("flow-prefix");
1485 }
1486 // declare counter
1487 int counter = 0;
1488 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1489 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1490 counter++;
1491 }
1492 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1493 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1494 counter++;
1495 }
1496 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1497 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1498 counter++;
1499 }
1500 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1501 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1502 counter++;
1503 }
1504 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1505 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1506 counter++;
1507 }
1508 } else {
1509 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1510 counter++;
1511 }
1512 }
1513 // return new element ID
1514 return (prefix + "_" + toString(counter));
1515
1516}
1517
1518
1521 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1522 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1523 return it->second;
1524 }
1525 throw ProcessError(TL("Default vType doesn't exist"));
1526}
1527
1528
1529void
1531 // clear elements in grid
1532 for (const auto& demandElementsTags : myDemandElements) {
1533 for (const auto& demandElement : demandElementsTags.second) {
1534 myNet->removeGLObjectFromGrid(demandElement.second);
1535 }
1536 }
1537 // iterate over myDemandElements and clear all demand elements
1538 for (auto& demandElements : myDemandElements) {
1539 demandElements.second.clear();
1540 }
1541 for (auto& demandElements : myDemandElementIDs) {
1542 demandElements.second.clear();
1543 }
1544}
1545
1546
1547void
1549 const auto tag = demandElement->getTagProperty()->getTag();
1550 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1551 if (it == myDemandElementIDs.at(tag).end()) {
1552 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1553 } else {
1554 // remove from container, set new Id, and insert it again
1555 myDemandElementIDs.at(tag).erase(it);
1556 // set microsim ID
1557 demandElement->setMicrosimID(newID);
1558 myDemandElementIDs.at(tag)[newID] = demandElement;
1559 }
1560}
1561
1562
1563void
1565 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1566 GNEVType* defaultVehicleType = new GNEVType(DEFAULT_VTYPE_ID, myNet, SVC_PASSENGER);
1567 myDemandElements.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1568 myDemandElementIDs.at(defaultVehicleType->getTagProperty()->getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1569 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1570
1571 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1572 GNEVType* defaultBikeType = new GNEVType(DEFAULT_BIKETYPE_ID, myNet, SVC_BICYCLE);
1573 myDemandElements.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1574 myDemandElementIDs.at(defaultBikeType->getTagProperty()->getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1575 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1576 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1577
1578 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1579 GNEVType* defaultTaxiType = new GNEVType(DEFAULT_TAXITYPE_ID, myNet, SVC_TAXI);
1580 myDemandElements.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1581 myDemandElementIDs.at(defaultTaxiType->getTagProperty()->getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1582 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1583 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1584
1585 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1586 GNEVType* defaultRailType = new GNEVType(DEFAULT_RAILTYPE_ID, myNet, SVC_RAIL);
1587 myDemandElements.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1588 myDemandElementIDs.at(defaultRailType->getTagProperty()->getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1589 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1590 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1591
1592 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1593 GNEVType* defaultPersonType = new GNEVType(DEFAULT_PEDTYPE_ID, myNet, SVC_PEDESTRIAN);
1594 myDemandElements.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1595 myDemandElementIDs.at(defaultPersonType->getTagProperty()->getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1596 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1597 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1598
1599 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1600 GNEVType* defaultContainerType = new GNEVType(DEFAULT_CONTAINERTYPE_ID, myNet, SVC_IGNORING);
1601 myDemandElements.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1602 myDemandElementIDs.at(defaultContainerType->getTagProperty()->getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1603 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1604 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1605}
1606
1607
1608int
1610 return myStopIndex++;
1611}
1612
1613
1614int
1616 int counter = 0;
1617 for (const auto& demandElementsTags : myDemandElements) {
1618 for (const auto& demandElement : demandElementsTags.second) {
1619 if (demandElement.second->isAttributeCarrierSelected()) {
1620 counter++;
1621 }
1622 }
1623 }
1624 return counter;
1625}
1626
1627
1628int
1630 int counter = 0;
1631 // iterate over routes
1632 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1633 if (route.second->isAttributeCarrierSelected()) {
1634 counter++;
1635 }
1636 }
1637 // iterate over vehicles with embedded routes
1638 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1639 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1640 counter++;
1641 }
1642 }
1643 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1644 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1645 counter++;
1646 }
1647 }
1648 return counter;
1649}
1650
1651
1652int
1654 int counter = 0;
1655 // iterate over all vehicles and flows
1656 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1657 if (vehicle.second->isAttributeCarrierSelected()) {
1658 counter++;
1659 }
1660 }
1661 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1662 if (trip.second->isAttributeCarrierSelected()) {
1663 counter++;
1664 }
1665 }
1666 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1667 if (vehicle.second->isAttributeCarrierSelected()) {
1668 counter++;
1669 }
1670 }
1671 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1672 if (flow.second->isAttributeCarrierSelected()) {
1673 counter++;
1674 }
1675 }
1676 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1677 if (flow.second->isAttributeCarrierSelected()) {
1678 counter++;
1679 }
1680 }
1681 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1682 if (flow.second->isAttributeCarrierSelected()) {
1683 counter++;
1684 }
1685 }
1686 return counter;
1687}
1688
1689
1690int
1692 int counter = 0;
1693 // iterate over all persons
1694 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1695 if (person.second->isAttributeCarrierSelected()) {
1696 counter++;
1697 }
1698 }
1699 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1700 if (personFlow.second->isAttributeCarrierSelected()) {
1701 counter++;
1702 }
1703 }
1704 return counter;
1705}
1706
1707
1708int
1710 int counter = 0;
1711 // iterate over all person plans
1712 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1713 for (const auto& personPlan : person.second->getChildDemandElements()) {
1714 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1715 counter++;
1716 }
1717 }
1718 }
1719 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1720 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1721 if (personPlan->getTagProperty()->isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1722 counter++;
1723 }
1724 }
1725 }
1726 return counter;
1727}
1728
1729
1730int
1732 int counter = 0;
1733 // iterate over all person plans
1734 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1735 for (const auto& personPlan : person.second->getChildDemandElements()) {
1736 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1737 counter++;
1738 }
1739 }
1740 }
1741 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1742 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1743 if (personPlan->getTagProperty()->isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1744 counter++;
1745 }
1746 }
1747 }
1748 return counter;
1749}
1750
1751
1752int
1754 int counter = 0;
1755 // iterate over all person plans
1756 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1757 for (const auto& personPlan : person.second->getChildDemandElements()) {
1758 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1759 counter++;
1760 }
1761 }
1762 }
1763 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1764 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1765 if (personPlan->getTagProperty()->isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1766 counter++;
1767 }
1768 }
1769 }
1770 return counter;
1771}
1772
1773
1774int
1776 int counter = 0;
1777 // iterate over all containers
1778 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1779 if (container.second->isAttributeCarrierSelected()) {
1780 counter++;
1781 }
1782 }
1783 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1784 if (containerFlow.second->isAttributeCarrierSelected()) {
1785 counter++;
1786 }
1787 }
1788 return counter;
1789}
1790
1791
1792int
1794 int counter = 0;
1795 // iterate over all container plans
1796 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1797 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1798 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1799 counter++;
1800 }
1801 }
1802 }
1803 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1804 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1805 if (containerPlan->getTagProperty()->isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1806 counter++;
1807 }
1808 }
1809 }
1810 return counter;
1811}
1812
1813
1814int
1816 int counter = 0;
1817 // iterate over all container plans
1818 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1819 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1820 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1821 counter++;
1822 }
1823 }
1824 }
1825 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1826 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1827 if (containerPlan->getTagProperty()->isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1828 counter++;
1829 }
1830 }
1831 }
1832 return counter;
1833}
1834
1835
1836int
1838 int counter = 0;
1839 // iterate over routes
1840 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1841 if (route.second->isAttributeCarrierSelected()) {
1842 counter++;
1843 }
1844 }
1845 // vehicles
1846 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1847 for (const auto& stop : trip.second->getChildDemandElements()) {
1848 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1849 counter++;
1850 }
1851 }
1852 }
1853 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1854 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1855 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1856 counter++;
1857 }
1858 }
1859 }
1860 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1861 for (const auto& stop : flow.second->getChildDemandElements()) {
1862 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1863 counter++;
1864 }
1865 }
1866 }
1867 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1868 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1869 if (stop->getTagProperty()->isVehicleStop() && stop->isAttributeCarrierSelected()) {
1870 counter++;
1871 }
1872 }
1873 }
1874 // persons
1875 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1876 for (const auto& personPlan : person.second->getChildDemandElements()) {
1877 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1878 counter++;
1879 }
1880 }
1881 }
1882 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1883 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1884 if (personPlan->getTagProperty()->isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1885 counter++;
1886 }
1887 }
1888 }
1889 // containers
1890 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1891 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1892 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1893 counter++;
1894 }
1895 }
1896 }
1897 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1898 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1899 if (containerPlan->getTagProperty()->isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1900 counter++;
1901 }
1902 }
1903 }
1904 return counter;
1905}
1906
1907
1909GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1910 for (const auto& dataSet : myDataSets) {
1911 if (dataSet.second->getID() == id) {
1912 return dataSet.second;
1913 }
1914 }
1915 if (hardFail) {
1916 throw ProcessError("Attempted to retrieve non-existant data set");
1917 } else {
1918 return nullptr;
1919 }
1920}
1921
1922
1923const std::map<const std::string, GNEDataSet*>&
1925 return myDataSets;
1926}
1927
1928
1929std::string
1931 // get prefix
1932 const auto prefix = OptionsCont::getOptions().getString("dataSet-prefix");
1933 int counter = 0;
1934 while (retrieveDataSet(prefix + "_" + toString(counter), false) != nullptr) {
1935 counter++;
1936 }
1937 return (prefix + "_" + toString(counter));
1938}
1939
1940
1943 if (myDataIntervals.count(AC)) {
1944 return myDataIntervals.at(AC);
1945 } else if (hardFail) {
1946 throw ProcessError("Attempted to retrieve non-existant data interval");
1947 } else {
1948 return nullptr;
1949 }
1950}
1951
1952
1953const std::unordered_map<const GNEAttributeCarrier*, GNEDataInterval*>&
1955 return myDataIntervals;
1956}
1957
1958
1959void
1961 if (myDataIntervals.count(AC) > 0) {
1962 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
1963 } else {
1964 myDataIntervals[AC] = dataInterval;
1965 }
1966 // mark interval toolbar for update
1967 myNet->getViewNet()->getIntervalBar().markForUpdate();
1968}
1969
1970
1971void
1973 const auto finder = myDataIntervals.find(dataInterval);
1974 if (finder == myDataIntervals.end()) {
1975 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
1976 } else {
1977 myDataIntervals.erase(finder);
1978 }
1979 // remove it from inspected elements and GNEElementTree
1980 myNet->getViewNet()->getInspectedElements().uninspectAC(dataInterval);
1981 dataInterval->unmarkForDrawingFront();
1982 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
1983 // mark interval toolbar for update
1984 myNet->getViewNet()->getIntervalBar().markForUpdate();
1985}
1986
1987
1990 // iterate over all genericDatas
1991 for (const auto& genericDataTag : myGenericDatas) {
1992 auto it = genericDataTag.second.find(glObject);
1993 if (it != genericDataTag.second.end()) {
1994 return it->second;
1995 }
1996 }
1997 if (hardFail) {
1998 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
1999 } else {
2000 return nullptr;
2001 }
2002}
2003
2004
2005std::vector<GNEGenericData*>
2007 std::vector<GNEGenericData*> result;
2008 // returns generic datas depending of selection
2009 for (const auto& genericDataTag : myGenericDatas) {
2010 for (const auto& genericData : genericDataTag.second) {
2011 if (genericData.second->isAttributeCarrierSelected()) {
2012 result.push_back(genericData.second);
2013 }
2014 }
2015 }
2016 return result;
2017}
2018
2019
2020const std::unordered_map<SumoXMLTag, std::unordered_map<const GUIGlObject*, GNEGenericData*>, std::hash<int> >&
2022 return myGenericDatas;
2023}
2024
2025
2026std::vector<GNEGenericData*>
2027GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2028 // declare generic data vector
2029 std::vector<GNEGenericData*> genericDatas;
2030 // iterate over all data sets
2031 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2032 // check interval
2033 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2034 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2035 genericDatas.push_back(genericData.second);
2036 }
2037 }
2038 return genericDatas;
2039}
2040
2041
2042int
2044 int counter = 0;
2045 // iterate over all generic datas
2046 for (const auto& genericDataTag : myGenericDatas) {
2047 counter += (int)genericDataTag.second.size();
2048 }
2049 return counter;
2050}
2051
2052
2053int
2055 int counter = 0;
2056 // iterate over all edgeDatas
2057 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2058 if (genericData.second->isAttributeCarrierSelected()) {
2059 counter++;
2060 }
2061 }
2062 return counter;
2063}
2064
2065
2066int
2068 int counter = 0;
2069 // iterate over all edgeDatas
2070 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2071 if (genericData.second->isAttributeCarrierSelected()) {
2072 counter++;
2073 }
2074 }
2075 return counter;
2076}
2077
2078
2079int
2081 int counter = 0;
2082 // iterate over all edgeDatas
2083 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2084 if (genericData.second->isAttributeCarrierSelected()) {
2085 counter++;
2086 }
2087 }
2088 return counter;
2089}
2090
2091
2092void
2094 if (myGenericDatas.at(genericData->getTagProperty()->getTag()).count(genericData->getGUIGlObject()) > 0) {
2095 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2096 } else {
2097 myGenericDatas.at(genericData->getTagProperty()->getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2098 }
2099 // mark interval toolbar for update
2100 myNet->getViewNet()->getIntervalBar().markForUpdate();
2101}
2102
2103
2104void
2106 const auto finder = myGenericDatas.at(genericData->getTagProperty()->getTag()).find(genericData);
2107 if (finder == myGenericDatas.at(genericData->getTagProperty()->getTag()).end()) {
2108 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2109 } else {
2110 myGenericDatas.at(genericData->getTagProperty()->getTag()).erase(finder);
2111 }
2112 // remove it from inspected elements and GNEElementTree
2113 myNet->getViewNet()->getInspectedElements().uninspectAC(genericData);
2114 genericData->unmarkForDrawingFront();
2115 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2116 // delete path element
2117 myNet->getDataPathManager()->removePath(genericData);
2118 // mark interval toolbar for update
2119 myNet->getViewNet()->getIntervalBar().markForUpdate();
2120}
2121
2122
2123std::set<std::string>
2124GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2125 // declare solution
2126 std::set<std::string> attributesSolution;
2127 // declare generic data vector
2128 std::vector<GNEGenericData*> genericDatas;
2129 // iterate over all data sets
2130 for (const auto& interval : myDataIntervals) {
2131 // check interval
2132 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2133 // iterate over generic datas
2134 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2135 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2136 genericDatas.push_back(genericData);
2137 }
2138 }
2139 }
2140 }
2141 // iterate over generic datas
2142 for (const auto& genericData : genericDatas) {
2143 for (const auto& attribute : genericData->getParametersMap()) {
2144 attributesSolution.insert(attribute.first);
2145 }
2146 }
2147 return attributesSolution;
2148}
2149
2150
2151std::set<std::string>
2152GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2153 const std::string& beginStr, const std::string& endStr) const {
2154 // declare solution
2155 std::set<std::string> attributesSolution;
2156 // vector of data sets and intervals
2157 std::vector<GNEDataSet*> dataSets;
2158 std::vector<GNEDataInterval*> dataIntervals;
2159 // get dataSet
2160 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2161 // if dataSetID is empty, return all parameters
2162 if (dataSetID.empty()) {
2163 // add all data sets
2164 dataSets.reserve(myDataSets.size());
2165 for (const auto& dataSet : myDataSets) {
2166 dataSets.push_back(dataSet.second);
2167 }
2168 } else if (retrievedDataSet) {
2169 dataSets.push_back(retrievedDataSet);
2170 } else {
2171 return attributesSolution;
2172 }
2173 // now continue with data intervals
2174 int numberOfIntervals = 0;
2175 for (const auto& dataSet : dataSets) {
2176 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2177 }
2178 // resize dataIntervals
2179 dataIntervals.reserve(numberOfIntervals);
2180 // add intervals
2181 for (const auto& dataSet : dataSets) {
2182 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2183 // continue depending of begin and end
2184 if (beginStr.empty() && endStr.empty()) {
2185 dataIntervals.push_back(dataInterval.second);
2186 } else if (endStr.empty()) {
2187 // parse begin
2188 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2189 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2190 dataIntervals.push_back(dataInterval.second);
2191 }
2192 } else if (beginStr.empty()) {
2193 // parse end
2194 const double end = GNEAttributeCarrier::parse<double>(endStr);
2195 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2196 dataIntervals.push_back(dataInterval.second);
2197 }
2198 } else {
2199 // parse both begin end
2200 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2201 const double end = GNEAttributeCarrier::parse<double>(endStr);
2202 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2203 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2204 dataIntervals.push_back(dataInterval.second);
2205 }
2206 }
2207 }
2208 }
2209 // finally iterate over intervals and get attributes
2210 for (const auto& dataInterval : dataIntervals) {
2211 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2212 // check generic data tag
2213 if (genericDataTag.empty() || (genericData->getTagProperty()->getTagStr() == genericDataTag)) {
2214 for (const auto& attribute : genericData->getParametersMap()) {
2215 attributesSolution.insert(attribute.first);
2216 }
2217 }
2218 }
2219 }
2220 return attributesSolution;
2221}
2222
2223
2225GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2226 for (const auto& meanData : myMeanDatas.at(type)) {
2227 if (meanData.second->getID() == id) {
2228 return meanData.second;
2229 }
2230 }
2231 if (hardFail) {
2232 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2233 } else {
2234 return nullptr;
2235 }
2236}
2237
2238
2239const std::unordered_map<SumoXMLTag, std::map<const std::string, GNEMeanData*>, std::hash<int> >&
2241 return myMeanDatas;
2242}
2243
2244
2245int
2247 return myNumberOfMeanDataElements;
2248}
2249
2250
2251void
2253 // iterate over myMeanDatas and clear all meanDatas
2254 for (auto& meanDatas : myMeanDatas) {
2255 meanDatas.second.clear();
2256 }
2257}
2258
2259
2260void
2262 const auto tag = meanData->getTagProperty()->getTag();
2263 const auto it = myMeanDatas.at(tag).find(meanData->getID());
2264 if (it == myMeanDatas.at(tag).end()) {
2265 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' doesn't exist in AttributeCarriers.meanDatas");
2266 } else {
2267 // remove from container, set new Id, and insert it again
2268 myMeanDatas.at(tag).erase(it);
2269 myMeanDatas.at(tag)[newID] = meanData;
2270 }
2271}
2272
2273
2274std::string
2276 // obtain option container
2277 const auto& neteditOptions = OptionsCont::getOptions();
2278 // get prefix
2279 std::string prefix;
2280 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2281 prefix = neteditOptions.getString("meanDataEdge-prefix");
2282 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2283 prefix = neteditOptions.getString("meanDataLane-prefix");
2284 }
2285 int counter = 0;
2286 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2287 counter++;
2288 }
2289 return (prefix + "_" + toString(counter));
2290}
2291
2292
2293void
2295 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2296 registerJunction(junction);
2297}
2298
2299
2300void
2302 // remove it from inspected elements and GNEElementTree
2303 myNet->getViewNet()->getInspectedElements().uninspectAC(junction);
2304 junction->unmarkForDrawingFront();
2305 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2306 // Remove from grid and container
2307 myNet->removeGLObjectFromGrid(junction);
2308 myJunctions.erase(junction->getMicrosimID());
2309 myNumberOfNetworkElements--;
2310 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2311 junction->decRef("GNENet::deleteSingleJunction");
2312 junction->setResponsible(true);
2313}
2314
2315
2316void
2318 // get pointer to create edge frame
2319 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2320 // insert in myEdgeTypes
2321 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2322 myNumberOfNetworkElements++;
2323 // update edge selector
2324 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
2325 myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2326 }
2327 // set current edge type inspected
2328 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2329}
2330
2331
2332void
2334 // get pointer to create edge frame
2335 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2336 // remove it from inspected elements and GNEElementTree
2337 myNet->getViewNet()->getInspectedElements().uninspectAC(edgeType);
2338 edgeType->unmarkForDrawingFront();
2339 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2340 // remove from edge types
2341 myEdgeTypes.erase(edgeType->getMicrosimID());
2342 myNumberOfNetworkElements--;
2343 // check if this is the selected edge type in edgeSelector
2344 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2345 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2346 }
2347 // update edge selector
2348 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2349}
2350
2351
2352void
2354 NBEdge* nbe = edge->getNBEdge();
2355 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2356 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2357 nbe->getFromNode()->addOutgoingEdge(nbe);
2358 nbe->getToNode()->addIncomingEdge(nbe);
2359 // register edge
2360 registerEdge(edge);
2361}
2362
2363
2364void
2366 // remove it from inspected elements and GNEElementTree
2367 myNet->getViewNet()->getInspectedElements().uninspectAC(edge);
2368 edge->unmarkForDrawingFront();
2369 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2370 // remove edge from visual grid and container
2371 myNet->removeGLObjectFromGrid(edge);
2372 myEdges.erase(edge->getMicrosimID());
2373 myNumberOfNetworkElements--;
2374 // remove all lanes
2375 for (const auto& lane : edge->getChildLanes()) {
2376 deleteLane(lane);
2377 }
2378 // extract edge of district container
2379 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2380 edge->decRef("GNENet::deleteSingleEdge");
2381 edge->setResponsible(true);
2382 // Remove refrences from GNEJunctions
2384 edge->getToJunction()->removeIncomingGNEEdge(edge);
2385 // update boundaries of both junctions (to remove it from Grid)
2388 // get template editor
2389 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
2390 // check if we have to remove template
2391 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2392 templateEditor->setEdgeTemplate(nullptr);
2393 }
2394}
2395
2396
2397void
2399 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2400 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2401 } else {
2402 myLanes[lane->getGUIGlObject()] = lane;
2403 myNumberOfNetworkElements++;
2404 }
2405}
2406
2407
2408void
2410 const auto finder = myLanes.find(lane->getGUIGlObject());
2411 if (finder == myLanes.end()) {
2412 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2413 } else {
2414 myLanes.erase(finder);
2415 myNumberOfNetworkElements--;
2416 // remove it from inspected elements and GNEElementTree
2417 myNet->getViewNet()->getInspectedElements().uninspectAC(lane);
2418 lane->unmarkForDrawingFront();
2419 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2420 }
2421}
2422
2423
2424void
2426 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2427 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2428 } else {
2429 myCrossings[crossing->getGUIGlObject()] = crossing;
2430 myNumberOfNetworkElements++;
2431 }
2432}
2433
2434
2435void
2437 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2438 if (finder == myCrossings.end()) {
2439 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2440 } else {
2441 myCrossings.erase(finder);
2442 myNumberOfNetworkElements--;
2443 // remove it from inspected elements and GNEElementTree
2444 if (myNet->getViewNet()) {
2445 myNet->getViewNet()->getInspectedElements().uninspectAC(crossing);
2446 crossing->unmarkForDrawingFront();
2447 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2448 }
2449 }
2450}
2451
2452
2453void
2455 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2456 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2457 } else {
2458 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2459 myNumberOfNetworkElements++;
2460 }
2461}
2462
2463
2464void
2466 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2467 if (finder == myWalkingAreas.end()) {
2468 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2469 } else {
2470 myWalkingAreas.erase(finder);
2471 myNumberOfNetworkElements--;
2472 // remove it from inspected elements and GNEElementTree
2473 myNet->getViewNet()->getInspectedElements().uninspectAC(walkingArea);
2474 walkingArea->unmarkForDrawingFront();
2475 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2476 }
2477}
2478
2479
2480void
2482 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2483 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2484 } else {
2485 myConnections[connection->getGUIGlObject()] = connection;
2486 myNumberOfNetworkElements++;
2487 }
2488}
2489
2490
2491void
2493 const auto finder = myConnections.find(connection->getGUIGlObject());
2494 if (finder == myConnections.end()) {
2495 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2496 } else {
2497 myConnections.erase(finder);
2498 myNumberOfNetworkElements--;
2499 // remove it from inspected elements and GNEElementTree
2500 myNet->getViewNet()->getInspectedElements().uninspectAC(connection);
2501 connection->unmarkForDrawingFront();
2502 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(connection);
2503 }
2504}
2505
2506
2507void
2509 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2510 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getMicrosimID() + "' already exist");
2511 } else {
2512 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2513 myNumberOfNetworkElements++;
2514 }
2515}
2516
2517
2518void
2520 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2521 if (finder == myInternalLanes.end()) {
2522 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2523 } else {
2524 myInternalLanes.erase(finder);
2525 myNumberOfNetworkElements--;
2526 }
2527}
2528
2529
2530void
2532 const auto tag = additional->getTagProperty()->getTag();
2533 if (myAdditionals.at(tag).count(additional) > 0) {
2534 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2535 } else {
2536 // insert in both containers
2537 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2538 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2539 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2540 }
2541 myNumberOfNetworkElements++;
2542 // add element in grid
2543 if (additional->getTagProperty()->isPlacedInRTree()) {
2544 myNet->addGLObjectIntoGrid(additional);
2545 }
2546 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2547 if (myNet->isUpdateGeometryEnabled()) {
2548 additional->updateGeometry();
2549 }
2550 // additionals has to be saved
2551 myNet->getSavingStatus()->requireSaveAdditionals();
2552 }
2553}
2554
2555
2556void
2558 const auto tag = additional->getTagProperty()->getTag();
2559 // find demanElement in additionalTag
2560 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2561 // check if additional was previously inserted
2562 if (itFind == myAdditionals.at(tag).end()) {
2563 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2564 } else {
2565 // remove from both container
2566 myAdditionals.at(tag).erase(itFind);
2567 if (additional->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2568 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2569 }
2570 myNumberOfNetworkElements--;
2571 // remove it from inspected elements and GNEElementTree
2572 myNet->getViewNet()->getInspectedElements().uninspectAC(additional);
2573 additional->unmarkForDrawingFront();
2574 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2575 // remove element from grid
2576 if (additional->getTagProperty()->isPlacedInRTree()) {
2577 myNet->removeGLObjectFromGrid(additional);
2578 }
2579 // delete path element
2580 myNet->getNetworkPathManager()->removePath(additional);
2581 // additionals has to be saved
2582 myNet->getSavingStatus()->requireSaveAdditionals();
2583 }
2584}
2585
2586
2587
2588
2589void
2591 const auto sourceSinkTag = sourceSink->getTagProperty()->getTag();
2592 if (myTAZSourceSinks.at(sourceSinkTag).count(sourceSink) > 0) {
2593 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' already exist");
2594 } else {
2595 myTAZSourceSinks.at(sourceSinkTag)[sourceSink] = sourceSink;
2596 myNumberOfNetworkElements++;
2597 // additionals has to be saved
2598 myNet->getSavingStatus()->requireSaveAdditionals();
2599 }
2600}
2601
2602
2603void
2605 const auto tag = sourceSink->getTagProperty()->getTag();
2606 // find demanElement in additionalTag
2607 auto itFind = myTAZSourceSinks.at(tag).find(sourceSink);
2608 // check if sourceSink was previously inserted
2609 if (itFind == myTAZSourceSinks.at(tag).end()) {
2610 throw ProcessError(sourceSink->getTagStr() + " with ID='" + sourceSink->getID() + "' wasn't previously inserted");
2611 } else {
2612 // remove from both container
2613 myTAZSourceSinks.at(tag).erase(itFind);
2614 myNumberOfNetworkElements--;
2615 // remove it from inspected elements and GNEElementTree
2616 myNet->getViewNet()->getInspectedElements().uninspectAC(sourceSink);
2617 sourceSink->unmarkForDrawingFront();
2618 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(sourceSink);
2619 // additionals has to be saved
2620 myNet->getSavingStatus()->requireSaveAdditionals();
2621 }
2622}
2623
2624
2625void
2627 const auto tag = demandElement->getTagProperty()->getTag();
2628 if (myDemandElements.at(tag).count(demandElement) > 0) {
2629 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2630 } else {
2631 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2632 myNumberOfDemandElements++;
2633 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2634 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2635 }
2636 // add element in grid
2637 myNet->addGLObjectIntoGrid(demandElement);
2638 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2639 if (myNet->isUpdateGeometryEnabled()) {
2640 demandElement->updateGeometry();
2641 }
2642 // compute path element
2643 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2644 demandElement->computePathElement();
2645 }
2646 // update demand elements frames
2647 updateDemandElementFrames(demandElement->getTagProperty());
2648 // demandElements has to be saved
2649 myNet->getSavingStatus()->requireSaveDemandElements();
2650 }
2651}
2652
2653
2654void
2656 const auto tag = demandElement->getTagProperty()->getTag();
2657 auto viewParent = myNet->getViewNet()->getViewParent();
2658 // find demanElement in demandElementTag
2659 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2660 // check if demandElement was previously inserted
2661 if (itFind == myDemandElements.at(tag).end()) {
2662 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2663 } else {
2664 // erase it from container
2665 myDemandElements.at(tag).erase(itFind);
2666 if (demandElement->getTagProperty()->hasAttribute(SUMO_ATTR_ID)) {
2667 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2668 }
2669 myNumberOfDemandElements--;
2670 // remove element from grid
2671 myNet->removeGLObjectFromGrid(demandElement);
2672 // remove it from inspected elements and GNEElementTree
2673 myNet->getViewNet()->getInspectedElements().uninspectAC(demandElement);
2674 demandElement->unmarkForDrawingFront();
2675 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2676 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2677 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2678 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2679 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2680 }
2681 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2682 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2683 }
2684 // if is the last inserted route, remove it from GNEViewNet
2685 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2686 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2687 }
2688 // delete path element
2689 myNet->getDemandPathManager()->removePath(demandElement);
2690 // check if update demand elements frames
2691 if (updateFrames) {
2692 updateDemandElementFrames(demandElement->getTagProperty());
2693 }
2694 // demandElements has to be saved
2695 myNet->getSavingStatus()->requireSaveDemandElements();
2696 }
2697}
2698
2699
2700void
2702 if (myDataSets.count(dataSet->getID()) > 0) {
2703 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2704 } else {
2705 myDataSets[dataSet->getID()] = dataSet;
2706 myNumberOfDataElements++;
2707 // dataSets has to be saved
2708 myNet->getSavingStatus()->requireSaveDataElements();
2709 // mark interval toolbar for update
2710 myNet->getViewNet()->getIntervalBar().markForUpdate();
2711 }
2712}
2713
2714
2715void
2717 const auto finder = myDataSets.find(dataSet->getID());
2718 if (finder == myDataSets.end()) {
2719 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2720 } else {
2721 myDataSets.erase(finder);
2722 myNumberOfDataElements--;
2723 // remove it from inspected elements and GNEElementTree
2724 myNet->getViewNet()->getInspectedElements().uninspectAC(dataSet);
2725 dataSet->unmarkForDrawingFront();
2726 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2727 // dataSets has to be saved
2728 myNet->getSavingStatus()->requireSaveDataElements();
2729 // mark interval toolbar for update
2730 myNet->getViewNet()->getIntervalBar().markForUpdate();
2731 }
2732}
2733
2734
2735void
2737 if (myMeanDatas.at(meanData->getTagProperty()->getTag()).count(meanData->getID()) > 0) {
2738 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2739 } else {
2740 myMeanDatas.at(meanData->getTagProperty()->getTag()).insert(std::make_pair(meanData->getID(), meanData));
2741 myNumberOfMeanDataElements++;
2742 // meanDatas has to be saved
2743 myNet->getSavingStatus()->requireSaveMeanDatas();
2744 }
2745}
2746
2747
2748void
2750 // find demanElement in meanDataTag
2751 auto itFind = myMeanDatas.at(meanData->getTagProperty()->getTag()).find(meanData->getID());
2752 // check if meanData was previously inserted
2753 if (itFind == myMeanDatas.at(meanData->getTagProperty()->getTag()).end()) {
2754 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2755 } else {
2756 // remove from container
2757 myMeanDatas.at(meanData->getTagProperty()->getTag()).erase(itFind);
2758 myNumberOfMeanDataElements--;
2759 // remove it from inspected elements and GNEElementTree
2760 myNet->getViewNet()->getInspectedElements().uninspectAC(meanData);
2761 meanData->unmarkForDrawingFront();
2762 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2763 // remove element from grid
2764 if (meanData->getTagProperty()->isPlacedInRTree()) {
2765 myNet->removeGLObjectFromGrid(meanData);
2766 }
2767 // meanDatas has to be saved
2768 myNet->getSavingStatus()->requireSaveMeanDatas();
2769 }
2770}
2771
2772
2773void
2775 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2776 // continue depending of demand mode
2777 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2779 if (tagProperty->isType()) {
2780 myNet->getViewNet()->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2781 }
2782 break;
2784 if (tagProperty->isType()) {
2785 myNet->getViewNet()->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2786 }
2787 break;
2789 if (tagProperty->isType()) {
2790 myNet->getViewNet()->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2791 }
2792 break;
2794 if (tagProperty->isRoute()) {
2795 myNet->getViewNet()->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2796 }
2797 break;
2799 if (tagProperty->isType()) {
2800 myNet->getViewNet()->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2801 }
2802 break;
2804 if (tagProperty->isPerson()) {
2805 myNet->getViewNet()->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2806 }
2807 break;
2809 if (tagProperty->isType()) {
2810 myNet->getViewNet()->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2811 }
2812 break;
2814 if (tagProperty->isContainer()) {
2815 myNet->getViewNet()->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2816 }
2817 break;
2819 myNet->getViewNet()->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2820 break;
2821 default:
2822 // nothing to update
2823 break;
2824 }
2825 }
2826}
2827
2828
2829void
2831 // fill network elements
2832 if (tag->getTag() == SUMO_TAG_JUNCTION) {
2833 for (const auto& junction : myJunctions) {
2834 ACs.push_back(junction.second);
2835 }
2836 }
2837 if (tag->getTag() == SUMO_TAG_EDGE) {
2838 for (const auto& edge : myEdges) {
2839 ACs.push_back(edge.second);
2840 }
2841 }
2842 if (tag->getTag() == SUMO_TAG_LANE) {
2843 for (const auto& lane : myLanes) {
2844 ACs.push_back(lane.second);
2845 }
2846 }
2847 if (tag->getTag() == SUMO_TAG_CONNECTION) {
2848 for (const auto& connection : myConnections) {
2849 ACs.push_back(connection.second);
2850 }
2851 }
2852 if (tag->getTag() == SUMO_TAG_CROSSING) {
2853 for (const auto& crossing : myCrossings) {
2854 ACs.push_back(crossing.second);
2855 }
2856 }
2857 if (tag->getTag() == SUMO_TAG_WALKINGAREA) {
2858 for (const auto& walkingArea : myWalkingAreas) {
2859 ACs.push_back(walkingArea.second);
2860 }
2861 }
2862 // fill additional elements
2863 if (tag->isAdditionalElement()) {
2864 for (const auto& additionalTag : myAdditionals) {
2865 if (additionalTag.first == tag->getTag()) {
2866 for (const auto& additional : additionalTag.second) {
2867 ACs.push_back(additional.second);
2868 }
2869 }
2870 }
2871 }
2872 // fill demand elements
2873 if (tag->isDemandElement()) {
2874 for (const auto& demandElementTag : myDemandElements) {
2875 if (demandElementTag.first == tag->getTag()) {
2876 for (const auto& demandElemet : demandElementTag.second) {
2877 ACs.push_back(demandElemet.second);
2878 }
2879 }
2880 }
2881 }
2882 // fill data elements
2883 if (tag->isDataElement()) {
2884 if (tag->getTag() == SUMO_TAG_DATASET) {
2885 for (const auto& dataSet : myDataSets) {
2886 ACs.push_back(dataSet.second);
2887 }
2888 }
2889 if (tag->getTag() == SUMO_TAG_DATAINTERVAL) {
2890 for (const auto& dataInterval : myDataIntervals) {
2891 ACs.push_back(dataInterval.second);
2892 }
2893 }
2894 for (const auto& genericDataTag : myGenericDatas) {
2895 if (genericDataTag.first == tag->getTag()) {
2896 for (const auto& genericData : genericDataTag.second) {
2897 ACs.push_back(genericData.second);
2898 }
2899 }
2900 }
2901 for (const auto& meanDataTag : myMeanDatas) {
2902 if (meanDataTag.first == tag->getTag()) {
2903 for (const auto& meanData : meanDataTag.second) {
2904 ACs.push_back(meanData.second);
2905 }
2906 }
2907 }
2908 }
2909 // iterate over children
2910 for (const auto child : tag->getHierarchicalChildren()) {
2911 retrieveAttributeCarriersRecursively(child, ACs);
2912 }
2913}
2914
2915// ---------------------------------------------------------------------------
2916// GNENetHelper::GNETagSelector - methods
2917// ---------------------------------------------------------------------------
2918
2920 myNet(net) {
2921}
2922
2923
2924void
2926 // network
2927 myTemplates[SUMO_TAG_CROSSING] = new GNECrossing(myNet);
2928 // additionals
2929 myTemplates[SUMO_TAG_BUS_STOP] = GNEBusStop::buildBusStop(myNet);
2930 myTemplates[SUMO_TAG_TRAIN_STOP] = GNEBusStop::buildTrainStop(myNet);
2931 myTemplates[SUMO_TAG_ACCESS] = new GNEAccess(myNet);
2932 myTemplates[SUMO_TAG_CONTAINER_STOP] = new GNEContainerStop(myNet);
2933 myTemplates[SUMO_TAG_CHARGING_STATION] = new GNEChargingStation(myNet);
2934 myTemplates[SUMO_TAG_PARKING_AREA] = new GNEParkingArea(myNet);
2935 myTemplates[SUMO_TAG_PARKING_SPACE] = new GNEParkingSpace(myNet);
2936 myTemplates[SUMO_TAG_INDUCTION_LOOP] = new GNEInductionLoopDetector(myNet);
2941 myTemplates[SUMO_TAG_DET_EXIT] = new GNEEntryExitDetector(SUMO_TAG_DET_EXIT, myNet);
2943 myTemplates[SUMO_TAG_VSS] = new GNEVariableSpeedSign(myNet);
2944 myTemplates[SUMO_TAG_STEP] = new GNEVariableSpeedSignStep(myNet);
2945 myTemplates[SUMO_TAG_CALIBRATOR] = new GNECalibrator(SUMO_TAG_CALIBRATOR, myNet);
2947 myTemplates[GNE_TAG_CALIBRATOR_FLOW] = new GNECalibratorFlow(myNet);
2948 myTemplates[SUMO_TAG_REROUTER] = new GNERerouter(myNet);
2949 myTemplates[SUMO_TAG_INTERVAL] = new GNERerouterInterval(myNet);
2950 myTemplates[SUMO_TAG_CLOSING_REROUTE] = new GNEClosingReroute(myNet);
2951 myTemplates[SUMO_TAG_CLOSING_LANE_REROUTE] = new GNEClosingLaneReroute(myNet);
2952 myTemplates[SUMO_TAG_DEST_PROB_REROUTE] = new GNEDestProbReroute(myNet);
2953 myTemplates[SUMO_TAG_PARKING_AREA_REROUTE] = new GNEParkingAreaReroute(myNet);
2954 myTemplates[SUMO_TAG_ROUTE_PROB_REROUTE] = new GNERouteProbReroute(myNet);
2955 myTemplates[SUMO_TAG_ROUTEPROBE] = new GNERouteProbe(myNet);
2956 myTemplates[SUMO_TAG_VAPORIZER] = new GNEVaporizer(myNet);
2957 // symbols
2958 myTemplates[GNE_TAG_REROUTER_SYMBOL] = new GNERerouterSymbol(myNet);
2959 myTemplates[GNE_TAG_VSS_SYMBOL] = new GNEVariableSpeedSignSymbol(myNet);
2960 // shapes
2961 myTemplates[SUMO_TAG_POLY] = new GNEPoly(SUMO_TAG_POLY, myNet);
2962 myTemplates[SUMO_TAG_POI] = new GNEPOI(SUMO_TAG_POI, myNet);
2963 myTemplates[GNE_TAG_POILANE] = new GNEPOI(GNE_TAG_POILANE, myNet);
2964 myTemplates[GNE_TAG_POIGEO] = new GNEPOI(GNE_TAG_POIGEO, myNet);
2965 // TAZs
2966 myTemplates[SUMO_TAG_TAZ] = new GNETAZ(myNet);
2967 myTemplates[SUMO_TAG_TAZSOURCE] = new GNETAZSourceSink(SUMO_TAG_TAZSOURCE, myNet);
2968 myTemplates[SUMO_TAG_TAZSINK] = new GNETAZSourceSink(SUMO_TAG_TAZSINK, myNet);
2969 // wires
2970 myTemplates[SUMO_TAG_TRACTION_SUBSTATION] = new GNETractionSubstation(myNet);
2971 myTemplates[SUMO_TAG_OVERHEAD_WIRE_SECTION] = new GNEOverheadWire(myNet);
2972 //myTemplates[SUMO_TAG_OVERHEAD_WIRE_CLAMP] = nullptr; // TMP
2973 // JuPedSim elements
2975 myTemplates[GNE_TAG_JPS_OBSTACLE] = new GNEPoly(GNE_TAG_JPS_OBSTACLE, myNet);
2976 // vTypes
2977 const auto vTypes = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::VTYPE);
2978 for (const auto vType : vTypes) {
2979 myTemplates[vType->getTag()] = new GNEVType(vType->getTag(), myNet);
2980 }
2981 // vType distributions
2982 myTemplates[SUMO_TAG_VTYPE_DISTRIBUTION] = new GNEVTypeDistribution(myNet);
2983 myTemplates[GNE_TAG_VTYPEREF] = new GNEVTypeRef(myNet);
2984 // routes (basic and embedded)
2985 const auto routes = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::ROUTE);
2986 for (const auto route : routes) {
2987 myTemplates[route->getTag()] = new GNERoute(route->getTag(), myNet);
2988 }
2989 // route distribution
2990 myTemplates[SUMO_TAG_ROUTE_DISTRIBUTION] = new GNERouteDistribution(myNet);
2991 myTemplates[GNE_TAG_ROUTEREF] = new GNERouteRef(myNet);
2992 // vehicles
2993 const auto vehicles = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::VEHICLE);
2994 for (const auto vehicle : vehicles) {
2995 myTemplates[vehicle->getTag()] = new GNEVehicle(vehicle->getTag(), myNet);
2996 }
2997 // persons
2998 const auto persons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSON);
2999 for (const auto person : persons) {
3000 myTemplates[person->getTag()] = new GNEPerson(person->getTag(), myNet);
3001 }
3002 // container
3003 const auto containers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::CONTAINER);
3004 for (const auto container : containers) {
3005 myTemplates[container->getTag()] = new GNEContainer(container->getTag(), myNet);
3006 }
3007 // stops and waypoints
3008 const auto stopAndWaypoints = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_VEHICLE);
3009 for (const auto stopAndWaypoint : stopAndWaypoints) {
3010 myTemplates[stopAndWaypoint->getTag()] = new GNEStop(stopAndWaypoint->getTag(), myNet);
3011 }
3012 // personTrip
3013 const auto personTrips = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::PERSONTRIP);
3014 for (const auto personTrip : personTrips) {
3015 myTemplates[personTrip->getTag()] = new GNEPersonTrip(personTrip->getTag(), myNet);
3016 }
3017 // walk
3018 const auto walks = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::WALK);
3019 for (const auto walk : walks) {
3020 myTemplates[walk->getTag()] = new GNEWalk(walk->getTag(), myNet);
3021 }
3022 // ride
3023 const auto rides = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::RIDE);
3024 for (const auto ride : rides) {
3025 myTemplates[ride->getTag()] = new GNERide(ride->getTag(), myNet);
3026 }
3027 // stop person
3028 const auto stopPersons = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_PERSON);
3029 for (const auto stopPerson : stopPersons) {
3030 myTemplates[stopPerson->getTag()] = new GNEStopPlan(stopPerson->getTag(), myNet);
3031 }
3032 // transport
3033 const auto transports = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSPORT);
3034 for (const auto transport : transports) {
3035 myTemplates[transport->getTag()] = new GNETransport(transport->getTag(), myNet);
3036 }
3037 // tranship
3038 const auto tranships = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::TRANSHIP);
3039 for (const auto tranship : tranships) {
3040 myTemplates[tranship->getTag()] = new GNETranship(tranship->getTag(), myNet);
3041 }
3042 // stop container
3043 const auto stopContainers = myNet->getTagPropertiesDatabase()->getTagPropertiesByType(GNETagProperties::Type::STOP_CONTAINER);
3044 for (const auto stopContainer : stopContainers) {
3045 myTemplates[stopContainer->getTag()] = new GNEStopPlan(stopContainer->getTag(), myNet);
3046 }
3047 // reset all to their default values
3048 for (const auto& AC : myTemplates) {
3049 AC.second->resetDefaultValues(false);
3050 }
3051}
3052
3053
3055 for (auto& AC : myTemplates) {
3056 delete AC.second;
3057 }
3058}
3059
3060
3061std::map<SumoXMLTag, GNEAttributeCarrier*>
3063 return myTemplates;
3064}
3065
3066
3069 if (myTemplates.count(tag) > 0) {
3070 return myTemplates.at(tag);
3071 } else {
3072 return nullptr;
3073 }
3074}
3075
3076
3078GNENetHelper::ACTemplate::getTemplateAC(const std::string& selectorText) const {
3079 for (const auto& templateAC : myTemplates) {
3080 if (templateAC.second->getTagProperty()->getSelectorText() == selectorText) {
3081 return templateAC.second;
3082 }
3083 }
3084 return nullptr;
3085}
3086
3087// ---------------------------------------------------------------------------
3088// GNENetHelper::SavingFilesHandler - methods
3089// ---------------------------------------------------------------------------
3090
3094
3095
3096void
3098 auto& neteditOptions = OptionsCont::getOptions();
3099 // get files
3100 const auto additionalFiles = parsingSavingFiles(myAdditionalElementsSavingFiles);
3101 const auto demandElementFiles = parsingSavingFiles(myDemandElementsSavingFiles);
3102 const auto dataElementFiles = parsingSavingFiles(myDataElementsSavingFiles);
3103 const auto meanDataElementFiles = parsingSavingFiles(myMeanDataElementsSavingFiles);
3104 // additionals
3105 neteditOptions.resetWritable();
3106 if (additionalFiles.size() > 0) {
3107 neteditOptions.set("additional-files", additionalFiles);
3108 } else {
3109 neteditOptions.resetDefault("additional-files");
3110 }
3111 // route files
3112 neteditOptions.resetWritable();
3113 if (demandElementFiles.size() > 0) {
3114 neteditOptions.set("route-files", demandElementFiles);
3115 } else {
3116 neteditOptions.resetDefault("route-files");
3117 }
3118 // data files
3119 neteditOptions.resetWritable();
3120 if (dataElementFiles.size() > 0) {
3121 neteditOptions.set("data-files", dataElementFiles);
3122 } else {
3123 neteditOptions.resetDefault("data-files");
3124 }
3125 // meanData files
3126 neteditOptions.resetWritable();
3127 if (meanDataElementFiles.size() > 0) {
3128 neteditOptions.set("meandata-files", meanDataElementFiles);
3129 } else {
3130 neteditOptions.resetDefault("meandata-files");
3131 }
3132}
3133
3134
3135void
3137 if ((additionalElement->getFilename().size() > 0) && !existAdditionalFilename(additionalElement->getFilename())) {
3138 if (myAdditionalElementsSavingFiles.empty()) {
3139 updateAdditionalEmptyFilenames(additionalElement->getFilename());
3140 } else {
3141 myAdditionalElementsSavingFiles.push_back(additionalElement->getFilename());
3142 }
3143 }
3144}
3145
3146
3147void
3149 for (const auto& additionalTag : myNet->getAttributeCarriers()->getAdditionals()) {
3150 for (const auto& additional : additionalTag.second) {
3151 additional.second->changeDefaultFilename(file);
3152 }
3153 }
3154 // update all templates
3155 for (auto& templateAC : myNet->getACTemplates()->getACTemplates()) {
3156 if (templateAC.second->getTagProperty()->isAdditionalElement() && templateAC.second->getFilename().empty()) {
3157 templateAC.second->changeDefaultFilename(file);
3158 }
3159 }
3160 // add it to current files
3161 if (!existAdditionalFilename(file)) {
3162 myAdditionalElementsSavingFiles.push_back(file);
3163 }
3164}
3165
3166
3167const std::vector<std::string>&
3169 return myAdditionalElementsSavingFiles;
3170}
3171
3172
3175 ACsbyFilename additionalsbyFilenames;
3176 for (const auto& additionalTag : myNet->getAttributeCarriers()->getAdditionals()) {
3177 for (const auto& additional : additionalTag.second) {
3178 additionalsbyFilenames[additional.second->getFilename()].insert(additional.second);
3179 }
3180 }
3181 // special case for routes (due calibrators)
3182 for (const auto& route : myNet->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE)) {
3183 if (std::find(myAdditionalElementsSavingFiles.begin(), myAdditionalElementsSavingFiles.end(), route.second->getFilename()) != myAdditionalElementsSavingFiles.end()) {
3184 additionalsbyFilenames[route.second->getFilename()].insert(route.second);
3185 }
3186 }
3187 // clear empty saving files
3188 auto it = myAdditionalElementsSavingFiles.begin();
3189 while (it != myAdditionalElementsSavingFiles.end()) {
3190 if (it->empty() || (additionalsbyFilenames.find(*it) == additionalsbyFilenames.end())) {
3191 it = myAdditionalElementsSavingFiles.erase(it);
3192 } else {
3193 it++;
3194 }
3195 }
3196 return additionalsbyFilenames;
3197}
3198
3199
3200bool
3202 const auto it = std::find(myAdditionalElementsSavingFiles.begin(), myAdditionalElementsSavingFiles.end(), file);
3203 return it != myAdditionalElementsSavingFiles.end();
3204}
3205
3206
3207void
3209 if ((demandElement->getFilename().size() > 0) && !existDemandFilename(demandElement->getFilename())) {
3210 if (myDemandElementsSavingFiles.empty()) {
3211 updateDemandEmptyFilenames(demandElement->getFilename());
3212 } else {
3213 myDemandElementsSavingFiles.push_back(demandElement->getFilename());
3214 }
3215 }
3216}
3217
3218
3219void
3221 for (const auto& demandTag : myNet->getAttributeCarriers()->getDemandElements()) {
3222 for (const auto& demand : demandTag.second) {
3223 demand.second->changeDefaultFilename(file);
3224 }
3225 }
3226 // update all templates
3227 for (auto& templateAC : myNet->getACTemplates()->getACTemplates()) {
3228 if (templateAC.second->getTagProperty()->isDemandElement() && templateAC.second->getFilename().empty()) {
3229 templateAC.second->changeDefaultFilename(file);
3230 }
3231 }
3232 // add it to current files
3233 if (!existDemandFilename(file)) {
3234 myDemandElementsSavingFiles.push_back(file);
3235 }
3236}
3237
3238
3239const std::vector<std::string>&
3241 return myDemandElementsSavingFiles;
3242}
3243
3244
3247 ACsbyFilename demandsbyFilenames;
3248 for (const auto& demandTag : myNet->getAttributeCarriers()->getDemandElements()) {
3249 for (const auto& demand : demandTag.second) {
3250 if (std::find(myAdditionalElementsSavingFiles.begin(), myAdditionalElementsSavingFiles.end(), demand.second->getFilename()) == myAdditionalElementsSavingFiles.end()) {
3251 demandsbyFilenames[demand.second->getFilename()].insert(demand.second);
3252 }
3253 }
3254 }
3255 // clear empty saving files
3256 auto it = myDemandElementsSavingFiles.begin();
3257 while (it != myDemandElementsSavingFiles.end()) {
3258 if (it->empty() || (demandsbyFilenames.find(*it) == demandsbyFilenames.end())) {
3259 it = myDemandElementsSavingFiles.erase(it);
3260 } else {
3261 it++;
3262 }
3263 }
3264 return demandsbyFilenames;
3265}
3266
3267
3268bool
3270 const auto it = std::find(myDemandElementsSavingFiles.begin(), myDemandElementsSavingFiles.end(), file);
3271 return it != myDemandElementsSavingFiles.end();
3272}
3273
3274
3275void
3277 if ((dataElement->getFilename().size() > 0) && !existDataFilename(dataElement->getFilename())) {
3278 if (myDataElementsSavingFiles.empty()) {
3279 updateDataEmptyFilenames(dataElement->getFilename());
3280 } else {
3281 myDataElementsSavingFiles.push_back(dataElement->getFilename());
3282 }
3283 }
3284}
3285
3286
3287void
3289 if (file.size() > 0) {
3290 for (const auto& dataSet : myNet->getAttributeCarriers()->getDataSets()) {
3291 dataSet.second->changeDefaultFilename(file);
3292 }
3293 // add it to current files
3294 if (!existDataFilename(file)) {
3295 myDataElementsSavingFiles.push_back(file);
3296 }
3297 }
3298}
3299
3300
3301const std::vector<std::string>&
3303 return myDataElementsSavingFiles;
3304}
3305
3306
3309 ACsbyFilename datasbyFilenames;
3310 for (const auto& dataSet : myNet->getAttributeCarriers()->getDataSets()) {
3311 datasbyFilenames[dataSet.second->getFilename()].insert(dataSet.second);
3312 }
3313 // clear empty saving files
3314 auto it = myDataElementsSavingFiles.begin();
3315 while (it != myDataElementsSavingFiles.end()) {
3316 if (it->empty() || (datasbyFilenames.find(*it) == datasbyFilenames.end())) {
3317 it = myDataElementsSavingFiles.erase(it);
3318 } else {
3319 it++;
3320 }
3321 }
3322 return datasbyFilenames;
3323}
3324
3325
3326bool
3328 const auto it = std::find(myDataElementsSavingFiles.begin(), myDataElementsSavingFiles.end(), file);
3329 return it != myDataElementsSavingFiles.end();
3330}
3331
3332
3333void
3335 if ((meanDataElement->getFilename().size() > 0) && !existMeanDataFilename(meanDataElement->getFilename())) {
3336 if (myMeanDataElementsSavingFiles.empty()) {
3337 updateMeanDataEmptyFilenames(meanDataElement->getFilename());
3338 } else {
3339 myMeanDataElementsSavingFiles.push_back(meanDataElement->getFilename());
3340 }
3341 }
3342}
3343
3344
3345void
3347 for (const auto& meanDataTag : myNet->getAttributeCarriers()->getMeanDatas()) {
3348 for (const auto& meanData : meanDataTag.second) {
3349 meanData.second->changeDefaultFilename(file);
3350 }
3351 }
3352 // update all templates
3353 for (auto& templateAC : myNet->getACTemplates()->getACTemplates()) {
3354 if (templateAC.second->getTagProperty()->isMeanData() && templateAC.second->getFilename().empty()) {
3355 templateAC.second->changeDefaultFilename(file);
3356 }
3357 }
3358 // add it to current files
3359 if (!existMeanDataFilename(file)) {
3360 myMeanDataElementsSavingFiles.push_back(file);
3361 }
3362}
3363
3364
3365const std::vector<std::string>&
3367 return myMeanDataElementsSavingFiles;
3368}
3369
3370
3373 ACsbyFilename meanDatasbyFilenames;
3374 for (const auto& meanDataTag : myNet->getAttributeCarriers()->getMeanDatas()) {
3375 for (const auto& meanData : meanDataTag.second) {
3376 meanDatasbyFilenames[meanData.second->getFilename()].insert(meanData.second);
3377 }
3378 }
3379 // clear empty saving files
3380 auto it = myMeanDataElementsSavingFiles.begin();
3381 while (it != myMeanDataElementsSavingFiles.end()) {
3382 if (it->empty() || (meanDatasbyFilenames.find(*it) == meanDatasbyFilenames.end())) {
3383 it = myMeanDataElementsSavingFiles.erase(it);
3384 } else {
3385 it++;
3386 }
3387 }
3388 return meanDatasbyFilenames;
3389}
3390
3391
3392bool
3394 const auto it = std::find(myMeanDataElementsSavingFiles.begin(), myMeanDataElementsSavingFiles.end(), file);
3395 return it != myMeanDataElementsSavingFiles.end();
3396}
3397
3398
3399std::string
3400GNENetHelper::SavingFilesHandler::parsingSavingFiles(const std::vector<std::string>& savingFiles) const {
3401 std::string savingFileNames;
3402 // group all saving files in a single string separated with comma
3403 for (const auto& savingFile : savingFiles) {
3404 savingFileNames.append(savingFile + ",");
3405 }
3406 // remove last ','
3407 if (savingFileNames.size() > 0) {
3408 savingFileNames.pop_back();
3409 }
3410 return savingFileNames;
3411}
3412
3413// ---------------------------------------------------------------------------
3414// GNENetHelper::SavingStatus - methods
3415// ---------------------------------------------------------------------------
3416
3418 myNet(net) {
3419}
3420
3421
3422void
3424 mySumoConfigSaved = false;
3425}
3426
3427
3428void
3430 mySumoConfigSaved = true;
3431}
3432
3433
3434bool
3436 return mySumoConfigSaved;
3437}
3438
3439
3440
3441void
3443 myNeteditConfigSaved = false;
3444}
3445
3446
3447void
3449 myNeteditConfigSaved = true;
3450}
3451
3452
3453bool
3455 return myNeteditConfigSaved;
3456}
3457
3458
3459void
3461 myNetworkSaved = false;
3462 // implies requiere save netedit config and sumo config
3463 myNeteditConfigSaved = false;
3464 mySumoConfigSaved = false;
3465}
3466
3467
3468void
3470 myNetworkSaved = true;
3471}
3472
3473
3474bool
3476 return myNetworkSaved;
3477}
3478
3479
3480void
3482 myTLSSaved = false;
3483}
3484
3485
3486void
3488 myTLSSaved = true;
3489}
3490
3491
3492bool
3494 return myTLSSaved;
3495}
3496
3497
3498void
3500 myEdgeTypeSaved = false;
3501}
3502
3503
3504void
3506 myEdgeTypeSaved = true;
3507}
3508
3509
3510bool
3512 return myEdgeTypeSaved;
3513}
3514
3515
3516void
3518 myAdditionalSaved = false;
3519 // implies requiere save netedit config and sumo config
3520 myNeteditConfigSaved = false;
3521 mySumoConfigSaved = false;
3522}
3523
3524
3525void
3527 myAdditionalSaved = true;
3528}
3529
3530
3531bool
3533 return myAdditionalSaved;
3534}
3535
3536
3537void
3539 myDemandElementSaved = false;
3540 // implies requiere save netedit config and sumo config
3541 myNeteditConfigSaved = false;
3542 mySumoConfigSaved = false;
3543}
3544
3545
3546void
3548 myDemandElementSaved = true;
3549}
3550
3551
3552bool
3554 return myDemandElementSaved;
3555}
3556
3557
3558void
3560 myDataElementSaved = false;
3561 // implies requiere save netedit config and sumo config
3562 myNeteditConfigSaved = false;
3563 mySumoConfigSaved = false;
3564}
3565
3566
3567void
3569 myDataElementSaved = true;
3570}
3571
3572
3573bool
3575 return myDataElementSaved;
3576}
3577
3578
3579void
3581 myMeanDataElementSaved = false;
3582 // implies requiere save netedit config and sumo config
3583 myNeteditConfigSaved = false;
3584 mySumoConfigSaved = false;
3585}
3586
3587
3588void
3590 myMeanDataElementSaved = true;
3591}
3592
3593
3594bool
3596 return myMeanDataElementSaved;
3597}
3598
3599
3602 // Check if there are non saved network elements
3603 if (myNetworkSaved) {
3604 return AskSaving::CONTINUE;
3605 } else {
3606 // open question box
3607 const std::string header = TL("Confirm close Network");
3608 const std::string contentsA = TL("You have unsaved changes in the network.");
3609 const std::string contentsB = TL("Do you wish to close and discard all changes?");
3610 const auto answer = GUISaveDialog::question(myNet->getApp(), header.c_str(), "%s", (contentsA + "\n" + contentsB).c_str());
3611 // continue depending of answer
3612 if (answer == GUISaveDialog::CLICKED_DISCARD) {
3613 return AskSaving::DISCARD;
3614 } else if (answer == GUISaveDialog::CLICKED_SAVE) {
3615 return AskSaving::SAVE;
3616 } else {
3617 return AskSaving::ABORT;
3618 }
3619 }
3620}
3621
3622
3625 // Check if there are non saved additional elements
3626 if (myAdditionalSaved) {
3627 return AskSaving::CONTINUE;
3628 } else {
3629 // open question box
3630 const std::string header = TL("Save additional elements before close");
3631 const std::string contentsA = TL("You have unsaved additional elements.");
3632 const std::string contentsB = TL("Do you wish to close and discard all changes?");
3633 const auto answer = GUISaveDialog::question(myNet->getApp(), header.c_str(), "%s", (contentsA + "\n" + contentsB).c_str());
3634 // continue depending of answer
3635 if (answer == GUISaveDialog::CLICKED_DISCARD) {
3636 return AskSaving::DISCARD;
3637 } else if (answer == GUISaveDialog::CLICKED_SAVE) {
3638 return AskSaving::SAVE;
3639 } else {
3640 return AskSaving::ABORT;
3641 }
3642 }
3643}
3644
3645
3648 // Check if there are non saved demand elements
3649 if (myDemandElementSaved) {
3650 return AskSaving::CONTINUE;
3651 } else {
3652 // open question box
3653 const std::string header = TL("Save demand elements before close");
3654 const std::string contentsA = TL("You have unsaved demand elements.");
3655 const std::string contentsB = TL("Do you wish to close and discard all changes?");
3656 const auto answer = GUISaveDialog::question(myNet->getApp(), header.c_str(), "%s", (contentsA + "\n" + contentsB).c_str());
3657 // continue depending of answer
3658 if (answer == GUISaveDialog::CLICKED_DISCARD) {
3659 return AskSaving::DISCARD;
3660 } else if (answer == GUISaveDialog::CLICKED_SAVE) {
3661 return AskSaving::SAVE;
3662 } else {
3663 return AskSaving::ABORT;
3664 }
3665 }
3666}
3667
3668
3671 // Check if there are non saved data elements
3672 if (myDataElementSaved) {
3673 return AskSaving::CONTINUE;
3674 } else {
3675 // open question box
3676 const std::string header = TL("Save data elements before close");
3677 const std::string contentsA = TL("You have unsaved data elements.");
3678 const std::string contentsB = TL("Do you wish to close and discard all changes?");
3679 const auto answer = GUISaveDialog::question(myNet->getApp(), header.c_str(), "%s", (contentsA + "\n" + contentsB).c_str());
3680 // continue depending of answer
3681 if (answer == GUISaveDialog::CLICKED_DISCARD) {
3682 return AskSaving::DISCARD;
3683 } else if (answer == GUISaveDialog::CLICKED_SAVE) {
3684 return AskSaving::SAVE;
3685 } else {
3686 return AskSaving::ABORT;
3687 }
3688 }
3689}
3690
3691
3694 // Check if there are non saved mean data elements
3695 if (myMeanDataElementSaved) {
3696 return AskSaving::CONTINUE;
3697 } else {
3698 // open question box
3699 const std::string header = TL("Save meanData elements before close");
3700 const std::string contentsA = TL("You have unsaved meanData elements.");
3701 const std::string contentsB = TL("Do you wish to close and discard all changes?");
3702 const auto answer = GUISaveDialog::question(myNet->getApp(), header.c_str(), "%s", (contentsA + "\n" + contentsB).c_str());
3703 // continue depending of answer
3704 if (answer == GUISaveDialog::CLICKED_DISCARD) {
3705 return AskSaving::DISCARD;
3706 } else if (answer == GUISaveDialog::CLICKED_SAVE) {
3707 return AskSaving::SAVE;
3708 } else {
3709 return AskSaving::ABORT;
3710 }
3711 }
3712}
3713
3714// ---------------------------------------------------------------------------
3715// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
3716// ---------------------------------------------------------------------------
3717
3719 GNEChange(Supermode::NETWORK, true, false),
3720 myTllcont(tllcont),
3721 myReplaced(replaced),
3722 myBy(by) {
3723}
3724
3725
3727
3728
3729void
3731 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3732 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
3733}
3734
3735
3736void
3738 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
3739 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
3740}
3741
3742
3743std::string
3745 return TL("Redo replace in TLS");
3746}
3747
3748
3749std::string
3751 return TL("Undo replace in TLS");
3752}
3753
3754
3755bool
3757 return myReplaced != myBy;
3758}
3759
3760/****************************************************************************/
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
GUISelectedStorage gSelected
A global holder of selected objects.
#define TL(string)
Definition MsgHandler.h:305
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_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_NOTHING
invalid tag, must be the last one
@ 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
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_MEANDATA_LANE
a lane based mean data detector
@ SUMO_TAG_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_POIGEO
Point of interest over view with GEO attributes.
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_WALKINGAREA
walking area for pedestrians
@ 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
@ 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_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_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
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
virtual Position getPositionInView() const =0
Returns position of additional in view.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
const std::string & getFilename() const
get filename in which save this AC
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
void unmarkForDrawingFront()
unmark for drawing front
virtual GUIGlObject * getGUIGlObject()=0
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
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition GNECrossing.h:44
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
virtual void computePathElement()=0
implement in children+
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNEEdge.cpp:708
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition GNEEdge.cpp:1566
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:829
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2347
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:74
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:79
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:702
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
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)
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
void setResponsible(bool newVal)
set responsibility for deleting internal structures
void updateGeometry()
update pre-computed geometry information (including crossings)
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
NBNode * getNBNode() const
Return net build node.
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:650
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
std::vector< GNEEdge * > retrieveEdges(GNEJunction *from, GNEJunction *to) const
get all edges by from and to GNEJunction
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * >, std::hash< int > > & getDemandElements() const
get demand elements
GNETAZSourceSink * retrieveTAZSourceSink(const GNEAttributeCarrier *sourceSink, bool hardFail=true) const
Returns the named sourceSink.
void insertWalkingArea(GNEWalkingArea *walkingArea)
insert walkingArea in container
GNEAttributeCarrier * retrieveAttributeCarrier(const GUIGlID id, bool hardFail=true) const
get a single attribute carrier based on a GLID
int getNumberOfSelectedAdditionals() const
get number of selected additionals (Including POIs, Polygons, TAZs and Wires)
const std::unordered_map< const GUIGlObject *, GNEConnection * > & getConnections() const
get connections
int getNumberOfSelectedJpsObstacles() const
get number of selected obstacles
int getNumberOfSelectedConnections() const
get number of selected connections
void deleteDataSet(GNEDataSet *dataSet)
delete data set of container
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * >, std::hash< int > > myGenericDatas
map with the tag and pointer to all generic datas
void addPrefixToJunctions(const std::string &prefix)
add prefix to all junctions
void insertLane(GNELane *lane)
insert lane in container
int getNumberOfSelectedEdgeRelDatas() const
get number of selected edge rel datas
int getNumberOfSelectedCrossings() const
get number of selected crossings
GNEEdgeType * registerEdgeType(GNEEdgeType *edgeType)
registers a edge in containers
std::vector< GNEAdditional * > getSelectedShapes() const
get selected shapes
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
void insertDataSet(GNEDataSet *dataSet)
Insert a data set in container.
int getNumberOfSelectedRides() const
get number of selected rides
void clearDemandElements()
clear demand elements
void clearTAZSourceSinks()
clear sourceSinks
const std::unordered_map< const GUIGlObject *, GNECrossing * > & getCrossings() const
get crossings
void insertGenericData(GNEGenericData *genericData)
insert generic data in container
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with containers
void deleteDemandElement(GNEDemandElement *demandElement, const bool updateFrames)
delete demand element of container
void insertDataInterval(const GNEAttributeCarrier *AC, GNEDataInterval *dataInterval)
insert data interval in container
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEGenericData * >, std::hash< int > > & getGenericDatas() const
get all generic datas
int getNumberOfSelectedPersonTrips() const
get number of selected person trips
std::string generateDemandElementID(SumoXMLTag tag) const
generate demand element id
int getNumberOfMeanDatas() const
get number of meanDatas
GNECrossing * retrieveCrossing(const GUIGlObject *glObject, bool hardFail=true) const
get Crossing by AC
void addPrefixToEdges(const std::string &prefix)
add prefix to all edges
void remapJunctionAndEdgeIds()
remap junction and edge IDs
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(SumoXMLTag tag=SUMO_TAG_NOTHING)
get the attribute carriers based on Type
AttributeCarriers()=delete
Invalidated default constructor.
void clearEdgeTypes()
clear edgeTypes
std::string generateEdgeID() const
generate edge ID
int getNumberOfSelectedTranships() const
get number of selected tranships
const std::unordered_map< SumoXMLTag, std::unordered_map< const GNEAttributeCarrier *, GNETAZSourceSink * >, std::hash< int > > & getTAZSourceSinks() const
get sourceSinks
int getNumberOfSelectedVehicles() const
get number of selected vehicles
int getNumberOfSelectedWalks() const
get number of selected walks
void deleteEdgeType(GNEEdgeType *edgeType)
delete edge type from container
int getNumberOfSelectedJpsWalkableAreas() const
get number of selected walkable areas
void deleteInternalLane(GNEInternalLane *internalLane)
delete internalLane from container
void deleteConnection(GNEConnection *connection)
delete connection from container
void clearAdditionals()
clear additionals
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
std::vector< GNEGenericData * > retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end)
retrieve generic datas within the given interval
void insertInternalLane(GNEInternalLane *internalLane)
insert internalLane in container
int getStopIndex()
get (and update) stop index
std::set< std::string > retrieveGenericDataParameters(const std::string &genericDataTag, const double begin, const double end) const
return a set of parameters for the given data Interval
std::vector< GNEWalkingArea * > getSelectedWalkingAreas() const
return all selected walkingAreas
GNENet * myNet
pointer to net
void deleteSingleJunction(GNEJunction *junction)
delete junction from container
GNEMeanData * retrieveMeanData(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named meanData.
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction in containers
const std::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * >, std::hash< int > > & getMeanDatas() const
get meanDatas
int getNumberOfSelectedWalkingAreas() const
get number of selected walkingAreas
GNEWalkingArea * retrieveWalkingArea(const GUIGlObject *glObject, bool hardFail=true) const
get WalkingArea by GlObject
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
const std::map< const std::string, GNEDataSet * > & getDataSets() const
get demand elements
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
void updateJunctionID(GNEJunction *junction, const std::string &newID)
update junction ID in container
void deleteGenericData(GNEGenericData *genericData)
delete generic data of container
void insertCrossing(GNECrossing *crossing)
insert crossing in container
int getNumberOfSelectedWires() const
get number of selected Wires
std::string generateMeanDataID(SumoXMLTag type) const
generate meanData id
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEMeanData * >, std::hash< int > > myMeanDatas
map with the tag and pointer to meanData elements of net
void insertMeanData(GNEMeanData *meanData)
Insert a meanData element in container.
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
int getNumberOfSelectedTAZs() const
get number of selected TAZs
void deleteWalkingArea(GNEWalkingArea *walkingArea)
delete walkingArea from container
int getNumberOfSelectedTransport() const
get number of selected transports
void updateMeanDataID(GNEMeanData *meanData, const std::string &newID)
update meanData ID in container
std::vector< GNELane * > getSelectedLanes() const
get selected lanes
void insertConnection(GNEConnection *connection)
insert connection in container
std::vector< GNEAdditional * > getSelectedAdditionals() const
get selected additionals
int getNumberOfSelectedJunctions() const
get number of selected junctions
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEAdditional * >, std::hash< int > > myAdditionalIDs
map with the tag and pointer to additional elements of net, sorted by IDs
int getNumberOfDataElements() const
get number of current data elements saved in AttributeCarriers
int getNumberOfGenericDatas() const
Return the number of generic datas.
void updateAdditionalID(GNEAdditional *additional, const std::string &newID)
update additional ID in container
int getNumberOfSelectedDemandElements() const
get number of selected demand elements
std::unordered_map< SumoXMLTag, std::unordered_map< const GNEAttributeCarrier *, GNETAZSourceSink * >, std::hash< int > > myTAZSourceSinks
map with the tag and pointer to TAZSourceSinks elements of net
int getNumberOfSelectedPersons() const
get number of selected persons
int getNumberOfSelectedPureAdditionals() const
get number of selected pure additionals (Except POIs, Polygons, TAZs and Wires)
GNEEdgeType * retrieveEdgeType(const std::string &id, bool hardFail=true) const
get edge type by id
void deleteMeanData(GNEMeanData *meanData)
delete meanData element of container
GNEAdditional * retrieveAdditionals(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named additional.
int getNumberOfSelectedRoutes() const
get number of selected routes
void addDefaultVTypes()
add default VTypes
int getNumberOfSelectedPOIs() const
get number of selected POIs
void deleteSingleEdge(GNEEdge *edge)
delete edge from container
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
void deleteAdditional(GNEAdditional *additional)
delete additional element of container
int getNumberOfDemandElements() const
get number of current demand elements saved in AttributeCarriers (default vTypes are NOT included)
int getNumberOfSelectedPolygons() const
get number of selected polygons
std::vector< GNEJunction * > getSelectedJunctions() const
return selected junctions
std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * >, std::hash< int > > myAdditionals
map with the tag and pointer to additional elements of net
int getNumberOfAdditionals() const
get number of additionals
std::unordered_map< SumoXMLTag, std::map< const std::string, GNEDemandElement * >, std::hash< int > > myDemandElementIDs
map with the tag and pointer to demand elements of net, sorted by IDs
void updateDemandElementID(GNEDemandElement *demandElement, const std::string &newID)
update demand element ID in container
bool isNetworkElementAroundTriangle(GNEAttributeCarrier *AC, const Triangle &triangle) const
check if shape of given AC (network element) is around the given triangle
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element in container.
void insertTAZSourceSink(GNETAZSourceSink *sourceSink)
Insert a sourceSink element in container.
void updateEdgeID(GNEEdge *edge, const std::string &newID)
update edge ID in container
GNEDataInterval * retrieveDataInterval(const GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
std::vector< GNECrossing * > getSelectedCrossings() const
return all selected crossings
int getNumberOfSelectedLanes() const
get number of selected lanes
GNEAdditional * retrieveRerouterInterval(const std::string &rerouterID, const SUMOTime begin, const SUMOTime end) const
Returns the rerouter interval defined by given begin and end.
int getNumberOfSelectedEdgeDatas() const
get number of selected edge datas
void updateEdgeTypeID(GNEEdgeType *edgeType, const std::string &newID)
update edgeType ID in container
GNEInternalLane * retrieveInternalLane(const GUIGlObject *glObject, bool hardFail=true) const
get InternalLane by GUIGlObject
void updateDemandElementFrames(const GNETagProperties *tagProperty)
update demand element frames (called after insert/delete demand element)
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
void retrieveAttributeCarriersRecursively(const GNETagProperties *tag, std::vector< GNEAttributeCarrier * > &ACs)
retrieve attribute carriers recursively
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
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
bool existMeanDataFilename(const std::string &file) const
check if the given meanData file was already registered
ACsbyFilename getMeanDatasByFilename()
get meanDatas sorted by filenames (and also clear unused filenames)
std::string parsingSavingFiles(const std::vector< std::string > &savingFiles) const
parsing saving files
const std::vector< std::string > & getAdditionalFilenames() const
get vector with additional elements saving files (starting with default)
void addDataFilename(const GNEAttributeCarrier *dataElement)
data elements
void updateMeanDataEmptyFilenames(const std::string &file)
update meanData elements with empty filenames with the given file
void addMeanDataFilename(const GNEAttributeCarrier *meanDataElement)
meanData elements
ACsbyFilename getDatasByFilename()
get datas sorted by filenames (and also clear unused filenames)
void updateAdditionalEmptyFilenames(const std::string &file)
update additional elements with empty filenames with the given file
const std::vector< std::string > & getDemandFilenames() const
get vector with demand elements saving files (starting with default)
bool existAdditionalFilename(const std::string &file) const
check if the given additional file was already registered
void updateDataEmptyFilenames(const std::string &file)
update data elements with empty filenames with the given file
bool existDataFilename(const std::string &file) const
check if the given data file was already registered
void updateNeteditConfig()
update netedit config
ACsbyFilename getAdditionalsByFilename()
get additionals sorted by filenames (and also clear unused filenames)
ACsbyFilename getDemandsByFilename()
get demands sorted by filenames (and also clear unused filenames)
void updateDemandEmptyFilenames(const std::string &file)
update demand elements with empty filenames with the given file
const std::vector< std::string > & getMeanDataFilenames() const
get vector with meanData elements saving files (starting with default)
const std::vector< std::string > & getDataFilenames() const
get vector with data elements saving files (starting with default)
std::map< std::string, std::unordered_set< const GNEAttributeCarrier * > > ACsbyFilename
typedef used for group ACs by filename
void addDemandFilename(const GNEAttributeCarrier *demandElement)
demand elements
SavingFilesHandler()=delete
Invalidated default constructor.
bool existDemandFilename(const std::string &file) const
check if the given demand file was already registered
void addAdditionalFilename(const GNEAttributeCarrier *additionalElement)
additional elements
void requireSaveTLS()
inform that TLS has to be saved
void dataElementsSaved()
mark demand elements as saved
bool isEdgeTypeSaved() const
check if edgeType are saved
void requireSaveNetwork()
inform that network has to be saved
void requireSaveEdgeType()
inform that edgeType has to be saved
bool isTLSSaved() const
check if TLS are saved
void demandElementsSaved()
mark demand elements as saved
AskSaving askSaveMeanDataElements() const
warns about unsaved changes in meanData elements and gives the user the option to abort
AskSaving askSaveAdditionalElements() const
warns about unsaved changes in additionals and gives the user the option to abort
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
AskSaving askSaveNetwork() const
warns about unsaved changes in network and gives the user the option to abort
AskSaving askSaveDemandElements() const
warns about unsaved changes in demand elements and gives the user the option to abort
AskSaving
enum used to keep the result of ask about saving elements
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
AskSaving askSaveDataElements() const
warns about unsaved changes in data elements and gives the user the option to abort
bool isDemandElementsSaved() const
check if demand elements are saved
void requireSaveAdditionals()
inform that additionals has to be saved
bool isDataElementsSaved() const
check if data elements are saved
bool isNetworkSaved() const
check if network is saved
bool isMeanDatasSaved() const
check if mean data elements are saved
void requireSaveDataElements()
inform that data elements has to be saved
bool isNeteditConfigSaved() const
check if netedit config is saved
void networkSaved()
mark network as saved
bool isAdditionalsSaved() const
check if additionals are saved
SavingStatus()=delete
invalidate default constructor
void requireSaveDemandElements()
inform that demand elements has to be saved
void edgeTypeSaved()
mark edgeType as saved
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database
Definition GNENet.cpp:141
void setNetworkElementID(const std::string &newID)
set network element id
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void decRef(const std::string &debugMsg="")
Decrease reference.
void incRef(const std::string &debugMsg="")
Increase reference.
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
bool isPlacedInRTree() const
return true if Tag correspond to an element that has to be placed in RTREE
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
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
const PositionVector & getShape() const
The shape of the additional element.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
static FXuint question(FXApp *app, const char *caption, const char *message,...)
Show modal question message, in free floating window.
const std::unordered_set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
The representation of a single edge during network building.
Definition NBEdge.h:92
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:546
const std::string & getID() const
Definition NBEdge.h:1531
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:539
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition NBNode.cpp:507
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition NBNode.cpp:4197
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:3130
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition NBNode.cpp:517
const Position & getPosition() const
Definition NBNode.h:260
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2757
A container for traffic light definitions and built programs.
const std::string & getID() const
Returns the id.
Definition Named.h:74
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > busStops
busStops namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static const std::vector< SumoXMLTag > laneAreaDetectors
lane area detectors namespace
static const std::vector< SumoXMLTag > POIs
POIs namespace.
static const std::vector< SumoXMLTag > routes
route namespace
static const std::vector< SumoXMLTag > persons
persons namespace
static const std::vector< SumoXMLTag > calibrators
calibrators namespace
static const std::vector< SumoXMLTag > polygons
polygon namespace
static const std::vector< SumoXMLTag > containers
containers namespace
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
C++ TraCI client API implementation.
double z() const
Returns the z-position.
Definition Position.h:62
long long int parametersSet
Information for the router which parameter were set.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
A simple triangle defined in 3D.
Definition Triangle.h:35
bool isPositionWithin(const Position &pos) const
check if the given position is within this triangle
Definition Triangle.cpp:53
bool intersectWithShape(const PositionVector &shape) const
check if the given shape is within or intersect with this triangle
Definition Triangle.cpp:68