Package org.onebusaway.utility
Class TransitInterpolationLibrary
- java.lang.Object
-
- org.onebusaway.utility.TransitInterpolationLibrary
-
public class TransitInterpolationLibrary extends Object
Transit-specific methods to support searching for deviations (produced from real-time predictions) for a given stop. Interpolation behavior is consistent with the GTFS-realtime spec (https://developers.google.com/transit/gtfs-realtime/) when using theEInRangeStrategy.PREVIOUS_VALUEandEOutOfRangeStrategy.LAST_VALUEstrategies - in particular, this applies to the propagation of delays downstream in a trip. TheEInRangeStrategy.INTERPOLATEandEOutOfRangeStrategy.INTERPOLATEstrategies have behavior consistent with the normalInterpolationLibrary, which do not conform to the GTFS-rt spec.
-
-
Constructor Summary
Constructors Constructor Description TransitInterpolationLibrary()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Doubleinterpolate(double[] keys, double[] values, double target, EOutOfRangeStrategy outOfRangeStrategy)static Doubleinterpolate(double[] keys, double[] values, double target, EOutOfRangeStrategy outOfRangeStrategy, EInRangeStrategy inRangeStrategy)Find the deviation that should be used for a particular stop, given sorted keys (arrival times) and values (deviations) arrays.
-
-
-
Method Detail
-
interpolate
public static Double interpolate(double[] keys, double[] values, double target, EOutOfRangeStrategy outOfRangeStrategy)
-
interpolate
public static Double interpolate(double[] keys, double[] values, double target, EOutOfRangeStrategy outOfRangeStrategy, EInRangeStrategy inRangeStrategy)
Find the deviation that should be used for a particular stop, given sorted keys (arrival times) and values (deviations) arrays. Thetargetis the arrival time for the stop we're searching for. Delay propagation is consistent with the GTFS-realtime spec (https://developers.google.com/transit/gtfs-realtime/) when using theEInRangeStrategy.PREVIOUS_VALUEandEOutOfRangeStrategy.LAST_VALUEstrategies. IfEOutOfRangeStrategy.LAST_VALUEis provided and all deviations are downstream from the target stop, null will be returned to indicate that no real-time information is available for the target stop. IfEInRangeStrategy.INTERPOLATEis provided, this method will interpolate using linear interpolation and produce a value for a target key within the key-range of the map. For a key outside the range of the keys of the map, theoutOfRangeEOutOfRangeStrategystrategy will determine the interpolation behavior.EOutOfRangeStrategy.INTERPOLATEwill linearly extrapolate the value.- Parameters:
keys- sorted array of keys (the scheduled arrival time of the stop)values- sorted arrays of values (the list of real-time deviations for the provided stops)target- the target key used to interpolate a value (the scheduled arrival time of the stop)outOfRangeStrategy- the strategy to use for a target key that outside the key-range of the value map (useEOutOfRangeStrategy.LAST_VALUEfor GTFS-rt behavior)inRangeStrategy- the strategy to use for a target key that inside the key-range of the value map (useEInRangeStrategy.PREVIOUS_VALUEfor GTFS-rt behavior)- Returns:
- an interpolated value (deviation) for the target key, or null if the target is upstream of the deviations
-
-