Examples of StateEditor


Examples of org.opentripplanner.routing.core.StateEditor

    @Override
    public State traverse(State s0) {
        double d = getDistance();
        TraverseMode mode = s0.getNonTransitMode();
        int t = (int) (d / s0.getOptions().getSpeed(mode));
        StateEditor s1 = s0.edit(this);
        s1.incrementTimeInSeconds(t);
        s1.incrementWeight(d);
        return s1.makeState();
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

    @Override
    public State traverse(State s0) {
        RoutingRequest rr = s0.getOptions();
        double walkspeed = rr.walkSpeed;
        StateEditor se = s0.edit(this);
        se.setBackMode(TraverseMode.WALK);
        int time = (int) Math.ceil(distance / walkspeed) + 2 * StreetTransitLink.STL_TRAVERSE_COST;
        se.incrementTimeInSeconds(time);
        se.incrementWeight(time * rr.walkReluctance);
        se.incrementWalkDistance(distance);
        return se.makeState();
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

                return null;
            }
            if (!s0.isCarParked()) {
                throw new IllegalStateException("Stolen car?");
            }
            StateEditor s1 = s0.edit(this);
            int time = request.carDropoffTime;
            s1.incrementWeight(time);
            s1.incrementTimeInSeconds(time);
            s1.setCarParked(false);
            s1.setBackMode(TraverseMode.LEG_SWITCH);
            return s1.makeState();
        } else {
            /*
             * To park a car, we need to be in one and have allowed walk modes.
             */
            if (s0.getNonTransitMode() != TraverseMode.CAR) {
                return null;
            }
            if (s0.isCarParked()) {
                throw new IllegalStateException("Can't drive 2 cars");
            }
            StateEditor s1 = s0.edit(this);
            int time = request.carDropoffTime;
            s1.incrementWeight(time);
            s1.incrementTimeInSeconds(time);
            s1.setCarParked(true);
            s1.setBackMode(TraverseMode.LEG_SWITCH);
            return s1.makeState();
        }
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

            }
        }
       
        if (options.arriveBy) {
            /* Traverse backward: not much to do */
            StateEditor s1 = s0.edit(this);
            TransitStop fromVertex = (TransitStop) getFromVertex();

            //apply board slack
            s1.incrementTimeInSeconds(options.boardSlack);
            s1.alightTransit();
            s1.setBackMode(getMode());
            return s1.makeState();
        } else {
            /* Traverse forward: apply stop(pair)-specific costs */

            // Do not pre-board if transit modes are not selected.
            // Return null here rather than in StreetTransitLink so that walk-only
            // options can be used to find transit stops without boarding vehicles.
            if (!options.modes.isTransit())
                return null;

            // If we've hit our transfer limit, don't go any further
            if (s0.getNumBoardings() > options.maxTransfers)
                return null;

            /* apply transfer rules */
            /*
             * look in the global transfer table for the rules from the previous stop to this stop.
             */
            long t0 = s0.getTimeSeconds();

            long slack;
            if (s0.isEverBoarded()) {
                slack = options.transferSlack - options.alightSlack;
            } else {
                slack = options.boardSlack;
            }
            long board_after = t0 + slack;
            long transfer_penalty = 0;

            // penalize transfers more heavily if requested by the user
            if (s0.isEverBoarded()) {
                // this is not the first boarding, therefore we must have "transferred" -- whether
                // via a formal transfer or by walking.
                transfer_penalty += options.transferPenalty;
            }

            StateEditor s1 = s0.edit(this);
            s1.setTimeSeconds(board_after);
            long wait_cost = board_after - t0;
            s1.incrementWeight(wait_cost + transfer_penalty);
            s1.setBackMode(getMode());
            return s1.makeState();
        }
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

    }

    public State optimisticTraverse(State s0) {
        // do not include minimum transfer time in heuristic weight
        // (it is path-dependent)
        StateEditor s1 = s0.edit(this);
        s1.setBackMode(getMode());
        return s1.makeState();
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

        super(from, to);
    }

    @Override
    public State traverse(State s0) {
        StateEditor s1 = s0.edit(this);
        s1.setBackMode(TraverseMode.LEG_SWITCH);
        s1.incrementWeight(1);
        // Increment weight, but not time. See Javadoc on this class.
        return s1.makeState();
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

         * To unpark a bike, we need to be walking, and be allowed to bike.
         */
        if (s0.getNonTransitMode() != TraverseMode.WALK || !options.modes.getBicycle())
            return null;

        StateEditor s0e = s0.edit(this);
        s0e.incrementWeight(options.bikeParkCost);
        s0e.incrementTimeInSeconds(options.bikeParkTime);
        s0e.setBackMode(TraverseMode.LEG_SWITCH);
        s0e.setBikeParked(false);
        State s1 = s0e.makeState();
        return s1;
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

        BikeParkVertex bikeParkVertex = (BikeParkVertex) tov;
        if (bikeParkVertex.getSpacesAvailable() == 0) {
            return null;
        }

        StateEditor s0e = s0.edit(this);
        s0e.incrementWeight(options.bikeParkCost);
        s0e.incrementTimeInSeconds(options.bikeParkTime);
        s0e.setBackMode(TraverseMode.LEG_SWITCH);
        s0e.setBikeParked(true);
        State s1 = s0e.makeState();
        return s1;
    }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

    super(v1, v2);
  }

  @Override
  public State traverse(State s0) {
    StateEditor editor = s0.edit(this);
    editor.setBackMode(TraverseMode.LEG_SWITCH);
    return editor.makeState();
  }
View Full Code Here

Examples of org.opentripplanner.routing.core.StateEditor

        super(from, to);
    }

    @Override
    public State traverse(State s0) {
        StateEditor s1 = s0.edit(this);
        s1.incrementWeight(1);
        // do not change mode, which means it may be null at the start of a trip
        return s1.makeState();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.