Search in sources :

Example 1 with StopTimeInstanceBean

use of org.onebusaway.transit_data.model.StopTimeInstanceBean in project onebusaway-application-modules by camsys.

the class StopScheduleBeanServiceImpl method applyGroupIdForGroupKey.

private void applyGroupIdForGroupKey(StopTimeByDirectionEntry stopTimesForDirection, Object key, String groupId) {
    List<StopTimeInstanceBean> stopTimesForGroup = stopTimesForDirection.getStopTimesForGroupKey(key);
    for (StopTimeInstanceBean stiBean : stopTimesForGroup) {
        List<String> groupIds = stiBean.getGroupIds();
        if (groupIds == null) {
            groupIds = new ArrayList<String>();
            stiBean.setGroupIds(groupIds);
        }
        groupIds.add(groupId);
    }
}
Also used : StopTimeInstanceBean(org.onebusaway.transit_data.model.StopTimeInstanceBean)

Example 2 with StopTimeInstanceBean

use of org.onebusaway.transit_data.model.StopTimeInstanceBean in project onebusaway-application-modules by camsys.

the class StopTimeBeanServiceImpl method getStopTimeInstanceAsBean.

@Override
public StopTimeInstanceBean getStopTimeInstanceAsBean(StopTimeInstance instance) {
    StopTimeInstanceBean bean = new StopTimeInstanceBean();
    bean.setArrivalTime(instance.getArrivalTime());
    bean.setDepartureTime(instance.getDepartureTime());
    bean.setServiceDate(instance.getServiceDate());
    bean.setTripId(AgencyAndIdLibrary.convertToString(instance.getTrip().getTrip().getId()));
    return bean;
}
Also used : StopTimeInstanceBean(org.onebusaway.transit_data.model.StopTimeInstanceBean)

Example 3 with StopTimeInstanceBean

use of org.onebusaway.transit_data.model.StopTimeInstanceBean in project onebusaway-application-modules by camsys.

the class ScheduleAction method getFilteredStopTimes.

private List<StopTimeInstanceBean> getFilteredStopTimes(StopRouteDirectionScheduleBean direction) {
    List<StopTimeInstanceBean> stopTimes = direction.getStopTimes();
    List<StopTimeInstanceBean> filteredStopTimes = new ArrayList<StopTimeInstanceBean>(stopTimes.size());
    boolean showArrivals = (_showArrivals == null) ? !(directionHasDepartures(direction)) : _showArrivals;
    for (StopTimeInstanceBean stopTime : stopTimes) {
        if ((showArrivals && stopTime.isArrivalEnabled()) || (!showArrivals && stopTime.isDepartureEnabled()))
            filteredStopTimes.add(stopTime);
    }
    return filteredStopTimes;
}
Also used : StopTimeInstanceBean(org.onebusaway.transit_data.model.StopTimeInstanceBean) ArrayList(java.util.ArrayList)

Example 4 with StopTimeInstanceBean

use of org.onebusaway.transit_data.model.StopTimeInstanceBean in project onebusaway-application-modules by camsys.

the class UserReportingServiceImpl method getRecordAsBean.

private TripProblemReportBean getRecordAsBean(TripProblemReportRecord record) {
    AgencyAndId stopId = record.getStopId();
    AgencyAndId tripId = record.getTripId();
    TripProblemReportBean bean = new TripProblemReportBean();
    bean.setCode(record.getCode());
    bean.setId(record.getId());
    bean.setServiceDate(record.getServiceDate());
    bean.setStatus(record.getStatus());
    bean.setLabel(record.getLabel());
    bean.setStopId(AgencyAndIdLibrary.convertToString(stopId));
    bean.setTime(record.getTime());
    bean.setTripId(AgencyAndIdLibrary.convertToString(tripId));
    bean.setUserComment(record.getUserComment());
    bean.setUserLat(record.getUserLat());
    bean.setUserLon(record.getUserLon());
    bean.setUserLocationAccuracy(record.getUserLocationAccuracy());
    bean.setUserOnVehicle(record.isUserOnVehicle());
    bean.setUserVehicleNumber(record.getUserVehicleNumber());
    bean.setPredicted(record.isPredicted());
    bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
    bean.setDistanceAlongBlock(record.getDistanceAlongBlock());
    bean.setScheduleDeviation(record.getScheduleDeviation());
    bean.setVehicleLat(record.getVehicleLat());
    bean.setVehicleLon(record.getVehicleLon());
    if (stopId != null) {
        try {
            bean.setStop(_stopBeanService.getStopForId(stopId));
        } catch (NoSuchStopServiceException ex) {
        }
    }
    if (tripId != null) {
        bean.setTrip(_tripBeanService.getTripForId(tripId));
    }
    if (tripId != null && stopId != null) {
        TripEntry trip = _graph.getTripEntryForId(tripId);
        StopEntry stop = _graph.getStopEntryForId(stopId);
        if (trip != null && stop != null) {
            AgencyAndId vehicleId = record.getMatchedVehicleId();
            if (vehicleId == null)
                vehicleId = record.getVehicleId();
            ArrivalAndDepartureQuery query = new ArrivalAndDepartureQuery();
            query.setStop(stop);
            query.setStopSequence(-1);
            query.setTrip(trip);
            query.setServiceDate(record.getServiceDate());
            query.setVehicleId(vehicleId);
            query.setTime(record.getTime());
            ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
            if (instance != null) {
                StopTimeInstance sti = instance.getStopTimeInstance();
                StopTimeInstanceBean stopTimeBean = _stopTimeBeanService.getStopTimeInstanceAsBean(sti);
                bean.setStopTime(stopTimeBean);
            }
        }
    }
    return bean;
}
Also used : StopTimeInstanceBean(org.onebusaway.transit_data.model.StopTimeInstanceBean) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopTimeInstance(org.onebusaway.transit_data_federation.model.StopTimeInstance) ArrivalAndDepartureQuery(org.onebusaway.transit_data_federation.services.ArrivalAndDepartureQuery) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) ArrivalAndDepartureInstance(org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance) TripProblemReportBean(org.onebusaway.transit_data.model.problems.TripProblemReportBean)

Example 5 with StopTimeInstanceBean

use of org.onebusaway.transit_data.model.StopTimeInstanceBean in project onebusaway-application-modules by camsys.

the class ScheduleAction method filterResults.

/**
 **
 *
 ***
 */
private void filterResults() {
    List<StopRouteScheduleBean> routes = _result.getRoutes();
    List<StopRouteScheduleBean> filteredRoutes = new ArrayList<StopRouteScheduleBean>(routes.size());
    for (StopRouteScheduleBean route : routes) {
        List<StopRouteDirectionScheduleBean> directions = route.getDirections();
        List<StopRouteDirectionScheduleBean> filteredDirections = new ArrayList<StopRouteDirectionScheduleBean>(directions.size());
        for (StopRouteDirectionScheduleBean direction : directions) {
            List<StopTimeInstanceBean> filteredStopTimes = getFilteredStopTimes(direction);
            List<FrequencyInstanceBean> filteredFrequencies = getFilteredFrequencies(direction);
            if (!(filteredStopTimes.isEmpty() && filteredFrequencies.isEmpty())) {
                direction.setStopTimes(filteredStopTimes);
                direction.setFrequencies(filteredFrequencies);
                filteredDirections.add(direction);
            }
        }
        if (!filteredDirections.isEmpty()) {
            route.setDirections(filteredDirections);
            filteredRoutes.add(route);
        }
    }
    _result.setRoutes(filteredRoutes);
}
Also used : StopTimeInstanceBean(org.onebusaway.transit_data.model.StopTimeInstanceBean) StopRouteScheduleBean(org.onebusaway.transit_data.model.StopRouteScheduleBean) FrequencyInstanceBean(org.onebusaway.transit_data.model.schedule.FrequencyInstanceBean) ArrayList(java.util.ArrayList) StopRouteDirectionScheduleBean(org.onebusaway.transit_data.model.StopRouteDirectionScheduleBean)

Aggregations

StopTimeInstanceBean (org.onebusaway.transit_data.model.StopTimeInstanceBean)7 ArrayList (java.util.ArrayList)4 FrequencyInstanceBean (org.onebusaway.transit_data.model.schedule.FrequencyInstanceBean)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 StopRouteDirectionScheduleBean (org.onebusaway.transit_data.model.StopRouteDirectionScheduleBean)2 StopRouteScheduleBean (org.onebusaway.transit_data.model.StopRouteScheduleBean)2 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)2 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)2 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)2 HashSet (java.util.HashSet)1 List (java.util.List)1 FactoryMap (org.onebusaway.collections.FactoryMap)1 Cacheable (org.onebusaway.container.cache.Cacheable)1 NoSuchStopServiceException (org.onebusaway.exceptions.NoSuchStopServiceException)1 RouteBean (org.onebusaway.transit_data.model.RouteBean)1 StopTimeGroupBean (org.onebusaway.transit_data.model.StopTimeGroupBean)1 TripProblemReportBean (org.onebusaway.transit_data.model.problems.TripProblemReportBean)1 TripNarrative (org.onebusaway.transit_data_federation.model.narrative.TripNarrative)1 ArrivalAndDepartureQuery (org.onebusaway.transit_data_federation.services.ArrivalAndDepartureQuery)1 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)1