use of org.onebusaway.gtfs_realtime.model.TripUpdateModel in project onebusaway-application-modules by camsys.
the class TripUpdateConvertor method readFeedEntity.
@Override
public TripUpdateModel readFeedEntity(FeedEntity entity, long timestamp) {
if (entity.hasTripUpdate()) {
TripUpdateModel tu = new TripUpdateModel();
TripDescriptor t = entity.getTripUpdate().getTrip();
if (entity.getTripUpdate().hasTimestamp()) {
timestamp = entity.getTripUpdate().getTimestamp() * 1000;
}
tu.setTimestamp(new Date(timestamp));
if (entity.getTripUpdate().hasDelay()) {
tu.setDelay(entity.getTripUpdate().getDelay());
}
if (t.hasTripId())
tu.setTripId(t.getTripId());
if (t.hasRouteId()) {
tu.setRouteId(t.getRouteId());
}
if (t.hasStartDate() && t.hasStartTime()) {
tu.setTripStart(GtfsRealtimeConversionLibrary.parseDate(t.getStartDate(), t.getStartTime()));
}
tu.setScheduleRelationship(findRelationship(t));
VehicleDescriptor vehicle = entity.getTripUpdate().getVehicle();
if (vehicle != null) {
tu.setVehicleId(vehicle.getId());
tu.setVehicleLabel(vehicle.getLabel());
tu.setVehicleLicensePlate(vehicle.getLicensePlate());
}
for (StopTimeUpdate stu : entity.getTripUpdate().getStopTimeUpdateList()) {
StopTimeUpdateModel stopTimeUpdate = readStopTimeUpdate(stu, tu.getScheduleRelationship());
if (stopTimeUpdate != null) {
stopTimeUpdate.setTripUpdateModel(tu);
tu.addStopTimeUpdateModel(stopTimeUpdate);
}
}
return tu;
}
return null;
}
use of org.onebusaway.gtfs_realtime.model.TripUpdateModel in project onebusaway-application-modules by camsys.
the class FeedServiceImpl method readTripUpdates.
@Override
public List<TripUpdateModel> readTripUpdates(FeedMessage tripUpdates, GtfsRealtimeEntitySource entitySource) {
List<TripUpdateModel> updates = GtfsRealtimeConversionLibrary.readTripUpdates(tripUpdates);
for (TripUpdateModel tripUpdate : updates) {
String agencyId = getAgencyId(entitySource);
addAgencyIdToTripId(tripUpdate, agencyId, entitySource);
addAgencyIdToRouteId(tripUpdate, agencyId, entitySource);
// Check stop id
for (StopTimeUpdateModel stopTimeUpdate : tripUpdate.getStopTimeUpdates()) {
addAgencyIdToStopId(stopTimeUpdate, agencyId, entitySource);
}
_persistor.persist(tripUpdate);
}
return updates;
}
Aggregations