Eclipse SUMO - Simulation of Urban MObility
GNEClosingLaneReroute.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 //
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include "GNEClosingLaneReroute.h"
24 
25 #include <netedit/GNEUndoList.h>
26 #include <netedit/GNENet.h>
27 
28 
29 // ===========================================================================
30 // member method definitions
31 // ===========================================================================
32 
33 GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
34  GNEAdditional(rerouterIntervalParent->getNet(), GLO_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false,
35 {}, {}, {}, {rerouterIntervalParent}, {}, {}, {}, {}),
36 myClosedLane(closedLane),
37 myPermissions(permissions) {
38  // update centering boundary without updating grid
39  updateCenteringBoundary(false);
40 }
41 
42 
44 
45 
47 GNEClosingLaneReroute::getMoveOperation(const double /*shapeOffset*/) {
48  // GNEClosingLaneReroute cannot be moved
49  return nullptr;
50 }
51 
52 
53 void
55  // use geometry of rerouter parent
57 }
58 
59 
60 void
62  // use boundary of parent element
63  myBoundary = getParentAdditionals().front()->getCenteringBoundary();
64 }
65 
66 
67 void
68 GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
69  // geometry of this element cannot be splitted
70 }
71 
72 
73 std::string
75  return getParentAdditionals().at(0)->getID();
76 }
77 
78 
79 void
81  // Currently this additional isn't drawn
82 }
83 
84 
85 std::string
87  switch (key) {
88  case SUMO_ATTR_ID:
89  return getID();
90  case SUMO_ATTR_LANE:
91  return myClosedLane->getID();
92  case SUMO_ATTR_ALLOW:
94  case SUMO_ATTR_DISALLOW:
96  case GNE_ATTR_PARENT:
97  return getParentAdditionals().at(0)->getID();
99  return getParametersStr();
100  default:
101  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
102  }
103 }
104 
105 
106 double
108  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
109 }
110 
111 
112 void
113 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
114  if (value == getAttribute(key)) {
115  return; //avoid needless changes, later logic relies on the fact that attributes have changed
116  }
117  switch (key) {
118  case SUMO_ATTR_ID:
119  case SUMO_ATTR_LANE:
120  case SUMO_ATTR_ALLOW:
121  case SUMO_ATTR_DISALLOW:
122  case GNE_ATTR_PARAMETERS:
123  undoList->p_add(new GNEChange_Attribute(this, key, value));
124  break;
125  default:
126  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
127  }
128 }
129 
130 
131 bool
132 GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
133  switch (key) {
134  case SUMO_ATTR_ID:
135  return isValidAdditionalID(value);
136  case SUMO_ATTR_LANE:
137  return (myNet->retrieveLane(value, false) != nullptr);
138  case SUMO_ATTR_ALLOW:
139  case SUMO_ATTR_DISALLOW:
140  return canParseVehicleClasses(value);
141  case GNE_ATTR_PARAMETERS:
142  return Parameterised::areParametersValid(value);
143  default:
144  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
145  }
146 }
147 
148 
149 bool
151  return true;
152 }
153 
154 
155 std::string
157  return getTagStr();
158 }
159 
160 
161 std::string
163  return getTagStr() + ": " + myClosedLane->getID();
164 }
165 
166 // ===========================================================================
167 // private
168 // ===========================================================================
169 
170 void
171 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
172  switch (key) {
173  case SUMO_ATTR_ID:
174  myNet->getAttributeCarriers()->updateID(this, value);
175  break;
176  case SUMO_ATTR_LANE:
177  myClosedLane = myNet->retrieveLane(value);
178  break;
179  case SUMO_ATTR_ALLOW:
181  break;
182  case SUMO_ATTR_DISALLOW:
184  break;
185  case GNE_ATTR_PARAMETERS:
186  setParametersStr(value);
187  break;
188  default:
189  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
190  }
191 }
192 
193 
194 void
196  // nothing to do
197 }
198 
199 
200 void
201 GNEClosingLaneReroute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
202  // nothing to do
203 }
204 
205 /****************************************************************************/
@ GLO_REROUTER
a Rerouter
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ GNE_ATTR_PARENT
parent of an additional element
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
const std::string & getID() const
get ID
GNEGeometry::Geometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
Boundary myBoundary
Additional Boundary.
const GNEGeometry::Geometry & getAdditionalGeometry() const
obtain additional geometry
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
bool isAttributeEnabled(SumoXMLAttr key) const
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
double getAttributeDouble(SumoXMLAttr key) const
std::string getParentName() const
Returns the name of the parent object.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
void updateGeometry()
update pre-computed geometry information
GNELane * myClosedLane
closed lane
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
GNEClosingLaneReroute(GNEAdditional *rerouterIntervalParent, GNELane *closedLane, SVCPermissions permissions)
parameter constructor
std::string getAttribute(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void updateGeometry(const PositionVector &shape, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
update geometry shape
Definition: GNEGeometry.cpp:81
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
move operation
move result
void updateID(GNEAttributeCarrier *AC, const std::string newID)
update ID
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1337
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
retrieve all attribute carriers of Net
Definition: GNENet.cpp:130
const std::string & getID() const
get ID
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Stores the information about how to visualize structures.
static bool areParametersValid(const std::string &value, bool report=false, ParameterisedAttrType attrType=ParameterisedAttrType::STRING, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".