Search in sources :

Example 11 with Leg

use of org.opentripplanner.api.model.Leg in project OpenTripPlanner by opentripplanner.

the class WheelchairTest method test2b1.

public void test2b1() {
    Leg leg = plan(+1388530860L, "2b1", "2b2", null, true, false, null, "", "");
    validateLeg(leg, 1388530980000L, 1388531040000L, "2b2", "2b1", null);
}
Also used : Leg(org.opentripplanner.api.model.Leg)

Example 12 with Leg

use of org.opentripplanner.api.model.Leg in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method validateIntermediatePlacesVisited.

// Check that every via location is visited in the right order
private void validateIntermediatePlacesVisited(Itinerary itinerary, GenericLocation[] via) {
    int legIndex = 0;
    for (GenericLocation location : via) {
        Leg leg;
        do {
            assertTrue("Intermediate location was not an endpoint of any leg", legIndex < itinerary.legs.size());
            leg = itinerary.legs.get(legIndex);
            legIndex++;
        } while (Math.abs(leg.to.lat - location.lat) > DELTA || Math.abs(leg.to.lon - location.lng) > DELTA);
    }
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Leg(org.opentripplanner.api.model.Leg)

Example 13 with Leg

use of org.opentripplanner.api.model.Leg in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method validateLegsTemporally.

// Check that the start time and end time of each leg are consistent
private void validateLegsTemporally(RoutingRequest request, Itinerary itinerary) {
    Calendar departTime = Calendar.getInstance(timeZone);
    Calendar arriveTime = Calendar.getInstance(timeZone);
    if (request.arriveBy) {
        departTime = itinerary.legs.get(0).from.departure;
        arriveTime.setTimeInMillis(request.dateTime * 1000);
    } else {
        departTime.setTimeInMillis(request.dateTime * 1000);
        arriveTime = itinerary.legs.get(itinerary.legs.size() - 1).to.arrival;
    }
    long sumOfDuration = 0;
    for (Leg leg : itinerary.legs) {
        assertFalse(departTime.after(leg.startTime));
        assertEquals(leg.startTime, leg.from.departure);
        assertEquals(leg.endTime, leg.to.arrival);
        assertFalse(leg.startTime.after(leg.endTime));
        departTime = leg.to.arrival;
        sumOfDuration += leg.getDuration();
    }
    sumOfDuration += itinerary.waitingTime;
    assertFalse(departTime.after(arriveTime));
    // Check the total duration of the legs,
    // allow 1 second per leg for rounding errors
    int accuracy = itinerary.legs.size();
    assertEquals(sumOfDuration, itinerary.duration.doubleValue(), accuracy);
}
Also used : Calendar(java.util.Calendar) Leg(org.opentripplanner.api.model.Leg)

Example 14 with Leg

use of org.opentripplanner.api.model.Leg in project OpenTripPlanner by opentripplanner.

the class TimeTest method test1g1.

public void test1g1() {
    Leg leg = plan(+1388530920L, "1g1", "1g2", null, false, false, null, "", "");
    validateLeg(leg, 1388530980000L, 1388531040000L, "1g2", "1g1", null);
}
Also used : Leg(org.opentripplanner.api.model.Leg)

Example 15 with Leg

use of org.opentripplanner.api.model.Leg in project OpenTripPlanner by opentripplanner.

the class TimeTest method test1g6.

public void test1g6() {
    Leg leg = plan(-1388703840L, "1g1", "1g2", null, false, false, null, "", "");
    validateLeg(leg, 1388703780000L, 1388703840000L, "1g2", "1g1", null);
}
Also used : Leg(org.opentripplanner.api.model.Leg)

Aggregations

Leg (org.opentripplanner.api.model.Leg)20 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)1 Place (org.opentripplanner.api.model.Place)1 GenericLocation (org.opentripplanner.common.model.GenericLocation)1