mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 08:19:51 +00:00
use common line parser for efa based apis
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@213 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
e8d2d60919
commit
8419822b30
4 changed files with 242 additions and 331 deletions
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
|
@ -82,194 +81,6 @@ public class GvhProvider extends AbstractEfaProvider
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
private static final Pattern P_LINE_RE = Pattern.compile("RE\\d+");
|
||||
private static final Pattern P_LINE_RB = Pattern.compile("RB\\d+");
|
||||
private static final Pattern P_LINE_U = Pattern.compile("U\\d+");
|
||||
|
||||
@Override
|
||||
protected String parseLine(final String number, final String symbol, final String mot)
|
||||
{
|
||||
if (!number.equals(symbol))
|
||||
throw new IllegalStateException("number " + number + ", symbol " + symbol);
|
||||
|
||||
final int t = Integer.parseInt(mot);
|
||||
|
||||
if (t == 0)
|
||||
{
|
||||
final String[] parts = number.split(" ", 3);
|
||||
final String type = parts[0];
|
||||
final String num = parts.length >= 2 ? parts[1] : null;
|
||||
final String str = type + (num != null ? num : "");
|
||||
|
||||
if (type.equals("EC")) // Eurocity
|
||||
return 'I' + str;
|
||||
if (type.equals("EN")) // Euronight
|
||||
return 'I' + str;
|
||||
if (type.equals("IC")) // Intercity
|
||||
return 'I' + str;
|
||||
if (type.equals("ICE")) // Intercity Express
|
||||
return 'I' + str;
|
||||
if (type.equals("CNL")) // City Night Line
|
||||
return 'I' + str;
|
||||
if (type.equals("THA")) // Thalys
|
||||
return 'I' + str;
|
||||
if (type.equals("TGV")) // TGV
|
||||
return 'I' + str;
|
||||
if (type.equals("RJ")) // railjet
|
||||
return 'I' + str;
|
||||
|
||||
if (type.equals("IR")) // Interregio
|
||||
return 'R' + str;
|
||||
if (type.equals("IRE")) // Interregio-Express
|
||||
return 'R' + str;
|
||||
if (type.equals("RE")) // Regional-Express
|
||||
return 'R' + str;
|
||||
if (P_LINE_RE.matcher(type).matches())
|
||||
return 'R' + str;
|
||||
if (type.equals("RB")) // Regionalbahn
|
||||
return 'R' + str;
|
||||
if (P_LINE_RB.matcher(type).matches())
|
||||
return 'R' + str;
|
||||
if (type.equals("R")) // Regionalzug
|
||||
return 'R' + str;
|
||||
if (type.equals("D")) // Schnellzug
|
||||
return 'R' + str;
|
||||
if (type.equals("WFB")) // Westfalenbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("NWB")) // NordWestBahn
|
||||
return 'R' + str;
|
||||
if (type.equals("ME")) // Metronom
|
||||
return 'R' + str;
|
||||
if (type.equals("ERB")) // eurobahn
|
||||
return 'R' + str;
|
||||
if (type.equals("CAN")) // cantus
|
||||
return 'R' + str;
|
||||
if (type.equals("HEX")) // Veolia Verkehr Sachsen-Anhalt
|
||||
return 'R' + str;
|
||||
if (type.equals("EB")) // Erfurter Bahn
|
||||
return 'R' + str;
|
||||
if (type.equals("MRB")) // Mittelrheinbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("ABR")) // ABELLIO Rail NRW
|
||||
return 'R' + str;
|
||||
if (type.equals("NEB")) // Niederbarnimer Eisenbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("OE")) // Ostdeutsche Eisenbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("MR")) // Märkische Regiobahn
|
||||
return 'R' + str;
|
||||
if (type.equals("OLA")) // Ostseeland Verkehr
|
||||
return 'R' + str;
|
||||
if (type.equals("UBB")) // Usedomer Bäderbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("EVB")) // Elbe-Weser
|
||||
return 'R' + str;
|
||||
if (type.equals("PEG")) // Prignitzer Eisenbahngesellschaft
|
||||
return 'R' + str;
|
||||
if (type.equals("RTB")) // Rurtalbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("STB")) // Süd-Thüringen-Bahn
|
||||
return 'R' + str;
|
||||
if (type.equals("HTB")) // Hellertalbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("VBG")) // Vogtlandbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("VX")) // Vogtland Express
|
||||
return 'R' + str;
|
||||
if (type.equals("CB")) // City-Bahn Chemnitz
|
||||
return 'R' + str;
|
||||
if (type.equals("VEC")) // VECTUS Verkehrsgesellschaft
|
||||
return 'R' + str;
|
||||
if (type.equals("HzL")) // Hohenzollerische Landesbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("OSB")) // Ortenau-S-Bahn
|
||||
return 'R' + str;
|
||||
if (type.equals("SBB")) // SBB
|
||||
return 'R' + str;
|
||||
if (type.equals("MBB")) // Mecklenburgische Bäderbahn Molli
|
||||
return 'R' + str;
|
||||
if (type.equals("OS")) // Regionalbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("SP"))
|
||||
return 'R' + str;
|
||||
if (type.equals("Dab")) // Daadetalbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("FEG")) // Freiberger Eisenbahngesellschaft
|
||||
return 'R' + str;
|
||||
if (type.equals("ARR")) // ARRIVA
|
||||
return 'R' + str;
|
||||
if (type.equals("HSB")) // Harzer Schmalspurbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("SBE")) // Sächsisch-Böhmische Eisenbahngesellschaft
|
||||
return 'R' + str;
|
||||
if (type.equals("ALX")) // Arriva-Länderbahn-Express
|
||||
return 'R' + str;
|
||||
if (type.equals("MEr")) // metronom regional
|
||||
return 'R' + str;
|
||||
if (type.equals("AKN")) // AKN Eisenbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("ZUG")) // Regionalbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("SOE")) // Sächsisch-Oberlausitzer Eisenbahngesellschaft
|
||||
return 'R' + str;
|
||||
if (type.equals("VIA")) // VIAS
|
||||
return 'R' + str;
|
||||
if (type.equals("BRB")) // Bayerische Regiobahn
|
||||
return 'R' + str;
|
||||
if (type.equals("BLB")) // Berchtesgadener Land Bahn
|
||||
return 'R' + str;
|
||||
if (type.equals("HLB")) // Hessische Landesbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("NOB")) // NordOstseeBahn
|
||||
return 'R' + str;
|
||||
if (type.equals("WEG")) // Wieslauftalbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("NBE")) // Nordbahn Eisenbahngesellschaft
|
||||
return 'R' + str;
|
||||
if (type.equals("VEN")) // Rhenus Veniro
|
||||
return 'R' + str;
|
||||
if (type.equals("DPN")) // Nahreisezug
|
||||
return 'R' + str;
|
||||
if (type.equals("SHB")) // Schleswig-Holstein-Bahn
|
||||
return 'R' + str;
|
||||
if (type.equals("RBG")) // Regental Bahnbetriebs GmbH
|
||||
return 'R' + str;
|
||||
if (type.equals("BOB")) // Bayerische Oberlandbahn
|
||||
return 'R' + str;
|
||||
if (type.equals("SWE")) // Südwestdeutsche Verkehrs AG
|
||||
return 'R' + str;
|
||||
if (type.equals("VE")) // Vetter
|
||||
return 'R' + str;
|
||||
if (type.equals("SDG")) // Sächsische Dampfeisenbahngesellschaft
|
||||
return 'R' + str;
|
||||
|
||||
if (type.equals("BSB")) // Breisgau-S-Bahn
|
||||
return 'S' + str;
|
||||
|
||||
if (P_LINE_U.matcher(type).matches())
|
||||
return 'U' + str;
|
||||
|
||||
if (type.equals("RT")) // RegioTram
|
||||
return 'T' + str;
|
||||
if (type.equals("STR")) // Nordhausen
|
||||
return 'T' + str;
|
||||
|
||||
throw new IllegalArgumentException("cannot normalize: " + number);
|
||||
}
|
||||
if (t == 1)
|
||||
return 'S' + number;
|
||||
if (t == 3 || t == 4)
|
||||
return 'T' + number;
|
||||
if (t == 5 || t == 6 || t == 7 || t == 10)
|
||||
return 'B' + number;
|
||||
if (t == 9)
|
||||
return 'F' + number;
|
||||
if (t == 11)
|
||||
return '?' + number;
|
||||
|
||||
throw new IllegalStateException("cannot normalize mot '" + mot + "' number '" + number + "'");
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryConnections(LocationType fromType, String from, LocationType viaType, String via, LocationType toType,
|
||||
String to, Date date, boolean dep, WalkSpeed walkSpeed) throws IOException
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue