Examples of AgencyAndId


Examples of org.onebusaway.gtfs.model.AgencyAndId

  private List<AgencyAndId> makeMtaStopList(String... stops) {

    ArrayList<AgencyAndId> out = new ArrayList<AgencyAndId>();
    for (String stop : stops) {
      out.add(new AgencyAndId("MTA NYCT", stop));
      out.add(new AgencyAndId("MTA NYCT", stop + "N"));
      out.add(new AgencyAndId("MTA NYCT", stop + "S"));
    }
    return out;
  }
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

   
    public TripShort (Trip trip) {
        id = trip.getId();
        tripHeadsign = trip.getTripHeadsign();
        serviceId = trip.getServiceId();
        AgencyAndId shape = trip.getShapeId();
        shapeId = shape == null ? null : shape.getId();
        String directionId = trip.getDirectionId();
        direction = directionId == null ? null : Integer.parseInt(directionId);
    }
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

                continue;
            }

            AlertPatch patch = new AlertPatch();
            if (routeId != null) {
                patch.setRoute(new AgencyAndId(agencyId, routeId));
            }
            if (tripId != null) {
                patch.setTrip(new AgencyAndId(agencyId, tripId));
            }
            if (stopId != null) {
                patch.setStop(new AgencyAndId(agencyId, stopId));
            }
            if(agencyId != null && routeId == null && tripId == null && stopId == null) {
                patch.setAgencyId(agencyId);
            }
            patch.setTimePeriods(periods);
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

     * Test different specific transfers
     */
    public void testSpecificTransfer() {
        // Setup from trip with route
        Route fromRoute = new Route();
        fromRoute.setId(new AgencyAndId("A1", "R1"));
        Trip fromTrip = new Trip();
        fromTrip.setId(new AgencyAndId("A1", "T1"));
        fromTrip.setRoute(fromRoute);
       
        // Setup to trip with route
        Route toRoute = new Route();
        toRoute.setId(new AgencyAndId("A1", "R2"));
        Trip toTrip = new Trip();
        toTrip.setId(new AgencyAndId("A1", "T2"));
        toTrip.setRoute(toRoute);
       
        // Create full SpecificTransfer
        SpecificTransfer s1 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), fromTrip.getId(), toTrip.getId(), 1);
        assertTrue(s1.matches(fromTrip, toTrip));
        assertTrue(s1.getSpecificity() == SpecificTransfer.MAX_SPECIFICITY);
        assertTrue(s1.transferTime == 1);
       
        // Create empty SpecificTransfer
        SpecificTransfer s2 = new SpecificTransfer((AgencyAndId) null, null, null, null, 2);
        assertTrue(s2.matches(fromTrip, toTrip));
        assertTrue(s2.getSpecificity() == SpecificTransfer.MIN_SPECIFICITY);
        assertTrue(s2.transferTime == 2);
       
        // Create SpecificTransfer one trip missing
        SpecificTransfer s3 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), null, toTrip.getId(), 3);
        assertTrue(s3.matches(fromTrip, toTrip));
        assertTrue(s3.getSpecificity() == 3);
        assertTrue(s3.transferTime == 3);
       
        // Create SpecificTransfer one trip different
        SpecificTransfer s4 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), new AgencyAndId("A1", "T3"), toTrip.getId(), 4);
        assertFalse(s4.matches(fromTrip, toTrip));
        assertTrue(s4.getSpecificity() == SpecificTransfer.MAX_SPECIFICITY);
        assertTrue(s4.transferTime == 4);
       
        // Create SpecificTransfer one trip and route missing
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

public class TestRouteMatcher extends TestCase {

    public void testRouteMatcher() {

        Route r1 = new Route();
        r1.setId(new AgencyAndId("A1", "42"));
        r1.setShortName("R1");
        Route r2 = new Route();
        r2.setId(new AgencyAndId("A1", "43"));
        r2.setShortName("R2");
        Route r1b = new Route();
        r1b.setId(new AgencyAndId("A2", "42"));
        r1b.setShortName("R1");
        Route r3 = new Route();
        r3.setId(new AgencyAndId("A1", "44"));
        r3.setShortName("R3_b");

        RouteMatcher emptyMatcher = RouteMatcher.emptyMatcher();
        assertFalse(emptyMatcher.matches(r1));
        assertFalse(emptyMatcher.matches(r1b));
        assertFalse(emptyMatcher.matches(r2));

        RouteMatcher matcherR1i = RouteMatcher.parse("A1__42");
        assertTrue(matcherR1i.matches(r1));
        assertFalse(matcherR1i.matches(r1b));
        assertFalse(matcherR1i.matches(r2));

        RouteMatcher matcherR2n = RouteMatcher.parse("A1_R2");
        assertFalse(matcherR2n.matches(r1));
        assertFalse(matcherR2n.matches(r1b));
        assertTrue(matcherR2n.matches(r2));

        RouteMatcher matcherR1R2 = RouteMatcher.parse("A1_R1,A1__43,A2__43");
        assertTrue(matcherR1R2.matches(r1));
        assertFalse(matcherR1R2.matches(r1b));
        assertTrue(matcherR1R2.matches(r2));

        RouteMatcher matcherR1n = RouteMatcher.parse("_R1");
        assertTrue(matcherR1n.matches(r1));
        assertTrue(matcherR1n.matches(r1b));
        assertFalse(matcherR1n.matches(r2));

        RouteMatcher matcherR1R1bR2 = RouteMatcher.parse("A1_R1,A2_R1,A1_R2");
        assertTrue(matcherR1R1bR2.matches(r1));
        assertTrue(matcherR1R1bR2.matches(r1b));
        assertTrue(matcherR1R1bR2.matches(r2));

        RouteMatcher matcherR3e = RouteMatcher.parse("A1_R3 b");
        assertFalse(matcherR3e.matches(r1));
        assertFalse(matcherR3e.matches(r1b));
        assertFalse(matcherR3e.matches(r2));
        assertTrue(matcherR3e.matches(r3));

        RouteMatcher nullList = RouteMatcher.parse(null);
        assertTrue(nullList == RouteMatcher.emptyMatcher());

        RouteMatcher emptyList = RouteMatcher.parse("");
        assertTrue(emptyList == RouteMatcher.emptyMatcher());

        RouteMatcher degenerate = RouteMatcher.parse(",,,");
        assertTrue(degenerate == RouteMatcher.emptyMatcher());

        boolean thrown = false;
        try {
            RouteMatcher badMatcher = RouteMatcher.parse("A1_R1_42");
        } catch (IllegalArgumentException e) {
            thrown = true;
        }
        assertTrue(thrown);
       
        Route r1c = new Route();
        r1c.setId(new AgencyAndId("A_1", "R_42"));
        r1c.setShortName("R_42");

        RouteMatcher matcherR1c = RouteMatcher.parse("A\\_1_R 42");
        assertTrue(matcherR1c.matches(r1c));
        assertFalse(matcherR1c.matches(r1));
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

       
        // Create (very simple) new graph
        Graph graph = new Graph();
       
        Stop stop1 = new Stop();
        stop1.setId(new AgencyAndId("agency", "stop1"));
        Stop stop2 = new Stop();
        stop2.setId(new AgencyAndId("agency", "stop2"));
       
        Vertex from = new TransitStop(graph, stop1);
        Vertex to = new TransitStop(graph, stop2);
       
        // Create dummy TimetableResolver
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

    /**
     * Test different stop matchers
     */
    public void testStopMatcher() {
        Stop s1 = new Stop();
        s1.setId(new AgencyAndId("A1", "42"));
        Stop s2 = new Stop();
        s2.setId(new AgencyAndId("A1", "43"));

        StopMatcher emptyMatcher = StopMatcher.emptyMatcher();
        assertFalse(emptyMatcher.matches(s1));
        assertFalse(emptyMatcher.matches(s2));

View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

    /**
     * Test different stop matchers including stops with parents
     */
    public void testStopMatcherParents() {
        Stop parent = new Stop();
        parent.setId(new AgencyAndId("A1", "10"));
        Stop s1 = new Stop();
        s1.setId(new AgencyAndId("A1", "42"));
        s1.setParentStation("10");
        Stop s2 = new Stop();
        s2.setId(new AgencyAndId("A1", "43"));
        s2.setParentStation("10");
       
        StopMatcher matcherParent = StopMatcher.parse("A1:10");
        assertTrue(matcherParent.matches(parent));
        assertTrue(matcherParent.matches(s1));
View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

        snp1.setTimePeriods(Collections.singletonList(new TimePeriod(
                0, 1000L * 60 * 60 * 24 * 365 * 40))); // until ~1/1/2011
        Alert note1 = Alert.createSimpleAlerts("The first note");
        snp1.setAlert(note1);
        snp1.setId("id1");
        snp1.setStop(new AgencyAndId("agency", "A"));
        snp1.apply(graph);

        Vertex stop_a = graph.getVertex("agency:A");
        Vertex stop_e = graph.getVertex("agency:E_arrive");

View Full Code Here

Examples of org.onebusaway.gtfs.model.AgencyAndId

        timePeriods.add(new TimePeriod(secondPeriodStartTime, secondPeriodEndTime));
        snp1.setTimePeriods(timePeriods);
        Alert note1 = Alert.createSimpleAlerts("The first note");
        snp1.setAlert(note1);
        snp1.setId("id1");
        snp1.setStop(new AgencyAndId("agency", "A"));
        snp1.apply(graph);

        Vertex stop_a = graph.getVertex("agency:A");
        Vertex stop_e = graph.getVertex("agency:E_arrive");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.