use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class GtfsController method getRoute.
/* Expose shape points for route */
@RequestMapping(value = "/route/{agencyId}/{id}")
@ResponseBody
public ShapePoints getRoute(@PathVariable String agencyId, @PathVariable String id) {
AgencyAndId routeId = new AgencyAndId(agencyId, id);
RouteEntry route = _transitGraphDao.getRouteForId(routeId);
// BAD - just uses first trip.
TripEntry trip = routeToTrip(route);
AgencyAndId shapeId = trip.getShapeId();
return _shapePointService.getShapePointsForShapeId(shapeId);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class GtfsRealtimeEntitySource method getTrip.
public TripEntry getTrip(String tripId) {
for (String agencyId : _agencyIds) {
AgencyAndId id = new AgencyAndId(agencyId, tripId);
TripEntry trip = _transitGraphDao.getTripEntryForId(id);
if (trip != null)
return trip;
}
try {
AgencyAndId id = AgencyAndId.convertFromString(tripId);
TripEntry trip = _transitGraphDao.getTripEntryForId(id);
if (trip != null)
return trip;
} catch (IllegalArgumentException ex) {
}
return null;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class FeedServiceImpl method addAgencyIdToTripId.
private HasTripId addAgencyIdToTripId(HasTripId entity, String agencyId, GtfsRealtimeEntitySource entitySource) {
if (StringUtils.isNotBlank(entity.getTripId())) {
String tripId = entity.getTripId();
if (agencyId.length() > 0) {
entity.setTripId(new AgencyAndId(agencyId, tripId).toString());
} else {
// Look for the agency which has a match for this trip id
TripEntry trip = entitySource.getTrip(entity.getTripId());
if (trip == null) {
_log.debug("No match found for trip: " + entity.getTripId());
} else {
entity.setTripId(trip.getId().toString());
agencyId = trip.getId().getAgencyId();
}
}
}
return entity;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry 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;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry 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;
}
Aggregations