Package org.opentripplanner.api.model

Examples of org.opentripplanner.api.model.Leg


                /* fix up from/to on first/last legs */
                if (i.legs.size() == 0) {
                    LOG.warn("itinerary has no legs");
                    continue;
                }
                Leg firstLeg = i.legs.get(0);
                firstLeg.from.orig = plan.from.orig;
                Leg lastLeg = i.legs.get(i.legs.size() - 1);
                lastLeg.to.orig = plan.to.orig;
            }
        }
        options.rctx.debugOutput.finishedRendering();
        return plan;
View Full Code Here


     * @param states The array of states to base the leg on
     * @param showIntermediateStops Whether to include intermediate stops in the leg or not
     * @return The generated leg
     */
    private Leg generateLeg(Graph graph, State[] states, boolean showIntermediateStops) {
        Leg leg = new Leg();

        Edge[] edges = new Edge[states.length - 1];

        leg.startTime = makeCalendar(states[0]);
        leg.endTime = makeCalendar(states[states.length - 1]);

        // Calculate leg distance and fill array of edges
        leg.distance = 0.0;
        for (int i = 0; i < edges.length; i++) {
            edges[i] = states[i + 1].getBackEdge();
            leg.distance += edges[i].getDistance();
        }

        addModeAndAlerts(graph, leg, states);

        TimeZone timeZone = leg.startTime.getTimeZone();
        leg.agencyTimeZoneOffset = timeZone.getOffset(leg.startTime.getTimeInMillis());

        addTripFields(leg, states);

        addPlaces(leg, states, edges, showIntermediateStops);

        if (leg.isTransitLeg()) addRealTimeData(leg, states);

        CoordinateArrayListSequence coordinates = makeCoordinates(edges);
        Geometry geometry = GeometryUtils.getGeometryFactory().createLineString(coordinates);

        leg.legGeometry = PolylineEncoder.createEncodings(geometry);
View Full Code Here

        TestPlanner planner = new TestPlanner(
                "portland", "From::NE 43RD AVE at NE GLISAN ST", "To::NE 43RD AVE at NE ROYAL CT");

        Response response = planner.getItineraries();
        Itinerary itinerary = response.getPlan().itinerary.get(0);
        Leg leg = itinerary.legs.get(0);
        List<WalkStep> steps = leg.walkSteps;
        assertEquals(3, steps.size());
        WalkStep step0 = steps.get(0);
        WalkStep step2 = steps.get(2);
        assertEquals(AbsoluteDirection.NORTH, step0.absoluteDirection);
View Full Code Here

        TestPlanner planner = new TestPlanner(
                "portland", "SE 47TH AVE at SE ASH ST", "NE 47TH AVE at NE COUCH ST");
        Response response = planner.getItineraries();

        Itinerary itinerary = response.getPlan().itinerary.get(0);
        Leg leg = itinerary.legs.get(0);
        List<WalkStep> steps = leg.walkSteps;
        assertEquals(2, steps.size());
        WalkStep step0 = steps.get(0);
        WalkStep step1 = steps.get(1);
View Full Code Here

        // Ban trips with ids 190W1280 and 190W1260 from agency with id TriMet
        planner.setBannedTrips(Arrays.asList("TriMet:190W1280,TriMet:190W1260"));
        // Do the planning
        Response response = planner.getItineraries();
        Itinerary itinerary = response.getPlan().itinerary.get(0);
        Leg leg = itinerary.legs.get(1);
        // Without bannedTrips this leg would contain a trip with id 190W1280
        assertFalse(leg.tripId.equals("190W1280"));
        // Instead a trip is now expected with id 190W1290
        assertTrue(leg.tripId.equals("190W1290"));
    }
View Full Code Here

        planner.setBannedStops(Arrays.asList("TriMet:2106,TriMet:2107"));
        // Do the planning
        Response response = planner.getItineraries();
        // First check the request
        Itinerary itinerary = response.getPlan().itinerary.get(0);
        Leg leg = itinerary.legs.get(1);
        // Without bannedStops this leg would stop at the stop with id 2107
        assertFalse(leg.to.stopId.getId().equals("2107"));
        // Instead a stop is now expected with id 2109
        assertTrue(leg.to.stopId.getId().equals("2109"));
    }
View Full Code Here

        // Do the planning
        Response response = planner.getItineraries();
        // First check the request
        Itinerary itinerary = response.getPlan().itinerary.get(0);
        Leg leg = itinerary.legs.get(1);
        // Validate that this leg uses trip 190W1280
        assertTrue(leg.tripId.equals("190W1280"));

        // Ban stop hard with id 2009 from agency with id TriMet
        // This is a stop that will be passed when using trip 190W1280
View Full Code Here

    public final String getFeedName() {
        return "mmri/2b";
    }

    public void test2b1() {
        Leg leg = plan(+1388530860L, "2b1", "2b2", null, true, false, null, "", "");

        validateLeg(leg, 1388530980000L, 1388531040000L, "2b2", "2b1", null);
    }
View Full Code Here

    public final String getFeedName() {
        return "mmri/2a1";
    }

    public void test2a1() {
        Leg leg = plan(+1388530860L, "2a1", "2a2", null, false, false, null, "", "");

        validateLeg(leg, 1388530860000L, 1388530920000L, "2a2", "2a1", null);
    }
View Full Code Here

        validateLeg(leg, 1388530860000L, 1388530920000L, "2a2", "2a1", null);
    }

    public void test2a2() {
        Leg leg = plan(+1388530980L, "2a1", "2a2", null, false, false, null, "", "");

        validateLeg(leg, 1388531100000L, 1388531160000L, "2a2", "2a1", null);
    }
View Full Code Here

TOP

Related Classes of org.opentripplanner.api.model.Leg

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.