From 10685a39fbf4ac82f0752a529a2cb816bedbbc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Skj=C3=B8lberg?= Date: Fri, 9 Mar 2018 20:33:24 +0100 Subject: [PATCH] Avoid creating additional calendar in ServiceDate --- .../impl/WSFBlockResolutionStrategy.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/impl/WSFBlockResolutionStrategy.java b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/impl/WSFBlockResolutionStrategy.java index 571f465d3..34dfcf9d1 100644 --- a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/impl/WSFBlockResolutionStrategy.java +++ b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/impl/WSFBlockResolutionStrategy.java @@ -151,8 +151,8 @@ private void setBlockIdsFromSchedResponse(SchedResponse resp) { String arrive = stc.getArrivingTerminalID().toString(); for (SchedTime sched : schedTime(stc)) { - long time = ts(sched.getDepartingTime()); - Trip trip = _tripResolutionService.resolve(depart, time, arrive); + GregorianCalendar gregorianCalendar = sched.getDepartingTime().toGregorianCalendar(_agencyTimeZone, null, null); + Trip trip = _tripResolutionService.resolve(depart, gregorianCalendar, arrive); if (trip != null) { trip.setBlockId(sched.getVesselID().toString()); } else { @@ -278,10 +278,9 @@ public WSFTripResolutionService(GtfsRelationalDao dao, String agencyId, _maxStopTime = calculateMaxStopTime(); } - public Trip resolve(String departingTerminalId, long departureTime, + public Trip resolve(String departingTerminalId, Calendar departureTime, String arrivingTerminalId) { - ServiceDate initialServiceDate = new ServiceDate( - new Date(departureTime * 1000)); + ServiceDate initialServiceDate = new ServiceDate(departureTime); int lookBackDays = (_maxStopTime / 86400) + 1; AgencyAndId stopId = new AgencyAndId(_agencyId, departingTerminalId); @@ -297,9 +296,9 @@ public Trip resolve(String departingTerminalId, long departureTime, if (_csd.getServiceIdsForDate(sd).contains( st.getTrip().getServiceId()) - && st.getDepartureTime() == (departureTime - - (sd.getAsCalendar(_agencyTimeZone).getTimeInMillis() - / 1000))) { + && st.getDepartureTime() == (departureTime.getTimeInMillis() + - sd.getAsCalendar(_agencyTimeZone).getTimeInMillis()) + / 1000) { return st.getTrip(); }