Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.TransferTable


           
            /* Compute penalty for non-preferred transfers. */
            int transferPenalty = 0;
            /* If this is not the first boarding, then we are transferring. */
            if (s0.isEverBoarded()) {
                TransferTable transferTable = options.getRoutingContext().transferTable;
                int transferTime = transferTable.getTransferTime(s0.getPreviousStop(),
                                   getStop(), s0.getPreviousTrip(), trip, boarding);
                transferPenalty  = transferTable.determineTransferPenalty(transferTime,
                                   options.nonpreferredTransferPenalty);
            }           

            /* Found a trip to board. Now make the child state. */
            StateEditor s1 = s0.edit(this);
View Full Code Here


        // Plan short trip
        TestPlanner planner = new TestPlanner(
                "portland", "45.5264892578125,-122.60479259490967", "45.511622,-122.645564");

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        Graph graph = Context.getInstance().graph;
        when(graph.getTransferTable()).thenReturn(table);

        // Do the planning
        Response response = planner.getItineraries();
View Full Code Here

        // Plan short trip
        TestPlanner planner = new TestPlanner(
                "portland", "45.5264892578125,-122.60479259490967", "45.511622,-122.645564");

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        Graph graph = Context.getInstance().graph;
        when(graph.getTransferTable()).thenReturn(table);

        // Do the planning
        Response response = planner.getItineraries();
View Full Code Here

        // Plan short trip
        TestPlanner planner = new TestPlanner(
                "portland", "45.506077,-122.621139", "45.464637,-122.706061");

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        Graph graph = Context.getInstance().graph;
        when(graph.getTransferTable()).thenReturn(table);

        // Do the planning
        Response response = planner.getItineraries();
View Full Code Here

        // Plan short trip
        TestPlanner planner = new TestPlanner(
                "portland", "45.506077,-122.621139", "45.464637,-122.706061");

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        Graph graph = Context.getInstance().graph;
        when(graph.getTransferTable()).thenReturn(table);

        // Do the planning
        Response response = planner.getItineraries();
View Full Code Here

        endTime =  TestUtils.dateInSeconds("America/New_York", 2009, 8, 19, 15, 10, 0);
        assertEquals(endTime, path.getEndTime());
    }

    public void testTransfers() throws Exception {
        TransferTable transferTable = graph.getTransferTable();
       
        // create dummy routes and trips
        Route fromRoute = new Route();
        fromRoute.setId(new AgencyAndId("agency", "1"));
        Trip fromTrip = new Trip();
        fromTrip.setId(new AgencyAndId("agency", "1.1"));
        fromTrip.setRoute(fromRoute);
        Route toRoute = new Route();
        toRoute.setId(new AgencyAndId("agency", "2"));
        Trip toTrip = new Trip();
        toTrip.setId(new AgencyAndId("agency", "2.1"));
        toTrip.setRoute(toRoute);
        Trip toTrip2 = new Trip();
        toTrip2.setId(new AgencyAndId("agency", "2.2"));
        toTrip2.setRoute(toRoute);
       
        // find stops
        Stop stopK = ((TransitStopArrive)graph.getVertex("agency:K_arrive")).getStop();
        Stop stopN = ((TransitStopDepart)graph.getVertex("agency:N_depart")).getStop();
        Stop stopM = ((TransitStopDepart)graph.getVertex("agency:M_depart")).getStop();
       
        assertTrue(transferTable.hasPreferredTransfers());
        assertEquals(StopTransfer.UNKNOWN_TRANSFER, transferTable.getTransferTime(stopN, stopM, fromTrip, toTrip, true));
        assertEquals(StopTransfer.FORBIDDEN_TRANSFER, transferTable.getTransferTime(stopK, stopM, fromTrip, toTrip, true));
        assertEquals(StopTransfer.PREFERRED_TRANSFER, transferTable.getTransferTime(stopN, stopK, toTrip, toTrip2, true));
        assertEquals(StopTransfer.TIMED_TRANSFER, transferTable.getTransferTime(stopN, stopK, fromTrip, toTrip, true));
        assertEquals(15, transferTable.getTransferTime(stopN, stopK, fromTrip, toTrip2, true));
       
        TransitStop e_arrive = (TransitStop) graph.getVertex("agency:E");
        TransitStop f_depart = (TransitStop) graph.getVertex("agency:F");
        Edge edge = new TransferEdge(e_arrive, f_depart, 10000, 10000);
       
View Full Code Here

        _geometriesByShapeSegmentKey.clear();
    }

    private void loadTransfers(Graph graph) {
        Collection<Transfer> transfers = _dao.getAllTransfers();
        TransferTable transferTable = graph.getTransferTable();
        for (Transfer t : transfers) {
            Stop fromStop = t.getFromStop();
            Stop toStop = t.getToStop();
            Route fromRoute = t.getFromRoute();
            Route toRoute = t.getToRoute();
            Trip fromTrip = t.getFromTrip();
            Trip toTrip = t.getToTrip();
            Vertex fromVertex = context.stopArriveNodes.get(fromStop);
            Vertex toVertex = context.stopDepartNodes.get(toStop);
            switch (t.getTransferType()) {
            case 1:
                // timed (synchronized) transfer
                // Handle with edges that bypass the street network.
                // from and to vertex here are stop_arrive and stop_depart vertices
               
                // only add edge when it doesn't exist already
                boolean hasTimedTransferEdge = false;
                for (Edge outgoingEdge : fromVertex.getOutgoing()) {
                    if (outgoingEdge instanceof TimedTransferEdge) {
                        if (outgoingEdge.getToVertex() == toVertex) {
                            hasTimedTransferEdge = true;
                            break;
                        }
                    }
                }
                if (!hasTimedTransferEdge) {
                    new TimedTransferEdge(fromVertex, toVertex);
                }
                // add to transfer table to handle specificity
                transferTable.addTransferTime(fromStop, toStop, fromRoute, toRoute, fromTrip, toTrip, StopTransfer.TIMED_TRANSFER);
                break;
            case 2:
                // min transfer time
                transferTable.addTransferTime(fromStop, toStop, fromRoute, toRoute, fromTrip, toTrip, t.getMinTransferTime());
                break;
            case 3:
                // forbidden transfer
                transferTable.addTransferTime(fromStop, toStop, fromRoute, toRoute, fromTrip, toTrip, StopTransfer.FORBIDDEN_TRANSFER);
                break;
            case 0:
            default:
                // preferred transfer
                transferTable.addTransferTime(fromStop, toStop, fromRoute, toRoute, fromTrip, toTrip, StopTransfer.PREFERRED_TRANSFER);
                break;
            }
        }
    }
View Full Code Here

    private int adjustTimeForTransfer(State state, Stop currentStop, Trip trip, boolean boarding, ServiceDay serviceDay, int t0) {
        if ( ! state.isEverBoarded()) {
            // This is the first boarding not a transfer.
            return t0;
        }
        TransferTable transferTable = state.getOptions().getRoutingContext().transferTable;
        int transferTime = transferTable.getTransferTime(state.getPreviousStop(), currentStop, state.getPreviousTrip(), trip, boarding);
        // Check whether back edge is TimedTransferEdge
        if (state.getBackEdge() instanceof TimedTransferEdge) {
            // Transfer must be of type TIMED_TRANSFER
            if (transferTime != StopTransfer.TIMED_TRANSFER) {
                return -1;
View Full Code Here

TOP

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

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.