Search in sources :

Example 11 with BlockTripBean

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

the class BlockStatusBeanServiceImpl method bean.

private BlockStatusBean bean(BlockLocation blockLocation) {
    if (blockLocation == null)
        return null;
    BlockInstance instance = blockLocation.getBlockInstance();
    BlockConfigurationEntry block = instance.getBlock();
    long serviceDate = instance.getServiceDate();
    BlockStatusBean bean = new BlockStatusBean();
    bean.setBlock(_blockBeanService.getBlockForId(block.getBlock().getId()));
    bean.setStatus("default");
    bean.setServiceDate(serviceDate);
    bean.setTotalDistanceAlongBlock(block.getTotalBlockDistance());
    bean.setInService(blockLocation.isInService());
    CoordinatePoint location = blockLocation.getLocation();
    bean.setLocation(location);
    bean.setScheduledDistanceAlongBlock(blockLocation.getScheduledDistanceAlongBlock());
    bean.setDistanceAlongBlock(blockLocation.getDistanceAlongBlock());
    BlockTripEntry activeTrip = blockLocation.getActiveTrip();
    if (activeTrip != null) {
        BlockTripBean activeTripBean = _blockBeanService.getBlockTripAsBean(activeTrip);
        bean.setActiveTrip(activeTripBean);
    }
    BlockStopTimeEntry stop = blockLocation.getClosestStop();
    if (stop != null) {
        StopBean stopBean = _stopBeanService.getStopForId(stop.getStopTime().getStop().getId());
        bean.setClosestStop(stopBean);
        bean.setClosestStopTimeOffset(blockLocation.getClosestStopTimeOffset());
    }
    bean.setPredicted(blockLocation.isPredicted());
    bean.setLastUpdateTime(blockLocation.getLastUpdateTime());
    bean.setScheduleDeviation(blockLocation.getScheduleDeviation());
    AgencyAndId vid = blockLocation.getVehicleId();
    if (vid != null)
        bean.setVehicleId(ApplicationBeanLibrary.getId(vid));
    return bean;
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) BlockTripBean(org.onebusaway.transit_data.model.blocks.BlockTripBean) BlockStatusBean(org.onebusaway.transit_data.model.blocks.BlockStatusBean) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) StopBean(org.onebusaway.transit_data.model.StopBean) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Aggregations

BlockTripBean (org.onebusaway.transit_data.model.blocks.BlockTripBean)11 BlockStopTimeBean (org.onebusaway.transit_data.model.blocks.BlockStopTimeBean)7 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)5 BigInteger (java.math.BigInteger)4 StopBean (org.onebusaway.transit_data.model.StopBean)4 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)3 BigDecimal (java.math.BigDecimal)2 DecimalFormat (java.text.DecimalFormat)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)2 BlockInstanceBean (org.onebusaway.transit_data.model.blocks.BlockInstanceBean)2 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)2 Date (java.util.Date)1 TimeZone (java.util.TimeZone)1 BlockConfigurationV2Bean (org.onebusaway.api.model.transit.blocks.BlockConfigurationV2Bean)1 BlockTripV2Bean (org.onebusaway.api.model.transit.blocks.BlockTripV2Bean)1 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)1 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)1 ArrivalAndDepartureBean (org.onebusaway.transit_data.model.ArrivalAndDepartureBean)1