use of org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean in project onebusaway-application-modules by camsys.
the class SimulateScheduledVehicleLocationsController method index.
@RequestMapping()
public ModelAndView index(@RequestParam() String blockId, @RequestParam() long serviceDate, @RequestParam(defaultValue = "0") int scheduleDeviation, @RequestParam(defaultValue = "0.0") double noise) {
AgencyAndId bid = AgencyAndIdLibrary.convertFromString(blockId);
BlockInstance blockInstance = _blockCalendarService.getBlockInstance(bid, serviceDate);
CurrentVehicleEstimateQueryBean bean = new CurrentVehicleEstimateQueryBean();
long time = SystemTime.currentTimeMillis();
List<Record> records = new ArrayList<Record>();
for (int i = 0; i < 5 * 60; i += 30) {
int scheduleTime = (int) ((time - blockInstance.getServiceDate()) / 1000 - scheduleDeviation - i);
ScheduledBlockLocation location = _scheduledBlockLocationService.getScheduledBlockLocationFromScheduledTime(blockInstance.getBlock(), scheduleTime);
if (location != null) {
CoordinatePoint p = applyNoiseToLocation(location.getLocation(), noise);
Record r = new Record();
r.setLocation(location.getLocation());
r.setTimestamp(time - i * 1000);
r.setLocation(p);
r.setAccuracy(noise);
records.add(r);
}
}
bean.setRecords(records);
ModelAndView mv = new ModelAndView("simulate-vehicle-locations.jspx");
mv.addObject("time", time);
mv.addObject("query", bean);
return mv;
}
use of org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean in project onebusaway-application-modules by camsys.
the class SimulateVehicleLocationsController method index.
@RequestMapping()
public ModelAndView index(@RequestParam() String vehicleId, @RequestParam(defaultValue = "0.0") double noise) {
AgencyAndId vid = AgencyAndIdLibrary.convertFromString(vehicleId);
CurrentVehicleEstimateQueryBean bean = new CurrentVehicleEstimateQueryBean();
long time = SystemTime.currentTimeMillis();
List<Record> records = new ArrayList<Record>();
for (int i = 0; i < 5 * 60; i += 30) {
TargetTime tt = new TargetTime(time - i * 1000);
BlockLocation location = _blockLocationService.getLocationForVehicleAndTime(vid, tt);
if (location != null) {
CoordinatePoint p = applyNoiseToLocation(location.getLocation(), noise);
Record r = new Record();
r.setLocation(location.getLocation());
r.setTimestamp(tt.getTargetTime());
r.setLocation(p);
r.setAccuracy(noise);
records.add(r);
}
}
bean.setRecords(records);
ModelAndView mv = new ModelAndView("simulate-vehicle-locations.jspx");
mv.addObject("time", time);
mv.addObject("query", bean);
return mv;
}
Aggregations