Search in sources :

Example 1 with IStopTester

use of org.opentripplanner.graph_builder.module.stopsAlerts.IStopTester in project OpenTripPlanner by opentripplanner.

the class StopsAlerts method buildGraph.

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
    try {
        PrintWriter pw = new PrintWriter(new File(logFile));
        pw.printf("%s,%s,%s,%s\n", "stopId", "lon", "lat", "types");
        for (TransitStop ts : Iterables.filter(graph.getVertices(), TransitStop.class)) {
            StringBuilder types = new StringBuilder();
            for (IStopTester stopTester : stopTesters) {
                if (stopTester.fulfillDemands(ts, graph)) {
                    if (types.length() > 0)
                        types.append(";");
                    types.append(stopTester.getType());
                }
            }
            if (types.length() > 0) {
                pw.printf("%s,%f,%f,%s\n", ts.getStopId(), ts.getCoordinate().x, ts.getCoordinate().y, types.toString());
            }
        }
        pw.close();
    } catch (FileNotFoundException e) {
        LOG.error("Failed to write StopsAlerts log file", e);
    }
}
Also used : TransitStop(org.opentripplanner.routing.vertextype.TransitStop) FileNotFoundException(java.io.FileNotFoundException) IStopTester(org.opentripplanner.graph_builder.module.stopsAlerts.IStopTester) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 IStopTester (org.opentripplanner.graph_builder.module.stopsAlerts.IStopTester)1 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)1