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