Skip to content

Commit

Permalink
adding doors value fix #14335
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Mar 11, 2024
1 parent 3737b7b commit a22ee8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/netedit/elements/additional/GNEAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ myFriendlyPosition(false) {
}


GNEAccess::GNEAccess(GNEAdditional* busStop, GNELane* lane, GNENet* net, double pos, const double length, bool friendlyPos,
const Parameterised::Map& parameters) :
GNEAccess::GNEAccess(GNEAdditional* busStop, GNELane* lane, GNENet* net, const double pos, const std::string& specialPos,
const bool friendlyPos, const double length, const Parameterised::Map& parameters) :
GNEAdditional(net, GLO_ACCESS, SUMO_TAG_ACCESS, GUIIconSubSys::getIcon(GUIIcon::ACCESS), "", {}, {}, {lane}, {busStop}, {}, {}),
Parameterised(parameters),
myPositionOverLane(pos),
mySpecialPosition(specialPos),
myLength(length),
myFriendlyPosition(friendlyPos) {
// update centering boundary without updating grid
Expand Down Expand Up @@ -268,7 +269,7 @@ GNEAccess::getAttribute(SumoXMLAttr key) const {
return getParentLanes().front()->getID();
case SUMO_ATTR_POSITION:
if (myPositionOverLane == INVALID_DOUBLE) {
return "random";
return mySpecialPosition;
} else {
return toString(myPositionOverLane);
}
Expand Down Expand Up @@ -337,7 +338,7 @@ GNEAccess::isValid(SumoXMLAttr key, const std::string& value) {
}
}
case SUMO_ATTR_POSITION:
if (value.empty() || (value == "random")) {
if (value.empty() || value == "random" || value == "doors") {
return true;
} else {
return canParse<double>(value);
Expand Down Expand Up @@ -387,8 +388,9 @@ GNEAccess::setAttribute(SumoXMLAttr key, const std::string& value) {
case SUMO_ATTR_POSITION:
if (value.empty()) {
myPositionOverLane = 0;
} else if (value == "random") {
} else if (value == "random" || value == "doors") {
myPositionOverLane = INVALID_DOUBLE;
mySpecialPosition = value;
} else {
myPositionOverLane = parse<double>(value);
}
Expand Down
7 changes: 5 additions & 2 deletions src/netedit/elements/additional/GNEAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class GNEAccess : public GNEAdditional, public Parameterised {
* @param[in] friendlyPos enable or disable friendly positions
* @param[in] parameters generic parameters
*/
GNEAccess(GNEAdditional* busStop, GNELane* lane, GNENet* net, double pos, const double length,
bool friendlyPos, const Parameterised::Map& parameters);
GNEAccess(GNEAdditional* busStop, GNELane* lane, GNENet* net, const double pos, const std::string& specialPos,
const bool friendlyPos, const double length, const Parameterised::Map& parameters);

/// @brief Destructor
~GNEAccess();
Expand Down Expand Up @@ -168,6 +168,9 @@ class GNEAccess : public GNEAdditional, public Parameterised {
/// @brief position over lane
double myPositionOverLane;

/// @brief position over lane
std::string mySpecialPosition;

/// @brief Access length
double myLength;

Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/additional/GNEAdditionalHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ GNEAdditionalHandler::buildAccess(const CommonXMLStructure::SumoBaseObject* sumo
if (GNEAttributeCarrier::canParse<double>(pos)) {
posDouble = GNEAttributeCarrier::parse<double>(pos);
validPos = checkLanePosition(posDouble, 0, lane->getParentEdge()->getNBEdge()->getFinalLength(), friendlyPos);
} else if (pos == "random") {
} else if (pos == "random" || pos == "doors") {
posDouble = INVALID_DOUBLE;
} else if (pos.empty()) {
posDouble = 0;
Expand All @@ -205,7 +205,7 @@ GNEAdditionalHandler::buildAccess(const CommonXMLStructure::SumoBaseObject* sumo
WRITE_WARNING(TLF("Could not build access in netedit; The lane '%' doesn't support pedestrians", lane->getID()));
} else {
// build access
GNEAdditional* access = new GNEAccess(busStop, lane, myNet, posDouble, length, friendlyPos, parameters);
GNEAdditional* access = new GNEAccess(busStop, lane, myNet, posDouble, pos, friendlyPos, length, parameters);
// insert depending of allowUndoRedo
if (myAllowUndoRedo) {
myNet->getViewNet()->getUndoList()->begin(access, TL("add access in '") + busStop->getID() + "'");
Expand Down

0 comments on commit a22ee8b

Please sign in to comment.