use of org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl in project onebusaway-application-modules by camsys.
the class DistanceAlongShapeMain method run.
public void run(String shapeFile, String stopsFile) throws IOException, DistanceAlongShapeException {
ShapePoints shapePoints = readShapePoints(shapeFile);
List<StopTimeEntryImpl> stopTimes = readStopTimes(stopsFile);
DistanceAlongShapeLibrary library = new DistanceAlongShapeLibrary();
PointAndIndex[] points = library.getDistancesAlongShape(shapePoints, stopTimes);
System.out.println(points);
}
use of org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl 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;
}
Aggregations