Search in sources :

Example 26 with Stop

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

the class LinkStopToPlatformTest method before.

@Before
public void before() {
    // Set up transit platform
    graph = new Graph();
    ArrayList<IntersectionVertex> vertices = new ArrayList<IntersectionVertex>();
    vertices.add(new IntersectionVertex(graph, "1", 10.22054, 59.13568, "Platform vertex 1"));
    vertices.add(new IntersectionVertex(graph, "2", 10.22432, 59.13519, "Platform vertex 2"));
    vertices.add(new IntersectionVertex(graph, "3", 10.22492, 59.13514, "Platform vertex 3"));
    vertices.add(new IntersectionVertex(graph, "4", 10.22493, 59.13518, "Platform vertex 4"));
    vertices.add(new IntersectionVertex(graph, "5", 10.22056, 59.13575, "Platform vertex 5"));
    AreaEdgeList areaEdgeList = new AreaEdgeList();
    ArrayList<AreaEdge> edges = new ArrayList<AreaEdge>();
    edges.add(createAreaEdge(vertices.get(0), vertices.get(1), areaEdgeList, "edge 1"));
    edges.add(createAreaEdge(vertices.get(1), vertices.get(2), areaEdgeList, "edge 2"));
    edges.add(createAreaEdge(vertices.get(2), vertices.get(3), areaEdgeList, "edge 3"));
    edges.add(createAreaEdge(vertices.get(3), vertices.get(4), areaEdgeList, "edge 4"));
    edges.add(createAreaEdge(vertices.get(4), vertices.get(0), areaEdgeList, "edge 5"));
    edges.add(createAreaEdge(vertices.get(1), vertices.get(0), areaEdgeList, "edge 6"));
    edges.add(createAreaEdge(vertices.get(2), vertices.get(1), areaEdgeList, "edge 7"));
    edges.add(createAreaEdge(vertices.get(3), vertices.get(2), areaEdgeList, "edge 8"));
    edges.add(createAreaEdge(vertices.get(4), vertices.get(3), areaEdgeList, "edge 9"));
    edges.add(createAreaEdge(vertices.get(0), vertices.get(4), areaEdgeList, "edge 10"));
    Stop stop = Stop.stopForTest("TestStop", 59.13545, 10.22213);
    TransitStopVertex stopVertex = new TransitStopVertex(graph, stop, null);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) Stop(org.opentripplanner.model.Stop) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) ArrayList(java.util.ArrayList) AreaEdgeList(org.opentripplanner.routing.edgetype.AreaEdgeList) AreaEdge(org.opentripplanner.routing.edgetype.AreaEdge) Before(org.junit.Before)

Example 27 with Stop

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

the class TestHalfEdges method setUp.

@Before
public void setUp() {
    graph = new Graph();
    // a 0.1 degree x 0.1 degree square
    tl = new IntersectionVertex(graph, "tl", -74.01, 40.01);
    tr = new IntersectionVertex(graph, "tr", -74.0, 40.01);
    bl = new IntersectionVertex(graph, "bl", -74.01, 40.0);
    br = new IntersectionVertex(graph, "br", -74.00, 40.0);
    top = new StreetEdge(tl, tr, GeometryUtils.makeLineString(-74.01, 40.01, -74.0, 40.01), "top", 1500, StreetTraversalPermission.ALL, false);
    bottom = new StreetEdge(br, bl, GeometryUtils.makeLineString(-74.01, 40.0, -74.0, 40.0), "bottom", 1500, StreetTraversalPermission.ALL, false);
    left = new StreetEdge(bl, tl, GeometryUtils.makeLineString(-74.01, 40.0, -74.01, 40.01), "left", 1500, StreetTraversalPermission.ALL, false);
    right = new StreetEdge(br, tr, GeometryUtils.makeLineString(-74.0, 40.0, -74.0, 40.01), "right", 1500, StreetTraversalPermission.PEDESTRIAN, false);
    @SuppressWarnings("unused") StreetEdge topBack = new StreetEdge(tr, tl, (LineString) top.getGeometry().reverse(), "topBack", 1500, StreetTraversalPermission.ALL, true);
    @SuppressWarnings("unused") StreetEdge bottomBack = new StreetEdge(br, bl, (LineString) bottom.getGeometry().reverse(), "bottomBack", 1500, StreetTraversalPermission.ALL, true);
    leftBack = new StreetEdge(tl, bl, (LineString) left.getGeometry().reverse(), "leftBack", 1500, StreetTraversalPermission.ALL, true);
    rightBack = new StreetEdge(tr, br, (LineString) right.getGeometry().reverse(), "rightBack", 1500, StreetTraversalPermission.ALL, true);
    Stop s1 = Stop.stopForTest("fleem station", 40.0099999, -74.005);
    Stop s2 = Stop.stopForTest("morx station", 40.0099999, -74.002);
    station1 = new TransitStopVertex(graph, s1, null);
    station2 = new TransitStopVertex(graph, s2, null);
    station1.addMode(TransitMode.RAIL);
    station2.addMode(TransitMode.RAIL);
    // Linkers aren't run otherwise in testNetworkLinker
    graph.hasStreets = true;
    graph.hasTransit = true;
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) LineString(org.locationtech.jts.geom.LineString) Stop(org.opentripplanner.model.Stop) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Before(org.junit.Before)

Example 28 with Stop

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

the class StopIndexForRaptorTest method listStopIndexesForTripPattern.

@Test
public void listStopIndexesForTripPattern() {
    Stop[] input = new Stop[] { STOP_0, STOP_2, STOP_4 };
    StopIndexForRaptor stopIndex = new StopIndexForRaptor(STOPS, TransitTuningParameters.FOR_TEST);
    int[] result = stopIndex.listStopIndexesForStops(input);
    assertEquals("[0, 2, 4]", Arrays.toString(result));
}
Also used : Stop(org.opentripplanner.model.Stop) StopIndexForRaptor(org.opentripplanner.routing.algorithm.raptor.transit.StopIndexForRaptor) Test(org.junit.Test)

Example 29 with Stop

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

the class TripPatternMapperTest method testMapTripPattern.

@Test
public void testMapTripPattern() {
    NetexTestDataSample sample = new NetexTestDataSample();
    TripPatternMapper tripPatternMapper = new TripPatternMapper(MappingSupport.ID_FACTORY, sample.getStopsById(), sample.getOtpRouteByid(), Collections.emptySet(), sample.getRouteById(), sample.getJourneyPatternById(), sample.getQuayIdByStopPointRef(), new HierarchicalMapById<>(), sample.getServiceJourneyByPatternId(), new Deduplicator());
    TripPatternMapper.Result r = tripPatternMapper.mapTripPattern(sample.getJourneyPattern());
    assertEquals(1, r.tripPatterns.size());
    TripPattern tripPattern = r.tripPatterns.get(0);
    assertEquals(4, tripPattern.getStops().size());
    assertEquals(1, tripPattern.getTrips().size());
    List<Stop> stops = tripPattern.getStops();
    Trip trip = tripPattern.getTrips().get(0);
    assertEquals("RUT:ServiceJourney:1", trip.getId().getId());
    assertEquals("NSR:Quay:1", stops.get(0).getId().getId());
    assertEquals("NSR:Quay:2", stops.get(1).getId().getId());
    assertEquals("NSR:Quay:3", stops.get(2).getId().getId());
    assertEquals("NSR:Quay:4", stops.get(3).getId().getId());
    assertEquals(1, tripPattern.scheduledTimetable.tripTimes.size());
    TripTimes tripTimes = tripPattern.scheduledTimetable.tripTimes.get(0);
    assertEquals(4, tripTimes.getNumStops());
    assertEquals(18000, tripTimes.getDepartureTime(0));
    assertEquals(18240, tripTimes.getDepartureTime(1));
    assertEquals(18600, tripTimes.getDepartureTime(2));
    assertEquals(18900, tripTimes.getDepartureTime(3));
}
Also used : Trip(org.opentripplanner.model.Trip) Stop(org.opentripplanner.model.Stop) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) TripPattern(org.opentripplanner.model.TripPattern) Test(org.junit.Test)

Example 30 with Stop

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

the class OtpTransitServiceImplTest method testGetStopForId.

@Test
public void testGetStopForId() {
    Stop stop = subject.getStopForId(new FeedScopedId("Z", "P"));
    assertEquals("<Stop Z:P>", stop.toString());
}
Also used : Stop(org.opentripplanner.model.Stop) FeedScopedId(org.opentripplanner.model.FeedScopedId) Test(org.junit.Test)

Aggregations

Stop (org.opentripplanner.model.Stop)73 FeedScopedId (org.opentripplanner.model.FeedScopedId)25 ArrayList (java.util.ArrayList)24 TripPattern (org.opentripplanner.model.TripPattern)24 Trip (org.opentripplanner.model.Trip)21 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)13 RoutingService (org.opentripplanner.routing.RoutingService)13 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)13 HashSet (java.util.HashSet)12 Station (org.opentripplanner.model.Station)12 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)11 List (java.util.List)10 Test (org.junit.Test)8 Route (org.opentripplanner.model.Route)8 StopTime (org.opentripplanner.model.StopTime)8 Collectors (java.util.stream.Collectors)7 GET (javax.ws.rs.GET)7 Path (javax.ws.rs.Path)7 ApiStop (org.opentripplanner.api.model.ApiStop)7 TripTimeShort (org.opentripplanner.model.TripTimeShort)7