Skip to content

Commit

Permalink
rerouter position #14198
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 17, 2024
1 parent eede07d commit ab58c98
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 12 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) {
GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes,
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos) {
GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos,
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 {
virtual MSTriggeredRerouter* buildRerouter(MSNet& net,
const std::string& id, MSEdgeVector& edges,
double prob, bool off, bool optional, SUMOTime timeThreshold,
const std::string& vTypes) override;
const std::string& vTypes, const Position& pos) 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 @@ -628,7 +628,7 @@ void
GUIEdge::addRerouter() {
MSEdgeVector edges;
edges.push_back(this);
GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, false, 0, "",
GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, false, 0, "", Position::INVALID,
GUINet::getGUIInstance()->getVisualisationSpeedUp());

MSTriggeredRerouter::RerouteInterval ri;
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, SUMORTree& rtree) :
MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes),
bool off, bool optional, SUMOTime timeThreshold, const std::string& vTypes, const Position& pos, SUMORTree& rtree) :
MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos),
GUIGlObject_AbstractAdd(GLO_REROUTER, id, GUIIconSubSys::getIcon(GUIIcon::REROUTER)),
myShiftProbDistIndex(0) {
// add visualisation objects for edges which trigger the rerouter
Expand Down
2 changes: 1 addition & 1 deletion src/guisim/GUITriggeredRerouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ 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,
bool off, bool optional, SUMOTime timeThreshold, const std::string& vTypes, const Position& pos,
SUMORTree& rtree);


Expand Down
2 changes: 1 addition & 1 deletion src/microsim/trigger/MSTriggeredRerouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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=Position::INVALID);
const std::string& vTypes, const Position& pos);


/** @brief Destructor */
Expand Down
19 changes: 16 additions & 3 deletions src/netload/NLTriggerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,23 @@ 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, "");
Position p = Position::INVALID;
if (pos != "") {
const std::vector<std::string> posSplit = StringTokenizer(pos, ",").getVector();
if (posSplit.size() == 1) {
p = edges.front()->getLanes()[0]->geometryPositionAtOffset(StringUtils::toDouble(posSplit[0]));
} else if (posSplit.size() == 2) {
p = Position(StringUtils::toDouble(posSplit[0]), StringUtils::toDouble(posSplit[1]));
} else if (posSplit.size() == 3) {
p = Position(StringUtils::toDouble(posSplit[0]), StringUtils::toDouble(posSplit[1]), StringUtils::toDouble(posSplit[2]));
} else {
throw InvalidArgument("Invalid position for rerouter '" + id + "'.");
}
}
if (!ok) {
throw InvalidArgument("Could not parse rerouter '" + id + "'.");
}
MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, off, optional, timeThreshold, vTypes);
MSTriggeredRerouter* trigger = buildRerouter(net, id, edges, prob, off, optional, timeThreshold, vTypes, p);
// read in the trigger description
trigger->registerParent(SUMO_TAG_REROUTER, myHandler);
}
Expand Down Expand Up @@ -755,8 +768,8 @@ NLTriggerBuilder::buildCalibrator(MSNet& /*net*/, 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) {
return new MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes);
SUMOTime timeThreshold, const std::string& vTypes, const Position& pos) {
return new MSTriggeredRerouter(id, edges, prob, off, optional, timeThreshold, vTypes, pos);
}


Expand Down
2 changes: 1 addition & 1 deletion src/netload/NLTriggerBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,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 std::string& vTypes, const Position& pos);
//@}


Expand Down

0 comments on commit ab58c98

Please sign in to comment.