private void transitIndexWithBreakRequired(TransitIndexService transitIndex) { transitIndexRequired(transitIndex); if (transitIndex.getOvernightBreak() == -1) { throw new RuntimeException( "TransitIndexBuilder could not find an overnight break " + "in the transit schedule; first/last trips are undefined"); } }
/** Returns the first trip of the service day. */ public TripPlan generateFirstTrip(RoutingRequest request) { Graph graph = graphService.getGraph(request.getRouterId()); TransitIndexService transitIndex = graph.getService(TransitIndexService.class); transitIndexWithBreakRequired(transitIndex); request.setArriveBy(false); TimeZone tz = graph.getTimeZone(); GregorianCalendar calendar = new GregorianCalendar(tz); calendar.setTimeInMillis(request.dateTime * 1000); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.AM_PM, 0); calendar.set(Calendar.SECOND, transitIndex.getOvernightBreak()); request.dateTime = calendar.getTimeInMillis() / 1000; return generate(request); }