Package org.onebusaway.uk.network_rail.gtfs_realtime

Examples of org.onebusaway.uk.network_rail.gtfs_realtime.TimetableService


    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    TimetableService model = new TimetableService();
    model.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));

    Map<String, String> regionToStyle = new HashMap<String, String>();

    PrintWriter writer = new PrintWriter(new File(
        cli.getOptionValue(ARG_OUTPUT_PATH)));
    writer.println("region,style,stanox,tiploc,lat,lon,name");

    for (int stanox : model.getAllStanox()) {
      String stanoxValue = Integer.toString(stanox);
      if (stanoxValue.length() < 2) {
        System.out.println(stanox);
        continue;
      }
      String region = stanoxValue.substring(0, 2);
      String style = regionToStyle.get(region);
      if (style == null) {
        style = IconStyles.SMALL[regionToStyle.size() % IconStyles.SMALL.length];
        regionToStyle.put(region, style);
      }
      for (String tiploc : model.getTiplocsForStanox(stanox)) {
        StationElement station = model.getStationForTiploc(tiploc);
        if (station != null) {
          writer.println(region + "," + style + "," + stanox + "," + tiploc
              + "," + station.getLat() + "," + station.getLon() + ","
              + station.getName());
        }
View Full Code Here


    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    TimetableService model = new TimetableService();
    model.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));

    Map<String, String> regionToStyle = new HashMap<String, String>();

    PrintWriter writer = new PrintWriter(new File(
        cli.getOptionValue(ARG_OUTPUT_PATH)));
    writer.println("area,style,from,to,region,stanox,tiploc,lat,lon,name");

    BufferedReader reader = new BufferedReader(new FileReader(
        cli.getOptionValue(ARG_BERTH_MAPPING_PATH)));
    String line = null;
   
    Map<String,Pair<Range>> rangesByArea = new HashMap<String, Pair<Range>>();

    while ((line = reader.readLine()) != null) {
      String[] tokens = line.split(",");
      String area = tokens[0];
      String from = tokens[2];
      String to = tokens[3];
      String stanoxValue = tokens[4];
      if (stanoxValue.length() < 2) {
        System.out.println(stanoxValue);
        continue;
      }
      int stanox = Integer.parseInt(stanoxValue);
      String region = stanoxValue.substring(0, 2);

      String style = regionToStyle.get(area);

      if (style == null) {
        style = IconStyles.SMALL[regionToStyle.size() % IconStyles.SMALL.length];
        regionToStyle.put(area, style);
      }
     
      Pair<Range> ranges = rangesByArea.get(area);
      if (ranges == null) {
        ranges = Tuples.pair(new Range(), new Range());
        rangesByArea.put(area, ranges);
      }
      Range xRange = ranges.getFirst();
      Range yRange = ranges.getSecond();
       
      for (String tiploc : model.getTiplocsForStanox(stanox)) {
        StationElement station = model.getStationForTiploc(tiploc);
        if (station != null) {
          writer.println(area + "," + style + "," + from + "," + to + ","
              + region + "," + stanox + "," + tiploc + "," + station.getLat()
              + "," + station.getLon() + "," + station.getName());
          xRange.addValue(station.getEasting());
View Full Code Here

TOP

Related Classes of org.onebusaway.uk.network_rail.gtfs_realtime.TimetableService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.