use of org.onebusaway.gtfs_realtime.interfaces.FeedEntityModel in project onebusaway-application-modules by camsys.
the class GtfsRealtimeRetrieverImpl method getFeedMessage.
@Override
public FeedMessage getFeedMessage(EntityType type, Date startDate, Date endDate) {
FeedMessage.Builder builder = FeedMessage.newBuilder();
List<? extends FeedEntityModel> updates = (type == EntityType.VEHICLE) ? _vehiclePositionDao.findByDate(startDate, endDate) : _tripUpdateDao.findByDate(startDate, endDate);
long timestamp = 0;
for (FeedEntityModel update : updates) {
FeedEntity.Builder fe = fillFeedEntity(update);
// This is not guaranteed to match entityID in source feed.
fe.setId(Long.toString(update.getId()));
builder.addEntity(fe);
timestamp = Math.max(timestamp, update.getTimestamp().getTime());
}
FeedHeader.Builder header = FeedHeader.newBuilder();
header.setTimestamp(timestamp / 1000);
header.setGtfsRealtimeVersion(GTFS_RT_VERSION);
builder.setHeader(header);
return builder.build();
}
Aggregations