Skip to content

Commit

Permalink
refactoring refs #12
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 7, 2024
1 parent f793555 commit 038013a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/microsim/MSRouteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ MSRouteHandler::parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs) {
useTaz = false;
}
bool ok = true;
const std::string rid = "for " + element + " '" + myVehicleParameter->id + "'";
// from-attributes
if ((useTaz || !attrs.hasAttribute(SUMO_ATTR_FROM)) &&
(attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) || attrs.hasAttribute(SUMO_ATTR_FROM_JUNCTION))) {
Expand All @@ -115,16 +116,16 @@ MSRouteHandler::parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs) {
const std::string tazID = attrs.get<std::string>(useJunction ? SUMO_ATTR_FROM_JUNCTION : SUMO_ATTR_FROM_TAZ, myVehicleParameter->id.c_str(), ok);
const MSEdge* fromTaz = MSEdge::dictionary(tazID + "-source");
if (fromTaz == nullptr) {
throw ProcessError("Source " + tazType + " '" + tazID + "' not known for " + element + " '" + myVehicleParameter->id + "'!"
throw ProcessError("Source " + tazType + " '" + tazID + "' not known " + rid + "!"
+ (useJunction ? JUNCTION_TAZ_MISSING_HELP : ""));
} else if (fromTaz->getNumSuccessors() == 0 && tag != SUMO_TAG_PERSON) {
throw ProcessError("Source " + tazType + " '" + tazID + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
throw ProcessError("Source " + tazType + " '" + tazID + "' has no outgoing edges " + rid + "!");
} else {
myActiveRoute.push_back(fromTaz);
}
} else {
MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok),
myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
myActiveRoute, rid);
}

// via-attributes
Expand All @@ -143,7 +144,7 @@ MSRouteHandler::parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs) {
}
} else {
MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok),
viaEdges, "for " + element + " '" + myVehicleParameter->id + "'");
viaEdges, rid);
}
if (!viaEdges.empty()) {
myHaveVia = true;
Expand All @@ -161,16 +162,16 @@ MSRouteHandler::parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs) {
const std::string tazID = attrs.get<std::string>(useJunction ? SUMO_ATTR_TO_JUNCTION : SUMO_ATTR_TO_TAZ, myVehicleParameter->id.c_str(), ok, true);
const MSEdge* toTaz = MSEdge::dictionary(tazID + "-sink");
if (toTaz == nullptr) {
throw ProcessError("Sink " + tazType + " '" + tazID + "' not known for " + element + " '" + myVehicleParameter->id + "'!"
throw ProcessError("Sink " + tazType + " '" + tazID + "' not known " + rid + "!"
+ (useJunction ? JUNCTION_TAZ_MISSING_HELP : ""));
} else if (toTaz->getNumPredecessors() == 0 && tag != SUMO_TAG_PERSON) {
throw ProcessError("Sink " + tazType + " '" + tazID + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
throw ProcessError("Sink " + tazType + " '" + tazID + "' has no incoming edges " + rid + "!");
} else {
myActiveRoute.push_back(toTaz);
}
} else {
MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true),
myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
myActiveRoute, rid);
}
myActiveRouteID = "!" + myVehicleParameter->id;
if (myVehicleParameter->routeid == "") {
Expand Down

0 comments on commit 038013a

Please sign in to comment.