OC Transpo usually reports a bus with no GPS data as having a
"GPS last read" time of (-1) minutes ago. But sometimes it reports
it as (-2), for reasons that aren't clear (at least, not to me).
The code was applying an "== (-1)" test in one spot, but a "< 0"
test in another; inconsistency is not good, nor is repeating a
conditional test unnecessarily.
Route route = stopInfo.getRoute(routeIdx);
for (int tripIdx = 0; tripIdx < route.getNumTrips(); ++tripIdx) {
Trip trip = route.getTrip(tripIdx);
- boolean isGhost = ((-1) == trip.getAdjAge());
+ boolean isGhost = (trip.getAdjAge() < 0);
if (isGhost) {
// GPS is off. This bus may not exist.
pw.println(" <TR CLASS=\"ghost\">");
remainArray.append(trip.getAdjTime());
remainCount++;
- if (trip.getAdjAge() < 0) {
+ if (isGhost) {
pw.println(" <TD>" + trans(FrankBundle.GPS_OFF) + "</TD>");
}
else {
trip = new TripMock(queryDate);
trip.mock_setDest(HURDMAN);
trip.mock_setAdjTime(37);
+ trip.mock_setAdjAge(-2);
route.mock_addTrip(trip);
rsm.mock_addRoute(route);
Assert.assertTrue(actual.contains("<TD>" + HURDMAN + "</TD>"));
Assert.assertTrue(actual.contains("<TD><SPAN ID=\"in_2\">17m</SPAN></TD>"));
+ Assert.assertTrue(actual.contains("<TR CLASS=\"ghost\">"));
Assert.assertTrue(actual.contains("<TD>4</TD>"));
Assert.assertTrue(actual.contains("<TD>" + HURDMAN + "</TD>"));
Assert.assertTrue(actual.contains("<TD><SPAN ID=\"in_3\">37m</SPAN></TD>"));
+ Assert.assertTrue(actual.contains("<TD>GPS off</TD>"));
}
}