Skip to content

Commit

Permalink
fix #14296
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 5, 2024
1 parent efc59c3 commit 1a92016
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 30 deletions.
27 changes: 20 additions & 7 deletions src/netedit/elements/demand/GNEDemandElementPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ GNEDemandElementPlan::getPlanMoveOperation() {

void
GNEDemandElementPlan::writePlanAttributes(OutputDevice& device) const {
// get tag property
const auto tagProperty = myPlanElement->getTagProperty();
// write attributes depending of parent elements
if (tagProperty.planConsecutiveEdges()) {
Expand All @@ -333,13 +332,8 @@ GNEDemandElementPlan::writePlanAttributes(OutputDevice& device) const {
device.writeAttr(SUMO_ATTR_FROM_TAZ, myPlanElement->getParentAdditionals().front()->getID());
} else if (tagProperty.planFromJunction()) {
device.writeAttr(SUMO_ATTR_FROM_JUNCTION, myPlanElement->getParentJunctions().front()->getID());
} else if (tagProperty.planFromBusStop()) {
device.writeAttr(GNE_ATTR_FROM_BUSSTOP, myPlanElement->getParentAdditionals().front()->getID());
} else if (tagProperty.planFromTrainStop()) {
device.writeAttr(GNE_ATTR_FROM_TRAINSTOP, myPlanElement->getParentAdditionals().front()->getID());
} else if (tagProperty.planFromContainerStop()) {
device.writeAttr(GNE_ATTR_FROM_CONTAINERSTOP, myPlanElement->getParentAdditionals().front()->getID());
}
// origin stopping places are transformed into an intial stop stage (see writeOriginStop)
}
// continue writting to attribute
if (tagProperty.planToEdge()) {
Expand Down Expand Up @@ -371,6 +365,25 @@ GNEDemandElementPlan::writePlanAttributes(OutputDevice& device) const {
}


void
GNEDemandElementPlan::writeOriginStop(OutputDevice& device) const {
const auto tagProperty = myPlanElement->getTagProperty();
if (tagProperty.planFromStoppingPlace()) {
device.openTag(SUMO_TAG_STOP);
const std::string stopID = myPlanElement->getParentAdditionals().front()->getID();
if (tagProperty.planFromBusStop()) {
device.writeAttr(SUMO_ATTR_BUS_STOP, stopID);
} else if (tagProperty.planFromTrainStop()) {
device.writeAttr(SUMO_ATTR_TRAIN_STOP, stopID);
} else if (tagProperty.planFromContainerStop()) {
device.writeAttr(SUMO_ATTR_CONTAINER_STOP, stopID);
}
device.writeAttr(SUMO_ATTR_DURATION, 0);
device.closeTag();
}
}


GUIGLObjectPopupMenu*
GNEDemandElementPlan::getPlanPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *myPlanElement);
Expand Down
3 changes: 3 additions & 0 deletions src/netedit/elements/demand/GNEDemandElementPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class GNEDemandElementPlan {
/// @brief write plan element common attributes
void writePlanAttributes(OutputDevice& device) const;

/// @brief write initial stop stage if plan starts at a stopping place
void writeOriginStop(OutputDevice& device) const;

/// @brief Returns an own popup-menu
GUIGLObjectPopupMenu* getPlanPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent);

Expand Down
7 changes: 1 addition & 6 deletions src/netedit/elements/demand/GNEPersonTrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,18 @@ GNEPersonTrip::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNEPersonTrip::writeDemandElement(OutputDevice& device) const {
// open tag
writeOriginStop(device);
device.openTag(SUMO_TAG_PERSONTRIP);
// write plan attributes
writePlanAttributes(device);
// write modes
if (myModes.size() > 0) {
device.writeAttr(SUMO_ATTR_MODES, myModes);
}
// write lines
if (myLines.size() > 0) {
device.writeAttr(SUMO_ATTR_LINES, myLines);
}
// write vTypes
if (myVTypes.size() > 0) {
device.writeAttr(SUMO_ATTR_VTYPES, myVTypes);
}
// close tag
device.closeTag();
}

Expand Down
5 changes: 1 addition & 4 deletions src/netedit/elements/demand/GNERide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,14 @@ GNERide::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNERide::writeDemandElement(OutputDevice& device) const {
// open tag
writeOriginStop(device);
device.openTag(SUMO_TAG_RIDE);
// write plan attributes
writePlanAttributes(device);
// write lines
if (myLines.empty()) {
device.writeAttr(SUMO_ATTR_LINES, "ANY");
} else {
device.writeAttr(SUMO_ATTR_LINES, myLines);
}
// close tag
device.closeTag();
}

Expand Down
3 changes: 0 additions & 3 deletions src/netedit/elements/demand/GNEStopPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ GNEStopPlan::getMoveOperation() {

void
GNEStopPlan::writeDemandElement(OutputDevice& device) const {
// open tag
device.openTag(SUMO_TAG_STOP);
// write plan attributes
writePlanAttributes(device);
// write stop attributes
if (isAttributeEnabled(SUMO_ATTR_DURATION)) {
Expand All @@ -114,7 +112,6 @@ GNEStopPlan::writeDemandElement(OutputDevice& device) const {
if (myTagProperty.hasAttribute(SUMO_ATTR_FRIENDLY_POS) && myFriendlyPos) {
device.writeAttr(SUMO_ATTR_FRIENDLY_POS, myFriendlyPos);
}
// close tag
device.closeTag();
}

Expand Down
4 changes: 1 addition & 3 deletions src/netedit/elements/demand/GNETranship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ GNETranship::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNETranship::writeDemandElement(OutputDevice& device) const {
// open tag
writeOriginStop(device);
device.openTag(SUMO_TAG_TRANSHIP);
// write plan attributes
writePlanAttributes(device);
// close tag
device.closeTag();
}

Expand Down
5 changes: 1 addition & 4 deletions src/netedit/elements/demand/GNETransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,12 @@ GNETransport::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNETransport::writeDemandElement(OutputDevice& device) const {
// open tag
writeOriginStop(device);
device.openTag(SUMO_TAG_TRANSPORT);
// write plan attributes
writePlanAttributes(device);
// write lines
if (myLines.size() > 0) {
device.writeAttr(SUMO_ATTR_LINES, myLines);
}
// close tag
device.closeTag();
}

Expand Down
4 changes: 1 addition & 3 deletions src/netedit/elements/demand/GNEWalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ GNEWalk::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNEWalk::writeDemandElement(OutputDevice& device) const {
// open tag
writeOriginStop(device);
device.openTag(SUMO_TAG_WALK);
// write plan attributes
writePlanAttributes(device);
// close tag
device.closeTag();
}

Expand Down

0 comments on commit 1a92016

Please sign in to comment.