Search in sources :

Example 31 with StopEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl in project onebusaway-application-modules by camsys.

the class DistanceAlongShapeMain method readStopTimes.

private List<StopTimeEntryImpl> readStopTimes(String path) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader(path));
    String line = null;
    Map<String, StopEntryImpl> stops = new HashMap<String, StopEntryImpl>();
    int index = 0;
    TripEntryImpl trip = UnitTestingSupport.trip("trip");
    List<StopTimeEntryImpl> stopTimes = new ArrayList<StopTimeEntryImpl>();
    while ((line = reader.readLine()) != null) {
        String[] tokens = line.split(" ");
        String stopId = tokens[0];
        double lat = Double.parseDouble(tokens[1]);
        double lon = Double.parseDouble(tokens[2]);
        StopEntryImpl stop = stops.get(stopId);
        if (stop == null) {
            stop = UnitTestingSupport.stop(stopId, lat, lon);
            stops.put(stopId, stop);
        }
        StopTimeEntryImpl stopTime = UnitTestingSupport.stopTime(index, stop, trip, index, index, Double.NaN);
        stopTimes.add(stopTime);
    }
    reader.close();
    return stopTimes;
}
Also used : HashMap(java.util.HashMap) StopTimeEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl) ArrayList(java.util.ArrayList) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) StopEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 32 with StopEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl in project onebusaway-application-modules by camsys.

the class BlockIndexServiceImpl method loadStopTripIndices.

private void loadStopTripIndices() {
    // Clear any existing indices
    for (StopEntry stop : _graphDao.getAllStops()) {
        StopEntryImpl stopImpl = (StopEntryImpl) stop;
        stopImpl.getStopTripIndices().clear();
        stopImpl.getFrequencyStopTripIndices().clear();
    }
    for (BlockSequenceIndex index : _blockSequenceIndices) {
        BlockSequence sequence = index.getSequences().get(0);
        int offset = 0;
        for (BlockStopTimeEntry bst : sequence.getStopTimes()) {
            StopTimeEntry stopTime = bst.getStopTime();
            StopEntryImpl stop = (StopEntryImpl) stopTime.getStop();
            BlockStopSequenceIndex blockStopTripIndex = new BlockStopSequenceIndex(index, offset);
            stop.addBlockStopTripIndex(blockStopTripIndex);
            offset++;
        }
    }
    for (FrequencyBlockTripIndex index : _frequencyBlockTripIndices) {
        BlockTripEntry trip = index.getTrips().get(0);
        int offset = 0;
        for (BlockStopTimeEntry bst : trip.getStopTimes()) {
            StopTimeEntry stopTime = bst.getStopTime();
            StopEntryImpl stop = (StopEntryImpl) stopTime.getStop();
            FrequencyStopTripIndex stopTripIndex = new FrequencyStopTripIndex(index, offset);
            stop.addFrequencyStopTripIndex(stopTripIndex);
            offset++;
        }
    }
}
Also used : BlockStopSequenceIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopSequenceIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) FrequencyStopTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyStopTripIndex) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) BlockSequenceIndex(org.onebusaway.transit_data_federation.services.blocks.BlockSequenceIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) BlockStopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry) StopEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)

Example 33 with StopEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl in project onebusaway-application-modules by camsys.

the class BlockIndexServiceImpl method loadStopTimeIndices.

private void loadStopTimeIndices() {
    // Clear any existing indices
    for (StopEntry stop : _graphDao.getAllStops()) {
        StopEntryImpl stopImpl = (StopEntryImpl) stop;
        stopImpl.getStopTimeIndices().clear();
        stopImpl.getFrequencyStopTimeIndices().clear();
    }
    BlockStopTimeIndicesFactory factory = new BlockStopTimeIndicesFactory();
    factory.setVerbose(true);
    List<BlockStopTimeIndex> indices = factory.createIndices(_graphDao.getAllBlocks());
    for (BlockStopTimeIndex index : indices) {
        StopEntryImpl stop = (StopEntryImpl) index.getStop();
        stop.addStopTimeIndex(index);
    }
    List<FrequencyBlockStopTimeIndex> frequencyIndices = factory.createFrequencyIndices(_graphDao.getAllBlocks());
    for (FrequencyBlockStopTimeIndex index : frequencyIndices) {
        StopEntryImpl stop = (StopEntryImpl) index.getStop();
        stop.addFrequencyStopTimeIndex(index);
    }
}
Also used : FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) StopEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)

Aggregations

StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)33 Test (org.junit.Test)23 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)22 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)16 StopTimeEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl)12 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)11 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)10 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)7 ArrayList (java.util.ArrayList)6 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)6 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)5 Stop (org.onebusaway.gtfs.model.Stop)5 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)5 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)5 XYPoint (org.onebusaway.geospatial.model.XYPoint)4 PointAndIndex (org.onebusaway.transit_data_federation.impl.shapes.PointAndIndex)4 StopNarrative (org.onebusaway.transit_data_federation.model.narrative.StopNarrative)4 FrequencyBlockTripIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex)4 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)4 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)4