Skip to content

Commit

Permalink
introducing radius #15426
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Dec 20, 2024
1 parent 5aade9a commit c613fb6
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/guinetload/GUITriggerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ GUITriggerBuilder::buildLaneSpeedTrigger(MSNet& net,
MSTriggeredRerouter*
GUITriggerBuilder::buildRerouter(MSNet& net, const std::string& id,
MSEdgeVector& edges, double prob, bool off, bool optional,
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos) {
GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos,
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos, const double radius) {
GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos, radius,
dynamic_cast<GUINet&>(net).getVisualisationSpeedUp());
return rr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/guinetload/GUITriggerBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class GUITriggerBuilder : public NLTriggerBuilder {
MSTriggeredRerouter* buildRerouter(MSNet& net,
const std::string& id, MSEdgeVector& edges,
double prob, bool off, bool optional, SUMOTime timeThreshold,
const std::string& vTypes, const Position& pos) override;
const std::string& vTypes, const Position& pos, const double radius) override;


/** @brief Builds a bus stop
Expand Down
2 changes: 1 addition & 1 deletion src/guisim/GUIEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ GUIEdge::addRerouter() {
MSEdgeVector edges;
edges.push_back(this);
GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, false, 0, "", Position::INVALID,
GUINet::getGUIInstance()->getVisualisationSpeedUp());
std::numeric_limits<double>::max(), GUINet::getGUIInstance()->getVisualisationSpeedUp());

MSTriggeredRerouter::RerouteInterval ri;
ri.begin = MSNet::getInstance()->getCurrentTimeStep();
Expand Down
4 changes: 2 additions & 2 deletions src/guisim/GUITriggeredRerouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ GUITriggeredRerouter::GUITriggeredRerouterPopupMenu::onCmdOpenManip(FXObject*,
// -------------------------------------------------------------------------

GUITriggeredRerouter::GUITriggeredRerouter(const std::string& id, const MSEdgeVector& edges, double prob,
bool off, bool optional, SUMOTime timeThreshold, const std::string& vTypes, const Position& pos, SUMORTree& rtree) :
MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos),
bool off, bool optional, SUMOTime timeThreshold, const std::string& vTypes, const Position& pos, const double radius, SUMORTree& rtree) :
MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos, radius),
GUIGlObject_AbstractAdd(GLO_REROUTER, id, GUIIconSubSys::getIcon(GUIIcon::REROUTER)),
myShiftProbDistIndex(0) {
// add visualisation objects for edges which trigger the rerouter
Expand Down
3 changes: 2 additions & 1 deletion src/guisim/GUITriggeredRerouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class GUITriggeredRerouter
* @param[in] off Whether the rerouter is off (not working) initially
*/
GUITriggeredRerouter(const std::string& id, const MSEdgeVector& edges, double prob,
bool off, bool optional, SUMOTime timeThreshold, const std::string& vTypes, const Position& pos,
bool off, bool optional, SUMOTime timeThreshold,
const std::string& vTypes, const Position& pos, const double radius,
SUMORTree& rtree);


Expand Down
3 changes: 2 additions & 1 deletion src/microsim/trigger/MSTriggeredRerouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::map<std::string, MSTriggeredRerouter*> MSTriggeredRerouter::myInstances;
// ===========================================================================
MSTriggeredRerouter::MSTriggeredRerouter(const std::string& id,
const MSEdgeVector& edges, double prob, bool off, bool optional,
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos) :
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos, const double radius) :
Named(id),
MSMoveReminder(id),
MSStoppingPlaceRerouter(SUMO_TAG_PARKING_AREA, "parking"),
Expand All @@ -86,6 +86,7 @@ MSTriggeredRerouter::MSTriggeredRerouter(const std::string& id,
myAmInUserMode(false),
myAmOptional(optional),
myPosition(pos),
myRadius(radius),
myTimeThreshold(timeThreshold),
myHaveParkProbs(false) {
myInstances[id] = this;
Expand Down
5 changes: 4 additions & 1 deletion src/microsim/trigger/MSTriggeredRerouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MSTriggeredRerouter :
*/
MSTriggeredRerouter(const std::string& id, const MSEdgeVector& edges,
double prob, bool off, bool optional, SUMOTime timeThreshold,
const std::string& vTypes, const Position& pos);
const std::string& vTypes, const Position& pos, const double radius);


/** @brief Destructor */
Expand Down Expand Up @@ -283,6 +283,9 @@ class MSTriggeredRerouter :
/// Where are we located in the network
Position myPosition;

/// At which distance are we activated
double myRadius;

// @brief waiting time threshold for activation
SUMOTime myTimeThreshold;

Expand Down
7 changes: 4 additions & 3 deletions src/netload/NLTriggerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ NLTriggerBuilder::parseAndBuildRerouter(MSNet& net, const SUMOSAXAttributes& att
const SUMOTime timeThreshold = TIME2STEPS(attrs.getOpt<double>(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, 0));
const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
const std::string pos = attrs.getOpt<std::string>(SUMO_ATTR_POSITION, id.c_str(), ok, "");
const double radius = attrs.getOpt<double>(SUMO_ATTR_RADIUS, id.c_str(), ok, std::numeric_limits<double>::max());
Position p = Position::INVALID;
if (pos != "") {
const std::vector<std::string> posSplit = StringTokenizer(pos, ",").getVector();
Expand All @@ -740,7 +741,7 @@ NLTriggerBuilder::parseAndBuildRerouter(MSNet& net, const SUMOSAXAttributes& att
if (!ok) {
throw InvalidArgument("Could not parse rerouter '" + id + "'.");
}
MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, off, optional, timeThreshold, vTypes, p);
MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, off, optional, timeThreshold, vTypes, p, radius);
// read in the trigger description
trigger->registerParent(SUMO_TAG_REROUTER, myHandler);
}
Expand Down Expand Up @@ -795,8 +796,8 @@ NLTriggerBuilder::buildCalibrator(const std::string& id,
MSTriggeredRerouter*
NLTriggerBuilder::buildRerouter(MSNet&, const std::string& id,
MSEdgeVector& edges, double prob, bool off, bool optional,
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos) {
return new MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos);
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos, const double radius) {
return new MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos, radius);
}


Expand Down
2 changes: 1 addition & 1 deletion src/netload/NLTriggerBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class NLTriggerBuilder {
virtual MSTriggeredRerouter* buildRerouter(MSNet& net,
const std::string& id, MSEdgeVector& edges,
double prob, bool off, bool optional, SUMOTime timeThreshold,
const std::string& vTypes, const Position& pos);
const std::string& vTypes, const Position& pos, const double radius);
//@}


Expand Down

0 comments on commit c613fb6

Please sign in to comment.