Search in sources :

Example 16 with StopEntry

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

the class BlockSequenceIndex method toString.

@Override
public String toString() {
    BlockSequence first = _sequences.get(0);
    BlockConfigurationEntry blockConfig = first.getBlockConfig();
    BlockEntry block = blockConfig.getBlock();
    List<BlockStopTimeEntry> bsts = first.getStopTimes();
    BlockStopTimeEntry firstBst = bsts.get(0);
    BlockStopTimeEntry lastBst = bsts.get(bsts.size() - 1);
    StopEntry fromStop = firstBst.getStopTime().getStop();
    StopEntry toStop = lastBst.getStopTime().getStop();
    return "BlockSequenceIndex [ex: block=" + block.getId() + " fromStop=" + fromStop.getId() + " toStop=" + toStop.getId() + " serviceIds=" + getServiceIds() + "]";
}
Also used : BlockSequence(org.onebusaway.transit_data_federation.impl.blocks.BlockSequence) BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 17 with StopEntry

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

the class GtfsRealtimeEntitySource method getStopId.

public AgencyAndId getStopId(String stopId) {
    for (String agencyId : _agencyIds) {
        AgencyAndId id = new AgencyAndId(agencyId, stopId);
        StopEntry stop = _transitGraphDao.getStopEntryForId(id);
        if (stop != null)
            return id;
    }
    try {
        AgencyAndId id = AgencyAndId.convertFromString(stopId);
        StopEntry stop = _transitGraphDao.getStopEntryForId(id);
        if (stop != null)
            return id;
    } catch (IllegalArgumentException ex) {
    }
    _log.debug("stop not found with id \"{}\"", stopId);
    // If not found, just return null.
    return null;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)

Example 18 with StopEntry

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

the class StopIdsController method index.

@RequestMapping()
public ModelAndView index() {
    List<String> ids = new ArrayList<String>();
    for (StopEntry stop : _graphDao.getAllStops()) {
        String id = AgencyAndIdLibrary.convertToString(stop.getId());
        ids.add(id);
    }
    return new ModelAndView("stop-ids.jspx", "ids", ids);
}
Also used : ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with StopEntry

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

the class AgencyServiceImpl method getAgencyIdsAndCoverageAreas.

@Cacheable
public Map<String, CoordinateBounds> getAgencyIdsAndCoverageAreas() {
    Map<String, CoordinateBounds> boundsByAgencyId = new HashMap<String, CoordinateBounds>();
    for (AgencyEntry agency : _graph.getAllAgencies()) {
        CoordinateBounds bounds = new CoordinateBounds();
        for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
            for (RouteEntry route : routeCollection.getChildren()) {
                for (TripEntry trip : route.getTrips()) {
                    for (StopTimeEntry stopTime : trip.getStopTimes()) {
                        StopEntry stop = stopTime.getStop();
                        bounds.addPoint(stop.getStopLat(), stop.getStopLon());
                    }
                }
            }
        }
        boundsByAgencyId.put(agency.getId(), bounds);
    }
    return boundsByAgencyId;
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) HashMap(java.util.HashMap) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) AgencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 20 with StopEntry

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

the class ArrivalAndDepartureServiceImpl method getArrivalAndDepartureForStop.

@Override
public ArrivalAndDepartureInstance getArrivalAndDepartureForStop(ArrivalAndDepartureQuery query) {
    StopEntry stop = query.getStop();
    int stopSequence = query.getStopSequence();
    TripEntry trip = query.getTrip();
    long serviceDate = query.getServiceDate();
    AgencyAndId vehicleId = query.getVehicleId();
    long time = query.getTime();
    Map<BlockInstance, List<BlockLocation>> locationsByInstance = _blockStatusService.getBlocks(trip.getBlock().getId(), serviceDate, vehicleId, time);
    if (locationsByInstance.isEmpty())
        return null;
    Map.Entry<BlockInstance, List<BlockLocation>> entry = locationsByInstance.entrySet().iterator().next();
    BlockInstance blockInstance = entry.getKey();
    List<BlockLocation> locations = entry.getValue();
    int timeOfServiceDate = (int) ((time - serviceDate) / 1000);
    ArrivalAndDepartureInstance instance = createArrivalAndDeparture(blockInstance, trip.getId(), stop.getId(), stopSequence, serviceDate, timeOfServiceDate, time);
    if (!locations.isEmpty()) {
        /**
         * What if there are multiple locations? Pick the first?
         */
        BlockLocation location = locations.get(0);
        applyBlockLocationToInstance(instance, location, time);
    }
    return instance;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockLocation(org.onebusaway.transit_data_federation.services.realtime.BlockLocation) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) ArrayList(java.util.ArrayList) List(java.util.List) ArrivalAndDepartureInstance(org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance) HashMap(java.util.HashMap) Map(java.util.Map) FactoryMap(org.onebusaway.collections.FactoryMap)

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