Migrate from using char as a product type to Product enum. Line labels are really just the label and can be null.

This commit is contained in:
Andreas Schildbach 2015-01-31 11:48:41 +01:00
parent 7cb4e8fb06
commit 883015177e
52 changed files with 1216 additions and 1238 deletions

View file

@ -999,441 +999,441 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
private static final Pattern P_LINE_S_DB = Pattern.compile("(S\\d+) \\((?:DB Regio AG)\\)"); private static final Pattern P_LINE_S_DB = Pattern.compile("(S\\d+) \\((?:DB Regio AG)\\)");
private static final Pattern P_LINE_NUMBER = Pattern.compile("\\d+"); private static final Pattern P_LINE_NUMBER = Pattern.compile("\\d+");
protected String parseLine(final String mot, String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, String symbol, final String name, final String longName, final String trainType,
final String trainNum, final String trainName) final String trainNum, final String trainName)
{ {
if (mot == null) if (mot == null)
{ {
if (trainName != null) if (trainName != null)
{ {
final String str = name != null ? name : ""; final String str = Strings.nullToEmpty(name);
if (trainName.equals("S-Bahn")) if (trainName.equals("S-Bahn"))
return 'S' + str; return new Line(id, Product.SUBURBAN_TRAIN, str);
if (trainName.equals("U-Bahn")) if (trainName.equals("U-Bahn"))
return 'U' + str; return new Line(id, Product.SUBWAY, str);
if (trainName.equals("Straßenbahn")) if (trainName.equals("Straßenbahn"))
return 'T' + str; return new Line(id, Product.TRAM, str);
if (trainName.equals("Badner Bahn")) if (trainName.equals("Badner Bahn"))
return 'T' + str; return new Line(id, Product.TRAM, str);
if (trainName.equals("Stadtbus")) if (trainName.equals("Stadtbus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Citybus")) if (trainName.equals("Citybus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Regionalbus")) if (trainName.equals("Regionalbus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("ÖBB-Postbus")) if (trainName.equals("ÖBB-Postbus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Autobus")) if (trainName.equals("Autobus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Discobus")) if (trainName.equals("Discobus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Nachtbus")) if (trainName.equals("Nachtbus"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Anrufsammeltaxi")) if (trainName.equals("Anrufsammeltaxi"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Ersatzverkehr")) if (trainName.equals("Ersatzverkehr"))
return 'B' + str; return new Line(id, Product.BUS, str);
if (trainName.equals("Vienna Airport Lines")) if (trainName.equals("Vienna Airport Lines"))
return 'B' + str; return new Line(id, Product.BUS, str);
} }
} }
else if ("0".equals(mot)) else if ("0".equals(mot))
{ {
final String trainNumStr = trainNum != null ? trainNum : ""; final String trainNumStr = Strings.nullToEmpty(trainNum);
if (("EC".equals(trainType) || "EuroCity".equals(trainName) || "Eurocity".equals(trainName)) && trainNum != null) if (("EC".equals(trainType) || "EuroCity".equals(trainName) || "Eurocity".equals(trainName)) && trainNum != null)
return "IEC" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "EC" + trainNum);
if (("EN".equals(trainType) || "EuroNight".equals(trainName)) && trainNum != null) if (("EN".equals(trainType) || "EuroNight".equals(trainName)) && trainNum != null)
return "IEN" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "EN" + trainNum);
if (("IC".equals(trainType) || "InterCity".equals(trainName)) && trainNum != null) if (("IC".equals(trainType) || "InterCity".equals(trainName)) && trainNum != null)
return "IIC" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "IC" + trainNum);
if (("ICE".equals(trainType) || "ICE".equals(trainName) || "Intercity-Express".equals(trainName)) && trainNum != null) if (("ICE".equals(trainType) || "ICE".equals(trainName) || "Intercity-Express".equals(trainName)) && trainNum != null)
return "IICE" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "ICE" + trainNum);
if (("ICN".equals(trainType) || "InterCityNight".equals(trainName)) && trainNum != null) if (("ICN".equals(trainType) || "InterCityNight".equals(trainName)) && trainNum != null)
return "IICN" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "ICN" + trainNum);
if (("X".equals(trainType) || "InterConnex".equals(trainName)) && trainNum != null) if (("X".equals(trainType) || "InterConnex".equals(trainName)) && trainNum != null)
return "IX" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "X" + trainNum);
if (("CNL".equals(trainType) || "CityNightLine".equals(trainName)) && trainNum != null) // City Night Line if (("CNL".equals(trainType) || "CityNightLine".equals(trainName)) && trainNum != null) // City Night Line
return "ICNL" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "CNL" + trainNum);
if (("THA".equals(trainType) || "Thalys".equals(trainName)) && trainNum != null) if (("THA".equals(trainType) || "Thalys".equals(trainName)) && trainNum != null)
return "ITHA" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "THA" + trainNum);
if ("RHI".equals(trainType) && trainNum != null) if ("RHI".equals(trainType) && trainNum != null)
return "IRHI" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "RHI" + trainNum);
if (("TGV".equals(trainType) || "TGV".equals(trainName)) && trainNum != null) if (("TGV".equals(trainType) || "TGV".equals(trainName)) && trainNum != null)
return "ITGV" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "TGV" + trainNum);
if ("TGD".equals(trainType) && trainNum != null) if ("TGD".equals(trainType) && trainNum != null)
return "ITGD" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "TGD" + trainNum);
if ("INZ".equals(trainType) && trainNum != null) if ("INZ".equals(trainType) && trainNum != null)
return "IINZ" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "INZ" + trainNum);
if (("RJ".equals(trainType) || "railjet".equals(trainName)) && trainNum != null) // railjet if (("RJ".equals(trainType) || "railjet".equals(trainName)) && trainNum != null) // railjet
return "IRJ" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "RJ" + trainNum);
if (("WB".equals(trainType) || "WESTbahn".equals(trainName)) && trainNum != null) if (("WB".equals(trainType) || "WESTbahn".equals(trainName)) && trainNum != null)
return "IWB" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "WB" + trainNum);
if (("HKX".equals(trainType) || "Hamburg-Köln-Express".equals(trainName)) && trainNum != null) if (("HKX".equals(trainType) || "Hamburg-Köln-Express".equals(trainName)) && trainNum != null)
return "IHKX" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "HKX" + trainNum);
if ("INT".equals(trainType) && trainNum != null) // SVV, VAGFR if ("INT".equals(trainType) && trainNum != null) // SVV, VAGFR
return "IINT" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "INT" + trainNum);
if (("SC".equals(trainType) || "SC Pendolino".equals(trainName)) && trainNum != null) // SuperCity if (("SC".equals(trainType) || "SC Pendolino".equals(trainName)) && trainNum != null) // SuperCity
return "ISC" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "SC" + trainNum);
if ("ECB".equals(trainType) && trainNum != null) // EC, Verona-München if ("ECB".equals(trainType) && trainNum != null) // EC, Verona-München
return "IECB" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "ECB" + trainNum);
if ("ES".equals(trainType) && trainNum != null) // Eurostar Italia if ("ES".equals(trainType) && trainNum != null) // Eurostar Italia
return "IES" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "ES" + trainNum);
if (("EST".equals(trainType) || "EUROSTAR".equals(trainName)) && trainNum != null) if (("EST".equals(trainType) || "EUROSTAR".equals(trainName)) && trainNum != null)
return "IEST" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "EST" + trainNum);
if ("EIC".equals(trainType) && trainNum != null) // Ekspres InterCity, Polen if ("EIC".equals(trainType) && trainNum != null) // Ekspres InterCity, Polen
return "IEIC" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "EIC" + trainNum);
if ("MT".equals(trainType) && "Schnee-Express".equals(trainName) && trainNum != null) if ("MT".equals(trainType) && "Schnee-Express".equals(trainName) && trainNum != null)
return "IMT" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "MT" + trainNum);
if (("TLK".equals(trainType) || "Tanie Linie Kolejowe".equals(trainName)) && trainNum != null) if (("TLK".equals(trainType) || "Tanie Linie Kolejowe".equals(trainName)) && trainNum != null)
return "ITLK" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "TLK" + trainNum);
if ("Zug".equals(trainName)) if ("Zug".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("Zuglinie".equals(trainName)) if ("Zuglinie".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("IR".equals(trainType) || "Interregio".equals(trainName) || "InterRegio".equals(trainName)) if ("IR".equals(trainType) || "Interregio".equals(trainName) || "InterRegio".equals(trainName))
return "RIR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "IR" + trainNum);
if ("IRE".equals(trainType) || "Interregio-Express".equals(trainName)) if ("IRE".equals(trainType) || "Interregio-Express".equals(trainName))
return "RIRE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "IRE" + trainNum);
if ("InterRegioExpress".equals(trainName)) if ("InterRegioExpress".equals(trainName))
return "RIRE" + trainNumStr; return new Line(id, Product.REGIONAL_TRAIN, "IRE" + trainNumStr);
if ("RE".equals(trainType) || "Regional-Express".equals(trainName)) if ("RE".equals(trainType) || "Regional-Express".equals(trainName))
return "RRE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "RE" + trainNum);
if (trainType == null && trainNum != null && P_LINE_RE.matcher(trainNum).matches()) if (trainType == null && trainNum != null && P_LINE_RE.matcher(trainNum).matches())
return 'R' + trainNum; return new Line(id, Product.REGIONAL_TRAIN, trainNum);
if ("Regionalexpress".equals(trainName)) if ("Regionalexpress".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("R-Bahn".equals(trainName)) if ("R-Bahn".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("RB-Bahn".equals(trainName)) if ("RB-Bahn".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("RE-Bahn".equals(trainName)) if ("RE-Bahn".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("REX".equals(trainType)) // RegionalExpress, Österreich if ("REX".equals(trainType)) // RegionalExpress, Österreich
return "RREX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "REX" + trainNum);
if (("RB".equals(trainType) || "Regionalbahn".equals(trainName)) && trainNum != null) if (("RB".equals(trainType) || "Regionalbahn".equals(trainName)) && trainNum != null)
return "RRB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "RB" + trainNum);
if (trainType == null && trainNum != null && P_LINE_RB.matcher(trainNum).matches()) if (trainType == null && trainNum != null && P_LINE_RB.matcher(trainNum).matches())
return 'R' + trainNum; return new Line(id, Product.REGIONAL_TRAIN, trainNum);
if ("Abellio-Zug".equals(trainName)) if ("Abellio-Zug".equals(trainName))
return "R" + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("Westfalenbahn".equals(trainName)) if ("Westfalenbahn".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("Chiemseebahn".equals(trainName)) if ("Chiemseebahn".equals(trainName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("R".equals(trainType) || "Regionalzug".equals(trainName)) if ("R".equals(trainType) || "Regionalzug".equals(trainName))
return "RR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "R" + trainNum);
if (trainType == null && trainNum != null && P_LINE_R.matcher(trainNum).matches()) if (trainType == null && trainNum != null && P_LINE_R.matcher(trainNum).matches())
return 'R' + trainNum; return new Line(id, Product.REGIONAL_TRAIN, trainNum);
if ("D".equals(trainType) || "Schnellzug".equals(trainName)) if ("D".equals(trainType) || "Schnellzug".equals(trainName))
return "RD" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "D" + trainNum);
if ("E".equals(trainType) || "Eilzug".equals(trainName)) if ("E".equals(trainType) || "Eilzug".equals(trainName))
return "RE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "E" + trainNum);
if ("WFB".equals(trainType) || "WestfalenBahn".equals(trainName)) if ("WFB".equals(trainType) || "WestfalenBahn".equals(trainName))
return "RWFB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "WFB" + trainNum);
if (("NWB".equals(trainType) || "NordWestBahn".equals(trainName)) && trainNum != null) if (("NWB".equals(trainType) || "NordWestBahn".equals(trainName)) && trainNum != null)
return "RNWB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "NWB" + trainNum);
if ("WES".equals(trainType) || "Westbahn".equals(trainName)) if ("WES".equals(trainType) || "Westbahn".equals(trainName))
return "RWES" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "WES" + trainNum);
if ("ERB".equals(trainType) || "eurobahn".equals(trainName)) if ("ERB".equals(trainType) || "eurobahn".equals(trainName))
return "RERB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ERB" + trainNum);
if ("CAN".equals(trainType) || "cantus Verkehrsgesellschaft".equals(trainName)) if ("CAN".equals(trainType) || "cantus Verkehrsgesellschaft".equals(trainName))
return "RCAN" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "CAN" + trainNum);
if ("HEX".equals(trainType) || "Veolia Verkehr Sachsen-Anhalt".equals(trainName)) if ("HEX".equals(trainType) || "Veolia Verkehr Sachsen-Anhalt".equals(trainName))
return "RHEX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "HEX" + trainNum);
if ("EB".equals(trainType) || "Erfurter Bahn".equals(trainName)) if ("EB".equals(trainType) || "Erfurter Bahn".equals(trainName))
return "REB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "EB" + trainNum);
if ("Erfurter Bahn".equals(longName)) if ("Erfurter Bahn".equals(longName))
return "REB"; return new Line(id, Product.REGIONAL_TRAIN, "EB");
if ("EBx".equals(trainType) || "Erfurter Bahn Express".equals(trainName)) if ("EBx".equals(trainType) || "Erfurter Bahn Express".equals(trainName))
return "REBx" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "EBx" + trainNum);
if ("Erfurter Bahn Express".equals(longName)) if ("Erfurter Bahn Express".equals(longName))
return "REBx"; return new Line(id, Product.REGIONAL_TRAIN, "EBx");
if ("MRB".equals(trainType) || "Mitteldeutsche Regiobahn".equals(trainName)) if ("MRB".equals(trainType) || "Mitteldeutsche Regiobahn".equals(trainName))
return "RMRB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MRB" + trainNum);
if ("ABR".equals(trainType) || "ABELLIO Rail NRW GmbH".equals(trainName)) if ("ABR".equals(trainType) || "ABELLIO Rail NRW GmbH".equals(trainName))
return "RABR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ABR" + trainNum);
if ("NEB".equals(trainType) || "NEB Niederbarnimer Eisenbahn".equals(trainName)) if ("NEB".equals(trainType) || "NEB Niederbarnimer Eisenbahn".equals(trainName))
return "RNEB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "NEB" + trainNum);
if ("OE".equals(trainType) || "Ostdeutsche Eisenbahn GmbH".equals(trainName)) if ("OE".equals(trainType) || "Ostdeutsche Eisenbahn GmbH".equals(trainName))
return "ROE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "OE" + trainNum);
if ("ODE".equals(trainType)) if ("ODE".equals(trainType))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("OLA".equals(trainType) || "Ostseeland Verkehr GmbH".equals(trainName)) if ("OLA".equals(trainType) || "Ostseeland Verkehr GmbH".equals(trainName))
return "ROLA" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "OLA" + trainNum);
if ("UBB".equals(trainType) || "Usedomer Bäderbahn".equals(trainName)) if ("UBB".equals(trainType) || "Usedomer Bäderbahn".equals(trainName))
return "RUBB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "UBB" + trainNum);
if ("EVB".equals(trainType) || "ELBE-WESER GmbH".equals(trainName)) if ("EVB".equals(trainType) || "ELBE-WESER GmbH".equals(trainName))
return "REVB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "EVB" + trainNum);
if ("RTB".equals(trainType) || "Rurtalbahn GmbH".equals(trainName)) if ("RTB".equals(trainType) || "Rurtalbahn GmbH".equals(trainName))
return "RRTB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "RTB" + trainNum);
if ("STB".equals(trainType) || "Süd-Thüringen-Bahn".equals(trainName)) if ("STB".equals(trainType) || "Süd-Thüringen-Bahn".equals(trainName))
return "RSTB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "STB" + trainNum);
if ("HTB".equals(trainType) || "Hellertalbahn".equals(trainName)) if ("HTB".equals(trainType) || "Hellertalbahn".equals(trainName))
return "RHTB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "HTB" + trainNum);
if ("VBG".equals(trainType) || "Vogtlandbahn".equals(trainName)) if ("VBG".equals(trainType) || "Vogtlandbahn".equals(trainName))
return "RVBG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "VBG" + trainNum);
if ("CB".equals(trainType) || "City-Bahn Chemnitz".equals(trainName)) if ("CB".equals(trainType) || "City-Bahn Chemnitz".equals(trainName))
return "RCB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "CB" + trainNum);
if ("VEC".equals(trainType) || "vectus Verkehrsgesellschaft".equals(trainName)) if ("VEC".equals(trainType) || "vectus Verkehrsgesellschaft".equals(trainName))
return "RVEC" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "VEC" + trainNum);
if ("HzL".equals(trainType) || "Hohenzollerische Landesbahn AG".equals(trainName)) if ("HzL".equals(trainType) || "Hohenzollerische Landesbahn AG".equals(trainName))
return "RHzL" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "HzL" + trainNum);
if ("SBB".equals(trainType) || "SBB GmbH".equals(trainName)) if ("SBB".equals(trainType) || "SBB GmbH".equals(trainName))
return "RSBB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SBB" + trainNum);
if ("MBB".equals(trainType) || "Mecklenburgische Bäderbahn Molli".equals(trainName)) if ("MBB".equals(trainType) || "Mecklenburgische Bäderbahn Molli".equals(trainName))
return "RMBB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MBB" + trainNum);
if ("OS".equals(trainType)) // Osobní vlak if ("OS".equals(trainType)) // Osobní vlak
return "ROS" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "OS" + trainNum);
if ("SP".equals(trainType) || "Sp".equals(trainType)) // Spěšný vlak if ("SP".equals(trainType) || "Sp".equals(trainType)) // Spěšný vlak
return "RSP" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SP" + trainNum);
if ("Dab".equals(trainType) || "Daadetalbahn".equals(trainName)) if ("Dab".equals(trainType) || "Daadetalbahn".equals(trainName))
return "RDab" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "Dab" + trainNum);
if ("FEG".equals(trainType) || "Freiberger Eisenbahngesellschaft".equals(trainName)) if ("FEG".equals(trainType) || "Freiberger Eisenbahngesellschaft".equals(trainName))
return "RFEG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "FEG" + trainNum);
if ("ARR".equals(trainType) || "ARRIVA".equals(trainName)) if ("ARR".equals(trainType) || "ARRIVA".equals(trainName))
return "RARR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ARR" + trainNum);
if ("HSB".equals(trainType) || "Harzer Schmalspurbahn".equals(trainName)) if ("HSB".equals(trainType) || "Harzer Schmalspurbahn".equals(trainName))
return "RHSB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "HSB" + trainNum);
if ("ALX".equals(trainType) || "alex - Länderbahn und Vogtlandbahn GmbH".equals(trainName)) if ("ALX".equals(trainType) || "alex - Länderbahn und Vogtlandbahn GmbH".equals(trainName))
return "RALX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ALX" + trainNum);
if ("EX".equals(trainType) || "Fatra".equals(trainName)) if ("EX".equals(trainType) || "Fatra".equals(trainName))
return "REX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "EX" + trainNum);
if ("ME".equals(trainType) || "metronom".equals(trainName)) if ("ME".equals(trainType) || "metronom".equals(trainName))
return "RME" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ME" + trainNum);
if ("metronom".equals(longName)) if ("metronom".equals(longName))
return "RME"; return new Line(id, Product.REGIONAL_TRAIN, "ME");
if ("MEr".equals(trainType)) if ("MEr".equals(trainType))
return "RMEr" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MEr" + trainNum);
if ("AKN".equals(trainType) || "AKN Eisenbahn AG".equals(trainName)) if ("AKN".equals(trainType) || "AKN Eisenbahn AG".equals(trainName))
return "RAKN" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "AKN" + trainNum);
if ("SOE".equals(trainType) || "Sächsisch-Oberlausitzer Eisenbahngesellschaft".equals(trainName)) if ("SOE".equals(trainType) || "Sächsisch-Oberlausitzer Eisenbahngesellschaft".equals(trainName))
return "RSOE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SOE" + trainNum);
if ("VIA".equals(trainType) || "VIAS GmbH".equals(trainName)) if ("VIA".equals(trainType) || "VIAS GmbH".equals(trainName))
return "RVIA" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "VIA" + trainNum);
if ("BRB".equals(trainType) || "Bayerische Regiobahn".equals(trainName)) if ("BRB".equals(trainType) || "Bayerische Regiobahn".equals(trainName))
return "RBRB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BRB" + trainNum);
if ("BLB".equals(trainType) || "Berchtesgadener Land Bahn".equals(trainName)) if ("BLB".equals(trainType) || "Berchtesgadener Land Bahn".equals(trainName))
return "RBLB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BLB" + trainNum);
if ("HLB".equals(trainType) || "Hessische Landesbahn".equals(trainName)) if ("HLB".equals(trainType) || "Hessische Landesbahn".equals(trainName))
return "RHLB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "HLB" + trainNum);
if ("NOB".equals(trainType) || "NordOstseeBahn".equals(trainName)) if ("NOB".equals(trainType) || "NordOstseeBahn".equals(trainName))
return "RNOB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "NOB" + trainNum);
if ("NBE".equals(trainType) || "Nordbahn Eisenbahngesellschaft".equals(trainName)) if ("NBE".equals(trainType) || "Nordbahn Eisenbahngesellschaft".equals(trainName))
return "RNBE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "NBE" + trainNum);
if ("VEN".equals(trainType) || "Rhenus Veniro".equals(trainName)) if ("VEN".equals(trainType) || "Rhenus Veniro".equals(trainName))
return "RVEN" + trainType; return new Line(id, Product.REGIONAL_TRAIN, "VEN" + trainType);
if ("DPN".equals(trainType) || "Nahreisezug".equals(trainName)) if ("DPN".equals(trainType) || "Nahreisezug".equals(trainName))
return "RDPN" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "DPN" + trainNum);
if ("RBG".equals(trainType) || "Regental Bahnbetriebs GmbH".equals(trainName)) if ("RBG".equals(trainType) || "Regental Bahnbetriebs GmbH".equals(trainName))
return "RRBG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "RBG" + trainNum);
if ("BOB".equals(trainType) || "Bodensee-Oberschwaben-Bahn".equals(trainName)) if ("BOB".equals(trainType) || "Bodensee-Oberschwaben-Bahn".equals(trainName))
return "RBOB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BOB" + trainNum);
if ("VE".equals(trainType) || "Vetter".equals(trainName)) if ("VE".equals(trainType) || "Vetter".equals(trainName))
return "RVE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "VE" + trainNum);
if ("SDG".equals(trainType) || "SDG Sächsische Dampfeisenbahngesellschaft mbH".equals(trainName)) if ("SDG".equals(trainType) || "SDG Sächsische Dampfeisenbahngesellschaft mbH".equals(trainName))
return "RSDG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SDG" + trainNum);
if ("PRE".equals(trainType) || "Pressnitztalbahn".equals(trainName)) if ("PRE".equals(trainType) || "Pressnitztalbahn".equals(trainName))
return "RPRE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "PRE" + trainNum);
if ("VEB".equals(trainType) || "Vulkan-Eifel-Bahn".equals(trainName)) if ("VEB".equals(trainType) || "Vulkan-Eifel-Bahn".equals(trainName))
return "RVEB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "VEB" + trainNum);
if ("neg".equals(trainType) || "Norddeutsche Eisenbahn Gesellschaft".equals(trainName)) if ("neg".equals(trainType) || "Norddeutsche Eisenbahn Gesellschaft".equals(trainName))
return "Rneg" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "neg" + trainNum);
if ("AVG".equals(trainType) || "Felsenland-Express".equals(trainName)) if ("AVG".equals(trainType) || "Felsenland-Express".equals(trainName))
return "RAVG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "AVG" + trainNum);
if ("P".equals(trainType) || "BayernBahn Betriebs-GmbH".equals(trainName) || "Brohltalbahn".equals(trainName) if ("P".equals(trainType) || "BayernBahn Betriebs-GmbH".equals(trainName) || "Brohltalbahn".equals(trainName)
|| "Kasbachtalbahn".equals(trainName)) || "Kasbachtalbahn".equals(trainName))
return "RP" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "P" + trainNum);
if ("SBS".equals(trainType) || "Städtebahn Sachsen".equals(trainName)) if ("SBS".equals(trainType) || "Städtebahn Sachsen".equals(trainName))
return "RSBS" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SBS" + trainNum);
if ("SES".equals(trainType) || "Städteexpress Sachsen".equals(trainName)) if ("SES".equals(trainType) || "Städteexpress Sachsen".equals(trainName))
return "RSES" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SES" + trainNum);
if ("SB-".equals(trainType)) // Städtebahn Sachsen if ("SB-".equals(trainType)) // Städtebahn Sachsen
return "RSB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SB" + trainNum);
if ("ag".equals(trainType)) // agilis if ("ag".equals(trainType)) // agilis
return "Rag" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ag" + trainNum);
if ("agi".equals(trainType) || "agilis".equals(trainName)) if ("agi".equals(trainType) || "agilis".equals(trainName))
return "Ragi" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "agi" + trainNum);
if ("as".equals(trainType) || "agilis-Schnellzug".equals(trainName)) if ("as".equals(trainType) || "agilis-Schnellzug".equals(trainName))
return "Ras" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "as" + trainNum);
if ("TLX".equals(trainType) || "TRILEX".equals(trainName)) // Trilex (Vogtlandbahn) if ("TLX".equals(trainType) || "TRILEX".equals(trainName)) // Trilex (Vogtlandbahn)
return "RTLX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TLX" + trainNum);
if ("MSB".equals(trainType) || "Mainschleifenbahn".equals(trainName)) if ("MSB".equals(trainType) || "Mainschleifenbahn".equals(trainName))
return "RMSB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MSB" + trainNum);
if ("BE".equals(trainType) || "Bentheimer Eisenbahn".equals(trainName)) if ("BE".equals(trainType) || "Bentheimer Eisenbahn".equals(trainName))
return "RBE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BE" + trainNum);
if ("erx".equals(trainType) || "erixx - Der Heidesprinter".equals(trainName)) if ("erx".equals(trainType) || "erixx - Der Heidesprinter".equals(trainName))
return "Rerx" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "erx" + trainNum);
if ("SWEG-Zug".equals(trainName)) // Südwestdeutschen Verkehrs-Aktiengesellschaft if ("SWEG-Zug".equals(trainName)) // Südwestdeutschen Verkehrs-Aktiengesellschaft
return "RSWEG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SWEG" + trainNum);
if ("SWEG-Zug".equals(longName)) if ("SWEG-Zug".equals(longName))
return "RSWEG"; return new Line(id, Product.REGIONAL_TRAIN, "SWEG");
if ("EGP Eisenbahngesellschaft Potsdam".equals(trainName)) if ("EGP Eisenbahngesellschaft Potsdam".equals(trainName))
return "REGP" + trainNumStr; return new Line(id, Product.REGIONAL_TRAIN, "EGP" + trainNumStr);
if ("ÖBB".equals(trainType) || "ÖBB".equals(trainName)) if ("ÖBB".equals(trainType) || "ÖBB".equals(trainName))
return "RÖBB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ÖBB" + trainNum);
if ("CAT".equals(trainType)) // City Airport Train Wien if ("CAT".equals(trainType)) // City Airport Train Wien
return "RCAT" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "CAT" + trainNum);
if ("DZ".equals(trainType) || "Dampfzug".equals(trainName)) if ("DZ".equals(trainType) || "Dampfzug".equals(trainName))
return "RDZ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "DZ" + trainNum);
if ("CD".equals(trainType)) // Tschechien if ("CD".equals(trainType)) // Tschechien
return "RCD" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "CD" + trainNum);
if ("VR".equals(trainType)) // Polen if ("VR".equals(trainType)) // Polen
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("PR".equals(trainType)) // Polen if ("PR".equals(trainType)) // Polen
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("KD".equals(trainType)) // Koleje Dolnośląskie (Niederschlesische Eisenbahn) if ("KD".equals(trainType)) // Koleje Dolnośląskie (Niederschlesische Eisenbahn)
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("Koleje Dolnoslaskie".equals(trainName) && symbol != null) // Koleje Dolnośląskie if ("Koleje Dolnoslaskie".equals(trainName) && symbol != null) // Koleje Dolnośląskie
return "R" + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("OO".equals(trainType) || "Ordinary passenger (o.pas.)".equals(trainName)) // GB if ("OO".equals(trainType) || "Ordinary passenger (o.pas.)".equals(trainName)) // GB
return "ROO" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "OO" + trainNum);
if ("XX".equals(trainType) || "Express passenger (ex.pas.)".equals(trainName)) // GB if ("XX".equals(trainType) || "Express passenger (ex.pas.)".equals(trainName)) // GB
return "RXX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "XX" + trainNum);
if ("XZ".equals(trainType) || "Express passenger sleeper".equals(trainName)) // GB if ("XZ".equals(trainType) || "Express passenger sleeper".equals(trainName)) // GB
return "RXZ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "XZ" + trainNum);
if ("ATB".equals(trainType)) // Autoschleuse Tauernbahn if ("ATB".equals(trainType)) // Autoschleuse Tauernbahn
return "RATB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ATB" + trainNum);
if ("ATZ".equals(trainType)) // Autozug if ("ATZ".equals(trainType)) // Autozug
return "RATZ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ATZ" + trainNum);
if ("AZ".equals(trainType) || "Auto-Zug".equals(trainName)) if ("AZ".equals(trainType) || "Auto-Zug".equals(trainName))
return "RAZ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "AZ" + trainNum);
if ("DWE".equals(trainType) || "Dessau-Wörlitzer Eisenbahn".equals(trainName)) if ("DWE".equals(trainType) || "Dessau-Wörlitzer Eisenbahn".equals(trainName))
return "RDWE" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "DWE" + trainNum);
if ("KTB".equals(trainType) || "Kandertalbahn".equals(trainName)) if ("KTB".equals(trainType) || "Kandertalbahn".equals(trainName))
return "RKTB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "KTB" + trainNum);
if ("CBC".equals(trainType) || "CBC".equals(trainName)) // City-Bahn Chemnitz if ("CBC".equals(trainType) || "CBC".equals(trainName)) // City-Bahn Chemnitz
return "RCBC" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "CBC" + trainNum);
if ("Bernina Express".equals(trainName)) if ("Bernina Express".equals(trainName))
return 'R' + trainNum; return new Line(id, Product.REGIONAL_TRAIN, trainNum);
if ("STR".equals(trainType)) // Harzquerbahn, Nordhausen if ("STR".equals(trainType)) // Harzquerbahn, Nordhausen
return "RSTR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "STR" + trainNum);
if ("EXT".equals(trainType) || "Extrazug".equals(trainName)) if ("EXT".equals(trainType) || "Extrazug".equals(trainName))
return "REXT" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "EXT" + trainNum);
if ("Heritage Railway".equals(trainName)) // GB if ("Heritage Railway".equals(trainName)) // GB
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("WTB".equals(trainType) || "Wutachtalbahn".equals(trainName)) if ("WTB".equals(trainType) || "Wutachtalbahn".equals(trainName))
return "RWTB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "WTB" + trainNum);
if ("DB".equals(trainType) || "DB Regio".equals(trainName)) if ("DB".equals(trainType) || "DB Regio".equals(trainName))
return "RDB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "DB" + trainNum);
if ("M".equals(trainType) && "Meridian".equals(trainName)) if ("M".equals(trainType) && "Meridian".equals(trainName))
return "RM" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "M" + trainNum);
if ("M".equals(trainType) && "Messezug".equals(trainName)) if ("M".equals(trainType) && "Messezug".equals(trainName))
return "RM" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "M" + trainNum);
if ("EZ".equals(trainType)) // ÖBB Erlebniszug if ("EZ".equals(trainType)) // ÖBB Erlebniszug
return "REZ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "EZ" + trainNum);
if ("DPF".equals(trainType)) if ("DPF".equals(trainType))
return "RDPF" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "DPF" + trainNum);
if ("WBA".equals(trainType) || "Waldbahn".equals(trainName)) if ("WBA".equals(trainType) || "Waldbahn".equals(trainName))
return "RWBA" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "WBA" + trainNum);
if ("ÖBA".equals(trainType) && trainNum != null) // Eisenbahn-Betriebsgesellschaft Ochsenhausen if ("ÖBA".equals(trainType) && trainNum != null) // Eisenbahn-Betriebsgesellschaft Ochsenhausen
return "RÖBA" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ÖBA" + trainNum);
if (("UEF".equals(trainType) || "Ulmer Eisenbahnfreunde".equals(trainName)) && trainNum != null) if (("UEF".equals(trainType) || "Ulmer Eisenbahnfreunde".equals(trainName)) && trainNum != null)
return "RUEF" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "UEF" + trainNum);
if (("DBG".equals(trainType) || "Döllnitzbahn".equals(trainName)) && trainNum != null) if (("DBG".equals(trainType) || "Döllnitzbahn".equals(trainName)) && trainNum != null)
return "RDBG" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "DBG" + trainNum);
if (("TL".equals(trainType) || "Trilex".equals(trainName)) && trainNum != null) if (("TL".equals(trainType) || "Trilex".equals(trainName)) && trainNum != null)
return "RTL" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TL" + trainNum);
if (("OPB".equals(trainType) || "oberpfalzbahn".equals(trainName)) && trainNum != null) if (("OPB".equals(trainType) || "oberpfalzbahn".equals(trainName)) && trainNum != null)
return "ROPB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "OPB" + trainNum);
if (("OPX".equals(trainType) || "oberpfalz-express".equals(trainName)) && trainNum != null) if (("OPX".equals(trainType) || "oberpfalz-express".equals(trainName)) && trainNum != null)
return "ROPX" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "OPX" + trainNum);
if (("V6".equals(trainType) || "vlexx".equals(trainName)) && trainNum != null) if (("V6".equals(trainType) || "vlexx".equals(trainName)) && trainNum != null)
return "Rvlexx" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "vlexx" + trainNum);
if (("ARZ".equals(trainType) || "Autoreisezug".equals(trainName)) && trainNum != null) if (("ARZ".equals(trainType) || "Autoreisezug".equals(trainName)) && trainNum != null)
return "RARZ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ARZ" + trainNum);
if ("BSB-Zug".equals(trainName) && trainNum != null) // Breisgau-S-Bahn if ("BSB-Zug".equals(trainName) && trainNum != null) // Breisgau-S-Bahn
return 'S' + trainNum; return new Line(id, Product.SUBURBAN_TRAIN, trainNum);
if ("BSB-Zug".equals(trainName) && trainNum == null) if ("BSB-Zug".equals(trainName) && trainNum == null)
return "SBSB"; return new Line(id, Product.SUBURBAN_TRAIN, "BSB");
if ("BSB-Zug".equals(longName)) if ("BSB-Zug".equals(longName))
return "SBSB"; return new Line(id, Product.SUBURBAN_TRAIN, "BSB");
if ("RSB".equals(trainType)) // Regionalschnellbahn, Wien if ("RSB".equals(trainType)) // Regionalschnellbahn, Wien
return "SRSB" + trainNum; return new Line(id, Product.SUBURBAN_TRAIN, "RSB" + trainNum);
if ("RER".equals(trainName) && symbol != null && symbol.length() == 1) // Réseau Express Régional, if ("RER".equals(trainName) && symbol != null && symbol.length() == 1) // Réseau Express Régional,
// Frankreich // Frankreich
return 'S' + symbol; return new Line(id, Product.SUBURBAN_TRAIN, symbol);
if ("S".equals(trainType)) if ("S".equals(trainType))
return "SS" + trainNum; return new Line(id, Product.SUBURBAN_TRAIN, "S" + trainNum);
if ("S-Bahn".equals(trainName)) if ("S-Bahn".equals(trainName))
return "SS" + trainNumStr; return new Line(id, Product.SUBURBAN_TRAIN, "S" + trainNumStr);
if ("RT".equals(trainType) || "RegioTram".equals(trainName)) if ("RT".equals(trainType) || "RegioTram".equals(trainName))
return "TRT" + trainNum; return new Line(id, Product.TRAM, "RT" + trainNum);
if ("Bus".equals(trainType)) if ("Bus".equals(trainType))
return "B" + trainNum; return new Line(id, Product.BUS, "" + trainNum);
if ("SEV".equals(trainType) || "SEV".equals(trainNum) || "SEV".equals(trainName) || "SEV".equals(symbol) || "BSV".equals(trainType) if ("SEV".equals(trainType) || "SEV".equals(trainNum) || "SEV".equals(trainName) || "SEV".equals(symbol) || "BSV".equals(trainType)
|| "Ersatzverkehr".equals(trainName) || "Schienenersatzverkehr".equals(trainName)) || "Ersatzverkehr".equals(trainName) || "Schienenersatzverkehr".equals(trainName))
return "BSEV" + (trainNum != null ? trainNum : ""); return new Line(id, Product.BUS, "SEV" + trainNumStr);
if ("Bus replacement".equals(trainName)) // GB if ("Bus replacement".equals(trainName)) // GB
return "BBR"; return new Line(id, Product.BUS, "BR");
if ("BR".equals(trainType) && trainName.startsWith("Bus")) // GB if ("BR".equals(trainType) && trainName.startsWith("Bus")) // GB
return "BBR" + trainNum; return new Line(id, Product.BUS, "BR" + trainNum);
if ("GB".equals(trainType)) // Gondelbahn if ("GB".equals(trainType)) // Gondelbahn
return "CGB" + trainNum; return new Line(id, Product.CABLECAR, "GB" + trainNum);
if ("SB".equals(trainType)) // Seilbahn if ("SB".equals(trainType)) // Seilbahn
return "CSB" + trainNum; return new Line(id, Product.SUBURBAN_TRAIN, "SB" + trainNum);
if ("ZUG".equals(trainType) && trainNum != null) if ("ZUG".equals(trainType) && trainNum != null)
return '?' + trainNum; return new Line(id, null, trainNum);
if (symbol != null && P_LINE_NUMBER.matcher(symbol).matches() && trainType == null && trainName == null) if (symbol != null && P_LINE_NUMBER.matcher(symbol).matches() && trainType == null && trainName == null)
return '?' + symbol; return new Line(id, null, symbol);
if ("N".equals(trainType) && trainName == null && symbol == null) if ("N".equals(trainType) && trainName == null && symbol == null)
return "?N" + trainNum; return new Line(id, null, "N" + trainNum);
if ("Train".equals(trainName)) if ("Train".equals(trainName))
return "?"; return new Line(id, null, null);
// generic // generic
if (trainName != null && trainType == null && trainNum == null) if (trainName != null && trainType == null && trainNum == null)
return '?' + trainName; return new Line(id, null, trainName);
} }
else if ("1".equals(mot)) else if ("1".equals(mot))
{ {
if (symbol != null && P_LINE_S.matcher(symbol).matches()) if (symbol != null && P_LINE_S.matcher(symbol).matches())
return "S" + symbol; return new Line(id, Product.SUBURBAN_TRAIN, symbol);
if (name != null && P_LINE_S.matcher(name).matches()) if (name != null && P_LINE_S.matcher(name).matches())
return "S" + name; return new Line(id, Product.SUBURBAN_TRAIN, name);
if ("S-Bahn".equals(trainName)) if ("S-Bahn".equals(trainName))
return "SS" + Strings.nullToEmpty(trainNum); return new Line(id, Product.SUBURBAN_TRAIN, "S" + Strings.nullToEmpty(trainNum));
if ("S5X".equals(symbol)) if ("S5X".equals(symbol))
return "SS5X"; return new Line(id, Product.SUBURBAN_TRAIN, "S5X");
if (symbol != null && symbol.equals(name)) if (symbol != null && symbol.equals(name))
{ {
final Matcher m = P_LINE_S_DB.matcher(symbol); final Matcher m = P_LINE_S_DB.matcher(symbol);
if (m.matches()) if (m.matches())
return "S" + m.group(1); return new Line(id, Product.SUBURBAN_TRAIN, m.group(1));
} }
} }
else if ("2".equals(mot)) else if ("2".equals(mot))
{ {
return 'U' + name; return new Line(id, Product.SUBWAY, name);
} }
else if ("3".equals(mot) || "4".equals(mot)) else if ("3".equals(mot) || "4".equals(mot))
{ {
return 'T' + name; return new Line(id, Product.TRAM, name);
} }
else if ("5".equals(mot) || "6".equals(mot) || "7".equals(mot) || "10".equals(mot)) else if ("5".equals(mot) || "6".equals(mot) || "7".equals(mot) || "10".equals(mot))
{ {
if ("Schienenersatzverkehr".equals(name)) if ("Schienenersatzverkehr".equals(name))
return "BSEV"; return new Line(id, Product.BUS, "SEV");
else else
return 'B' + name; return new Line(id, Product.BUS, name);
} }
else if ("8".equals(mot)) else if ("8".equals(mot))
{ {
return 'C' + name; return new Line(id, Product.CABLECAR, name);
} }
else if ("9".equals(mot)) else if ("9".equals(mot))
{ {
return 'F' + name; return new Line(id, Product.FERRY, name);
} }
else if ("11".equals(mot)) else if ("11".equals(mot))
{ {
return '?' + ParserUtils.firstNotEmpty(symbol, name); return new Line(id, null, ParserUtils.firstNotEmpty(symbol, name));
} }
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
@ -1805,8 +1805,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
} }
final String network = lineId.substring(0, lineId.indexOf(':')); final String network = lineId.substring(0, lineId.indexOf(':'));
final String lineLabel = parseLine(productType, symbol, symbol, null, trainType, trainNum, productName); final Line parsedLine = parseLine(lineId, productType, symbol, symbol, null, trainType, trainNum, productName);
line = new Line(lineId, lineLabel, lineStyle(network, lineLabel)); line = new Line(parsedLine.id, parsedLine.product, parsedLine.label, lineStyle(network, parsedLine.product, parsedLine.label));
} }
XmlPullUtil.skipExit(pp, "m"); XmlPullUtil.skipExit(pp, "m");
@ -1974,9 +1974,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String trainType = ParserUtils.firstNotEmpty(slTrainType, itdTrainType); final String trainType = ParserUtils.firstNotEmpty(slTrainType, itdTrainType);
final String trainName = ParserUtils.firstNotEmpty(slTrainName, itdTrainName); final String trainName = ParserUtils.firstNotEmpty(slTrainName, itdTrainName);
final String label = parseLine(slMotType, slSymbol, slNumber, slNumber, trainType, slTrainNum, trainName); final Line line = parseLine(slStateless, slMotType, slSymbol, slNumber, slNumber, trainType, slTrainNum, trainName);
return new Line(slStateless, label, lineStyle(divaNetwork, label), itdMessage); return new Line(line.id, line.product, line.label, lineStyle(divaNetwork, line.product, line.label), itdMessage);
} }
private static final Pattern P_STATION_NAME_WHITESPACE = Pattern.compile("\\s+"); private static final Pattern P_STATION_NAME_WHITESPACE = Pattern.compile("\\s+");
@ -2496,22 +2496,14 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String destinationId = XmlPullUtil.optAttr(pp, "destID", null); final String destinationId = XmlPullUtil.optAttr(pp, "destID", null);
final Location destination = new Location(destinationId != null ? LocationType.STATION : LocationType.ANY, destinationId, final Location destination = new Location(destinationId != null ? LocationType.STATION : LocationType.ANY, destinationId,
null, destinationName); null, destinationName);
final String lineLabel;
final String motSymbol = XmlPullUtil.optAttr(pp, "symbol", null);
if ("AST".equals(motSymbol))
{
lineLabel = "BAST";
}
else
{
final String motType = XmlPullUtil.attr(pp, "motType");
final String motShortName = XmlPullUtil.optAttr(pp, "shortname", null);
final String motName = XmlPullUtil.attr(pp, "name");
final String motTrainName = XmlPullUtil.optAttr(pp, "trainName", null);
final String motTrainType = XmlPullUtil.optAttr(pp, "trainType", null);
lineLabel = parseLine(motType, motSymbol, motShortName, motName, motTrainType, motShortName, motTrainName); final String motSymbol = XmlPullUtil.optAttr(pp, "symbol", null);
} final String motType = XmlPullUtil.optAttr(pp, "motType", null);
final String motShortName = XmlPullUtil.optAttr(pp, "shortname", null);
final String motName = XmlPullUtil.attr(pp, "name");
final String motTrainName = XmlPullUtil.optAttr(pp, "trainName", null);
final String motTrainType = XmlPullUtil.optAttr(pp, "trainType", null);
XmlPullUtil.enter(pp, "itdMeansOfTransport"); XmlPullUtil.enter(pp, "itdMeansOfTransport");
XmlPullUtil.require(pp, "motDivaParams"); XmlPullUtil.require(pp, "motDivaParams");
final String divaNetwork = XmlPullUtil.attr(pp, "network"); final String divaNetwork = XmlPullUtil.attr(pp, "network");
@ -2522,6 +2514,12 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String lineId = divaNetwork + ':' + divaLine + ':' + divaSupplement + ':' + divaDirection + ':' + divaProject; final String lineId = divaNetwork + ':' + divaLine + ':' + divaSupplement + ':' + divaDirection + ':' + divaProject;
XmlPullUtil.skipExit(pp, "itdMeansOfTransport"); XmlPullUtil.skipExit(pp, "itdMeansOfTransport");
final Line line;
if ("AST".equals(motSymbol))
line = new Line(null, Product.BUS, "AST");
else
line = parseLine(lineId, motType, motSymbol, motShortName, motName, motTrainType, motShortName, motTrainName);
final Integer departureDelay; final Integer departureDelay;
final Integer arrivalDelay; final Integer arrivalDelay;
if (XmlPullUtil.test(pp, "itdRBLControlled")) if (XmlPullUtil.test(pp, "itdRBLControlled"))
@ -2694,14 +2692,15 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Set<Line.Attr> lineAttrs = new HashSet<Line.Attr>(); final Set<Line.Attr> lineAttrs = new HashSet<Line.Attr>();
if (wheelChairAccess || lowFloorVehicle) if (wheelChairAccess || lowFloorVehicle)
lineAttrs.add(Line.Attr.WHEEL_CHAIR_ACCESS); lineAttrs.add(Line.Attr.WHEEL_CHAIR_ACCESS);
final Line line = new Line(lineId, lineLabel, lineStyle(divaNetwork, lineLabel), lineAttrs); final Line styledLine = new Line(line.id, line.product, line.label, lineStyle(divaNetwork, line.product, line.label),
lineAttrs);
final Stop departure = new Stop(departureLocation, true, departureTargetTime != null ? departureTargetTime final Stop departure = new Stop(departureLocation, true, departureTargetTime != null ? departureTargetTime
: departureTime, departureTime != null ? departureTime : null, departurePosition, null); : departureTime, departureTime != null ? departureTime : null, departurePosition, null);
final Stop arrival = new Stop(arrivalLocation, false, arrivalTargetTime != null ? arrivalTargetTime : arrivalTime, final Stop arrival = new Stop(arrivalLocation, false, arrivalTargetTime != null ? arrivalTargetTime : arrivalTime,
arrivalTime != null ? arrivalTime : null, arrivalPosition, null); arrivalTime != null ? arrivalTime : null, arrivalPosition, null);
legs.add(new Trip.Public(line, destination, departure, arrival, intermediateStops, path, message)); legs.add(new Trip.Public(styledLine, destination, departure, arrival, intermediateStops, path, message));
} }
else else
{ {

View file

@ -242,9 +242,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
return (1 << numProductBits) - 1; return (1 << numProductBits) - 1;
} }
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
return 0; return null;
} }
protected abstract void setProductBits(StringBuilder productBits, Product product); protected abstract void setProductBits(StringBuilder productBits, Product product);
@ -648,16 +648,14 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
final Line line; final Line line;
if (classStr != null) if (classStr != null)
{ {
final char classChar = intToProduct(Integer.parseInt(classStr)); final Product product = intToProduct(Integer.parseInt(classStr));
if (classChar == 0) if (product == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
// could check for type consistency here // could check for type consistency here
final String lineName = prodLine.label.substring(1);
if (prodLine.attrs != null) if (prodLine.attrs != null)
line = newLine(classChar, lineName, null, prodLine.attrs.toArray(new Line.Attr[0])); line = newLine(product, prodLine.label, null, prodLine.attrs.toArray(new Line.Attr[0]));
else else
line = newLine(classChar, lineName, null); line = newLine(product, prodLine.label, null);
} }
else else
{ {
@ -1955,9 +1953,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
} }
else if (type == 2) else if (type == 2)
{ {
final char lineProduct; final Product lineProduct;
if (lineOnDemand) if (lineOnDemand)
lineProduct = Product.ON_DEMAND.code; lineProduct = Product.ON_DEMAND;
else if (lineClass != 0) else if (lineClass != 0)
lineProduct = intToProduct(lineClass); lineProduct = intToProduct(lineClass);
else else
@ -2553,444 +2551,435 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
private static final Pattern P_LINE_BUS = Pattern.compile("BUS\\w{0,5}"); private static final Pattern P_LINE_BUS = Pattern.compile("BUS\\w{0,5}");
private static final Pattern P_LINE_TAXI = Pattern.compile("TAX\\w{0,5}"); private static final Pattern P_LINE_TAXI = Pattern.compile("TAX\\w{0,5}");
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
// Intercity // Intercity
if ("EC".equals(ucType)) // EuroCity if ("EC".equals(ucType)) // EuroCity
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("EN".equals(ucType)) // EuroNight if ("EN".equals(ucType)) // EuroNight
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("D".equals(ucType)) // EuroNight, Sitzwagenabteil if ("D".equals(ucType)) // EuroNight, Sitzwagenabteil
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("EIC".equals(ucType)) // Ekspres InterCity, Polen if ("EIC".equals(ucType)) // Ekspres InterCity, Polen
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ICE".equals(ucType)) // InterCityExpress if ("ICE".equals(ucType)) // InterCityExpress
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("IC".equals(ucType)) // InterCity if ("IC".equals(ucType)) // InterCity
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ICT".equals(ucType)) // InterCity if ("ICT".equals(ucType)) // InterCity
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ICN".equals(ucType)) // InterCityNight if ("ICN".equals(ucType)) // InterCityNight
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ICD".equals(ucType)) // Intercity direkt Amsterdam-Breda if ("ICD".equals(ucType)) // Intercity direkt Amsterdam-Breda
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("CNL".equals(ucType)) // CityNightLine if ("CNL".equals(ucType)) // CityNightLine
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("MT".equals(ucType)) // Schnee-Express if ("MT".equals(ucType)) // Schnee-Express
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("OEC".equals(ucType)) // ÖBB-EuroCity if ("OEC".equals(ucType)) // ÖBB-EuroCity
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("OIC".equals(ucType)) // ÖBB-InterCity if ("OIC".equals(ucType)) // ÖBB-InterCity
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("RJ".equals(ucType)) // RailJet, Österreichische Bundesbahnen if ("RJ".equals(ucType)) // RailJet, Österreichische Bundesbahnen
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("WB".equals(ucType)) // westbahn if ("WB".equals(ucType)) // westbahn
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("THA".equals(ucType)) // Thalys if ("THA".equals(ucType)) // Thalys
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("TGV".equals(ucType)) // Train à Grande Vitesse if ("TGV".equals(ucType)) // Train à Grande Vitesse
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("DNZ".equals(ucType)) // Nachtzug Basel-Moskau if ("DNZ".equals(ucType)) // Nachtzug Basel-Moskau
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("AIR".equals(ucType)) // Generic Flight if ("AIR".equals(ucType)) // Generic Flight
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ECB".equals(ucType)) // EC, Verona-München if ("ECB".equals(ucType)) // EC, Verona-München
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("LYN".equals(ucType)) // Dänemark if ("LYN".equals(ucType)) // Dänemark
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("NZ".equals(ucType)) // Schweden, Nacht if ("NZ".equals(ucType)) // Schweden, Nacht
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("INZ".equals(ucType)) // Nacht if ("INZ".equals(ucType)) // Nacht
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("RHI".equals(ucType)) // ICE if ("RHI".equals(ucType)) // ICE
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("RHT".equals(ucType)) // TGV if ("RHT".equals(ucType)) // TGV
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("TGD".equals(ucType)) // TGV if ("TGD".equals(ucType)) // TGV
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("IRX".equals(ucType)) // IC if ("IRX".equals(ucType)) // IC
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ES".equals(ucType)) // Eurostar Italia if ("ES".equals(ucType)) // Eurostar Italia
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("EST".equals(ucType)) // Eurostar Frankreich if ("EST".equals(ucType)) // Eurostar Frankreich
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("EM".equals(ucType)) // Euromed, Barcelona-Alicante, Spanien if ("EM".equals(ucType)) // Euromed, Barcelona-Alicante, Spanien
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("A".equals(ucType)) // Spain, Highspeed if ("A".equals(ucType)) // Spain, Highspeed
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("AVE".equals(ucType)) // Alta Velocidad Española, Spanien if ("AVE".equals(ucType)) // Alta Velocidad Española, Spanien
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ARC".equals(ucType)) // Arco (Renfe), Spanien if ("ARC".equals(ucType)) // Arco (Renfe), Spanien
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ALS".equals(ucType)) // Alaris (Renfe), Spanien if ("ALS".equals(ucType)) // Alaris (Renfe), Spanien
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ATR".equals(ucType)) // Altaria (Renfe), Spanien if ("ATR".equals(ucType)) // Altaria (Renfe), Spanien
return 'R'; return Product.REGIONAL_TRAIN;
if ("TAL".equals(ucType)) // Talgo, Spanien if ("TAL".equals(ucType)) // Talgo, Spanien
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("TLG".equals(ucType)) // Spanien, Madrid if ("TLG".equals(ucType)) // Spanien, Madrid
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("HOT".equals(ucType)) // Spanien, Nacht if ("HOT".equals(ucType)) // Spanien, Nacht
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("X2".equals(ucType)) // X2000 Neigezug, Schweden if ("X2".equals(ucType)) // X2000 Neigezug, Schweden
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("X".equals(ucType)) // InterConnex if ("X".equals(ucType)) // InterConnex
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("FYR".equals(ucType)) // Fyra, Amsterdam-Schiphol-Rotterdam if ("FYR".equals(ucType)) // Fyra, Amsterdam-Schiphol-Rotterdam
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("FYRA".equals(ucType)) // Fyra, Amsterdam-Schiphol-Rotterdam if ("FYRA".equals(ucType)) // Fyra, Amsterdam-Schiphol-Rotterdam
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("SC".equals(ucType)) // SuperCity, Tschechien if ("SC".equals(ucType)) // SuperCity, Tschechien
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("LE".equals(ucType)) // LEO Express, Prag if ("LE".equals(ucType)) // LEO Express, Prag
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("FLUG".equals(ucType)) if ("FLUG".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("TLK".equals(ucType)) // Tanie Linie Kolejowe, Polen if ("TLK".equals(ucType)) // Tanie Linie Kolejowe, Polen
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("EIP".equals(ucType)) // Express Intercity Premium if ("EIP".equals(ucType)) // Express Intercity Premium
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("INT".equals(ucType)) // Zürich-Brüssel - Budapest-Istanbul if ("INT".equals(ucType)) // Zürich-Brüssel - Budapest-Istanbul
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("HKX".equals(ucType)) // Hamburg-Koeln-Express if ("HKX".equals(ucType)) // Hamburg-Koeln-Express
return 'I'; return Product.HIGH_SPEED_TRAIN;
// Regional // Regional
if ("ZUG".equals(ucType)) // Generic Train if ("ZUG".equals(ucType)) // Generic Train
return 'R'; return Product.REGIONAL_TRAIN;
if ("R".equals(ucType)) // Generic Regional Train if ("R".equals(ucType)) // Generic Regional Train
return 'R'; return Product.REGIONAL_TRAIN;
if ("DPN".equals(ucType)) // Dritter Personen Nahverkehr if ("DPN".equals(ucType)) // Dritter Personen Nahverkehr
return 'R'; return Product.REGIONAL_TRAIN;
if ("RB".equals(ucType)) // RegionalBahn if ("RB".equals(ucType)) // RegionalBahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("RE".equals(ucType)) // RegionalExpress if ("RE".equals(ucType)) // RegionalExpress
return 'R'; return Product.REGIONAL_TRAIN;
if ("IR".equals(ucType)) // Interregio if ("IR".equals(ucType)) // Interregio
return 'R'; return Product.REGIONAL_TRAIN;
if ("IRE".equals(ucType)) // Interregio Express if ("IRE".equals(ucType)) // Interregio Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("HEX".equals(ucType)) // Harz-Berlin-Express, Veolia if ("HEX".equals(ucType)) // Harz-Berlin-Express, Veolia
return 'R'; return Product.REGIONAL_TRAIN;
if ("WFB".equals(ucType)) // Westfalenbahn if ("WFB".equals(ucType)) // Westfalenbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("RT".equals(ucType)) // RegioTram if ("RT".equals(ucType)) // RegioTram
return 'R'; return Product.REGIONAL_TRAIN;
if ("REX".equals(ucType)) // RegionalExpress, Österreich if ("REX".equals(ucType)) // RegionalExpress, Österreich
return 'R'; return Product.REGIONAL_TRAIN;
if ("OS".equals(ucType)) // Osobný vlak, Slovakia oder Osobní vlak, Czech Republic if ("OS".equals(ucType)) // Osobný vlak, Slovakia oder Osobní vlak, Czech Republic
return 'R'; return Product.REGIONAL_TRAIN;
if ("SP".equals(ucType)) // Spěšný vlak, Czech Republic if ("SP".equals(ucType)) // Spěšný vlak, Czech Republic
return 'R'; return Product.REGIONAL_TRAIN;
if ("EZ".equals(ucType)) // ÖBB ErlebnisBahn if ("EZ".equals(ucType)) // ÖBB ErlebnisBahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("ARZ".equals(ucType)) // Auto-Reisezug Brig - Iselle di Trasquera if ("ARZ".equals(ucType)) // Auto-Reisezug Brig - Iselle di Trasquera
return 'R'; return Product.REGIONAL_TRAIN;
if ("OE".equals(ucType)) // Ostdeutsche Eisenbahn if ("OE".equals(ucType)) // Ostdeutsche Eisenbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("MR".equals(ucType)) // Märkische Regionalbahn if ("MR".equals(ucType)) // Märkische Regionalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("PE".equals(ucType)) // Prignitzer Eisenbahn GmbH if ("PE".equals(ucType)) // Prignitzer Eisenbahn GmbH
return 'R'; return Product.REGIONAL_TRAIN;
if ("NE".equals(ucType)) // NEB Betriebsgesellschaft mbH if ("NE".equals(ucType)) // NEB Betriebsgesellschaft mbH
return 'R'; return Product.REGIONAL_TRAIN;
if ("MRB".equals(ucType)) // Mitteldeutsche Regiobahn if ("MRB".equals(ucType)) // Mitteldeutsche Regiobahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("ERB".equals(ucType)) // eurobahn (Keolis Deutschland) if ("ERB".equals(ucType)) // eurobahn (Keolis Deutschland)
return 'R'; return Product.REGIONAL_TRAIN;
if ("HLB".equals(ucType)) // Hessische Landesbahn if ("HLB".equals(ucType)) // Hessische Landesbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("VIA".equals(ucType)) if ("VIA".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("HSB".equals(ucType)) // Harzer Schmalspurbahnen if ("HSB".equals(ucType)) // Harzer Schmalspurbahnen
return 'R'; return Product.REGIONAL_TRAIN;
if ("OSB".equals(ucType)) // Ortenau-S-Bahn if ("OSB".equals(ucType)) // Ortenau-S-Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("VBG".equals(ucType)) // Vogtlandbahn if ("VBG".equals(ucType)) // Vogtlandbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("AKN".equals(ucType)) // AKN Eisenbahn AG if ("AKN".equals(ucType)) // AKN Eisenbahn AG
return 'R'; return Product.REGIONAL_TRAIN;
if ("OLA".equals(ucType)) // Ostseeland Verkehr if ("OLA".equals(ucType)) // Ostseeland Verkehr
return 'R'; return Product.REGIONAL_TRAIN;
if ("UBB".equals(ucType)) // Usedomer Bäderbahn if ("UBB".equals(ucType)) // Usedomer Bäderbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("PEG".equals(ucType)) // Prignitzer Eisenbahn if ("PEG".equals(ucType)) // Prignitzer Eisenbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("NWB".equals(ucType)) // NordWestBahn if ("NWB".equals(ucType)) // NordWestBahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("CAN".equals(ucType)) // cantus Verkehrsgesellschaft if ("CAN".equals(ucType)) // cantus Verkehrsgesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("BRB".equals(ucType)) // ABELLIO Rail if ("BRB".equals(ucType)) // ABELLIO Rail
return 'R'; return Product.REGIONAL_TRAIN;
if ("SBB".equals(ucType)) // Schweizerische Bundesbahnen if ("SBB".equals(ucType)) // Schweizerische Bundesbahnen
return 'R'; return Product.REGIONAL_TRAIN;
if ("VEC".equals(ucType)) // vectus Verkehrsgesellschaft if ("VEC".equals(ucType)) // vectus Verkehrsgesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("TLX".equals(ucType)) // Trilex (Vogtlandbahn) if ("TLX".equals(ucType)) // Trilex (Vogtlandbahn)
return 'R'; return Product.REGIONAL_TRAIN;
if ("TL".equals(ucType)) // Trilex (Vogtlandbahn) if ("TL".equals(ucType)) // Trilex (Vogtlandbahn)
return 'R'; return Product.REGIONAL_TRAIN;
if ("HZL".equals(ucType)) // Hohenzollerische Landesbahn if ("HZL".equals(ucType)) // Hohenzollerische Landesbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("ABR".equals(ucType)) // Bayerische Regiobahn if ("ABR".equals(ucType)) // Bayerische Regiobahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("CB".equals(ucType)) // City Bahn Chemnitz if ("CB".equals(ucType)) // City Bahn Chemnitz
return 'R'; return Product.REGIONAL_TRAIN;
if ("WEG".equals(ucType)) // Württembergische Eisenbahn-Gesellschaft if ("WEG".equals(ucType)) // Württembergische Eisenbahn-Gesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("NEB".equals(ucType)) // Niederbarnimer Eisenbahn if ("NEB".equals(ucType)) // Niederbarnimer Eisenbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("ME".equals(ucType)) // metronom Eisenbahngesellschaft if ("ME".equals(ucType)) // metronom Eisenbahngesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("MER".equals(ucType)) // metronom regional if ("MER".equals(ucType)) // metronom regional
return 'R'; return Product.REGIONAL_TRAIN;
if ("ALX".equals(ucType)) // Arriva-Länderbahn-Express if ("ALX".equals(ucType)) // Arriva-Länderbahn-Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("EB".equals(ucType)) // Erfurter Bahn if ("EB".equals(ucType)) // Erfurter Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("EBX".equals(ucType)) // Erfurter Bahn if ("EBX".equals(ucType)) // Erfurter Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("VEN".equals(ucType)) // Rhenus Veniro if ("VEN".equals(ucType)) // Rhenus Veniro
return 'R'; return Product.REGIONAL_TRAIN;
if ("BOB".equals(ucType)) // Bayerische Oberlandbahn if ("BOB".equals(ucType)) // Bayerische Oberlandbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("SBS".equals(ucType)) // Städtebahn Sachsen if ("SBS".equals(ucType)) // Städtebahn Sachsen
return 'R'; return Product.REGIONAL_TRAIN;
if ("SES".equals(ucType)) // Städtebahn Sachsen Express if ("SES".equals(ucType)) // Städtebahn Sachsen Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("EVB".equals(ucType)) // Eisenbahnen und Verkehrsbetriebe Elbe-Weser if ("EVB".equals(ucType)) // Eisenbahnen und Verkehrsbetriebe Elbe-Weser
return 'R'; return Product.REGIONAL_TRAIN;
if ("STB".equals(ucType)) // Süd-Thüringen-Bahn if ("STB".equals(ucType)) // Süd-Thüringen-Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("AG".equals(ucType)) // Ingolstadt-Landshut if ("AG".equals(ucType)) // Ingolstadt-Landshut
return 'R'; return Product.REGIONAL_TRAIN;
if ("PRE".equals(ucType)) // Pressnitztalbahn if ("PRE".equals(ucType)) // Pressnitztalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("DBG".equals(ucType)) // Döllnitzbahn GmbH if ("DBG".equals(ucType)) // Döllnitzbahn GmbH
return 'R'; return Product.REGIONAL_TRAIN;
if ("SHB".equals(ucType)) // Schleswig-Holstein-Bahn if ("SHB".equals(ucType)) // Schleswig-Holstein-Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("NOB".equals(ucType)) // Nord-Ostsee-Bahn if ("NOB".equals(ucType)) // Nord-Ostsee-Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("RTB".equals(ucType)) // Rurtalbahn if ("RTB".equals(ucType)) // Rurtalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("BLB".equals(ucType)) // Berchtesgadener Land Bahn if ("BLB".equals(ucType)) // Berchtesgadener Land Bahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("NBE".equals(ucType)) // Nordbahn Eisenbahngesellschaft if ("NBE".equals(ucType)) // Nordbahn Eisenbahngesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("SOE".equals(ucType)) // Sächsisch-Oberlausitzer Eisenbahngesellschaft if ("SOE".equals(ucType)) // Sächsisch-Oberlausitzer Eisenbahngesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("SDG".equals(ucType)) // Sächsische Dampfeisenbahngesellschaft if ("SDG".equals(ucType)) // Sächsische Dampfeisenbahngesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("VE".equals(ucType)) // Lutherstadt Wittenberg if ("VE".equals(ucType)) // Lutherstadt Wittenberg
return 'R'; return Product.REGIONAL_TRAIN;
if ("DAB".equals(ucType)) // Daadetalbahn if ("DAB".equals(ucType)) // Daadetalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("WTB".equals(ucType)) // Wutachtalbahn e.V. if ("WTB".equals(ucType)) // Wutachtalbahn e.V.
return 'R'; return Product.REGIONAL_TRAIN;
if ("BE".equals(ucType)) // Grensland-Express if ("BE".equals(ucType)) // Grensland-Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("ARR".equals(ucType)) // Ostfriesland if ("ARR".equals(ucType)) // Ostfriesland
return 'R'; return Product.REGIONAL_TRAIN;
if ("HTB".equals(ucType)) // Hörseltalbahn if ("HTB".equals(ucType)) // Hörseltalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("FEG".equals(ucType)) // Freiberger Eisenbahngesellschaft if ("FEG".equals(ucType)) // Freiberger Eisenbahngesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("NEG".equals(ucType)) // Norddeutsche Eisenbahngesellschaft Niebüll if ("NEG".equals(ucType)) // Norddeutsche Eisenbahngesellschaft Niebüll
return 'R'; return Product.REGIONAL_TRAIN;
if ("RBG".equals(ucType)) // Regental Bahnbetriebs GmbH if ("RBG".equals(ucType)) // Regental Bahnbetriebs GmbH
return 'R'; return Product.REGIONAL_TRAIN;
if ("MBB".equals(ucType)) // Mecklenburgische Bäderbahn Molli if ("MBB".equals(ucType)) // Mecklenburgische Bäderbahn Molli
return 'R'; return Product.REGIONAL_TRAIN;
if ("VEB".equals(ucType)) // Vulkan-Eifel-Bahn Betriebsgesellschaft if ("VEB".equals(ucType)) // Vulkan-Eifel-Bahn Betriebsgesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("LEO".equals(ucType)) // Chiemgauer Lokalbahn if ("LEO".equals(ucType)) // Chiemgauer Lokalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("VX".equals(ucType)) // Vogtland Express if ("VX".equals(ucType)) // Vogtland Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("MSB".equals(ucType)) // Mainschleifenbahn if ("MSB".equals(ucType)) // Mainschleifenbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("P".equals(ucType)) // Kasbachtalbahn if ("P".equals(ucType)) // Kasbachtalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("ÖBA".equals(ucType)) // Öchsle-Bahn Betriebsgesellschaft if ("ÖBA".equals(ucType)) // Öchsle-Bahn Betriebsgesellschaft
return 'R'; return Product.REGIONAL_TRAIN;
if ("KTB".equals(ucType)) // Kandertalbahn if ("KTB".equals(ucType)) // Kandertalbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("ERX".equals(ucType)) // erixx if ("ERX".equals(ucType)) // erixx
return 'R'; return Product.REGIONAL_TRAIN;
if ("ATZ".equals(ucType)) // Autotunnelzug if ("ATZ".equals(ucType)) // Autotunnelzug
return 'R'; return Product.REGIONAL_TRAIN;
if ("ATB".equals(ucType)) // Autoschleuse Tauernbahn if ("ATB".equals(ucType)) // Autoschleuse Tauernbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("CAT".equals(ucType)) // City Airport Train if ("CAT".equals(ucType)) // City Airport Train
return 'R'; return Product.REGIONAL_TRAIN;
if ("EXTRA".equals(ucType) || "EXT".equals(ucType)) // Extrazug if ("EXTRA".equals(ucType) || "EXT".equals(ucType)) // Extrazug
return 'R'; return Product.REGIONAL_TRAIN;
if ("KD".equals(ucType)) // Koleje Dolnośląskie (Niederschlesische Eisenbahn) if ("KD".equals(ucType)) // Koleje Dolnośląskie (Niederschlesische Eisenbahn)
return 'R'; return Product.REGIONAL_TRAIN;
if ("KM".equals(ucType)) // Koleje Mazowieckie if ("KM".equals(ucType)) // Koleje Mazowieckie
return 'R'; return Product.REGIONAL_TRAIN;
if ("EX".equals(ucType)) // Polen if ("EX".equals(ucType)) // Polen
return 'R'; return Product.REGIONAL_TRAIN;
if ("PCC".equals(ucType)) // PCC Rail, Polen if ("PCC".equals(ucType)) // PCC Rail, Polen
return 'R'; return Product.REGIONAL_TRAIN;
if ("ZR".equals(ucType)) // ZSR (Slovakian Republic Railways) if ("ZR".equals(ucType)) // ZSR (Slovakian Republic Railways)
return 'R'; return Product.REGIONAL_TRAIN;
if ("RNV".equals(ucType)) // Rhein-Neckar-Verkehr GmbH if ("RNV".equals(ucType)) // Rhein-Neckar-Verkehr GmbH
return 'R'; return Product.REGIONAL_TRAIN;
if ("DWE".equals(ucType)) // Dessau-Wörlitzer Eisenbahn if ("DWE".equals(ucType)) // Dessau-Wörlitzer Eisenbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("BKB".equals(ucType)) // Buckower Kleinbahn if ("BKB".equals(ucType)) // Buckower Kleinbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("GEX".equals(ucType)) // Glacier Express if ("GEX".equals(ucType)) // Glacier Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("M".equals(ucType)) // Meridian if ("M".equals(ucType)) // Meridian
return 'R'; return Product.REGIONAL_TRAIN;
if ("WBA".equals(ucType)) // Waldbahn if ("WBA".equals(ucType)) // Waldbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("BEX".equals(ucType)) // Bernina Express if ("BEX".equals(ucType)) // Bernina Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("VAE".equals(ucType)) // Voralpen-Express if ("VAE".equals(ucType)) // Voralpen-Express
return 'R'; return Product.REGIONAL_TRAIN;
if ("OPB".equals(ucType)) // oberpfalzbahn if ("OPB".equals(ucType)) // oberpfalzbahn
return 'R'; return Product.REGIONAL_TRAIN;
if ("OPX".equals(ucType)) // oberpfalz-express if ("OPX".equals(ucType)) // oberpfalz-express
return 'R'; return Product.REGIONAL_TRAIN;
if ("TER".equals(ucType)) // Transport express régional if ("TER".equals(ucType)) // Transport express régional
return 'R'; return Product.REGIONAL_TRAIN;
// Suburban Trains // Suburban Trains
if (P_LINE_SBAHN.matcher(ucType).matches()) // Generic (Night) S-Bahn if (P_LINE_SBAHN.matcher(ucType).matches()) // Generic (Night) S-Bahn
return 'S'; return Product.SUBURBAN_TRAIN;
if ("S-BAHN".equals(ucType)) if ("S-BAHN".equals(ucType))
return 'S'; return Product.SUBURBAN_TRAIN;
if ("BSB".equals(ucType)) // Breisgau S-Bahn if ("BSB".equals(ucType)) // Breisgau S-Bahn
return 'S'; return Product.SUBURBAN_TRAIN;
if ("SWE".equals(ucType)) // Südwestdeutsche Verkehrs-AG, Ortenau-S-Bahn if ("SWE".equals(ucType)) // Südwestdeutsche Verkehrs-AG, Ortenau-S-Bahn
return 'S'; return Product.SUBURBAN_TRAIN;
if ("RER".equals(ucType)) // Réseau Express Régional, Frankreich if ("RER".equals(ucType)) // Réseau Express Régional, Frankreich
return 'S'; return Product.SUBURBAN_TRAIN;
if ("WKD".equals(ucType)) // Warszawska Kolej Dojazdowa (Warsaw Suburban Railway) if ("WKD".equals(ucType)) // Warszawska Kolej Dojazdowa (Warsaw Suburban Railway)
return 'S'; return Product.SUBURBAN_TRAIN;
if ("SKM".equals(ucType)) // Szybka Kolej Miejska Tricity if ("SKM".equals(ucType)) // Szybka Kolej Miejska Tricity
return 'S'; return Product.SUBURBAN_TRAIN;
if ("SKW".equals(ucType)) // Szybka Kolej Miejska Warschau if ("SKW".equals(ucType)) // Szybka Kolej Miejska Warschau
return 'S'; return Product.SUBURBAN_TRAIN;
// if ("SPR".equals(normalizedType)) // Sprinter, Niederlande
// return "S" + normalizedName;
// Subway // Subway
if ("U".equals(ucType)) // Generic U-Bahn if ("U".equals(ucType)) // Generic U-Bahn
return 'U'; return Product.SUBWAY;
if ("MET".equals(ucType)) if ("MET".equals(ucType))
return 'U'; return Product.SUBWAY;
if ("METRO".equals(ucType)) if ("METRO".equals(ucType))
return 'U'; return Product.SUBWAY;
// Tram // Tram
if (P_LINE_TRAM.matcher(ucType).matches()) // Generic Tram if (P_LINE_TRAM.matcher(ucType).matches()) // Generic Tram
return 'T'; return Product.TRAM;
if ("NFT".equals(ucType)) // Niederflur-Tram if ("NFT".equals(ucType)) // Niederflur-Tram
return 'T'; return Product.TRAM;
if ("TRAM".equals(ucType)) if ("TRAM".equals(ucType))
return 'T'; return Product.TRAM;
if ("TRA".equals(ucType)) if ("TRA".equals(ucType))
return 'T'; return Product.TRAM;
if ("WLB".equals(ucType)) // Wiener Lokalbahnen if ("WLB".equals(ucType)) // Wiener Lokalbahnen
return 'T'; return Product.TRAM;
if ("STRWLB".equals(ucType)) // Wiener Lokalbahnen if ("STRWLB".equals(ucType)) // Wiener Lokalbahnen
return 'T'; return Product.TRAM;
if ("SCHW-B".equals(ucType)) // Schwebebahn, gilt als "Straßenbahn besonderer Bauart" if ("SCHW-B".equals(ucType)) // Schwebebahn, gilt als "Straßenbahn besonderer Bauart"
return 'T'; return Product.TRAM;
// Bus // Bus
if (P_LINE_BUS.matcher(ucType).matches()) // Generic Bus if (P_LINE_BUS.matcher(ucType).matches()) // Generic Bus
return 'B'; return Product.BUS;
if ("NFB".equals(ucType)) // Niederflur-Bus if ("NFB".equals(ucType)) // Niederflur-Bus
return 'B'; return Product.BUS;
if ("SEV".equals(ucType)) // Schienen-Ersatz-Verkehr if ("SEV".equals(ucType)) // Schienen-Ersatz-Verkehr
return 'B'; return Product.BUS;
if ("BUSSEV".equals(ucType)) // Schienen-Ersatz-Verkehr if ("BUSSEV".equals(ucType)) // Schienen-Ersatz-Verkehr
return 'B'; return Product.BUS;
if ("BSV".equals(ucType)) // Bus SEV if ("BSV".equals(ucType)) // Bus SEV
return 'B'; return Product.BUS;
if ("FB".equals(ucType)) // Fernbus? Luxemburg-Saarbrücken if ("FB".equals(ucType)) // Fernbus? Luxemburg-Saarbrücken
return 'B'; return Product.BUS;
if ("EXB".equals(ucType)) // Expressbus München-Prag? if ("EXB".equals(ucType)) // Expressbus München-Prag?
return 'B'; return Product.BUS;
if ("ICB".equals(ucType)) // ÖBB ICBus if ("ICB".equals(ucType)) // ÖBB ICBus
return 'B'; return Product.BUS;
if ("TRO".equals(ucType)) // Trolleybus if ("TRO".equals(ucType)) // Trolleybus
return 'B'; return Product.BUS;
if ("RFB".equals(ucType)) // Rufbus if ("RFB".equals(ucType)) // Rufbus
return 'B'; return Product.BUS;
if ("RUF".equals(ucType)) // Rufbus if ("RUF".equals(ucType)) // Rufbus
return 'B'; return Product.BUS;
if (P_LINE_TAXI.matcher(ucType).matches()) // Generic Taxi if (P_LINE_TAXI.matcher(ucType).matches()) // Generic Taxi
return 'B'; return Product.BUS;
if ("RFT".equals(ucType)) // Ruftaxi if ("RFT".equals(ucType)) // Ruftaxi
return 'B'; return Product.BUS;
if ("LT".equals(ucType)) // Linien-Taxi if ("LT".equals(ucType)) // Linien-Taxi
return 'B'; return Product.BUS;
if ("NB".equals(ucType)) // Nachtbus Zürich if ("NB".equals(ucType)) // Nachtbus Zürich
return 'B'; return Product.BUS;
// Phone // Phone
if (ucType.startsWith("AST")) // Anruf-Sammel-Taxi if (ucType.startsWith("AST")) // Anruf-Sammel-Taxi
return 'P'; return Product.ON_DEMAND;
if (ucType.startsWith("ALT")) // Anruf-Linien-Taxi if (ucType.startsWith("ALT")) // Anruf-Linien-Taxi
return 'P'; return Product.ON_DEMAND;
if (ucType.startsWith("BUXI")) // Bus-Taxi (Schweiz) if (ucType.startsWith("BUXI")) // Bus-Taxi (Schweiz)
return 'P'; return Product.ON_DEMAND;
if ("TB".equals(ucType)) // Taxi-Bus? if ("TB".equals(ucType)) // Taxi-Bus?
return 'P'; return Product.ON_DEMAND;
// Ferry // Ferry
if ("SCHIFF".equals(ucType)) if ("SCHIFF".equals(ucType))
return 'F'; return Product.FERRY;
if ("FÄHRE".equals(ucType)) if ("FÄHRE".equals(ucType))
return 'F'; return Product.FERRY;
if ("FÄH".equals(ucType)) if ("FÄH".equals(ucType))
return 'F'; return Product.FERRY;
if ("FAE".equals(ucType)) if ("FAE".equals(ucType))
return 'F'; return Product.FERRY;
if ("SCH".equals(ucType)) // Schiff if ("SCH".equals(ucType)) // Schiff
return 'F'; return Product.FERRY;
if ("AS".equals(ucType)) // SyltShuttle, eigentlich Autoreisezug if ("AS".equals(ucType)) // SyltShuttle, eigentlich Autoreisezug
return 'F'; return Product.FERRY;
if ("KAT".equals(ucType)) // Katamaran, e.g. Friedrichshafen - Konstanz if ("KAT".equals(ucType)) // Katamaran, e.g. Friedrichshafen - Konstanz
return 'F'; return Product.FERRY;
if ("BAT".equals(ucType)) // Boots Anlege Terminal? if ("BAT".equals(ucType)) // Boots Anlege Terminal?
return 'F'; return Product.FERRY;
if ("BAV".equals(ucType)) // Boots Anlege? if ("BAV".equals(ucType)) // Boots Anlege?
return 'F'; return Product.FERRY;
// Cable Car // Cable Car
if ("SEILBAHN".equals(ucType)) if ("SEILBAHN".equals(ucType))
return 'C'; return Product.CABLECAR;
if ("SB".equals(ucType)) // Seilbahn if ("SB".equals(ucType)) // Seilbahn
return 'C'; return Product.CABLECAR;
if ("ZAHNR".equals(ucType)) // Zahnradbahn, u.a. Zugspitzbahn if ("ZAHNR".equals(ucType)) // Zahnradbahn, u.a. Zugspitzbahn
return 'C'; return Product.CABLECAR;
if ("GB".equals(ucType)) // Gondelbahn if ("GB".equals(ucType)) // Gondelbahn
return 'C'; return Product.CABLECAR;
if ("LB".equals(ucType)) // Luftseilbahn if ("LB".equals(ucType)) // Luftseilbahn
return 'C'; return Product.CABLECAR;
if ("FUN".equals(ucType)) // Funiculaire (Standseilbahn) if ("FUN".equals(ucType)) // Funiculaire (Standseilbahn)
return 'C'; return Product.CABLECAR;
if ("SL".equals(ucType)) // Sessel-Lift if ("SL".equals(ucType)) // Sessel-Lift
return 'C'; return Product.CABLECAR;
// if ("L".equals(normalizedType)) throw new IllegalStateException("cannot normalize type '" + type + "'");
// return "?" + normalizedName;
// if ("CR".equals(normalizedType))
// return "?" + normalizedName;
// if ("TRN".equals(normalizedType))
// return "?" + normalizedName;
return 0;
} }
private static final Pattern P_NORMALIZE_LINE_NAME_BUS = Pattern.compile("bus\\s+(.*)", Pattern.CASE_INSENSITIVE); private static final Pattern P_NORMALIZE_LINE_NAME_BUS = Pattern.compile("bus\\s+(.*)", Pattern.CASE_INSENSITIVE);
@ -3029,15 +3018,15 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
{ {
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(normalizedName); final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(normalizedName);
if (mBus.matches()) if (mBus.matches())
return newLine('B', mBus.group(1), null); return newLine(Product.BUS, mBus.group(1), null);
final Matcher mTram = P_NORMALIZE_LINE_TRAM.matcher(normalizedName); final Matcher mTram = P_NORMALIZE_LINE_TRAM.matcher(normalizedName);
if (mTram.matches()) if (mTram.matches())
return newLine('T', mTram.group(1), null); return newLine(Product.TRAM, mTram.group(1), null);
} }
final char normalizedType = normalizeType(type); final Product normalizedType = normalizeType(type);
if (normalizedType == 0) if (normalizedType == null)
throw new IllegalStateException("cannot normalize type '" + type + "' line '" + normalizedName + "'"); throw new IllegalStateException("cannot normalize type '" + type + "' line '" + normalizedName + "'");
final Line.Attr[] attrs; final Line.Attr[] attrs;
@ -3076,29 +3065,29 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
if (type.length() == 0) if (type.length() == 0)
{ {
if (number.length() == 0) if (number.length() == 0)
return newLine('?', null, null); return newLine(null, null, null);
if (P_NORMALIZE_LINE_NUMBER.matcher(number).matches()) if (P_NORMALIZE_LINE_NUMBER.matcher(number).matches())
return newLine('?', number, null); return newLine(null, number, null);
if (P_LINE_RUSSIA.matcher(number).matches()) if (P_LINE_RUSSIA.matcher(number).matches())
return newLine('R', number, null); return newLine(Product.REGIONAL_TRAIN, number, null);
} }
else else
{ {
final char normalizedType = normalizeType(type); final Product normalizedType = normalizeType(type);
if (normalizedType != 0) if (normalizedType != null)
{ {
if (normalizedType == 'B') if (normalizedType == Product.BUS)
{ {
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(number); final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(number);
if (mBus.matches()) if (mBus.matches())
return newLine('B', mBus.group(1), null); return newLine(Product.BUS, mBus.group(1), null);
} }
if (normalizedType == 'T') if (normalizedType == Product.TRAM)
{ {
final Matcher mTram = P_NORMALIZE_LINE_TRAM.matcher(number); final Matcher mTram = P_NORMALIZE_LINE_TRAM.matcher(number);
if (mTram.matches()) if (mTram.matches())
return newLine('T', mTram.group(1), null); return newLine(Product.TRAM, mTram.group(1), null);
} }
return newLine(normalizedType, number.replaceAll("\\s+", ""), null); return newLine(normalizedType, number.replaceAll("\\s+", ""), null);
@ -3111,20 +3100,18 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
throw new IllegalStateException("cannot normalize line#type '" + lineAndType + "'"); throw new IllegalStateException("cannot normalize line#type '" + lineAndType + "'");
} }
protected Line newLine(final char product, final String normalizedName, final String comment, final Line.Attr... attrs) protected Line newLine(final Product product, final String normalizedName, final String comment, final Line.Attr... attrs)
{ {
final String lineStr = (product != 0 ? Character.toString(product) : Product.UNKNOWN) + (normalizedName != null ? normalizedName : "?");
if (attrs.length == 0) if (attrs.length == 0)
{ {
return new Line(null, lineStr, lineStyle(null, lineStr), comment); return new Line(null, product, normalizedName, lineStyle(null, product, normalizedName), comment);
} }
else else
{ {
final Set<Line.Attr> attrSet = new HashSet<Line.Attr>(); final Set<Line.Attr> attrSet = new HashSet<Line.Attr>();
for (final Line.Attr attr : attrs) for (final Line.Attr attr : attrs)
attrSet.add(attr); attrSet.add(attr);
return new Line(null, lineStr, lineStyle(null, lineStr), attrSet, comment); return new Line(null, product, normalizedName, lineStyle(null, product, normalizedName), attrSet, comment);
} }
} }
} }

View file

@ -141,7 +141,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
return Style.deriveForegroundColor(bgColor); return Style.deriveForegroundColor(bgColor);
} }
protected Style getLineStyle(final char product, final String code, final String color) protected Style getLineStyle(final Product product, final String code, final String color)
{ {
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
} }
@ -393,15 +393,14 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
modeId = link.getString("id"); modeId = link.getString("id");
} }
final char product = parseLineProductFromMode(modeId); final Product product = parseLineProductFromMode(modeId);
final JSONObject displayInfo = section.getJSONObject("display_informations"); final JSONObject displayInfo = section.getJSONObject("display_informations");
final String code = displayInfo.getString("code"); final String code = displayInfo.getString("code");
final String lineLabel = product + code;
final String colorHex = displayInfo.getString("color"); final String colorHex = displayInfo.getString("color");
final String color = colorHex.equals("000000") ? "#FFFFFF" : "#" + colorHex; final String color = colorHex.equals("000000") ? "#FFFFFF" : "#" + colorHex;
final Style lineStyle = getLineStyle(product, code, color); final Style lineStyle = getLineStyle(product, code, color);
return new Line(lineId, lineLabel, lineStyle); return new Line(lineId, product, code, lineStyle);
} }
catch (final JSONException jsonExc) catch (final JSONException jsonExc)
{ {
@ -582,12 +581,11 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
try try
{ {
final String lineId = jsonLine.getString("id"); final String lineId = jsonLine.getString("id");
final char product = parseLineProduct(jsonLine); final Product product = parseLineProduct(jsonLine);
final String code = jsonLine.getString("code"); final String code = jsonLine.getString("code");
final String lineLabel = product + code;
final String color = "#" + jsonLine.getString("color"); final String color = "#" + jsonLine.getString("color");
final Style lineStyle = getLineStyle(product, code, color); final Style lineStyle = getLineStyle(product, code, color);
return new Line(lineId, lineLabel, lineStyle); return new Line(lineId, product, code, lineStyle);
} }
catch (final JSONException jsonExc) catch (final JSONException jsonExc)
{ {
@ -595,9 +593,9 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
} }
} }
private Map<String, Character> lineProductCache = new WeakHashMap<String, Character>(); private Map<String, Product> lineProductCache = new WeakHashMap<String, Product>();
private char parseLineProductFromMode(final String modeId) private Product parseLineProductFromMode(final String modeId)
{ {
final String modeType = modeId.replace("commercial_mode:", ""); final String modeType = modeId.replace("commercial_mode:", "");
final CommercialMode commercialMode = CommercialMode.valueOf(modeType.toUpperCase()); final CommercialMode commercialMode = CommercialMode.valueOf(modeType.toUpperCase());
@ -605,38 +603,38 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
switch (commercialMode) switch (commercialMode)
{ {
case BUS: case BUS:
return 'B'; return Product.BUS;
case RAPIDTRANSIT: case RAPIDTRANSIT:
case TRAIN: case TRAIN:
return 'S'; return Product.SUBURBAN_TRAIN;
case TRAM: case TRAM:
case TRAMWAY: case TRAMWAY:
return 'T'; return Product.TRAM;
case METRO: case METRO:
return 'U'; return Product.SUBWAY;
case FERRY: case FERRY:
return 'F'; return Product.FERRY;
case FUNICULAR: case FUNICULAR:
case CABLECAR: case CABLECAR:
return 'C'; return Product.CABLECAR;
case DEFAULT_COMMERCIAL_MODE: case DEFAULT_COMMERCIAL_MODE:
default: default:
throw new IllegalArgumentException("Unhandled place type: " + modeId); throw new IllegalArgumentException("Unhandled place type: " + modeId);
} }
} }
private char parseLineProduct(final JSONObject line) throws IOException private Product parseLineProduct(final JSONObject line) throws IOException
{ {
try try
{ {
final String lineId = line.getString("id"); final String lineId = line.getString("id");
final Character cachedProduct = lineProductCache.get(lineId); final Product cachedProduct = lineProductCache.get(lineId);
if (cachedProduct != null) if (cachedProduct != null)
return cachedProduct; return cachedProduct;
final JSONObject mode = line.getJSONObject("commercial_mode"); final JSONObject mode = line.getJSONObject("commercial_mode");
final String modeId = mode.getString("id"); final String modeId = mode.getString("id");
final char product = parseLineProductFromMode(modeId); final Product product = parseLineProductFromMode(modeId);
lineProductCache.put(lineId, product); lineProductCache.put(lineId, product);

View file

@ -25,6 +25,8 @@ import java.util.TimeZone;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.google.common.base.Strings;
import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Position; import de.schildbach.pte.dto.Position;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
@ -80,27 +82,24 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
private static final char STYLES_SEP = '|'; private static final char STYLES_SEP = '|';
public Style lineStyle(final String network, final String line) public Style lineStyle(final String network, final Product product, final String label)
{ {
if (line == null || line.length() == 0) if (styles != null && product != null)
return null;
if (styles != null)
{ {
if (network != null) if (network != null)
{ {
// check for line match // check for line match
final Style lineStyle = styles.get(network + STYLES_SEP + line); final Style lineStyle = styles.get(network + STYLES_SEP + product.code + Strings.nullToEmpty(label));
if (lineStyle != null) if (lineStyle != null)
return lineStyle; return lineStyle;
// check for product match // check for product match
final Style productStyle = styles.get(network + STYLES_SEP + line.charAt(0)); final Style productStyle = styles.get(network + STYLES_SEP + product.code);
if (productStyle != null) if (productStyle != null)
return productStyle; return productStyle;
// check for night bus, as that's a common special case // check for night bus, as that's a common special case
if (line.startsWith("BN")) if (product == Product.BUS && label.startsWith("N"))
{ {
final Style nightStyle = styles.get(network + STYLES_SEP + "BN"); final Style nightStyle = styles.get(network + STYLES_SEP + "BN");
if (nightStyle != null) if (nightStyle != null)
@ -109,17 +108,18 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
} }
// check for line match // check for line match
final Style lineStyle = styles.get(line); final String string = product.code + Strings.nullToEmpty(label);
final Style lineStyle = styles.get(string);
if (lineStyle != null) if (lineStyle != null)
return lineStyle; return lineStyle;
// check for product match // check for product match
final Style productStyle = styles.get(new Character(line.charAt(0)).toString()); final Style productStyle = styles.get(Character.toString(product.code));
if (productStyle != null) if (productStyle != null)
return productStyle; return productStyle;
// check for night bus, as that's a common special case // check for night bus, as that's a common special case
if (line.startsWith("BN")) if (product == Product.BUS && label.startsWith("N"))
{ {
final Style nightStyle = styles.get("BN"); final Style nightStyle = styles.get("BN");
if (nightStyle != null) if (nightStyle != null)
@ -128,7 +128,7 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
} }
// standard colors // standard colors
return Standard.STYLES.get(line.charAt(0)); return Standard.STYLES.get(product);
} }
public Point[] getArea() throws IOException public Point[] getArea() throws IOException

View file

@ -129,34 +129,34 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
private static final ResultHeader HEADER = new ResultHeader("tsi"); private static final ResultHeader HEADER = new ResultHeader("tsi");
private static Map<String, Character> TRANSPORT_MODE_SHORTS = new HashMap<String, Character>(); private static Map<String, Product> TRANSPORT_MODES = new HashMap<String, Product>();
static static
{ {
// HIGH_SPEED_TRAIN // HIGH_SPEED_TRAIN
TRANSPORT_MODE_SHORTS.put("TGV", 'I'); TRANSPORT_MODES.put("TGV", Product.HIGH_SPEED_TRAIN);
TRANSPORT_MODE_SHORTS.put("HST", 'I'); TRANSPORT_MODES.put("HST", Product.HIGH_SPEED_TRAIN);
// REGIONAL_TRAIN // REGIONAL_TRAIN
TRANSPORT_MODE_SHORTS.put("TRAIN", 'R'); TRANSPORT_MODES.put("TRAIN", Product.REGIONAL_TRAIN);
TRANSPORT_MODE_SHORTS.put("TER", 'R'); TRANSPORT_MODES.put("TER", Product.REGIONAL_TRAIN);
// SUBURBAN_TRAIN // SUBURBAN_TRAIN
TRANSPORT_MODE_SHORTS.put("LOCAL_TRAIN", 'S'); TRANSPORT_MODES.put("LOCAL_TRAIN", Product.SUBURBAN_TRAIN);
// SUBWAY // SUBWAY
TRANSPORT_MODE_SHORTS.put("METRO", 'U'); TRANSPORT_MODES.put("METRO", Product.SUBWAY);
// TRAM // TRAM
TRANSPORT_MODE_SHORTS.put("TRAM", 'T'); TRANSPORT_MODES.put("TRAM", Product.TRAM);
TRANSPORT_MODE_SHORTS.put("TRAMWAY", 'T'); TRANSPORT_MODES.put("TRAMWAY", Product.TRAM);
// BUS // BUS
TRANSPORT_MODE_SHORTS.put("BUS", 'B'); TRANSPORT_MODES.put("BUS", Product.BUS);
TRANSPORT_MODE_SHORTS.put("COACH", 'B'); TRANSPORT_MODES.put("COACH", Product.BUS);
// CABLECAR // CABLECAR
TRANSPORT_MODE_SHORTS.put("TROLLEY", 'C'); TRANSPORT_MODES.put("TROLLEY", Product.CABLECAR);
TRANSPORT_MODE_SHORTS.put("TROLLEY_BUS", 'C'); TRANSPORT_MODES.put("TROLLEY_BUS", Product.CABLECAR);
} }
protected static double latLonToDouble(final int value) protected static double latLonToDouble(final int value)
@ -242,18 +242,17 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
return uri; return uri;
} }
private String createLineLabel(final String mode, final String number, final String name, final String operatorCode, final String codeActivity) private Line createLine(final String id, final String mode, final String number, final String name, final String operatorCode,
final String codeActivity)
{ {
final Character modePrefix = TRANSPORT_MODE_SHORTS.get(mode); final Product product = TRANSPORT_MODES.get(mode);
if (modePrefix == null) if (product == null)
throw new IllegalStateException("cannot normalize mode '" + mode + "' number '" + number + "'"); throw new IllegalStateException("cannot normalize mode '" + mode + "' number '" + number + "'");
final StringBuilder label = new StringBuilder(); final StringBuilder label = new StringBuilder();
label.append(modePrefix); if (number != null)
if (number != null && number.length() > 0)
{ {
label.append(number); label.append(number);
} }
@ -268,7 +267,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
label.append(name); label.append(name);
} }
return label.toString(); return new Line(id, product, label.toString());
} }
private List<Location> identifyLocation(final Location location) throws IOException private List<Location> identifyLocation(final Location location) throws IOException
@ -552,6 +551,9 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
network = null; network = null;
final JSONObject lineInfo = ptrInfo.getJSONObject("Line"); final JSONObject lineInfo = ptrInfo.getJSONObject("Line");
final String id = lineInfo.getString("id");
final String transportMode = ptrInfo.getString("TransportMode"); final String transportMode = ptrInfo.getString("TransportMode");
final String lineNumber = lineInfo.optString("Number"); final String lineNumber = lineInfo.optString("Number");
@ -566,9 +568,9 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
final String codeActivity = jsonOptString(ptrInfo, "CodeActivity"); final String codeActivity = jsonOptString(ptrInfo, "CodeActivity");
final String lineLabel = createLineLabel(transportMode, lineNumber, lineName, operatorCode, codeActivity); final Line line = createLine(id, transportMode, lineNumber, lineName, operatorCode, codeActivity);
final Line styledLine = new Line(line.id, line.product, line.label, lineStyle(network, line.product, line.label));
return new Line(lineInfo.getString("id"), lineLabel, lineStyle(network, lineLabel), null, null); return styledLine;
} }
private Location parseJsonTransportLocation(final JSONObject data) throws JSONException private Location parseJsonTransportLocation(final JSONObject data) throws JSONException

View file

@ -20,6 +20,8 @@ package de.schildbach.pte;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
/** /**
@ -44,16 +46,16 @@ public class AvvProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("Regionalbahn".equals(trainName) && symbol != null) if ("Regionalbahn".equals(trainName) && symbol != null)
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -46,28 +46,28 @@ public final class BahnProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'U'; return Product.SUBWAY;
if (value == 256) if (value == 256)
return 'T'; return Product.TRAM;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -169,19 +169,15 @@ public final class BahnProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(String type) protected Product normalizeType(String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
final char t = super.normalizeType(type);
if (t != 0)
return t;
if ("E".equals(ucType)) if ("E".equals(ucType))
return '?'; return null;
if ("N".equals(ucType)) if ("N".equals(ucType))
return '?'; return null;
return 0; return super.normalizeType(type);
} }
} }

View file

@ -24,6 +24,7 @@ import java.util.Set;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
@ -62,44 +63,44 @@ public class BayernProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("M".equals(trainType) && trainNum != null && trainName != null && trainName.endsWith("Meridian")) if ("M".equals(trainType) && trainNum != null && trainName != null && trainName.endsWith("Meridian"))
return "RM" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "M" + trainNum);
if ("ZUG".equals(trainType) && trainNum != null) if ("ZUG".equals(trainType) && trainNum != null)
return "R" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, trainNum);
} }
else if ("16".equals(mot)) else if ("16".equals(mot))
{ {
if ("EC".equals(trainType) && trainNum != null) if ("EC".equals(trainType) && trainNum != null)
return "IEC" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "EC" + trainNum);
if ("IC".equals(trainType) && trainNum != null) if ("IC".equals(trainType) && trainNum != null)
return "IIC" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "IC" + trainNum);
if ("ICE".equals(trainType) && trainNum != null) if ("ICE".equals(trainType) && trainNum != null)
return "IICE" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "ICE" + trainNum);
if ("CNL".equals(trainType) && trainNum != null) if ("CNL".equals(trainType) && trainNum != null)
return "ICNL" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "CNL" + trainNum);
if ("THA".equals(trainType) && trainNum != null) // Thalys if ("THA".equals(trainType) && trainNum != null) // Thalys
return "ITHA" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "THA" + trainNum);
if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse
return "ITGV" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "TGV" + trainNum);
if ("RJ".equals(trainType) && trainNum != null) // railjet if ("RJ".equals(trainType) && trainNum != null) // railjet
return "IRJ" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "RJ" + trainNum);
if ("WB".equals(trainType) && trainNum != null) // WESTbahn if ("WB".equals(trainType) && trainNum != null) // WESTbahn
return "IWB" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "WB" + trainNum);
if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express
return "IHKX" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "HKX" + trainNum);
if ("D".equals(trainType) && trainNum != null) // Schnellzug if ("D".equals(trainType) && trainNum != null) // Schnellzug
return "ID" + trainNum; return new Line(id, Product.HIGH_SPEED_TRAIN, "D" + trainNum);
if ("IR".equals(trainType) && trainNum != null) // InterRegio if ("IR".equals(trainType) && trainNum != null) // InterRegio
return "RIR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "IR" + trainNum);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
@Override @Override

View file

@ -55,24 +55,24 @@ public final class BvgProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 2) if (value == 2)
return 'U'; return Product.SUBWAY;
if (value == 4) if (value == 4)
return 'T'; return Product.TRAM;
if (value == 8) if (value == 8)
return 'B'; return Product.BUS;
if (value == 16) if (value == 16)
return 'F'; return Product.FERRY;
if (value == 32) if (value == 32)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 64) if (value == 64)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 128) if (value == 128)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -193,29 +193,29 @@ public final class BvgProvider extends AbstractHafasProvider
protected Line parseLineAndType(final String lineAndType) protected Line parseLineAndType(final String lineAndType)
{ {
if ("X#".equals(lineAndType)) if ("X#".equals(lineAndType))
return newLine('I', "X", null); // InterConnex return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
else else
return super.parseLineAndType(lineAndType); return super.parseLineAndType(lineAndType);
} }
@Override @Override
protected Line newLine(final char product, final String normalizedName, final String comment, final Attr... attrs) protected Line newLine(final Product product, final String normalizedName, final String comment, final Attr... attrs)
{ {
if (product == 'S' && "S41".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_CLOCKWISE)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_CLOCKWISE));
if (product == 'S' && "S42".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_ANTICLOCKWISE)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_ANTICLOCKWISE));
if (product == 'B' && "S41".equals(normalizedName)) if (product == Product.BUS && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE));
if (product == 'B' && "S42".equals(normalizedName)) if (product == Product.BUS && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE));
if (product == 'B' && "TXL".equals(normalizedName)) if (product == Product.BUS && "TXL".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == 'S' && "S9".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S9".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == 'S' && "S45".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S45".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
return super.newLine(product, normalizedName, comment, attrs); return super.newLine(product, normalizedName, comment, attrs);

View file

@ -46,30 +46,30 @@ public class DsbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) if (value == 128)
return 'B'; return Product.BUS;
if (value == 256) if (value == 256)
return 'B'; return Product.BUS;
if (value == 512) if (value == 512)
return 'F'; return Product.FERRY;
if (value == 1024) if (value == 1024)
return 'U'; return Product.SUBWAY;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -138,52 +138,48 @@ public class DsbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("ICL".equals(ucType)) if ("ICL".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("IB".equals(ucType)) if ("IB".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("SJ".equals(ucType)) if ("SJ".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("ØR".equals(ucType)) if ("ØR".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("RA".equals(ucType)) if ("RA".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("RX".equals(ucType)) if ("RX".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("PP".equals(ucType)) if ("PP".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("S-TOG".equals(ucType)) if ("S-TOG".equals(ucType))
return 'S'; return Product.SUBURBAN_TRAIN;
if ("BYBUS".equals(ucType)) if ("BYBUS".equals(ucType))
return 'B'; return Product.BUS;
if ("X-BUS".equals(ucType) || "X BUS".equals(ucType)) if ("X-BUS".equals(ucType) || "X BUS".equals(ucType))
return 'B'; return Product.BUS;
if ("HV-BUS".equals(ucType)) // Havnebus if ("HV-BUS".equals(ucType)) // Havnebus
return 'B'; return Product.BUS;
if ("T-BUS".equals(ucType)) // Togbus if ("T-BUS".equals(ucType)) // Togbus
return 'B'; return Product.BUS;
if ("TOGBUS".equals(ucType)) if ("TOGBUS".equals(ucType))
return 'B'; return Product.BUS;
if ("TELEBUS".equals(ucType)) if ("TELEBUS".equals(ucType))
return 'P'; return Product.ON_DEMAND;
if ("TELETAXI".equals(ucType)) if ("TELETAXI".equals(ucType))
return 'P'; return Product.ON_DEMAND;
if ("FÆRGE".equals(ucType)) if ("FÆRGE".equals(ucType))
return 'F'; return Product.FERRY;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -108,21 +108,21 @@ public class EireannProvider extends AbstractHafasProvider
{ {
final Matcher mLine = P_NORMALIZE_LINE.matcher(lineAndType); final Matcher mLine = P_NORMALIZE_LINE.matcher(lineAndType);
if (mLine.matches()) if (mLine.matches())
return newLine('B', mLine.group(1), null); return newLine(Product.BUS, mLine.group(1), null);
return super.parseLineAndType(lineAndType); return super.parseLineAndType(lineAndType);
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("COA".equals(ucType)) if ("COA".equals(ucType))
return 'B'; return Product.BUS;
if ("CIT".equals(ucType)) if ("CIT".equals(ucType))
return 'B'; return Product.BUS;
return 0; return null;
} }
} }

View file

@ -330,29 +330,29 @@ public class InvgProvider extends AbstractHafasProvider
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line); final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
if (mBus.matches()) if (mBus.matches())
{ {
final String lineStr = "B" + mBus.group(1); final String label = mBus.group(1);
return new Line(null, lineStr, lineStyle(null, lineStr)); return new Line(null, Product.BUS, label, lineStyle(null, Product.BUS, label));
} }
final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line); final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line);
if (mNachtbus.matches()) if (mNachtbus.matches())
{ {
final String lineStr = "BN" + mNachtbus.group(1); final String label = "N" + mNachtbus.group(1);
return new Line(null, lineStr, lineStyle(null, lineStr)); return new Line(null, Product.BUS, label, lineStyle(null, Product.BUS, label));
} }
final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line); final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line);
if (mBusS.matches()) if (mBusS.matches())
{ {
final String lineStr = "BS" + mBusS.group(1); final String label = "S" + mBusS.group(1);
return new Line(null, lineStr, lineStyle(null, lineStr)); return new Line(null, Product.BUS, label, lineStyle(null, Product.BUS, label));
} }
final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line); final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line);
if (mBusX.matches()) if (mBusX.matches())
{ {
final String lineStr = "BX" + mBusX.group(1); final String label = "X" + mBusX.group(1);
return new Line(null, lineStr, lineStyle(null, lineStr)); return new Line(null, Product.BUS, label, lineStyle(null, Product.BUS, label));
} }
} }
@ -360,12 +360,12 @@ public class InvgProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
if ("1".equals(type)) if ("1".equals(type))
return 'B'; return Product.BUS;
return 0; return null;
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -51,12 +51,12 @@ public class JetProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 4) if (value == 4)
return 'T'; return Product.TRAM;
if (value == 8) if (value == 8)
return 'B'; return Product.BUS;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -138,14 +138,14 @@ public class JetProvider extends AbstractHafasProvider
protected Line parseLineAndType(final String lineAndType) protected Line parseLineAndType(final String lineAndType)
{ {
if ("רק1#".equals(lineAndType)) if ("רק1#".equals(lineAndType))
return newLine('T', "רק1", null); return newLine(Product.TRAM, "רק1", null);
if ("א 11#".equals(lineAndType) || "11א#".equals(lineAndType)) if ("א 11#".equals(lineAndType) || "11א#".equals(lineAndType))
return newLine('B', "א11", null); return newLine(Product.BUS, "א11", null);
final Matcher mBus = P_NORMALIZE_BUS.matcher(lineAndType); final Matcher mBus = P_NORMALIZE_BUS.matcher(lineAndType);
if (mBus.matches()) if (mBus.matches())
return newLine('B', mBus.group(1), null); return newLine(Product.BUS, mBus.group(1), null);
throw new IllegalStateException("cannot normalize line#type '" + lineAndType + "'"); throw new IllegalStateException("cannot normalize line#type '" + lineAndType + "'");
} }

View file

@ -22,6 +22,7 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.Style.Shape; import de.schildbach.pte.dto.Style.Shape;
@ -54,17 +55,17 @@ public class KvvProvider extends AbstractEfaProvider
private static final Pattern P_LINE = Pattern.compile("(.*?)\\s+\\([\\w/]+\\)", Pattern.CASE_INSENSITIVE); private static final Pattern P_LINE = Pattern.compile("(.*?)\\s+\\([\\w/]+\\)", Pattern.CASE_INSENSITIVE);
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if (name != null) if (name != null)
{ {
final Matcher m = P_LINE.matcher(name); final Matcher m = P_LINE.matcher(name);
if (m.matches()) if (m.matches())
return super.parseLine(mot, symbol, m.group(1), longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, m.group(1), longName, trainType, trainNum, trainName);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
// TODO check for " (Ersatzverkehr)" // TODO check for " (Ersatzverkehr)"
} }

View file

@ -42,26 +42,26 @@ public class LuProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) if (value == 128)
return 'B'; return Product.BUS;
if (value == 256) if (value == 256)
return 'B'; return Product.BUS;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -132,26 +132,22 @@ public class LuProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("CRE".equals(ucType)) if ("CRE".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("CITYBUS".equals(ucType)) if ("CITYBUS".equals(ucType))
return 'B'; return Product.BUS;
if ("NIGHTBUS".equals(ucType)) if ("NIGHTBUS".equals(ucType))
return 'B'; return Product.BUS;
if ("DIFFBUS".equals(ucType)) if ("DIFFBUS".equals(ucType))
return 'B'; return Product.BUS;
if ("NAVETTE".equals(ucType)) if ("NAVETTE".equals(ucType))
return 'B'; return Product.BUS;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -22,6 +22,8 @@ import java.util.Map;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
/** /**
@ -51,27 +53,27 @@ public class MetProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("Regional Train :".equals(longName)) if ("Regional Train :".equals(longName))
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("Regional Train".equals(trainName)) if ("Regional Train".equals(trainName))
return "R"; return new Line(id, Product.REGIONAL_TRAIN, null);
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName)) if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
return "RV/Line"; return new Line(id, Product.REGIONAL_TRAIN, "V/Line");
} }
else if ("1".equals(mot)) else if ("1".equals(mot))
{ {
if (trainType == null && trainNum != null) if (trainType == null && trainNum != null)
return 'S' + trainNum; return new Line(id, Product.SUBURBAN_TRAIN, trainNum);
if ("Metropolitan Train".equals(trainName) && trainNum == null) if ("Metropolitan Train".equals(trainName) && trainNum == null)
return 'S' + Strings.nullToEmpty(name); return new Line(id, Product.SUBURBAN_TRAIN, Strings.nullToEmpty(name));
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -22,8 +22,10 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Position; import de.schildbach.pte.dto.Position;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
/** /**
@ -54,26 +56,26 @@ public class MvvProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("Mittelrheinbahn (trans regio)".equals(trainName)) if ("Mittelrheinbahn (trans regio)".equals(trainName))
return "RMiRhBa"; return new Line(id, Product.REGIONAL_TRAIN, "MiRhBa");
if ("Süd-Thüringen-Bahn".equals(longName)) if ("Süd-Thüringen-Bahn".equals(longName))
return "RSTB"; return new Line(id, Product.REGIONAL_TRAIN, "STB");
if ("agilis".equals(longName)) if ("agilis".equals(longName))
return "Ragilis"; return new Line(id, Product.REGIONAL_TRAIN, "agilis");
if ("SBB".equals(trainName)) if ("SBB".equals(trainName))
return "RSBB"; return new Line(id, Product.REGIONAL_TRAIN, "SBB");
if ("A".equals(trainNum)) if ("A".equals(trainNum))
return "SA"; return new Line(id, Product.SUBURBAN_TRAIN, "A");
if ("DB AG".equals(trainName)) if ("DB AG".equals(trainName))
return '?' + symbol; return new Line(id, null, symbol);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Pattern P_POSITION = Pattern.compile("(Fern|Regio|S-Bahn|U-Bahn|U\\d(?:/U\\d)*)\\s+(.*)"); private static final Pattern P_POSITION = Pattern.compile("(Fern|Regio|S-Bahn|U-Bahn|U\\d(?:/U\\d)*)\\s+(.*)");

View file

@ -50,24 +50,24 @@ public class NasaProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'T'; return Product.TRAM;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) // Rufbus if (value == 128) // Rufbus
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -167,44 +167,40 @@ public class NasaProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(String type) protected Product normalizeType(String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("ECW".equals(ucType)) if ("ECW".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("IXB".equals(ucType)) // ICE International if ("IXB".equals(ucType)) // ICE International
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("RRT".equals(ucType)) if ("RRT".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("DPF".equals(ucType)) // mit Dampflok bespannter Zug if ("DPF".equals(ucType)) // mit Dampflok bespannter Zug
return 'R'; return Product.REGIONAL_TRAIN;
if ("DAM".equals(ucType)) // Harzer Schmalspurbahnen: mit Dampflok bespannter Zug if ("DAM".equals(ucType)) // Harzer Schmalspurbahnen: mit Dampflok bespannter Zug
return 'R'; return Product.REGIONAL_TRAIN;
if ("TW".equals(ucType)) // Harzer Schmalspurbahnen: Triebwagen if ("TW".equals(ucType)) // Harzer Schmalspurbahnen: Triebwagen
return 'R'; return Product.REGIONAL_TRAIN;
if ("RR".equals(ucType)) // Polen if ("RR".equals(ucType)) // Polen
return 'R'; return Product.REGIONAL_TRAIN;
if ("BAHN".equals(ucType)) if ("BAHN".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("ZUGBAHN".equals(ucType)) if ("ZUGBAHN".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("DAMPFZUG".equals(ucType)) if ("DAMPFZUG".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("E".equals(ucType)) // Stadtbahn Karlsruhe: S4/S31/xxxxx if ("E".equals(ucType)) // Stadtbahn Karlsruhe: S4/S31/xxxxx
return 'S'; return Product.SUBURBAN_TRAIN;
if ("RUFBUS".equals(ucType)) // Rufbus if ("RUFBUS".equals(ucType)) // Rufbus
return 'B'; return Product.BUS;
if ("RBS".equals(ucType)) // Rufbus if ("RBS".equals(ucType)) // Rufbus
return 'B'; return Product.BUS;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -164,11 +164,13 @@ public interface NetworkProvider
* *
* @param network * @param network
* network to disambiguate line * network to disambiguate line
* @param line * @param product
* line to get style of * line product to get style of
* @param label
* line label to get style of, or null
* @return object containing background, foreground and optional border colors * @return object containing background, foreground and optional border colors
*/ */
Style lineStyle(String network, String line); Style lineStyle(String network, Product product, String label);
/** /**
* Gets the primary covered area of the network * Gets the primary covered area of the network

View file

@ -49,24 +49,24 @@ public class NriProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) // Air if (value == 1) // Air
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 4) if (value == 4)
return 'B'; return Product.BUS;
if (value == 8) if (value == 8)
return 'T'; return Product.TRAM;
if (value == 16) if (value == 16)
return 'U'; return Product.SUBWAY;
if (value == 32) if (value == 32)
return 'F'; return Product.FERRY;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'F'; return Product.FERRY;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -143,44 +143,44 @@ public class NriProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("AIR".equals(ucType)) if ("AIR".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("TRA".equals(ucType)) if ("TRA".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("TRAIN".equals(ucType)) if ("TRAIN".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("HEL".equals(ucType)) // Heli if ("HEL".equals(ucType)) // Heli
return 'R'; return Product.REGIONAL_TRAIN;
if ("U".equals(ucType)) if ("U".equals(ucType))
return 'U'; return Product.SUBWAY;
if ("TRAM".equals(ucType)) if ("TRAM".equals(ucType))
return 'T'; return Product.TRAM;
if ("MTR".equals(ucType)) if ("MTR".equals(ucType))
return 'T'; return Product.TRAM;
if (ucType.startsWith("BUS")) if (ucType.startsWith("BUS"))
return 'B'; return Product.BUS;
if ("EXP".equals(ucType)) if ("EXP".equals(ucType))
return 'F'; return Product.FERRY;
if ("EXP.BOAT".equals(ucType)) if ("EXP.BOAT".equals(ucType))
return 'F'; return Product.FERRY;
if ("FERRY".equals(ucType)) if ("FERRY".equals(ucType))
return 'F'; return Product.FERRY;
if ("FER".equals(ucType)) if ("FER".equals(ucType))
return 'F'; return Product.FERRY;
if ("SHIP".equals(ucType)) if ("SHIP".equals(ucType))
return 'F'; return Product.FERRY;
if ("SHI".equals(ucType)) if ("SHI".equals(ucType))
return 'F'; return Product.FERRY;
return 0; return null;
} }
} }

View file

@ -51,28 +51,28 @@ public class NsProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'U'; return Product.SUBWAY;
if (value == 256) if (value == 256)
return 'T'; return Product.TRAM;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -150,21 +150,17 @@ public class NsProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if (ucType.equals("SPR")) if (ucType.equals("SPR"))
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("E")) // Budapest, Ungarn if (ucType.equals("E")) // Budapest, Ungarn
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Avignon if (ucType.equals("N")) // Avignon
return 'R'; return Product.REGIONAL_TRAIN;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -23,6 +23,7 @@ import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryTripsContext; import de.schildbach.pte.dto.QueryTripsContext;
@ -57,37 +58,37 @@ public class NvbwProvider extends AbstractEfaProvider
private static final Pattern P_LINE_S_AVG_VBK = Pattern.compile("(S\\d+) \\((?:AVG|VBK)\\)"); private static final Pattern P_LINE_S_AVG_VBK = Pattern.compile("(S\\d+) \\((?:AVG|VBK)\\)");
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if (("ICE".equals(trainName) || "InterCityExpress".equals(trainName)) && trainNum == null) if (("ICE".equals(trainName) || "InterCityExpress".equals(trainName)) && trainNum == null)
return "IICE"; return new Line(id, Product.HIGH_SPEED_TRAIN, "ICE");
if ("InterCity".equals(trainName) && trainNum == null) if ("InterCity".equals(trainName) && trainNum == null)
return "IIC"; return new Line(id, Product.HIGH_SPEED_TRAIN, "IC");
if ("Fernreisezug externer EU".equals(trainName) && trainNum == null) if ("Fernreisezug externer EU".equals(trainName) && trainNum == null)
return "I"; return new Line(id, Product.HIGH_SPEED_TRAIN, null);
if ("SuperCity".equals(trainName) && trainNum == null) if ("SuperCity".equals(trainName) && trainNum == null)
return "ISC"; return new Line(id, Product.HIGH_SPEED_TRAIN, "SC");
if ("InterRegio".equals(longName) && symbol == null) if ("InterRegio".equals(longName) && symbol == null)
return "RIR"; return new Line(id, Product.REGIONAL_TRAIN, "IR");
if ("REGIOBAHN".equals(trainName) && trainNum == null) if ("REGIOBAHN".equals(trainName) && trainNum == null)
return "R"; return new Line(id, Product.REGIONAL_TRAIN, null);
if ("RR".equals(trainType) && trainNum == null) if ("RR".equals(trainType) && trainNum == null)
return "RRR"; return new Line(id, Product.REGIONAL_TRAIN, "RR");
if ("Meridian".equals(trainName) && symbol != null) if ("Meridian".equals(trainName) && symbol != null)
return "R" + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("CityBahn".equals(trainName) && trainNum == null) if ("CityBahn".equals(trainName) && trainNum == null)
return "RCB"; return new Line(id, Product.REGIONAL_TRAIN, "CB");
if ("Trilex".equals(trainName) && trainNum == null) if ("Trilex".equals(trainName) && trainNum == null)
return "RTLX"; return new Line(id, Product.REGIONAL_TRAIN, "TLX");
if ("Bay. Seenschifffahrt".equals(trainName) && symbol != null) if ("Bay. Seenschifffahrt".equals(trainName) && symbol != null)
return "F" + symbol; return new Line(id, Product.FERRY, symbol);
if ("Nahverkehrszug von Dritten".equals(trainName) && trainNum == null) if ("Nahverkehrszug von Dritten".equals(trainName) && trainNum == null)
return "?Zug"; return new Line(id, null, "Zug");
if ("DB".equals(trainName) && trainNum == null) if ("DB".equals(trainName) && trainNum == null)
return "?DB"; return new Line(id, null, "DB");
} }
else if ("1".equals(mot)) else if ("1".equals(mot))
{ {
@ -95,11 +96,11 @@ public class NvbwProvider extends AbstractEfaProvider
{ {
final Matcher m = P_LINE_S_AVG_VBK.matcher(symbol); final Matcher m = P_LINE_S_AVG_VBK.matcher(symbol);
if (m.matches()) if (m.matches())
return "S" + m.group(1); return new Line(id, Product.SUBURBAN_TRAIN, m.group(1));
} }
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
@Override @Override

View file

@ -96,32 +96,32 @@ public class NvvProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 16) if (value == 16)
return 'U'; return Product.SUBWAY;
if (value == 32) if (value == 32)
return 'T'; return Product.TRAM;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) if (value == 128)
return 'B'; return Product.BUS;
if (value == 256) if (value == 256)
return 'F'; return Product.FERRY;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
if (value == 1024) if (value == 1024)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 2048) if (value == 2048)
return 'R'; return Product.REGIONAL_TRAIN;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -195,23 +195,19 @@ public class NvvProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("U-BAHN".equals(ucType)) if ("U-BAHN".equals(ucType))
return 'U'; return Product.SUBWAY;
if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich
return 'B'; return Product.BUS;
if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt
return 'P'; return Product.ON_DEMAND;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -51,34 +51,34 @@ public class OebbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 32) if (value == 32)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) if (value == 128)
return 'F'; return Product.FERRY;
if (value == 256) if (value == 256)
return 'U'; return Product.SUBWAY;
if (value == 512) if (value == 512)
return 'T'; return Product.TRAM;
if (value == 1024) // Autoreisezug if (value == 1024) // Autoreisezug
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2048) if (value == 2048)
return 'P'; return Product.ON_DEMAND;
if (value == 4096) if (value == 4096)
return 'I'; return Product.HIGH_SPEED_TRAIN;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -194,76 +194,72 @@ public class OebbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if (ucType.equals("RR")) // Finnland, Connections only? if (ucType.equals("RR")) // Finnland, Connections only?
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("EE")) // Rumänien, Connections only? if (ucType.equals("EE")) // Rumänien, Connections only?
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("OZ")) // Schweden, Oeresundzug, Connections only? if (ucType.equals("OZ")) // Schweden, Oeresundzug, Connections only?
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("UUU")) // Italien, Nacht, Connections only? if (ucType.equals("UUU")) // Italien, Nacht, Connections only?
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("S2")) // Helsinki-Turku, Connections only? if (ucType.equals("S2")) // Helsinki-Turku, Connections only?
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("RE")) // RegionalExpress Deutschland if (ucType.equals("RE")) // RegionalExpress Deutschland
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("DPN")) // Connections only? TODO nicht evtl. doch eher ne S-Bahn? if (ucType.equals("DPN")) // Connections only? TODO nicht evtl. doch eher ne S-Bahn?
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("E")) // Budapest, Ungarn if (ucType.equals("E")) // Budapest, Ungarn
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("IP")) // Ozd, Ungarn if (ucType.equals("IP")) // Ozd, Ungarn
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Frankreich, Tours if (ucType.equals("N")) // Frankreich, Tours
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("DPF")) // VX=Vogtland Express, Connections only? if (ucType.equals("DPF")) // VX=Vogtland Express, Connections only?
return 'R'; return Product.REGIONAL_TRAIN;
if ("UAU".equals(ucType)) // Rußland if ("UAU".equals(ucType)) // Rußland
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("RSB")) // Schnellbahn Wien if (ucType.equals("RSB")) // Schnellbahn Wien
return 'S'; return Product.SUBURBAN_TRAIN;
if (ucType.equals("LKB")) // Connections only? if (ucType.equals("LKB")) // Connections only?
return 'T'; return Product.TRAM;
if (ucType.equals("OBU")) // Connections only? if (ucType.equals("OBU")) // Connections only?
return 'B'; return Product.BUS;
if (ucType.equals("O-BUS")) // Stadtbus if (ucType.equals("O-BUS")) // Stadtbus
return 'B'; return Product.BUS;
if (ucType.equals("O")) // Stadtbus if (ucType.equals("O")) // Stadtbus
return 'B'; return Product.BUS;
if (ucType.equals("SCH")) // Connections only? if (ucType.equals("SCH")) // Connections only?
return 'F'; return Product.FERRY;
if (ucType.equals("F")) // Fähre if (ucType.equals("F")) // Fähre
return 'F'; return Product.FERRY;
if (ucType.equals("LIF")) if (ucType.equals("LIF"))
return 'C'; return Product.CABLECAR;
if (ucType.equals("LIFT")) // Graz Uhrturm if (ucType.equals("LIFT")) // Graz Uhrturm
return 'C'; return Product.CABLECAR;
if (ucType.equals("SSB")) // Graz Schlossbergbahn if (ucType.equals("SSB")) // Graz Schlossbergbahn
return 'C'; return Product.CABLECAR;
final char t = super.normalizeType(type);
if (t != 0)
return t;
if (ucType.equals("U70")) // U.K., Connections only? if (ucType.equals("U70")) // U.K., Connections only?
return '?'; return null;
if (ucType.equals("X70")) // U.K., Connections only? if (ucType.equals("X70")) // U.K., Connections only?
return '?'; return null;
if (ucType.equals("R84")) // U.K., Connections only? if (ucType.equals("R84")) // U.K., Connections only?
return '?'; return null;
if (ucType.equals("S84")) // U.K., Connections only? if (ucType.equals("S84")) // U.K., Connections only?
return '?'; return null;
if (ucType.equals("T84")) // U.K., Connections only? if (ucType.equals("T84")) // U.K., Connections only?
return '?'; return null;
return 0; return super.normalizeType(type);
} }
} }

View file

@ -17,6 +17,7 @@
package de.schildbach.pte; package de.schildbach.pte;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.Style.Shape; import de.schildbach.pte.dto.Style.Shape;
@ -47,11 +48,11 @@ public class ParisProvider extends AbstractNavitiaProvider
} }
@Override @Override
protected Style getLineStyle(final char product, final String code, final String color) protected Style getLineStyle(final Product product, final String code, final String color)
{ {
switch (product) switch (product)
{ {
case 'S': case SUBURBAN_TRAIN:
{ {
// RER // RER
if (code.compareTo("F") < 0) if (code.compareTo("F") < 0)
@ -64,17 +65,17 @@ public class ParisProvider extends AbstractNavitiaProvider
return new Style(Shape.ROUNDED, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color)); return new Style(Shape.ROUNDED, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
} }
} }
case 'U': case SUBWAY:
{ {
// Metro // Metro
return new Style(Shape.CIRCLE, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.CIRCLE, Style.parseColor(color), computeForegroundColor(color));
} }
case 'T': case TRAM:
{ {
// Tram // Tram
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
} }
case 'B': case BUS:
{ {
// Bus + Noctilien // Bus + Noctilien
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));

View file

@ -43,22 +43,22 @@ public class PlProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 16) // Bus if (value == 16) // Bus
return 'B'; return Product.BUS;
if (value == 32) // AST, SEV if (value == 32) // AST, SEV
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -134,37 +134,33 @@ public class PlProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("AR".equals(ucType)) // Arriva Polaczen if ("AR".equals(ucType)) // Arriva Polaczen
return 'R'; return Product.REGIONAL_TRAIN;
if ("N".equals(ucType)) if ("N".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("KW".equals(ucType)) // Koleje Wielkopolskie if ("KW".equals(ucType)) // Koleje Wielkopolskie
return 'R'; return Product.REGIONAL_TRAIN;
if ("KS".equals(ucType)) // Koleje Śląskie if ("KS".equals(ucType)) // Koleje Śląskie
return 'R'; return Product.REGIONAL_TRAIN;
if ("E".equals(ucType)) if ("E".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("DB".equals(ucType)) if ("DB".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("REG".equals(ucType)) if ("REG".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("IRB".equals(ucType)) // interREGIO Bus if ("IRB".equals(ucType)) // interREGIO Bus
return 'B'; return Product.BUS;
if ("ZKA".equals(ucType)) // Zastępcza Komunikacja Autobusowa (Schienenersatzverkehr) if ("ZKA".equals(ucType)) // Zastępcza Komunikacja Autobusowa (Schienenersatzverkehr)
return 'B'; return Product.BUS;
if ("FRE".equals(ucType)) if ("FRE".equals(ucType))
return 'F'; return Product.FERRY;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -49,28 +49,28 @@ public class RsagProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'U'; return Product.SUBWAY;
if (value == 256) if (value == 256)
return 'T'; return Product.TRAM;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }

View file

@ -97,26 +97,22 @@ public class RtProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("E".equals(ucType)) // Romania, Croatia if ("E".equals(ucType)) // Romania, Croatia
return 'R'; return Product.REGIONAL_TRAIN;
if ("N".equals(ucType)) // Frankreich, Tours if ("N".equals(ucType)) // Frankreich, Tours
return 'R'; return Product.REGIONAL_TRAIN;
final char t = super.normalizeType(type);
if (t != 0)
return t;
if (ucType.equals("U70")) if (ucType.equals("U70"))
return '?'; return null;
if (ucType.equals("X70")) if (ucType.equals("X70"))
return '?'; return null;
if (ucType.equals("T84")) if (ucType.equals("T84"))
return '?'; return null;
return 0; return super.normalizeType(type);
} }
} }

View file

@ -43,28 +43,28 @@ public class SbbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'F'; return Product.FERRY;
if (value == 32) if (value == 32)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) if (value == 128)
return 'C'; return Product.CABLECAR;
if (value == 256) if (value == 256)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 512) if (value == 512)
return 'T'; return Product.TRAM;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -146,29 +146,25 @@ public class SbbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("IN".equals(ucType)) // Italien Roma-Lecce if ("IN".equals(ucType)) // Italien Roma-Lecce
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("E".equals(ucType)) if ("E".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("T".equals(ucType)) if ("T".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("TX".equals(ucType)) if ("TX".equals(ucType))
return 'B'; return Product.BUS;
if ("NFO".equals(ucType)) if ("NFO".equals(ucType))
return 'B'; return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus? if ("KB".equals(ucType)) // Kleinbus?
return 'B'; return Product.BUS;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -53,30 +53,30 @@ public class SeProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) // Flyg if (value == 1) // Flyg
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) // X2000 if (value == 2) // X2000
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) // Expressbus if (value == 8) // Expressbus
return 'B'; return Product.BUS;
if (value == 16) if (value == 16)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 32) // Tunnelbana if (value == 32) // Tunnelbana
return 'U'; return Product.SUBWAY;
if (value == 64) // Spårvagn if (value == 64) // Spårvagn
return 'T'; return Product.TRAM;
if (value == 128) if (value == 128)
return 'B'; return Product.BUS;
if (value == 256) if (value == 256)
return 'F'; return Product.FERRY;
if (value == 512) // Länstaxi if (value == 512) // Länstaxi
return 'F'; return Product.FERRY;
if (value == 1024) // Future if (value == 1024) // Future
return 'R'; return Product.REGIONAL_TRAIN;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -162,12 +162,12 @@ public class SeProvider extends AbstractHafasProvider
{ {
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line); final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
if (mBus.matches()) if (mBus.matches())
return newLine('B', mBus.group(1), null); return newLine(Product.BUS, mBus.group(1), null);
final Matcher mSubway = P_NORMALIZE_LINE_SUBWAY.matcher(line); final Matcher mSubway = P_NORMALIZE_LINE_SUBWAY.matcher(line);
if (mSubway.matches()) if (mSubway.matches())
return newLine('U', "T" + mSubway.group(1), null); return newLine(Product.SUBWAY, "T" + mSubway.group(1), null);
return newLine('?', line, null); return newLine(null, line, null);
} }
} }

View file

@ -305,7 +305,7 @@ public class SeptaProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
@ -313,39 +313,39 @@ public class SeptaProvider extends AbstractHafasProvider
// Regional // Regional
if (ucType.equals("RAI")) if (ucType.equals("RAI"))
return 'R'; return Product.REGIONAL_TRAIN;
// Subway // Subway
if (ucType.equals("BSS")) if (ucType.equals("BSS"))
return 'U'; return Product.SUBWAY;
if (ucType.equals("BSL")) if (ucType.equals("BSL"))
return 'U'; return Product.SUBWAY;
if (ucType.equals("MFL")) if (ucType.equals("MFL"))
return 'U'; return Product.SUBWAY;
// Tram // Tram
if (ucType.equals("TRM")) if (ucType.equals("TRM"))
return 'T'; return Product.TRAM;
if (ucType.equals("NHS")) // Tro NHSL if (ucType.equals("NHS")) // Tro NHSL
return 'T'; return Product.TRAM;
// Bus // Bus
if (ucType.equals("BUS")) if (ucType.equals("BUS"))
return 'B'; return Product.BUS;
if (ucType.equals("TRO")) if (ucType.equals("TRO"))
return 'B'; return Product.BUS;
// from Connections: // from Connections:
if (ucType.equals("RAIL")) if (ucType.equals("RAIL"))
return 'R'; return Product.REGIONAL_TRAIN;
if (ucType.equals("SUBWAY")) if (ucType.equals("SUBWAY"))
return 'U'; return Product.SUBWAY;
if (ucType.equals("TROLLEY")) if (ucType.equals("TROLLEY"))
return 'B'; return Product.BUS;
return 0; return null;
} }
} }

View file

@ -20,6 +20,8 @@ package de.schildbach.pte;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
/** /**
@ -56,60 +58,60 @@ public class SfProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if (("XAA".equals(symbol) || "Daly City / Fremont".equals(symbol)) && "Daly City / Fremont".equals(name)) if (("XAA".equals(symbol) || "Daly City / Fremont".equals(symbol)) && "Daly City / Fremont".equals(name))
return "RDALY/FRMT"; return new Line(id, Product.REGIONAL_TRAIN, "DALY/FRMT");
if (("FRE".equals(symbol) || "Fremont / Daly City".equals(symbol)) && "Fremont / Daly City".equals(name)) if (("FRE".equals(symbol) || "Fremont / Daly City".equals(symbol)) && "Fremont / Daly City".equals(name))
return "RFRMT/DALY"; return new Line(id, Product.REGIONAL_TRAIN, "FRMT/DALY");
if (("XAC".equals(symbol) || "Fremont / Richmond".equals(symbol)) && "Fremont / Richmond".equals(name)) if (("XAC".equals(symbol) || "Fremont / Richmond".equals(symbol)) && "Fremont / Richmond".equals(name))
return "RFRMT/RICH"; return new Line(id, Product.REGIONAL_TRAIN, "FRMT/RICH");
if (("XAD".equals(symbol) || "Richmond / Fremont".equals(symbol)) && "Richmond / Fremont".equals(name)) if (("XAD".equals(symbol) || "Richmond / Fremont".equals(symbol)) && "Richmond / Fremont".equals(name))
return "RRICH/FRMT"; return new Line(id, Product.REGIONAL_TRAIN, "RICH/FRMT");
if (("XAE".equals(symbol) || "Pittsburg Bay Point / SFO".equals(symbol)) && "Pittsburg Bay Point / SFO".equals(name)) if (("XAE".equals(symbol) || "Pittsburg Bay Point / SFO".equals(symbol)) && "Pittsburg Bay Point / SFO".equals(name))
return "RPITT/SFIA"; return new Line(id, Product.REGIONAL_TRAIN, "PITT/SFIA");
if (("SFI".equals(symbol) || "SFO / Pittsburg Bay Point".equals(symbol)) && "SFO / Pittsburg Bay Point".equals(name)) if (("SFI".equals(symbol) || "SFO / Pittsburg Bay Point".equals(symbol)) && "SFO / Pittsburg Bay Point".equals(name))
return "RSFIA/PITT"; return new Line(id, Product.REGIONAL_TRAIN, "SFIA/PITT");
if (("XAF".equals(symbol) || "Millbrae / Richmond".equals(symbol)) && "Millbrae / Richmond".equals(name)) if (("XAF".equals(symbol) || "Millbrae / Richmond".equals(symbol)) && "Millbrae / Richmond".equals(name))
return "RMLBR/RICH"; return new Line(id, Product.REGIONAL_TRAIN, "MLBR/RICH");
if (("XAG".equals(symbol) || "Richmond / Millbrae".equals(symbol)) && "Richmond / Millbrae".equals(name)) if (("XAG".equals(symbol) || "Richmond / Millbrae".equals(symbol)) && "Richmond / Millbrae".equals(name))
return "RRICH/MLBR"; return new Line(id, Product.REGIONAL_TRAIN, "RICH/MLBR");
if (("XAH".equals(symbol) || "Daly City / Dublin Pleasanton".equals(symbol)) && "Daly City / Dublin Pleasanton".equals(name)) if (("XAH".equals(symbol) || "Daly City / Dublin Pleasanton".equals(symbol)) && "Daly City / Dublin Pleasanton".equals(name))
return "RDALY/DUBL"; return new Line(id, Product.REGIONAL_TRAIN, "DALY/DUBL");
if (("XAI".equals(symbol) || "Dublin Pleasanton / Daly City".equals(symbol)) && "Dublin Pleasanton / Daly City".equals(name)) if (("XAI".equals(symbol) || "Dublin Pleasanton / Daly City".equals(symbol)) && "Dublin Pleasanton / Daly City".equals(name))
return "RDUBL/DALY"; return new Line(id, Product.REGIONAL_TRAIN, "DUBL/DALY");
if ("LOC".equals(symbol) && "LOCAL".equals(name)) if ("LOC".equals(symbol) && "LOCAL".equals(name))
return "RLocal"; return new Line(id, Product.REGIONAL_TRAIN, "Local");
if ("CAP".equals(symbol) && "CAPITOL".equals(name)) if ("CAP".equals(symbol) && "CAPITOL".equals(name))
return "RCapitol"; return new Line(id, Product.REGIONAL_TRAIN, "Capitol");
if ("OAK".equals(symbol) && "OAK / Coliseum".equals(name)) if ("OAK".equals(symbol) && "OAK / Coliseum".equals(name))
return "ROAK/Coliseum"; return new Line(id, Product.REGIONAL_TRAIN, "OAK/Coliseum");
if ("Muni Rail".equals(trainName) && symbol != null) // Muni if ("Muni Rail".equals(trainName) && symbol != null) // Muni
return 'T' + symbol; return new Line(id, Product.TRAM, symbol);
if (trainType == null && "F".equals(trainNum)) // Muni Historic Streetcar if (trainType == null && "F".equals(trainNum)) // Muni Historic Streetcar
return "TF"; return new Line(id, Product.TRAM, "F");
if (trainType == null && "J".equals(trainNum)) // Muni Metro if (trainType == null && "J".equals(trainNum)) // Muni Metro
return "TJ"; return new Line(id, Product.TRAM, "J");
if (trainType == null && "K".equals(trainNum)) // Muni Metro if (trainType == null && "K".equals(trainNum)) // Muni Metro
return "TK"; return new Line(id, Product.TRAM, "K");
if (trainType == null && "KT".equals(trainNum)) // Muni Metro if (trainType == null && "KT".equals(trainNum)) // Muni Metro
return "TKT"; return new Line(id, Product.TRAM, "KT");
if (trainType == null && "L".equals(trainNum)) // Muni Metro if (trainType == null && "L".equals(trainNum)) // Muni Metro
return "TL"; return new Line(id, Product.TRAM, "L");
if (trainType == null && "M".equals(trainNum)) // Muni Metro if (trainType == null && "M".equals(trainNum)) // Muni Metro
return "TM"; return new Line(id, Product.TRAM, "M");
if (trainType == null && "N".equals(trainNum)) // Muni Metro if (trainType == null && "N".equals(trainNum)) // Muni Metro
return "TN"; return new Line(id, Product.TRAM, "N");
if (trainType == null && "T".equals(trainNum)) // Muni Metro if (trainType == null && "T".equals(trainNum)) // Muni Metro
return "TT"; return new Line(id, Product.TRAM, "T");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -49,28 +49,28 @@ public class ShProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'U'; return Product.SUBWAY;
if (value == 256) if (value == 256)
return 'T'; return Product.TRAM;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }

View file

@ -52,22 +52,22 @@ public class SncbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 256) if (value == 256)
return 'U'; return Product.SUBWAY;
if (value == 512) if (value == 512)
return 'B'; return Product.BUS;
if (value == 1024) if (value == 1024)
return 'T'; return Product.TRAM;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -158,34 +158,30 @@ public class SncbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if (ucType.startsWith("IC ")) if (ucType.startsWith("IC "))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if ("THALYS".equals(ucType)) if ("THALYS".equals(ucType))
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (ucType.startsWith("IR ")) if (ucType.startsWith("IR "))
return 'R'; return Product.REGIONAL_TRAIN;
if ("L".equals(ucType)) if ("L".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("CR".equals(ucType)) if ("CR".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("TRN".equals(ucType)) if ("TRN".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("MÉTRO".equals(ucType)) if ("MÉTRO".equals(ucType))
return 'U'; return Product.SUBWAY;
if ("TRAMWAY".equals(ucType)) if ("TRAMWAY".equals(ucType))
return 'T'; return Product.TRAM;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -20,6 +20,7 @@ package de.schildbach.pte;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.Style.Shape; import de.schildbach.pte.dto.Style.Shape;
@ -28,17 +29,17 @@ import de.schildbach.pte.dto.Style.Shape;
*/ */
public class Standard public class Standard
{ {
public static final Map<Character, Style> STYLES = new HashMap<Character, Style>(); public static final Map<Product, Style> STYLES = new HashMap<Product, Style>();
static static
{ {
STYLES.put('I', new Style(Shape.RECT, Style.WHITE, Style.RED, Style.RED)); STYLES.put(Product.HIGH_SPEED_TRAIN, new Style(Shape.RECT, Style.WHITE, Style.RED, Style.RED));
STYLES.put('R', new Style(Shape.RECT, Style.GRAY, Style.WHITE)); STYLES.put(Product.REGIONAL_TRAIN, new Style(Shape.RECT, Style.GRAY, Style.WHITE));
STYLES.put('S', new Style(Shape.CIRCLE, Style.parseColor("#006e34"), Style.WHITE)); STYLES.put(Product.SUBURBAN_TRAIN, new Style(Shape.CIRCLE, Style.parseColor("#006e34"), Style.WHITE));
STYLES.put('U', new Style(Shape.RECT, Style.parseColor("#003090"), Style.WHITE)); STYLES.put(Product.SUBWAY, new Style(Shape.RECT, Style.parseColor("#003090"), Style.WHITE));
STYLES.put('T', new Style(Shape.RECT, Style.parseColor("#cc0000"), Style.WHITE)); STYLES.put(Product.TRAM, new Style(Shape.RECT, Style.parseColor("#cc0000"), Style.WHITE));
STYLES.put('B', new Style(Style.parseColor("#993399"), Style.WHITE)); STYLES.put(Product.BUS, new Style(Style.parseColor("#993399"), Style.WHITE));
STYLES.put('F', new Style(Shape.CIRCLE, Style.BLUE, Style.WHITE)); STYLES.put(Product.FERRY, new Style(Shape.CIRCLE, Style.BLUE, Style.WHITE));
STYLES.put('?', new Style(Style.DKGRAY, Style.WHITE)); STYLES.put(null, new Style(Style.DKGRAY, Style.WHITE));
} }
} }

View file

@ -49,22 +49,22 @@ public class StockholmProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) // Pendeltåg if (value == 1) // Pendeltåg
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 2) // Tunnelbana if (value == 2) // Tunnelbana
return 'U'; return Product.SUBWAY;
if (value == 4) // Lokalbanor if (value == 4) // Lokalbanor
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) // Bussar if (value == 8) // Bussar
return 'B'; return Product.BUS;
if (value == 16) // Flygbussar if (value == 16) // Flygbussar
return 'B'; return Product.BUS;
if (value == 32) if (value == 32)
return 'F'; return Product.FERRY;
if (value == 64) // Waxholmsbåtar if (value == 64) // Waxholmsbåtar
return 'F'; return Product.FERRY;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -153,9 +153,9 @@ public class StockholmProvider extends AbstractHafasProvider
if (type.length() > 0) if (type.length() > 0)
{ {
final char normalizedType = normalizeType(type); final Product product = normalizeType(type);
if (normalizedType != 0) if (product != null)
return newLine(normalizedType, number, null); return newLine(product, number, null);
} }
throw new IllegalStateException("cannot normalize type " + type + " number " + number + " line#type " + lineAndType); throw new IllegalStateException("cannot normalize type " + type + " number " + number + " line#type " + lineAndType);
@ -165,43 +165,43 @@ public class StockholmProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("TRAIN".equals(ucType)) if ("TRAIN".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("NÄRTRAFIKEN".equals(ucType)) if ("NÄRTRAFIKEN".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("LOKALTÅG".equals(ucType)) if ("LOKALTÅG".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("PENDELTÅG".equals(ucType)) if ("PENDELTÅG".equals(ucType))
return 'S'; return Product.SUBURBAN_TRAIN;
if ("METRO".equals(ucType)) if ("METRO".equals(ucType))
return 'U'; return Product.SUBWAY;
if ("TUNNELBANA".equals(ucType)) if ("TUNNELBANA".equals(ucType))
return 'U'; return Product.SUBWAY;
if ("TRAM".equals(ucType)) if ("TRAM".equals(ucType))
return 'T'; return Product.TRAM;
if ("BUS".equals(ucType)) if ("BUS".equals(ucType))
return 'B'; return Product.BUS;
if ("BUSS".equals(ucType)) if ("BUSS".equals(ucType))
return 'B'; return Product.BUS;
if ("FLYG".equals(ucType)) if ("FLYG".equals(ucType))
return 'B'; return Product.BUS;
if ("SHIP".equals(ucType)) if ("SHIP".equals(ucType))
return 'F'; return Product.FERRY;
if ("BÅT".equals(ucType)) if ("BÅT".equals(ucType))
return 'F'; return Product.FERRY;
if ("FÄRJA".equals(ucType)) if ("FÄRJA".equals(ucType))
return 'F'; return Product.FERRY;
return 0; return null;
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -17,6 +17,9 @@
package de.schildbach.pte; package de.schildbach.pte;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
@ -38,15 +41,15 @@ public class StvProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("M".equals(trainType) && trainNum != null) if ("M".equals(trainType) && trainNum != null)
return "RM" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "M" + trainNum);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
} }

View file

@ -20,6 +20,8 @@ package de.schildbach.pte;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
/** /**
@ -56,37 +58,37 @@ public class SydneyProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("1".equals(mot)) if ("1".equals(mot))
{ {
if ("BMT".equals(symbol) || "Blue Mountains Line".equals(symbol)) if ("BMT".equals(symbol) || "Blue Mountains Line".equals(symbol))
return "SBMT"; return new Line(id, Product.SUBURBAN_TRAIN, "BMT");
if ("CCN".equals(symbol) || "Central Coast & Newcastle Line".equals(symbol)) if ("CCN".equals(symbol) || "Central Coast & Newcastle Line".equals(symbol))
return "SCCN"; return new Line(id, Product.SUBURBAN_TRAIN, "CCN");
if ("SHL".equals(symbol) || "Southern Highlands Line".equals(symbol)) if ("SHL".equals(symbol) || "Southern Highlands Line".equals(symbol))
return "SSHL"; return new Line(id, Product.SUBURBAN_TRAIN, "SHL");
if ("SCO".equals(symbol) || "South Coast Line".equals(symbol)) if ("SCO".equals(symbol) || "South Coast Line".equals(symbol))
return "SSCO"; return new Line(id, Product.SUBURBAN_TRAIN, "SCO");
if ("HUN".equals(symbol) || "Hunter Line".equals(symbol)) if ("HUN".equals(symbol) || "Hunter Line".equals(symbol))
return "SHUN"; return new Line(id, Product.SUBURBAN_TRAIN, "HUN");
if ("T1".equals(symbol) || "T1 North Shore & Northern Line".equals(symbol) || "T1 Northern Line".equals(symbol) if ("T1".equals(symbol) || "T1 North Shore & Northern Line".equals(symbol) || "T1 Northern Line".equals(symbol)
|| "T1 Western Line".equals(symbol)) || "T1 Western Line".equals(symbol))
return "ST1"; return new Line(id, Product.SUBURBAN_TRAIN, "T1");
if ("T2".equals(symbol) || "T2 Inner West & South Line".equals(symbol) || "T2 Airport Line".equals(symbol)) if ("T2".equals(symbol) || "T2 Inner West & South Line".equals(symbol) || "T2 Airport Line".equals(symbol))
return "ST2"; return new Line(id, Product.SUBURBAN_TRAIN, "T2");
if ("T3".equals(symbol) || "T3 Bankstown Line".equals(symbol)) if ("T3".equals(symbol) || "T3 Bankstown Line".equals(symbol))
return "ST3"; return new Line(id, Product.SUBURBAN_TRAIN, "T3");
if ("T4".equals(symbol) || "T4 Eastern Suburbs & Illawarra Line".equals(symbol)) if ("T4".equals(symbol) || "T4 Eastern Suburbs & Illawarra Line".equals(symbol))
return "ST4"; return new Line(id, Product.SUBURBAN_TRAIN, "T4");
if ("T5".equals(symbol) || "T5 Cumberland Line".equals(symbol)) if ("T5".equals(symbol) || "T5 Cumberland Line".equals(symbol))
return "ST5"; return new Line(id, Product.SUBURBAN_TRAIN, "T5");
if ("T6".equals(symbol) || "T6 Carlingford Line".equals(symbol)) if ("T6".equals(symbol) || "T6 Carlingford Line".equals(symbol))
return "ST6"; return new Line(id, Product.SUBURBAN_TRAIN, "T6");
if ("T7".equals(symbol) || "T7 Olympic Park Line".equals(symbol)) if ("T7".equals(symbol) || "T7 Olympic Park Line".equals(symbol))
return "ST7"; return new Line(id, Product.SUBURBAN_TRAIN, "T7");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'"); + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
@ -94,7 +96,7 @@ public class SydneyProvider extends AbstractEfaProvider
else if ("4".equals(mot)) else if ("4".equals(mot))
{ {
if ("L1".equals(symbol) || "L1 Dulwich Hill Line".equals(symbol)) if ("L1".equals(symbol) || "L1 Dulwich Hill Line".equals(symbol))
return "TL1"; return new Line(id, Product.TRAM, "L1");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'"); + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
@ -102,29 +104,29 @@ public class SydneyProvider extends AbstractEfaProvider
else if ("9".equals(mot)) else if ("9".equals(mot))
{ {
if ("F1".equals(symbol) || "F1 Manly".equals(symbol)) if ("F1".equals(symbol) || "F1 Manly".equals(symbol))
return "FF1"; return new Line(id, Product.FERRY, "F1");
if ("F2".equals(symbol) || "F2 Taronga Zoo".equals(symbol)) if ("F2".equals(symbol) || "F2 Taronga Zoo".equals(symbol))
return "FF2"; return new Line(id, Product.FERRY, "F2");
if ("F3".equals(symbol) || "F3 Parramatta River".equals(symbol)) if ("F3".equals(symbol) || "F3 Parramatta River".equals(symbol))
return "FF3"; return new Line(id, Product.FERRY, "F3");
if ("F4".equals(symbol) || "F4 Darling Harbour".equals(symbol)) if ("F4".equals(symbol) || "F4 Darling Harbour".equals(symbol))
return "FF4"; return new Line(id, Product.FERRY, "F4");
if ("F5".equals(symbol) || "F5 Neutral Bay".equals(symbol)) if ("F5".equals(symbol) || "F5 Neutral Bay".equals(symbol))
return "FF5"; return new Line(id, Product.FERRY, "F5");
if ("F6".equals(symbol) || "F6 Mosman Bay".equals(symbol)) if ("F6".equals(symbol) || "F6 Mosman Bay".equals(symbol))
return "FF6"; return new Line(id, Product.FERRY, "F6");
if ("F7".equals(symbol) || "F7 Eastern Suburbs".equals(symbol)) if ("F7".equals(symbol) || "F7 Eastern Suburbs".equals(symbol))
return "FF7"; return new Line(id, Product.FERRY, "F7");
if ("Private ferry servic".equals(trainName) && symbol != null) if ("Private ferry servic".equals(trainName) && symbol != null)
return 'F' + symbol; return new Line(id, Product.FERRY, symbol);
if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name)) if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name))
return "FMFF"; return new Line(id, Product.FERRY, "MFF");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'"); + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -19,6 +19,7 @@ package de.schildbach.pte;
import java.util.Set; import java.util.Set;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
/** /**
@ -49,19 +50,19 @@ public class TfiProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("DART".equals(name)) if ("DART".equals(name))
return "SDART"; return new Line(id, Product.SUBURBAN_TRAIN, "DART");
if ("Rail".equals(trainName) && trainNum == null) if ("Rail".equals(trainName) && trainNum == null)
return "?Rail"; return new Line(id, null, "Rail");
if ("Train".equals(name) && "Train".equals(symbol)) if ("Train".equals(name) && "Train".equals(symbol))
return "?Train"; return new Line(id, null, "Train");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
} }

View file

@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
@ -71,16 +72,16 @@ public class TlemProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("1".equals(mot)) if ("1".equals(mot))
{ {
if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName))) if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName)))
return "SDLR"; return new Line(id, Product.SUBURBAN_TRAIN, "DLR");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -50,22 +50,22 @@ public class VbbProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 2) if (value == 2)
return 'U'; return Product.SUBWAY;
if (value == 4) if (value == 4)
return 'T'; return Product.TRAM;
if (value == 8) if (value == 8)
return 'B'; return Product.BUS;
if (value == 16) if (value == 16)
return 'F'; return Product.FERRY;
if (value == 32) if (value == 32)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 64) if (value == 64)
return 'R'; return Product.REGIONAL_TRAIN;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -176,7 +176,7 @@ public class VbbProvider extends AbstractHafasProvider
protected Line parseLineAndType(final String lineAndType) protected Line parseLineAndType(final String lineAndType)
{ {
if ("X#".equals(lineAndType)) if ("X#".equals(lineAndType))
return newLine('I', "X", null); // InterConnex return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
else else
return super.parseLineAndType(lineAndType); return super.parseLineAndType(lineAndType);
} }

View file

@ -17,6 +17,9 @@
package de.schildbach.pte; package de.schildbach.pte;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
@ -38,61 +41,61 @@ public class VblProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("BLS".equals(trainType) && trainNum != null) if ("BLS".equals(trainType) && trainNum != null)
return "RBLS" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BLS" + trainNum);
if ("ASM".equals(trainType) && trainNum != null) // Aare Seeland mobil if ("ASM".equals(trainType) && trainNum != null) // Aare Seeland mobil
return "RASM" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ASM" + trainNum);
if ("SOB".equals(trainType) && trainNum != null) // Schweizerische Südostbahn if ("SOB".equals(trainType) && trainNum != null) // Schweizerische Südostbahn
return "RSOB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "SOB" + trainNum);
if ("RhB".equals(trainType) && trainNum != null) // Rhätische Bahn if ("RhB".equals(trainType) && trainNum != null) // Rhätische Bahn
return "RRhB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "RhB" + trainNum);
if ("AB-".equals(trainType) && trainNum != null) // Appenzeller Bahnen if ("AB-".equals(trainType) && trainNum != null) // Appenzeller Bahnen
return "RAB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "AB" + trainNum);
if ("BDW".equals(trainType) && trainNum != null) // BDWM Transport if ("BDW".equals(trainType) && trainNum != null) // BDWM Transport
return "RBDW" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BDW" + trainNum);
if ("ZB".equals(trainType) && trainNum != null) // Zentralbahn if ("ZB".equals(trainType) && trainNum != null) // Zentralbahn
return "RZB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "ZB" + trainNum);
if ("TPF".equals(trainType) && trainNum != null) // Transports publics fribourgeois if ("TPF".equals(trainType) && trainNum != null) // Transports publics fribourgeois
return "RTPF" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TPF" + trainNum);
if ("MGB".equals(trainType) && trainNum != null) // Matterhorn Gotthard Bahn if ("MGB".equals(trainType) && trainNum != null) // Matterhorn Gotthard Bahn
return "RMGB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MGB" + trainNum);
if ("CJ".equals(trainType) && trainNum != null) // Chemins de fer du Jura if ("CJ".equals(trainType) && trainNum != null) // Chemins de fer du Jura
return "RCJ" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "CJ" + trainNum);
if ("LEB".equals(trainType) && trainNum != null) // Lausanne-Echallens-Bercher if ("LEB".equals(trainType) && trainNum != null) // Lausanne-Echallens-Bercher
return "RLEB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "LEB" + trainNum);
if ("FAR".equals(trainType) && trainNum != null) // Ferrovie Autolinee Regionali Ticinesi if ("FAR".equals(trainType) && trainNum != null) // Ferrovie Autolinee Regionali Ticinesi
return "RFAR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "FAR" + trainNum);
if ("WAB".equals(trainType) && trainNum != null) // Wengernalpbahn if ("WAB".equals(trainType) && trainNum != null) // Wengernalpbahn
return "RWAB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "WAB" + trainNum);
if ("JB".equals(trainType) && trainNum != null) // Jungfraubahn if ("JB".equals(trainType) && trainNum != null) // Jungfraubahn
return "RJB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "JB" + trainNum);
if ("NSt".equals(trainType) && trainNum != null) // Nyon-St-Cergue-Morez if ("NSt".equals(trainType) && trainNum != null) // Nyon-St-Cergue-Morez
return "RNSt" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "NSt" + trainNum);
if ("RA".equals(trainType) && trainNum != null) // Regionalps if ("RA".equals(trainType) && trainNum != null) // Regionalps
return "RRA" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "RA" + trainNum);
if ("TRN".equals(trainType) && trainNum != null) // Transport Publics Neuchâtelois if ("TRN".equals(trainType) && trainNum != null) // Transport Publics Neuchâtelois
return "RTRN" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TRN" + trainNum);
if ("TPC".equals(trainType) && trainNum != null) // Transports Publics du Chablais if ("TPC".equals(trainType) && trainNum != null) // Transports Publics du Chablais
return "RTPC" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TPC" + trainNum);
if ("MVR".equals(trainType) && trainNum != null) // Montreux-Vevey-Riviera if ("MVR".equals(trainType) && trainNum != null) // Montreux-Vevey-Riviera
return "RMVR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MVR" + trainNum);
if ("MOB".equals(trainType) && trainNum != null) // Montreux-Oberland Bernois if ("MOB".equals(trainType) && trainNum != null) // Montreux-Oberland Bernois
return "RMOB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "MOB" + trainNum);
if ("TRA".equals(trainType) && trainNum != null) // Transports Vallée de Joux-Yverdon-Ste-Croix if ("TRA".equals(trainType) && trainNum != null) // Transports Vallée de Joux-Yverdon-Ste-Croix
return "RTRA" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TRA" + trainNum);
if ("TMR".equals(trainType) && trainNum != null) // Transports de Martigny et Régions if ("TMR".equals(trainType) && trainNum != null) // Transports de Martigny et Régions
return "RTMR" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "TMR" + trainNum);
if ("GGB".equals(trainType) && trainNum != null) // Gornergratbahn if ("GGB".equals(trainType) && trainNum != null) // Gornergratbahn
return "RGGB" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "GGB" + trainNum);
if ("BLM".equals(trainType) && trainNum != null) // Lauterbrunnen-Mürren if ("BLM".equals(trainType) && trainNum != null) // Lauterbrunnen-Mürren
return "RBLM" + trainNum; return new Line(id, Product.REGIONAL_TRAIN, "BLM" + trainNum);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
} }

View file

@ -42,28 +42,28 @@ public class VbnProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'U'; return Product.SUBWAY;
if (value == 256) if (value == 256)
return 'T'; return Product.TRAM;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -129,17 +129,13 @@ public class VbnProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("SEILB".equals(ucType)) if ("SEILB".equals(ucType))
return 'C'; return Product.CABLECAR;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
@ -44,20 +45,20 @@ public class VgnProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("R5(z)".equals(trainNum)) if ("R5(z)".equals(trainNum))
return "RR5(z)"; return new Line(id, Product.REGIONAL_TRAIN, "R5(z)");
if ("R7(z)".equals(trainNum)) if ("R7(z)".equals(trainNum))
return "RR7(z)"; return new Line(id, Product.REGIONAL_TRAIN, "R7(z)");
if ("R8(z)".equals(trainNum)) if ("R8(z)".equals(trainNum))
return "RR8(z)"; return new Line(id, Product.REGIONAL_TRAIN, "R8(z)");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
@Override @Override

View file

@ -17,6 +17,9 @@
package de.schildbach.pte; package de.schildbach.pte;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
@ -36,22 +39,22 @@ public class VmsProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("Ilztalbahn".equals(trainName) && trainNum == null) if ("Ilztalbahn".equals(trainName) && trainNum == null)
return "RITB"; return new Line(id, Product.REGIONAL_TRAIN, "ITB");
if ("Meridian".equals(trainName) && trainNum == null) if ("Meridian".equals(trainName) && trainNum == null)
return "RM"; return new Line(id, Product.REGIONAL_TRAIN, "M");
if ("CityBahn".equals(trainName) && trainNum == null) if ("CityBahn".equals(trainName) && trainNum == null)
return "RCB"; return new Line(id, Product.REGIONAL_TRAIN, "CB");
if ("RE 3".equals(symbol) && "Zug".equals(longName)) if ("RE 3".equals(symbol) && "Zug".equals(longName))
return "RRE3"; return new Line(id, Product.REGIONAL_TRAIN, "RE3");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
} }

View file

@ -17,6 +17,9 @@
package de.schildbach.pte; package de.schildbach.pte;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
@ -38,15 +41,15 @@ public class VrnProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("InterRegio".equals(longName) && symbol == null) if ("InterRegio".equals(longName) && symbol == null)
return "RIR"; return new Line(id, Product.REGIONAL_TRAIN, "IR");
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
} }

View file

@ -22,6 +22,8 @@ import java.util.Map;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style; import de.schildbach.pte.dto.Style;
/** /**
@ -50,36 +52,36 @@ public class VrrProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if (trainType == null && "RB67/71".equals(trainNum)) if (trainType == null && "RB67/71".equals(trainNum))
return 'R' + trainNum; return new Line(id, Product.REGIONAL_TRAIN, trainNum);
if ("Regionalbahn".equals(trainName) && symbol != null) if ("Regionalbahn".equals(trainName) && symbol != null)
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if ("NordWestBahn".equals(trainName) && symbol != null) if ("NordWestBahn".equals(trainName) && symbol != null)
return 'R' + symbol; return new Line(id, Product.REGIONAL_TRAIN, symbol);
if (trainType == null && "SEV7".equals(trainNum)) if (trainType == null && "SEV7".equals(trainNum))
return 'B' + trainNum; return new Line(id, Product.BUS, trainNum);
if ("Zug".equals(longName)) if ("Zug".equals(longName))
return "?Zug"; return new Line(id, null, "Zug");
} }
else if ("11".equals(mot)) else if ("11".equals(mot))
{ {
// Wuppertaler Schwebebahn & SkyTrain D'dorf // Wuppertaler Schwebebahn & SkyTrain D'dorf
if ("Schwebebahn".equals(trainName) || (longName != null && longName.startsWith("Schwebebahn"))) if ("Schwebebahn".equals(trainName) || (longName != null && longName.startsWith("Schwebebahn")))
return 'C' + name; return new Line(id, Product.CABLECAR, name);
// H-Bahn TU Dortmund // H-Bahn TU Dortmund
if ("H-Bahn".equals(trainName) || (longName != null && longName.startsWith("H-Bahn"))) if ("H-Bahn".equals(trainName) || (longName != null && longName.startsWith("H-Bahn")))
return 'C' + name; return new Line(id, Product.CABLECAR, name);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();
@ -188,11 +190,11 @@ public class VrrProvider extends AbstractEfaProvider
} }
@Override @Override
public Style lineStyle(final String network, final String line) public Style lineStyle(final String network, final Product product, final String label)
{ {
if (line != null && line.startsWith("BSB")) if (product == Product.BUS && label != null && label.startsWith("SB"))
return super.lineStyle(network, "BSB"); return super.lineStyle(network, product, "SB");
return super.lineStyle(network, line); return super.lineStyle(network, product, label);
} }
} }

View file

@ -46,28 +46,28 @@ public class VsnProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 32) if (value == 32)
return 'B'; return Product.BUS;
if (value == 64) if (value == 64)
return 'F'; return Product.FERRY;
if (value == 128) if (value == 128)
return 'U'; return Product.SUBWAY;
if (value == 256) if (value == 256)
return 'T'; return Product.TRAM;
if (value == 512) if (value == 512)
return 'P'; return Product.ON_DEMAND;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -158,20 +158,16 @@ public class VsnProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("E".equals(ucType)) if ("E".equals(ucType))
return 'R'; return Product.REGIONAL_TRAIN;
if ("T84".equals(ucType)) if ("T84".equals(ucType))
return '?'; return null;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
} }

View file

@ -19,6 +19,9 @@ package de.schildbach.pte;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
@ -46,31 +49,31 @@ public class VvoProvider extends AbstractEfaProvider
} }
@Override @Override
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType, protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
final String trainNum, final String trainName) final String trainType, final String trainNum, final String trainName)
{ {
if ("0".equals(mot)) if ("0".equals(mot))
{ {
if ("Twoje Linie Kolejowe".equals(trainName) && symbol != null) if ("Twoje Linie Kolejowe".equals(trainName) && symbol != null)
return "ITLK" + symbol; return new Line(id, Product.HIGH_SPEED_TRAIN, "TLK" + symbol);
if ("Regionalbahn".equals(trainName) && trainNum == null) if ("Regionalbahn".equals(trainName) && trainNum == null)
return "R"; return new Line(id, Product.REGIONAL_TRAIN, null);
if ("Ostdeutsche Eisenbahn GmbH".equals(longName)) if ("Ostdeutsche Eisenbahn GmbH".equals(longName))
return "ROE"; return new Line(id, Product.REGIONAL_TRAIN, "OE");
if ("Meridian".equals(longName)) if ("Meridian".equals(longName))
return "RM"; return new Line(id, Product.REGIONAL_TRAIN, "M");
if ("trilex".equals(longName)) if ("trilex".equals(longName))
return "RTLX"; return new Line(id, Product.REGIONAL_TRAIN, "TLX");
if ("Trilex".equals(trainName) && trainNum == null) if ("Trilex".equals(trainName) && trainNum == null)
return "RTLX"; return new Line(id, Product.REGIONAL_TRAIN, "TLX");
if ("U28".equals(symbol)) // Nationalparkbahn if ("U28".equals(symbol)) // Nationalparkbahn
return "RU28"; return new Line(id, Product.REGIONAL_TRAIN, "U28");
if ("Fernbus".equals(trainName) && trainNum == null) if ("Fernbus".equals(trainName) && trainNum == null)
return "B" + trainName; return new Line(id, Product.BUS, trainName);
} }
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName); return super.parseLine(id, mot, symbol, name, longName, trainType, trainNum, trainName);
} }
} }

View file

@ -49,28 +49,28 @@ public class ZvvProvider extends AbstractHafasProvider
} }
@Override @Override
protected char intToProduct(final int value) protected Product intToProduct(final int value)
{ {
if (value == 1) if (value == 1)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 2) if (value == 2)
return 'I'; return Product.HIGH_SPEED_TRAIN;
if (value == 4) if (value == 4)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 8) if (value == 8)
return 'R'; return Product.REGIONAL_TRAIN;
if (value == 16) if (value == 16)
return 'F'; return Product.FERRY;
if (value == 32) if (value == 32)
return 'S'; return Product.SUBURBAN_TRAIN;
if (value == 64) if (value == 64)
return 'B'; return Product.BUS;
if (value == 128) if (value == 128)
return 'C'; return Product.CABLECAR;
if (value == 256) if (value == 256)
return 'U'; return Product.SUBWAY;
if (value == 512) if (value == 512)
return 'T'; return Product.TRAM;
throw new IllegalArgumentException("cannot handle: " + value); throw new IllegalArgumentException("cannot handle: " + value);
} }
@ -179,23 +179,23 @@ public class ZvvProvider extends AbstractHafasProvider
final String type = m.group(2); final String type = m.group(2);
if ("Bus".equals(type)) if ("Bus".equals(type))
return newLine('B', stripPrefix(number, "Bus"), null); return newLine(Product.BUS, stripPrefix(number, "Bus"), null);
if ("Bus-NF".equals(type)) if ("Bus-NF".equals(type))
return newLine('B', stripPrefix(number, "Bus", "Bus-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS); return newLine(Product.BUS, stripPrefix(number, "Bus", "Bus-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Tro".equals(type) || "Trolley".equals(type)) if ("Tro".equals(type) || "Trolley".equals(type))
return newLine('B', stripPrefix(number, "Tro"), null); return newLine(Product.BUS, stripPrefix(number, "Tro"), null);
if ("Tro-NF".equals(type)) if ("Tro-NF".equals(type))
return newLine('B', stripPrefix(number, "Tro", "Tro-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS); return newLine(Product.BUS, stripPrefix(number, "Tro", "Tro-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Trm".equals(type)) if ("Trm".equals(type))
return newLine('T', stripPrefix(number, "Trm"), null); return newLine(Product.TRAM, stripPrefix(number, "Trm"), null);
if ("Trm-NF".equals(type)) if ("Trm-NF".equals(type))
return newLine('T', stripPrefix(number, "Trm", "Trm-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS); return newLine(Product.TRAM, stripPrefix(number, "Trm", "Trm-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if (type.length() > 0) if (type.length() > 0)
{ {
final char normalizedType = normalizeType(type); final Product product = normalizeType(type);
if (normalizedType != 0) if (product != null)
return newLine(normalizedType, number, null); return newLine(product, number, null);
} }
throw new IllegalStateException("cannot normalize type " + type + " number " + number + " line#type " + lineAndType); throw new IllegalStateException("cannot normalize type " + type + " number " + number + " line#type " + lineAndType);
@ -214,34 +214,30 @@ public class ZvvProvider extends AbstractHafasProvider
} }
@Override @Override
protected char normalizeType(final String type) protected Product normalizeType(final String type)
{ {
final String ucType = type.toUpperCase(); final String ucType = type.toUpperCase();
if ("N".equals(ucType)) // Nachtbus if ("N".equals(ucType)) // Nachtbus
return 'B'; return Product.BUS;
if ("TX".equals(ucType)) if ("TX".equals(ucType))
return 'B'; return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus? if ("KB".equals(ucType)) // Kleinbus?
return 'B'; return Product.BUS;
if ("D-SCHIFF".equals(ucType)) if ("D-SCHIFF".equals(ucType))
return 'F'; return Product.FERRY;
if ("DAMPFSCH".equals(ucType)) if ("DAMPFSCH".equals(ucType))
return 'F'; return Product.FERRY;
if ("BERGBAHN".equals(ucType)) if ("BERGBAHN".equals(ucType))
return 'C'; return Product.CABLECAR;
if ("LSB".equals(ucType)) // Luftseilbahn if ("LSB".equals(ucType)) // Luftseilbahn
return 'C'; return Product.CABLECAR;
if ("SLB".equals(ucType)) // Sesselliftbahn if ("SLB".equals(ucType)) // Sesselliftbahn
return 'C'; return Product.CABLECAR;
final char t = super.normalizeType(type); return super.normalizeType(type);
if (t != 0)
return t;
return 0;
} }
private static final Map<String, Style> STYLES = new HashMap<String, Style>(); private static final Map<String, Style> STYLES = new HashMap<String, Style>();

View file

@ -22,6 +22,8 @@ import java.util.Set;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
@ -36,43 +38,50 @@ public final class Line implements Serializable, Comparable<Line>
private static final long serialVersionUID = -5642533805998375070L; private static final long serialVersionUID = -5642533805998375070L;
public final String id; public final String id;
private final transient char product; // TODO make true field public final Product product;
public final String label; public final String label;
public final Style style; public final Style style;
public final Set<Attr> attrs; public final Set<Attr> attrs;
public final String message; public final String message;
private static final String PRODUCT_ORDER = "IRSUTBPFC?";
public static final Line FOOTWAY = new Line(null, null, null); public static final Line FOOTWAY = new Line(null, null, null);
public static final Line TRANSFER = new Line(null, null, null); public static final Line TRANSFER = new Line(null, null, null);
public static final Line SECURE_CONNECTION = new Line(null, null, null); public static final Line SECURE_CONNECTION = new Line(null, null, null);
public static final Line DO_NOT_CHANGE = new Line(null, null, null); public static final Line DO_NOT_CHANGE = new Line(null, null, null);
public Line(final String id, final String label, final Style style) public Line(final String id, final Product product, final String label)
{ {
this(id, label, style, null, null); this(id, product, label, null, null, null);
} }
public Line(final String id, final String label, final Style style, final String message) public Line(final String id, final Product product, final String label, final Style style)
{ {
this(id, label, style, null, message); this(id, product, label, style, null, null);
} }
public Line(final String id, final String label, final Style style, final Set<Attr> attrs) public Line(final String id, final Product product, final String label, final Style style, final String message)
{ {
this(id, label, style, attrs, null); this(id, product, label, style, null, message);
} }
public Line(final String id, final String label, final Style style, final Set<Attr> attrs, final String message) public Line(final String id, final Product product, final String label, final Style style, final Set<Attr> attrs)
{
this(id, product, label, style, attrs, null);
}
public Line(final String id, final Product product, final String label, final Style style, final Set<Attr> attrs, final String message)
{ {
this.id = id; this.id = id;
this.product = product;
this.label = label; this.label = label;
this.style = style; this.style = style;
this.attrs = attrs; this.attrs = attrs;
this.message = message; this.message = message;
}
product = (label != null && label.length() >= 1) ? label.charAt(0) : '?'; public char productCode()
{
return product != null ? product.code : Product.UNKNOWN;
} }
public boolean hasAttr(final Attr attr) public boolean hasAttr(final Attr attr)
@ -88,31 +97,31 @@ public final class Line implements Serializable, Comparable<Line>
if (!(o instanceof Line)) if (!(o instanceof Line))
return false; return false;
final Line other = (Line) o; final Line other = (Line) o;
if (!Objects.equal(this.product, other.product))
return false;
return Objects.equal(this.label, other.label); return Objects.equal(this.label, other.label);
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
return Objects.hashCode(label); return Objects.hashCode(product, label);
} }
@Override @Override
public String toString() public String toString()
{ {
return MoreObjects.toStringHelper(this).addValue(label).toString(); return MoreObjects.toStringHelper(this) //
.addValue(product) //
.addValue(label) //
.toString();
} }
public int compareTo(final Line other) public int compareTo(final Line other)
{ {
final int productThis = PRODUCT_ORDER.indexOf(this.product); return ComparisonChain.start() //
final int productOther = PRODUCT_ORDER.indexOf(other.product); .compare(this.product, other.product, Ordering.natural().nullsLast()) //
.compare(this.label, other.label, Ordering.natural().nullsLast()) //
final int compareProduct = new Integer(productThis >= 0 ? productThis : Integer.MAX_VALUE).compareTo(productOther >= 0 ? productOther .result();
: Integer.MAX_VALUE);
if (compareProduct != 0)
return compareProduct;
return this.label.compareTo(other.label);
} }
} }

View file

@ -188,7 +188,7 @@ public final class Trip implements Serializable
for (final Leg leg : legs) for (final Leg leg : legs)
if (leg instanceof Public) if (leg instanceof Public)
products.add(Product.fromCode(((Public) leg).line.label.charAt(0))); products.add(((Public) leg).line.product);
return products; return products;
} }
@ -219,7 +219,9 @@ public final class Trip implements Serializable
final Public publicLeg = (Public) leg; final Public publicLeg = (Public) leg;
builder.append(publicLeg.departureStop.plannedDepartureTime.getTime()).append('-'); builder.append(publicLeg.departureStop.plannedDepartureTime.getTime()).append('-');
builder.append(publicLeg.arrivalStop.plannedArrivalTime.getTime()).append('-'); builder.append(publicLeg.arrivalStop.plannedArrivalTime.getTime()).append('-');
builder.append(publicLeg.line.label); final Line line = publicLeg.line;
builder.append(line.productCode());
builder.append(line.label);
} }
builder.append('|'); builder.append('|');