@Override public void setTravelCost(double travelCost) { netRoute.setTravelCost(travelCost); }
@Override public Route getRoute(String mode) { Id<Link> startLinkId = Id.createLinkId(startLinkIdString); Id<Link> endLinkId = Id.createLinkId(endLinkIdString); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(startLinkId, endLinkId); route.setDistance(distance); List<Id<Link>> linkIds = new ArrayList<>(); for (String linkId : linkIdStrings) linkIds.add(Id.createLinkId(linkId)); route.setLinkIds(startLinkId, linkIds, endLinkId); route.setTravelCost(travelCost); route.setTravelTime(travelTime); route.setVehicleId(vehicleIdString == null ? null : Id.create(vehicleIdString, Vehicle.class)); return route; }
/** * Re-locates a future route. The route is given by its leg. It just replaces the route for the given leg, without looking after * overall plan consistency. * * @return true when replacing the route worked, false when something went wrong * */ @Deprecated // not consistent with access/egress approach; can only be used if you know exactly what you are doing. // Maybe replanXxx (which does not have these problems) is already sufficient? Otherwise use EditTrips or EditPlans. kai, nov'17 public boolean relocateFutureLegRoute(Leg leg, Id<Link> fromLinkId, Id<Link> toLinkId, Person person ) { Link fromLink = network.getLinks().get(fromLinkId); Link toLink = network.getLinks().get(toLinkId); Vehicle vehicle = null ; Node startNode = fromLink.getToNode() ; Node endNode = toLink.getFromNode() ; double starttime = leg.getDepartureTime() ; Path path = pathCalculator.calcLeastCostPath(startNode, endNode, starttime, person, vehicle) ; if (path == null) throw new RuntimeException("No route found from node " + startNode.getId() + " to node " + endNode.getId() + "."); NetworkRoute route = this.routeFactories.createRoute(NetworkRoute.class, fromLink.getId(), toLink.getId()); route.setLinkIds(fromLink.getId(), NetworkUtils.getLinkIds(path.links), toLink.getId()); route.setTravelTime((int) path.travelTime); // yyyy why int? kai, dec'15 route.setTravelCost(path.travelCost); route.setDistance(RouteUtils.calcDistance(route,1.,1., this.network)); leg.setRoute(route); return true; }
public void createRoute(Id<Link> fromLinkId, Path path, Id<Link> toLinkId) { NetworkRoute networkRoute = RouteUtils.createLinkNetworkRouteImpl(fromLinkId, toLinkId); if (!fromLinkId.equals(toLinkId)) { // do not drive/walk around, if we stay on the same link // path = this.routeAlgo.calcLeastCostPath(startNode, endNode, depTime, person, null); // if (path == null) throw new RuntimeException("No route found from node " + startNode.getId() + " to node " + endNode.getId() + "."); // NetworkRoute route = this.routeFactory.createRoute(NetworkRoute.class, fromLink.getId(), toLink.getId()); networkRoute.setLinkIds(fromLinkId, NetworkUtils.getLinkIds(path.links), toLinkId); networkRoute.setTravelTime(path.travelTime); networkRoute.setTravelCost(path.travelCost); networkRoute.setDistance(RouteUtils.calcDistanceExcludingStartEndLink(networkRoute, this.network)); } else { // create an empty route == staying on place if toLink == endLink route.setTravelTime(0); route.setDistance(0.0); } this.route = networkRoute; // List<Id<Link>> linkIds = new ArrayList<Id<Link>>(); // for (int i = 1; i < linksAllIncluded.size() - 2; i++) { // linkIds.add(linksAllIncluded.get(i).getId()); // } // this.route = new LinkNetworkRouteImpl(linksAllIncluded.get(0).getId(), linkIds, linksAllIncluded.get(linksAllIncluded.size()-1).getId()); // this.calculateNetworkRouteLength(); // this.route.setTravelTime(traveltime); } }
route.setLinkIds(fromFacility.getLinkId(), NetworkUtils.getLinkIds(path.links), toFacility.getLinkId()); route.setTravelTime(path.travelTime); route.setTravelCost(path.travelCost); route.setDistance(RouteUtils.calcDistance(route, 1.0, 1.0, this.network)); newLeg.setRoute(route);
/*package (Tests)*/ double routeLeg(Person person, Leg leg, Link fromLink, Link toLink, double depTime) { double travTime = 0; Node startNode = fromLink.getToNode(); // start at the end of the "current" link Node endNode = toLink.getFromNode(); // the target is the start of the link if (toLink != fromLink) { // (a "true" route) Path path = this.routeAlgo.calcLeastCostPath(startNode, endNode, depTime, person, null); if (path == null) throw new RuntimeException("No route found from node " + startNode.getId() + " to node " + endNode.getId() + "."); NetworkRoute route = this.populationFactory.getRouteFactories().createRoute(NetworkRoute.class, fromLink.getId(), toLink.getId()); route.setLinkIds(fromLink.getId(), NetworkUtils.getLinkIds(path.links), toLink.getId()); route.setTravelTime((int) path.travelTime); route.setTravelCost(path.travelCost); route.setDistance(RouteUtils.calcDistance(route, 1.0,1.0,this.network)); leg.setRoute(route); travTime = (int) path.travelTime; } else { // create an empty route == staying on place if toLink == endLink // note that we still do a route: someone may drive from one location to another on the link. kai, dec'15 NetworkRoute route = this.populationFactory.getRouteFactories().createRoute(NetworkRoute.class, fromLink.getId(), toLink.getId()); route.setTravelTime(0); route.setDistance(0.0); leg.setRoute(route); travTime = 0; } leg.setDepartureTime(depTime); leg.setTravelTime(travTime); return travTime; }
route.setLinkIds(fromLink.getId(), NetworkUtils.getLinkIds(path.links), toLink.getId()); route.setTravelTime(path.travelTime); route.setTravelCost(path.travelCost); route.setDistance(RouteUtils.calcDistance(route, 1.0, 1.0, this.network)); newLeg.setRoute(route);