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-2024 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
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
49
50#include "GNENetHelper.h"
51
52// ---------------------------------------------------------------------------
53// GNENetHelper::AttributeCarriers - methods
54// ---------------------------------------------------------------------------
55
57 myNet(net),
58 myStopIndex(0) {
59 // fill additionals with tags
62 for (const auto& additionalTagProperty : additionalTagProperties) {
63 myAdditionals.insert(std::make_pair(additionalTagProperty.getTag(), std::map<const GUIGlObject*, GNEAdditional*>()));
64 if (additionalTagProperty.hasAttribute(SUMO_ATTR_ID)) {
65 myAdditionalIDs.insert(std::make_pair(additionalTagProperty.getTag(), std::map<const std::string, GNEAdditional*>()));
66 }
67 }
68 // fill demand elements with tags
70 for (const auto& demandElementTagProperty : demandElementTagProperties) {
71 myDemandElements.insert(std::make_pair(demandElementTagProperty.getTag(), std::map<const GUIGlObject*, GNEDemandElement*>()));
72 if (demandElementTagProperty.hasAttribute(SUMO_ATTR_ID)) {
73 myDemandElementIDs.insert(std::make_pair(demandElementTagProperty.getTag(), std::map<const std::string, GNEDemandElement*>()));
74 }
75 }
77 for (const auto& stopTagProperty : stopTagProperties) {
78 myDemandElements.insert(std::make_pair(stopTagProperty.getTag(), std::map<const GUIGlObject*, GNEDemandElement*>()));
79 }
80 // fill data elements with tags
82 for (const auto& genericDataElementTagProperty : genericDataElementTagProperties) {
83 myGenericDatas.insert(std::make_pair(genericDataElementTagProperty.getTag(), std::map<const GUIGlObject*, GNEGenericData*>()));
84 }
85 // fill meanDatas with tags
87 for (const auto& meanDataTagProperty : meanDataTagProperties) {
88 myMeanDatas.insert(std::make_pair(meanDataTagProperty.getTag(), std::map<const std::string, GNEMeanData*>()));
89 }
90}
91
92
94 // Drop EdgeTypes
95 for (const auto& edgeType : myEdgeTypes) {
96 edgeType.second->decRef("GNENetHelper::~GNENet");
97 // show extra information for tests
98 WRITE_DEBUG("Deleting unreferenced " + edgeType.second->getTagStr() + " '" + edgeType.second->getID() + "' in AttributeCarriers destructor");
99 delete edgeType.second;
100 }
101 // Drop Edges
102 for (const auto& edge : myEdges) {
103 edge.second->decRef("GNENetHelper::~GNENet");
104 // show extra information for tests
105 WRITE_DEBUG("Deleting unreferenced " + edge.second->getTagStr() + " '" + edge.second->getID() + "' in AttributeCarriers destructor");
106 delete edge.second;
107 }
108 // Drop myJunctions
109 for (const auto& junction : myJunctions) {
110 junction.second->decRef("GNENetHelper::~GNENet");
111 // show extra information for tests
112 WRITE_DEBUG("Deleting unreferenced " + junction.second->getTagStr() + " '" + junction.second->getID() + "' in AttributeCarriers destructor");
113 delete junction.second;
114 }
115 // Drop Additionals (Only used for additionals that were inserted without using GNEChange_Additional)
116 for (const auto& additionalTag : myAdditionals) {
117 for (const auto& additional : additionalTag.second) {
118 // decrease reference manually (because it was increased manually in GNEAdditionalHandler)
119 additional.second->decRef();
120 // show extra information for tests
121 WRITE_DEBUG("Deleting unreferenced " + additional.second->getTagStr() + " in AttributeCarriers destructor");
122 delete additional.second;
123 }
124 }
125 // Drop demand elements (Only used for demand elements that were inserted without using GNEChange_DemandElement, for example the default VType")
126 for (const auto& demandElementTag : myDemandElements) {
127 for (const auto& demandElement : demandElementTag.second) {
128 // decrease reference manually (because it was increased manually in GNERouteHandler)
129 demandElement.second->decRef();
130 // show extra information for tests
131 if (demandElement.second->getTagProperty().isType()) {
132 // special case for default VTypes
133 if (DEFAULT_VTYPES.count(demandElement.second->getID()) == 0) {
134 WRITE_DEBUG("Deleting unreferenced " + demandElement.second->getTagStr() + " in AttributeCarriers destructor");
135 }
136 } else {
137 WRITE_DEBUG("Deleting unreferenced " + demandElement.second->getTagStr() + " in AttributeCarriers destructor");
138 }
139 delete demandElement.second;
140 }
141 }
142 // Drop dataSets (Only used for TAZElements that were inserted without using GNEChange_DataSets)
143 for (const auto& dataSet : myDataSets) {
144 // decrease reference manually (because it was increased manually in GNEDataHandler)
145 dataSet.second->decRef();
146 // show extra information for tests
147 WRITE_DEBUG("Deleting unreferenced " + dataSet.second->getTagStr() + " in AttributeCarriers destructor");
148 delete dataSet.second;
149 }
150 // Drop MeanDatas (Only used for meanDatas that were inserted without using GNEChange_MeanData)
151 for (const auto& meanDataTag : myMeanDatas) {
152 for (const auto& meanData : meanDataTag.second) {
153 // decrease reference manually (because it was increased manually in GNEMeanDataHandler)
154 meanData.second->decRef();
155 // show extra information for tests
156 WRITE_DEBUG("Deleting unreferenced " + meanData.second->getTagStr() + " in AttributeCarriers destructor");
157 delete meanData.second;
158 }
159 }
160}
161
162
163void
165 std::map<std::string, GNEEdge*> newEdgeMap;
166 std::map<std::string, GNEJunction*> newJunctionMap;
167 // fill newEdgeMap
168 for (const auto& edge : myEdges) {
169 edge.second->setEdgeID(edge.second->getNBEdge()->getID());
170 newEdgeMap[edge.second->getNBEdge()->getID()] = edge.second;
171 }
172 for (const auto& junction : myJunctions) {
173 newJunctionMap[junction.second->getNBNode()->getID()] = junction.second;
174 junction.second->setNetworkElementID(junction.second->getNBNode()->getID());
175 }
176 myEdges = newEdgeMap;
177 myJunctions = newJunctionMap;
178}
179
180
181bool
183 // check what type of AC
184 if (AC->getTagProperty().getTag() == SUMO_TAG_JUNCTION) {
185 // Junction
186 const GNEJunction* junction = myJunctions.at(AC->getID());
187 if (junction->getNBNode()->getShape().size() == 0) {
188 return shape.around(junction->getNBNode()->getCenter());
189 } else {
190 return (shape.overlapsWith(junction->getNBNode()->getShape()));
191 }
192 } else if (AC->getTagProperty().getTag() == SUMO_TAG_EDGE) {
193 // Edge
194 for (const auto& lane : myEdges.at(AC->getID())->getLanes()) {
195 if (shape.overlapsWith(lane->getLaneShape())) {
196 return true;
197 }
198 }
199 return false;
200 } else if (AC->getTagProperty().getTag() == SUMO_TAG_LANE) {
201 // Lane
202 return shape.overlapsWith(retrieveLane(AC->getID())->getLaneShape());
203 } else if (AC->getTagProperty().getTag() == SUMO_TAG_CONNECTION) {
204 // connection
205 return shape.overlapsWith(myConnections.at(AC->getGUIGlObject())->getConnectionShape());
206 } else if (AC->getTagProperty().getTag() == SUMO_TAG_CROSSING) {
207 // crossing
208 return shape.overlapsWith(myCrossings.at(AC->getGUIGlObject())->getCrossingShape());
209 } else if (AC->getTagProperty().isAdditionalElement()) {
210 // Additional (including shapes and TAZs
211 const GNEAdditional* additional = retrieveAdditional(AC->getGUIGlObject());
212 if (additional->getAdditionalGeometry().getShape().size() <= 1) {
213 return shape.around(additional->getPositionInView());
214 } else {
215 return shape.overlapsWith(additional->getAdditionalGeometry().getShape());
216 }
217 } else {
218 return false;
219 }
220}
221
222
225 // obtain blocked GUIGlObject
227 // Make sure that object exists
228 if (object != nullptr) {
229 // unblock and try to parse to AttributeCarrier
231 GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(object);
232 // If was successfully parsed, return it
233 if (ac == nullptr) {
234 throw ProcessError("GUIGlObject does not match the declared type");
235 } else {
236 return ac;
237 }
238 } else if (hardFail) {
239 throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
240 } else {
241 return nullptr;
242 }
243}
244
245
246std::vector<GNEAttributeCarrier*>
248 std::vector<GNEAttributeCarrier*> result;
249 if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_JUNCTION)) {
250 for (const auto& junction : myJunctions) {
251 result.push_back(junction.second);
252 }
253 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_EDGE)) {
254 for (const auto& edge : myEdges) {
255 result.push_back(edge.second);
256 }
257 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_LANE)) {
258 for (const auto& lane : myLanes) {
259 result.push_back(lane.second);
260 }
261 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CONNECTION)) {
262 for (const auto& connection : myConnections) {
263 result.push_back(connection.second);
264 }
265 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_CROSSING)) {
266 for (const auto& crossing : myCrossings) {
267 result.push_back(crossing.second);
268 }
269 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_WALKINGAREA)) {
270 for (const auto& walkingArea : myWalkingAreas) {
271 result.push_back(walkingArea.second);
272 }
274 for (const auto& additional : myAdditionals.at(tag)) {
275 result.push_back(additional.second);
276 }
279 if (mergingPlans.size() > 0) {
280 for (const auto& mergingPlan : mergingPlans) {
281 for (const auto& demandElemet : myDemandElements.at(mergingPlan.getTag())) {
282 result.push_back(demandElemet.second);
283 }
284 }
285 } else {
286 for (const auto& demandElemet : myDemandElements.at(tag)) {
287 result.push_back(demandElemet.second);
288 }
289 }
290 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATASET)) {
291 for (const auto& dataSet : myDataSets) {
292 result.push_back(dataSet.second);
293 }
294 } else if ((tag == SUMO_TAG_NOTHING) || (tag == SUMO_TAG_DATAINTERVAL)) {
295 for (const auto& dataInterval : myDataIntervals) {
296 result.push_back(dataInterval.second);
297 }
299 for (const auto& genericData : myGenericDatas.at(tag)) {
300 result.push_back(genericData.second);
301 }
302 } else if ((tag == SUMO_TAG_NOTHING) || (GNEAttributeCarrier::getTagProperty(tag).isMeanData())) {
303 for (const auto& meanData : myMeanDatas.at(tag)) {
304 result.push_back(meanData.second);
305 }
306 }
307 return result;
308}
309
310
311std::vector<GNEAttributeCarrier*>
313 std::vector<GNEAttributeCarrier*> result;
314 // continue depending of supermode
315 if (supermode == Supermode::NETWORK) {
316 // network
317 for (const auto& junction : myJunctions) {
318 if (!onlySelected || junction.second->isAttributeCarrierSelected()) {
319 result.push_back(junction.second);
320 }
321 }
322 for (const auto& crossing : myCrossings) {
323 if (!onlySelected || crossing.second->isAttributeCarrierSelected()) {
324 result.push_back(crossing.second);
325 }
326 }
327 for (const auto& edge : myEdges) {
328 if (!onlySelected || edge.second->isAttributeCarrierSelected()) {
329 result.push_back(edge.second);
330 }
331 }
332 for (const auto& lane : myLanes) {
333 if (!onlySelected || lane.second->isAttributeCarrierSelected()) {
334 result.push_back(lane.second);
335 }
336 }
337 for (const auto& connection : myConnections) {
338 if (!onlySelected || connection.second->isAttributeCarrierSelected()) {
339 result.push_back(connection.second);
340 }
341 }
342 for (const auto& additionalSet : myAdditionals) {
343 for (const auto& additional : additionalSet.second) {
344 if (!onlySelected || additional.second->isAttributeCarrierSelected()) {
345 result.push_back(additional.second);
346 }
347 }
348 }
349 } else if (supermode == Supermode::DEMAND) {
350 for (const auto& demandElementSet : myDemandElements) {
351 for (const auto& demandElement : demandElementSet.second) {
352 if (!onlySelected || demandElement.second->isAttributeCarrierSelected()) {
353 result.push_back(demandElement.second);
354 }
355 }
356 }
357 } else if (supermode == Supermode::DATA) {
358 for (const auto& dataSet : myDataSets) {
359 if (!onlySelected || dataSet.second->isAttributeCarrierSelected()) {
360 result.push_back(dataSet.second);
361 }
362 }
363 for (const auto& dataInterval : myDataIntervals) {
364 if (!onlySelected || dataInterval.second->isAttributeCarrierSelected()) {
365 result.push_back(dataInterval.second);
366 }
367 }
368 for (const auto& genericDataSet : myGenericDatas) {
369 for (const auto& genericData : genericDataSet.second) {
370 if (!onlySelected || genericData.second->isAttributeCarrierSelected()) {
371 result.push_back(genericData.second);
372 }
373 }
374 }
375 for (const auto& meanDataSet : myMeanDatas) {
376 for (const auto& meanData : meanDataSet.second) {
377 if (!onlySelected || meanData.second->isAttributeCarrierSelected()) {
378 result.push_back(meanData.second);
379 }
380 }
381 }
382 }
383 return result;
384}
385
386
387std::vector<GNEAttributeCarrier*>
389 // get modes
390 const auto& editModes = myNet->getViewNet()->getEditModes();
391 // declare vector to save result
392 std::vector<GNEAttributeCarrier*> result;
393 result.reserve(gSelected.getSelected().size());
394 // iterate over all elements of global selection
395 for (const auto& glID : gSelected.getSelected()) {
396 // obtain AC
397 GNEAttributeCarrier* AC = retrieveAttributeCarrier(glID, false);
398 // check if attribute carrier exist and is selected
399 if (AC && AC->isAttributeCarrierSelected()) {
400 bool insert = false;
401 if (ignoreCurrentSupermode) {
402 insert = true;
403 } else if (editModes.isCurrentSupermodeNetwork() && (AC->getTagProperty().isNetworkElement() || AC->getTagProperty().isAdditionalElement())) {
404 insert = true;
405 } else if (editModes.isCurrentSupermodeDemand() && AC->getTagProperty().isDemandElement()) {
406 insert = true;
407 } else if (editModes.isCurrentSupermodeData() && AC->getTagProperty().isDataElement()) {
408 insert = true;
409 }
410 if (insert) {
411 result.push_back(AC);
412 }
413 }
414 }
415 return result;
416}
417
418
420GNENetHelper::AttributeCarriers::retrieveJunction(const std::string& id, bool hardFail) const {
421 auto it = myJunctions.find(id);
422 if (it != myJunctions.end()) {
423 return it->second;
424 }
425 if (hardFail) {
426 // If junction wasn't found, throw exception
427 throw UnknownElement("Attempted to retrieve non-existant junction " + id);
428 } else {
429 return nullptr;
430 }
431}
432
433
434const std::map<std::string, GNEJunction*>&
436 return myJunctions;
437}
438
439
440std::vector<GNEJunction*>
442 std::vector<GNEJunction*> result;
443 // returns junctions depending of selection
444 for (const auto& junction : myJunctions) {
445 if (junction.second->isAttributeCarrierSelected()) {
446 result.push_back(junction.second);
447 }
448 }
449 return result;
450}
451
452
455 // increase reference
456 junction->incRef("GNENet::registerJunction");
457 junction->setResponsible(false);
458 myJunctions[junction->getMicrosimID()] = junction;
459 // expand net boundary
460 myNet->expandBoundary(junction->getCenteringBoundary());
461 // add edge into grid
462 myNet->addGLObjectIntoGrid(junction);
463 // update geometry
464 junction->updateGeometry();
465 // add z in net boundary
466 myNet->addZValueInBoundary(junction->getNBNode()->getPosition().z());
467 return junction;
468}
469
470
471void
473 myJunctions.clear();
474}
475
476
477void
479 // make a copy of junctions
480 auto junctionCopy = myJunctions;
481 // clear junctions
482 myJunctions.clear();
483 // fill junctions again
484 for (const auto& junction : junctionCopy) {
485 // update microsim ID
486 junction.second->setNetworkElementID(prefix + junction.first);
487 // insert in myJunctions again
488 myJunctions[prefix + junction.first] = junction.second;
489 }
490}
491
492
493void
495 if (myJunctions.count(junction->getID()) == 0) {
496 throw ProcessError(junction->getTagStr() + " with ID='" + junction->getID() + "' doesn't exist in AttributeCarriers.junction");
497 } else if (myJunctions.count(newID) != 0) {
498 throw ProcessError("There is another " + junction->getTagStr() + " with new ID='" + newID + "' in myJunctions");
499 } else {
500 // remove junction from container
501 myJunctions.erase(junction->getNBNode()->getID());
502 // rename in NetBuilder
503 myNet->getNetBuilder()->getNodeCont().rename(junction->getNBNode(), newID);
504 // update microsim ID
505 junction->setNetworkElementID(newID);
506 // add it into myJunctions again
507 myJunctions[junction->getID()] = junction;
508 // build crossings
509 junction->getNBNode()->buildCrossings();
510 // net has to be saved
511 myNet->getSavingStatus()->requireSaveNetwork();
512 }
513}
514
515
516int
518 int counter = 0;
519 for (const auto& junction : myJunctions) {
520 if (junction.second->isAttributeCarrierSelected()) {
521 counter++;
522 }
523 }
524 return counter;
525}
526
527
530 auto it = myCrossings.find(glObject);
531 if (it != myCrossings.end()) {
532 return it->second;
533 }
534 if (hardFail) {
535 // If junction wasn't found, throw exception
536 throw UnknownElement("Attempted to retrieve non-existant crossing " + glObject->getMicrosimID());
537 } else {
538 return nullptr;
539 }
540}
541
542
543const std::map<const GUIGlObject*, GNECrossing*>&
545 return myCrossings;
546}
547
548
549std::vector<GNECrossing*>
551 std::vector<GNECrossing*> result;
552 // iterate over crossings
553 for (const auto& crossing : myCrossings) {
554 if (crossing.second->isAttributeCarrierSelected()) {
555 result.push_back(crossing.second);
556 }
557 }
558 return result;
559}
560
561
562int
564 int counter = 0;
565 for (const auto& crossing : myCrossings) {
566 if (crossing.second->isAttributeCarrierSelected()) {
567 counter++;
568 }
569 }
570 return counter;
571}
572
573
576 auto it = myWalkingAreas.find(glObject);
577 if (it != myWalkingAreas.end()) {
578 return it->second;
579 }
580 if (hardFail) {
581 // If junction wasn't found, throw exception
582 throw UnknownElement("Attempted to retrieve non-existant walkingArea " + glObject->getMicrosimID());
583 } else {
584 return nullptr;
585 }
586}
587
588
589const std::map<const GUIGlObject*, GNEWalkingArea*>&
591 return myWalkingAreas;
592}
593
594
595std::vector<GNEWalkingArea*>
597 std::vector<GNEWalkingArea*> result;
598 // iterate over walkingAreas
599 for (const auto& walkingArea : myWalkingAreas) {
600 if (walkingArea.second->isAttributeCarrierSelected()) {
601 result.push_back(walkingArea.second);
602 }
603 }
604 return result;
605}
606
607
608int
610 int counter = 0;
611 for (const auto& walkingArea : myWalkingAreas) {
612 if (walkingArea.second->isAttributeCarrierSelected()) {
613 counter++;
614 }
615 }
616 return counter;
617}
618
619
621GNENetHelper::AttributeCarriers::retrieveEdgeType(const std::string& id, bool hardFail) const {
622 if (myEdgeTypes.count(id) > 0) {
623 return myEdgeTypes.at(id);
624 } else if (hardFail) {
625 // If edge wasn't found, throw exception
626 throw UnknownElement("Attempted to retrieve non-existant EdgeType " + id);
627 } else {
628 return nullptr;
629 }
630}
631
632
635 // increase reference
636 edgeType->incRef("GNENet::registerEdgeType");
637 // add it in container
638 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
639 return edgeType;
640}
641
642
643const std::map<std::string, GNEEdgeType*>&
645 return myEdgeTypes;
646}
647
648
650 myEdgeTypes.clear();
651}
652
653
654void
656 if (myEdgeTypes.count(edgeType->getID()) == 0) {
657 throw ProcessError(edgeType->getTagStr() + " with ID='" + edgeType->getID() + "' doesn't exist in AttributeCarriers.edgeType");
658 } else if (myEdgeTypes.count(newID) != 0) {
659 throw ProcessError("There is another " + edgeType->getTagStr() + " with new ID='" + newID + "' in myEdgeTypes");
660 } else {
661 // remove edgeType from container
662 myEdgeTypes.erase(edgeType->getID());
663 // rename in typeCont
664 myNet->getNetBuilder()->getTypeCont().updateEdgeTypeID(edgeType->getID(), newID);
665 // update microsim ID
666 edgeType->setNetworkElementID(newID);
667 // add it into myEdgeTypes again
668 myEdgeTypes[edgeType->getID()] = edgeType;
669 // net has to be saved
670 myNet->getSavingStatus()->requireSaveNetwork();
671 }
672}
673
674
675std::string
677 int counter = 0;
678 while (myEdgeTypes.count("edgeType_" + toString(counter)) != 0) {
679 counter++;
680 }
681 return ("edgeType_" + toString(counter));
682}
683
684
685GNEEdge*
686GNENetHelper::AttributeCarriers::retrieveEdge(const std::string& id, bool hardFail) const {
687 auto it = myEdges.find(id);
688 if (it != myEdges.end()) {
689 return it->second;
690 }
691 if (hardFail) {
692 // If edge wasn't found, throw exception
693 throw UnknownElement("Attempted to retrieve non-existant edge " + id);
694 } else {
695 return nullptr;
696 }
697}
698
699
700std::vector<GNEEdge*>
702 if ((from == nullptr) || (to == nullptr)) {
703 throw UnknownElement("Junctions cannot be nullptr");
704 }
705 std::vector<GNEEdge*> edges;
706 // iterate over Junctions
707 for (const auto& edge : myEdges) {
708 if ((edge.second->getFromJunction() == from) && (edge.second->getToJunction() == to)) {
709 edges.push_back(edge.second);
710 }
711 }
712 return edges;
713}
714
715
716const std::map<std::string, GNEEdge*>&
718 return myEdges;
719}
720
721
722std::vector<GNEEdge*>
724 std::vector<GNEEdge*> result;
725 // returns edges depending of selection
726 for (const auto& edge : myEdges) {
727 if (edge.second->isAttributeCarrierSelected()) {
728 result.push_back(edge.second);
729 }
730 }
731 return result;
732}
733
734
735GNEEdge*
737 edge->incRef("GNENet::registerEdge");
738 edge->setResponsible(false);
739 // add edge to internal container of GNENet
740 myEdges[edge->getMicrosimID()] = edge;
741 // insert all lanes
742 for (const auto& lane : edge->getLanes()) {
743 insertLane(lane);
744 }
745 // Add references into GNEJunctions
746 edge->getFromJunction()->addOutgoingGNEEdge(edge);
747 edge->getToJunction()->addIncomingGNEEdge(edge);
748 // update boundaries of both junctions (to remove it from Grid)
751 // update edge boundary
752 edge->updateCenteringBoundary(false);
753 // expand edge boundary
754 myNet->expandBoundary(edge->getCenteringBoundary());
755 // finally add edge into grid
756 myNet->addGLObjectIntoGrid(edge);
757 return edge;
758}
759
760
761void
765
766
767void
769 // make a copy of edges
770 auto edgeCopy = myEdges;
771 // clear edges
772 myEdges.clear();
773 // fill edges again
774 for (const auto& edge : edgeCopy) {
775 // update microsim ID
776 edge.second->setNetworkElementID(prefix + edge.first);
777 // insert in myEdges again
778 myEdges[prefix + edge.first] = edge.second;
779 }
780}
781
782
783void
785 if (myEdges.count(edge->getID()) == 0) {
786 throw ProcessError(edge->getTagStr() + " with ID='" + edge->getID() + "' doesn't exist in AttributeCarriers.edge");
787 } else if (myEdges.count(newID) != 0) {
788 throw ProcessError("There is another " + edge->getTagStr() + " with new ID='" + newID + "' in myEdges");
789 } else {
790 // remove edge from container
791 myEdges.erase(edge->getNBEdge()->getID());
792 // rename in NetBuilder
793 myNet->getNetBuilder()->getEdgeCont().rename(edge->getNBEdge(), newID);
794 // update microsim ID
795 edge->setEdgeID(newID);
796 // add it into myEdges again
797 myEdges[edge->getID()] = edge;
798 // rename all connections related to this edge
799 for (const auto& lane : edge->getLanes()) {
800 lane->updateConnectionIDs();
801 }
802 // net has to be saved
803 myNet->getSavingStatus()->requireSaveNetwork();
804 }
805}
806
807
808int
810 int counter = 0;
811 for (const auto& edge : myEdges) {
812 if (edge.second->isAttributeCarrierSelected()) {
813 counter++;
814 }
815 }
816 return counter;
817}
818
819
820GNELane*
821GNENetHelper::AttributeCarriers::retrieveLane(const std::string& id, bool hardFail, bool checkVolatileChange) const {
822 const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
823 const GNEEdge* edge = retrieveEdge(edge_id, false);
824 if (edge != nullptr) {
825 GNELane* lane = nullptr;
826 // search lane in lane's edges
827 for (auto laneIt : edge->getLanes()) {
828 if (laneIt->getID() == id) {
829 lane = laneIt;
830 }
831 }
832 // throw exception or return nullptr if lane wasn't found
833 if (lane == nullptr) {
834 if (hardFail) {
835 // Throw exception if hardFail is enabled
836 throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
837 }
838 } else {
839 // check if the recomputing with volatile option has changed the number of lanes (needed for additionals and demand elements)
840 if (checkVolatileChange && (myNet->getEdgesAndNumberOfLanes().count(edge_id) == 1) &&
841 myNet->getEdgesAndNumberOfLanes().at(edge_id) != (int)edge->getLanes().size()) {
842 return edge->getLanes().at(lane->getIndex() + 1);
843 }
844 return lane;
845 }
846 } else if (hardFail) {
847 // Throw exception if hardFail is enabled
848 throw UnknownElement(toString(SUMO_TAG_EDGE) + " " + edge_id);
849 }
850 return nullptr;
851}
852
853
854GNELane*
855GNENetHelper::AttributeCarriers::retrieveLane(const GUIGlObject* glObject, bool hardFail) const {
856 auto it = myLanes.find(glObject);
857 if (it != myLanes.end()) {
858 return it->second;
859 }
860 if (hardFail) {
861 // If junction wasn't found, throw exception
862 throw UnknownElement("Attempted to retrieve non-existant lane " + glObject->getMicrosimID());
863 } else {
864 return nullptr;
865 }
866}
867
868
869const std::map<const GUIGlObject*, GNELane*>&
871 return myLanes;
872}
873
874
875std::vector<GNELane*>
877 std::vector<GNELane*> result;
878 // returns lanes depending of selection
879 for (const auto& lane : myLanes) {
880 if (lane.second->isAttributeCarrierSelected()) {
881 result.push_back(lane.second);
882 }
883 }
884 return result;
885}
886
887
888int
890 int counter = 0;
891 for (const auto& lane : myLanes) {
892 if (lane.second->isAttributeCarrierSelected()) {
893 counter++;
894 }
895 }
896 return counter;
897}
898
899
901GNENetHelper::AttributeCarriers::retrieveConnection(const std::string& id, bool hardFail) const {
902 // iterate over connections
903 for (const auto& connection : myConnections) {
904 if (connection.second->getID() == id) {
905 return connection.second;
906 }
907 }
908 if (hardFail) {
909 // If POI wasn't found, throw exception
910 throw UnknownElement("Attempted to retrieve non-existant connection " + id);
911 } else {
912 return nullptr;
913 }
914}
915
916
919 auto it = myConnections.find(glObject);
920 if (it != myConnections.end()) {
921 return it->second;
922 }
923 if (hardFail) {
924 // If POI wasn't found, throw exception
925 throw UnknownElement("Attempted to retrieve non-existant connection " + glObject->getMicrosimID());
926 } else {
927 return nullptr;
928 }
929}
930
931
932const std::map<const GUIGlObject*, GNEConnection*>&
934 return myConnections;
935}
936
937
938std::vector<GNEConnection*>
940 std::vector<GNEConnection*> result;
941 // returns connections depending of selection
942 for (const auto& connection : myConnections) {
943 if (connection.second->isAttributeCarrierSelected()) {
944 result.push_back(connection.second);
945 }
946 }
947 return result;
948}
949
950
951int
953 int counter = 0;
954 for (const auto& connection : myConnections) {
955 if (connection.second->isAttributeCarrierSelected()) {
956 counter++;
957 }
958 }
959 return counter;
960}
961
962
965 auto it = myInternalLanes.find(glObject);
966 if (it != myInternalLanes.end()) {
967 return it->second;
968 }
969 if (hardFail) {
970 // If POI wasn't found, throw exception
971 throw UnknownElement("Attempted to retrieve non-existant internalLane " + glObject->getMicrosimID());
972 } else {
973 return nullptr;
974 }
975}
976
977
979GNENetHelper::AttributeCarriers::retrieveAdditional(SumoXMLTag type, const std::string& id, bool hardFail) const {
980 auto it = myAdditionalIDs.at(type).find(id);
981 if (it != myAdditionalIDs.at(type).end()) {
982 return it->second;
983 }
984 if (hardFail) {
985 throw ProcessError("Attempted to retrieve non-existant additional (string)");
986 } else {
987 return nullptr;
988 }
989}
990
991
993GNENetHelper::AttributeCarriers::retrieveAdditionals(const std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
994 for (const auto& type : types) {
995 auto it = myAdditionalIDs.at(type).find(id);
996 if (it != myAdditionalIDs.at(type).end()) {
997 return it->second;
998 }
999 }
1000 if (hardFail) {
1001 throw ProcessError("Attempted to retrieve non-existant additional (string)");
1002 } else {
1003 return nullptr;
1004 }
1005}
1006
1007
1010 // iterate over all additionals
1011 for (const auto& additionalTag : myAdditionals) {
1012 auto it = additionalTag.second.find(glObject);
1013 if (it != additionalTag.second.end()) {
1014 return it->second;
1015 }
1016 }
1017 if (hardFail) {
1018 throw ProcessError("Attempted to retrieve non-existant additional (glObject)");
1019 } else {
1020 return nullptr;
1021 }
1022}
1023
1024
1026GNENetHelper::AttributeCarriers::retrieveRerouterInterval(const std::string& rerouterID, const SUMOTime begin, const SUMOTime end) const {
1027 // first retrieve rerouter
1028 const GNEAdditional* rerouter = retrieveAdditional(SUMO_TAG_REROUTER, rerouterID);
1029 // parse begin and end
1030 const std::string beginStr = time2string(begin);
1031 const std::string endStr = time2string(end);
1032 // now iterate over all children and check begin and end
1033 for (const auto& interval : rerouter->getChildAdditionals()) {
1034 // check tag (to avoid symbols)
1035 if (interval->getTagProperty().getTag() == SUMO_TAG_INTERVAL) {
1036 // check begin and end
1037 if ((interval->getAttribute(SUMO_ATTR_BEGIN) == beginStr) &&
1038 (interval->getAttribute(SUMO_ATTR_END) == endStr)) {
1039 return interval;
1040 }
1041 }
1042 }
1043 // throw exception
1044 throw ProcessError("Attempted to retrieve non-existant rerouter interval");
1045}
1046
1047
1048const std::map<SumoXMLTag, std::map<const GUIGlObject*, GNEAdditional*> >&
1050 return myAdditionals;
1051}
1052
1053
1054std::vector<GNEAdditional*>
1056 std::vector<GNEAdditional*> result;
1057 // returns additionals depending of selection
1058 for (const auto& additionalsTags : myAdditionals) {
1059 for (const auto& additional : additionalsTags.second) {
1060 if (additional.second->isAttributeCarrierSelected()) {
1061 result.push_back(additional.second);
1062 }
1063 }
1064 }
1065 return result;
1066}
1067
1068
1069std::vector<GNEAdditional*>
1071 std::vector<GNEAdditional*> result;
1072 // returns additionals depending of selection
1073 for (const auto& additionalsTags : myAdditionals) {
1074 for (const auto& additional : additionalsTags.second) {
1075 if (additional.second->getTagProperty().isShapeElement() && additional.second->isAttributeCarrierSelected()) {
1076 result.push_back(additional.second);
1077 }
1078 }
1079 }
1080 return result;
1081}
1082
1083
1084int
1086 int counter = 0;
1087 for (const auto& additionalsTag : myAdditionals) {
1088 counter += (int)additionalsTag.second.size();
1089 }
1090 return counter;
1091}
1092
1093
1094void
1096 // clear elements in grid
1097 for (const auto& additionalsTags : myAdditionals) {
1098 for (const auto& additional : additionalsTags.second) {
1099 myNet->removeGLObjectFromGrid(additional.second);
1100 }
1101 }
1102 // iterate over myAdditionals and clear all additionals
1103 for (auto& additionals : myAdditionals) {
1104 additionals.second.clear();
1105 }
1106 for (auto& additionals : myAdditionalIDs) {
1107 additionals.second.clear();
1108 }
1109}
1110
1111
1112void
1114 const auto tag = additional->getTagProperty().getTag();
1115 const auto it = myAdditionalIDs.at(tag).find(additional->getID());
1116 if (it == myAdditionalIDs.at(tag).end()) {
1117 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' doesn't exist in AttributeCarriers.additionals");
1118 } else {
1119 // remove from container, set new Id, and insert it again
1120 myAdditionalIDs.at(tag).erase(it);
1121 // set microsim ID
1122 additional->setMicrosimID(newID);
1123 myAdditionalIDs.at(tag)[newID] = additional;
1124 }
1125}
1126
1127
1128std::string
1130 // obtain option container
1131 const auto& neteditOptions = OptionsCont::getOptions();
1132 // get prefix
1133 std::string prefix;
1134 if (tag == SUMO_TAG_BUS_STOP) {
1135 prefix = neteditOptions.getString("busStop-prefix");
1136 } else if (tag == SUMO_TAG_TRAIN_STOP) {
1137 prefix = neteditOptions.getString("trainStop-prefix");
1138 } else if (tag == SUMO_TAG_CONTAINER_STOP) {
1139 prefix = neteditOptions.getString("containerStop-prefix");
1140 } else if (tag == SUMO_TAG_CHARGING_STATION) {
1141 prefix = neteditOptions.getString("chargingStation-prefix");
1142 } else if (tag == SUMO_TAG_PARKING_AREA) {
1143 prefix = neteditOptions.getString("parkingArea-prefix");
1144 } else if (tag == SUMO_TAG_INDUCTION_LOOP) {
1145 prefix = neteditOptions.getString("e1Detector-prefix");
1146 } else if ((tag == SUMO_TAG_LANE_AREA_DETECTOR) || (tag == GNE_TAG_MULTI_LANE_AREA_DETECTOR)) {
1147 prefix = neteditOptions.getString("e2Detector-prefix");
1148 } else if (tag == SUMO_TAG_ENTRY_EXIT_DETECTOR) {
1149 prefix = neteditOptions.getString("e3Detector-prefix");
1150 } else if (tag == SUMO_TAG_INSTANT_INDUCTION_LOOP) {
1151 prefix = neteditOptions.getString("e1InstantDetector-prefix");
1152 } else if (tag == SUMO_TAG_REROUTER) {
1153 prefix = neteditOptions.getString("rerouter-prefix");
1154 } else if ((tag == SUMO_TAG_CALIBRATOR) || (tag == GNE_TAG_CALIBRATOR_LANE)) {
1155 prefix = neteditOptions.getString("calibrator-prefix");
1156 } else if (tag == SUMO_TAG_ROUTEPROBE) {
1157 prefix = neteditOptions.getString("routeProbe-prefix");
1158 } else if (tag == SUMO_TAG_VSS) {
1159 prefix = neteditOptions.getString("vss-prefix");
1160 } else if (tag == SUMO_TAG_TRACTION_SUBSTATION) {
1161 prefix = neteditOptions.getString("tractionSubstation-prefix");
1162 } else if (tag == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
1163 prefix = neteditOptions.getString("overheadWire-prefix");
1164 } else if (tag == SUMO_TAG_POLY) {
1165 prefix = neteditOptions.getString("polygon-prefix");
1166 } else if ((tag == SUMO_TAG_POI) || (tag == GNE_TAG_POILANE) || (tag == GNE_TAG_POIGEO)) {
1167 prefix = neteditOptions.getString("poi-prefix");
1168 } else if (tag == SUMO_TAG_TAZ) {
1169 prefix = toString(SUMO_TAG_TAZ);
1170 } else if (tag == GNE_TAG_JPS_WALKABLEAREA) {
1171 prefix = neteditOptions.getString("jps.walkableArea-prefix");
1172 } else if (tag == GNE_TAG_JPS_OBSTACLE) {
1173 prefix = neteditOptions.getString("jps.obstacle-prefix");
1174 }
1175 int counter = 0;
1176 // check namespaces
1177 if (std::find(NamespaceIDs::busStops.begin(), NamespaceIDs::busStops.end(), tag) != NamespaceIDs::busStops.end()) {
1178 while (retrieveAdditionals(NamespaceIDs::busStops, prefix + "_" + toString(counter), false) != nullptr) {
1179 counter++;
1180 }
1181 } else if (std::find(NamespaceIDs::calibrators.begin(), NamespaceIDs::calibrators.end(), tag) != NamespaceIDs::calibrators.end()) {
1182 while (retrieveAdditionals(NamespaceIDs::calibrators, prefix + "_" + toString(counter), false) != nullptr) {
1183 counter++;
1184 }
1185 } else if (std::find(NamespaceIDs::polygons.begin(), NamespaceIDs::polygons.end(), tag) != NamespaceIDs::polygons.end()) {
1186 while (retrieveAdditionals(NamespaceIDs::polygons, prefix + "_" + toString(counter), false) != nullptr) {
1187 counter++;
1188 }
1189 } else if (std::find(NamespaceIDs::POIs.begin(), NamespaceIDs::POIs.end(), tag) != NamespaceIDs::POIs.end()) {
1190 while (retrieveAdditionals(NamespaceIDs::POIs, prefix + "_" + toString(counter), false) != nullptr) {
1191 counter++;
1192 }
1193 } else if (std::find(NamespaceIDs::laneAreaDetectors.begin(), NamespaceIDs::laneAreaDetectors.end(), tag) != NamespaceIDs::laneAreaDetectors.end()) {
1194 while (retrieveAdditionals(NamespaceIDs::laneAreaDetectors, prefix + "_" + toString(counter), false) != nullptr) {
1195 counter++;
1196 }
1197 } else {
1198 while (retrieveAdditional(tag, prefix + "_" + toString(counter), false) != nullptr) {
1199 counter++;
1200 }
1201 }
1202 // return new element ID
1203 return (prefix + "_" + toString(counter));
1204}
1205
1206
1207int
1209 int counter = 0;
1210 for (const auto& additionalsTags : myAdditionals) {
1211 for (const auto& additional : additionalsTags.second) {
1212 if (additional.second->isAttributeCarrierSelected()) {
1213 counter++;
1214 }
1215 }
1216 }
1217 return counter;
1218}
1219
1220
1221int
1223 return getNumberOfSelectedAdditionals() -
1224 // shapes
1225 getNumberOfSelectedPolygons() - getNumberOfSelectedPOIs() -
1226 // JuPedSims
1227 getNumberOfSelectedJpsWalkableAreas() - getNumberOfSelectedJpsObstacles() -
1228 // TAZ
1229 getNumberOfSelectedTAZs() - getNumberOfSelectedTAZSources() - getNumberOfSelectedTAZSinks() -
1230 // wires
1231 getNumberOfSelectedWires();
1232}
1233
1234
1235int
1237 int counter = 0;
1238 for (const auto& poly : myAdditionals.at(SUMO_TAG_POLY)) {
1239 if (poly.second->isAttributeCarrierSelected()) {
1240 counter++;
1241 }
1242 }
1243 return counter;
1244}
1245
1246
1247int
1249 int counter = 0;
1250 for (const auto& walkableArea : myAdditionals.at(GNE_TAG_JPS_WALKABLEAREA)) {
1251 if (walkableArea.second->isAttributeCarrierSelected()) {
1252 counter++;
1253 }
1254 }
1255 return counter;
1256}
1257
1258
1259int
1261 int counter = 0;
1262 for (const auto& obstacle : myAdditionals.at(GNE_TAG_JPS_OBSTACLE)) {
1263 if (obstacle.second->isAttributeCarrierSelected()) {
1264 counter++;
1265 }
1266 }
1267 return counter;
1268}
1269
1270
1271int
1273 int counter = 0;
1274 for (const auto& POI : myAdditionals.at(SUMO_TAG_POI)) {
1275 if (POI.second->isAttributeCarrierSelected()) {
1276 counter++;
1277 }
1278 }
1279 for (const auto& POILane : myAdditionals.at(GNE_TAG_POILANE)) {
1280 if (POILane.second->isAttributeCarrierSelected()) {
1281 counter++;
1282 }
1283 }
1284 for (const auto& POIGEO : myAdditionals.at(GNE_TAG_POIGEO)) {
1285 if (POIGEO.second->isAttributeCarrierSelected()) {
1286 counter++;
1287 }
1288 }
1289 return counter;
1290}
1291
1292
1293int
1295 int counter = 0;
1296 for (const auto& TAZ : myAdditionals.at(SUMO_TAG_TAZ)) {
1297 if (TAZ.second->isAttributeCarrierSelected()) {
1298 counter++;
1299 }
1300 }
1301 return counter;
1302}
1303
1304
1305int
1307 int counter = 0;
1308 for (const auto& TAZSource : myAdditionals.at(SUMO_TAG_TAZSOURCE)) {
1309 if (TAZSource.second->isAttributeCarrierSelected()) {
1310 counter++;
1311 }
1312 }
1313 return counter;
1314}
1315
1316
1317int
1319 int counter = 0;
1320 for (const auto& TAZSink : myAdditionals.at(SUMO_TAG_TAZSINK)) {
1321 if (TAZSink.second->isAttributeCarrierSelected()) {
1322 counter++;
1323 }
1324 }
1325 return counter;
1326}
1327
1328
1329int
1331 int counter = 0;
1332 for (const auto& additionalsTags : myAdditionals) {
1333 for (const auto& additional : additionalsTags.second) {
1334 if (additional.second->isAttributeCarrierSelected() && additional.second->getTagProperty().isWireElement()) {
1335 counter++;
1336 }
1337 }
1338 }
1339 return counter;
1340}
1341
1342
1344GNENetHelper::AttributeCarriers::retrieveDemandElement(SumoXMLTag type, const std::string& id, bool hardFail) const {
1345 auto it = myDemandElementIDs.at(type).find(id);
1346 if (it != myDemandElementIDs.at(type).end()) {
1347 return it->second;
1348 }
1349 if (hardFail) {
1350 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1351 } else {
1352 return nullptr;
1353 }
1354}
1355
1356
1358GNENetHelper::AttributeCarriers::retrieveDemandElements(std::vector<SumoXMLTag> types, const std::string& id, bool hardFail) const {
1359 for (const auto& type : types) {
1360 auto it = myDemandElementIDs.at(type).find(id);
1361 if (it != myDemandElementIDs.at(type).end()) {
1362 return it->second;
1363 }
1364 }
1365 if (hardFail) {
1366 throw ProcessError("Attempted to retrieve non-existant demand element (string)");
1367 } else {
1368 return nullptr;
1369 }
1370}
1371
1372
1375 // iterate over all demand elements
1376 for (const auto& demandElementTag : myDemandElements) {
1377 auto it = demandElementTag.second.find(glObject);
1378 if (it != demandElementTag.second.end()) {
1379 return it->second;
1380 }
1381 }
1382 if (hardFail) {
1383 throw ProcessError("Attempted to retrieve non-existant demandElement (glObject)");
1384 } else {
1385 return nullptr;
1386 }
1387}
1388
1389
1390std::vector<GNEDemandElement*>
1392 std::vector<GNEDemandElement*> result;
1393 // returns demand elements depending of selection
1394 for (const auto& demandElementTag : myDemandElements) {
1395 for (const auto& demandElement : demandElementTag.second) {
1396 if (demandElement.second->isAttributeCarrierSelected()) {
1397 result.push_back(demandElement.second);
1398 }
1399 }
1400 }
1401 return result;
1402}
1403
1404
1405const std::map<SumoXMLTag, std::map<const GUIGlObject*, GNEDemandElement*> >&
1407 return myDemandElements;
1408}
1409
1410
1411int
1413 int counter = 0;
1414 for (const auto& demandElementTag : myDemandElements) {
1415 if (demandElementTag.first == SUMO_TAG_VTYPE) {
1416 // iterate over vehicle types to avoid default vTypes
1417 for (const auto& vType : demandElementTag.second) {
1418 if (vType.second->getAttribute(GNE_ATTR_DEFAULT_VTYPE) != GNEAttributeCarrier::True) {
1419 counter++;
1420 }
1421 }
1422 } else {
1423 counter += (int)demandElementTag.second.size();
1424 }
1425 }
1426 return counter;
1427}
1428
1429
1430std::string
1432 // obtain option container
1433 const auto& neteditOptions = OptionsCont::getOptions();
1434 // get tag property
1435 const auto tagProperty = GNEAttributeCarrier::getTagProperty(tag);
1436 // get prefix
1437 std::string prefix;
1438 if (tag == SUMO_TAG_ROUTE) {
1439 prefix = neteditOptions.getString("route-prefix");
1440 } else if (tag == SUMO_TAG_ROUTE_DISTRIBUTION) {
1441 prefix = neteditOptions.getString("routeDistribution-prefix");
1442 } else if (tag == SUMO_TAG_VTYPE) {
1443 prefix = neteditOptions.getString("vType-prefix");
1444 } else if (tag == SUMO_TAG_VTYPE_DISTRIBUTION) {
1445 prefix = neteditOptions.getString("vTypeDistribution-prefix");
1446 } else if ((tag == SUMO_TAG_TRIP) || (tag == GNE_TAG_TRIP_JUNCTIONS) || (tag == GNE_TAG_TRIP_TAZS)) {
1447 prefix = neteditOptions.getString("trip-prefix");
1448 } else if (tagProperty.isVehicle() && !tagProperty.isFlow()) {
1449 prefix = neteditOptions.getString("vehicle-prefix");
1450 } else if (tagProperty.isPerson()) {
1451 if (tagProperty.isFlow()) {
1452 prefix = neteditOptions.getString("personflow-prefix");
1453 } else {
1454 prefix = neteditOptions.getString("person-prefix");
1455 }
1456 } else if (tagProperty.isContainer()) {
1457 if (tagProperty.isFlow()) {
1458 prefix = neteditOptions.getString("containerflow-prefix");
1459 } else {
1460 prefix = neteditOptions.getString("container-prefix");
1461 }
1462 } else if (tagProperty.isFlow()) {
1463 prefix = neteditOptions.getString("flow-prefix");
1464 }
1465 // declare counter
1466 int counter = 0;
1467 if (std::find(NamespaceIDs::types.begin(), NamespaceIDs::types.end(), tag) != NamespaceIDs::types.end()) {
1468 while (retrieveDemandElements(NamespaceIDs::types, prefix + "_" + toString(counter), false) != nullptr) {
1469 counter++;
1470 }
1471 } else if (std::find(NamespaceIDs::routes.begin(), NamespaceIDs::routes.end(), tag) != NamespaceIDs::routes.end()) {
1472 while (retrieveDemandElements(NamespaceIDs::routes, prefix + "_" + toString(counter), false) != nullptr) {
1473 counter++;
1474 }
1475 } else if (std::find(NamespaceIDs::persons.begin(), NamespaceIDs::persons.end(), tag) != NamespaceIDs::persons.end()) {
1476 while (retrieveDemandElements(NamespaceIDs::persons, prefix + "_" + toString(counter), false) != nullptr) {
1477 counter++;
1478 }
1479 } else if (std::find(NamespaceIDs::containers.begin(), NamespaceIDs::containers.end(), tag) != NamespaceIDs::containers.end()) {
1480 while (retrieveDemandElements(NamespaceIDs::containers, prefix + "_" + toString(counter), false) != nullptr) {
1481 counter++;
1482 }
1483 } else if (std::find(NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end(), tag) != NamespaceIDs::vehicles.end()) {
1484 while (retrieveDemandElements(NamespaceIDs::vehicles, prefix + "_" + toString(counter), false) != nullptr) {
1485 counter++;
1486 }
1487 } else {
1488 while (retrieveDemandElement(tag, prefix + "_" + toString(counter), false) != nullptr) {
1489 counter++;
1490 }
1491 }
1492 // return new element ID
1493 return (prefix + "_" + toString(counter));
1494
1495}
1496
1497
1500 auto it = myDemandElementIDs.at(SUMO_TAG_VTYPE).find(DEFAULT_VTYPE_ID);
1501 if (it != myDemandElementIDs.at(SUMO_TAG_VTYPE).end()) {
1502 return it->second;
1503 }
1504 throw ProcessError(TL("Default vType doesn't exist"));
1505}
1506
1507
1508void
1510 // clear elements in grid
1511 for (const auto& demandElementsTags : myDemandElements) {
1512 for (const auto& demandElement : demandElementsTags.second) {
1513 myNet->removeGLObjectFromGrid(demandElement.second);
1514 }
1515 }
1516 // iterate over myDemandElements and clear all demand elements
1517 for (auto& demandElements : myDemandElements) {
1518 demandElements.second.clear();
1519 }
1520 for (auto& demandElements : myDemandElementIDs) {
1521 demandElements.second.clear();
1522 }
1523}
1524
1525
1526void
1528 const auto tag = demandElement->getTagProperty().getTag();
1529 const auto it = myDemandElementIDs.at(tag).find(demandElement->getID());
1530 if (it == myDemandElementIDs.at(tag).end()) {
1531 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' doesn't exist in AttributeCarriers.demandElements");
1532 } else {
1533 // remove from container, set new Id, and insert it again
1534 myDemandElementIDs.at(tag).erase(it);
1535 // set microsim ID
1536 demandElement->setMicrosimID(newID);
1537 myDemandElementIDs.at(tag)[newID] = demandElement;
1538 }
1539}
1540
1541
1542void
1544 // Create default vehicle Type (it has to be created here due myViewNet was previously nullptr)
1545 GNEVType* defaultVehicleType = new GNEVType(myNet, DEFAULT_VTYPE_ID, SVC_PASSENGER);
1546 myDemandElements.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getGUIGlObject(), defaultVehicleType));
1547 myDemandElementIDs.at(defaultVehicleType->getTagProperty().getTag()).insert(std::make_pair(defaultVehicleType->getID(), defaultVehicleType));
1548 defaultVehicleType->incRef("GNENet::DEFAULT_VEHTYPE");
1549
1550 // Create default Bike Type (it has to be created here due myViewNet was previously nullptr)
1551 GNEVType* defaultBikeType = new GNEVType(myNet, DEFAULT_BIKETYPE_ID, SVC_BICYCLE);
1552 myDemandElements.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getGUIGlObject(), defaultBikeType));
1553 myDemandElementIDs.at(defaultBikeType->getTagProperty().getTag()).insert(std::make_pair(defaultBikeType->getID(), defaultBikeType));
1554 defaultBikeType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1555 defaultBikeType->incRef("GNENet::DEFAULT_BIKETYPE_ID");
1556
1557 // Create default taxi Type (it has to be created here due myViewNet was previously nullptr)
1558 GNEVType* defaultTaxiType = new GNEVType(myNet, DEFAULT_TAXITYPE_ID, SVC_TAXI);
1559 myDemandElements.at(defaultTaxiType->getTagProperty().getTag()).insert(std::make_pair(defaultTaxiType->getGUIGlObject(), defaultTaxiType));
1560 myDemandElementIDs.at(defaultTaxiType->getTagProperty().getTag()).insert(std::make_pair(defaultTaxiType->getID(), defaultTaxiType));
1561 defaultTaxiType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1562 defaultTaxiType->incRef("GNENet::DEFAULT_TAXITYPE_ID");
1563
1564 // Create default rail Type (it has to be created here due myViewNet was previously nullptr)
1565 GNEVType* defaultRailType = new GNEVType(myNet, DEFAULT_RAILTYPE_ID, SVC_RAIL);
1566 myDemandElements.at(defaultRailType->getTagProperty().getTag()).insert(std::make_pair(defaultRailType->getGUIGlObject(), defaultRailType));
1567 myDemandElementIDs.at(defaultRailType->getTagProperty().getTag()).insert(std::make_pair(defaultRailType->getID(), defaultRailType));
1568 defaultRailType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1569 defaultRailType->incRef("GNENet::DEFAULT_RAILTYPE_ID");
1570
1571 // Create default person Type (it has to be created here due myViewNet was previously nullptr)
1572 GNEVType* defaultPersonType = new GNEVType(myNet, DEFAULT_PEDTYPE_ID, SVC_PEDESTRIAN);
1573 myDemandElements.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getGUIGlObject(), defaultPersonType));
1574 myDemandElementIDs.at(defaultPersonType->getTagProperty().getTag()).insert(std::make_pair(defaultPersonType->getID(), defaultPersonType));
1575 defaultPersonType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1576 defaultPersonType->incRef("GNENet::DEFAULT_PEDTYPE_ID");
1577
1578 // Create default container Type (it has to be created here due myViewNet was previously nullptr)
1579 GNEVType* defaultContainerType = new GNEVType(myNet, DEFAULT_CONTAINERTYPE_ID, SVC_IGNORING);
1580 myDemandElements.at(defaultContainerType->getTagProperty().getTag()).insert(std::make_pair(defaultContainerType->getGUIGlObject(), defaultContainerType));
1581 myDemandElementIDs.at(defaultContainerType->getTagProperty().getTag()).insert(std::make_pair(defaultContainerType->getID(), defaultContainerType));
1582 defaultContainerType->parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
1583 defaultContainerType->incRef("GNENet::DEFAULT_CONTAINERTYPE_ID");
1584}
1585
1586
1587int
1589 return myStopIndex++;
1590}
1591
1592
1593int
1595 int counter = 0;
1596 for (const auto& demandElementsTags : myDemandElements) {
1597 for (const auto& demandElement : demandElementsTags.second) {
1598 if (demandElement.second->isAttributeCarrierSelected()) {
1599 counter++;
1600 }
1601 }
1602 }
1603 return counter;
1604}
1605
1606
1607int
1609 int counter = 0;
1610 // iterate over routes
1611 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1612 if (route.second->isAttributeCarrierSelected()) {
1613 counter++;
1614 }
1615 }
1616 // iterate over vehicles with embedded routes
1617 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1618 if (vehicle.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1619 counter++;
1620 }
1621 }
1622 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1623 if (flow.second->getChildDemandElements().front()->isAttributeCarrierSelected()) {
1624 counter++;
1625 }
1626 }
1627 return counter;
1628}
1629
1630
1631int
1633 int counter = 0;
1634 // iterate over all vehicles and flows
1635 for (const auto& vehicle : myDemandElements.at(SUMO_TAG_VEHICLE)) {
1636 if (vehicle.second->isAttributeCarrierSelected()) {
1637 counter++;
1638 }
1639 }
1640 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1641 if (trip.second->isAttributeCarrierSelected()) {
1642 counter++;
1643 }
1644 }
1645 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1646 if (vehicle.second->isAttributeCarrierSelected()) {
1647 counter++;
1648 }
1649 }
1650 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1651 if (flow.second->isAttributeCarrierSelected()) {
1652 counter++;
1653 }
1654 }
1655 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_ROUTE)) {
1656 if (flow.second->isAttributeCarrierSelected()) {
1657 counter++;
1658 }
1659 }
1660 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1661 if (flow.second->isAttributeCarrierSelected()) {
1662 counter++;
1663 }
1664 }
1665 return counter;
1666}
1667
1668
1669int
1671 int counter = 0;
1672 // iterate over all persons
1673 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1674 if (person.second->isAttributeCarrierSelected()) {
1675 counter++;
1676 }
1677 }
1678 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1679 if (personFlow.second->isAttributeCarrierSelected()) {
1680 counter++;
1681 }
1682 }
1683 return counter;
1684}
1685
1686
1687int
1689 int counter = 0;
1690 // iterate over all person plans
1691 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1692 for (const auto& personPlan : person.second->getChildDemandElements()) {
1693 if (personPlan->getTagProperty().isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1694 counter++;
1695 }
1696 }
1697 }
1698 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1699 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1700 if (personPlan->getTagProperty().isPlanPersonTrip() && personPlan->isAttributeCarrierSelected()) {
1701 counter++;
1702 }
1703 }
1704 }
1705 return counter;
1706}
1707
1708
1709int
1711 int counter = 0;
1712 // iterate over all person plans
1713 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1714 for (const auto& personPlan : person.second->getChildDemandElements()) {
1715 if (personPlan->getTagProperty().isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1716 counter++;
1717 }
1718 }
1719 }
1720 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1721 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1722 if (personPlan->getTagProperty().isPlanWalk() && personPlan->isAttributeCarrierSelected()) {
1723 counter++;
1724 }
1725 }
1726 }
1727 return counter;
1728}
1729
1730
1731int
1733 int counter = 0;
1734 // iterate over all person plans
1735 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1736 for (const auto& personPlan : person.second->getChildDemandElements()) {
1737 if (personPlan->getTagProperty().isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1738 counter++;
1739 }
1740 }
1741 }
1742 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1743 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1744 if (personPlan->getTagProperty().isPlanRide() && personPlan->isAttributeCarrierSelected()) {
1745 counter++;
1746 }
1747 }
1748 }
1749 return counter;
1750}
1751
1752
1753int
1755 int counter = 0;
1756 // iterate over all containers
1757 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1758 if (container.second->isAttributeCarrierSelected()) {
1759 counter++;
1760 }
1761 }
1762 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1763 if (containerFlow.second->isAttributeCarrierSelected()) {
1764 counter++;
1765 }
1766 }
1767 return counter;
1768}
1769
1770
1771int
1773 int counter = 0;
1774 // iterate over all container plans
1775 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1776 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1777 if (containerPlan->getTagProperty().isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1778 counter++;
1779 }
1780 }
1781 }
1782 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1783 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1784 if (containerPlan->getTagProperty().isPlanTransport() && containerPlan->isAttributeCarrierSelected()) {
1785 counter++;
1786 }
1787 }
1788 }
1789 return counter;
1790}
1791
1792
1793int
1795 int counter = 0;
1796 // iterate over all container plans
1797 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1798 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1799 if (containerPlan->getTagProperty().isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1800 counter++;
1801 }
1802 }
1803 }
1804 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1805 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1806 if (containerPlan->getTagProperty().isPlanTranship() && containerPlan->isAttributeCarrierSelected()) {
1807 counter++;
1808 }
1809 }
1810 }
1811 return counter;
1812}
1813
1814
1815int
1817 int counter = 0;
1818 // iterate over routes
1819 for (const auto& route : myDemandElements.at(SUMO_TAG_ROUTE)) {
1820 if (route.second->isAttributeCarrierSelected()) {
1821 counter++;
1822 }
1823 }
1824 // vehicles
1825 for (const auto& trip : myDemandElements.at(SUMO_TAG_TRIP)) {
1826 for (const auto& stop : trip.second->getChildDemandElements()) {
1827 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1828 counter++;
1829 }
1830 }
1831 }
1832 for (const auto& vehicle : myDemandElements.at(GNE_TAG_VEHICLE_WITHROUTE)) {
1833 for (const auto& stop : vehicle.second->getChildDemandElements().front()->getChildDemandElements()) {
1834 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1835 counter++;
1836 }
1837 }
1838 }
1839 for (const auto& flow : myDemandElements.at(SUMO_TAG_FLOW)) {
1840 for (const auto& stop : flow.second->getChildDemandElements()) {
1841 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1842 counter++;
1843 }
1844 }
1845 }
1846 for (const auto& flow : myDemandElements.at(GNE_TAG_FLOW_WITHROUTE)) {
1847 for (const auto& stop : flow.second->getChildDemandElements().front()->getChildDemandElements()) {
1848 if (stop->getTagProperty().isVehicleStop() && stop->isAttributeCarrierSelected()) {
1849 counter++;
1850 }
1851 }
1852 }
1853 // persons
1854 for (const auto& person : myDemandElements.at(SUMO_TAG_PERSON)) {
1855 for (const auto& personPlan : person.second->getChildDemandElements()) {
1856 if (personPlan->getTagProperty().isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1857 counter++;
1858 }
1859 }
1860 }
1861 for (const auto& personFlow : myDemandElements.at(SUMO_TAG_PERSONFLOW)) {
1862 for (const auto& personPlan : personFlow.second->getChildDemandElements()) {
1863 if (personPlan->getTagProperty().isPlanStopPerson() && personPlan->isAttributeCarrierSelected()) {
1864 counter++;
1865 }
1866 }
1867 }
1868 // containers
1869 for (const auto& container : myDemandElements.at(SUMO_TAG_CONTAINER)) {
1870 for (const auto& containerPlan : container.second->getChildDemandElements()) {
1871 if (containerPlan->getTagProperty().isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1872 counter++;
1873 }
1874 }
1875 }
1876 for (const auto& containerFlow : myDemandElements.at(SUMO_TAG_CONTAINERFLOW)) {
1877 for (const auto& containerPlan : containerFlow.second->getChildDemandElements()) {
1878 if (containerPlan->getTagProperty().isPlanStopContainer() && containerPlan->isAttributeCarrierSelected()) {
1879 counter++;
1880 }
1881 }
1882 }
1883 return counter;
1884}
1885
1886
1888GNENetHelper::AttributeCarriers::retrieveDataSet(const std::string& id, bool hardFail) const {
1889 for (const auto& dataSet : myDataSets) {
1890 if (dataSet.second->getID() == id) {
1891 return dataSet.second;
1892 }
1893 }
1894 if (hardFail) {
1895 throw ProcessError("Attempted to retrieve non-existant data set");
1896 } else {
1897 return nullptr;
1898 }
1899}
1900
1901
1902const std::map<const std::string, GNEDataSet*>&
1904 return myDataSets;
1905}
1906
1907
1908std::string
1910 const std::string dataSetTagStr = toString(SUMO_TAG_DATASET);
1911 int counter = 0;
1912 while (retrieveDataSet(prefix + dataSetTagStr + "_" + toString(counter), false) != nullptr) {
1913 counter++;
1914 }
1915 return (prefix + dataSetTagStr + "_" + toString(counter));
1916}
1917
1918
1921 if (myDataIntervals.count(AC)) {
1922 return myDataIntervals.at(AC);
1923 } else if (hardFail) {
1924 throw ProcessError("Attempted to retrieve non-existant data interval");
1925 } else {
1926 return nullptr;
1927 }
1928}
1929
1930
1931const std::map<const GNEAttributeCarrier*, GNEDataInterval*>&
1933 return myDataIntervals;
1934}
1935
1936
1937void
1939 if (myDataIntervals.count(AC) > 0) {
1940 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' already exist");
1941 } else {
1942 myDataIntervals[AC] = dataInterval;
1943 }
1944 // mark interval toolbar for update
1945 myNet->getViewNet()->getIntervalBar().markForUpdate();
1946}
1947
1948
1949void
1951 const auto finder = myDataIntervals.find(dataInterval);
1952 if (finder == myDataIntervals.end()) {
1953 throw ProcessError(dataInterval->getTagStr() + " with ID='" + dataInterval->getID() + "' wasn't previously inserted");
1954 } else {
1955 myDataIntervals.erase(finder);
1956 }
1957 // remove it from inspected elements and GNEElementTree
1958 myNet->getViewNet()->removeFromAttributeCarrierInspected(dataInterval);
1959 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataInterval);
1960 // mark interval toolbar for update
1961 myNet->getViewNet()->getIntervalBar().markForUpdate();
1962}
1963
1964
1967 // iterate over all genericDatas
1968 for (const auto& genericDataTag : myGenericDatas) {
1969 auto it = genericDataTag.second.find(glObject);
1970 if (it != genericDataTag.second.end()) {
1971 return it->second;
1972 }
1973 }
1974 if (hardFail) {
1975 throw ProcessError("Attempted to retrieve non-existant generic (glObject)");
1976 } else {
1977 return nullptr;
1978 }
1979}
1980
1981
1982std::vector<GNEGenericData*>
1984 std::vector<GNEGenericData*> result;
1985 // returns generic datas depending of selection
1986 for (const auto& genericDataTag : myGenericDatas) {
1987 for (const auto& genericData : genericDataTag.second) {
1988 if (genericData.second->isAttributeCarrierSelected()) {
1989 result.push_back(genericData.second);
1990 }
1991 }
1992 }
1993 return result;
1994}
1995
1996
1997const std::map<SumoXMLTag, std::map<const GUIGlObject*, GNEGenericData*> >&
1999 return myGenericDatas;
2000}
2001
2002
2003std::vector<GNEGenericData*>
2004GNENetHelper::AttributeCarriers::retrieveGenericDatas(const SumoXMLTag genericDataTag, const double begin, const double end) {
2005 // declare generic data vector
2006 std::vector<GNEGenericData*> genericDatas;
2007 // iterate over all data sets
2008 for (const auto& genericData : myGenericDatas.at(genericDataTag)) {
2009 // check interval
2010 if ((genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2011 (genericData.second->getDataIntervalParent()->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2012 genericDatas.push_back(genericData.second);
2013 }
2014 }
2015 return genericDatas;
2016}
2017
2018
2019int
2021 int counter = 0;
2022 // iterate over all generic datas
2023 for (const auto& genericDataTag : myGenericDatas) {
2024 counter += (int)genericDataTag.second.size();
2025 }
2026 return counter;
2027}
2028
2029
2030int
2032 int counter = 0;
2033 // iterate over all edgeDatas
2034 for (const auto& genericData : myGenericDatas.at(GNE_TAG_EDGEREL_SINGLE)) {
2035 if (genericData.second->isAttributeCarrierSelected()) {
2036 counter++;
2037 }
2038 }
2039 return counter;
2040}
2041
2042
2043int
2045 int counter = 0;
2046 // iterate over all edgeDatas
2047 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_EDGEREL)) {
2048 if (genericData.second->isAttributeCarrierSelected()) {
2049 counter++;
2050 }
2051 }
2052 return counter;
2053}
2054
2055
2056int
2058 int counter = 0;
2059 // iterate over all edgeDatas
2060 for (const auto& genericData : myGenericDatas.at(SUMO_TAG_TAZREL)) {
2061 if (genericData.second->isAttributeCarrierSelected()) {
2062 counter++;
2063 }
2064 }
2065 return counter;
2066}
2067
2068
2069void
2071 if (myGenericDatas.at(genericData->getTagProperty().getTag()).count(genericData->getGUIGlObject()) > 0) {
2072 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' already exist");
2073 } else {
2074 myGenericDatas.at(genericData->getTagProperty().getTag()).insert(std::make_pair(genericData->getGUIGlObject(), genericData));
2075 }
2076 // mark interval toolbar for update
2077 myNet->getViewNet()->getIntervalBar().markForUpdate();
2078}
2079
2080
2081void
2083 const auto finder = myGenericDatas.at(genericData->getTagProperty().getTag()).find(genericData);
2084 if (finder == myGenericDatas.at(genericData->getTagProperty().getTag()).end()) {
2085 throw ProcessError(genericData->getTagStr() + " with ID='" + genericData->getID() + "' wasn't previously inserted");
2086 } else {
2087 myGenericDatas.at(genericData->getTagProperty().getTag()).erase(finder);
2088 }
2089 // remove it from inspected elements and GNEElementTree
2090 myNet->getViewNet()->removeFromAttributeCarrierInspected(genericData);
2091 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(genericData);
2092 // mark interval toolbar for update
2093 myNet->getViewNet()->getIntervalBar().markForUpdate();
2094}
2095
2096
2097std::set<std::string>
2098GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& genericDataTag, const double begin, const double end) const {
2099 // declare solution
2100 std::set<std::string> attributesSolution;
2101 // declare generic data vector
2102 std::vector<GNEGenericData*> genericDatas;
2103 // iterate over all data sets
2104 for (const auto& interval : myDataIntervals) {
2105 // check interval
2106 if ((interval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) && (interval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2107 // iterate over generic datas
2108 for (const auto& genericData : interval.second->getGenericDataChildren()) {
2109 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2110 genericDatas.push_back(genericData);
2111 }
2112 }
2113 }
2114 }
2115 // iterate over generic datas
2116 for (const auto& genericData : genericDatas) {
2117 for (const auto& attribute : genericData->getParametersMap()) {
2118 attributesSolution.insert(attribute.first);
2119 }
2120 }
2121 return attributesSolution;
2122}
2123
2124
2125std::set<std::string>
2126GNENetHelper::AttributeCarriers::retrieveGenericDataParameters(const std::string& dataSetID, const std::string& genericDataTag,
2127 const std::string& beginStr, const std::string& endStr) const {
2128 // declare solution
2129 std::set<std::string> attributesSolution;
2130 // vector of data sets and intervals
2131 std::vector<GNEDataSet*> dataSets;
2132 std::vector<GNEDataInterval*> dataIntervals;
2133 // get dataSet
2134 GNEDataSet* retrievedDataSet = retrieveDataSet(dataSetID, false);
2135 // if dataSetID is empty, return all parameters
2136 if (dataSetID.empty()) {
2137 // add all data sets
2138 dataSets.reserve(myDataSets.size());
2139 for (const auto& dataSet : myDataSets) {
2140 dataSets.push_back(dataSet.second);
2141 }
2142 } else if (retrievedDataSet) {
2143 dataSets.push_back(retrievedDataSet);
2144 } else {
2145 return attributesSolution;
2146 }
2147 // now continue with data intervals
2148 int numberOfIntervals = 0;
2149 for (const auto& dataSet : dataSets) {
2150 numberOfIntervals += (int)dataSet->getDataIntervalChildren().size();
2151 }
2152 // resize dataIntervals
2153 dataIntervals.reserve(numberOfIntervals);
2154 // add intervals
2155 for (const auto& dataSet : dataSets) {
2156 for (const auto& dataInterval : dataSet->getDataIntervalChildren()) {
2157 // continue depending of begin and end
2158 if (beginStr.empty() && endStr.empty()) {
2159 dataIntervals.push_back(dataInterval.second);
2160 } else if (endStr.empty()) {
2161 // parse begin
2162 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2163 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) {
2164 dataIntervals.push_back(dataInterval.second);
2165 }
2166 } else if (beginStr.empty()) {
2167 // parse end
2168 const double end = GNEAttributeCarrier::parse<double>(endStr);
2169 if (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end) {
2170 dataIntervals.push_back(dataInterval.second);
2171 }
2172 } else {
2173 // parse both begin end
2174 const double begin = GNEAttributeCarrier::parse<double>(beginStr);
2175 const double end = GNEAttributeCarrier::parse<double>(endStr);
2176 if ((dataInterval.second->getAttributeDouble(SUMO_ATTR_BEGIN) >= begin) &&
2177 (dataInterval.second->getAttributeDouble(SUMO_ATTR_END) <= end)) {
2178 dataIntervals.push_back(dataInterval.second);
2179 }
2180 }
2181 }
2182 }
2183 // finally iterate over intervals and get attributes
2184 for (const auto& dataInterval : dataIntervals) {
2185 for (const auto& genericData : dataInterval->getGenericDataChildren()) {
2186 // check generic data tag
2187 if (genericDataTag.empty() || (genericData->getTagProperty().getTagStr() == genericDataTag)) {
2188 for (const auto& attribute : genericData->getParametersMap()) {
2189 attributesSolution.insert(attribute.first);
2190 }
2191 }
2192 }
2193 }
2194 return attributesSolution;
2195}
2196
2197
2199GNENetHelper::AttributeCarriers::retrieveMeanData(SumoXMLTag type, const std::string& id, bool hardFail) const {
2200 for (const auto& meanData : myMeanDatas.at(type)) {
2201 if (meanData.second->getID() == id) {
2202 return meanData.second;
2203 }
2204 }
2205 if (hardFail) {
2206 throw ProcessError("Attempted to retrieve non-existant meanData (string)");
2207 } else {
2208 return nullptr;
2209 }
2210}
2211
2212
2213const std::map<SumoXMLTag, std::map<const std::string, GNEMeanData*> >&
2215 return myMeanDatas;
2216}
2217
2218
2219int
2221 int counter = 0;
2222 for (const auto& meanDatasTag : myMeanDatas) {
2223 counter += (int)meanDatasTag.second.size();
2224 }
2225 return counter;
2226}
2227
2228
2229void
2231 // iterate over myMeanDatas and clear all meanDatas
2232 for (auto& meanDatas : myMeanDatas) {
2233 meanDatas.second.clear();
2234 }
2235}
2236
2237
2238std::string
2240 // obtain option container
2241 const auto& neteditOptions = OptionsCont::getOptions();
2242 // get prefix
2243 std::string prefix;
2244 if (tag == SUMO_TAG_MEANDATA_EDGE) {
2245 prefix = neteditOptions.getString("meanDataEdge-prefix");
2246 } else if (tag == SUMO_TAG_MEANDATA_LANE) {
2247 prefix = neteditOptions.getString("meanDataLane-prefix");
2248 }
2249 int counter = 0;
2250 while (retrieveMeanData(tag, prefix + "_" + toString(counter), false) != nullptr) {
2251 counter++;
2252 }
2253 return (prefix + "_" + toString(counter));
2254}
2255
2256
2257void
2259 myNet->getNetBuilder()->getNodeCont().insert(junction->getNBNode());
2260 registerJunction(junction);
2261}
2262
2263
2264void
2266 // remove it from inspected elements and GNEElementTree
2267 myNet->getViewNet()->removeFromAttributeCarrierInspected(junction);
2268 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(junction);
2269 // Remove from grid and container
2270 myNet->removeGLObjectFromGrid(junction);
2271 myJunctions.erase(junction->getMicrosimID());
2272 myNet->getNetBuilder()->getNodeCont().extract(junction->getNBNode());
2273 junction->decRef("GNENet::deleteSingleJunction");
2274 junction->setResponsible(true);
2275}
2276
2277
2278void
2280 // get pointer to create edge frame
2281 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2282 // insert in myEdgeTypes
2283 myEdgeTypes[edgeType->getMicrosimID()] = edgeType;
2284 // update edge selector
2285 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
2286 myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2287 }
2288 // set current edge type inspected
2289 createEdgeFrame->getEdgeTypeSelector()->setCurrentEdgeType(edgeType);
2290}
2291
2292
2293void
2295 // get pointer to create edge frame
2296 const auto& createEdgeFrame = myNet->getViewNet()->getViewParent()->getCreateEdgeFrame();
2297 // remove it from inspected elements and GNEElementTree
2298 myNet->getViewNet()->removeFromAttributeCarrierInspected(edgeType);
2299 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edgeType);
2300 // remove from edge types
2301 myEdgeTypes.erase(edgeType->getMicrosimID());
2302 // check if this is the selected edge type in edgeSelector
2303 if (createEdgeFrame->getEdgeTypeSelector()->getEdgeTypeSelected() == edgeType) {
2304 createEdgeFrame->getEdgeTypeSelector()->clearEdgeTypeSelected();
2305 }
2306 // update edge selector
2307 createEdgeFrame->getEdgeTypeSelector()->refreshEdgeTypeSelector();
2308}
2309
2310
2311void
2313 NBEdge* nbe = edge->getNBEdge();
2314 myNet->getNetBuilder()->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
2315 // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
2316 nbe->getFromNode()->addOutgoingEdge(nbe);
2317 nbe->getToNode()->addIncomingEdge(nbe);
2318 // register edge
2319 registerEdge(edge);
2320}
2321
2322
2323void
2325 // remove it from inspected elements and GNEElementTree
2326 myNet->getViewNet()->removeFromAttributeCarrierInspected(edge);
2327 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(edge);
2328 // remove edge from visual grid and container
2329 myNet->removeGLObjectFromGrid(edge);
2330 myEdges.erase(edge->getMicrosimID());
2331 // remove all lanes
2332 for (const auto& lane : edge->getLanes()) {
2333 deleteLane(lane);
2334 }
2335 // extract edge of district container
2336 myNet->getNetBuilder()->getEdgeCont().extract(myNet->getNetBuilder()->getDistrictCont(), edge->getNBEdge());
2337 edge->decRef("GNENet::deleteSingleEdge");
2338 edge->setResponsible(true);
2339 // Remove refrences from GNEJunctions
2341 edge->getToJunction()->removeIncomingGNEEdge(edge);
2342 // update boundaries of both junctions (to remove it from Grid)
2345 // get template editor
2346 GNEInspectorFrame::TemplateEditor* templateEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getTemplateEditor();
2347 // check if we have to remove template
2348 if (templateEditor->getEdgeTemplate() && (templateEditor->getEdgeTemplate()->getID() == edge->getID())) {
2349 templateEditor->setEdgeTemplate(nullptr);
2350 }
2351}
2352
2353
2354void
2356 if (myLanes.count(lane->getGUIGlObject()) > 0) {
2357 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' already exist");
2358 } else {
2359 myLanes[lane->getGUIGlObject()] = lane;
2360 }
2361}
2362
2363
2364void
2366 const auto finder = myLanes.find(lane->getGUIGlObject());
2367 if (finder == myLanes.end()) {
2368 throw ProcessError(lane->getTagStr() + " with ID='" + lane->getID() + "' wasn't previously inserted");
2369 } else {
2370 myLanes.erase(finder);
2371 }
2372 // remove it from inspected elements and GNEElementTree
2373 myNet->getViewNet()->removeFromAttributeCarrierInspected(lane);
2374 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(lane);
2375}
2376
2377
2378void
2380 if (myCrossings.count(crossing->getGUIGlObject()) > 0) {
2381 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' already exist");
2382 } else {
2383 myCrossings[crossing->getGUIGlObject()] = crossing;
2384 }
2385}
2386
2387
2388void
2390 const auto finder = myCrossings.find(crossing->getGUIGlObject());
2391 if (finder == myCrossings.end()) {
2392 throw ProcessError(crossing->getTagStr() + " with ID='" + crossing->getID() + "' wasn't previously inserted");
2393 } else {
2394 myCrossings.erase(finder);
2395 }
2396 // remove it from inspected elements and GNEElementTree
2397 myNet->getViewNet()->removeFromAttributeCarrierInspected(crossing);
2398 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(crossing);
2399}
2400
2401
2402void
2404 if (myWalkingAreas.count(walkingArea->getGUIGlObject()) > 0) {
2405 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' already exist");
2406 } else {
2407 myWalkingAreas[walkingArea->getGUIGlObject()] = walkingArea;
2408 }
2409}
2410
2411
2412void
2414 const auto finder = myWalkingAreas.find(walkingArea->getGUIGlObject());
2415 if (finder == myWalkingAreas.end()) {
2416 throw ProcessError(walkingArea->getTagStr() + " with ID='" + walkingArea->getID() + "' wasn't previously inserted");
2417 } else {
2418 myWalkingAreas.erase(finder);
2419 }
2420 // remove it from inspected elements and GNEElementTree
2421 myNet->getViewNet()->removeFromAttributeCarrierInspected(walkingArea);
2422 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(walkingArea);
2423}
2424
2425
2426void
2428 if (myConnections.count(connection->getGUIGlObject()) > 0) {
2429 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' already exist");
2430 } else {
2431 myConnections[connection->getGUIGlObject()] = connection;
2432 }
2433}
2434
2435
2436void
2438 const auto finder = myConnections.find(connection->getGUIGlObject());
2439 if (finder == myConnections.end()) {
2440 throw ProcessError(connection->getTagStr() + " with ID='" + connection->getID() + "' wasn't previously inserted");
2441 } else {
2442 myConnections.erase(finder);
2443 }
2444}
2445
2446
2447void
2449 if (myInternalLanes.count(internalLane->getGUIGlObject()) > 0) {
2450 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' already exist");
2451 } else {
2452 myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
2453 }
2454}
2455
2456
2457void
2459 const auto finder = myInternalLanes.find(internalLane->getGUIGlObject());
2460 if (finder == myInternalLanes.end()) {
2461 throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
2462 } else {
2463 myInternalLanes.erase(finder);
2464 }
2465}
2466
2467
2468void
2470 const auto tag = additional->getTagProperty().getTag();
2471 if (myAdditionals.at(tag).count(additional) > 0) {
2472 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' already exist");
2473 } else {
2474 myAdditionals.at(tag)[additional->getGUIGlObject()] = additional;
2475 if (additional->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2476 myAdditionalIDs.at(tag)[additional->getID()] = additional;
2477 }
2478 }
2479 // add element in grid
2480 if (additional->getTagProperty().isPlacedInRTree()) {
2481 myNet->addGLObjectIntoGrid(additional);
2482 }
2483 // update geometry after insertion of additionals if myUpdateGeometryEnabled is enabled
2484 if (myNet->isUpdateGeometryEnabled()) {
2485 additional->updateGeometry();
2486 }
2487 // additionals has to be saved
2488 myNet->getSavingStatus()->requireSaveAdditionals();
2489}
2490
2491
2492void
2494 const auto tag = additional->getTagProperty().getTag();
2495 // find demanElement in additionalTag
2496 auto itFind = myAdditionals.at(tag).find(additional->getGUIGlObject());
2497 // check if additional was previously inserted
2498 if (itFind == myAdditionals.at(tag).end()) {
2499 throw ProcessError(additional->getTagStr() + " with ID='" + additional->getID() + "' wasn't previously inserted");
2500 }
2501 // remove it from inspected elements and GNEElementTree
2502 myNet->getViewNet()->removeFromAttributeCarrierInspected(additional);
2503 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(additional);
2504 // remove from both container
2505 myAdditionals.at(tag).erase(itFind);
2506 if (additional->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2507 myAdditionalIDs.at(tag).erase(myAdditionalIDs.at(tag).find(additional->getID()));
2508 }
2509 // remove element from grid
2510 if (additional->getTagProperty().isPlacedInRTree()) {
2511 myNet->removeGLObjectFromGrid(additional);
2512 }
2513 // delete path element
2514 myNet->getNetworkPathManager()->removePath(additional);
2515 myNet->getDemandPathManager()->removePath(additional);
2516 // additionals has to be saved
2517 myNet->getSavingStatus()->requireSaveAdditionals();
2518}
2519
2520
2521void
2523 const auto tag = demandElement->getTagProperty().getTag();
2524 if (myDemandElements.at(tag).count(demandElement) > 0) {
2525 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' already exist");
2526 } else {
2527 myDemandElements.at(tag)[demandElement->getGUIGlObject()] = demandElement;
2528 if (demandElement->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2529 myDemandElementIDs.at(tag)[demandElement->getID()] = demandElement;
2530 }
2531 }
2532 // add element in grid
2533 myNet->addGLObjectIntoGrid(demandElement);
2534 // update geometry after insertion of demandElements if myUpdateGeometryEnabled is enabled
2535 if (myNet->isUpdateGeometryEnabled()) {
2536 demandElement->updateGeometry();
2537 }
2538 // compute path element
2539 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2540 demandElement->computePathElement();
2541 }
2542 // update demand elements frames
2543 updateDemandElementFrames(demandElement->getTagProperty());
2544 // demandElements has to be saved
2545 myNet->getSavingStatus()->requireSaveDemandElements();
2546}
2547
2548
2549void
2551 const auto tag = demandElement->getTagProperty().getTag();
2552 auto viewParent = myNet->getViewNet()->getViewParent();
2553 // find demanElement in demandElementTag
2554 auto itFind = myDemandElements.at(tag).find(demandElement->getGUIGlObject());
2555 // check if demandElement was previously inserted
2556 if (itFind == myDemandElements.at(tag).end()) {
2557 throw ProcessError(demandElement->getTagStr() + " with ID='" + demandElement->getID() + "' wasn't previously inserted");
2558 }
2559 // remove it from inspected elements and GNEElementTree
2560 myNet->getViewNet()->removeFromAttributeCarrierInspected(demandElement);
2561 viewParent->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(demandElement);
2562 viewParent->getPersonPlanFrame()->getPersonHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2563 viewParent->getContainerPlanFrame()->getContainerHierarchy()->removeCurrentEditedAttributeCarrier(demandElement);
2564 if (viewParent->getRouteDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2565 viewParent->getRouteDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2566 }
2567 if (viewParent->getTypeDistributionFrame()->getDistributionSelector()->getCurrentDistribution() == demandElement) {
2568 viewParent->getTypeDistributionFrame()->getDistributionSelector()->setDistribution(nullptr);
2569 }
2570 // if is the last inserted route, remove it from GNEViewNet
2571 if (myNet->getViewNet()->getLastCreatedRoute() == demandElement) {
2572 myNet->getViewNet()->setLastCreatedRoute(nullptr);
2573 }
2574 // erase it from container
2575 myDemandElements.at(tag).erase(itFind);
2576 if (demandElement->getTagProperty().hasAttribute(SUMO_ATTR_ID)) {
2577 myDemandElementIDs.at(tag).erase(myDemandElementIDs.at(tag).find(demandElement->getID()));
2578 }
2579 // remove element from grid
2580 myNet->removeGLObjectFromGrid(demandElement);
2581 // delete path element
2582 myNet->getNetworkPathManager()->removePath(demandElement);
2583 myNet->getDemandPathManager()->removePath(demandElement);
2584 // check if update demand elements frames
2585 if (updateFrames) {
2586 updateDemandElementFrames(demandElement->getTagProperty());
2587 }
2588 // demandElements has to be saved
2589 myNet->getSavingStatus()->requireSaveDemandElements();
2590}
2591
2592
2593void
2595 if (myDataSets.count(dataSet->getID()) > 0) {
2596 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' already exist");
2597 } else {
2598 myDataSets[dataSet->getID()] = dataSet;
2599 }
2600 // dataSets has to be saved
2601 myNet->getSavingStatus()->requireSaveDataElements();
2602 // mark interval toolbar for update
2603 myNet->getViewNet()->getIntervalBar().markForUpdate();
2604}
2605
2606
2607void
2609 const auto finder = myDataSets.find(dataSet->getID());
2610 if (finder == myDataSets.end()) {
2611 throw ProcessError(dataSet->getTagStr() + " with ID='" + dataSet->getID() + "' wasn't previously inserted");
2612 } else {
2613 myDataSets.erase(finder);
2614 }
2615 // remove it from inspected elements and GNEElementTree
2616 myNet->getViewNet()->removeFromAttributeCarrierInspected(dataSet);
2617 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(dataSet);
2618 // dataSets has to be saved
2619 myNet->getSavingStatus()->requireSaveDataElements();
2620 // mark interval toolbar for update
2621 myNet->getViewNet()->getIntervalBar().markForUpdate();
2622}
2623
2624
2625void
2627 if (myMeanDatas.at(meanData->getTagProperty().getTag()).count(meanData->getID()) > 0) {
2628 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' already exist");
2629 } else {
2630 myMeanDatas.at(meanData->getTagProperty().getTag()).insert(std::make_pair(meanData->getID(), meanData));
2631 }
2632 // meanDatas has to be saved
2633 myNet->getSavingStatus()->requireSaveMeanDatas();
2634}
2635
2636
2637void
2639 // find demanElement in meanDataTag
2640 auto itFind = myMeanDatas.at(meanData->getTagProperty().getTag()).find(meanData->getID());
2641 // check if meanData was previously inserted
2642 if (itFind == myMeanDatas.at(meanData->getTagProperty().getTag()).end()) {
2643 throw ProcessError(meanData->getTagStr() + " with ID='" + meanData->getID() + "' wasn't previously inserted");
2644 }
2645 // remove it from inspected elements and GNEElementTree
2646 myNet->getViewNet()->removeFromAttributeCarrierInspected(meanData);
2647 myNet->getViewNet()->getViewParent()->getInspectorFrame()->getHierarchicalElementTree()->removeCurrentEditedAttributeCarrier(meanData);
2648 // remove from container
2649 myMeanDatas.at(meanData->getTagProperty().getTag()).erase(itFind);
2650 // remove element from grid
2651 if (meanData->getTagProperty().isPlacedInRTree()) {
2652 myNet->removeGLObjectFromGrid(meanData);
2653 }
2654 // meanDatas has to be saved
2655 myNet->getSavingStatus()->requireSaveMeanDatas();
2656}
2657
2658
2659void
2661 if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
2662 // continue depending of demand mode
2663 switch (myNet->getViewNet()->getEditModes().demandEditMode) {
2665 if (tagProperty.isType()) {
2666 myNet->getViewNet()->getViewParent()->getVehicleFrame()->getTypeSelector()->refreshDemandElementSelector();
2667 }
2668 break;
2670 if (tagProperty.isType()) {
2671 myNet->getViewNet()->getViewParent()->getTypeFrame()->getTypeSelector()->refreshTypeSelector(true);
2672 }
2673 break;
2675 if (tagProperty.isType()) {
2676 myNet->getViewNet()->getViewParent()->getTypeDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2677 }
2678 break;
2680 if (tagProperty.isRoute()) {
2681 myNet->getViewNet()->getViewParent()->getRouteDistributionFrame()->getDistributionSelector()->refreshDistributionSelector();
2682 }
2683 break;
2685 if (tagProperty.isType()) {
2686 myNet->getViewNet()->getViewParent()->getPersonFrame()->getTypeSelector()->refreshDemandElementSelector();
2687 }
2688 break;
2690 if (tagProperty.isPerson()) {
2691 myNet->getViewNet()->getViewParent()->getPersonPlanFrame()->getPersonSelector()->refreshDemandElementSelector();
2692 }
2693 break;
2695 if (tagProperty.isType()) {
2696 myNet->getViewNet()->getViewParent()->getContainerFrame()->getTypeSelector()->refreshDemandElementSelector();
2697 }
2698 break;
2700 if (tagProperty.isContainer()) {
2701 myNet->getViewNet()->getViewParent()->getContainerPlanFrame()->getContainerSelector()->refreshDemandElementSelector();
2702 }
2703 break;
2705 myNet->getViewNet()->getViewParent()->getStopFrame()->getStopParentSelector()->refreshDemandElementSelector();
2706 break;
2707 default:
2708 // nothing to update
2709 break;
2710 }
2711 }
2712}
2713
2714// ---------------------------------------------------------------------------
2715// GNENetHelper::SavingStatus - methods
2716// ---------------------------------------------------------------------------
2717
2720
2721
2722void
2724 mySumoConfigSaved = false;
2725}
2726
2727
2728void
2730 mySumoConfigSaved = true;
2731}
2732
2733
2734bool
2736 return mySumoConfigSaved;
2737}
2738
2739
2740
2741void
2743 myNeteditConfigSaved = false;
2744}
2745
2746
2747void
2749 myNeteditConfigSaved = true;
2750}
2751
2752
2753bool
2755 return myNeteditConfigSaved;
2756}
2757
2758
2759void
2761 myNetworkSaved = false;
2762 // implies requiere save netedit config and sumo config
2763 myNeteditConfigSaved = false;
2764 mySumoConfigSaved = false;
2765}
2766
2767
2768void
2770 myNetworkSaved = true;
2771}
2772
2773
2774bool
2776 return myNetworkSaved;
2777}
2778
2779
2780void
2782 myTLSSaved = false;
2783}
2784
2785
2786void
2788 myTLSSaved = true;
2789}
2790
2791
2792bool
2794 return myTLSSaved;
2795}
2796
2797
2798void
2800 myEdgeTypeSaved = false;
2801}
2802
2803
2804void
2806 myEdgeTypeSaved = true;
2807}
2808
2809
2810bool
2812 return myEdgeTypeSaved;
2813}
2814
2815
2816void
2818 myAdditionalSaved = false;
2819 // implies requiere save netedit config and sumo config
2820 myNeteditConfigSaved = false;
2821 mySumoConfigSaved = false;
2822}
2823
2824
2825void
2827 myAdditionalSaved = true;
2828}
2829
2830
2831bool
2833 return myAdditionalSaved;
2834}
2835
2836
2837void
2839 myDemandElementSaved = false;
2840 // implies requiere save netedit config and sumo config
2841 myNeteditConfigSaved = false;
2842 mySumoConfigSaved = false;
2843}
2844
2845
2846void
2848 myDemandElementSaved = true;
2849}
2850
2851
2852bool
2854 return myDemandElementSaved;
2855}
2856
2857
2858void
2860 myDataElementSaved = false;
2861 // implies requiere save netedit config and sumo config
2862 myNeteditConfigSaved = false;
2863 mySumoConfigSaved = false;
2864}
2865
2866
2867void
2869 myDataElementSaved = true;
2870}
2871
2872
2873bool
2875 return myDataElementSaved;
2876}
2877
2878
2879void
2881 myMeanDataElementSaved = false;
2882 // implies requiere save netedit config and sumo config
2883 myNeteditConfigSaved = false;
2884 mySumoConfigSaved = false;
2885}
2886
2887
2888void
2890 myMeanDataElementSaved = true;
2891}
2892
2893
2894bool
2896 return myMeanDataElementSaved;
2897}
2898
2899// ---------------------------------------------------------------------------
2900// GNENetHelper::GNEChange_ReplaceEdgeInTLS - methods
2901// ---------------------------------------------------------------------------
2902
2904 GNEChange(Supermode::NETWORK, true, false),
2905 myTllcont(tllcont),
2906 myReplaced(replaced),
2907 myBy(by) {
2908}
2909
2910
2912
2913
2914void
2916 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2917 myTllcont.replaceRemoved(myBy, -1, myReplaced, -1, true);
2918}
2919
2920
2921void
2923 // assuming this is only used for replacing incoming connections (GNENet::replaceIncomingEdge)
2924 myTllcont.replaceRemoved(myReplaced, -1, myBy, -1, true);
2925}
2926
2927
2928std::string
2930 return TL("Redo replace in TLS");
2931}
2932
2933
2934std::string
2936 return TL("Undo replace in TLS");
2937}
2938
2939
2940bool
2942 return myReplaced != myBy;
2943}
2944
2945/****************************************************************************/
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:43
GUISelectedStorage gSelected
A global holder of selected objects.
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TL(string)
Definition MsgHandler.h:315
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
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::set< std::string > DEFAULT_VTYPES
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
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ 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_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ 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_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_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
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ 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
begin/end of the 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_POILANE
Point of interest over Lane.
@ SUMO_TAG_DATASET
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ SUMO_TAG_PERSON
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ 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
@ GNE_ATTR_DEFAULT_VTYPE
Flag to check if VType is a default VType.
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
An Element which don't belong to GNENet but has influence in the simulation.
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
static const std::vector< GNETagProperties > getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans)
get tagProperties associated to the given GNETagProperties::TagType (NETWORKELEMENT,...
static const std::string True
true value in string format (used for comparing boolean values in getAttribute(......
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
static const std::vector< GNETagProperties > getTagPropertiesByMergingTag(SumoXMLTag mergingTag)
get tagProperties associated to the given merging tag
virtual GUIGlObject * getGUIGlObject()=0
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
An Element which don't belong to GNENet but has influence in the simulation.
virtual void updateGeometry()=0
update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
virtual void computePathElement()=0
compute pathElement
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:658
void setResponsible(bool newVal)
set responsibility for deleting internal structures
Definition GNEEdge.cpp:1530
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:779
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:1116
void setEdgeID(const std::string &newID)
set edge ID
Definition GNEEdge.cpp:2321
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:77
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:82
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNEEdge.cpp:652
An Element which don't belong to GNENet but has influence in the simulation.
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
const std::vector< 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)
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:622
An Element which don't belong to GNENet but has influence in the simulation.
Definition GNEMeanData.h:33
std::vector< GNEEdge * > retrieveEdges(GNEJunction *from, GNEJunction *to) const
get all edges by from and to GNEJunction
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)
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
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
std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEAdditional * > > myAdditionals
map with the tag and pointer to additional elements of net
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
const std::map< const GUIGlObject *, GNEWalkingArea * > & getWalkingAreas() const
get walkingAreas
void insertDataSet(GNEDataSet *dataSet)
Insert a data set in container.
int getNumberOfSelectedRides() const
get number of selected rides
void clearDemandElements()
clear demand elements
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
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
void clearEdgeTypes()
clear edgeTypes
const std::map< const GNEAttributeCarrier *, GNEDataInterval * > & getDataIntervals() const
get all data intervals of network
int getNumberOfSelectedTranships() const
get number of selected tranships
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
std::string generateDataSetID(const std::string &prefix) const
generate data set id
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::map< SumoXMLTag, std::map< const std::string, GNEDemandElement * > > myDemandElementIDs
map with the tag and pointer to demand elements of net, sorted by IDs
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
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
int getNumberOfSelectedWalkingAreas() const
get number of selected walkingAreas
GNEWalkingArea * retrieveWalkingArea(const GUIGlObject *glObject, bool hardFail=true) const
get WalkingArea by GlObject
bool isNetworkElementAroundShape(GNEAttributeCarrier *AC, const PositionVector &shape) const
check if shape of given AC (network element) is around the given shape
const std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEAdditional * > > & getAdditionals() const
get additionals
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
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
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
int getNumberOfGenericDatas() const
Return the number of generic datas.
void updateAdditionalID(GNEAdditional *additional, const std::string &newID)
update additional ID in container
const std::map< const GUIGlObject *, GNECrossing * > & getCrossings() const
get crossings
int getNumberOfSelectedDemandElements() const
get number of selected demand elements
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
std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEDemandElement * > > myDemandElements
map with the tag and pointer to additional elements of net
void deleteSingleEdge(GNEEdge *edge)
delete edge from container
std::map< SumoXMLTag, std::map< const std::string, GNEMeanData * > > myMeanDatas
map with the tag and pointer to meanData elements of net
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
Return the number of demand elements.
int getNumberOfSelectedPolygons() const
get number of selected polygons
std::vector< GNEJunction * > getSelectedJunctions() const
return selected junctions
const std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEGenericData * > > & getGenericDatas() const
get all generic datas
int getNumberOfAdditionals() const
get number of additionals
void updateDemandElementID(GNEDemandElement *demandElement, const std::string &newID)
update demand element ID in container
const std::map< SumoXMLTag, std::map< const std::string, GNEMeanData * > > & getMeanDatas() const
get meanDatas
void insertDemandElement(GNEDemandElement *demandElement)
Insert a demand element in container.
const std::map< const GUIGlObject *, GNELane * > & getLanes() const
get lanes
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
std::map< SumoXMLTag, std::map< const std::string, GNEAdditional * > > myAdditionalIDs
map with the tag and pointer to additional elements of net, sorted by IDs
GNEInternalLane * retrieveInternalLane(const GUIGlObject *glObject, bool hardFail=true) const
get InternalLane by GUIGlObject
int getNumberOfSelectedTAZSources() const
get number of selected TAZSources
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
void insertEdgeType(GNEEdgeType *edgeType)
insert edge type in container
const std::map< const GUIGlObject *, GNEConnection * > & getConnections() const
get connections
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
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 getNumberOfSelectedTAZSinks() const
get number of selected TAZSinks
void updateDemandElementFrames(const GNETagProperties &tagProperty)
update demand element frames (called after insert/delete demand element)
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
const std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEDemandElement * > > & getDemandElements() const
get demand elements
void clearJunctions()
clear junctions
void deleteCrossing(GNECrossing *crossing)
delete crossing from container
GNEDemandElement * getDefaultType() const
get default type
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
AttributeCarriers(GNENet *net)
constructor
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
std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEGenericData * > > myGenericDatas
map with the tag and pointer to all generic datas
int getNumberOfSelectedContainers() const
get number of selected containers
std::string undoName() const
undo name
GNEChange_ReplaceEdgeInTLS(NBTrafficLightLogicCont &tllcont, NBEdge *replaced, NBEdge *by)
constructor
std::string redoName() const
get Redo name
bool trueChange()
wether original and new value differ
void requireSaveTLS()
inform that TLS has to be saved
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
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
bool isDataElementsSaved() const
check if data elements are saved
bool isNetworkSaved() const
check if network is saved
bool isMeanDatasSaved() const
check if mean data elements are saved
void requireSaveDataElements()
inform that data elements has to be saved
bool isNeteditConfigSaved() const
check if netedit config is saved
void networkSaved()
mark network as saved
bool isAdditionalsSaved() const
check if additionals are saved
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
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.
bool isMeanData() const
return true if tag correspond to a mean data element
bool isContainer() const
return true if tag correspond to a container element
bool isGenericData() const
data elements
bool isNetworkElement() const
element sets
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
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::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
The representation of a single edge during network building.
Definition NBEdge.h:92
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:546
const std::string & getID() const
Definition NBEdge.h:1528
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:539
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition NBNode.cpp:490
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition NBNode.cpp:3966
int buildCrossings()
build pedestrian crossings
Definition NBNode.cpp:2987
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition NBNode.cpp:500
const Position & getPosition() const
Definition NBNode.h:260
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2616
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
static OptionsCont & getOptions()
Retrieves the options.
C++ TraCI client API implementation.
double z() const
Returns the z-position.
Definition Position.h:65
A list of positions.
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
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