use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class PreCacheTask method run.
@Override
public void run() {
// Clear all existing cache elements
for (String cacheName : _cacheManager.getCacheNames()) {
Cache cache = _cacheManager.getCache(cacheName);
cache.removeAll();
}
try {
List<AgencyWithCoverageBean> agenciesWithCoverage = _service.getAgenciesWithCoverage();
for (AgencyWithCoverageBean agencyWithCoverage : agenciesWithCoverage) {
AgencyBean agency = agencyWithCoverage.getAgency();
System.out.println("agency=" + agency.getId());
ListBean<String> stopIds = _service.getStopIdsForAgencyId(agency.getId());
for (String stopId : stopIds.getList()) {
System.out.println(" stop=" + stopId);
_service.getStop(stopId);
}
ListBean<String> routeIds = _service.getRouteIdsForAgencyId(agency.getId());
for (String routeId : routeIds.getList()) {
System.out.println(" route=" + routeId);
_service.getStopsForRoute(routeId);
}
}
Set<AgencyAndId> shapeIds = new HashSet<AgencyAndId>();
for (TripEntry trip : _transitGraphDao.getAllTrips()) {
AgencyAndId shapeId = trip.getShapeId();
if (shapeId != null && shapeId.hasValues())
shapeIds.add(shapeId);
}
for (AgencyAndId shapeId : shapeIds) {
System.out.println("shape=" + shapeId);
_service.getShapeForId(AgencyAndIdLibrary.convertToString(shapeId));
}
} catch (ServiceException ex) {
_log.error("service exception", ex);
}
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class UnitTestingSupport method blockConfiguration.
public static BlockConfigurationEntry blockConfiguration(BlockEntry block, ServiceIdActivation serviceIds, TripEntry... trips) {
Builder builder = BlockConfigurationEntryImpl.builder();
builder.setBlock(block);
builder.setServiceIds(serviceIds);
builder.setTrips(Arrays.asList(trips));
builder.setTripGapDistances(new double[trips.length]);
BlockConfigurationEntry blockConfig = builder.create();
BlockEntryImpl blockImpl = (BlockEntryImpl) block;
List<BlockConfigurationEntry> configs = block.getConfigurations();
if (configs == null) {
configs = new ArrayList<BlockConfigurationEntry>();
blockImpl.setConfigurations(configs);
}
configs.add(blockConfig);
for (TripEntry trip : trips) {
if (trip.getBlock() == null)
((TripEntryImpl) trip).setBlock((BlockEntryImpl) block);
}
return blockConfig;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class UnitTestingSupport method linkBlockTrips.
public static BlockConfigurationEntry linkBlockTrips(BlockEntryImpl block, List<FrequencyEntry> frequencies, TripEntryImpl... trips) {
List<TripEntry> tripEntries = new ArrayList<TripEntry>();
Set<LocalizedServiceId> serviceIds = new TreeSet<LocalizedServiceId>();
for (int i = 0; i < trips.length; i++) {
TripEntryImpl trip = trips[i];
trip.setBlock(block);
tripEntries.add(trip);
if (trip.getServiceId() != null)
serviceIds.add(trip.getServiceId());
}
Builder builder = BlockConfigurationEntryImpl.builder();
builder.setBlock(block);
builder.setServiceIds(new ServiceIdActivation(new ArrayList<LocalizedServiceId>(serviceIds), new ArrayList<LocalizedServiceId>()));
builder.setTrips(tripEntries);
builder.setFrequencies(frequencies);
builder.setTripGapDistances(new double[tripEntries.size()]);
BlockConfigurationEntry configuration = builder.create();
List<BlockConfigurationEntry> configurations = block.getConfigurations();
if (configurations == null) {
configurations = new ArrayList<BlockConfigurationEntry>();
block.setConfigurations(configurations);
}
configurations.add(configuration);
return configuration;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class GtfsController method getStops.
@RequestMapping(value = "/stops/{agencyId}/{id}")
@ResponseBody
public List<CoordinatePoint> getStops(@PathVariable String agencyId, @PathVariable String id) {
AgencyAndId routeId = new AgencyAndId(agencyId, id);
RouteEntry route = _transitGraphDao.getRouteForId(routeId);
TripEntry trip = routeToTrip(route);
List<StopTimeEntry> stopTimes = trip.getStopTimes();
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
for (StopTimeEntry entry : stopTimes) {
StopEntry stop = entry.getStop();
points.add(stop.getStopLocation());
}
return points;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.
the class GtfsRealtimeEntitySource method getTripId.
public Id getTripId(String tripId) {
TripEntry trip = getTrip(tripId);
if (trip != null)
return ServiceAlertLibrary.id(trip.getId());
_log.debug("trip not found with id \"{}\"", tripId);
AgencyAndId id = new AgencyAndId(_agencyIds.get(0), tripId);
return ServiceAlertLibrary.id(id);
}
Aggregations