VehicleRefStructure vehicleRef = mvj.getVehicleRef();
if (vehicleRef == null || vehicleRef.getValue() == null)
continue;
BlockEntry block = getBlockForMonitoredVehicleJourney(mvj,
endpointDetails);
if (block == null) {
TripEntry trip = getTripForMonitoredVehicleJourney(mvj, endpointDetails);
if (trip != null)
block = trip.getBlock();
}
if (block == null)
continue;
List<BlockInstance> instances = _blockCalendarService.getActiveBlocks(
block.getId(), timeFrom, timeTo);
// TODO : We currently assume that a block won't overlap with itself
if (instances.size() != 1)
continue;
BlockInstance instance = instances.get(0);
VehicleLocationRecord r = new VehicleLocationRecord();
r.setTimeOfRecord(time.getTime());
r.setServiceDate(instance.getServiceDate());
r.setBlockId(block.getId());
String agencyId = block.getId().getAgencyId();
r.setVehicleId(new AgencyAndId(agencyId, vehicleRef.getValue()));
r.setScheduleDeviation(delay.getTimeInMillis(now) / 1000);
LocationStructure location = mvj.getVehicleLocation();