Search in sources :

Example 6 with StopEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.

the class StopTimeServiceImpl method getDepartureForStopAndServiceDate.

@Override
public Range getDepartureForStopAndServiceDate(AgencyAndId stopId, ServiceDate serviceDate) {
    StopEntry stop = _graph.getStopEntryForId(stopId, true);
    List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stop);
    Range interval = new Range();
    for (BlockStopTimeIndex index : indices) {
        extendIntervalWithIndex(serviceDate, interval, index);
    }
    List<FrequencyBlockStopTimeIndex> freqIndices = _blockIndexService.getFrequencyStopTimeIndicesForStop(stop);
    for (FrequencyBlockStopTimeIndex index : freqIndices) extendIntervalWithIndex(serviceDate, interval, index);
    return interval;
}
Also used : FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) AbstractBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.AbstractBlockStopTimeIndex) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) Range(org.onebusaway.collections.Range)

Example 7 with StopEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry 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 8 with StopEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.

the class ScheduledBlockLocationServiceImpl method getScheduledBlockLocationWhenAtStopTime.

private ScheduledBlockLocation getScheduledBlockLocationWhenAtStopTime(BlockStopTimeEntry blockStopTime, BlockStopTimeEntry previousBlockStopTime, StopTimeEntry stopTime, int scheduleTime, int stopTimeIndex) {
    StopEntry stop = stopTime.getStop();
    ScheduledBlockLocation result = new ScheduledBlockLocation();
    int shapePointIndex = stopTime.getShapePointIndex();
    PointAndOrientation po = getLocationAlongShape(blockStopTime.getTrip(), blockStopTime.getDistanceAlongBlock(), shapePointIndex, shapePointIndex + 1);
    if (po != null) {
        result.setLocation(po.getPoint());
        result.setOrientation(po.getOrientation());
    } else {
        CoordinatePoint location = new CoordinatePoint(stop.getStopLat(), stop.getStopLon());
        result.setLocation(location);
        result.setOrientation(0);
    }
    result.setClosestStop(blockStopTime);
    result.setClosestStopTimeOffset(0);
    result.setNextStop(blockStopTime);
    result.setNextStopTimeOffset(0);
    result.setScheduledTime(scheduleTime);
    result.setDistanceAlongBlock(blockStopTime.getDistanceAlongBlock());
    result.setActiveTrip(blockStopTime.getTrip());
    result.setInService(true);
    result.setStopTimeIndex(stopTimeIndex);
    // If there is more than 1 stop, grab the previous stop
    if (blockStopTime.hasPreviousStop()) {
        result.setPreviousStop(previousBlockStopTime);
    }
    return result;
}
Also used : ScheduledBlockLocation(org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) PointAndOrientation(org.onebusaway.transit_data_federation.impl.shapes.PointAndOrientation) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint)

Example 9 with StopEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.

the class BlockIndexFactoryServiceImpl method computeDirectionOfTravel.

private double computeDirectionOfTravel(List<BlockStopTimeEntry> bsts) {
    BlockStopTimeEntry fromBst = bsts.get(0);
    BlockStopTimeEntry toBst = bsts.get(bsts.size() - 1);
    StopEntry fromStop = fromBst.getStopTime().getStop();
    StopEntry toStop = toBst.getStopTime().getStop();
    return SphericalGeometryLibrary.getOrientation(fromStop.getStopLat(), fromStop.getStopLon(), toStop.getStopLat(), toStop.getStopLon());
}
Also used : StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 10 with StopEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.

the class TransitDataServiceTemplateImpl method createArrivalAndDepartureQuery.

protected ArrivalAndDepartureQuery createArrivalAndDepartureQuery(ArrivalAndDepartureForStopQueryBean query) {
    ArrivalAndDepartureQuery adQuery = new ArrivalAndDepartureQuery();
    AgencyAndId stopId = AgencyAndIdLibrary.convertFromString(query.getStopId());
    StopEntry stop = _transitGraphDao.getStopEntryForId(stopId, true);
    AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId());
    TripEntry trip = _transitGraphDao.getTripEntryForId(tripId);
    if (trip == null)
        throw new NoSuchTripServiceException(query.getTripId());
    adQuery.setStop(stop);
    adQuery.setStopSequence(query.getStopSequence());
    adQuery.setTrip(trip);
    adQuery.setServiceDate(query.getServiceDate());
    adQuery.setVehicleId(AgencyAndIdLibrary.convertFromString(query.getVehicleId()));
    adQuery.setTime(query.getTime());
    return adQuery;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) NoSuchTripServiceException(org.onebusaway.exceptions.NoSuchTripServiceException) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)

Aggregations

StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)54 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)28 ArrayList (java.util.ArrayList)15 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)14 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)12 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)12 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)12 BlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex)10 List (java.util.List)9 FactoryMap (org.onebusaway.collections.FactoryMap)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Test (org.junit.Test)8 StopNarrative (org.onebusaway.transit_data_federation.model.narrative.StopNarrative)8 HashSet (java.util.HashSet)7 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)7 Cacheable (org.onebusaway.container.cache.Cacheable)6 Stop (org.onebusaway.gtfs.model.Stop)6 StopBean (org.onebusaway.transit_data.model.StopBean)4