Search in sources :

Example 21 with StopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method calculateArrivalDeviation.

private int calculateArrivalDeviation(BlockStopTimeEntry nextBlockStopTime, BlockStopTimeEntry targetBlockStopTime, int effectiveScheduleTime, int scheduleDeviation) {
    if (nextBlockStopTime == null || nextBlockStopTime.getBlockSequence() > targetBlockStopTime.getBlockSequence()) {
        return scheduleDeviation;
    }
    int a = targetBlockStopTime.getAccumulatedSlackTime();
    int b = nextBlockStopTime.getAccumulatedSlackTime();
    double slack = a - b;
    StopTimeEntry nextStopTime = nextBlockStopTime.getStopTime();
    if (nextStopTime.getArrivalTime() <= effectiveScheduleTime && effectiveScheduleTime <= nextStopTime.getDepartureTime()) {
        slack -= (effectiveScheduleTime - nextStopTime.getArrivalTime());
    }
    slack = Math.max(slack, 0);
    if (slack > 0 && scheduleDeviation > 0)
        scheduleDeviation -= Math.min(scheduleDeviation, slack);
    return scheduleDeviation;
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 22 with StopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method calculateDepartureDeviation.

private int calculateDepartureDeviation(BlockStopTimeEntry nextBlockStopTime, BlockStopTimeEntry targetBlockStopTime, int effectiveScheduleTime, int scheduleDeviation) {
    // TargetStopTime
    if (nextBlockStopTime == null || nextBlockStopTime.getBlockSequence() > targetBlockStopTime.getBlockSequence()) {
        return scheduleDeviation;
    }
    StopTimeEntry nextStopTime = nextBlockStopTime.getStopTime();
    StopTimeEntry targetStopTime = targetBlockStopTime.getStopTime();
    double slack = targetBlockStopTime.getAccumulatedSlackTime() - nextBlockStopTime.getAccumulatedSlackTime();
    slack += targetStopTime.getSlackTime();
    if (nextStopTime.getArrivalTime() <= effectiveScheduleTime && effectiveScheduleTime <= nextStopTime.getDepartureTime()) {
        slack -= (effectiveScheduleTime - nextStopTime.getArrivalTime());
    }
    slack = Math.max(slack, 0);
    if (slack > 0 && scheduleDeviation > 0)
        scheduleDeviation -= Math.min(scheduleDeviation, slack);
    return scheduleDeviation;
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 23 with StopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.

the class DistanceAlongShapeLibrary method assignmentSanityCheck.

private void assignmentSanityCheck(ShapePoints shapePoints, List<StopTimeEntryImpl> stopTimes, List<List<PointAndIndex>> possibleAssignments) throws DistanceAlongShapeException {
    int stIndex = 0;
    for (List<PointAndIndex> assignments : possibleAssignments) {
        if (assignments.isEmpty()) {
            StopTimeEntry stopTime = stopTimes.get(stIndex);
            throw new InvalidStopToShapeMappingException(stopTime.getTrip());
        }
        Min<PointAndIndex> m = new Min<PointAndIndex>();
        for (PointAndIndex pindex : assignments) m.add(pindex.distanceFromTarget, pindex);
        if (m.getMinValue() > _maxDistanceFromStopToShapePoint) {
            StopTimeEntry stopTime = stopTimes.get(stIndex);
            PointAndIndex pindex = m.getMinElement();
            CoordinatePoint point = shapePoints.getPointForIndex(pindex.index);
            throw new StopIsTooFarFromShapeException(stopTime, pindex, point);
        }
        stIndex++;
    }
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) Min(org.onebusaway.collections.Min) PointAndIndex(org.onebusaway.transit_data_federation.impl.shapes.PointAndIndex) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) XYPoint(org.onebusaway.geospatial.model.XYPoint)

Example 24 with StopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method computePredictedArrivalTimeInterval.

private TimeIntervalBean computePredictedArrivalTimeInterval(ArrivalAndDepartureInstance instance, BlockLocation blockLocation, long targetTime) {
    BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    // interval
    if (stopTime.getArrivalTime() <= blockLocation.getEffectiveScheduleTime())
        return null;
    ScheduleDeviationSamples samples = blockLocation.getScheduleDeviations();
    if (samples == null || samples.isEmpty())
        return null;
    double mu = InterpolationLibrary.interpolate(samples.getScheduleTimes(), samples.getScheduleDeviationMus(), stopTime.getArrivalTime(), EOutOfRangeStrategy.LAST_VALUE, EInRangeStrategy.INTERPOLATE);
    double sigma = InterpolationLibrary.interpolate(samples.getScheduleTimes(), samples.getScheduleDeviationSigmas(), stopTime.getArrivalTime(), EOutOfRangeStrategy.LAST_VALUE, EInRangeStrategy.INTERPOLATE);
    long from = (long) (instance.getScheduledArrivalTime() + (mu - sigma) * 1000);
    long to = (long) (instance.getScheduledArrivalTime() + (mu + sigma) * 1000);
    return new TimeIntervalBean(from, to);
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) ScheduleDeviationSamples(org.onebusaway.transit_data_federation.services.realtime.ScheduleDeviationSamples) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) TimeIntervalBean(org.onebusaway.transit_data.model.TimeIntervalBean)

Example 25 with StopTimeEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.

the class ArrivalAndDepartureServiceImpl method isMatch.

private boolean isMatch(List<StopTimeEntry> stopTimes, AgencyAndId stopId, int index) {
    if (index < 0 || index >= stopTimes.size())
        return false;
    StopTimeEntry stopTime = stopTimes.get(index);
    StopEntry stop = stopTime.getStop();
    return stop.getId().equals(stopId);
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)

Aggregations

StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)50 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)40 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)18 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)15 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)15 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)12 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)10 ArrayList (java.util.ArrayList)6 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)6 ServiceInterval (org.onebusaway.gtfs.model.calendar.ServiceInterval)4 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)4 RouteEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry)4 HashMap (java.util.HashMap)3 Min (org.onebusaway.collections.Min)3 Cacheable (org.onebusaway.container.cache.Cacheable)3 StopBean (org.onebusaway.transit_data.model.StopBean)3 PointAndOrientation (org.onebusaway.transit_data_federation.impl.shapes.PointAndOrientation)3 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)3 HashSet (java.util.HashSet)2 TimeIntervalBean (org.onebusaway.transit_data.model.TimeIntervalBean)2