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