lots of new lines for JSON API

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@184 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-09-23 17:55:25 +00:00
parent 67d01e979c
commit a4a779673e
2 changed files with 224 additions and 81 deletions

View file

@ -753,7 +753,7 @@ public final class BahnProvider implements NetworkProvider
return "RSB" + number; return "RSB" + number;
if (type.equals("LT")) if (type.equals("LT"))
return "RLT" + number; return "RLT" + number;
if (type.equals("CB")) // http://www.railfan.de/nebahn/morac.html if (type.equals("CB")) // City Bahn Chemnitz
return "RCB" + number; return "RCB" + number;
if (type.equals("SWE")) // SWEG if (type.equals("SWE")) // SWEG
return "RSWE" + number; return "RSWE" + number;

View file

@ -473,7 +473,7 @@ public class OebbProvider implements NetworkProvider
uri.append("&time=").append(TIME_FORMAT.format(now)); uri.append("&time=").append(TIME_FORMAT.format(now));
uri.append("&productsFilter=111111111111"); uri.append("&productsFilter=111111111111");
uri.append("&additionalTime=0"); uri.append("&additionalTime=0");
uri.append("&maxJourneys=20"); uri.append("&maxJourneys=").append(maxDepartures != 0 ? maxDepartures : 20);
uri.append("&start=yes"); uri.append("&start=yes");
uri.append("&selectDate=today"); uri.append("&selectDate=today");
uri.append("&monitor=1"); uri.append("&monitor=1");
@ -484,11 +484,20 @@ public class OebbProvider implements NetworkProvider
return uri.toString(); return uri.toString();
} }
private static final Pattern P_DEPARTURES_ERROR = Pattern.compile("(Verbindung zum Server konnte leider nicht hergestellt werden)");
public QueryDeparturesResult queryDepartures(final String uri) throws IOException public QueryDeparturesResult queryDepartures(final String uri) throws IOException
{ {
// scrape page // scrape page
final String page = ParserUtils.scrape(uri).toString().substring(14); final String page = ParserUtils.scrape(uri).toString().substring(14);
final Matcher mError = P_DEPARTURES_ERROR.matcher(page);
if (mError.find())
{
if (mError.group(1) != null)
return new QueryDeparturesResult(uri, Status.SERVICE_DOWN);
}
try try
{ {
final JSONObject head = new JSONObject(page); final JSONObject head = new JSONObject(page);
@ -516,8 +525,6 @@ public class OebbProvider implements NetworkProvider
if (position != null) if (position != null)
position = "Gl. " + position; position = "Gl. " + position;
final boolean rt = head.optBoolean("rt", false); final boolean rt = head.optBoolean("rt", false);
if (rt == true)
System.out.println("Realtime!!");
final String lineLink = departure.optString("tinfoline"); final String lineLink = departure.optString("tinfoline");
departures.add(new Departure(!rt ? time : null, rt ? time : null, line, line != null ? LINES.get(line.charAt(0)) : null, departures.add(new Departure(!rt ? time : null, rt ? time : null, line, line != null ? LINES.get(line.charAt(0)) : null,
@ -534,7 +541,10 @@ public class OebbProvider implements NetworkProvider
} }
} }
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([A-Za-zÄÖÜäöüßáàâéèêíìîóòôúùû-]+)[\\s]*(.*)"); private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([A-Za-zÄÖÜäöüßáàâéèêíìîóòôúùû/-]+)[\\s]*(.*)");
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}");
private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("\\d{1,3}[A-Z]{2}");
private static final Pattern P_NORMALIZE_LINE_RUSSIA_INT = Pattern.compile("\\d{3}Y");
private static String normalizeLine(final String line) private static String normalizeLine(final String line)
{ {
@ -548,13 +558,24 @@ public class OebbProvider implements NetworkProvider
if (normalizedType != 0) if (normalizedType != 0)
return normalizedType + type + number; return normalizedType + type + number;
// return '?' + strippedLine;
throw new IllegalStateException("cannot normalize type " + type + " line " + line); throw new IllegalStateException("cannot normalize type " + type + " line " + line);
} }
else
{ if (line.length() == 0)
return "?";
if (P_NORMALIZE_LINE_RUSSIA.matcher(line).matches())
return "R" + line;
if (P_NORMALIZE_LINE_RUSSIA_INT.matcher(line).matches())
return "I" + line;
if (P_NORMALIZE_LINE_NUMBER.matcher(line).matches())
return "?" + line;
throw new IllegalStateException("cannot normalize line " + line); throw new IllegalStateException("cannot normalize line " + line);
} }
}
private static String normalizeLine(final String type, final String line) private static String normalizeLine(final String type, final String line)
{ {
@ -565,8 +586,7 @@ public class OebbProvider implements NetworkProvider
if (normalizedType != 0) if (normalizedType != 0)
return normalizedType + strippedLine; return normalizedType + strippedLine;
return '?' + strippedLine; throw new IllegalStateException("cannot normalize type " + type + " line " + line);
// throw new IllegalStateException("cannot normalize type " + type + " line " + line);
} }
private static char normalizeType(final String type) private static char normalizeType(final String type)
@ -585,48 +605,52 @@ public class OebbProvider implements NetworkProvider
return 'I'; return 'I';
// if (ucType.equals("X")) // Interconnex // if (ucType.equals("X")) // Interconnex
// return 'I'; // return 'I';
// if (ucType.equals("EN")) // EuroNight if (ucType.equals("EN")) // EuroNight
// return 'I'; return 'I';
// if (ucType.equals("CNL")) // CityNightLine if (ucType.equals("CNL")) // CityNightLine
// return 'I'; return 'I';
// if (ucType.equals("DNZ")) // Berlin-Saratov, Berlin-Moskva // if (ucType.equals("DNZ")) // Berlin-Saratov, Berlin-Moskva
// return 'I'; // return 'I';
// if (ucType.equals("INT")) // Rußland // if (ucType.equals("INT")) // Rußland
// return 'I'; // return 'I';
// if (ucType.equals("D")) // Rußland if (ucType.equals("D")) // Rußland
// return 'I'; return 'I';
// if (ucType.equals("RR")) // Finnland // if (ucType.equals("RR")) // Finnland
// return 'I'; // return 'I';
// if (ucType.equals("TLK")) // Tanie Linie Kolejowe, Polen if (ucType.equals("TLK")) // Tanie Linie Kolejowe, Polen
// return 'I'; return 'I';
// if (ucType.equals("EE")) // Rumänien // if (ucType.equals("EE")) // Rumänien
// return 'I'; // return 'I';
// if (ucType.equals("SC")) // SuperCity, Tschechien if (ucType.equals("SC")) // SuperCity, Tschechien
// return 'I'; return 'I';
// if (ucType.equals("RJ")) // RailJet, Österreichische Bundesbahnen if (ucType.equals("RJ")) // RailJet, Österreichische Bundesbahnen
// return 'I'; return 'I';
// if (ucType.equals("EST")) // Eurostar Frankreich if (ucType.equals("EST")) // Eurostar Frankreich
// return 'I'; return 'I';
// if (ucType.equals("ALS")) // Spanien if (ucType.equals("ALS")) // Spanien
// return 'I'; return 'I';
// if (ucType.equals("ARC")) // Spanien if (ucType.equals("ARC")) // Spanien
// return 'I'; return 'I';
// if (ucType.equals("TLG")) // Spanien, Madrid if (ucType.equals("TLG")) // Spanien, Madrid
// return 'I'; return 'I';
// if (ucType.equals("HOT")) // Spanien, Nacht if (ucType.equals("HOT")) // Spanien, Nacht
// return 'I'; return 'I';
// if (ucType.equals("AVE")) // Alta Velocidad Española, Spanien if (ucType.equals("AVE")) // Alta Velocidad Española, Spanien
// return 'I'; return 'I';
// if (ucType.equals("INZ")) // Schweden, Nacht // if (ucType.equals("INZ")) // Schweden, Nacht
// return 'I'; // return 'I';
if (ucType.equals("NZ")) // Schweden, Nacht, via JSON API
return 'I';
// if (ucType.equals("OZ")) // Schweden, Oeresundzug // if (ucType.equals("OZ")) // Schweden, Oeresundzug
// return 'I'; // return 'I';
// if (ucType.equals("X2")) // Schweden // if (ucType.equals("X2")) // Schweden
// return 'I'; // return 'I';
// if (ucType.equals("THA")) // Thalys if (ucType.equals("X")) // Schweden, via JSON API
// return 'I'; return 'I';
// if (ucType.equals("TGV")) // Train à Grande Vitesse if (ucType.equals("THA")) // Thalys
// return 'I'; return 'I';
if (ucType.equals("TGV")) // Train à Grande Vitesse
return 'I';
// if (ucType.equals("LYN")) // Dänemark // if (ucType.equals("LYN")) // Dänemark
// return 'I'; // return 'I';
if (ucType.equals("ARZ")) // Frankreich, Nacht if (ucType.equals("ARZ")) // Frankreich, Nacht
@ -656,8 +680,8 @@ public class OebbProvider implements NetworkProvider
return 'R'; return 'R';
// if (ucType.equals("ZUG")) // if (ucType.equals("ZUG"))
// return 'R'; // return 'R';
// if (ucType.equals("EZ")) // Erlebniszug if (ucType.equals("EZ")) // Erlebniszug
// return 'R'; return 'R';
// if (ucType.equals("S2")) // Helsinki-Turku // if (ucType.equals("S2")) // Helsinki-Turku
// return 'R'; // return 'R';
if (ucType.equals("RB")) // RegionalBahn Deutschland if (ucType.equals("RB")) // RegionalBahn Deutschland
@ -666,49 +690,157 @@ public class OebbProvider implements NetworkProvider
return 'R'; return 'R';
// if (ucType.equals("DPN")) // TODO nicht evtl. doch eher ne S-Bahn? // if (ucType.equals("DPN")) // TODO nicht evtl. doch eher ne S-Bahn?
// return 'R'; // return 'R';
// if (ucType.equals("VIA")) if (ucType.equals("BRB")) // ABELLIO Rail, via JSON API
// return 'R'; return 'R';
// if (ucType.equals("PCC")) // Polen if (ucType.equals("ABR")) // Bayerische Regiobahn, via JSON API
// return 'R'; return 'R';
// if (ucType.equals("KM")) // Polen if (ucType.equals("RTB")) // Rurtalbahn, via JSON API
// return 'R'; return 'R';
// if (ucType.equals("SKM")) // Polen if (ucType.equals("VIA"))
// return 'R'; return 'R';
// if (ucType.equals("SKW")) // Polen if (ucType.equals("PCC")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("WKD")) // Warszawska Kolej Dojazdowa, Polen if (ucType.equals("KM")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("IR")) // Polen if (ucType.equals("SKM")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("OS")) // Chop-Cierna nas Tisou if (ucType.equals("SKW")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("SP")) // Polen if (ucType.equals("WKD")) // Warszawska Kolej Dojazdowa, Polen
// return 'R'; return 'R';
// if (ucType.equals("EX")) // Polen if (ucType.equals("IR")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("E")) // Budapest, Ungarn if (ucType.equals("OS")) // Chop-Cierna nas Tisou
// return 'R'; return 'R';
// if (ucType.equals("IP")) // Ozd, Ungarn if (ucType.equals("SP")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("ZR")) // Bratislava, Slovakai if (ucType.equals("EX")) // Polen
// return 'R'; return 'R';
// if (ucType.equals("CAT")) // Stockholm-Arlanda, Arlanda Express if (ucType.equals("NEB")) // Kostrzyn-Berlin, via JSON API
// return 'R'; return 'R';
// if (ucType.equals("RT")) // Deutschland if (ucType.equals("E")) // Budapest, Ungarn
// return 'R'; return 'R';
// if (ucType.equals("IRE")) // Interregio Express if (ucType.equals("IP")) // Ozd, Ungarn
// return 'R'; return 'R';
if (ucType.equals("ZR")) // Bratislava, Slovakai
return 'R';
if (ucType.equals("CAT")) // Stockholm-Arlanda, Arlanda Express
return 'R';
if (ucType.equals("RT")) // Deutschland
return 'R';
if (ucType.equals("IRE")) // Interregio Express
return 'R';
// if (ucType.equals("N")) // Frankreich, Tours // if (ucType.equals("N")) // Frankreich, Tours
// return 'R'; // return 'R';
// if (ucType.equals("DPF")) // VX=Vogtland Express // if (ucType.equals("DPF")) // VX=Vogtland Express
// return 'R'; // return 'R';
if (ucType.equals("VBG")) // Vogtlandbahn, via JSON API
return 'R';
if (ucType.equals("SBE")) // Zittau-Seifhennersdorf, via JSON API
return 'R';
if (ucType.equals("UBB")) // Usedomer Bäderbahn, via JSON API
return 'R';
if (ucType.equals("HZL")) // Hohenzollerische Landesbahn, via JSON API
return 'R';
if (ucType.equals("ME")) // metronom Eisenbahngesellschaft, via JSON API
return 'R';
if (ucType.equals("MER")) // metronom regional, via JSON API
return 'R';
if (ucType.equals("PEG")) // Prignitzer Eisenbahn, via JSON API
return 'R';
if (ucType.equals("HLB")) // Hessische Landesbahn, via JSON API
return 'R';
if (ucType.equals("NWB")) // NordWestBahn, via JSON API
return 'R';
if (ucType.equals("VEN")) // Rhenus Veniro, via JSON API
return 'R';
if (ucType.equals("BOB")) // Bayerische Oberlandbahn, via JSON API
return 'R';
if (ucType.equals("SBB")) // Schweizerische Bundesbahnen, via JSON API
return 'R';
if (ucType.equals("ERB")) // eurobahn (Keolis Deutschland), via JSON API
return 'R';
if (ucType.equals("CAN")) // cantus Verkehrsgesellschaft, via JSON API
return 'R';
if (ucType.equals("ALX")) // Arriva-Länderbahn-Express, via JSON API
return 'R';
if (ucType.equals("VEC")) // vectus Verkehrsgesellschaft, via JSON API
return 'R';
if (ucType.equals("OSB")) // Ortenau-S-Bahn, via JSON API
return 'R';
if (ucType.equals("NOB")) // Nord-Ostsee-Bahn, via JSON API
return 'R';
if (ucType.equals("MRB")) // Mitteldeutsche Regiobahn, via JSON API
return 'R';
if (ucType.equals("WFB")) // Westfalenbahn, via JSON API
return 'R';
if (ucType.equals("ARR")) // Ostfriesland, via JSON API
return 'R';
if (ucType.equals("SHB")) // Schleswig-Holstein-Bahn, via JSON API
return 'R';
if (ucType.equals("BLB")) // Berchtesgadener Land Bahn, via JSON API
return 'R';
if (ucType.equals("AKN")) // AKN Eisenbahn AG, via JSON API
return 'R';
if (ucType.equals("EVB")) // Eisenbahnen und Verkehrsbetriebe Elbe-Weser, via JSON API
return 'R';
if (ucType.equals("EB")) // Erfurter Bahn, via JSON API
return 'R';
if (ucType.equals("HTB")) // Hörseltalbahn, via JSON API
return 'R';
if (ucType.equals("NBE")) // nordbahn, via JSON API
return 'R';
if (ucType.equals("DAB")) // Daadetalbahn, via JSON API
return 'R';
if (ucType.equals("HEX")) // Harz-Berlin-Express, Veolia, via JSON API
return 'R';
if (ucType.equals("WEG")) // Württembergische Eisenbahn-Gesellschaft, via JSON API
return 'R';
if (ucType.equals("RBG")) // Regental Bahnbetriebs GmbH, via JSON API
return 'R';
if (ucType.equals("OE")) // Ostdeutsche Eisenbahn, via JSON API
return 'R';
if (ucType.equals("CB")) // City Bahn Chemnitz, via JSON API
return 'R';
if (ucType.equals("MR")) // Märkische Regionalbahn, via JSON API
return 'R';
if (ucType.equals("OLA")) // Ostseeland Verkehr, via JSON API
return 'R';
if (ucType.equals("VX")) // Vogtland Express, via JSON API
return 'R';
if (ucType.equals("STB")) // Süd-Thüringen-Bahn, via JSON API
return 'R';
if (ucType.equals("RNV")) // Rhein-Neckar-Verkehr GmbH, via JSON API
return 'R';
if (ucType.equals("MBB")) // Mecklenburgische Bäderbahn Molli, via JSON API
return 'R';
if (ucType.equals("HSB")) // Harzer Schmalspurbahnen, via JSON API
return 'R';
if (ucType.equals("VE")) // Lutherstadt Wittenberg, via JSON API
return 'R';
if (ucType.equals("PRE")) // Pressnitztalbahn, via JSON API
return 'R';
if (ucType.equals("SDG")) // Sächsische Dampfeisenbahngesellschaft, via JSON API
return 'R';
if (ucType.equals("SOE")) // Sächsisch-Oberlausitzer Eisenbahngesellschaft, via JSON API
return 'R';
if (ucType.equals("FEG")) // Freiberger Eisenbahngesellschaft, via JSON API
return 'R';
if (ucType.equals("NEG")) // Norddeutsche Eisenbahngesellschaft Niebüll, via JSON API
return 'R';
if (ucType.equals("S")) if (ucType.equals("S"))
return 'S'; return 'S';
if (ucType.equals("RSB")) // Schnellbahn Wien if (ucType.equals("RSB")) // Schnellbahn Wien
return 'S'; return 'S';
// if (ucType.equals("RER")) // Réseau Express Régional, Frankreich if (ucType.equals("BSB")) // Breisgau S-Bahn, via JSON API
// return 'S'; return 'S';
if (ucType.equals("DPN")) // S3 Bad Reichenhall-Freilassing, via JSON API
return 'S';
if (ucType.equals("SWE")) // Südwestdeutsche Verkehrs-AG, Ortenau-S-Bahn, via JSON API
return 'S';
if (ucType.equals("RER")) // Réseau Express Régional, Frankreich
return 'S';
if (ucType.equals("U")) if (ucType.equals("U"))
return 'U'; return 'U';
@ -722,8 +854,8 @@ public class OebbProvider implements NetworkProvider
if (ucType.equals("BUS")) if (ucType.equals("BUS"))
return 'B'; return 'B';
// if (ucType.equals("RFB")) if (ucType.equals("RFB"))
// return 'B'; return 'B';
// if (ucType.equals("OBU")) // if (ucType.equals("OBU"))
// return 'B'; // return 'B';
if (ucType.equals("AST")) if (ucType.equals("AST"))
@ -740,6 +872,10 @@ public class OebbProvider implements NetworkProvider
// return 'B'; // return 'B';
if (ucType.equals("BUSSV")) // via JSON API if (ucType.equals("BUSSV")) // via JSON API
return 'B'; return 'B';
if (ucType.equals("BUSLEOBE")) // Rufbus, via JSON API
return 'B';
if (ucType.equals("BUSTN/TW")) // via JSON API
return 'B';
if (ucType.equals("O-B")) // Stadtbus, via JSON API if (ucType.equals("O-B")) // Stadtbus, via JSON API
return 'B'; return 'B';
@ -747,12 +883,19 @@ public class OebbProvider implements NetworkProvider
// return 'F'; // return 'F';
// if (ucType.equals("AS")) // SyltShuttle // if (ucType.equals("AS")) // SyltShuttle
// return 'F'; // return 'F';
// if (ucType.equals("SCHIFF")) // via JSON API
return 'F';
// if (ucType.equals("SB")) // if (ucType.equals("SB"))
// return 'C'; // return 'C';
// if (ucType.equals("LIF")) if (ucType.equals("LIF"))
// return 'C'; return 'C';
// if (ucType.equals("SEILBAHN")) // via JSON API
return 'C';
if (ucType.equals("FLUG")) // via JSON API
return 'I';
// if (ucType.equals("U70")) // U.K. // if (ucType.equals("U70")) // U.K.
// return '?'; // return '?';
// if (ucType.equals("R84")) // if (ucType.equals("R84"))