Package org.onebusaway.gtfs.model

Examples of org.onebusaway.gtfs.model.Stop


                elapsedTime1 = s.getElapsedTimeSeconds();
                numBoardings1 = s.getNumBoardings();
            }

            /* Get a random transit hop from the computed path */
            Stop end = null;
            PatternStopVertex nextV = null;
            TripTimes tripTimes = null;
            int stopIndex = 0;
            long newStart = 0L;
            int nhop = 0;
            for (State s : path.states) {
                if (s.getVertex() instanceof PatternArriveVertex
                        && s.getBackEdge() instanceof PatternHop)
                    nhop++;
            }
            int hop = rand.nextInt(nhop);
            nhop = 0;
            float k = rand.nextFloat();
            for (State s : path.states) {
                Vertex v = s.getVertex();
                if (v instanceof PatternArriveVertex && s.getBackEdge() instanceof PatternHop) {
                    if (hop == nhop) {
                        PatternArriveVertex pav = (PatternArriveVertex) v;
                        end = pav.getStop();
                        nextV = pav;
                        PatternHop phe = (PatternHop) s.getBackEdge();
                        stopIndex = phe.getStopIndex();
                        tripTimes = s.getTripTimes();
                        int hopDuration = tripTimes.getRunningTime(stopIndex);
                        /*
                         * New start time at k% of hop. Note: do not try to make: round(time +
                         * k.hop) as it will be off few seconds due to floating-point rounding
                         * errors.
                         */
                        newStart = s.getBackState().getTimeSeconds() + Math.round(hopDuration * k);
                        break;
                    }
                    nhop++;
                }
            }
            System.out.println("Boarded depart: trip=" + tripTimes.trip + ", nextStop="
                    + nextV.getStop() + " stopIndex=" + stopIndex + " startTime="
                    + new Date(newStart * 1000L));

            /* And use it for onboard departure */
            double lat = end.getLat();
            double lon = end.getLon(); // Mock location, not really important here.
            OnboardDepartVertex onboardOrigin = new OnboardDepartVertex("OnBoard_Origin", lat, lon);
            @SuppressWarnings("unused")
            OnBoardDepartPatternHop currentHop = new OnBoardDepartPatternHop(onboardOrigin, nextV,
                    tripTimes, options.rctx.serviceDays.get(1), stopIndex, k);

View Full Code Here


    /**
     * Test transfer table
     */
    public void testTransferTable() {
        // Setup from stop
        Stop fromStop = new Stop();
        fromStop.setId(new AgencyAndId("A1", "S1"));
       
        // Setup to stop
        Stop toStop = new Stop();
        toStop.setId(new AgencyAndId("A1", "S2"));
       
        // Setup to stop parent
        Stop toStopParent = new Stop();
        toStopParent.setId(new AgencyAndId("A1", "S3"));
        toStop.setParentStation("S3");
       
        // Setup from trip with route
        Route fromRoute = new Route();
        fromRoute.setId(new AgencyAndId("A1", "R1"));
View Full Code Here

        // Validate result
        assertEquals("8.1", trips.get(0).getId().getId());
        assertEquals("4.2", trips.get(1).getId().getId());

        // Add transfer to table, transfer time was 27600 seconds
        Stop stopK = new Stop();
        stopK.setId(new AgencyAndId("agency", "K"));
        Stop stopF = new Stop();
        stopF.setId(new AgencyAndId("agency", "F"));
        table.addTransferTime(stopK, stopF, null, null, null, null, 27601);

        // Plan journey
        path = planJourney(options);
        trips = extractTrips(path);
View Full Code Here

        // Validate result
        assertEquals("8.1", trips.get(0).getId().getId());
        assertEquals("4.2", trips.get(1).getId().getId());

        // Add transfer to table, transfer time was 27600 seconds
        Stop stopK = new Stop();
        stopK.setId(new AgencyAndId("agency", "K"));
        Stop stopF = new Stop();
        stopF.setId(new AgencyAndId("agency", "F"));
        table.addTransferTime(stopK, stopF, null, null, null, null, 27601);

        // Plan journey
        path = planJourney(options, true);
        trips = extractTrips(path);
View Full Code Here

        }
        assertTrue(time >= 0);

        // Add transfer to table such that the next trip will be chosen
        // (there are 3600 seconds between trips), transfer time was 75 seconds
        Stop stopP = new Stop();
        stopP.setId(new AgencyAndId("agency", "P"));
        Stop stopU = new Stop();
        stopU.setId(new AgencyAndId("agency", "U"));
        table.addTransferTime(stopP, stopU, null, null, null, null, 3675);

        // Plan journey
        path = planJourney(options);
        trips = extractTrips(path);
View Full Code Here

        }
        assertTrue(time >= 0);

        // Add transfer to table such that the next trip will be chosen
        // (there are 3600 seconds between trips), transfer time was 75 seconds
        Stop stopV = new Stop();
        stopV.setId(new AgencyAndId("agency", "V"));
        Stop stopI = new Stop();
        stopI.setId(new AgencyAndId("agency", "I"));
        table.addTransferTime(stopV, stopI, null, null, null, null, 3675);

        // Plan journey
        path = planJourney(options);
        trips = extractTrips(path);
View Full Code Here

        // Validate result
        assertEquals("8.1", trips.get(0).getId().getId());
        assertEquals("4.2", trips.get(1).getId().getId());

        // Add forbidden transfer to table
        Stop stopK = new Stop();
        stopK.setId(new AgencyAndId("agency", "K"));
        Stop stopF = new Stop();
        stopF.setId(new AgencyAndId("agency", "F"));
        table.addTransferTime(stopK, stopF, null, null, null, null,
                StopTransfer.FORBIDDEN_TRANSFER);

        // Plan journey
        path = planJourney(options);
View Full Code Here

     */
    private void addPlaces(Leg leg, State[] states, Edge[] edges, boolean showIntermediateStops) {
        Vertex firstVertex = states[0].getVertex();
        Vertex lastVertex = states[states.length - 1].getVertex();

        Stop firstStop = firstVertex instanceof TransitVertex ?
                ((TransitVertex) firstVertex).getStop(): null;
        Stop lastStop = lastVertex instanceof TransitVertex ?
                ((TransitVertex) lastVertex).getStop(): null;
        TripTimes tripTimes = states[states.length - 1].getTripTimes();

        leg.from = makePlace(states[0], firstVertex, edges[0], firstStop, tripTimes);
        leg.from.arrival = null;
        leg.to = makePlace(states[states.length - 1], lastVertex, null, lastStop, tripTimes);
        leg.to.departure = null;

        if (showIntermediateStops) {
            leg.stop = new ArrayList<Place>();

            Stop previousStop = null;
            Stop currentStop;

            for (int i = 1; i < edges.length; i++) {
                Vertex vertex = states[i].getVertex();

                if (!(vertex instanceof TransitVertex)) continue;
View Full Code Here

    @Override
    public Stop unmarshal(StopType arg) throws Exception {
        if (arg == null) {
            return null;
        }
        Stop a = new Stop();
        a.setId(arg.id);
        a.setName(arg.stopName);
        a.setCode(arg.stopCode);
        a.setDesc(arg.stopDesc);
        a.setLat(arg.stopLat);
        a.setLon(arg.stopLon);
        a.setZoneId(arg.zoneId);
        a.setUrl(arg.stopUrl);
        a.setLocationType(arg.locationType);
        a.setParentStation(arg.parentStation);
        a.setWheelchairBoarding(arg.wheelchairBoarding);
        a.setDirection(arg.direction);
        return new Stop(a);
    }
View Full Code Here

                graph, "Vertex 2", 0, 0);
        IntersectionVertex v4 = new IntersectionVertex(
                graph, "Vertex 4", 1, 1);

        // Stops for legs 1, 2 and 4, plus initialization and storage in a list
        Stop trainStopDepart = new Stop();
        Stop trainStopDwell = new Stop();
        Stop trainStopInterline = new Stop();
        Stop trainStopArrive = new Stop();
        Stop ferryStopDepart = new Stop();
        Stop ferryStopArrive = new Stop();

        trainStopDepart.setId(new AgencyAndId("Train", "Depart"));
        trainStopDepart.setName("Train stop depart");
        trainStopDepart.setLon(1);
        trainStopDepart.setLat(1);
        trainStopDepart.setCode("Train depart code");
        trainStopDepart.setPlatformCode("Train depart platform");
        trainStopDepart.setZoneId("Train depart zone");
        trainStopDwell.setId(new AgencyAndId("Train", "Dwell"));
        trainStopDwell.setName("Train stop dwell");
        trainStopDwell.setLon(45);
        trainStopDwell.setLat(23);
        trainStopDwell.setCode("Train dwell code");
        trainStopDwell.setPlatformCode("Train dwell platform");
        trainStopDwell.setZoneId("Train dwell zone");
        trainStopInterline.setId(new AgencyAndId("Train", "Interline"));
        trainStopInterline.setName("Train stop interline");
        trainStopInterline.setLon(89);
        trainStopInterline.setLat(45);
        trainStopInterline.setCode("Train interline code");
        trainStopInterline.setPlatformCode("Train interline platform");
        trainStopInterline.setZoneId("Train interline zone");
        trainStopArrive.setId(new AgencyAndId("Train", "Arrive"));
        trainStopArrive.setName("Train stop arrive");
        trainStopArrive.setLon(133);
        trainStopArrive.setLat(67);
        trainStopArrive.setCode("Train arrive code");
        trainStopArrive.setPlatformCode("Train arrive platform");
        trainStopArrive.setZoneId("Train arrive zone");
        ferryStopDepart.setId(new AgencyAndId("Ferry", "Depart"));
        ferryStopDepart.setName("Ferry stop depart");
        ferryStopDepart.setLon(135);
        ferryStopDepart.setLat(67);
        ferryStopDepart.setCode("Ferry depart code");
        ferryStopDepart.setPlatformCode("Ferry depart platform");
        ferryStopDepart.setZoneId("Ferry depart zone");
        ferryStopArrive.setId(new AgencyAndId("Ferry", "Arrive"));
        ferryStopArrive.setName("Ferry stop arrive");
        ferryStopArrive.setLon(179);
        ferryStopArrive.setLat(89);
        ferryStopArrive.setCode("Ferry arrive code");
        ferryStopArrive.setPlatformCode("Ferry arrive platform");
        ferryStopArrive.setZoneId("Ferry arrive zone");

        ArrayList<Stop> firstStops = new ArrayList<Stop>();
        ArrayList<Stop> secondStops = new ArrayList<Stop>();
        ArrayList<Stop> thirdStops = new ArrayList<Stop>();
View Full Code Here

TOP

Related Classes of org.onebusaway.gtfs.model.Stop

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.