use of org.opentripplanner.model.calendar.CalendarService in project OpenTripPlanner by opentripplanner.
the class Graph method getTimeZone.
/**
* Returns the time zone for the first agency in this graph. This is used to interpret times in API requests. The JVM default time zone cannot be
* used because we support multiple graphs on one server via the routerId. Ideally we would want to interpret times in the time zone of the
* geographic location where the origin/destination vertex or board/alight event is located. This may become necessary when we start making graphs
* with long distance train, boat, or air services.
*/
public TimeZone getTimeZone() {
if (timeZone == null) {
if (agencies == null || agencies.size() == 0) {
timeZone = TimeZone.getTimeZone("GMT");
LOG.warn("graph contains no agencies (yet); API request times will be interpreted as GMT.");
} else {
CalendarService cs = this.getCalendarService();
for (Agency agency : agencies) {
TimeZone tz = cs.getTimeZoneForAgencyId(agency.getId());
if (timeZone == null) {
LOG.debug("graph time zone set to {}", tz);
timeZone = tz;
} else if (!timeZone.equals(tz)) {
LOG.error("agency time zone differs from graph time zone: {}", tz);
}
}
}
}
return timeZone;
}
use of org.opentripplanner.model.calendar.CalendarService in project OpenTripPlanner by opentripplanner.
the class GraphIndex method initalizeServiceCodesForDate.
private void initalizeServiceCodesForDate(Graph graph) {
CalendarService calendarService = graph.getCalendarService();
if (calendarService == null) {
return;
}
// CalendarService has one main implementation (CalendarServiceImpl) which contains a
// CalendarServiceData which can easily supply all of the dates. But it's impossible to
// actually see those dates without modifying the interfaces and inheritance. So we have
// to work around this abstraction and reconstruct the CalendarData.
// Note the "multiCalendarServiceImpl" which has docs saying it expects one single
// CalendarData. It seems to merge the calendar services from multiple GTFS feeds, but
// its only documentation says it's a hack.
// TODO OTP2 - This cleanup is added to the 'Final cleanup OTP2' issue #2757
// Reconstruct set of all dates where service is defined, keeping track of which services
// run on which days.
Multimap<ServiceDate, FeedScopedId> serviceIdsForServiceDate = HashMultimap.create();
for (FeedScopedId serviceId : calendarService.getServiceIds()) {
Set<ServiceDate> serviceDatesForService = calendarService.getServiceDatesForServiceId(serviceId);
for (ServiceDate serviceDate : serviceDatesForService) {
serviceIdsForServiceDate.put(serviceDate, serviceId);
}
}
for (ServiceDate serviceDate : serviceIdsForServiceDate.keySet()) {
TIntSet serviceCodesRunning = new TIntHashSet();
for (FeedScopedId serviceId : serviceIdsForServiceDate.get(serviceDate)) {
serviceCodesRunning.add(graph.getServiceCodes().get(serviceId));
}
serviceCodesRunningForDate.put(serviceDate, serviceCodesRunning);
}
}
Aggregations