Search in sources :

Example 31 with StopTimeEntryImpl

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);
}
Also used : ShapePoints(org.onebusaway.transit_data_federation.model.ShapePoints) StopTimeEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl) PointAndIndex(org.onebusaway.transit_data_federation.impl.shapes.PointAndIndex) DistanceAlongShapeLibrary(org.onebusaway.transit_data_federation.bundle.tasks.transit_graph.DistanceAlongShapeLibrary)

Example 32 with StopTimeEntryImpl

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

Aggregations

StopTimeEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopTimeEntryImpl)32 Test (org.junit.Test)15 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)14 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)12 PointAndIndex (org.onebusaway.transit_data_federation.impl.shapes.PointAndIndex)10 ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)10 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)9 StopTime (org.onebusaway.gtfs.model.StopTime)7 ArrayList (java.util.ArrayList)6 XYPoint (org.onebusaway.geospatial.model.XYPoint)6 Stop (org.onebusaway.gtfs.model.Stop)6 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)6 ShapePointsFactory (org.onebusaway.transit_data_federation.model.ShapePointsFactory)5 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)5 Agency (org.onebusaway.gtfs.model.Agency)4 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)4 Trip (org.onebusaway.gtfs.model.Trip)4 DistanceAlongShapeLibrary (org.onebusaway.transit_data_federation.bundle.tasks.transit_graph.DistanceAlongShapeLibrary)4 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)4 Date (java.util.Date)3