Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEHierarchicalElement.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A abstract class for representation of hierarchical elements
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
23
25
26// ===========================================================================
27// member method definitions
28// ===========================================================================
29
30// ---------------------------------------------------------------------------
31// GNEHierarchicalElement - methods
32// ---------------------------------------------------------------------------
33
35
36
38
39
44
45
46void
50
51
56
57
62
63
68
69
74
75
79 for (const auto& additional : getParentAdditionals()) {
80 if (additional->getTagProperty()->isStoppingPlace()) {
81 stoppingPlaces.push_back(additional);
82 }
83 }
84 return stoppingPlaces;
85}
86
87
91 for (const auto& additional : getParentAdditionals()) {
92 if (additional->getTagProperty()->isTAZElement()) {
93 TAZs.push_back(additional);
94 }
95 }
96 return TAZs;
97}
98
99
104
105
110
111
116
117
122
123
128
129
134
135
140
141
146
147
152
153
158
159
160std::string
161GNEHierarchicalElement::getNewListOfParents(const GNENetworkElement* currentElement, const GNENetworkElement* newNextElement) const {
162 std::vector<std::string> solution;
163 if ((currentElement->getTagProperty()->getTag() == SUMO_TAG_EDGE) && (newNextElement->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
164 // reserve solution
165 solution.reserve(getParentEdges().size());
166 // iterate over edges
167 for (const auto& edge : getParentEdges()) {
168 // add edge ID
169 solution.push_back(edge->getID());
170 // if current edge is the current element, then insert newNextElement ID
171 if (edge == currentElement) {
172 solution.push_back(newNextElement->getID());
173 }
174 }
175 } else if ((currentElement->getTagProperty()->getTag() == SUMO_TAG_LANE) && (newNextElement->getTagProperty()->getTag() == SUMO_TAG_LANE)) {
176 // reserve solution
177 solution.reserve(getParentLanes().size());
178 // iterate over lanes
179 for (const auto& lane : getParentLanes()) {
180 // add lane ID
181 solution.push_back(lane->getID());
182 // if current lane is the current element, then insert newNextElement ID
183 if (lane == currentElement) {
184 solution.push_back(newNextElement->getID());
185 }
186 }
187 }
188 // remove consecutive (adjacent) duplicates
189 solution.erase(std::unique(solution.begin(), solution.end()), solution.end());
190 // return solution
191 return toString(solution);
192}
193
194/****************************************************************************/
std::set< ChildType > GNEHierarchicalContainerChildrenSet
std::vector< ChildType > GNEHierarchicalContainerChildren
std::vector< ParentType > GNEHierarchicalContainerParents
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
const GNEHierarchicalContainerChildren< GNEEdge * > & getChildEdges() const
get child edges
GNEHierarchicalStructureChildren myHierarchicalStructureChildren
hierarchical structure with children
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
GNEHierarchicalElement()
default Constructor
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerParents< GNEGenericData * > & getParentGenericDatas() const
get parent demand elements
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
const GNEHierarchicalContainerChildrenSet< GNETAZSourceSink * > & getChildTAZSourceSinks() const
return child TAZSourceSinks (Set)
const GNEHierarchicalStructureChildren & getChildren() const
get child container
const GNEHierarchicalContainerChildren< GNEJunction * > & getChildJunctions() const
get child junctions
GNEHierarchicalStructureParents myHierarchicalStructureParents
hierarchical structure with parents
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerParents< GNEAdditional * > getParentStoppingPlaces() const
get parent stoppingPlaces (used by plans)
const GNEHierarchicalStructureParents & getParents() const
get parents container
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
std::string getNewListOfParents(const GNENetworkElement *currentElement, const GNENetworkElement *newNextElement) const
if use edge/parent lanes as a list of consecutive elements, obtain a list of IDs of elements after in...
void clearParents()
clear hierarchical structure parents (used in GNE_Change)
const GNEHierarchicalContainerParents< GNEAdditional * > getParentTAZs() const
get parent TAZs (used by plans)
Hierarchical structure used for keep children.
const GNEHierarchicalContainerChildren< ChildType > & get() const
get children
const GNEHierarchicalContainerChildrenSet< ChildType > & getSet() const
get children (set)
Hierarchical structure used for keep parents.
const GNEHierarchicalContainerParents< ParentType > & get() const
get parents
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property