diff --git a/transitclock/src/main/java/org/transitclock/applications/Core.java b/transitclock/src/main/java/org/transitclock/applications/Core.java index eff354f67..2bf13b19e 100755 --- a/transitclock/src/main/java/org/transitclock/applications/Core.java +++ b/transitclock/src/main/java/org/transitclock/applications/Core.java @@ -480,10 +480,12 @@ static private void populateCaches() throws Exception if(cacheReloadStartTimeStr.getValue().length()>0&&cacheReloadEndTimeStr.getValue().length()>0) { Criteria criteria = session.createCriteria(ArrivalDeparture.class); + logger.info("querying from {} to {}", cacheReloadStartTimeStr, cacheReloadEndTimeStr); + List results = StopArrivalDepartureCache.createArrivalDeparturesCriteriaMultiDay(criteria, new Date(Time.parse(cacheReloadStartTimeStr.getValue()).getTime()), new Date(Time.parse(cacheReloadEndTimeStr.getValue()).getTime())); - + logger.info("query complete from {} to {}", cacheReloadStartTimeStr, cacheReloadEndTimeStr); if(TripDataHistoryCacheFactory.getInstance()!=null) { logger.info("Populating TripDataHistoryCache cache for period {} to {}",cacheReloadStartTimeStr.getValue(),cacheReloadEndTimeStr.getValue()); diff --git a/transitclock/src/main/java/org/transitclock/core/SpatialMatch.java b/transitclock/src/main/java/org/transitclock/core/SpatialMatch.java index e10bc24cf..ec7472f8d 100644 --- a/transitclock/src/main/java/org/transitclock/core/SpatialMatch.java +++ b/transitclock/src/main/java/org/transitclock/core/SpatialMatch.java @@ -594,6 +594,11 @@ public int getScheduledWaitStopTimeSecs() { logger.error("no scheduled wait stop time for {} {}", tripIndex, stopPathIndex); return -1; } + if (scheduleTime.getDepartureTime() == null) { + // timepoints dont have departure times by convention + // this isn't an error + return -1; + } return scheduleTime.getDepartureTime(); } catch (Exception e) { logger.error("Tried to get wait stop time for a stop that didn't " diff --git a/transitclock/src/main/java/org/transitclock/core/TravelTimes.java b/transitclock/src/main/java/org/transitclock/core/TravelTimes.java index 839d0691c..e4d8dfab8 100644 --- a/transitclock/src/main/java/org/transitclock/core/TravelTimes.java +++ b/transitclock/src/main/java/org/transitclock/core/TravelTimes.java @@ -163,7 +163,7 @@ private static int adjustTravelTimeForWaitStop(int timeOfDaySecs, /** * Returns the scheduled epoch time vehicle is scheduled leave a wait stop. * Does not take into account whether vehicle can make it to the wait stop - * in time. + * in time. A wait stop now includes timepoint stops. * * @param indices * Describes which stop @@ -192,7 +192,9 @@ public static long scheduledDepartureTime(Indices indices, Integer scheduledDepartureTimeSecs = scheduleTime.getDepartureTime(); if (scheduledDepartureTimeSecs == null) { - logger.error("Called scheduledDepartureTimePlusWaitTime() for stop " + // timepoints will not have departure time set via convention + // this is not an error + logger.debug("Called scheduledDepartureTimePlusWaitTime() for stop " + "that doesn't have a scheduled departure time. {}", indices); return -1; diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/CacheTask.java b/transitclock/src/main/java/org/transitclock/core/dataCache/CacheTask.java index 898d74348..e9f73802e 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/CacheTask.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/CacheTask.java @@ -57,12 +57,12 @@ public String toString() { @Override public void run() throws Exception { - logger.error("in run for task with results=" + futureResults); + logger.info("in run for task with results=" + futureResults); Session session = null; List results = null; if (futureResults != null) { // block here until we have input ready - logger.error("async retrieval of {} to {}", startDate, endDate); + logger.info("async retrieval of {} to {}", startDate, endDate); try { results = (List) futureResults.get(); } catch (Throwable t) { @@ -70,16 +70,16 @@ public void run() throws Exception { logger.error("futureResult retrieval failed with {}", t, t); } if (results == null) { - logger.error("async retrieval of {} to {} failed!", startDate, endDate); + logger.info("async retrieval of {} to {} failed!", startDate, endDate); } else { - logger.error("async retrieval of {} to {} finished with {} results", startDate, endDate, results.size()); + logger.info("async retrieval of {} to {} finished with {} results", startDate, endDate, results.size()); } } try { if (this.futureResults == null) { session = HibernateUtils.getSession(); Criteria criteria = session.createCriteria(ArrivalDeparture.class); - logger.error("async / future results null, performing manual retrieval now"); + logger.info("async / future results null, performing manual retrieval now"); results = criteria.add(Restrictions.between("time", startDate, endDate)).list(); } @@ -87,9 +87,9 @@ public void run() throws Exception { switch (type) { case TripDataHistoryCacheFactory: if (results != null) { - logger.error("populating TripDataHistoryCache with " + results.size() + "records"); + logger.info("populating TripDataHistoryCache with " + results.size() + "records"); } else { - logger.error("populating TripDataHistoryCache with NuLl records"); + logger.info("populating TripDataHistoryCache with NuLl records"); } TripDataHistoryCacheFactory.getInstance().populateCacheFromDb(results); break; @@ -117,7 +117,7 @@ public void run() throws Exception { } catch (Throwable t) { logger.error("Error Populating {} cache for period {} to {}, {}", type, startDate, endDate, t, t); } finally { - logger.error("Finished Populating {} cache for period {} to {}", type, startDate, endDate); + logger.info("Finished Populating {} cache for period {} to {}", type, startDate, endDate); if (session != null) { // this session is in a separate thread and needs to be reclaimed // as it counts against the connection pool diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/KalmanErrorCacheKey.java b/transitclock/src/main/java/org/transitclock/core/dataCache/KalmanErrorCacheKey.java index 3cec5f392..fa7536cd5 100755 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/KalmanErrorCacheKey.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/KalmanErrorCacheKey.java @@ -1,6 +1,7 @@ package org.transitclock.core.dataCache; import org.transitclock.core.Indices; +import org.transitclock.db.structs.Trip; /** * @author Sean Og Crudden @@ -8,67 +9,92 @@ */ public class KalmanErrorCacheKey implements java.io.Serializable { + + private String routeId; + private String directionId; + private Integer startTimeSecondsIntoDay; + private String originStopId; + private String destinationStopId; - public String getTripId() { - return tripId; + // The vehicleId is only used for debug purposed we know in log which vehicle set the error value + private String vehicleId; + + public String getRouteId() { + return routeId; } - public void setTripId(String tripId) { - this.tripId = tripId; + public String getDirectionId() { + return directionId; } - public void setStopPathIndex(Integer stopPathIndex) { - this.stopPathIndex = stopPathIndex; + public Integer getStartTimeSecondsIntoDay() { + return startTimeSecondsIntoDay; } - private String tripId; - private Integer stopPathIndex; - - // The vehicleId is only used for debug purposed we know in log which vehicle set the error value - private String vehiceId; - - - public String getVehiceId() { - return vehiceId; + public String getOriginStopId() { + return originStopId; + } + + public String getDestinationStopId() { + return destinationStopId; } - public void setVehiceId(String vehiceId) { - this.vehiceId = vehiceId; + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; } /** * Needs to be serializable to add to cache */ - private static final long serialVersionUID = 5029823633051153716L; + private static final long serialVersionUID = 5029823633051153717L; public KalmanErrorCacheKey(Indices indices, String vehicleId) { super(); - - this.tripId=indices.getBlock().getTrip(indices.getTripIndex()).getId(); - this.stopPathIndex=indices.getStopPathIndex(); - this.vehiceId=vehicleId; + + Trip trip = indices.getBlock().getTrip(indices.getTripIndex()); + this.routeId = trip.getRouteId(); + this.directionId = trip.getDirectionId(); + this.startTimeSecondsIntoDay = trip.getStartTime(); + this.originStopId = trip.getTripPattern().getStopIds().get(0); + this.destinationStopId = trip.getLastStopId(); + this.vehicleId =vehicleId; } public KalmanErrorCacheKey(Indices indices) { super(); - - this.tripId=indices.getBlock().getTrip(indices.getTripIndex()).getId(); - this.stopPathIndex=indices.getStopPathIndex(); - - + + Trip trip = indices.getBlock().getTrip(indices.getTripIndex()); + this.routeId = trip.getRouteId(); + this.directionId = trip.getDirectionId(); + this.startTimeSecondsIntoDay = trip.getStartTime(); + this.originStopId = trip.getTripPattern().getStopIds().get(0); + this.destinationStopId = trip.getLastStopId(); + } @Override public String toString() { - return "KalmanErrorCacheKey [tripId=" + tripId + ", stopPathIndex=" + stopPathIndex + "]"; + return "KalmanErrorCacheKey [routeId=" + routeId + + ", directionId=" + directionId + + ", startTime=" + startTimeSecondsIntoDay + + ", originStopId=" + originStopId + + ", destinationStopId=" + destinationStopId + + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((stopPathIndex == null) ? 0 : stopPathIndex.hashCode()); - result = prime * result + ((tripId == null) ? 0 : tripId.hashCode()); + result = prime * result + ((routeId == null) ? 0 : routeId.hashCode()); + result = prime * result + ((directionId == null) ? 0 : directionId.hashCode()); + result = prime * result + ((originStopId == null) ? 0 : originStopId.hashCode()); + result = prime * result + ((destinationStopId == null) ? 0 : destinationStopId.hashCode()); + result = prime * result + ((startTimeSecondsIntoDay == null) ? 0 : startTimeSecondsIntoDay.hashCode()); return result; } @@ -81,41 +107,48 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; KalmanErrorCacheKey other = (KalmanErrorCacheKey) obj; - if (stopPathIndex == null) { - if (other.stopPathIndex != null) + if (routeId == null) { + if (other.routeId != null) + return false; + } else if (!routeId.equals(other.routeId)) + return false; + if (directionId == null) { + if (other.directionId != null) + return false; + } else if (!directionId.equals(other.directionId)) + return false; + if (startTimeSecondsIntoDay == null) { + if (other.startTimeSecondsIntoDay != null) + return false; + } else if (!startTimeSecondsIntoDay.equals(other.startTimeSecondsIntoDay)) + return false; + if (originStopId == null) { + if (other.originStopId != null) return false; - } else if (!stopPathIndex.equals(other.stopPathIndex)) + } else if (!originStopId.equals(other.originStopId)) return false; - if (tripId == null) { - if (other.tripId != null) + if (destinationStopId == null) { + if (other.destinationStopId != null) return false; - } else if (!tripId.equals(other.tripId)) + } else if (!destinationStopId.equals(other.destinationStopId)) return false; + return true; } - public KalmanErrorCacheKey(String tripId, Integer stopPathIndex) { + public KalmanErrorCacheKey(String routeId, String directionId, + Integer startTimeSecondsIntoDay, String originStopId, + String destinationStopId) { super(); - this.tripId = tripId; - this.stopPathIndex = stopPathIndex; + this.routeId = routeId; + this.directionId = directionId; + this.startTimeSecondsIntoDay = startTimeSecondsIntoDay; + this.originStopId = originStopId; + this.destinationStopId = destinationStopId; } - /** - * @return the stopPathIndex - */ - public int getStopPathIndex() { - return stopPathIndex; - } - - /** - * @param stopPathIndex the stopPathIndex to set - */ - public void setStopPathIndex(int stopPathIndex) { - this.stopPathIndex = stopPathIndex; - } - } diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/StopPathKey.java b/transitclock/src/main/java/org/transitclock/core/dataCache/StopPathKey.java new file mode 100644 index 000000000..5e545c5d1 --- /dev/null +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/StopPathKey.java @@ -0,0 +1,60 @@ +package org.transitclock.core.dataCache; + +import java.util.Objects; + +/** + * StopPatch caching based in TripInstance (Route/Direction/time) instead of tripId. + */ +public class StopPathKey extends TripKey implements java.io.Serializable { + + private static long serialVersionUID = 1L; + + private String originStopId; + private String destinationStopId; + private boolean travelTime; + + public StopPathKey(String routeId, + String directionId, + Integer startTimeSecondsIntoDay, + Long tripStartTime, + String originStopId, + String destinationStopId, + boolean travelTime) { + super(routeId, directionId, tripStartTime, startTimeSecondsIntoDay); + this.originStopId = originStopId; + this.destinationStopId = destinationStopId; + this.travelTime = travelTime; + } + + public String getOriginStopId() { + return originStopId; + } + + public String getDestinationStopId() { + return destinationStopId; + } + + public boolean isTravelTime() { + return travelTime; + } + + @Override + public int hashCode() { + return Objects.hash(getRouteId(), getDirectionId(), getStartTimeSecondsIntoDay(), + getTripStartTime(), originStopId, destinationStopId, travelTime); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return true; + StopPathKey that = (StopPathKey) o; + return Objects.equals(getRouteId(), that.getRouteId()) + && Objects.equals(getDirectionId(), that.getDirectionId()) + && Objects.equals(getStartTimeSecondsIntoDay(), that.getStartTimeSecondsIntoDay()) + && Objects.equals(getTripStartTime(), that.getTripStartTime()) + && Objects.equals(originStopId, that.originStopId) + && Objects.equals(destinationStopId, that.destinationStopId) + && Objects.equals(travelTime, that.travelTime); + } +} diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/TripDataHistoryCacheInterface.java b/transitclock/src/main/java/org/transitclock/core/dataCache/TripDataHistoryCacheInterface.java index e15fb9c0c..3dbe06ae6 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/TripDataHistoryCacheInterface.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/TripDataHistoryCacheInterface.java @@ -1,10 +1,7 @@ package org.transitclock.core.dataCache; -import java.util.Date; import java.util.List; -import org.hibernate.Session; -import org.slf4j.Logger; import org.transitclock.db.structs.ArrivalDeparture; import org.transitclock.ipc.data.IpcArrivalDeparture; diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/TripKey.java b/transitclock/src/main/java/org/transitclock/core/dataCache/TripKey.java old mode 100755 new mode 100644 index cfa1ff89b..4bc095bd6 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/TripKey.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/TripKey.java @@ -1,98 +1,65 @@ -package org.transitclock.core.dataCache; - -import java.util.Date; -/** - * @author Sean Og Crudden - * - */ -public class TripKey implements java.io.Serializable { - /** - * Needs to be serializable to add to cache - */ - private static final long serialVersionUID = 5029823633051153715L; - private String tripId; - - private Date tripStartDate; - private Integer startTime; - - - /** - * @return the tripId - */ - public String getTripId() { - return tripId; - } - - /** - * @return the tripStartDate - */ - public Date getTripStartDate() { - return tripStartDate; - } - /** - * @return the startTime - */ - public Integer getStartTime() { - return startTime; - } - public TripKey(String tripId, Date tripStartDate, - Integer startTime) { - super(); - this.tripId = tripId; - - this.tripStartDate = tripStartDate; - this.startTime = startTime; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); - result = prime * result + ((tripId == null) ? 0 : tripId.hashCode()); - result = prime * result + ((tripStartDate == null) ? 0 : tripStartDate.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TripKey other = (TripKey) obj; - if (startTime == null) { - if (other.startTime != null) - return false; - } else if (!startTime.equals(other.startTime)) - return false; - if (tripId == null) { - if (other.tripId != null) - return false; - } else if (!tripId.equals(other.tripId)) - return false; - if (tripStartDate == null) { - if (other.tripStartDate != null) - return false; - } else if (!tripStartDate.equals(other.tripStartDate)) - return false; - return true; - } - - @Override - public String toString() { - return "TripKey [tripId=" + tripId + ", tripStartDate=" + tripStartDate + ", startTime=" + startTime + "]"; - } - - public void setStartTime(Integer time) { - // TODO Auto-generated method stub - this.startTime=time; - - } - - - - -} +package org.transitclock.core.dataCache; + +import java.util.Date; +import java.util.Objects; + +/** + * index based on the instance of a trip via route, direction, and startTime + */ +public class TripKey implements java.io.Serializable { + + private static final long serialVersionUID = 1; + private String routeId; + private String directionId; + private Long tripStartTime; + private Integer startTimeSecondsIntoDay; + + public TripKey(String routeId, + String directionId, + Long tripStartTime, + Integer startTimeSecondsIntoDay) { + this.routeId = routeId; + this.directionId = directionId; + this.tripStartTime = tripStartTime; + this.startTimeSecondsIntoDay = startTimeSecondsIntoDay; + } + + public String getRouteId() { + return routeId; + } + + public String getDirectionId() { + return directionId; + } + + public Integer getStartTimeSecondsIntoDay() { + return startTimeSecondsIntoDay; + } + + public Long getTripStartTime() { + return tripStartTime; + } + + @Override + public int hashCode() { + return Objects.hash(routeId, directionId, startTimeSecondsIntoDay, tripStartTime); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return true; + TripKey that = (TripKey) o; + return Objects.equals(routeId, that.routeId) + && Objects.equals(directionId, that.directionId) + && Objects.equals(startTimeSecondsIntoDay, that.startTimeSecondsIntoDay) + && Objects.equals(tripStartTime, that.tripStartTime); + } + + @Override + public String toString() { + return "TripKey [routeId=" + routeId + ", directionId=" + directionId + ", startTimeSecondsIntoDay=" + startTimeSecondsIntoDay + + ", tripStartTime=" + new Date(tripStartTime) + "]"; + } + +} diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/frequency/TripDataHistoryCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/frequency/TripDataHistoryCache.java index be95c43e2..736bd2c0b 100755 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/frequency/TripDataHistoryCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/frequency/TripDataHistoryCache.java @@ -140,8 +140,9 @@ public TripKey putArrivalDeparture(ArrivalDeparture arrivalDeparture) { time = FrequencyBasedHistoricalAverageCache.round(time, FrequencyBasedHistoricalAverageCache.getCacheIncrementsForFrequencyService()); if (trip != null) { - tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), time); logger.debug("Putting :{} in TripDataHistoryCache cache using key {}.", arrivalDeparture, tripKey); @@ -188,8 +189,9 @@ public TripKey putArrivalDepartureInMemory(Map map, Arrival time = FrequencyBasedHistoricalAverageCache.round(time, FrequencyBasedHistoricalAverageCache.getCacheIncrementsForFrequencyService()); if (trip != null) { - tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), time); logger.debug("Putting :{} in TripDataHistoryCache cache using key {}.", arrivalDeparture, tripKey); diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/scheduled/TripDataHistoryCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/scheduled/TripDataHistoryCache.java index 1355e89f9..e3e85e1f7 100755 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/scheduled/TripDataHistoryCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/ehcache/scheduled/TripDataHistoryCache.java @@ -117,8 +117,9 @@ public TripKey putArrivalDeparture(ArrivalDeparture arrivalDeparture) { tripStartTime = trip.getStartTime(); } - tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), tripStartTime); IpcArrivalDeparture ipcad = null; @@ -155,8 +156,9 @@ public TripKey putArrivalDeparture(Map map, ArrivalDepartur tripStartTime = trip.getStartTime(); } - TripKey tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + TripKey tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), tripStartTime); IpcArrivalDeparture ipcad = new IpcArrivalDeparture(arrivalDeparture); @@ -180,8 +182,11 @@ public TripKey putArrivalDeparture(Map map, ArrivalDepartur @Override public void populateCacheFromDb(List results) { - logger.error("in populateCacheFromDb with results=" + results); - if (results == null || results.isEmpty()) return; + if (results == null || results.isEmpty()) { + logger.info("in populateCacheFromDb with null"); + return; + } + logger.info("in populateCacheFromDb with results entries" + results.size()); Map map = new HashMap<>(results.size()); Date nearestDay = DateUtils.truncate(new Date(results.get(0).getTime()), Calendar.DAY_OF_MONTH); @@ -197,7 +202,7 @@ public void populateCacheFromDb(List results) if (GtfsData.routeNotFiltered(result.getRouteId())) { putArrivalDeparture(map, result, dbConfig, nearestDay); } else { - logger.error("filtered route " + result.getRouteId()); + logger.info("filtered route " + result.getRouteId()); } counter++; } @@ -205,11 +210,11 @@ public void populateCacheFromDb(List results) logger.error("Exception in populateCacheFromDb {}", t, t); } - logger.error("sorting Trip Data History Records of {}", map.size()); + logger.info("sorting Trip Data History Records of {}", map.size()); for (TripEvents value : map.values()) { value.sort(); } - logger.error("sorted Trip Data History Records of {}", map.size()); + logger.info("sorted Trip Data History Records of {}", map.size()); synchronized (cache) { logger.info("adding " + map.size() + " to cache"); diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/frequency/FrequencyBasedHistoricalAverageCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/frequency/FrequencyBasedHistoricalAverageCache.java index f3d758073..b885a1d3e 100755 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/frequency/FrequencyBasedHistoricalAverageCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/frequency/FrequencyBasedHistoricalAverageCache.java @@ -240,8 +240,9 @@ public IpcArrivalDeparture findPreviousArrivalEvent(List ar private TravelTimeResult getLastPathDuration(IpcArrivalDeparture arrivalDeparture, Trip trip) { Date nearestDay = DateUtils.truncate(new Date(arrivalDeparture.getTime().getTime()), Calendar.DAY_OF_MONTH); - TripKey tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + TripKey tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), trip.getStartTime()); List arrivalDepartures=(List) TripDataHistoryCacheFactory.getInstance().getTripHistory(tripKey); @@ -263,8 +264,9 @@ private TravelTimeResult getLastPathDuration(IpcArrivalDeparture arrivalDepartur private DwellTimeResult getLastStopDuration(IpcArrivalDeparture arrivalDeparture, Trip trip) { Date nearestDay = DateUtils.truncate(new Date(arrivalDeparture.getTime().getTime()), Calendar.DAY_OF_MONTH); - TripKey tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + TripKey tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), trip.getStartTime()); List arrivalDepartures=(List) TripDataHistoryCacheFactory.getInstance().getTripHistory(tripKey); diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/frequency/TripDataHistoryCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/frequency/TripDataHistoryCache.java index c1fbf125d..bd525da2d 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/frequency/TripDataHistoryCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/frequency/TripDataHistoryCache.java @@ -61,14 +61,17 @@ public void logCache(Logger logger) { } @Override - public List getTripHistory(TripKey tripKey) { - + public List getTripHistory(TripKey tripKey) { + /* this is what gets the trip from the buckets */ - int time = FrequencyBasedHistoricalAverageCache.round(tripKey.getStartTime(), FrequencyBasedHistoricalAverageCache.getCacheIncrementsForFrequencyService()); - - tripKey.setStartTime(time); - - return cache.get(tripKey); + int time = FrequencyBasedHistoricalAverageCache.round(tripKey.getTripStartTime(), FrequencyBasedHistoricalAverageCache.getCacheIncrementsForFrequencyService()); + + TripKey copy = new TripKey(tripKey.getRouteId(), + tripKey.getDirectionId(), + tripKey.getTripStartTime(), + time); + + return cache.get(copy); } @Override @@ -96,8 +99,9 @@ synchronized public TripKey putArrivalDeparture(ArrivalDeparture arrivalDepartur /* this is what gets the trip from the buckets */ time=FrequencyBasedHistoricalAverageCache.round(time, FrequencyBasedHistoricalAverageCache.getCacheIncrementsForFrequencyService()); - tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), time); List list = cache.get(tripKey); diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/scheduled/TripDataHistoryCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/scheduled/TripDataHistoryCache.java index 167ba8f36..86e642ec6 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/scheduled/TripDataHistoryCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/jcs/scheduled/TripDataHistoryCache.java @@ -60,7 +60,7 @@ public void logCache(Logger logger) { } @Override - public List getTripHistory(TripKey tripKey) { + public List getTripHistory(TripKey tripKey) { return cache.get(tripKey); } @@ -84,8 +84,9 @@ synchronized public TripKey putArrivalDeparture(ArrivalDeparture arrivalDepartur if(trip!=null) { - tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), trip.getStartTime()); List list = cache.get(tripKey); diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/KalmanErrorCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/KalmanErrorCache.java index e02a1ca39..9b471fd62 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/KalmanErrorCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/KalmanErrorCache.java @@ -108,10 +108,20 @@ public List getKeys() { } private String createKey(KalmanErrorCacheKey key) { - return keystub + key.getTripId() + "_" + key.getStopPathIndex(); + + return keystub + key.getRouteId() + + "_" + key.getDirectionId() + + "_" + key.getStartTimeSecondsIntoDay() + + "_" + key.getOriginStopId() + + "_" + key.getDestinationStopId(); } private String createDwellKey(KalmanErrorCacheKey key) { - return dwellKeystub + key.getTripId() + "_" + key.getStopPathIndex(); + return dwellKeystub + + key.getRouteId() + + "_" + key.getDirectionId() + + "_" + key.getStartTimeSecondsIntoDay() + + "_" + key.getOriginStopId() + + "_" + key.getDestinationStopId(); } diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/TripDataHistoryCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/TripDataHistoryCache.java index 4e5bf118e..bb452f7df 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/TripDataHistoryCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/memcached/scheduled/TripDataHistoryCache.java @@ -81,7 +81,10 @@ public TripKey putArrivalDeparture(ArrivalDeparture arrivalDeparture) { Trip trip = dbConfig.getTrip(arrivalDeparture.getTripId()); if (trip != null) { - TripKey tripKey = new TripKey(arrivalDeparture.getTripId(), nearestDay, trip.getStartTime()); + TripKey tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), + trip.getStartTime()); List list = this.getTripHistory(tripKey); @@ -148,7 +151,11 @@ public IpcArrivalDeparture findPreviousDepartureEvent(List private String createKey(TripKey tripKey) { SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); - return keystub + tripKey.getTripId() + "_" + formatter.format(tripKey.getTripStartDate()); + return keystub + tripKey.getRouteId() + + "_" + + tripKey.getDirectionId() + + "_" + + formatter.format(tripKey.getTripStartTime()); } private static Iterable emptyIfNull(Iterable iterable) { return iterable == null ? Collections. emptyList() : iterable; diff --git a/transitclock/src/main/java/org/transitclock/core/dataCache/scheduled/ScheduleBasedHistoricalAverageCache.java b/transitclock/src/main/java/org/transitclock/core/dataCache/scheduled/ScheduleBasedHistoricalAverageCache.java index c27f42737..f57c25c81 100644 --- a/transitclock/src/main/java/org/transitclock/core/dataCache/scheduled/ScheduleBasedHistoricalAverageCache.java +++ b/transitclock/src/main/java/org/transitclock/core/dataCache/scheduled/ScheduleBasedHistoricalAverageCache.java @@ -190,8 +190,9 @@ public void putArrivalDepartureInMemory(Map map, ArrivalDeparture arrivalDepartu private TravelTimeDetails getLastTravelTimeDetails(IpcArrivalDeparture arrivalDeparture, Trip trip) { Date nearestDay = DateUtils.truncate(new Date(arrivalDeparture.getTime().getTime()), Calendar.DAY_OF_MONTH); - TripKey tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + TripKey tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), trip.getStartTime()); @@ -213,8 +214,9 @@ private TravelTimeDetails getLastTravelTimeDetails(IpcArrivalDeparture arrivalDe private DwellTimeDetails getLastDwellTimeDetails(IpcArrivalDeparture arrivalDeparture, Trip trip) { Date nearestDay = DateUtils.truncate(new Date(arrivalDeparture.getTime().getTime()), Calendar.DAY_OF_MONTH); - TripKey tripKey = new TripKey(arrivalDeparture.getTripId(), - nearestDay, + TripKey tripKey = new TripKey(arrivalDeparture.getRouteId(), + arrivalDeparture.getDirectionId(), + nearestDay.getTime(), trip.getStartTime()); // copy this list in case it changes underneath us diff --git a/transitclock/src/main/java/org/transitclock/core/predictiongenerator/HistoricalPredictionLibrary.java b/transitclock/src/main/java/org/transitclock/core/predictiongenerator/HistoricalPredictionLibrary.java index 3fbe2e38b..1b1626f3c 100644 --- a/transitclock/src/main/java/org/transitclock/core/predictiongenerator/HistoricalPredictionLibrary.java +++ b/transitclock/src/main/java/org/transitclock/core/predictiongenerator/HistoricalPredictionLibrary.java @@ -250,8 +250,8 @@ private static Integer numAfter(List stops, String stop1, String stop2) } public static List getHistoricalTravelTimes(TripDataHistoryCacheInterface cache, - String tripId, - String direction, + String routeId, + String directionId, int stopPathIndex, Date startDate, Integer startTime, @@ -270,7 +270,7 @@ public static List getHistoricalTravelTimes(TripDataHistoryCa Date nearestDay = DateUtils.truncate(DateUtils.addDays(startDate, (i + 1) * -1), Calendar.DAY_OF_MONTH); - TripKey tripKey = new TripKey(tripId, nearestDay, startTime); + TripKey tripKey = new TripKey(routeId, directionId, nearestDay.getTime(), startTime); results = cache.getTripHistory(tripKey); diff --git a/transitclock/src/main/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/KalmanPredictionGeneratorImpl.java b/transitclock/src/main/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/KalmanPredictionGeneratorImpl.java index ca76d79f9..11bf34e5b 100755 --- a/transitclock/src/main/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/KalmanPredictionGeneratorImpl.java +++ b/transitclock/src/main/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/KalmanPredictionGeneratorImpl.java @@ -190,7 +190,7 @@ protected List getHistoricalTravelTimes(AvlReport avlReport, List historicalTravelTimes = HistoricalPredictionLibrary.getHistoricalTravelTimes( getTripCache(), - currentVehicleState.getTrip().getId(), + currentVehicleState.getTrip().getRouteId(), currentVehicleState.getTrip().getDirectionId(), indices.getStopPathIndex(), nearestDay, diff --git a/transitclock/src/main/java/org/transitclock/core/reporting/RunTimeGenerator.java b/transitclock/src/main/java/org/transitclock/core/reporting/RunTimeGenerator.java index 457c62c97..cbe4172de 100755 --- a/transitclock/src/main/java/org/transitclock/core/reporting/RunTimeGenerator.java +++ b/transitclock/src/main/java/org/transitclock/core/reporting/RunTimeGenerator.java @@ -61,12 +61,13 @@ public boolean generate(VehicleState vehicleState) { // Lookup ArrivalsDepartures for Trip // If no valid ArrivalsDepartures then return - String tripId = prevMatch.getTrip().getId(); + String routeId = prevMatch.getRoute().getId(); + String directionId = prevMatch.getTrip().getDirectionId(); long vehicleMatchAvlTime = prevMatch.getAvlTime(); Integer tripStartTime = prevMatch.getTrip().getStartTime(); - List arrivalDeparturesForStop = getArrivalDeparturesForTrip(tripId, - vehicleMatchAvlTime, tripStartTime); + List arrivalDeparturesForStop = getArrivalDeparturesForTrip(routeId, + directionId, vehicleMatchAvlTime, tripStartTime); if(!isArrivalDeparturesValid(arrivalDeparturesForStop)){ return false; @@ -144,9 +145,9 @@ boolean isVehicleStateValid(VehicleState vehicleState){ } - public List getArrivalDeparturesForTrip(String tripId, long vehicleMatchAvlTime, Integer startTime){ + public List getArrivalDeparturesForTrip(String routeId, String directionId, long vehicleMatchAvlTime, Integer startTime){ Date nearestDay = DateUtils.truncate(new Date(vehicleMatchAvlTime), Calendar.DAY_OF_MONTH); - TripKey key=new TripKey(tripId, nearestDay, startTime); + TripKey key=new TripKey(routeId, directionId, nearestDay.getTime(), startTime); return TripDataHistoryCacheFactory.getInstance().getTripHistory(key); } diff --git a/transitclock/src/main/java/org/transitclock/ipc/data/IpcKalmanErrorCacheKey.java b/transitclock/src/main/java/org/transitclock/ipc/data/IpcKalmanErrorCacheKey.java index 5b569059e..0352a9878 100755 --- a/transitclock/src/main/java/org/transitclock/ipc/data/IpcKalmanErrorCacheKey.java +++ b/transitclock/src/main/java/org/transitclock/ipc/data/IpcKalmanErrorCacheKey.java @@ -8,25 +8,61 @@ public class IpcKalmanErrorCacheKey implements Serializable { - private static final long serialVersionUID = -748336688312487489L; - private String tripId; - private Integer stopPathIndex; - + private static final long serialVersionUID = -748336688312487490L; + + private String routeId; + private String directionId; + private Integer startTimeSecondsIntoDay; + private String originStopId; + private String destinationStopId; + + public IpcKalmanErrorCacheKey(KalmanErrorCacheKey key) { - super(); - this.tripId=key.getTripId(); - this.stopPathIndex=key.getStopPathIndex(); - } - public String getTripId() { - return tripId; + super(); + this.routeId = key.getRouteId(); + this.directionId = key.getDirectionId(); + this.startTimeSecondsIntoDay = key.getStartTimeSecondsIntoDay(); + this.originStopId = key.getOriginStopId(); + this.destinationStopId = key.getDestinationStopId(); } - public void setTripId(String tripId) { - this.tripId = tripId; + + public String getRouteId() { + return routeId; } - public Integer getStopPathIndex() { - return stopPathIndex; + + public void setRouteId(String routeId) { + this.routeId = routeId; } - public void setStopPathIndex(Integer stopPathIndex) { - this.stopPathIndex = stopPathIndex; + + public String getDirectionId() { + return directionId; + } + + public void setDirectionId(String directionId) { + this.directionId = directionId; + } + + public Integer getStartTimeSecondsIntoDay() { + return startTimeSecondsIntoDay; + } + + public void setStartTimeSecondsIntoDay(Integer startTimeSecondsIntoDay) { + this.startTimeSecondsIntoDay = startTimeSecondsIntoDay; + } + + public String getOriginStopId() { + return originStopId; + } + + public void setOriginStopId(String originStopId) { + this.originStopId = originStopId; + } + + public String getDestinationStopId() { + return destinationStopId; + } + + public void setDestinationStopId(String destinationStopId) { + this.destinationStopId = destinationStopId; } } diff --git a/transitclock/src/main/java/org/transitclock/ipc/interfaces/CacheQueryInterface.java b/transitclock/src/main/java/org/transitclock/ipc/interfaces/CacheQueryInterface.java index 4ada258c3..6ac79d14c 100755 --- a/transitclock/src/main/java/org/transitclock/ipc/interfaces/CacheQueryInterface.java +++ b/transitclock/src/main/java/org/transitclock/ipc/interfaces/CacheQueryInterface.java @@ -71,13 +71,15 @@ public IpcHistoricalAverage getHistoricalAverage(String tripId, Integer stopPath /** * Return the arrivals and departures for a trip on a specific day and start time - * @param tripId + * @param routeId + * @param directionId * @param date * @param starttime * @return * @throws RemoteException */ - public List getTripArrivalDepartures(String tripId, LocalDate date, Integer starttime) + public List getTripArrivalDepartures(String routeId, String directionId, + LocalDate date, Integer starttime) throws RemoteException; @@ -112,11 +114,14 @@ public List getHoldingTimeCacheKeys() /** * Return the latest Kalman error value for a the stop path of a trip. - * @param tripId - * @param stopPathIndex + * @param routeId + * @param directionId + * * @return * @throws RemoteException */ - public Double getKalmanErrorValue(String tripId, Integer stopPathIndex) throws RemoteException; + public Double getKalmanErrorValue(String routeId, String directionId, + Integer startTimeSecondsIntoDay, + String originStopId, String destinationStopId) throws RemoteException; } diff --git a/transitclock/src/main/java/org/transitclock/ipc/servers/CacheQueryServer.java b/transitclock/src/main/java/org/transitclock/ipc/servers/CacheQueryServer.java index 3bdb48572..c3255ea44 100755 --- a/transitclock/src/main/java/org/transitclock/ipc/servers/CacheQueryServer.java +++ b/transitclock/src/main/java/org/transitclock/ipc/servers/CacheQueryServer.java @@ -114,45 +114,50 @@ public IpcHistoricalAverage getHistoricalAverage(String tripId, Integer stopPath } @Override - public List getTripArrivalDepartures(String tripId, LocalDate localDate, Integer starttime) + public List getTripArrivalDepartures(String routeId, String directionId, + LocalDate localDate, Integer secondsIntoDay) throws RemoteException { try { List result = new ArrayList(); - if(tripId!=null && localDate!=null && starttime!=null){ + // case I: we have route/direction/secondsIntoDay/startTime + if(routeId!=null && directionId!=null && localDate!=null && secondsIntoDay!=null){ Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); - TripKey tripKey = new TripKey(tripId, date, starttime); + TripKey tripKey = new TripKey(routeId, directionId, date.getTime(), secondsIntoDay); result = TripDataHistoryCacheFactory.getInstance().getTripHistory(tripKey); } - else if(tripId!=null && localDate!=null && starttime==null) + // case II: we have route/direction/secondsIntoDay + else if(result!=null && directionId!=null && localDate!=null && secondsIntoDay==null) { Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); for(TripKey key:TripDataHistoryCacheFactory.getInstance().getKeys()) { - if(key.getTripId().equals(tripId) && date.compareTo(key.getTripStartDate())==0) + if(key.getRouteId().equals(routeId) && date.getTime() == key.getTripStartTime()) { result.addAll(TripDataHistoryCacheFactory.getInstance().getTripHistory(key)); } } - }else if(tripId!=null && localDate==null && starttime==null) + // case III: we have route/direction + }else if(routeId!=null && directionId !=null && localDate==null && secondsIntoDay==null) { for(TripKey key:TripDataHistoryCacheFactory.getInstance().getKeys()) { - if(key.getTripId().equals(tripId)) + if(key.getRouteId().equals(routeId) && key.getDirectionId().equals(directionId)) { result.addAll(TripDataHistoryCacheFactory.getInstance().getTripHistory(key)); } } } - else if(tripId==null && localDate!=null && starttime==null) + // case IV: we have tripStartTime + else if(routeId==null && directionId==null && localDate!=null && secondsIntoDay==null) { Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); for(TripKey key:TripDataHistoryCacheFactory.getInstance().getKeys()) { - if(date.compareTo(key.getTripStartDate())==0) + if(date.getTime() == key.getTripStartTime()) { result.addAll(TripDataHistoryCacheFactory.getInstance().getTripHistory(key)); } @@ -183,8 +188,9 @@ public List getScheduledBasedHistoricalAverageCach } @Override - public Double getKalmanErrorValue(String tripId, Integer stopPathIndex) throws RemoteException { - KalmanErrorCacheKey key=new KalmanErrorCacheKey(tripId, stopPathIndex); + public Double getKalmanErrorValue(String routeId, String directionId, Integer startTimeSecondsIntoDay, + String originStopId, String destinationStopId) throws RemoteException { + KalmanErrorCacheKey key=new KalmanErrorCacheKey(routeId, directionId, startTimeSecondsIntoDay, originStopId, destinationStopId); Double result = ErrorCacheFactory.getInstance().getErrorValue(key).getError(); return result; } diff --git a/transitclock/src/test/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/TripDataHistoryTestCache.java b/transitclock/src/test/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/TripDataHistoryTestCache.java index 0364640e9..f2d1038e6 100644 --- a/transitclock/src/test/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/TripDataHistoryTestCache.java +++ b/transitclock/src/test/java/org/transitclock/core/predictiongenerator/scheduled/traveltime/kalman/TripDataHistoryTestCache.java @@ -16,13 +16,11 @@ */ package org.transitclock.core.predictiongenerator.scheduled.traveltime.kalman; -import org.hibernate.Session; import org.transitclock.core.dataCache.TripDataHistoryCacheInterface; import org.transitclock.core.dataCache.TripKey; import org.transitclock.db.structs.ArrivalDeparture; import org.transitclock.ipc.data.IpcArrivalDeparture; -import java.util.Date; import java.util.List; /** diff --git a/transitclockApi/src/main/java/org/transitclock/api/data/ApiKalmanErrorCacheKey.java b/transitclockApi/src/main/java/org/transitclock/api/data/ApiKalmanErrorCacheKey.java index 2f2007e06..a7b05788e 100755 --- a/transitclockApi/src/main/java/org/transitclock/api/data/ApiKalmanErrorCacheKey.java +++ b/transitclockApi/src/main/java/org/transitclock/api/data/ApiKalmanErrorCacheKey.java @@ -15,16 +15,24 @@ public class ApiKalmanErrorCacheKey { @XmlAttribute - private String tripId; + private String routeId; @XmlAttribute - private Integer stopPathIndex; + private String directionId; + @XmlAttribute + private Integer startTimeSecondsIntoDay; + @XmlAttribute + private String originStopId; + @XmlAttribute + private String destinationStopId; public ApiKalmanErrorCacheKey() { } public ApiKalmanErrorCacheKey(IpcKalmanErrorCacheKey key) { - - this.tripId=key.getTripId(); - this.stopPathIndex=key.getStopPathIndex(); + this.routeId = key.getRouteId(); + this.directionId = key.getDirectionId(); + this.startTimeSecondsIntoDay = key.getStartTimeSecondsIntoDay(); + this.originStopId = key.getOriginStopId(); + this.destinationStopId = key.getDestinationStopId(); } } diff --git a/transitclockApi/src/main/java/org/transitclock/api/rootResources/CacheApi.java b/transitclockApi/src/main/java/org/transitclock/api/rootResources/CacheApi.java index 4ae7a4798..491a86654 100755 --- a/transitclockApi/src/main/java/org/transitclock/api/rootResources/CacheApi.java +++ b/transitclockApi/src/main/java/org/transitclock/api/rootResources/CacheApi.java @@ -242,7 +242,9 @@ public Response getStopArrivalDepartureCacheData(@BeanParam StandardParameters s tags= {"cache"}) public Response getTripArrivalDepartureCacheData(@BeanParam StandardParameters stdParameters, @Parameter(description="if specified, returns the list for that tripId.",required=false) - @QueryParam(value = "tripId") String tripid, + @QueryParam(value = "routeId") String routeId, + @Parameter(description="if specified, returns the list for that direction.",required=false) + @QueryParam(value = "directionId") String directionId, @Parameter(description="if specified, returns the list for that date.",required=false) @QueryParam(value = "date") DateParam date, @Parameter(description="if specified, returns the list for that starttime.",required=false) @@ -253,7 +255,7 @@ public Response getTripArrivalDepartureCacheData(@BeanParam StandardParameters s LocalDate queryDate = null; if (date != null) queryDate = date.getDate(); - List result = cachequeryInterface.getTripArrivalDepartures(tripid, queryDate, + List result = cachequeryInterface.getTripArrivalDepartures(routeId, directionId, queryDate, starttime); ApiArrivalDepartures apiResult = new ApiArrivalDepartures(result); @@ -305,14 +307,20 @@ public Response getHistoricalAverageCacheData(@BeanParam StandardParameters stdP tags= {"kalman","cache"}) public Response getKalmanErrorValue(@BeanParam StandardParameters stdParameters, @Parameter(description="Trip Id",required=true) - @QueryParam(value = "tripId") String tripId, - @Parameter(description="Stop path index",required=true) - @QueryParam(value = "stopPathIndex") Integer stopPathIndex) { + @QueryParam(value = "routeId") String routeId, + @QueryParam(value = "directionId") String directionId, + @Parameter(description="Trip Start time",required=true) + @QueryParam(value = "startTimeSecondsIntoDay") Integer startTimeSecondsIntoDay, + @Parameter(description="Origin Stop Id",required=true) + @QueryParam(value = "originStopId") String originStopId, + @Parameter(description="Destination Stop Id",required=true) + @QueryParam(value = "destinationStopId") String destinationStopId) { try { CacheQueryInterface cachequeryInterface = stdParameters.getCacheQueryInterface(); - Double result = cachequeryInterface.getKalmanErrorValue(tripId, stopPathIndex); + Double result = cachequeryInterface.getKalmanErrorValue(routeId, directionId, + startTimeSecondsIntoDay, originStopId, destinationStopId); Response response = stdParameters.createResponse(result);