Skip to content

Commit

Permalink
Fixed #13503
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Nov 13, 2023
1 parent 2919ee3 commit 36c0f88
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
15 changes: 8 additions & 7 deletions src/netedit/elements/demand/GNEDemandElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ class GNEDemandElement : public GNEPathManager::PathElement, public GNEHierarchi

/// @brief enum class for demandElement problems
enum class Problem {
OK, // There is no problem
INVALID_ELEMENT, // Element is invalid (for example, a route without edges)
INVALID_PATH, // Path (route, trip... ) is not valid (i.e is empty)
DISCONNECTED_PLAN, // Plan element (person, containers) is not connected with the previous or next plan
INVALID_STOPPOSITION, // StopPosition is invalid (only used in stops over edges or lanes
STOP_DOWNSTREAM, // Stops don't follow their route parent
NO_PLANS // Person or container doesn't have a plan
OK, // There is no problem
INVALID_ELEMENT, // Element is invalid (for example, a route without edges)
INVALID_PATH, // Path (route, trip... ) is not valid (i.e is empty)
DISCONNECTED_PLAN, // Plan element (person, containers) is not connected with the previous or next plan
INVALID_STOPPOSITION, // StopPosition is invalid (only used in stops over edges or lanes
STOP_DOWNSTREAM, // Stops don't follow their route parent
REPEATEDROUTE_DISCONNECTED, // Repeated route is disconnected
NO_PLANS // Person or container doesn't have a plan
};

/**@brief Constructor
Expand Down
40 changes: 29 additions & 11 deletions src/netedit/elements/demand/GNERoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,29 @@ GNERoute::isDemandElementValid() const {
stops.push_back(routeChild);
}
}
// check stops
if (getInvalidStops().size() > 0) {
return Problem::STOP_DOWNSTREAM;
}
// check parent edges
if ((getParentEdges().size() == 2) && (getParentEdges().at(0) == getParentEdges().at(1))) {
// from and to are the same edges, then return true
return Problem::OK;
} else if (getParentEdges().size() > 0) {
// check that exist a connection between every edge
if (isRouteValid(getParentEdges()).size() > 0) {
return Problem::INVALID_PATH;
} else {
return Problem::OK;
// check repeating
if (myRepeat > 0) {
// avoid repeat in routes with only one edge
if (getParentEdges().size() == 1) {
return Problem::REPEATEDROUTE_DISCONNECTED;
}
// check if front and last routes is connected
if ((getParentEdges().front() != getParentEdges().back()) &&
(isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0)) {
return Problem::REPEATEDROUTE_DISCONNECTED;
}
}
// check that exist a connection between every edge
if (isRouteValid(getParentEdges()).size() > 0) {
return Problem::INVALID_PATH;
} else {
return Problem::INVALID_ELEMENT;
return Problem::OK;
}
return Problem::INVALID_ELEMENT;
}


Expand All @@ -269,6 +275,18 @@ GNERoute::getDemandElementProblem() const {
if (invalidStops.size() > 0) {
return toString(invalidStops.size()) + " stops are outside of route (downstream)";
}
// check repeating
if (myRepeat > 0) {
// avoid repeat in routes with only one edge
if (getParentEdges().size() == 1) {
return TL("Cannot repeat in routes with only one edge");
}
// check if front and last routes is connected
if ((getParentEdges().front() != getParentEdges().back()) &&
(isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0)) {
return TL("Cannot repeat route; front and last edge isn't connected");
}
}
// return string with the problem obtained from isRouteValid
return isRouteValid(getParentEdges());
}
Expand Down

0 comments on commit 36c0f88

Please sign in to comment.