Search in sources :

Example 31 with StopTimeEntry

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

the class GenerateNarrativesTask method getAllOrientationsForStop.

private Collection<PointAndOrientation> getAllOrientationsForStop(NarrativeProviderImpl provider, StopEntry stop) {
    List<BlockStopTimeIndex> stopTimeIndices = _blockIndexService.getStopTimeIndicesForStop(stop);
    List<PointAndOrientation> pos = new ArrayList<PointAndOrientation>();
    Map<ShapeIdAndDistance, PointAndOrientation> orientationsByKey = new HashMap<ShapeIdAndDistance, PointAndOrientation>();
    for (BlockStopTimeIndex stopTimeIndex : stopTimeIndices) {
        for (BlockStopTimeEntry blockStopTime : stopTimeIndex.getStopTimes()) {
            StopTimeEntry stopTime = blockStopTime.getStopTime();
            TripEntry trip = stopTime.getTrip();
            AgencyAndId shapeId = trip.getShapeId();
            if (shapeId == null)
                continue;
            ShapePoints shapePoints = provider.getShapePointsForId(shapeId);
            if (shapePoints == null)
                continue;
            int shapePointIndex = stopTime.getShapePointIndex();
            if (shapePointIndex == -1)
                continue;
            ShapeIdAndDistance key = new ShapeIdAndDistance(shapeId, stopTime.getShapeDistTraveled());
            PointAndOrientation orientation = orientationsByKey.get(key);
            if (orientation == null) {
                int indexFrom = Math.max(0, shapePointIndex - 5);
                int indexTo = Math.min(shapePoints.getSize(), shapePointIndex + 5);
                ShapePointIndex shapePointIndexMethod = new DistanceTraveledShapePointIndex(stopTime.getShapeDistTraveled(), indexFrom, indexTo);
                orientation = shapePointIndexMethod.getPointAndOrientation(shapePoints);
                if (orientation == null)
                    continue;
                orientationsByKey.put(key, orientation);
            }
            pos.add(orientation);
        }
    }
    return orientationsByKey.values();
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) DistanceTraveledShapePointIndex(org.onebusaway.transit_data_federation.impl.shapes.DistanceTraveledShapePointIndex) DoubleArrayList(cern.colt.list.DoubleArrayList) ArrayList(java.util.ArrayList) PointAndOrientation(org.onebusaway.transit_data_federation.impl.shapes.PointAndOrientation) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) ShapePointIndex(org.onebusaway.transit_data_federation.impl.shapes.ShapePointIndex) DistanceTraveledShapePointIndex(org.onebusaway.transit_data_federation.impl.shapes.DistanceTraveledShapePointIndex) ProjectedPoint(org.onebusaway.transit_data_federation.model.ProjectedPoint) ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 32 with StopTimeEntry

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

the class RunTripEntry method getStopTime.

public int getStopTime() {
    // this run could end before the last stop
    int lastTime = reliefTime;
    if (lastTime < 0) {
        List<StopTimeEntry> stopTimes = entry.getStopTimes();
        StopTimeEntry lastStopTime = stopTimes.get(stopTimes.size() - 1);
        lastTime = lastStopTime.getDepartureTime();
    }
    return lastTime;
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)

Example 33 with StopTimeEntry

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

the class UnitTestingSupport method addStopTime.

public static StopTimeEntryImpl addStopTime(TripEntryImpl trip, StopTimeEntryImpl stopTime) {
    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    if (stopTimes == null) {
        stopTimes = new ArrayList<StopTimeEntry>();
        trip.setStopTimes(stopTimes);
    }
    int sequence = stopTimes.size();
    if (!stopTimes.isEmpty()) {
        StopTimeEntry prev = stopTimes.get(stopTimes.size() - 1);
        stopTime.setAccumulatedSlackTime(prev.getAccumulatedSlackTime() + prev.getSlackTime());
    }
    stopTimes.add(stopTime);
    stopTime.setTrip(trip);
    stopTime.setSequence(sequence);
    return stopTime;
}
Also used : StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) ShapePoint(org.onebusaway.gtfs.model.ShapePoint)

Example 34 with StopTimeEntry

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

the class BlockStopSequenceIndex method computeServiceInterval.

/**
 **
 * Private Methods
 ***
 */
private ServiceInterval computeServiceInterval(BlockSequenceIndex index, int stopIndex) {
    List<BlockSequence> sequences = _index.getSequences();
    BlockStopTimeEntry fromBst = sequences.get(0).getStopTimes().get(stopIndex);
    BlockStopTimeEntry toBst = sequences.get(sequences.size() - 1).getStopTimes().get(stopIndex);
    StopTimeEntry fromSt = fromBst.getStopTime();
    StopTimeEntry toSt = toBst.getStopTime();
    return new ServiceInterval(fromSt.getArrivalTime(), fromSt.getDepartureTime(), toSt.getArrivalTime(), toSt.getDepartureTime());
}
Also used : BlockSequence(org.onebusaway.transit_data_federation.impl.blocks.BlockSequence) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) ServiceInterval(org.onebusaway.gtfs.model.calendar.ServiceInterval) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)

Example 35 with StopTimeEntry

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

the class GtfsController method getStops.

@RequestMapping(value = "/stops/{agencyId}/{id}")
@ResponseBody
public List<CoordinatePoint> getStops(@PathVariable String agencyId, @PathVariable String id) {
    AgencyAndId routeId = new AgencyAndId(agencyId, id);
    RouteEntry route = _transitGraphDao.getRouteForId(routeId);
    TripEntry trip = routeToTrip(route);
    List<StopTimeEntry> stopTimes = trip.getStopTimes();
    List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
    for (StopTimeEntry entry : stopTimes) {
        StopEntry stop = entry.getStop();
        points.add(stop.getStopLocation());
    }
    return points;
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) ArrayList(java.util.ArrayList) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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