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;
}
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++;
}
}
}
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);
}
}
Aggregations