void ROVehicle::computeRoute(const RORouterProvider& provider, const bool removeLoops, MsgHandler* errorHandler) { SUMOAbstractRouter<ROEdge, ROVehicle>& router = provider.getVehicleRouter(); std::string noRouteMsg = "The vehicle '" + getID() + "' has no valid route."; RORouteDef* const routeDef = getRouteDefinition(); // check if the route definition is valid if (routeDef == nullptr) { errorHandler->inform(noRouteMsg); myRoutingSuccess = false; return; } RORoute* current = routeDef->buildCurrentRoute(router, getDepartureTime(), *this); if (current == nullptr || current->size() == 0) { delete current; errorHandler->inform(noRouteMsg); myRoutingSuccess = false; return; } // check whether we have to evaluate the route for not containing loops if (removeLoops) { const ROEdge* requiredStart = (getParameter().departPosProcedure == DEPART_POS_GIVEN || getParameter().departLaneProcedure == DEPART_LANE_GIVEN ? current->getEdgeVector().front() : 0); const ROEdge* requiredEnd = (getParameter().arrivalPosProcedure == ARRIVAL_POS_GIVEN || getParameter().arrivalLaneProcedure == ARRIVAL_LANE_GIVEN ? current->getEdgeVector().back() : 0); current->recheckForLoops(getMandatoryEdges(requiredStart, requiredEnd)); // check whether the route is still valid if (current->size() == 0) { delete current; errorHandler->inform(noRouteMsg + " (after removing loops)"); myRoutingSuccess = false; return; } } // add built route routeDef->addAlternative(router, this, current, getDepartureTime()); myRoutingSuccess = true; }
bool RONet::computeRoute(OptionsCont& options, SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh) { MsgHandler* mh = (OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()); std::string noRouteMsg = "The vehicle '" + veh->getID() + "' has no valid route."; RORouteDef* const routeDef = veh->getRouteDefinition(); // check if the route definition is valid if (routeDef == 0) { mh->inform(noRouteMsg); return false; } // check whether the route was already saved if (routeDef->isSaved()) { return true; } // RORoute* current = routeDef->buildCurrentRoute(router, veh->getDepartureTime(), *veh); if (current == 0 || current->size() == 0) { delete current; mh->inform(noRouteMsg); return false; } // check whether we have to evaluate the route for not containing loops if (options.getBool("remove-loops")) { current->recheckForLoops(); // check whether the route is still valid if (current->size() == 0) { delete current; mh->inform(noRouteMsg + " (after removing loops)"); return false; } } // add built route routeDef->addAlternative(router, veh, current, veh->getDepartureTime()); return true; }