FeedEntity vehiclePositionEntity = vehiclePositionsByBlockDescriptor.get(update.block);
if (vehiclePositionEntity != null) {
VehiclePosition vehiclePosition = vehiclePositionEntity.getVehicle();
update.vehiclePosition = vehiclePosition;
if (vehiclePosition.hasVehicle()) {
VehicleDescriptor vehicle = vehiclePosition.getVehicle();
if (vehicle.hasId()) {
update.block.setVehicleId(vehicle.getId());
}
}
}
if (update.block.getVehicleId() == null) {
for (TripUpdate tripUpdate : update.tripUpdates) {
if (tripUpdate.hasVehicle()) {
VehicleDescriptor vehicle = tripUpdate.getVehicle();
if (vehicle.hasId()) {
update.block.setVehicleId(vehicle.getId());
}
}
}
}