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