Search in sources :

Example 66 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class OtpTransitServiceImplTest method testGetShapePointsForShapeId.

@Test
public void testGetShapePointsForShapeId() {
    List<ShapePoint> shapePoints = subject.getShapePointsForShapeId(new FeedScopedId("Z", "5"));
    assertEquals("[#1 (41,-72), #2 (41,-72), #3 (40,-72), #4 (41,-73), #5 (41,-74)]", shapePoints.stream().map(OtpTransitServiceImplTest::toString).collect(toList()).toString());
}
Also used : ShapePoint(org.opentripplanner.model.ShapePoint) FeedScopedId(org.opentripplanner.model.FeedScopedId) Test(org.junit.Test)

Example 67 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class ItineraryTest method testDerivedFieldsWithTrainAllTheWay.

@Test
public void testDerivedFieldsWithTrainAllTheWay() {
    Itinerary result = newItinerary(TestItineraryBuilder.A).rail(20, 5, 15, TestItineraryBuilder.B).build();
    assertEquals(600, result.durationSeconds);
    assertEquals(0, result.nTransfers);
    assertEquals(720, result.generalizedCost);
    assertEquals(600, result.transitTimeSeconds);
    assertEquals(0, result.nonTransitTimeSeconds);
    assertEquals(0, result.waitingTimeSeconds);
    assertFalse(result.walkOnly);
    // Expected fields on bus leg set
    assertSameLocation(TestItineraryBuilder.A, result.firstLeg().from);
    assertSameLocation(TestItineraryBuilder.B, result.firstLeg().to);
    assertEquals(newTime(5), result.firstLeg().startTime);
    assertEquals(newTime(15), result.firstLeg().endTime);
    assertEquals(TraverseMode.RAIL, result.firstLeg().mode);
    assertEquals(new FeedScopedId("F", "20"), result.firstLeg().getTrip().getId());
    assertEquals(15_000, result.firstLeg().distanceMeters, 1E-3);
    assertEquals("A ~ RAIL 20 12:05 12:15 ~ B [cost: 720]", result.toStr());
}
Also used : TestItineraryBuilder.newItinerary(org.opentripplanner.model.plan.TestItineraryBuilder.newItinerary) FeedScopedId(org.opentripplanner.model.FeedScopedId) Test(org.junit.Test)

Example 68 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class NetexLoaderSmokeTest method assertStops.

private void assertStops(Collection<Stop> stops) {
    Map<FeedScopedId, Stop> map = stops.stream().collect(Collectors.toMap(Stop::getId, s -> s));
    Stop quay = map.get(fId("NSR:Quay:122003"));
    assertEquals("N/A", quay.getName());
    assertEquals(59.909803, quay.getLat(), 0.000001);
    assertEquals(10.748062, quay.getLon(), 0.000001);
    assertEquals("RB:NSR:StopPlace:3995", quay.getParentStation().getId().toString());
    assertEquals("L", quay.getCode());
    assertEquals(16, stops.size());
}
Also used : StopTimeKey(org.opentripplanner.model.StopTimeKey) Trip(org.opentripplanner.model.Trip) MultiModalStation(org.opentripplanner.model.MultiModalStation) Multimap(com.google.common.collect.Multimap) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) ArrayList(java.util.ArrayList) TransitEntity(org.opentripplanner.model.TransitEntity) Map(java.util.Map) ConstantsForTests(org.opentripplanner.ConstantsForTests) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Assert.fail(org.junit.Assert.fail) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) FeedScopedId(org.opentripplanner.model.FeedScopedId) Station(org.opentripplanner.model.Station) Operator(org.opentripplanner.model.Operator) TripPattern(org.opentripplanner.model.TripPattern) Stop(org.opentripplanner.model.Stop) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Notice(org.opentripplanner.model.Notice) Agency(org.opentripplanner.model.Agency) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) OtpTransitService(org.opentripplanner.model.OtpTransitService) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) Assert.assertEquals(org.junit.Assert.assertEquals) Stop(org.opentripplanner.model.Stop) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 69 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class NetexLoaderSmokeTest method assertTripPatterns.

private void assertTripPatterns(Collection<TripPattern> patterns) {
    Map<FeedScopedId, TripPattern> map = patterns.stream().collect(Collectors.toMap(TripPattern::getId, s -> s));
    TripPattern p = map.get(fId("RUT:JourneyPattern:12-1"));
    assertEquals("Jernbanetorget", p.getDirection());
    assertEquals("RB", p.getFeedId());
    assertEquals("[<Stop RB:NSR:Quay:7203>, <Stop RB:NSR:Quay:8027>]", p.getStops().toString());
    assertEquals("[<Trip RB:RUT:ServiceJourney:12-101375-1000>]", p.getTrips().toString());
    // TODO OTP2 - Why?
    assertNull(p.getServices());
    assertEquals(4, patterns.size());
}
Also used : StopTimeKey(org.opentripplanner.model.StopTimeKey) Trip(org.opentripplanner.model.Trip) MultiModalStation(org.opentripplanner.model.MultiModalStation) Multimap(com.google.common.collect.Multimap) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) ArrayList(java.util.ArrayList) TransitEntity(org.opentripplanner.model.TransitEntity) Map(java.util.Map) ConstantsForTests(org.opentripplanner.ConstantsForTests) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Assert.fail(org.junit.Assert.fail) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) FeedScopedId(org.opentripplanner.model.FeedScopedId) Station(org.opentripplanner.model.Station) Operator(org.opentripplanner.model.Operator) TripPattern(org.opentripplanner.model.TripPattern) Stop(org.opentripplanner.model.Stop) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Notice(org.opentripplanner.model.Notice) Agency(org.opentripplanner.model.Agency) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) OtpTransitService(org.opentripplanner.model.OtpTransitService) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) Assert.assertEquals(org.junit.Assert.assertEquals) FeedScopedId(org.opentripplanner.model.FeedScopedId) TripPattern(org.opentripplanner.model.TripPattern)

Example 70 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class NetexLoaderSmokeTest method assertMultiModalStations.

private void assertMultiModalStations(Collection<MultiModalStation> multiModalStations) {
    Map<FeedScopedId, MultiModalStation> map = multiModalStations.stream().collect(Collectors.toMap(MultiModalStation::getId, s -> s));
    MultiModalStation multiModalStation = map.get(fId("NSR:StopPlace:58243"));
    assertEquals("Bergkrystallen", multiModalStation.getName());
    assertEquals(59.866603, multiModalStation.getLat(), 0.000001);
    assertEquals(10.821614, multiModalStation.getLon(), 0.000001);
    assertEquals(3, multiModalStations.size());
}
Also used : StopTimeKey(org.opentripplanner.model.StopTimeKey) Trip(org.opentripplanner.model.Trip) MultiModalStation(org.opentripplanner.model.MultiModalStation) Multimap(com.google.common.collect.Multimap) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) ArrayList(java.util.ArrayList) TransitEntity(org.opentripplanner.model.TransitEntity) Map(java.util.Map) ConstantsForTests(org.opentripplanner.ConstantsForTests) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) Assert.fail(org.junit.Assert.fail) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) FeedScopedId(org.opentripplanner.model.FeedScopedId) Station(org.opentripplanner.model.Station) Operator(org.opentripplanner.model.Operator) TripPattern(org.opentripplanner.model.TripPattern) Stop(org.opentripplanner.model.Stop) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Notice(org.opentripplanner.model.Notice) Agency(org.opentripplanner.model.Agency) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) OtpTransitService(org.opentripplanner.model.OtpTransitService) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) Assert.assertEquals(org.junit.Assert.assertEquals) FeedScopedId(org.opentripplanner.model.FeedScopedId) MultiModalStation(org.opentripplanner.model.MultiModalStation)

Aggregations

FeedScopedId (org.opentripplanner.model.FeedScopedId)117 Trip (org.opentripplanner.model.Trip)32 Test (org.junit.Test)29 Stop (org.opentripplanner.model.Stop)25 TripPattern (org.opentripplanner.model.TripPattern)25 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)21 ArrayList (java.util.ArrayList)20 Route (org.opentripplanner.model.Route)15 HashSet (java.util.HashSet)11 List (java.util.List)11 Agency (org.opentripplanner.model.Agency)11 Collection (java.util.Collection)9 Map (java.util.Map)9 Collectors (java.util.stream.Collectors)9 ZonedDateTime (java.time.ZonedDateTime)8 TransitEntity (org.opentripplanner.model.TransitEntity)8 RoutingService (org.opentripplanner.routing.RoutingService)8 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)8 Notice (org.opentripplanner.model.Notice)7 Station (org.opentripplanner.model.Station)7