This commit is contained in:
Andreas Schildbach 2015-01-30 10:54:45 +01:00
parent 0ce2677615
commit 4a8a17f1fe
14 changed files with 98 additions and 75 deletions

View file

@ -48,6 +48,7 @@ import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import de.schildbach.pte.dto.Departure;
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_R = Pattern.compile("R ?\\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+");
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"))
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))
{
@ -1342,6 +1341,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
return "ROPX" + trainNum;
if (("V6".equals(trainType) || "vlexx".equals(trainName)) && trainNum != null)
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
return 'S' + trainNum;
@ -1389,9 +1390,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
// generic
if (trainName != null && trainType == null && trainNum == null)
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))
{
@ -1399,8 +1397,16 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
return "S" + symbol;
if (name != null && P_LINE_S.matcher(name).matches())
return "S" + name;
if ("S-Bahn".equals(trainName) && trainNum == null)
return "SS";
if ("S-Bahn".equals(trainName))
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))
{

View file

@ -2934,8 +2934,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
return 'B';
if ("LT".equals(ucType)) // Linien-Taxi
return 'B';
// if ("N".equals(normalizedType)) // Nachtbus
// return "B" + normalizedName;
if ("NB".equals(ucType)) // Nachtbus Zürich
return 'B';
// Phone
if (ucType.startsWith("AST")) // Anruf-Sammel-Taxi

View file

@ -74,28 +74,28 @@ public class BayernProvider extends AbstractEfaProvider
}
else if ("16".equals(mot))
{
if ("EC".equals(trainType))
if ("EC".equals(trainType) && trainNum != null)
return "IEC" + trainNum;
if ("IC".equals(trainType))
if ("IC".equals(trainType) && trainNum != null)
return "IIC" + trainNum;
if ("ICE".equals(trainType))
if ("ICE".equals(trainType) && trainNum != null)
return "IICE" + trainNum;
if ("CNL".equals(trainType))
if ("CNL".equals(trainType) && trainNum != null)
return "ICNL" + trainNum;
if ("THA".equals(trainType)) // Thalys
if ("THA".equals(trainType) && trainNum != null) // Thalys
return "ITHA" + trainNum;
if ("TGV".equals(trainType)) // Train a grande Vitesse
if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse
return "ITGV" + trainNum;
if ("RJ".equals(trainType)) // railjet
if ("RJ".equals(trainType) && trainNum != null) // railjet
return "IRJ" + trainNum;
if ("WB".equals(trainType)) // WESTbahn
if ("WB".equals(trainType) && trainNum != null) // WESTbahn
return "IWB" + trainNum;
if ("HKX".equals(trainType)) // Hamburg-Köln-Express
if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express
return "IHKX" + trainNum;
if ("D".equals(trainType)) // Schnellzug
if ("D".equals(trainType) && trainNum != null) // Schnellzug
return "ID" + trainNum;
if ("IR".equals(trainType)) // InterRegio
if ("IR".equals(trainType) && trainNum != null) // InterRegio
return "RIR" + trainNum;
}

View file

@ -20,6 +20,8 @@ package de.schildbach.pte;
import java.util.HashMap;
import java.util.Map;
import com.google.common.base.Strings;
import de.schildbach.pte.dto.Style;
/**
@ -61,6 +63,13 @@ public class MetProvider extends AbstractEfaProvider
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
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);
}

View file

@ -20,6 +20,8 @@ package de.schildbach.pte;
import java.io.IOException;
import java.util.Date;
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.Product;
@ -52,6 +54,8 @@ public class NvbwProvider extends AbstractEfaProvider
return NETWORK_ID;
}
private static final Pattern P_LINE_S_AVG_VBK = Pattern.compile("(S\\d+) \\((?:AVG|VBK)\\)");
@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)
@ -66,7 +70,7 @@ public class NvbwProvider extends AbstractEfaProvider
return "I";
if ("SuperCity".equals(trainName) && trainNum == null)
return "ISC";
if ("InterRegio".equals(longName))
if ("InterRegio".equals(longName) && symbol == null)
return "RIR";
if ("REGIOBAHN".equals(trainName) && trainNum == null)
return "R";
@ -85,6 +89,15 @@ public class NvbwProvider extends AbstractEfaProvider
if ("DB".equals(trainName) && trainNum == null)
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);
}

View file

@ -155,6 +155,8 @@ public class PlProvider extends AbstractHafasProvider
if ("IRB".equals(ucType)) // interREGIO Bus
return 'B';
if ("ZKA".equals(ucType)) // Zastępcza Komunikacja Autobusowa (Schienenersatzverkehr)
return 'B';
if ("FRE".equals(ucType))
return 'F';

View file

@ -149,7 +149,7 @@ public class StockholmProvider extends AbstractHafasProvider
if (m.matches())
{
final String type = m.group(1);
final String number = m.group(2).replaceAll("\\s+", " ");
final String number = m.group(2).replaceAll("\\s+", "");
if (type.length() > 0)
{

View file

@ -117,6 +117,8 @@ public class SydneyProvider extends AbstractEfaProvider
return "FF7";
if ("Private ferry servic".equals(trainName) && symbol != null)
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
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");

View file

@ -54,8 +54,12 @@ public class TfiProvider extends AbstractEfaProvider
{
if ("0".equals(mot))
{
if ("DART".equals(name))
return "SDART";
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);

View file

@ -70,6 +70,19 @@ public class TlemProvider extends AbstractEfaProvider
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>();
static

View file

@ -36,17 +36,4 @@ public class VmobilProvider extends AbstractEfaProvider
{
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);
}
}

View file

@ -36,4 +36,17 @@ public class VrnProvider extends AbstractEfaProvider
{
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);
}
}

View file

@ -175,7 +175,7 @@ public class ZvvProvider extends AbstractHafasProvider
final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType);
if (m.matches())
{
final String number = m.group(1).replaceAll("\\s+", " ");
final String number = m.group(1).replaceAll("\\s+", "");
final String type = m.group(2);
if ("Bus".equals(type))
@ -207,12 +207,8 @@ public class ZvvProvider extends AbstractHafasProvider
private String stripPrefix(final String str, final String... prefixes)
{
for (final String prefix : prefixes)
{
if (str.equals(prefix))
return "";
if (str.startsWith(prefix + ' '))
return str.substring(prefix.length() + 1);
}
if (str.startsWith(prefix))
return str.substring(prefix.length());
return str;
}
@ -222,36 +218,12 @@ public class ZvvProvider extends AbstractHafasProvider
{
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
return 'B';
if ("BUXI".equals(ucType))
return 'B';
if ("TX".equals(ucType))
return 'B';
if ("E-BUS".equals(ucType))
return 'B';
if ("TROLLEY".equals(ucType))
return 'B';
if ("KB".equals(ucType)) // Kleinbus?
return 'B';
if ("EE".equals(ucType))
return 'B';
if ("D-SCHIFF".equals(ucType))
return 'F';
@ -265,13 +237,6 @@ public class ZvvProvider extends AbstractHafasProvider
if ("SLB".equals(ucType)) // Sesselliftbahn
return 'C';
if ("UNB".equals(ucType))
return '?';
if ("UUU".equals(ucType))
return '?';
if ("???".equals(ucType))
return '?';
final char t = super.normalizeType(type);
if (t != 0)
return t;

View file

@ -181,4 +181,13 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest
print(result);
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);
}
}