use of org.onebusaway.gtfs.model.AgencyAndIdInstance in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryTask method loadRecords.
private Map<AgencyAndId, BlockLocationArchiveRecordMap> loadRecords(List<BlockLocationArchiveRecord> records) {
Map<AgencyAndId, BlockLocationArchiveRecordMap> recordsByTrip = new FactoryMap<AgencyAndId, BlockLocationArchiveRecordMap>(new BlockLocationArchiveRecordMap());
for (BlockLocationArchiveRecord record : records) {
AgencyAndId tripId = record.getTripId();
AgencyAndIdInstance instance = new AgencyAndIdInstance(tripId, record.getServiceDate());
recordsByTrip.get(record.getTripId()).get(instance).add(record);
}
return recordsByTrip;
}
use of org.onebusaway.gtfs.model.AgencyAndIdInstance in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryServiceImpl method getHistoryForTripId.
@Override
public Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> getHistoryForTripId(AgencyAndId tripId) {
TripEntry trip = _transitGraphDao.getTripEntryForId(tripId);
if (trip == null)
return null;
BlockEntry block = trip.getBlock();
List<File> files = getFilesForBlockId(block.getId());
CsvEntityReader reader = new CsvEntityReader();
reader.setTokenizerStrategy(new DelimiterTokenizerStrategy("\t"));
EntityHandlerImpl handler = new EntityHandlerImpl(tripId);
reader.addEntityHandler(handler);
try {
for (File file : files) {
InputStream in = openFileForInput(file);
reader.readEntities(BlockLocationArchiveRecord.class, in);
in.close();
}
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> recordsByInstance = handler.getRecordsByInstance();
for (List<BlockLocationArchiveRecord> records : recordsByInstance.values()) Collections.sort(records, new DistanceAlongBlockComparator());
return recordsByInstance;
}
use of org.onebusaway.gtfs.model.AgencyAndIdInstance in project onebusaway-application-modules by camsys.
the class BlockLocationHistoryForTripController method index.
@RequestMapping()
public ModelAndView index(@RequestParam() String tripId) {
AgencyAndId id = AgencyAndIdLibrary.convertFromString(tripId);
Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> histories = _service.getHistoryForTripId(id);
ModelAndView mv = new ModelAndView("block-location-history-for-trip.jspx");
mv.addObject("histories", histories);
return mv;
}
Aggregations