Search in sources :

Example 1 with FrequencyBean

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

the class TripStatusBeanServiceImpl method getTripEntryAndBlockLocationAsTripDetails.

private TripDetailsBean getTripEntryAndBlockLocationAsTripDetails(BlockTripInstance blockTripInstance, BlockLocation blockLocation, TripDetailsInclusionBean inclusion, long time) {
    TripBean trip = null;
    long serviceDate = blockTripInstance.getServiceDate();
    FrequencyBean frequency = null;
    TripStopTimesBean stopTimes = null;
    TripStatusBean status = null;
    AgencyAndId vehicleId = null;
    boolean missing = false;
    FrequencyEntry frequencyLabel = blockTripInstance.getFrequencyLabel();
    if (frequencyLabel != null) {
        frequency = FrequencyBeanLibrary.getBeanForFrequency(serviceDate, frequencyLabel);
    }
    BlockTripEntry blockTrip = blockTripInstance.getBlockTrip();
    TripEntry tripEntry = blockTrip.getTrip();
    if (inclusion.isIncludeTripBean()) {
        trip = _tripBeanService.getTripForId(tripEntry.getId());
        if (trip == null)
            missing = true;
    }
    if (inclusion.isIncludeTripSchedule()) {
        stopTimes = _tripStopTimesBeanService.getStopTimesForBlockTrip(blockTripInstance);
        if (stopTimes == null)
            missing = true;
    }
    if (inclusion.isIncludeTripStatus() && blockLocation != null) {
        status = getBlockLocationAsStatusBean(blockLocation, time);
        if (status == null)
            missing = true;
        else
            vehicleId = AgencyAndIdLibrary.convertFromString(status.getVehicleId());
    }
    List<ServiceAlertBean> situations = _serviceAlertBeanService.getServiceAlertsForVehicleJourney(time, blockTripInstance, vehicleId);
    if (missing)
        return null;
    String tripId = AgencyAndIdLibrary.convertToString(tripEntry.getId());
    TripDetailsBean bean = new TripDetailsBean();
    bean.setTripId(tripId);
    bean.setServiceDate(serviceDate);
    bean.setFrequency(frequency);
    bean.setTrip(trip);
    bean.setSchedule(stopTimes);
    bean.setStatus(status);
    bean.setSituations(situations);
    return bean;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripBean(org.onebusaway.transit_data.model.trips.TripBean) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean) FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) TripStatusBean(org.onebusaway.transit_data.model.trips.TripStatusBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean)

Example 2 with FrequencyBean

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

the class TripStopTimesBeanServiceImpl method getStopTimesForBlockTrip.

@Override
public TripStopTimesBean getStopTimesForBlockTrip(BlockTripInstance blockTripInstance) {
    BlockTripEntry blockTrip = blockTripInstance.getBlockTrip();
    TripStopTimesBean bean = getStopTimesForTrip(blockTrip.getTrip());
    if (blockTrip.getPreviousTrip() != null) {
        BlockTripEntry previous = blockTrip.getPreviousTrip();
        TripBean previousTrip = _tripBeanService.getTripForId(previous.getTrip().getId());
        bean.setPreviousTrip(previousTrip);
    }
    if (blockTrip.getNextTrip() != null) {
        BlockTripEntry next = blockTrip.getNextTrip();
        TripBean nextTrip = _tripBeanService.getTripForId(next.getTrip().getId());
        bean.setNextTrip(nextTrip);
    }
    FrequencyEntry frequencyLabel = blockTripInstance.getFrequencyLabel();
    if (frequencyLabel != null) {
        long serviceDate = blockTripInstance.getServiceDate();
        FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(serviceDate, frequencyLabel);
        bean.setFrequency(fb);
    }
    return bean;
}
Also used : FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripBean(org.onebusaway.transit_data.model.trips.TripBean) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean)

Example 3 with FrequencyBean

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

the class ArrivalsAndDeparturesBeanServiceImpl method getStopTimeInstanceAsBean.

/**
 **
 * Private Methods
 ***
 */
private ArrivalAndDepartureBean getStopTimeInstanceAsBean(long time, ArrivalAndDepartureInstance instance, Map<AgencyAndId, StopBean> stopBeanCache) {
    ArrivalAndDepartureBean pab = new ArrivalAndDepartureBean();
    pab.setServiceDate(instance.getServiceDate());
    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    BlockTripEntry blockTrip = blockStopTime.getTrip();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    StopEntry stop = stopTime.getStop();
    TripEntry trip = stopTime.getTrip();
    TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
    pab.setTrip(tripBean);
    pab.setBlockTripSequence(blockTrip.getSequence());
    pab.setArrivalEnabled(stopTime.getSequence() > 0);
    pab.setDepartureEnabled(stopTime.getSequence() + 1 < trip.getStopTimes().size());
    StopTimeNarrative stopTimeNarrative = _narrativeService.getStopTimeForEntry(stopTime);
    pab.setRouteShortName(stopTimeNarrative.getRouteShortName());
    pab.setTripHeadsign(stopTimeNarrative.getStopHeadsign());
    StopBean stopBean = stopBeanCache.get(stop.getId());
    if (stopBean == null) {
        stopBean = _stopBeanService.getStopForId(stop.getId());
        stopBeanCache.put(stop.getId(), stopBean);
    }
    pab.setStop(stopBean);
    pab.setStopSequence(stopTime.getSequence());
    pab.setTotalStopsInTrip(stopTime.getTotalStopsInTrip());
    pab.setStatus("default");
    pab.setScheduledArrivalTime(instance.getScheduledArrivalTime());
    pab.setScheduledDepartureTime(instance.getScheduledDepartureTime());
    FrequencyEntry frequency = instance.getFrequencyLabel();
    pab.setFrequency(null);
    if (frequency != null) {
        FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(instance.getServiceDate(), frequency);
        pab.setFrequency(fb);
    }
    return pab;
}
Also used : StopTimeNarrative(org.onebusaway.transit_data_federation.model.narrative.StopTimeNarrative) FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripBean(org.onebusaway.transit_data.model.trips.TripBean) StopBean(org.onebusaway.transit_data.model.StopBean) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) ArrivalAndDepartureBean(org.onebusaway.transit_data.model.ArrivalAndDepartureBean) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 4 with FrequencyBean

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

the class BeanFactoryV2 method getTripStopTimes.

public TripStopTimesV2Bean getTripStopTimes(TripStopTimesBean tripStopTimes) {
    TripStopTimesV2Bean bean = new TripStopTimesV2Bean();
    bean.setTimeZone(tripStopTimes.getTimeZone());
    List<TripStopTimeV2Bean> instances = new ArrayList<TripStopTimeV2Bean>();
    for (TripStopTimeBean sti : tripStopTimes.getStopTimes()) {
        TripStopTimeV2Bean stiBean = new TripStopTimeV2Bean();
        stiBean.setArrivalTime(sti.getArrivalTime());
        stiBean.setDepartureTime(sti.getDepartureTime());
        stiBean.setStopHeadsign(sti.getStopHeadsign());
        stiBean.setDistanceAlongTrip(sti.getDistanceAlongTrip());
        stiBean.setStopId(sti.getStop().getId());
        addToReferences(sti.getStop());
        instances.add(stiBean);
    }
    bean.setStopTimes(instances);
    TripBean nextTrip = tripStopTimes.getNextTrip();
    if (nextTrip != null) {
        bean.setNextTripId(nextTrip.getId());
        addToReferences(nextTrip);
    }
    TripBean prevTrip = tripStopTimes.getPreviousTrip();
    if (prevTrip != null) {
        bean.setPreviousTripId(prevTrip.getId());
        addToReferences(prevTrip);
    }
    FrequencyBean freq = tripStopTimes.getFrequency();
    if (freq != null)
        bean.setFrequency(getFrequency(freq));
    return bean;
}
Also used : FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) ArrayList(java.util.ArrayList) TripStopTimeBean(org.onebusaway.transit_data.model.TripStopTimeBean) BlockTripBean(org.onebusaway.transit_data.model.blocks.BlockTripBean) TripBean(org.onebusaway.transit_data.model.trips.TripBean)

Example 5 with FrequencyBean

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

the class BeanFactoryV2 method getTripStatus.

public TripStatusV2Bean getTripStatus(TripStatusBean tripStatus) {
    TripStatusV2Bean bean = new TripStatusV2Bean();
    TripBean activeTrip = tripStatus.getActiveTrip();
    if (activeTrip != null) {
        bean.setActiveTripId(activeTrip.getId());
        bean.setBlockTripSequence(tripStatus.getBlockTripSequence());
        addToReferences(activeTrip);
    }
    bean.setServiceDate(tripStatus.getServiceDate());
    FrequencyBean frequency = tripStatus.getFrequency();
    if (frequency != null)
        bean.setFrequency(getFrequency(frequency));
    bean.setScheduledDistanceAlongTrip(tripStatus.getScheduledDistanceAlongTrip());
    bean.setTotalDistanceAlongTrip(tripStatus.getTotalDistanceAlongTrip());
    bean.setPosition(tripStatus.getLocation());
    if (tripStatus.isOrientationSet())
        bean.setOrientation(tripStatus.getOrientation());
    StopBean closestStop = tripStatus.getClosestStop();
    if (closestStop != null) {
        bean.setClosestStop(closestStop.getId());
        addToReferences(closestStop);
        bean.setClosestStopTimeOffset(tripStatus.getClosestStopTimeOffset());
    }
    StopBean nextStop = tripStatus.getNextStop();
    if (nextStop != null) {
        bean.setNextStop(nextStop.getId());
        addToReferences(nextStop);
        bean.setNextStopTimeOffset(tripStatus.getNextStopTimeOffset());
    }
    bean.setPhase(tripStatus.getPhase());
    bean.setStatus(tripStatus.getStatus());
    bean.setPredicted(tripStatus.isPredicted());
    if (tripStatus.getLastUpdateTime() > 0)
        bean.setLastUpdateTime(tripStatus.getLastUpdateTime());
    if (tripStatus.getLastLocationUpdateTime() > 0)
        bean.setLastLocationUpdateTime(tripStatus.getLastLocationUpdateTime());
    if (tripStatus.isLastKnownDistanceAlongTripSet())
        bean.setLastKnownDistanceAlongTrip(tripStatus.getLastKnownDistanceAlongTrip());
    bean.setLastKnownLocation(tripStatus.getLastKnownLocation());
    if (tripStatus.isLastKnownOrientationSet())
        bean.setLastKnownOrientation(tripStatus.getLastKnownOrientation());
    if (tripStatus.isScheduleDeviationSet())
        bean.setScheduleDeviation((int) tripStatus.getScheduleDeviation());
    if (tripStatus.isDistanceAlongTripSet())
        bean.setDistanceAlongTrip(tripStatus.getDistanceAlongTrip());
    bean.setVehicleId(tripStatus.getVehicleId());
    List<ServiceAlertBean> situations = tripStatus.getSituations();
    if (situations != null && !situations.isEmpty()) {
        List<String> situationIds = new ArrayList<String>();
        for (ServiceAlertBean situation : situations) {
            situationIds.add(situation.getId());
            addToReferences(situation);
        }
        bean.setSituationIds(situationIds);
    }
    return bean;
}
Also used : FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) ArrayList(java.util.ArrayList) BlockTripBean(org.onebusaway.transit_data.model.blocks.BlockTripBean) TripBean(org.onebusaway.transit_data.model.trips.TripBean) StopBean(org.onebusaway.transit_data.model.StopBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Aggregations

FrequencyBean (org.onebusaway.transit_data.model.schedule.FrequencyBean)8 TripBean (org.onebusaway.transit_data.model.trips.TripBean)6 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)4 FrequencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)4 ArrayList (java.util.ArrayList)3 StopBean (org.onebusaway.transit_data.model.StopBean)3 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)3 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 TripStopTimesBean (org.onebusaway.transit_data.model.TripStopTimesBean)2 BlockTripBean (org.onebusaway.transit_data.model.blocks.BlockTripBean)2 TripStatusBean (org.onebusaway.transit_data.model.trips.TripStatusBean)2 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)2 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)2 EVehiclePhase (org.onebusaway.realtime.api.EVehiclePhase)1 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)1 ArrivalAndDepartureBean (org.onebusaway.transit_data.model.ArrivalAndDepartureBean)1 TripStopTimeBean (org.onebusaway.transit_data.model.TripStopTimeBean)1 TimepointPredictionBean (org.onebusaway.transit_data.model.trips.TimepointPredictionBean)1 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)1