Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.TraverseModeSet


            sptRequestA.worstTime = sptRequestA.dateTime + (30 * 60);
        } else {
            sptRequestA.worstTime = sptRequestA.dateTime + Math.round(walkInMin * 1.3 * 60);
        }
        // set the switch-time for shed/area calculation, i.e. to decide if the hull is calculated based on points or on edges
        TraverseModeSet modes = sptRequestA.modes;
        LOG.debug("mode(s): " + modes);
        if ((modes.contains(TraverseMode.TRANSIT)) || (modes.contains(TraverseMode.BUSISH))
                || (modes.contains(TraverseMode.TRAINISH))) {
            shedCalcMethodSwitchTimeInSec = 60 * 20; // 20min (use 20min for transit, since buses may not come all the time)
        } else if (modes.contains(TraverseMode.CAR)) {
            shedCalcMethodSwitchTimeInSec = 60 * 10; // 10min
        } else if (modes.contains(TraverseMode.BICYCLE)) {
            shedCalcMethodSwitchTimeInSec = 60 * 10; // 10min
        } else {
            shedCalcMethodSwitchTimeInSec = 60 * 20; // 20min
        }
        // set the maxUserSpeed, which is used later to check for u-type streets/crescents when calculating sub-edges;
        // Note, that the car speed depends on the edge itself, so this value may be replaced later
        this.usesCar = false;
        int numberOfModes = modes.getModes().size();
        if (numberOfModes == 1) {
            if (modes.getWalk()) {
                this.maxUserSpeed = sptRequestA.walkSpeed;
            } else if (modes.getBicycle()) {
                this.maxUserSpeed = sptRequestA.bikeSpeed;
            } else if (modes.getDriving()) {
                this.maxUserSpeed = sptRequestA.carSpeed;
                this.usesCar = true;
            }
        } else {// for all other cases (multiple-modes)
                // sstein: I thought I may set it to 36.111 m/sec = 130 km/h,
View Full Code Here


     * This is intended as a temporary solution, and uses the current system of a single mode set,
     * accompanied by some flags to help with routing.
     */
    public void applyToRequest(RoutingRequest req) {
        /* Start with an empty mode set. */
        TraverseModeSet modes = new TraverseModeSet();
        /* Use only the first set of qualified modes for now. */
        if (sets.isEmpty()) return;
        Set<QualifiedMode> qModes = sets.get(0);
        // First, copy over all the modes
        for (QualifiedMode qMode : qModes) {
            modes.setMode(qMode.mode, true);
        }

        // We used to always set WALK to true, but this forced walking when someone wanted to use a bike.
        // We also want it to be possible to force biking-only (e.g. this is done in some consistency tests).
        // TODO clearly define mode semantics: does presence of mode mean it is allowable, preferred... ?

        for (QualifiedMode qMode : qModes) {
            if (qMode.mode == TraverseMode.BICYCLE) {
                if (qMode.qualifiers.contains(Qualifier.RENT)) {
                    modes.setMode(TraverseMode.WALK, true); // turn on WALK for bike rental mode
                    req.allowBikeRental = true;
                }
                if (modes.isTransit()) { // this is ugly, using both kinds of modeset at once
                    req.bikeParkAndRide = qMode.qualifiers.contains(Qualifier.PARK);
                }
            }
            if (qMode.mode == TraverseMode.CAR && modes.isTransit()) { // this is ugly, using both kinds of modeset at once
                if (qMode.qualifiers.contains(Qualifier.PARK)) {
                    req.parkAndRide = true;
                } else {
                    req.kissAndRide = true;
                }
View Full Code Here

            when = dateFormat.parse(searchDate.getText());
        } catch (ParseException e) {
            searchDate.setText("Format: " + dateFormat.toPattern());
            return;
        }
        TraverseModeSet modeSet = new TraverseModeSet();
        modeSet.setWalk(walkCheckBox.isSelected());
        modeSet.setBicycle(bikeCheckBox.isSelected());
        modeSet.setFerry(ferryCheckBox.isSelected());
        modeSet.setTrainish(trainCheckBox.isSelected());
        modeSet.setBusish(busCheckBox.isSelected());
        modeSet.setCar(carCheckBox.isSelected());
        modeSet.setCustomMotorVehicle(cmvCheckBox.isSelected());
        // must set generic transit mode last, and only when it is checked
        // otherwise 'false' will clear trainish and busish
        if (transitCheckBox.isSelected())
            modeSet.setTransit(true);
        RoutingRequest options = new RoutingRequest(modeSet);
        options.setArriveBy(arriveByCheckBox.isSelected());
        options.setWalkBoardCost(Integer.parseInt(boardingPenaltyField.getText()) * 60); // override low 2-4 minute values
        // TODO LG Add ui element for bike board cost (for now bike = 2 * walk)
        options.setBikeBoardCost(Integer.parseInt(boardingPenaltyField.getText()) * 60 * 2);
 
View Full Code Here

    /** Boarding constructor (TransitStopDepart --> PatternStopVertex) */
    public TransitBoardAlight (TransitStopDepart fromStopVertex, PatternStopVertex toPatternVertex,
            int stopIndex, TraverseMode mode) {
        super(fromStopVertex, toPatternVertex);
        this.stopIndex = stopIndex;
        this.modeMask = new TraverseModeSet(mode).getMask();
        this.boarding = true;
    }
View Full Code Here

    /** Alighting constructor (PatternStopVertex --> TransitStopArrive) */
    public TransitBoardAlight (PatternStopVertex fromPatternStop, TransitStopArrive toStationVertex,
            int stopIndex, TraverseMode mode) {
        super(fromPatternStop, toStationVertex);
        this.stopIndex = stopIndex;
        this.modeMask = new TraverseModeSet(mode).getMask();
        this.boarding = false;
    }
View Full Code Here

                double preferrence = 1;
                if (preferredEdges != null && preferredEdges.contains(e)) {
                    preferrence = 3.0;
                }

                TraverseModeSet modes = reqs.modes;
                CandidateEdge ce = new CandidateEdge(se, location, preferrence, modes);

                // Even if an edge is outside the query envelope, bounding boxes can
                // still intersect. In this case, distance to the edge is greater
                // than the query envelope size.
View Full Code Here

        }
        Map<Vertex, Subgraph> subgraphs = new HashMap<Vertex, Subgraph>();
        Map<Vertex, ArrayList<Vertex>> neighborsForVertex = new HashMap<Vertex, ArrayList<Vertex>>();

//        RoutingRequest options = new RoutingRequest(new TraverseModeSet(TraverseMode.WALK, TraverseMode.TRANSIT));
        RoutingRequest options = new RoutingRequest(new TraverseModeSet(TraverseMode.WALK));

        for (Vertex gv : graph.getVertices()) {
            if (!(gv instanceof StreetVertex)) {
                continue;
            }
View Full Code Here

        ShortestPathTree spt = aStar.getShortestPathTree(opt);
        assertNotNull(spt);

        //test that the option to walk bikes on the first or last segment works
       
        opt = new RoutingRequest(new TraverseModeSet(TraverseMode.BICYCLE));
       
        //Real live cyclists tell me that they would prefer to ride around the long way than to
        //walk their bikes the short way.  If we slow down the default biking speed, that will
        //force a change in preferences.
        opt.bikeSpeed = 2;
View Full Code Here

     *
     * @param v
     */
    public LinkRequest connectVertexToStreets(BikeRentalStationVertex v) {
        LinkRequest request = new LinkRequest(this);
        request.connectVertexToStreets(v, new TraverseModeSet(TraverseMode.WALK,
                TraverseMode.BICYCLE), new LinkRequest.StreetLinkFactory<BikeRentalStationVertex>() {
            @Override
            public Collection<? extends Edge> connect(StreetVertex sv, BikeRentalStationVertex v) {
                return Arrays.asList(new StreetBikeRentalLink(sv, v), new StreetBikeRentalLink(v,
                        sv));
View Full Code Here

     *
     * @param v
     */
    public LinkRequest connectVertexToStreets(BikeParkVertex v) {
        LinkRequest request = new LinkRequest(this);
        request.connectVertexToStreets(v, new TraverseModeSet(TraverseMode.WALK,
                TraverseMode.BICYCLE), new LinkRequest.StreetLinkFactory<BikeParkVertex>() {
            @Override
            public Collection<? extends Edge> connect(StreetVertex sv, BikeParkVertex v) {
                return Arrays.asList(new StreetBikeParkLink(sv, v), new StreetBikeParkLink(v, sv));
            }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.core.TraverseModeSet

Copyright © 2018 www.massapicom. 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.