mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 16:29:51 +00:00
Lines.
This commit is contained in:
parent
0ce2677615
commit
4a8a17f1fe
14 changed files with 98 additions and 75 deletions
|
@ -48,6 +48,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.Fare;
|
import de.schildbach.pte.dto.Fare;
|
||||||
|
@ -995,6 +996,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
private static final Pattern P_LINE_RB = Pattern.compile("RB ?\\d+");
|
private static final Pattern P_LINE_RB = Pattern.compile("RB ?\\d+");
|
||||||
private static final Pattern P_LINE_R = Pattern.compile("R ?\\d+");
|
private static final Pattern P_LINE_R = Pattern.compile("R ?\\d+");
|
||||||
private static final Pattern P_LINE_S = Pattern.compile("S ?\\d+");
|
private static final Pattern P_LINE_S = Pattern.compile("S ?\\d+");
|
||||||
|
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 String parseLine(final String mot, String symbol, final String name, final String longName, final String trainType,
|
||||||
|
@ -1034,9 +1036,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
if (trainName.equals("Vienna Airport Lines"))
|
if (trainName.equals("Vienna Airport Lines"))
|
||||||
return 'B' + str;
|
return 'B' + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
|
|
||||||
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
|
|
||||||
}
|
}
|
||||||
else if ("0".equals(mot))
|
else if ("0".equals(mot))
|
||||||
{
|
{
|
||||||
|
@ -1342,6 +1341,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
return "ROPX" + trainNum;
|
return "ROPX" + trainNum;
|
||||||
if (("V6".equals(trainType) || "vlexx".equals(trainName)) && trainNum != null)
|
if (("V6".equals(trainType) || "vlexx".equals(trainName)) && trainNum != null)
|
||||||
return "Rvlexx" + trainNum;
|
return "Rvlexx" + trainNum;
|
||||||
|
if (("ARZ".equals(trainType) || "Autoreisezug".equals(trainName)) && trainNum != null)
|
||||||
|
return "RARZ" + 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 'S' + trainNum;
|
||||||
|
@ -1389,9 +1390,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
// generic
|
// generic
|
||||||
if (trainName != null && trainType == null && trainNum == null)
|
if (trainName != null && trainType == null && trainNum == null)
|
||||||
return '?' + trainName;
|
return '?' + trainName;
|
||||||
|
|
||||||
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
|
|
||||||
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
|
|
||||||
}
|
}
|
||||||
else if ("1".equals(mot))
|
else if ("1".equals(mot))
|
||||||
{
|
{
|
||||||
|
@ -1399,8 +1397,16 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
return "S" + symbol;
|
return "S" + symbol;
|
||||||
if (name != null && P_LINE_S.matcher(name).matches())
|
if (name != null && P_LINE_S.matcher(name).matches())
|
||||||
return "S" + name;
|
return "S" + name;
|
||||||
if ("S-Bahn".equals(trainName) && trainNum == null)
|
if ("S-Bahn".equals(trainName))
|
||||||
return "SS";
|
return "SS" + Strings.nullToEmpty(trainNum);
|
||||||
|
if ("S5X".equals(symbol))
|
||||||
|
return "SS5X";
|
||||||
|
if (symbol != null && symbol.equals(name))
|
||||||
|
{
|
||||||
|
final Matcher m = P_LINE_S_DB.matcher(symbol);
|
||||||
|
if (m.matches())
|
||||||
|
return "S" + m.group(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ("2".equals(mot))
|
else if ("2".equals(mot))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2934,8 +2934,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
return 'B';
|
return 'B';
|
||||||
if ("LT".equals(ucType)) // Linien-Taxi
|
if ("LT".equals(ucType)) // Linien-Taxi
|
||||||
return 'B';
|
return 'B';
|
||||||
// if ("N".equals(normalizedType)) // Nachtbus
|
if ("NB".equals(ucType)) // Nachtbus Zürich
|
||||||
// return "B" + normalizedName;
|
return 'B';
|
||||||
|
|
||||||
// Phone
|
// Phone
|
||||||
if (ucType.startsWith("AST")) // Anruf-Sammel-Taxi
|
if (ucType.startsWith("AST")) // Anruf-Sammel-Taxi
|
||||||
|
|
|
@ -74,28 +74,28 @@ public class BayernProvider extends AbstractEfaProvider
|
||||||
}
|
}
|
||||||
else if ("16".equals(mot))
|
else if ("16".equals(mot))
|
||||||
{
|
{
|
||||||
if ("EC".equals(trainType))
|
if ("EC".equals(trainType) && trainNum != null)
|
||||||
return "IEC" + trainNum;
|
return "IEC" + trainNum;
|
||||||
if ("IC".equals(trainType))
|
if ("IC".equals(trainType) && trainNum != null)
|
||||||
return "IIC" + trainNum;
|
return "IIC" + trainNum;
|
||||||
if ("ICE".equals(trainType))
|
if ("ICE".equals(trainType) && trainNum != null)
|
||||||
return "IICE" + trainNum;
|
return "IICE" + trainNum;
|
||||||
if ("CNL".equals(trainType))
|
if ("CNL".equals(trainType) && trainNum != null)
|
||||||
return "ICNL" + trainNum;
|
return "ICNL" + trainNum;
|
||||||
if ("THA".equals(trainType)) // Thalys
|
if ("THA".equals(trainType) && trainNum != null) // Thalys
|
||||||
return "ITHA" + trainNum;
|
return "ITHA" + trainNum;
|
||||||
if ("TGV".equals(trainType)) // Train a grande Vitesse
|
if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse
|
||||||
return "ITGV" + trainNum;
|
return "ITGV" + trainNum;
|
||||||
if ("RJ".equals(trainType)) // railjet
|
if ("RJ".equals(trainType) && trainNum != null) // railjet
|
||||||
return "IRJ" + trainNum;
|
return "IRJ" + trainNum;
|
||||||
if ("WB".equals(trainType)) // WESTbahn
|
if ("WB".equals(trainType) && trainNum != null) // WESTbahn
|
||||||
return "IWB" + trainNum;
|
return "IWB" + trainNum;
|
||||||
if ("HKX".equals(trainType)) // Hamburg-Köln-Express
|
if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express
|
||||||
return "IHKX" + trainNum;
|
return "IHKX" + trainNum;
|
||||||
if ("D".equals(trainType)) // Schnellzug
|
if ("D".equals(trainType) && trainNum != null) // Schnellzug
|
||||||
return "ID" + trainNum;
|
return "ID" + trainNum;
|
||||||
|
|
||||||
if ("IR".equals(trainType)) // InterRegio
|
if ("IR".equals(trainType) && trainNum != null) // InterRegio
|
||||||
return "RIR" + trainNum;
|
return "RIR" + trainNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 com.google.common.base.Strings;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +63,13 @@ public class MetProvider extends AbstractEfaProvider
|
||||||
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
|
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
|
||||||
return "RV/Line";
|
return "RV/Line";
|
||||||
}
|
}
|
||||||
|
else if ("1".equals(mot))
|
||||||
|
{
|
||||||
|
if (trainType == null && trainNum != null)
|
||||||
|
return 'S' + trainNum;
|
||||||
|
if ("Metropolitan Train".equals(trainName) && trainNum == null)
|
||||||
|
return 'S' + Strings.nullToEmpty(name);
|
||||||
|
}
|
||||||
|
|
||||||
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
|
@ -52,6 +54,8 @@ public class NvbwProvider extends AbstractEfaProvider
|
||||||
return NETWORK_ID;
|
return NETWORK_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType,
|
||||||
final String trainNum, final String trainName)
|
final String trainNum, final String trainName)
|
||||||
|
@ -66,7 +70,7 @@ public class NvbwProvider extends AbstractEfaProvider
|
||||||
return "I";
|
return "I";
|
||||||
if ("SuperCity".equals(trainName) && trainNum == null)
|
if ("SuperCity".equals(trainName) && trainNum == null)
|
||||||
return "ISC";
|
return "ISC";
|
||||||
if ("InterRegio".equals(longName))
|
if ("InterRegio".equals(longName) && symbol == null)
|
||||||
return "RIR";
|
return "RIR";
|
||||||
if ("REGIOBAHN".equals(trainName) && trainNum == null)
|
if ("REGIOBAHN".equals(trainName) && trainNum == null)
|
||||||
return "R";
|
return "R";
|
||||||
|
@ -85,6 +89,15 @@ public class NvbwProvider extends AbstractEfaProvider
|
||||||
if ("DB".equals(trainName) && trainNum == null)
|
if ("DB".equals(trainName) && trainNum == null)
|
||||||
return "?DB";
|
return "?DB";
|
||||||
}
|
}
|
||||||
|
else if ("1".equals(mot))
|
||||||
|
{
|
||||||
|
if (symbol != null && symbol.equals(name))
|
||||||
|
{
|
||||||
|
final Matcher m = P_LINE_S_AVG_VBK.matcher(symbol);
|
||||||
|
if (m.matches())
|
||||||
|
return "S" + m.group(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,8 @@ public class PlProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
if ("IRB".equals(ucType)) // interREGIO Bus
|
if ("IRB".equals(ucType)) // interREGIO Bus
|
||||||
return 'B';
|
return 'B';
|
||||||
|
if ("ZKA".equals(ucType)) // Zastępcza Komunikacja Autobusowa (Schienenersatzverkehr)
|
||||||
|
return 'B';
|
||||||
|
|
||||||
if ("FRE".equals(ucType))
|
if ("FRE".equals(ucType))
|
||||||
return 'F';
|
return 'F';
|
||||||
|
|
|
@ -117,6 +117,8 @@ public class SydneyProvider extends AbstractEfaProvider
|
||||||
return "FF7";
|
return "FF7";
|
||||||
if ("Private ferry servic".equals(trainName) && symbol != null)
|
if ("Private ferry servic".equals(trainName) && symbol != null)
|
||||||
return 'F' + symbol;
|
return 'F' + symbol;
|
||||||
|
if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name))
|
||||||
|
return "FMFF";
|
||||||
|
|
||||||
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 + "'");
|
||||||
|
|
|
@ -54,8 +54,12 @@ public class TfiProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
if ("0".equals(mot))
|
if ("0".equals(mot))
|
||||||
{
|
{
|
||||||
|
if ("DART".equals(name))
|
||||||
|
return "SDART";
|
||||||
if ("Rail".equals(trainName) && trainNum == null)
|
if ("Rail".equals(trainName) && trainNum == null)
|
||||||
return "RRail";
|
return "?Rail";
|
||||||
|
if ("Train".equals(name) && "Train".equals(symbol))
|
||||||
|
return "?Train";
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
||||||
|
|
|
@ -70,6 +70,19 @@ public class TlemProvider extends AbstractEfaProvider
|
||||||
return Product.ALL;
|
return Product.ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType,
|
||||||
|
final String trainNum, final String trainName)
|
||||||
|
{
|
||||||
|
if ("1".equals(mot))
|
||||||
|
{
|
||||||
|
if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName)))
|
||||||
|
return "SDLR";
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.parseLine(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>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -36,17 +36,4 @@ public class VmobilProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return NETWORK_ID;
|
return NETWORK_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType,
|
|
||||||
final String trainNum, final String trainName)
|
|
||||||
{
|
|
||||||
if ("0".equals(mot))
|
|
||||||
{
|
|
||||||
if ("ZUG".equals(trainType))
|
|
||||||
return 'R' + symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,17 @@ public class VrnProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return NETWORK_ID;
|
return NETWORK_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String parseLine(final String mot, final String symbol, final String name, final String longName, final String trainType,
|
||||||
|
final String trainNum, final String trainName)
|
||||||
|
{
|
||||||
|
if ("0".equals(mot))
|
||||||
|
{
|
||||||
|
if ("InterRegio".equals(longName) && symbol == null)
|
||||||
|
return "RIR";
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.parseLine(mot, symbol, name, longName, trainType, trainNum, trainName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,12 +207,8 @@ public class ZvvProvider extends AbstractHafasProvider
|
||||||
private String stripPrefix(final String str, final String... prefixes)
|
private String stripPrefix(final String str, final String... prefixes)
|
||||||
{
|
{
|
||||||
for (final String prefix : prefixes)
|
for (final String prefix : prefixes)
|
||||||
{
|
if (str.startsWith(prefix))
|
||||||
if (str.equals(prefix))
|
return str.substring(prefix.length());
|
||||||
return "";
|
|
||||||
if (str.startsWith(prefix + ' '))
|
|
||||||
return str.substring(prefix.length() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -222,36 +218,12 @@ public class ZvvProvider extends AbstractHafasProvider
|
||||||
{
|
{
|
||||||
final String ucType = type.toUpperCase();
|
final String ucType = type.toUpperCase();
|
||||||
|
|
||||||
// E-Bus: Bus, Tram oder Zug?
|
|
||||||
|
|
||||||
if ("S-BAHN".equals(ucType))
|
|
||||||
return 'S';
|
|
||||||
|
|
||||||
if ("T".equals(ucType))
|
|
||||||
return 'T';
|
|
||||||
if ("TRM".equals(ucType))
|
|
||||||
return 'T';
|
|
||||||
if ("TRM-NF".equals(ucType)) // Niederflur
|
|
||||||
return 'T';
|
|
||||||
|
|
||||||
if ("BUS-NF".equals(ucType)) // Niederflur
|
|
||||||
return 'B';
|
|
||||||
if ("TRO-NF".equals(ucType)) // Niederflur
|
|
||||||
return 'B';
|
|
||||||
if ("N".equals(ucType)) // Nachtbus
|
if ("N".equals(ucType)) // Nachtbus
|
||||||
return 'B';
|
return 'B';
|
||||||
if ("BUXI".equals(ucType))
|
|
||||||
return 'B';
|
|
||||||
if ("TX".equals(ucType))
|
if ("TX".equals(ucType))
|
||||||
return 'B';
|
return 'B';
|
||||||
if ("E-BUS".equals(ucType))
|
|
||||||
return 'B';
|
|
||||||
if ("TROLLEY".equals(ucType))
|
|
||||||
return 'B';
|
|
||||||
if ("KB".equals(ucType)) // Kleinbus?
|
if ("KB".equals(ucType)) // Kleinbus?
|
||||||
return 'B';
|
return 'B';
|
||||||
if ("EE".equals(ucType))
|
|
||||||
return 'B';
|
|
||||||
|
|
||||||
if ("D-SCHIFF".equals(ucType))
|
if ("D-SCHIFF".equals(ucType))
|
||||||
return 'F';
|
return 'F';
|
||||||
|
@ -265,13 +237,6 @@ public class ZvvProvider extends AbstractHafasProvider
|
||||||
if ("SLB".equals(ucType)) // Sesselliftbahn
|
if ("SLB".equals(ucType)) // Sesselliftbahn
|
||||||
return 'C';
|
return 'C';
|
||||||
|
|
||||||
if ("UNB".equals(ucType))
|
|
||||||
return '?';
|
|
||||||
if ("UUU".equals(ucType))
|
|
||||||
return '?';
|
|
||||||
if ("???".equals(ucType))
|
|
||||||
return '?';
|
|
||||||
|
|
||||||
final char t = super.normalizeType(type);
|
final char t = super.normalizeType(type);
|
||||||
if (t != 0)
|
if (t != 0)
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -181,4 +181,13 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest
|
||||||
print(result);
|
print(result);
|
||||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void tripPforzheimToKarlsruhe() throws Exception
|
||||||
|
{
|
||||||
|
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "7900050"), null,
|
||||||
|
new Location(LocationType.STATION, "7000090"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||||
|
print(result);
|
||||||
|
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue