Switch to modern code format. Organize imports. No functional changes.

Java sources use Eclipse 4.5 'Java Conventions' with indentation changed to 4 spaces only per level.
This commit is contained in:
Andreas Schildbach 2016-09-08 17:52:19 +02:00
parent db59817a05
commit 931dafb628
191 changed files with 24827 additions and 27703 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -38,165 +38,148 @@ import de.schildbach.pte.util.HttpClient;
/**
* @author Andreas Schildbach
*/
public abstract class AbstractNetworkProvider implements NetworkProvider
{
protected final NetworkId network;
protected final HttpClient httpClient = new HttpClient();
public abstract class AbstractNetworkProvider implements NetworkProvider {
protected final NetworkId network;
protected final HttpClient httpClient = new HttpClient();
protected TimeZone timeZone = TimeZone.getTimeZone("CET");
protected int numTripsRequested = 6;
private @Nullable Map<String, Style> styles = null;
protected TimeZone timeZone = TimeZone.getTimeZone("CET");
protected int numTripsRequested = 6;
private @Nullable Map<String, Style> styles = null;
protected static final Set<Product> ALL_EXCEPT_HIGHSPEED = EnumSet.complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN));
protected static final Set<Product> ALL_EXCEPT_HIGHSPEED = EnumSet
.complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN));
protected AbstractNetworkProvider(final NetworkId network)
{
this.network = network;
}
protected AbstractNetworkProvider(final NetworkId network) {
this.network = network;
}
public final NetworkId id()
{
return network;
}
public final NetworkId id() {
return network;
}
public final boolean hasCapabilities(final Capability... capabilities)
{
for (final Capability capability : capabilities)
if (!hasCapability(capability))
return false;
public final boolean hasCapabilities(final Capability... capabilities) {
for (final Capability capability : capabilities)
if (!hasCapability(capability))
return false;
return true;
}
return true;
}
protected abstract boolean hasCapability(Capability capability);
protected abstract boolean hasCapability(Capability capability);
public Set<Product> defaultProducts()
{
return ALL_EXCEPT_HIGHSPEED;
}
public Set<Product> defaultProducts() {
return ALL_EXCEPT_HIGHSPEED;
}
public void setUserAgent(final String userAgent)
{
httpClient.setUserAgent(userAgent);
}
public void setUserAgent(final String userAgent) {
httpClient.setUserAgent(userAgent);
}
protected void setTimeZone(final String timeZoneId)
{
this.timeZone = TimeZone.getTimeZone(timeZoneId);
}
protected void setTimeZone(final String timeZoneId) {
this.timeZone = TimeZone.getTimeZone(timeZoneId);
}
protected void setNumTripsRequested(final int numTripsRequested)
{
this.numTripsRequested = numTripsRequested;
}
protected void setNumTripsRequested(final int numTripsRequested) {
this.numTripsRequested = numTripsRequested;
}
protected void setStyles(final Map<String, Style> styles)
{
this.styles = styles;
}
protected void setStyles(final Map<String, Style> styles) {
this.styles = styles;
}
protected void setSessionCookieName(final String sessionCookieName)
{
httpClient.setSessionCookieName(sessionCookieName);
}
protected void setSessionCookieName(final String sessionCookieName) {
httpClient.setSessionCookieName(sessionCookieName);
}
private static final char STYLES_SEP = '|';
private static final char STYLES_SEP = '|';
public Style lineStyle(final @Nullable String network, final @Nullable Product product, final @Nullable String label)
{
final Map<String, Style> styles = this.styles;
if (styles != null && product != null)
{
if (network != null)
{
// check for line match
final Style lineStyle = styles.get(network + STYLES_SEP + product.code + Strings.nullToEmpty(label));
if (lineStyle != null)
return lineStyle;
public Style lineStyle(final @Nullable String network, final @Nullable Product product,
final @Nullable String label) {
final Map<String, Style> styles = this.styles;
if (styles != null && product != null) {
if (network != null) {
// check for line match
final Style lineStyle = styles.get(network + STYLES_SEP + product.code + Strings.nullToEmpty(label));
if (lineStyle != null)
return lineStyle;
// check for product match
final Style productStyle = styles.get(network + STYLES_SEP + product.code);
if (productStyle != null)
return productStyle;
// check for product match
final Style productStyle = styles.get(network + STYLES_SEP + product.code);
if (productStyle != null)
return productStyle;
// check for night bus, as that's a common special case
if (product == Product.BUS && label != null && label.startsWith("N"))
{
final Style nightStyle = styles.get(network + STYLES_SEP + "BN");
if (nightStyle != null)
return nightStyle;
}
}
// check for night bus, as that's a common special case
if (product == Product.BUS && label != null && label.startsWith("N")) {
final Style nightStyle = styles.get(network + STYLES_SEP + "BN");
if (nightStyle != null)
return nightStyle;
}
}
// check for line match
final String string = product.code + Strings.nullToEmpty(label);
final Style lineStyle = styles.get(string);
if (lineStyle != null)
return lineStyle;
// check for line match
final String string = product.code + Strings.nullToEmpty(label);
final Style lineStyle = styles.get(string);
if (lineStyle != null)
return lineStyle;
// check for product match
final Style productStyle = styles.get(Character.toString(product.code));
if (productStyle != null)
return productStyle;
// check for product match
final Style productStyle = styles.get(Character.toString(product.code));
if (productStyle != null)
return productStyle;
// check for night bus, as that's a common special case
if (product == Product.BUS && label != null && label.startsWith("N"))
{
final Style nightStyle = styles.get("BN");
if (nightStyle != null)
return nightStyle;
}
}
// check for night bus, as that's a common special case
if (product == Product.BUS && label != null && label.startsWith("N")) {
final Style nightStyle = styles.get("BN");
if (nightStyle != null)
return nightStyle;
}
}
// standard colors
return Standard.STYLES.get(product);
}
// standard colors
return Standard.STYLES.get(product);
}
public Point[] getArea() throws IOException
{
return null;
}
public Point[] getArea() throws IOException {
return null;
}
protected static String normalizeStationId(final String stationId)
{
if (stationId == null || stationId.length() == 0)
return null;
protected static String normalizeStationId(final String stationId) {
if (stationId == null || stationId.length() == 0)
return null;
if (stationId.charAt(0) != '0')
return stationId;
if (stationId.charAt(0) != '0')
return stationId;
final StringBuilder normalized = new StringBuilder(stationId);
while (normalized.length() > 0 && normalized.charAt(0) == '0')
normalized.deleteCharAt(0);
final StringBuilder normalized = new StringBuilder(stationId);
while (normalized.length() > 0 && normalized.charAt(0) == '0')
normalized.deleteCharAt(0);
return normalized.toString();
}
return normalized.toString();
}
private static final Pattern P_NAME_SECTION = Pattern.compile("(\\d{1,5})\\s*" + //
"([A-Z](?:\\s*-?\\s*[A-Z])?)?", Pattern.CASE_INSENSITIVE);
private static final Pattern P_NAME_SECTION = Pattern.compile("(\\d{1,5})\\s*" + //
"([A-Z](?:\\s*-?\\s*[A-Z])?)?", Pattern.CASE_INSENSITIVE);
private static final Pattern P_NAME_NOSW = Pattern.compile("(\\d{1,5})\\s*" + //
"(Nord|Süd|Ost|West)", Pattern.CASE_INSENSITIVE);
private static final Pattern P_NAME_NOSW = Pattern.compile("(\\d{1,5})\\s*" + //
"(Nord|Süd|Ost|West)", Pattern.CASE_INSENSITIVE);
protected Position parsePosition(final String position)
{
if (position == null)
return null;
protected Position parsePosition(final String position) {
if (position == null)
return null;
final Matcher mSection = P_NAME_SECTION.matcher(position);
if (mSection.matches())
{
final String name = Integer.toString(Integer.parseInt(mSection.group(1)));
if (mSection.group(2) != null)
return new Position(name, mSection.group(2).replaceAll("\\s+", ""));
else
return new Position(name);
}
final Matcher mSection = P_NAME_SECTION.matcher(position);
if (mSection.matches()) {
final String name = Integer.toString(Integer.parseInt(mSection.group(1)));
if (mSection.group(2) != null)
return new Position(name, mSection.group(2).replaceAll("\\s+", ""));
else
return new Position(name);
}
final Matcher mNosw = P_NAME_NOSW.matcher(position);
if (mNosw.matches())
return new Position(Integer.toString(Integer.parseInt(mNosw.group(1))), mNosw.group(2).substring(0, 1));
final Matcher mNosw = P_NAME_NOSW.matcher(position);
if (mNosw.matches())
return new Position(Integer.toString(Integer.parseInt(mNosw.group(1))), mNosw.group(2).substring(0, 1));
return new Position(position);
}
return new Position(position);
}
}

File diff suppressed because it is too large Load diff

View file

@ -20,14 +20,12 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class AtcProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://82.187.83.50/TravelPlanner/";
public class AtcProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://82.187.83.50/TravelPlanner/";
// http://cisium.webhop.net/TravelPlanner/
// http://cisium.webhop.net/TravelPlanner/
public AtcProvider()
{
super(NetworkId.ATC, API_BASE);
}
public AtcProvider() {
super(NetworkId.ATC, API_BASE);
}
}

View file

@ -33,113 +33,108 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class AvvProvider extends AbstractEfaProvider
{
private final static String API_BASE = "https://efa.avv-augsburg.de/avv2/";
public class AvvProvider extends AbstractEfaProvider {
private final static String API_BASE = "https://efa.avv-augsburg.de/avv2/";
public AvvProvider()
{
super(NetworkId.AVV, API_BASE);
public AvvProvider() {
super(NetworkId.AVV, API_BASE);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
}
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
uri.append("&inclMOT_11=on"); // night bus
uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on");
uri.append("&inclMOT_11=on"); // night bus
uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on");
return uri.toString();
}
return uri.toString();
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("Regionalbahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Staudenbahn SVG".equals(trainNum) && trainType == null && trainName == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "SVG");
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("Regionalbahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Staudenbahn SVG".equals(trainNum) && trainType == null && trainName == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "SVG");
// Streikfahrplan
if ("R1S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R4S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R6S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R7S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R8S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
}
// Streikfahrplan
if ("R1S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R4S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R6S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R7S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R8S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
STYLES.put("B", new Style(Style.Shape.CIRCLE, Style.parseColor("#abb1b1"), Style.BLACK));
STYLES.put("BB1", new Style(Style.Shape.CIRCLE, Style.parseColor("#93117e"), Style.WHITE));
STYLES.put("BB3", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B21", new Style(Style.Shape.CIRCLE, Style.parseColor("#00896b"), Style.WHITE));
STYLES.put("B22", new Style(Style.Shape.CIRCLE, Style.parseColor("#eb6b59"), Style.WHITE));
STYLES.put("B23", new Style(Style.Shape.CIRCLE, Style.parseColor("#97bf0d"), Style.parseColor("#d10019")));
STYLES.put("B27", new Style(Style.Shape.CIRCLE, Style.parseColor("#74b57e"), Style.WHITE));
STYLES.put("B29", new Style(Style.Shape.CIRCLE, Style.parseColor("#5f689f"), Style.WHITE));
STYLES.put("B30", new Style(Style.Shape.CIRCLE, Style.parseColor("#829ac3"), Style.WHITE));
STYLES.put("B31", new Style(Style.Shape.CIRCLE, Style.parseColor("#a3cdb0"), Style.parseColor("#006835")));
STYLES.put("B32", new Style(Style.Shape.CIRCLE, Style.parseColor("#45a477"), Style.WHITE));
STYLES.put("B33", new Style(Style.Shape.CIRCLE, Style.parseColor("#a0ca82"), Style.WHITE));
STYLES.put("B35", new Style(Style.Shape.CIRCLE, Style.parseColor("#0085c5"), Style.WHITE));
STYLES.put("B36", new Style(Style.Shape.CIRCLE, Style.parseColor("#b1c2e1"), Style.parseColor("#006ab3")));
STYLES.put("B37", new Style(Style.Shape.CIRCLE, Style.parseColor("#eac26b"), Style.BLACK));
STYLES.put("B38", new Style(Style.Shape.CIRCLE, Style.parseColor("#c3655a"), Style.WHITE));
STYLES.put("B41", new Style(Style.Shape.CIRCLE, Style.parseColor("#d26110"), Style.WHITE));
STYLES.put("B42", new Style(Style.Shape.CIRCLE, Style.parseColor("#d57642"), Style.WHITE));
STYLES.put("B43", new Style(Style.Shape.CIRCLE, Style.parseColor("#e29241"), Style.WHITE));
STYLES.put("B44", new Style(Style.Shape.CIRCLE, Style.parseColor("#d0aacc"), Style.parseColor("#6d1f80")));
STYLES.put("B45", new Style(Style.Shape.CIRCLE, Style.parseColor("#a76da7"), Style.WHITE));
STYLES.put("B46", new Style(Style.Shape.CIRCLE, Style.parseColor("#52bcc2"), Style.WHITE));
STYLES.put("B48", new Style(Style.Shape.CIRCLE, Style.parseColor("#a6d7d2"), Style.parseColor("#079098")));
STYLES.put("B51", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B52", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B54", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B56", new Style(Style.Shape.CIRCLE, Style.parseColor("#a86853"), Style.WHITE));
STYLES.put("B57", new Style(Style.Shape.CIRCLE, Style.parseColor("#a76da7"), Style.WHITE));
STYLES.put("B58", new Style(Style.Shape.CIRCLE, Style.parseColor("#d0aacc"), Style.parseColor("#6d1f80")));
STYLES.put("B59", new Style(Style.Shape.CIRCLE, Style.parseColor("#b1c2e1"), Style.parseColor("#00519e")));
STYLES.put("B70", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE));
STYLES.put("B71", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE));
STYLES.put("B72", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE));
STYLES.put("B76", new Style(Style.Shape.CIRCLE, Style.parseColor("#c3655a"), Style.WHITE));
static {
STYLES.put("B", new Style(Style.Shape.CIRCLE, Style.parseColor("#abb1b1"), Style.BLACK));
STYLES.put("BB1", new Style(Style.Shape.CIRCLE, Style.parseColor("#93117e"), Style.WHITE));
STYLES.put("BB3", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B21", new Style(Style.Shape.CIRCLE, Style.parseColor("#00896b"), Style.WHITE));
STYLES.put("B22", new Style(Style.Shape.CIRCLE, Style.parseColor("#eb6b59"), Style.WHITE));
STYLES.put("B23", new Style(Style.Shape.CIRCLE, Style.parseColor("#97bf0d"), Style.parseColor("#d10019")));
STYLES.put("B27", new Style(Style.Shape.CIRCLE, Style.parseColor("#74b57e"), Style.WHITE));
STYLES.put("B29", new Style(Style.Shape.CIRCLE, Style.parseColor("#5f689f"), Style.WHITE));
STYLES.put("B30", new Style(Style.Shape.CIRCLE, Style.parseColor("#829ac3"), Style.WHITE));
STYLES.put("B31", new Style(Style.Shape.CIRCLE, Style.parseColor("#a3cdb0"), Style.parseColor("#006835")));
STYLES.put("B32", new Style(Style.Shape.CIRCLE, Style.parseColor("#45a477"), Style.WHITE));
STYLES.put("B33", new Style(Style.Shape.CIRCLE, Style.parseColor("#a0ca82"), Style.WHITE));
STYLES.put("B35", new Style(Style.Shape.CIRCLE, Style.parseColor("#0085c5"), Style.WHITE));
STYLES.put("B36", new Style(Style.Shape.CIRCLE, Style.parseColor("#b1c2e1"), Style.parseColor("#006ab3")));
STYLES.put("B37", new Style(Style.Shape.CIRCLE, Style.parseColor("#eac26b"), Style.BLACK));
STYLES.put("B38", new Style(Style.Shape.CIRCLE, Style.parseColor("#c3655a"), Style.WHITE));
STYLES.put("B41", new Style(Style.Shape.CIRCLE, Style.parseColor("#d26110"), Style.WHITE));
STYLES.put("B42", new Style(Style.Shape.CIRCLE, Style.parseColor("#d57642"), Style.WHITE));
STYLES.put("B43", new Style(Style.Shape.CIRCLE, Style.parseColor("#e29241"), Style.WHITE));
STYLES.put("B44", new Style(Style.Shape.CIRCLE, Style.parseColor("#d0aacc"), Style.parseColor("#6d1f80")));
STYLES.put("B45", new Style(Style.Shape.CIRCLE, Style.parseColor("#a76da7"), Style.WHITE));
STYLES.put("B46", new Style(Style.Shape.CIRCLE, Style.parseColor("#52bcc2"), Style.WHITE));
STYLES.put("B48", new Style(Style.Shape.CIRCLE, Style.parseColor("#a6d7d2"), Style.parseColor("#079098")));
STYLES.put("B51", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B52", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B54", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE));
STYLES.put("B56", new Style(Style.Shape.CIRCLE, Style.parseColor("#a86853"), Style.WHITE));
STYLES.put("B57", new Style(Style.Shape.CIRCLE, Style.parseColor("#a76da7"), Style.WHITE));
STYLES.put("B58", new Style(Style.Shape.CIRCLE, Style.parseColor("#d0aacc"), Style.parseColor("#6d1f80")));
STYLES.put("B59", new Style(Style.Shape.CIRCLE, Style.parseColor("#b1c2e1"), Style.parseColor("#00519e")));
STYLES.put("B70", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE));
STYLES.put("B71", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE));
STYLES.put("B72", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE));
STYLES.put("B76", new Style(Style.Shape.CIRCLE, Style.parseColor("#c3655a"), Style.WHITE));
STYLES.put("T2", new Style(Style.Shape.RECT, Style.parseColor("#006ab3"), Style.WHITE));
STYLES.put("T13", new Style(Style.Shape.RECT, Style.parseColor("#e2001a"), Style.WHITE));
STYLES.put("T64", new Style(Style.Shape.RECT, Style.parseColor("#97bf0d"), Style.WHITE));
STYLES.put("T2", new Style(Style.Shape.RECT, Style.parseColor("#006ab3"), Style.WHITE));
STYLES.put("T13", new Style(Style.Shape.RECT, Style.parseColor("#e2001a"), Style.WHITE));
STYLES.put("T64", new Style(Style.Shape.RECT, Style.parseColor("#97bf0d"), Style.WHITE));
STYLES.put("RR1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1bbbea"), Style.WHITE));
STYLES.put("RR2", new Style(Style.Shape.ROUNDED, Style.parseColor("#003a80"), Style.WHITE));
STYLES.put("RR4", new Style(Style.Shape.ROUNDED, Style.parseColor("#bd5619"), Style.WHITE));
STYLES.put("RR6", new Style(Style.Shape.ROUNDED, Style.parseColor("#0098a1"), Style.WHITE));
STYLES.put("RR7", new Style(Style.Shape.ROUNDED, Style.parseColor("#80191c"), Style.WHITE));
STYLES.put("RR8", new Style(Style.Shape.ROUNDED, Style.parseColor("#007d40"), Style.WHITE));
STYLES.put("RR11", new Style(Style.Shape.ROUNDED, Style.parseColor("#e6a300"), Style.WHITE));
}
STYLES.put("RR1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1bbbea"), Style.WHITE));
STYLES.put("RR2", new Style(Style.Shape.ROUNDED, Style.parseColor("#003a80"), Style.WHITE));
STYLES.put("RR4", new Style(Style.Shape.ROUNDED, Style.parseColor("#bd5619"), Style.WHITE));
STYLES.put("RR6", new Style(Style.Shape.ROUNDED, Style.parseColor("#0098a1"), Style.WHITE));
STYLES.put("RR7", new Style(Style.Shape.ROUNDED, Style.parseColor("#80191c"), Style.WHITE));
STYLES.put("RR8", new Style(Style.Shape.ROUNDED, Style.parseColor("#007d40"), Style.WHITE));
STYLES.put("RR11", new Style(Style.Shape.ROUNDED, Style.parseColor("#e6a300"), Style.WHITE));
}
}

View file

@ -26,80 +26,72 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public final class BahnProvider extends AbstractHafasProvider
{
private static final String API_BASE = "https://reiseauskunft.bahn.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND, null, null,
null, null };
public final class BahnProvider extends AbstractHafasProvider {
private static final String API_BASE = "https://reiseauskunft.bahn.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.SUBWAY, Product.TRAM, Product.ON_DEMAND, null, null, null, null };
public BahnProvider()
{
super(NetworkId.DB, API_BASE, "dn", PRODUCTS_MAP);
public BahnProvider() {
super(NetworkId.DB, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardEndpoint("https://mobile.bahn.de/bin/mobil/bhftafel.exe/dn");
setStationBoardHasStationTable(false);
setJsonGetStopsUseWeight(false);
}
setStationBoardEndpoint("https://mobile.bahn.de/bin/mobil/bhftafel.exe/dn");
setStationBoardHasStationTable(false);
setJsonGetStopsUseWeight(false);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
private static final Pattern P_SPLIT_NAME_ONE_COMMA = Pattern.compile("([^,]*), ([^,]*)");
private static final Pattern P_SPLIT_NAME_ONE_COMMA = Pattern.compile("([^,]*), ([^,]*)");
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
private static final Pattern P_NORMALIZE_LINE_NAME_TRAM = Pattern.compile("str\\s+(.*)", Pattern.CASE_INSENSITIVE);
private static final Pattern P_NORMALIZE_LINE_NAME_TRAM = Pattern.compile("str\\s+(.*)", Pattern.CASE_INSENSITIVE);
@Override
protected String normalizeLineName(final String lineName)
{
final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName);
if (mTram.matches())
return mTram.group(1);
@Override
protected String normalizeLineName(final String lineName) {
final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName);
if (mTram.matches())
return mTram.group(1);
return super.normalizeLineName(lineName);
}
return super.normalizeLineName(lineName);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("N".equals(ucType))
return null;
if ("N".equals(ucType))
return null;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -43,148 +43,133 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class BayernProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://mobile.defas-fgi.de/beg/";
public class BayernProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://mobile.defas-fgi.de/beg/";
// http://mobile.defas-fgi.de/xml/
// http://mobile.defas-fgi.de/xml/
private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
private static final String STOP_FINDER_ENDPOINT = "XML_STOPFINDER_REQUEST";
private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
private static final String STOP_FINDER_ENDPOINT = "XML_STOPFINDER_REQUEST";
public BayernProvider()
{
super(NetworkId.BAYERN, API_BASE, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, STOP_FINDER_ENDPOINT, null);
public BayernProvider() {
super(NetworkId.BAYERN, API_BASE, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, STOP_FINDER_ENDPOINT, null);
setRequestUrlEncoding(Charsets.UTF_8);
setIncludeRegionId(false);
setNumTripsRequested(12);
}
setRequestUrlEncoding(Charsets.UTF_8);
setIncludeRegionId(false);
setNumTripsRequested(12);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("M".equals(trainType) && trainNum != null && trainName != null && trainName.endsWith("Meridian"))
return new Line(id, network, Product.REGIONAL_TRAIN, "M" + trainNum);
if ("ZUG".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, trainNum);
}
else if ("1".equals(mot))
{
if ("ABR".equals(trainType) || "ABELLIO Rail NRW GmbH".equals(trainName))
return new Line(id, network, Product.SUBURBAN_TRAIN, "ABR" + trainNum);
if ("SBB".equals(trainType) || "SBB GmbH".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "SBB" + Strings.nullToEmpty(trainNum));
}
else if ("5".equals(mot))
{
if (name != null && name.startsWith("Stadtbus Linie ")) // Lindau
return super.parseLine(id, network, mot, symbol, name.substring(15), longName, trainType, trainNum, trainName);
else
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
else if ("16".equals(mot))
{
if ("EC".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "EC" + trainNum);
if ("IC".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC" + trainNum);
if ("ICE".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE" + trainNum);
if ("CNL".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "CNL" + trainNum);
if ("THA".equals(trainType) && trainNum != null) // Thalys
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "THA" + trainNum);
if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TGV" + trainNum);
if ("RJ".equals(trainType) && trainNum != null) // railjet
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "RJ" + trainNum);
if ("WB".equals(trainType) && trainNum != null) // WESTbahn
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "WB" + trainNum);
if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "HKX" + trainNum);
if ("D".equals(trainType) && trainNum != null) // Schnellzug
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "D" + trainNum);
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("M".equals(trainType) && trainNum != null && trainName != null && trainName.endsWith("Meridian"))
return new Line(id, network, Product.REGIONAL_TRAIN, "M" + trainNum);
if ("ZUG".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, trainNum);
} else if ("1".equals(mot)) {
if ("ABR".equals(trainType) || "ABELLIO Rail NRW GmbH".equals(trainName))
return new Line(id, network, Product.SUBURBAN_TRAIN, "ABR" + trainNum);
if ("SBB".equals(trainType) || "SBB GmbH".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "SBB" + Strings.nullToEmpty(trainNum));
} else if ("5".equals(mot)) {
if (name != null && name.startsWith("Stadtbus Linie ")) // Lindau
return super.parseLine(id, network, mot, symbol, name.substring(15), longName, trainType, trainNum,
trainName);
else
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
} else if ("16".equals(mot)) {
if ("EC".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "EC" + trainNum);
if ("IC".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC" + trainNum);
if ("ICE".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE" + trainNum);
if ("CNL".equals(trainType) && trainNum != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "CNL" + trainNum);
if ("THA".equals(trainType) && trainNum != null) // Thalys
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "THA" + trainNum);
if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TGV" + trainNum);
if ("RJ".equals(trainType) && trainNum != null) // railjet
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "RJ" + trainNum);
if ("WB".equals(trainType) && trainNum != null) // WESTbahn
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "WB" + trainNum);
if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "HKX" + trainNum);
if ("D".equals(trainType) && trainNum != null) // Schnellzug
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "D" + trainNum);
if ("IR".equals(trainType) && trainNum != null) // InterRegio
return new Line(id, network, Product.REGIONAL_TRAIN, "IR" + trainNum);
}
if ("IR".equals(trainType) && trainNum != null) // InterRegio
return new Line(id, network, Product.REGIONAL_TRAIN, "IR" + trainNum);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations);
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation())
return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations);
if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type);
if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type);
throw new IllegalArgumentException("station"); // TODO
}
throw new IllegalArgumentException("station"); // TODO
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
checkNotNull(Strings.emptyToNull(stationId));
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
checkNotNull(Strings.emptyToNull(stationId));
return queryDeparturesMobile(stationId, time, maxDepartures, equivs);
}
return queryDeparturesMobile(stationId, time, maxDepartures, equivs);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException
{
return mobileStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString()));
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
return mobileStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString()));
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
if (products != null)
{
for (final Product p : products)
{
if (p == Product.HIGH_SPEED_TRAIN)
uri.append("&inclMOT_15=on&inclMOT_16=on");
if (products != null) {
for (final Product p : products) {
if (p == Product.HIGH_SPEED_TRAIN)
uri.append("&inclMOT_15=on&inclMOT_16=on");
if (p == Product.REGIONAL_TRAIN)
uri.append("&inclMOT_13=on");
}
}
if (p == Product.REGIONAL_TRAIN)
uri.append("&inclMOT_13=on");
}
}
uri.append("&inclMOT_11=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_11=on");
uri.append("&inclMOT_14=on");
uri.append("&calcOneDirection=1");
uri.append("&calcOneDirection=1");
return uri.toString();
}
return uri.toString();
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException
{
return queryMoreTripsMobile(contextObj, later);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException {
return queryMoreTripsMobile(contextObj, later);
}
}

View file

@ -34,102 +34,99 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class BsvagProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://bsvg.efa.de/bsvagstd/";
public class BsvagProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://bsvg.efa.de/bsvagstd/";
// http://212.68.73.240/vrbstd/
// http://212.68.73.240/vrbstd/
public BsvagProvider()
{
super(NetworkId.BSVAG, API_BASE);
public BsvagProvider() {
super(NetworkId.BSVAG, API_BASE);
setRequestUrlEncoding(Charsets.UTF_8);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setSessionCookieName("HASESSIONID");
}
setRequestUrlEncoding(Charsets.UTF_8);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setSessionCookieName("HASESSIONID");
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
uri.append("&inclMOT_11=on");
uri.append("&inclMOT_11=on");
return uri.toString();
}
return uri.toString();
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Braunschweig
STYLES.put("TM1", new Style(Style.parseColor("#62c2a2"), Style.WHITE));
STYLES.put("TM2", new Style(Style.parseColor("#b35e89"), Style.WHITE));
STYLES.put("TM3", new Style(Style.parseColor("#f9b5b9"), Style.WHITE));
STYLES.put("TM4", new Style(Style.parseColor("#811114"), Style.WHITE));
STYLES.put("TM5", new Style(Style.parseColor("#ffd00b"), Style.WHITE));
static {
// Braunschweig
STYLES.put("TM1", new Style(Style.parseColor("#62c2a2"), Style.WHITE));
STYLES.put("TM2", new Style(Style.parseColor("#b35e89"), Style.WHITE));
STYLES.put("TM3", new Style(Style.parseColor("#f9b5b9"), Style.WHITE));
STYLES.put("TM4", new Style(Style.parseColor("#811114"), Style.WHITE));
STYLES.put("TM5", new Style(Style.parseColor("#ffd00b"), Style.WHITE));
STYLES.put("BM11", new Style(Style.parseColor("#88891e"), Style.WHITE));
STYLES.put("BM13", new Style(Style.parseColor("#24a06d"), Style.WHITE));
STYLES.put("BM16", new Style(Style.parseColor("#f8991b"), Style.WHITE));
STYLES.put("BM19", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("BM29", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("BM11", new Style(Style.parseColor("#88891e"), Style.WHITE));
STYLES.put("BM13", new Style(Style.parseColor("#24a06d"), Style.WHITE));
STYLES.put("BM16", new Style(Style.parseColor("#f8991b"), Style.WHITE));
STYLES.put("BM19", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("BM29", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("B412", new Style(Style.parseColor("#094f34"), Style.WHITE));
STYLES.put("B414", new Style(Style.parseColor("#00bce4"), Style.WHITE));
STYLES.put("B415", new Style(Style.parseColor("#b82837"), Style.WHITE));
STYLES.put("B417", new Style(Style.parseColor("#2a2768"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#c12056"), Style.WHITE));
STYLES.put("B420", new Style(Style.parseColor("#b7d55b"), Style.WHITE));
STYLES.put("B422", new Style(Style.parseColor("#16bce4"), Style.WHITE));
STYLES.put("B424", new Style(Style.parseColor("#ffdf65"), Style.WHITE));
STYLES.put("B427", new Style(Style.parseColor("#b5d55b"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#fddb62"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#ed0e65"), Style.WHITE));
STYLES.put("B434", new Style(Style.parseColor("#bf2555"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#0080a2"), Style.WHITE));
STYLES.put("B437", new Style(Style.parseColor("#fdd11a"), Style.WHITE));
STYLES.put("B442", new Style(Style.parseColor("#cc3f68"), Style.WHITE));
STYLES.put("B443", new Style(Style.parseColor("#405a80"), Style.WHITE));
STYLES.put("B445", new Style(Style.parseColor("#3ca14a"), Style.WHITE));
STYLES.put("B450", new Style(Style.parseColor("#f2635a"), Style.WHITE));
STYLES.put("B451", new Style(Style.parseColor("#f5791e"), Style.WHITE));
STYLES.put("B452", new Style(Style.parseColor("#f0a3ca"), Style.WHITE));
STYLES.put("B455", new Style(Style.parseColor("#395f95"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#00b8a0"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#00a14b"), Style.WHITE));
STYLES.put("B465", new Style(Style.parseColor("#77234b"), Style.WHITE));
STYLES.put("B471", new Style(Style.parseColor("#380559"), Style.WHITE));
STYLES.put("B480", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("B481", new Style(Style.parseColor("#007ec1"), Style.WHITE));
STYLES.put("B484", new Style(Style.parseColor("#dc8998"), Style.WHITE));
STYLES.put("B485", new Style(Style.parseColor("#ea8d52"), Style.WHITE));
STYLES.put("B493", new Style(Style.parseColor("#f24825"), Style.WHITE));
STYLES.put("B560", new Style(Style.parseColor("#9f6fb0"), Style.WHITE));
STYLES.put("B412", new Style(Style.parseColor("#094f34"), Style.WHITE));
STYLES.put("B414", new Style(Style.parseColor("#00bce4"), Style.WHITE));
STYLES.put("B415", new Style(Style.parseColor("#b82837"), Style.WHITE));
STYLES.put("B417", new Style(Style.parseColor("#2a2768"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#c12056"), Style.WHITE));
STYLES.put("B420", new Style(Style.parseColor("#b7d55b"), Style.WHITE));
STYLES.put("B422", new Style(Style.parseColor("#16bce4"), Style.WHITE));
STYLES.put("B424", new Style(Style.parseColor("#ffdf65"), Style.WHITE));
STYLES.put("B427", new Style(Style.parseColor("#b5d55b"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#fddb62"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#ed0e65"), Style.WHITE));
STYLES.put("B434", new Style(Style.parseColor("#bf2555"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#0080a2"), Style.WHITE));
STYLES.put("B437", new Style(Style.parseColor("#fdd11a"), Style.WHITE));
STYLES.put("B442", new Style(Style.parseColor("#cc3f68"), Style.WHITE));
STYLES.put("B443", new Style(Style.parseColor("#405a80"), Style.WHITE));
STYLES.put("B445", new Style(Style.parseColor("#3ca14a"), Style.WHITE));
STYLES.put("B450", new Style(Style.parseColor("#f2635a"), Style.WHITE));
STYLES.put("B451", new Style(Style.parseColor("#f5791e"), Style.WHITE));
STYLES.put("B452", new Style(Style.parseColor("#f0a3ca"), Style.WHITE));
STYLES.put("B455", new Style(Style.parseColor("#395f95"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#00b8a0"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#00a14b"), Style.WHITE));
STYLES.put("B465", new Style(Style.parseColor("#77234b"), Style.WHITE));
STYLES.put("B471", new Style(Style.parseColor("#380559"), Style.WHITE));
STYLES.put("B480", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("B481", new Style(Style.parseColor("#007ec1"), Style.WHITE));
STYLES.put("B484", new Style(Style.parseColor("#dc8998"), Style.WHITE));
STYLES.put("B485", new Style(Style.parseColor("#ea8d52"), Style.WHITE));
STYLES.put("B493", new Style(Style.parseColor("#f24825"), Style.WHITE));
STYLES.put("B560", new Style(Style.parseColor("#9f6fb0"), Style.WHITE));
// Wolfsburg
STYLES.put("B201", new Style(Style.parseColor("#f1471c"), Style.WHITE));
STYLES.put("B202", new Style(Style.parseColor("#127bca"), Style.WHITE));
STYLES.put("B203", new Style(Style.parseColor("#f35c95"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("B205", new Style(Style.parseColor("#f67c13"), Style.WHITE));
STYLES.put("B206", new Style(Style.WHITE, Style.parseColor("#00adef"), Style.parseColor("#00adef")));
STYLES.put("B207", new Style(Style.parseColor("#94d221"), Style.WHITE));
STYLES.put("B208", new Style(Style.parseColor("#00adef"), Style.WHITE));
STYLES.put("B209", new Style(Style.parseColor("#bf7f50"), Style.WHITE));
STYLES.put("B211", new Style(Style.parseColor("#be65ba"), Style.WHITE));
STYLES.put("B212", new Style(Style.parseColor("#be65ba"), Style.WHITE));
STYLES.put("B213", new Style(Style.parseColor("#918f90"), Style.WHITE));
STYLES.put("B218", new Style(Style.parseColor("#a950ae"), Style.WHITE));
STYLES.put("B219", new Style(Style.parseColor("#bf7f50"), Style.WHITE));
STYLES.put("B230", new Style(Style.parseColor("#ca93d0"), Style.WHITE));
STYLES.put("B231", new Style(Style.WHITE, Style.parseColor("#fab20a"), Style.parseColor("#fab20a")));
STYLES.put("B244", new Style(Style.parseColor("#66cef6"), Style.WHITE));
STYLES.put("B267", new Style(Style.parseColor("#918f90"), Style.WHITE));
}
// Wolfsburg
STYLES.put("B201", new Style(Style.parseColor("#f1471c"), Style.WHITE));
STYLES.put("B202", new Style(Style.parseColor("#127bca"), Style.WHITE));
STYLES.put("B203", new Style(Style.parseColor("#f35c95"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("B205", new Style(Style.parseColor("#f67c13"), Style.WHITE));
STYLES.put("B206", new Style(Style.WHITE, Style.parseColor("#00adef"), Style.parseColor("#00adef")));
STYLES.put("B207", new Style(Style.parseColor("#94d221"), Style.WHITE));
STYLES.put("B208", new Style(Style.parseColor("#00adef"), Style.WHITE));
STYLES.put("B209", new Style(Style.parseColor("#bf7f50"), Style.WHITE));
STYLES.put("B211", new Style(Style.parseColor("#be65ba"), Style.WHITE));
STYLES.put("B212", new Style(Style.parseColor("#be65ba"), Style.WHITE));
STYLES.put("B213", new Style(Style.parseColor("#918f90"), Style.WHITE));
STYLES.put("B218", new Style(Style.parseColor("#a950ae"), Style.WHITE));
STYLES.put("B219", new Style(Style.parseColor("#bf7f50"), Style.WHITE));
STYLES.put("B230", new Style(Style.parseColor("#ca93d0"), Style.WHITE));
STYLES.put("B231", new Style(Style.WHITE, Style.parseColor("#fab20a"), Style.parseColor("#fab20a")));
STYLES.put("B244", new Style(Style.parseColor("#66cef6"), Style.WHITE));
STYLES.put("B267", new Style(Style.parseColor("#918f90"), Style.WHITE));
}
}

View file

@ -26,18 +26,15 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class BvbProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://www.efa-bvb.ch/bvb/";
public class BvbProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://www.efa-bvb.ch/bvb/";
public BvbProvider()
{
super(NetworkId.BVB, API_BASE);
}
public BvbProvider() {
super(NetworkId.BVB, API_BASE);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException
{
return xmlStopfinderRequest(new Location(LocationType.STATION, null, null, constraint.toString()));
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
return xmlStopfinderRequest(new Location(LocationType.STATION, null, null, constraint.toString()));
}
}

View file

@ -34,254 +34,246 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public final class BvgProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://bvg-apps.hafas.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.ON_DEMAND };
public final class BvgProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://bvg-apps.hafas.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS,
Product.FERRY, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.ON_DEMAND };
public BvgProvider()
{
super(NetworkId.BVG, API_BASE, "dn", PRODUCTS_MAP);
public BvgProvider() {
super(NetworkId.BVG, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsUseWeight(false);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
setJsonGetStopsUseWeight(false);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?");
private static final Pattern P_SPLIT_NAME_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?");
private static final Pattern P_SPLIT_NAME_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
@Override
protected String[] splitStationName(String name)
{
final Matcher mSu = P_SPLIT_NAME_SU.matcher(name);
if (!mSu.matches())
throw new IllegalStateException(name);
name = mSu.group(1);
final String su = mSu.group(2);
@Override
protected String[] splitStationName(String name) {
final Matcher mSu = P_SPLIT_NAME_SU.matcher(name);
if (!mSu.matches())
throw new IllegalStateException(name);
name = mSu.group(1);
final String su = mSu.group(2);
final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name);
if (!mBus.matches())
throw new IllegalStateException(name);
name = mBus.group(1);
final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name);
if (!mBus.matches())
throw new IllegalStateException(name);
name = mBus.group(1);
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches())
return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) };
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches())
return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) };
final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (mComma.matches())
return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) };
final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (mComma.matches())
return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
private String normalizePlace(final String place)
{
if ("Bln".equals(place))
return "Berlin";
else
return place;
}
private String normalizePlace(final String place) {
if ("Bln".equals(place))
return "Berlin";
else
return place;
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
private static final Pattern P_NORMALIZE_LINE_NAME_TRAM = Pattern.compile("(?:tra|tram)\\s+(.*)", Pattern.CASE_INSENSITIVE);
private static final Pattern P_NORMALIZE_LINE_NAME_TRAM = Pattern.compile("(?:tra|tram)\\s+(.*)",
Pattern.CASE_INSENSITIVE);
@Override
protected String normalizeLineName(final String lineName)
{
final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName);
if (mTram.matches())
return mTram.group(1);
@Override
protected String normalizeLineName(final String lineName) {
final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName);
if (mTram.matches())
return mTram.group(1);
return super.normalizeLineName(lineName);
}
return super.normalizeLineName(lineName);
}
@Override
protected Line parseLineAndType(final String lineAndType)
{
if ("X#".equals(lineAndType))
return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
else
return super.parseLineAndType(lineAndType);
}
@Override
protected Line parseLineAndType(final String lineAndType) {
if ("X#".equals(lineAndType))
return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
else
return super.parseLineAndType(lineAndType);
}
@Override
protected Line newLine(final Product product, final String normalizedName, final String comment, final Attr... attrs)
{
if (product == Product.SUBURBAN_TRAIN && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_CLOCKWISE));
if (product == Product.SUBURBAN_TRAIN && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_ANTICLOCKWISE));
@Override
protected Line newLine(final Product product, final String normalizedName, final String comment,
final Attr... attrs) {
if (product == Product.SUBURBAN_TRAIN && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_CLOCKWISE));
if (product == Product.SUBURBAN_TRAIN && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_ANTICLOCKWISE));
if (product == Product.BUS && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE));
if (product == Product.BUS && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE));
if (product == Product.BUS && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment,
concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE));
if (product == Product.BUS && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment,
concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE));
if (product == Product.BUS && "TXL".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == Product.SUBURBAN_TRAIN && "S9".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == Product.SUBURBAN_TRAIN && "S45".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == Product.BUS && "TXL".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == Product.SUBURBAN_TRAIN && "S9".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
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, attrs);
}
return super.newLine(product, normalizedName, comment, attrs);
}
private Attr[] concatAttrs(final Attr[] attrs1, final Attr... attrs2)
{
final int attrs1length = attrs1.length;
final int attrs2length = attrs2.length;
private Attr[] concatAttrs(final Attr[] attrs1, final Attr... attrs2) {
final int attrs1length = attrs1.length;
final int attrs2length = attrs2.length;
final Attr[] newAttrs = new Attr[attrs1length + attrs2length];
for (int i = 0; i < attrs1length; i++)
newAttrs[i] = attrs1[i];
for (int i = 0; i < attrs2length; i++)
newAttrs[attrs1length + i] = attrs2[i];
final Attr[] newAttrs = new Attr[attrs1length + attrs2length];
for (int i = 0; i < attrs1length; i++)
newAttrs[i] = attrs1[i];
for (int i = 0; i < attrs2length; i++)
newAttrs[attrs1length + i] = attrs2[i];
return newAttrs;
}
return newAttrs;
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
STYLES.put("SS1", new Style(Style.rgb(221, 77, 174), Style.WHITE));
STYLES.put("SS2", new Style(Style.rgb(16, 132, 73), Style.WHITE));
STYLES.put("SS25", new Style(Style.rgb(16, 132, 73), Style.WHITE));
STYLES.put("SS3", new Style(Style.rgb(22, 106, 184), Style.WHITE));
STYLES.put("SS41", new Style(Style.rgb(162, 63, 48), Style.WHITE));
STYLES.put("SS42", new Style(Style.rgb(191, 90, 42), Style.WHITE));
STYLES.put("SS45", new Style(Style.WHITE, Style.rgb(191, 128, 55), Style.rgb(191, 128, 55)));
STYLES.put("SS46", new Style(Style.rgb(191, 128, 55), Style.WHITE));
STYLES.put("SS47", new Style(Style.rgb(191, 128, 55), Style.WHITE));
STYLES.put("SS5", new Style(Style.rgb(243, 103, 23), Style.WHITE));
STYLES.put("SS7", new Style(Style.rgb(119, 96, 176), Style.WHITE));
STYLES.put("SS75", new Style(Style.rgb(119, 96, 176), Style.WHITE));
STYLES.put("SS8", new Style(Style.rgb(85, 184, 49), Style.WHITE));
STYLES.put("SS85", new Style(Style.WHITE, Style.rgb(85, 184, 49), Style.rgb(85, 184, 49)));
STYLES.put("SS9", new Style(Style.rgb(148, 36, 64), Style.WHITE));
static {
STYLES.put("SS1", new Style(Style.rgb(221, 77, 174), Style.WHITE));
STYLES.put("SS2", new Style(Style.rgb(16, 132, 73), Style.WHITE));
STYLES.put("SS25", new Style(Style.rgb(16, 132, 73), Style.WHITE));
STYLES.put("SS3", new Style(Style.rgb(22, 106, 184), Style.WHITE));
STYLES.put("SS41", new Style(Style.rgb(162, 63, 48), Style.WHITE));
STYLES.put("SS42", new Style(Style.rgb(191, 90, 42), Style.WHITE));
STYLES.put("SS45", new Style(Style.WHITE, Style.rgb(191, 128, 55), Style.rgb(191, 128, 55)));
STYLES.put("SS46", new Style(Style.rgb(191, 128, 55), Style.WHITE));
STYLES.put("SS47", new Style(Style.rgb(191, 128, 55), Style.WHITE));
STYLES.put("SS5", new Style(Style.rgb(243, 103, 23), Style.WHITE));
STYLES.put("SS7", new Style(Style.rgb(119, 96, 176), Style.WHITE));
STYLES.put("SS75", new Style(Style.rgb(119, 96, 176), Style.WHITE));
STYLES.put("SS8", new Style(Style.rgb(85, 184, 49), Style.WHITE));
STYLES.put("SS85", new Style(Style.WHITE, Style.rgb(85, 184, 49), Style.rgb(85, 184, 49)));
STYLES.put("SS9", new Style(Style.rgb(148, 36, 64), Style.WHITE));
STYLES.put("UU1", new Style(Shape.RECT, Style.rgb(84, 131, 47), Style.WHITE));
STYLES.put("UU2", new Style(Shape.RECT, Style.rgb(215, 25, 16), Style.WHITE));
STYLES.put("UU12", new Style(Shape.RECT, Style.rgb(84, 131, 47), Style.rgb(215, 25, 16), Style.WHITE, 0));
STYLES.put("UU3", new Style(Shape.RECT, Style.rgb(47, 152, 154), Style.WHITE));
STYLES.put("UU4", new Style(Shape.RECT, Style.rgb(255, 233, 42), Style.BLACK));
STYLES.put("UU5", new Style(Shape.RECT, Style.rgb(91, 31, 16), Style.WHITE));
STYLES.put("UU55", new Style(Shape.RECT, Style.rgb(91, 31, 16), Style.WHITE));
STYLES.put("UU6", new Style(Shape.RECT, Style.rgb(127, 57, 115), Style.WHITE));
STYLES.put("UU7", new Style(Shape.RECT, Style.rgb(0, 153, 204), Style.WHITE));
STYLES.put("UU8", new Style(Shape.RECT, Style.rgb(24, 25, 83), Style.WHITE));
STYLES.put("UU9", new Style(Shape.RECT, Style.rgb(255, 90, 34), Style.WHITE));
STYLES.put("UU1", new Style(Shape.RECT, Style.rgb(84, 131, 47), Style.WHITE));
STYLES.put("UU2", new Style(Shape.RECT, Style.rgb(215, 25, 16), Style.WHITE));
STYLES.put("UU12", new Style(Shape.RECT, Style.rgb(84, 131, 47), Style.rgb(215, 25, 16), Style.WHITE, 0));
STYLES.put("UU3", new Style(Shape.RECT, Style.rgb(47, 152, 154), Style.WHITE));
STYLES.put("UU4", new Style(Shape.RECT, Style.rgb(255, 233, 42), Style.BLACK));
STYLES.put("UU5", new Style(Shape.RECT, Style.rgb(91, 31, 16), Style.WHITE));
STYLES.put("UU55", new Style(Shape.RECT, Style.rgb(91, 31, 16), Style.WHITE));
STYLES.put("UU6", new Style(Shape.RECT, Style.rgb(127, 57, 115), Style.WHITE));
STYLES.put("UU7", new Style(Shape.RECT, Style.rgb(0, 153, 204), Style.WHITE));
STYLES.put("UU8", new Style(Shape.RECT, Style.rgb(24, 25, 83), Style.WHITE));
STYLES.put("UU9", new Style(Shape.RECT, Style.rgb(255, 90, 34), Style.WHITE));
STYLES.put("TM1", new Style(Shape.RECT, Style.parseColor("#eb8614"), Style.WHITE));
STYLES.put("TM2", new Style(Shape.RECT, Style.parseColor("#68c52f"), Style.WHITE));
STYLES.put("TM4", new Style(Shape.RECT, Style.parseColor("#cf1b22"), Style.WHITE));
STYLES.put("TM5", new Style(Shape.RECT, Style.parseColor("#bf8037"), Style.WHITE));
STYLES.put("TM6", new Style(Shape.RECT, Style.parseColor("#1e5ca2"), Style.WHITE));
STYLES.put("TM8", new Style(Shape.RECT, Style.parseColor("#f46717"), Style.WHITE));
STYLES.put("TM10", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("TM13", new Style(Shape.RECT, Style.parseColor("#36ab94"), Style.WHITE));
STYLES.put("TM17", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("TM1", new Style(Shape.RECT, Style.parseColor("#eb8614"), Style.WHITE));
STYLES.put("TM2", new Style(Shape.RECT, Style.parseColor("#68c52f"), Style.WHITE));
STYLES.put("TM4", new Style(Shape.RECT, Style.parseColor("#cf1b22"), Style.WHITE));
STYLES.put("TM5", new Style(Shape.RECT, Style.parseColor("#bf8037"), Style.WHITE));
STYLES.put("TM6", new Style(Shape.RECT, Style.parseColor("#1e5ca2"), Style.WHITE));
STYLES.put("TM8", new Style(Shape.RECT, Style.parseColor("#f46717"), Style.WHITE));
STYLES.put("TM10", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("TM13", new Style(Shape.RECT, Style.parseColor("#36ab94"), Style.WHITE));
STYLES.put("TM17", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T12", new Style(Shape.RECT, Style.parseColor("#7d64b2"), Style.WHITE));
STYLES.put("T16", new Style(Shape.RECT, Style.parseColor("#1e5ca2"), Style.WHITE));
STYLES.put("T18", new Style(Shape.RECT, Style.parseColor("#f46717"), Style.WHITE));
STYLES.put("T21", new Style(Shape.RECT, Style.parseColor("#7d64b2"), Style.WHITE));
STYLES.put("T27", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T37", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T50", new Style(Shape.RECT, Style.parseColor("#36ab94"), Style.WHITE));
STYLES.put("T60", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T61", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T62", new Style(Shape.RECT, Style.parseColor("#125030"), Style.WHITE));
STYLES.put("T63", new Style(Shape.RECT, Style.parseColor("#36ab94"), Style.WHITE));
STYLES.put("T67", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T68", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T12", new Style(Shape.RECT, Style.parseColor("#7d64b2"), Style.WHITE));
STYLES.put("T16", new Style(Shape.RECT, Style.parseColor("#1e5ca2"), Style.WHITE));
STYLES.put("T18", new Style(Shape.RECT, Style.parseColor("#f46717"), Style.WHITE));
STYLES.put("T21", new Style(Shape.RECT, Style.parseColor("#7d64b2"), Style.WHITE));
STYLES.put("T27", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T37", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T50", new Style(Shape.RECT, Style.parseColor("#36ab94"), Style.WHITE));
STYLES.put("T60", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T61", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T62", new Style(Shape.RECT, Style.parseColor("#125030"), Style.WHITE));
STYLES.put("T63", new Style(Shape.RECT, Style.parseColor("#36ab94"), Style.WHITE));
STYLES.put("T67", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T68", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("B", new Style(Shape.RECT, Style.parseColor("#993399"), Style.WHITE));
STYLES.put("BN", new Style(Shape.RECT, Style.BLACK, Style.WHITE));
STYLES.put("B", new Style(Shape.RECT, Style.parseColor("#993399"), Style.WHITE));
STYLES.put("BN", new Style(Shape.RECT, Style.BLACK, Style.WHITE));
STYLES.put("FF1", new Style(Style.BLUE, Style.WHITE)); // Potsdam
STYLES.put("FF10", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF11", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF12", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF21", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF23", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF24", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF1", new Style(Style.BLUE, Style.WHITE)); // Potsdam
STYLES.put("FF10", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF11", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF12", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF21", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF23", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF24", new Style(Style.BLUE, Style.WHITE));
// Regional lines Brandenburg:
STYLES.put("RRE1", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRE2", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRE3", new Style(Shape.RECT, Style.parseColor("#F57921"), Style.WHITE));
STYLES.put("RRE4", new Style(Shape.RECT, Style.parseColor("#952D4F"), Style.WHITE));
STYLES.put("RRE5", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE));
STYLES.put("RRE6", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRE7", new Style(Shape.RECT, Style.parseColor("#00854A"), Style.WHITE));
STYLES.put("RRE10", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
STYLES.put("RRE11", new Style(Shape.RECT, Style.parseColor("#059EDB"), Style.WHITE));
STYLES.put("RRE11", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRE15", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRE18", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("RRB10", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RRB12", new Style(Shape.RECT, Style.parseColor("#A3238E"), Style.WHITE));
STYLES.put("RRB13", new Style(Shape.RECT, Style.parseColor("#F68B1F"), Style.WHITE));
STYLES.put("RRB13", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("RRB14", new Style(Shape.RECT, Style.parseColor("#A3238E"), Style.WHITE));
STYLES.put("RRB20", new Style(Shape.RECT, Style.parseColor("#00854A"), Style.WHITE));
STYLES.put("RRB21", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("RRB22", new Style(Shape.RECT, Style.parseColor("#0087CB"), Style.WHITE));
STYLES.put("ROE25", new Style(Shape.RECT, Style.parseColor("#0087CB"), Style.WHITE));
STYLES.put("RNE26", new Style(Shape.RECT, Style.parseColor("#00A896"), Style.WHITE));
STYLES.put("RNE27", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRB30", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("RRB31", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RMR33", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("ROE35", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("ROE36", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
STYLES.put("RRB43", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("RRB45", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("ROE46", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RMR51", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRB51", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRB54", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRB55", new Style(Shape.RECT, Style.parseColor("#F57921"), Style.WHITE));
STYLES.put("ROE60", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("ROE63", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("ROE65", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE));
STYLES.put("RRB66", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RPE70", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RPE73", new Style(Shape.RECT, Style.parseColor("#00A896"), Style.WHITE));
STYLES.put("RPE74", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE));
STYLES.put("T89", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRB91", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
STYLES.put("RRB93", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
}
// Regional lines Brandenburg:
STYLES.put("RRE1", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRE2", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRE3", new Style(Shape.RECT, Style.parseColor("#F57921"), Style.WHITE));
STYLES.put("RRE4", new Style(Shape.RECT, Style.parseColor("#952D4F"), Style.WHITE));
STYLES.put("RRE5", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE));
STYLES.put("RRE6", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRE7", new Style(Shape.RECT, Style.parseColor("#00854A"), Style.WHITE));
STYLES.put("RRE10", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
STYLES.put("RRE11", new Style(Shape.RECT, Style.parseColor("#059EDB"), Style.WHITE));
STYLES.put("RRE11", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRE15", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRE18", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("RRB10", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RRB12", new Style(Shape.RECT, Style.parseColor("#A3238E"), Style.WHITE));
STYLES.put("RRB13", new Style(Shape.RECT, Style.parseColor("#F68B1F"), Style.WHITE));
STYLES.put("RRB13", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("RRB14", new Style(Shape.RECT, Style.parseColor("#A3238E"), Style.WHITE));
STYLES.put("RRB20", new Style(Shape.RECT, Style.parseColor("#00854A"), Style.WHITE));
STYLES.put("RRB21", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("RRB22", new Style(Shape.RECT, Style.parseColor("#0087CB"), Style.WHITE));
STYLES.put("ROE25", new Style(Shape.RECT, Style.parseColor("#0087CB"), Style.WHITE));
STYLES.put("RNE26", new Style(Shape.RECT, Style.parseColor("#00A896"), Style.WHITE));
STYLES.put("RNE27", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRB30", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("RRB31", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RMR33", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("ROE35", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("ROE36", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
STYLES.put("RRB43", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("RRB45", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("ROE46", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RMR51", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRB51", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRB54", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRB55", new Style(Shape.RECT, Style.parseColor("#F57921"), Style.WHITE));
STYLES.put("ROE60", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("ROE63", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("ROE65", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE));
STYLES.put("RRB66", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RPE70", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RPE73", new Style(Shape.RECT, Style.parseColor("#00A896"), Style.WHITE));
STYLES.put("RPE74", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE));
STYLES.put("T89", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRB91", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
STYLES.put("RRB93", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
}
@Override
public Point[] getArea()
{
return new Point[] { Point.fromDouble(52.674189, 13.074604), Point.fromDouble(52.341100, 13.757130) };
}
@Override
public Point[] getArea() {
return new Point[] { Point.fromDouble(52.674189, 13.074604), Point.fromDouble(52.341100, 13.757130) };
}
}

View file

@ -20,14 +20,12 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class DingProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://www.ding-ulm.de/ding2/";
public class DingProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://www.ding-ulm.de/ding2/";
// http://www.ding.eu/swu
// http://www.ding.eu/swu
public DingProvider()
{
super(NetworkId.DING, API_BASE);
}
public DingProvider() {
super(NetworkId.DING, API_BASE);
}
}

View file

@ -25,81 +25,77 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class DsbProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://mobil.rejseplanen.dk/mobil-bin/";
// http://dk.hafas.de/bin/fat/
// http://mobil.rejseplanen.dk/mobil-bin/
// http://www.dsb.dk/Rejseplan/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.BUS, Product.BUS, Product.BUS, Product.FERRY, Product.SUBWAY };
public class DsbProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://mobil.rejseplanen.dk/mobil-bin/";
// http://dk.hafas.de/bin/fat/
// http://mobil.rejseplanen.dk/mobil-bin/
// http://www.dsb.dk/Rejseplan/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.BUS,
Product.BUS, Product.BUS, Product.FERRY, Product.SUBWAY };
public DsbProvider()
{
super(NetworkId.DSB, API_BASE, "mn", PRODUCTS_MAP);
public DsbProvider() {
super(NetworkId.DSB, API_BASE, "mn", PRODUCTS_MAP);
setStationBoardHasStationTable(false);
}
setStationBoardHasStationTable(false);
}
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_PAREN.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_PAREN.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("ICL".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("IB".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("SJ".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("ICL".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("IB".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("SJ".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("ØR".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("RA".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("RX".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("PP".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("ØR".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("RA".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("RX".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("PP".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("S-TOG".equals(ucType))
return Product.SUBURBAN_TRAIN;
if ("S-TOG".equals(ucType))
return Product.SUBURBAN_TRAIN;
if ("BYBUS".equals(ucType))
return Product.BUS;
if ("X-BUS".equals(ucType) || "X BUS".equals(ucType))
return Product.BUS;
if ("HV-BUS".equals(ucType)) // Havnebus
return Product.BUS;
if ("T-BUS".equals(ucType)) // Togbus
return Product.BUS;
if ("TOGBUS".equals(ucType))
return Product.BUS;
if ("BYBUS".equals(ucType))
return Product.BUS;
if ("X-BUS".equals(ucType) || "X BUS".equals(ucType))
return Product.BUS;
if ("HV-BUS".equals(ucType)) // Havnebus
return Product.BUS;
if ("T-BUS".equals(ucType)) // Togbus
return Product.BUS;
if ("TOGBUS".equals(ucType))
return Product.BUS;
if ("TELEBUS".equals(ucType))
return Product.ON_DEMAND;
if ("TELETAXI".equals(ucType))
return Product.ON_DEMAND;
if ("TELEBUS".equals(ucType))
return Product.ON_DEMAND;
if ("TELETAXI".equals(ucType))
return Product.ON_DEMAND;
if ("FÆRGE".equals(ucType))
return Product.FERRY;
if ("FÆRGE".equals(ucType))
return Product.FERRY;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -20,16 +20,14 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class DubProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://wojhati.rta.ae/dub/";
public class DubProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://wojhati.rta.ae/dub/";
public DubProvider()
{
super(NetworkId.DUB, API_BASE);
public DubProvider() {
super(NetworkId.DUB, API_BASE);
setTimeZone("Asia/Dubai");
setUseRouteIndexAsTripId(false);
setFareCorrectionFactor(0.01f);
}
setTimeZone("Asia/Dubai");
setUseRouteIndexAsTripId(false);
setFareCorrectionFactor(0.01f);
}
}

View file

@ -36,55 +36,50 @@ import de.schildbach.pte.dto.QueryTripsResult;
*
* @author Andreas Schildbach
*/
public class EireannProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://journeyplanner.buseireann.ie/jp/bin/";
private static final Product[] PRODUCTS_MAP = { null, null, null, Product.BUS };
public class EireannProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://journeyplanner.buseireann.ie/jp/bin/";
private static final Product[] PRODUCTS_MAP = { null, null, null, Product.BUS };
public EireannProvider()
{
super(NetworkId.EIREANN, API_BASE, "en", PRODUCTS_MAP);
public EireannProvider() {
super(NetworkId.EIREANN, API_BASE, "en", PRODUCTS_MAP);
setStationBoardHasStationTable(false);
}
setStationBoardHasStationTable(false);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
return queryMoreTripsXml(context, later);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
return queryMoreTripsXml(context, later);
}
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([^#]+)#");
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([^#]+)#");
@Override
protected Line parseLineAndType(final String lineAndType)
{
final Matcher mLine = P_NORMALIZE_LINE.matcher(lineAndType);
if (mLine.matches())
return newLine(Product.BUS, mLine.group(1), null);
@Override
protected Line parseLineAndType(final String lineAndType) {
final Matcher mLine = P_NORMALIZE_LINE.matcher(lineAndType);
if (mLine.matches())
return newLine(Product.BUS, mLine.group(1), null);
return super.parseLineAndType(lineAndType);
}
return super.parseLineAndType(lineAndType);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("COA".equals(ucType))
return Product.BUS;
if ("CIT".equals(ucType))
return Product.BUS;
if ("COA".equals(ucType))
return Product.BUS;
if ("CIT".equals(ucType))
return Product.BUS;
// skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
// skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
}

View file

@ -25,63 +25,52 @@ import de.schildbach.pte.dto.Style.Shape;
* @author Nicolas Derive
* @author Stéphane Guillou
*/
public class FranceNorthEastProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "fr-ne";
// dataset available at: https://navitia.opendatasoft.com/explore/dataset/fr-ne/
public class FranceNorthEastProvider extends AbstractNavitiaProvider {
private static String API_REGION = "fr-ne";
// dataset available at: https://navitia.opendatasoft.com/explore/dataset/fr-ne/
public FranceNorthEastProvider(final String apiBase, final String authorization)
{
super(NetworkId.FRANCENORTHEAST, apiBase, authorization);
public FranceNorthEastProvider(final String apiBase, final String authorization) {
super(NetworkId.FRANCENORTHEAST, apiBase, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
public FranceNorthEastProvider(final String authorization)
{
super(NetworkId.FRANCENORTHEAST, authorization);
public FranceNorthEastProvider(final String authorization) {
super(NetworkId.FRANCENORTHEAST, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color)
{
switch (product)
{
case REGIONAL_TRAIN:
{
// Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF)
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBURBAN_TRAIN:
{
// Rail (route_type = 2) for Transilien (SNCF)
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case TRAM:
{
// Tram (route_type = 0) for Strasboug (CTS) and Nancy (Stan)
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
}
case BUS:
{
// Bus (route_type = 3)
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY:
{
// Subway (route_type = 1) for Lille (Transpole)
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
default:
throw new IllegalArgumentException("Unhandled product: " + product);
}
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color) {
switch (product) {
case REGIONAL_TRAIN: {
// Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF)
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBURBAN_TRAIN: {
// Rail (route_type = 2) for Transilien (SNCF)
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case TRAM: {
// Tram (route_type = 0) for Strasboug (CTS) and Nancy (Stan)
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
}
case BUS: {
// Bus (route_type = 3)
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY: {
// Subway (route_type = 1) for Lille (Transpole)
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
default:
throw new IllegalArgumentException("Unhandled product: " + product);
}
}
}

View file

@ -24,66 +24,54 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Anthony Chaput
*/
public class FranceSouthEastProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "fr-se";
public class FranceSouthEastProvider extends AbstractNavitiaProvider {
private static String API_REGION = "fr-se";
public FranceSouthEastProvider(final String apiBase, final String authorization)
{
super(NetworkId.FRANCESOUTHEAST, apiBase, authorization);
public FranceSouthEastProvider(final String apiBase, final String authorization) {
super(NetworkId.FRANCESOUTHEAST, apiBase, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
public FranceSouthEastProvider(final String authorization)
{
super(NetworkId.FRANCESOUTHEAST, authorization);
public FranceSouthEastProvider(final String authorization) {
super(NetworkId.FRANCESOUTHEAST, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color)
{
switch (product)
{
case REGIONAL_TRAIN:
{
// TER + Intercités
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBURBAN_TRAIN:
{
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case TRAM:
{
// Tram
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
case BUS:
{
// Bus + Transgironde
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case FERRY:
{
// Batcub
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY:
{
// Toulouse subway (from Tisseo network)
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
default:
return super.getLineStyle(product, code, color);
}
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color) {
switch (product) {
case REGIONAL_TRAIN: {
// TER + Intercités
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBURBAN_TRAIN: {
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case TRAM: {
// Tram
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
case BUS: {
// Bus + Transgironde
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case FERRY: {
// Batcub
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY: {
// Toulouse subway (from Tisseo network)
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
default:
return super.getLineStyle(product, code, color);
}
}
}

View file

@ -24,66 +24,54 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Nicolas Derive
*/
public class FrenchSouthWestProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "fr-sw";
public class FrenchSouthWestProvider extends AbstractNavitiaProvider {
private static String API_REGION = "fr-sw";
public FrenchSouthWestProvider(final String apiBase, final String authorization)
{
super(NetworkId.FRENCHSOUTHWEST, apiBase, authorization);
public FrenchSouthWestProvider(final String apiBase, final String authorization) {
super(NetworkId.FRENCHSOUTHWEST, apiBase, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
public FrenchSouthWestProvider(final String authorization)
{
super(NetworkId.FRENCHSOUTHWEST, authorization);
public FrenchSouthWestProvider(final String authorization) {
super(NetworkId.FRENCHSOUTHWEST, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color)
{
switch (product)
{
case REGIONAL_TRAIN:
{
// TER + Intercités
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBURBAN_TRAIN:
{
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case TRAM:
{
// Tram
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
case BUS:
{
// Bus + Transgironde
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case FERRY:
{
// Batcub
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY:
{
// Toulouse subway (from Tisseo network)
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
default:
return super.getLineStyle(product, code, color);
}
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color) {
switch (product) {
case REGIONAL_TRAIN: {
// TER + Intercités
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBURBAN_TRAIN: {
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case TRAM: {
// Tram
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
case BUS: {
// Bus + Transgironde
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case FERRY: {
// Batcub
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY: {
// Toulouse subway (from Tisseo network)
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
default:
return super.getLineStyle(product, code, color);
}
}
}

View file

@ -29,137 +29,133 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class GvhProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://bhb.efa.de/bhb/";
public class GvhProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://bhb.efa.de/bhb/";
// http://www.efa.de/efaws2/cmsembedded_gvh/
// http://bhb.efa.de/bhb/
// http://mobil.efa.de/mobile3/
// http://www.efa.de/efaws2/cmsembedded_gvh/
// http://bhb.efa.de/bhb/
// http://mobil.efa.de/mobile3/
public GvhProvider()
{
this(API_BASE);
}
public GvhProvider() {
this(API_BASE);
}
public GvhProvider(final String apiBase)
{
super(NetworkId.GVH, apiBase);
public GvhProvider(final String apiBase) {
super(NetworkId.GVH, apiBase);
setStyles(STYLES);
setSessionCookieName("HASESSIONID");
}
setStyles(STYLES);
setSessionCookieName("HASESSIONID");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("S4".equals(trainNum))
return new Line(id, network, Product.SUBURBAN_TRAIN, "S4");
if (longName != null && longName.startsWith("Bus ") && name != null)
return new Line(id, network, Product.BUS, name);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("S4".equals(trainNum))
return new Line(id, network, Product.SUBURBAN_TRAIN, "S4");
if (longName != null && longName.startsWith("Bus ") && name != null)
return new Line(id, network, Product.BUS, name);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// Hannover
STYLES.put("SS1", new Style(Style.Shape.CIRCLE, Style.parseColor("#816ba8"), Style.WHITE));
STYLES.put("SS2", new Style(Style.Shape.CIRCLE, Style.parseColor("#007a3b"), Style.WHITE));
STYLES.put("SS21", new Style(Style.Shape.CIRCLE, Style.parseColor("#007a3b"), Style.WHITE));
STYLES.put("SS3", new Style(Style.Shape.CIRCLE, Style.parseColor("#cc68a6"), Style.WHITE));
STYLES.put("SS4", new Style(Style.Shape.CIRCLE, Style.parseColor("#9b2a48"), Style.WHITE));
STYLES.put("SS5", new Style(Style.Shape.CIRCLE, Style.parseColor("#f18700"), Style.WHITE));
STYLES.put("SS51", new Style(Style.Shape.CIRCLE, Style.parseColor("#f18700"), Style.WHITE));
STYLES.put("SS6", new Style(Style.Shape.CIRCLE, Style.parseColor("#004e9e"), Style.WHITE));
STYLES.put("SS7", new Style(Style.Shape.CIRCLE, Style.parseColor("#afcb25"), Style.WHITE));
static {
// Hannover
STYLES.put("SS1", new Style(Style.Shape.CIRCLE, Style.parseColor("#816ba8"), Style.WHITE));
STYLES.put("SS2", new Style(Style.Shape.CIRCLE, Style.parseColor("#007a3b"), Style.WHITE));
STYLES.put("SS21", new Style(Style.Shape.CIRCLE, Style.parseColor("#007a3b"), Style.WHITE));
STYLES.put("SS3", new Style(Style.Shape.CIRCLE, Style.parseColor("#cc68a6"), Style.WHITE));
STYLES.put("SS4", new Style(Style.Shape.CIRCLE, Style.parseColor("#9b2a48"), Style.WHITE));
STYLES.put("SS5", new Style(Style.Shape.CIRCLE, Style.parseColor("#f18700"), Style.WHITE));
STYLES.put("SS51", new Style(Style.Shape.CIRCLE, Style.parseColor("#f18700"), Style.WHITE));
STYLES.put("SS6", new Style(Style.Shape.CIRCLE, Style.parseColor("#004e9e"), Style.WHITE));
STYLES.put("SS7", new Style(Style.Shape.CIRCLE, Style.parseColor("#afcb25"), Style.WHITE));
STYLES.put("T1", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#e40039")));
STYLES.put("T2", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#e40039")));
STYLES.put("T3", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#0069b4")));
STYLES.put("T4", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T5", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T6", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T16", new Style(Style.Shape.RECT, Style.WHITE, Style.GRAY, Style.parseColor("#f9b000")));
STYLES.put("T7", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#0069b4")));
STYLES.put("T8", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#e40039")));
STYLES.put("T18", new Style(Style.Shape.RECT, Style.WHITE, Style.GRAY, Style.parseColor("#e40039")));
STYLES.put("T9", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#0069b4")));
STYLES.put("T10", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#76b828")));
STYLES.put("T11", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T17", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#76b828")));
STYLES.put("T1", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#e40039")));
STYLES.put("T2", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#e40039")));
STYLES.put("T3", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#0069b4")));
STYLES.put("T4", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T5", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T6", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T16", new Style(Style.Shape.RECT, Style.WHITE, Style.GRAY, Style.parseColor("#f9b000")));
STYLES.put("T7", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#0069b4")));
STYLES.put("T8", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#e40039")));
STYLES.put("T18", new Style(Style.Shape.RECT, Style.WHITE, Style.GRAY, Style.parseColor("#e40039")));
STYLES.put("T9", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#0069b4")));
STYLES.put("T10", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#76b828")));
STYLES.put("T11", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#f9b000")));
STYLES.put("T17", new Style(Style.Shape.RECT, Style.WHITE, Style.BLACK, Style.parseColor("#76b828")));
STYLES.put("B100", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B120", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B121", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B122", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B123", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B124", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B125", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B126", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B127", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B128", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B129", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B130", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B133", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B134", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e21f34")));
STYLES.put("B135", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B136", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B137", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B200", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B300", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B330", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B340", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B341", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B350", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B360", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B363", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B365", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B366", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B370", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B420", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B440", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B450", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B460", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B461", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B470", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B490", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B491", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B500", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B570", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B571", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B574", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B580", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B581", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B620", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B631", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B700", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("BN31", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#9e348b")));
STYLES.put("BN41", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("BN43", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("BN56", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#2eab5c")));
STYLES.put("BN57", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1eb5ea")));
STYLES.put("BN70", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("BN62", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("B100", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B120", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B121", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B122", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B123", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B124", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B125", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B126", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B127", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B128", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B129", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B130", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B133", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B134", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e21f34")));
STYLES.put("B135", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B136", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B137", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B200", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B300", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B330", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B340", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B341", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B350", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B360", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B363", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B365", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B366", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B370", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B420", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1eb5ea")));
STYLES.put("B440", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B450", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#2eab5c")));
STYLES.put("B460", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B461", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B470", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#1a70b8")));
STYLES.put("B490", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B491", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B500", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B570", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#9e348b")));
STYLES.put("B571", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#a2c613")));
STYLES.put("B574", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B580", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B581", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#e3001f")));
STYLES.put("B620", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#fbba00")));
STYLES.put("B631", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("B700", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.BLACK, Style.parseColor("#f39100")));
STYLES.put("BN31", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#9e348b")));
STYLES.put("BN41", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("BN43", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("BN56", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#2eab5c")));
STYLES.put("BN57", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1eb5ea")));
STYLES.put("BN70", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
STYLES.put("BN62", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
// Hamburg
// STYLES.put("SS1", new Style(Style.parseColor("#00933B"), Style.WHITE));
// STYLES.put("SS11", new Style(Style.WHITE, Style.parseColor("#00933B"), Style.parseColor("#00933B")));
// STYLES.put("SS2", new Style(Style.WHITE, Style.parseColor("#9D271A"), Style.parseColor("#9D271A")));
// STYLES.put("SS21", new Style(Style.parseColor("#9D271A"), Style.WHITE));
// STYLES.put("SS3", new Style(Style.parseColor("#411273"), Style.WHITE));
// STYLES.put("SS31", new Style(Style.parseColor("#411273"), Style.WHITE));
// Hamburg
// STYLES.put("SS1", new Style(Style.parseColor("#00933B"), Style.WHITE));
// STYLES.put("SS11", new Style(Style.WHITE, Style.parseColor("#00933B"),
// Style.parseColor("#00933B")));
// STYLES.put("SS2", new Style(Style.WHITE, Style.parseColor("#9D271A"),
// Style.parseColor("#9D271A")));
// STYLES.put("SS21", new Style(Style.parseColor("#9D271A"), Style.WHITE));
// STYLES.put("SS3", new Style(Style.parseColor("#411273"), Style.WHITE));
// STYLES.put("SS31", new Style(Style.parseColor("#411273"), Style.WHITE));
STYLES.put("UU1", new Style(Style.parseColor("#044895"), Style.WHITE));
STYLES.put("UU2", new Style(Style.parseColor("#DC2B19"), Style.WHITE));
STYLES.put("UU3", new Style(Style.parseColor("#EE9D16"), Style.WHITE));
STYLES.put("UU4", new Style(Style.parseColor("#13A59D"), Style.WHITE));
}
STYLES.put("UU1", new Style(Style.parseColor("#044895"), Style.WHITE));
STYLES.put("UU2", new Style(Style.parseColor("#DC2B19"), Style.WHITE));
STYLES.put("UU3", new Style(Style.parseColor("#EE9D16"), Style.WHITE));
STYLES.put("UU4", new Style(Style.parseColor("#13A59D"), Style.WHITE));
}
}

File diff suppressed because it is too large Load diff

View file

@ -57,381 +57,350 @@ import de.schildbach.pte.util.ParserUtils;
/**
* @author Andreas Schildbach
*/
public class InvgProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://fpa.invg.de/bin/";
// http://invg.hafas.de/bin/
private static final Product[] PRODUCTS_MAP = { null, null, null, null, null, null, null, null, null, null };
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
public class InvgProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://fpa.invg.de/bin/";
// http://invg.hafas.de/bin/
private static final Product[] PRODUCTS_MAP = { null, null, null, null, null, null, null, null, null, null };
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
public InvgProvider()
{
super(NetworkId.INVG, API_BASE, "dn", PRODUCTS_MAP);
public InvgProvider() {
super(NetworkId.INVG, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardCanDoEquivs(false);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
setExtXmlEndpoint(API_BASE + "extxml.exe");
}
setStationBoardCanDoEquivs(false);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
setExtXmlEndpoint(API_BASE + "extxml.exe");
}
@Override
protected boolean hasCapability(final Capability capability)
{
if (capability == Capability.TRIPS)
return false;
else
return super.hasCapability(capability);
}
@Override
protected boolean hasCapability(final Capability capability) {
if (capability == Capability.TRIPS)
return false;
else
return super.hasCapability(capability);
}
private static final String[] PLACES = { "Ingolstadt", "München" };
private static final String[] PLACES = { "Ingolstadt", "München" };
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxStations) throws IOException
{
if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxStations) throws IOException {
if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern
.compile(
".*?" //
+ "(?:" //
+ "<div class=\"summary clearfix\">.*?<div class=\"block\">.*?(<div>.*?</div>.*?<div class=\"last\">.*?</div>).*?</div>.*?" //
+ "<div class=\"linkGroup\">.*?input=(\\d+).*?" // locationId
+ "(?:<table class=\"resultTable\" cellspacing=\"0\">(.*?)</table>|(verkehren an dieser Haltestelle keine))"//
+ "|(Eingabe kann nicht interpretiert)|(Verbindung zum Server konnte leider nicht hergestellt werden|kann vom Server derzeit leider nicht bearbeitet werden))" //
+ ".*?" //
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(".*?" //
+ "<span class=\"output\">(.*?)<.*?" // location
+ "<span class=\"output\">\n(\\d{2}\\.\\d{2}\\.\\d{2}).*?" // date
+ "Abfahrt (\\d{1,2}:\\d{2}).*?" // time
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"(depboard-\\w*)\">(.*?)</tr>", Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
+ "<td class=\"time\">(\\d{1,2}:\\d{2})</td>\n" // plannedTime
+ "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" //
+ "(?:&nbsp;|<span class=\"rtLimit\\d\">(p&#252;nktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
+ ")?.*?" //
+ "<img class=\"product\" src=\"/hafas-res/img/products/(\\w+)_pic\\.gif\"[^>]*>\\s*(.*?)\\s*</.*?" // type,
// line
+ "<strong>\n" //
+ "<a href=\"http://fpa\\.invg\\.de/bin/stboard\\.exe/dn\\?input=(\\d+)&[^>]*>" // destinationId
+ "\\s*(.*?)\\s*</a>\n" // destination
+ "</strong>.*?" //
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(".*?" //
+ "(?:" //
+ "<div class=\"summary clearfix\">.*?<div class=\"block\">.*?(<div>.*?</div>.*?<div class=\"last\">.*?</div>).*?</div>.*?" //
+ "<div class=\"linkGroup\">.*?input=(\\d+).*?" // locationId
+ "(?:<table class=\"resultTable\" cellspacing=\"0\">(.*?)</table>|(verkehren an dieser Haltestelle keine))"//
+ "|(Eingabe kann nicht interpretiert)|(Verbindung zum Server konnte leider nicht hergestellt werden|kann vom Server derzeit leider nicht bearbeitet werden))" //
+ ".*?" //
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(
".*?" //
+ "<span class=\"output\">(.*?)<.*?" // location
+ "<span class=\"output\">\n(\\d{2}\\.\\d{2}\\.\\d{2}).*?" // date
+ "Abfahrt (\\d{1,2}:\\d{2}).*?" // time
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"(depboard-\\w*)\">(.*?)</tr>",
Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(
".*?" //
+ "<td class=\"time\">(\\d{1,2}:\\d{2})</td>\n" // plannedTime
+ "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" //
+ "(?:&nbsp;|<span class=\"rtLimit\\d\">(p&#252;nktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
+ ")?.*?" //
+ "<img class=\"product\" src=\"/hafas-res/img/products/(\\w+)_pic\\.gif\"[^>]*>\\s*(.*?)\\s*</.*?" // type,
// line
+ "<strong>\n" //
+ "<a href=\"http://fpa\\.invg\\.de/bin/stboard\\.exe/dn\\?input=(\\d+)&[^>]*>" // destinationId
+ "\\s*(.*?)\\s*</a>\n" // destination
+ "</strong>.*?" //
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
, Pattern.DOTALL);
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
checkNotNull(Strings.emptyToNull(stationId));
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
checkNotNull(Strings.emptyToNull(stationId));
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final QueryDeparturesResult result = new QueryDeparturesResult(header);
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final QueryDeparturesResult result = new QueryDeparturesResult(header);
// scrape page
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null);
final CharSequence page = httpClient.get(uri.toString());
// scrape page
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null);
final CharSequence page = httpClient.get(uri.toString());
// parse page
final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page);
if (mHeadCoarse.matches())
{
// messages
if (mHeadCoarse.group(4) != null)
{
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId),
Collections.<Departure> emptyList(), null));
return result;
}
else if (mHeadCoarse.group(5) != null)
return new QueryDeparturesResult(header, Status.INVALID_STATION);
else if (mHeadCoarse.group(6) != null)
return new QueryDeparturesResult(header, Status.SERVICE_DOWN);
// parse page
final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page);
if (mHeadCoarse.matches()) {
// messages
if (mHeadCoarse.group(4) != null) {
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId),
Collections.<Departure> emptyList(), null));
return result;
} else if (mHeadCoarse.group(5) != null)
return new QueryDeparturesResult(header, Status.INVALID_STATION);
else if (mHeadCoarse.group(6) != null)
return new QueryDeparturesResult(header, Status.SERVICE_DOWN);
final String locationId = mHeadCoarse.group(2);
final String locationId = mHeadCoarse.group(2);
final Matcher mHeadFine = P_DEPARTURES_HEAD_FINE.matcher(mHeadCoarse.group(1));
if (mHeadFine.matches())
{
final String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mHeadFine.group(1)));
final Calendar currentTime = new GregorianCalendar(timeZone);
currentTime.clear();
ParserUtils.parseGermanDate(currentTime, mHeadFine.group(2));
ParserUtils.parseEuropeanTime(currentTime, mHeadFine.group(3));
final List<Departure> departures = new ArrayList<Departure>(8);
String oldZebra = null;
final Matcher mHeadFine = P_DEPARTURES_HEAD_FINE.matcher(mHeadCoarse.group(1));
if (mHeadFine.matches()) {
final String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mHeadFine.group(1)));
final Calendar currentTime = new GregorianCalendar(timeZone);
currentTime.clear();
ParserUtils.parseGermanDate(currentTime, mHeadFine.group(2));
ParserUtils.parseEuropeanTime(currentTime, mHeadFine.group(3));
final List<Departure> departures = new ArrayList<Departure>(8);
String oldZebra = null;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(3));
while (mDepCoarse.find())
{
final String zebra = mDepCoarse.group(1);
if (oldZebra != null && zebra.equals(oldZebra))
throw new IllegalArgumentException("missed row? last:" + zebra);
else
oldZebra = zebra;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(3));
while (mDepCoarse.find()) {
final String zebra = mDepCoarse.group(1);
if (oldZebra != null && zebra.equals(oldZebra))
throw new IllegalArgumentException("missed row? last:" + zebra);
else
oldZebra = zebra;
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
if (mDepFine.matches())
{
final Calendar plannedTime = new GregorianCalendar(timeZone);
plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseEuropeanTime(plannedTime, mDepFine.group(1));
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
if (mDepFine.matches()) {
final Calendar plannedTime = new GregorianCalendar(timeZone);
plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseEuropeanTime(plannedTime, mDepFine.group(1));
if (plannedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
plannedTime.add(Calendar.DAY_OF_MONTH, 1);
if (plannedTime.getTimeInMillis()
- currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
plannedTime.add(Calendar.DAY_OF_MONTH, 1);
final Calendar predictedTime;
final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2));
if (prognosis != null)
{
predictedTime = new GregorianCalendar(timeZone);
if (prognosis.equals("pünktlich"))
{
predictedTime.setTimeInMillis(plannedTime.getTimeInMillis());
}
else
{
predictedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseEuropeanTime(predictedTime, prognosis);
}
}
else
{
predictedTime = null;
}
final Calendar predictedTime;
final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2));
if (prognosis != null) {
predictedTime = new GregorianCalendar(timeZone);
if (prognosis.equals("pünktlich")) {
predictedTime.setTimeInMillis(plannedTime.getTimeInMillis());
} else {
predictedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseEuropeanTime(predictedTime, prognosis);
}
} else {
predictedTime = null;
}
final String lineType = mDepFine.group(3);
final String lineType = mDepFine.group(3);
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final String destinationId = mDepFine.group(5);
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final Location destination;
if (destinationId != null)
{
final String[] destinationPlaceAndName = splitStationName(destinationName);
destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0], destinationPlaceAndName[1]);
}
else
{
destination = new Location(LocationType.ANY, null, null, destinationName);
}
final String destinationId = mDepFine.group(5);
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final Location destination;
if (destinationId != null) {
final String[] destinationPlaceAndName = splitStationName(destinationName);
destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0],
destinationPlaceAndName[1]);
} else {
destination = new Location(LocationType.ANY, null, null, destinationName);
}
final Position position = parsePosition(ParserUtils.resolveEntities(mDepFine.group(7)));
final Position position = parsePosition(ParserUtils.resolveEntities(mDepFine.group(7)));
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, destination, null, null);
final Departure dep = new Departure(plannedTime.getTime(),
predictedTime != null ? predictedTime.getTime() : null, line, position, destination,
null, null);
if (!departures.contains(dep))
departures.add(dep);
}
else
{
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + stationId);
}
}
if (!departures.contains(dep))
departures.add(dep);
} else {
throw new IllegalArgumentException(
"cannot parse '" + mDepCoarse.group(2) + "' on " + stationId);
}
}
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, locationId, placeAndName[0], placeAndName[1]),
departures, null));
return result;
}
else
{
throw new IllegalArgumentException("cannot parse '" + mHeadCoarse.group(1) + "' on " + stationId);
}
}
else
{
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
}
}
result.stationDepartures.add(new StationDepartures(
new Location(LocationType.STATION, locationId, placeAndName[0], placeAndName[1]), departures,
null));
return result;
} else {
throw new IllegalArgumentException("cannot parse '" + mHeadCoarse.group(1) + "' on " + stationId);
}
} else {
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
}
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
return queryMoreTripsXml(context, later);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
return queryMoreTripsXml(context, later);
}
protected static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Bus\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_NACHTBUS = Pattern.compile("Bus\\s*N\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_BUS_S = Pattern.compile("Bus\\s*S\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_BUS_X = Pattern.compile("Bus\\s*X\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Bus\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_NACHTBUS = Pattern.compile("Bus\\s*N\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_BUS_S = Pattern.compile("Bus\\s*S\\s*(\\d+)");
protected static final Pattern P_NORMALIZE_LINE_BUS_X = Pattern.compile("Bus\\s*X\\s*(\\d+)");
@Override
protected Line parseLine(final String type, final String line, final boolean wheelchairAccess)
{
if ("1".equals(type))
{
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
if (mBus.matches())
{
final String label = mBus.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
@Override
protected Line parseLine(final String type, final String line, final boolean wheelchairAccess) {
if ("1".equals(type)) {
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
if (mBus.matches()) {
final String label = mBus.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line);
if (mNachtbus.matches())
{
final String label = "N" + mNachtbus.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line);
if (mNachtbus.matches()) {
final String label = "N" + mNachtbus.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line);
if (mBusS.matches())
{
final String label = "S" + mBusS.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line);
if (mBusS.matches()) {
final String label = "S" + mBusS.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line);
if (mBusX.matches())
{
final String label = "X" + mBusX.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
}
final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line);
if (mBusX.matches()) {
final String label = "X" + mBusX.group(1);
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
}
}
return super.parseLine(type, line, wheelchairAccess);
}
return super.parseLine(type, line, wheelchairAccess);
}
@Override
protected Product normalizeType(final String type)
{
if ("1".equals(type))
return Product.BUS;
@Override
protected Product normalizeType(final String type) {
if ("1".equals(type))
return Product.BUS;
// skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
// skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
STYLES.put("B10", new Style(Style.parseColor("#DA2510"), Style.WHITE));
STYLES.put("B11", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("B15", new Style(Style.parseColor("#84C326"), Style.BLACK));
STYLES.put("B16", new Style(Style.parseColor("#5D452E"), Style.WHITE));
STYLES.put("B17", new Style(Style.parseColor("#E81100"), Style.BLACK));
STYLES.put("B18", new Style(Style.parseColor("#79316C"), Style.WHITE));
STYLES.put("B20", new Style(Style.parseColor("#EA891C"), Style.BLACK));
STYLES.put("B21", new Style(Style.parseColor("#31B2EA"), Style.BLACK));
STYLES.put("B25", new Style(Style.parseColor("#7F65A0"), Style.WHITE));
STYLES.put("B26", new Style(Style.parseColor("#00BF73"), Style.WHITE)); // not present in Fahrplan 2012/2013
STYLES.put("B30", new Style(Style.parseColor("#901E78"), Style.WHITE));
STYLES.put("B31", new Style(Style.parseColor("#DCE722"), Style.BLACK));
STYLES.put("B40", new Style(Style.parseColor("#009240"), Style.WHITE));
STYLES.put("B41", new Style(Style.parseColor("#7BC5B1"), Style.BLACK));
STYLES.put("B44", new Style(Style.parseColor("#EA77A6"), Style.WHITE));
STYLES.put("B50", new Style(Style.parseColor("#FACF00"), Style.BLACK));
STYLES.put("B51", new Style(Style.parseColor("#C13C00"), Style.WHITE));
STYLES.put("B52", new Style(Style.parseColor("#94F0D4"), Style.BLACK));
STYLES.put("B53", new Style(Style.parseColor("#BEB405"), Style.BLACK));
STYLES.put("B55", new Style(Style.parseColor("#FFF500"), Style.BLACK));
STYLES.put("B60", new Style(Style.parseColor("#0072B7"), Style.WHITE));
STYLES.put("B61", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan 2012/2013
STYLES.put("B62", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan 2012/2013
STYLES.put("B65", new Style(Style.parseColor("#B7DDD2"), Style.BLACK));
STYLES.put("B70", new Style(Style.parseColor("#D49016"), Style.BLACK));
STYLES.put("B71", new Style(Style.parseColor("#996600"), Style.BLACK)); // not present in Fahrplan 2012/2013
STYLES.put("B85", new Style(Style.parseColor("#F6BAD3"), Style.BLACK));
STYLES.put("B111", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
static {
STYLES.put("B10", new Style(Style.parseColor("#DA2510"), Style.WHITE));
STYLES.put("B11", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("B15", new Style(Style.parseColor("#84C326"), Style.BLACK));
STYLES.put("B16", new Style(Style.parseColor("#5D452E"), Style.WHITE));
STYLES.put("B17", new Style(Style.parseColor("#E81100"), Style.BLACK));
STYLES.put("B18", new Style(Style.parseColor("#79316C"), Style.WHITE));
STYLES.put("B20", new Style(Style.parseColor("#EA891C"), Style.BLACK));
STYLES.put("B21", new Style(Style.parseColor("#31B2EA"), Style.BLACK));
STYLES.put("B25", new Style(Style.parseColor("#7F65A0"), Style.WHITE));
STYLES.put("B26", new Style(Style.parseColor("#00BF73"), Style.WHITE)); // not present in Fahrplan
// 2012/2013
STYLES.put("B30", new Style(Style.parseColor("#901E78"), Style.WHITE));
STYLES.put("B31", new Style(Style.parseColor("#DCE722"), Style.BLACK));
STYLES.put("B40", new Style(Style.parseColor("#009240"), Style.WHITE));
STYLES.put("B41", new Style(Style.parseColor("#7BC5B1"), Style.BLACK));
STYLES.put("B44", new Style(Style.parseColor("#EA77A6"), Style.WHITE));
STYLES.put("B50", new Style(Style.parseColor("#FACF00"), Style.BLACK));
STYLES.put("B51", new Style(Style.parseColor("#C13C00"), Style.WHITE));
STYLES.put("B52", new Style(Style.parseColor("#94F0D4"), Style.BLACK));
STYLES.put("B53", new Style(Style.parseColor("#BEB405"), Style.BLACK));
STYLES.put("B55", new Style(Style.parseColor("#FFF500"), Style.BLACK));
STYLES.put("B60", new Style(Style.parseColor("#0072B7"), Style.WHITE));
STYLES.put("B61", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan
// 2012/2013
STYLES.put("B62", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan
// 2012/2013
STYLES.put("B65", new Style(Style.parseColor("#B7DDD2"), Style.BLACK));
STYLES.put("B70", new Style(Style.parseColor("#D49016"), Style.BLACK));
STYLES.put("B71", new Style(Style.parseColor("#996600"), Style.BLACK)); // not present in Fahrplan
// 2012/2013
STYLES.put("B85", new Style(Style.parseColor("#F6BAD3"), Style.BLACK));
STYLES.put("B111", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("B9221", new Style(Style.rgb(217, 217, 255), Style.BLACK));
STYLES.put("B9226", new Style(Style.rgb(191, 255, 255), Style.BLACK));
STYLES.put("B9221", new Style(Style.rgb(217, 217, 255), Style.BLACK));
STYLES.put("B9226", new Style(Style.rgb(191, 255, 255), Style.BLACK));
STYLES.put("BN1", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN2", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN3", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN4", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN5", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN6", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN7", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN8", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN9", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN10", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN11", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN12", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN13", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN14", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN15", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN16", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN17", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN18", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN19", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN1", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN2", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN3", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN4", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN5", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN6", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN7", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN8", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN9", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN10", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN11", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN12", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN13", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN14", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN15", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN16", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN17", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN18", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN19", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BS1", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS2", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS3", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS4", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS5", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS6", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS7", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS8", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS9", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS1", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS2", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS3", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS4", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS5", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS6", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS7", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS8", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS9", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BX11", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("BX12", new Style(Style.parseColor("#B11839"), Style.BLACK));
STYLES.put("BX80", new Style(Style.parseColor("#FFFF40"), Style.BLACK));
STYLES.put("BX109", new Style(Style.WHITE, Style.BLACK, Style.BLACK));
}
STYLES.put("BX11", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("BX12", new Style(Style.parseColor("#B11839"), Style.BLACK));
STYLES.put("BX80", new Style(Style.parseColor("#FFFF40"), Style.BLACK));
STYLES.put("BX109", new Style(Style.WHITE, Style.BLACK, Style.BLACK));
}
}

View file

@ -22,33 +22,28 @@ import de.schildbach.pte.util.WordUtils;
/**
* @author Antonio El Khoury
*/
public class ItalyProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "it";
public class ItalyProvider extends AbstractNavitiaProvider {
private static String API_REGION = "it";
public ItalyProvider(final String apiBase, final String authorization)
{
super(NetworkId.IT, apiBase, authorization);
public ItalyProvider(final String apiBase, final String authorization) {
super(NetworkId.IT, apiBase, authorization);
setTimeZone("Europe/Rome");
}
setTimeZone("Europe/Rome");
}
public ItalyProvider(final String authorization)
{
super(NetworkId.IT, authorization);
public ItalyProvider(final String authorization) {
super(NetworkId.IT, authorization);
setTimeZone("Europe/Rome");
}
setTimeZone("Europe/Rome");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
@Override
protected String getLocationName(String name)
{
return WordUtils.capitalizeFully(name);
}
@Override
protected String getLocationName(String name) {
return WordUtils.capitalizeFully(name);
}
}

View file

@ -20,14 +20,12 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class IvbProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://efa.ivb.at/ivb/";
public class IvbProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://efa.ivb.at/ivb/";
public IvbProvider()
{
super(NetworkId.IVB, API_BASE);
public IvbProvider() {
super(NetworkId.IVB, API_BASE);
setUseRouteIndexAsTripId(false);
}
setUseRouteIndexAsTripId(false);
}
}

View file

@ -35,67 +35,57 @@ import de.schildbach.pte.dto.Product;
*
* @author Andreas Schildbach
*/
public class JetProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://planner.jet.org.il/bin/";
private static final Product[] PRODUCTS_MAP = { null, null, Product.TRAM, Product.BUS };
public class JetProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://planner.jet.org.il/bin/";
private static final Product[] PRODUCTS_MAP = { null, null, Product.TRAM, Product.BUS };
public JetProvider()
{
super(NetworkId.JET, API_BASE, "yn", PRODUCTS_MAP);
public JetProvider() {
super(NetworkId.JET, API_BASE, "yn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
{
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
} else if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
private static final Pattern P_NORMALIZE_BUS = Pattern.compile("([א]?\\d{1,3})#");
private static final Pattern P_NORMALIZE_BUS = Pattern.compile("([א]?\\d{1,3})#");
@Override
protected Line parseLineAndType(final String lineAndType)
{
if ("רק1#".equals(lineAndType))
return newLine(Product.TRAM, "רק1", null);
@Override
protected Line parseLineAndType(final String lineAndType) {
if ("רק1#".equals(lineAndType))
return newLine(Product.TRAM, "רק1", null);
if ("א 11#".equals(lineAndType) || "11א#".equals(lineAndType))
return newLine(Product.BUS, "א11", null);
if ("א 11#".equals(lineAndType) || "11א#".equals(lineAndType))
return newLine(Product.BUS, "א11", null);
final Matcher mBus = P_NORMALIZE_BUS.matcher(lineAndType);
if (mBus.matches())
return newLine(Product.BUS, mBus.group(1), null);
final Matcher mBus = P_NORMALIZE_BUS.matcher(lineAndType);
if (mBus.matches())
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

@ -31,140 +31,132 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class KvvProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://213.144.24.66/kvv2/";
public class KvvProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://213.144.24.66/kvv2/";
public KvvProvider()
{
this(API_BASE);
}
public KvvProvider() {
this(API_BASE);
}
public KvvProvider(final String apiBase)
{
super(NetworkId.KVV, apiBase);
public KvvProvider(final String apiBase) {
super(NetworkId.KVV, apiBase);
setStyles(STYLES);
setSessionCookieName("HASESSIONID");
}
setStyles(STYLES);
setSessionCookieName("HASESSIONID");
}
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
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, @Nullable String symbol,
@Nullable String name, @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if (symbol != null)
{
final Matcher m = P_LINE.matcher(symbol);
if (m.matches())
symbol = m.group(1);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
@Nullable String symbol, @Nullable String name, @Nullable String longName, final @Nullable String trainType,
final @Nullable String trainNum, final @Nullable String trainName) {
if (symbol != null) {
final Matcher m = P_LINE.matcher(symbol);
if (m.matches())
symbol = m.group(1);
}
if (name != null)
{
final Matcher m = P_LINE.matcher(name);
if (m.matches())
name = m.group(1);
}
if (name != null) {
final Matcher m = P_LINE.matcher(name);
if (m.matches())
name = m.group(1);
}
if (longName != null)
{
final Matcher m = P_LINE.matcher(longName);
if (m.matches())
longName = m.group(1);
}
if (longName != null) {
final Matcher m = P_LINE.matcher(longName);
if (m.matches())
longName = m.group(1);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// S-Bahn
STYLES.put("SS1", new Style(Style.parseColor("#00a76c"), Style.WHITE));
STYLES.put("SS11", new Style(Style.parseColor("#00a76c"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#9f68ab"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#00a99d"), Style.BLACK));
STYLES.put("SS31", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS32", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS33", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#9f184c"), Style.WHITE));
STYLES.put("SS41", new Style(Style.parseColor("#9f184c"), Style.WHITE));
STYLES.put("SS5", new Style(Style.parseColor("#f69795"), Style.BLACK));
STYLES.put("SS51", new Style(Style.parseColor("#f69795"), Style.BLACK));
STYLES.put("SS52", new Style(Style.parseColor("#f69795"), Style.BLACK));
STYLES.put("SS6", new Style(Style.parseColor("#292369"), Style.WHITE));
STYLES.put("SS7", new Style(Style.parseColor("#fff200"), Style.BLACK));
STYLES.put("SS9", new Style(Style.parseColor("#fab499"), Style.BLACK));
static {
// S-Bahn
STYLES.put("SS1", new Style(Style.parseColor("#00a76c"), Style.WHITE));
STYLES.put("SS11", new Style(Style.parseColor("#00a76c"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#9f68ab"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#00a99d"), Style.BLACK));
STYLES.put("SS31", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS32", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS33", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#9f184c"), Style.WHITE));
STYLES.put("SS41", new Style(Style.parseColor("#9f184c"), Style.WHITE));
STYLES.put("SS5", new Style(Style.parseColor("#f69795"), Style.BLACK));
STYLES.put("SS51", new Style(Style.parseColor("#f69795"), Style.BLACK));
STYLES.put("SS52", new Style(Style.parseColor("#f69795"), Style.BLACK));
STYLES.put("SS6", new Style(Style.parseColor("#292369"), Style.WHITE));
STYLES.put("SS7", new Style(Style.parseColor("#fff200"), Style.BLACK));
STYLES.put("SS9", new Style(Style.parseColor("#fab499"), Style.BLACK));
// S-Bahn RheinNeckar
STYLES.put("ddb|SS3", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("ddb|SS33", new Style(Style.parseColor("#8d5ca6"), Style.WHITE));
STYLES.put("ddb|SS4", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("ddb|SS5", new Style(Style.parseColor("#f89835"), Style.WHITE));
// S-Bahn RheinNeckar
STYLES.put("ddb|SS3", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("ddb|SS33", new Style(Style.parseColor("#8d5ca6"), Style.WHITE));
STYLES.put("ddb|SS4", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("ddb|SS5", new Style(Style.parseColor("#f89835"), Style.WHITE));
// Tram
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T1E", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#0071bc"), Style.WHITE));
STYLES.put("T2E", new Style(Shape.RECT, Style.parseColor("#0071bc"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#947139"), Style.WHITE));
STYLES.put("T3E", new Style(Shape.RECT, Style.parseColor("#947139"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("T4E", new Style(Shape.RECT, Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("T5E", new Style(Shape.RECT, Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#80c342"), Style.WHITE));
STYLES.put("T6E", new Style(Shape.RECT, Style.parseColor("#80c342"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#58595b"), Style.WHITE));
STYLES.put("T7E", new Style(Shape.RECT, Style.parseColor("#58595b"), Style.WHITE));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#f7931d"), Style.BLACK));
STYLES.put("T8E", new Style(Shape.RECT, Style.parseColor("#f7931d"), Style.BLACK));
// Tram
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T1E", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#0071bc"), Style.WHITE));
STYLES.put("T2E", new Style(Shape.RECT, Style.parseColor("#0071bc"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#947139"), Style.WHITE));
STYLES.put("T3E", new Style(Shape.RECT, Style.parseColor("#947139"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("T4E", new Style(Shape.RECT, Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("T5E", new Style(Shape.RECT, Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#80c342"), Style.WHITE));
STYLES.put("T6E", new Style(Shape.RECT, Style.parseColor("#80c342"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#58595b"), Style.WHITE));
STYLES.put("T7E", new Style(Shape.RECT, Style.parseColor("#58595b"), Style.WHITE));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#f7931d"), Style.BLACK));
STYLES.put("T8E", new Style(Shape.RECT, Style.parseColor("#f7931d"), Style.BLACK));
// Bus - only used on bus plan
// LINES.put("B21", new Style(Shape.CIRCLE, Style.parseColor("#2e3092"), Style.WHITE));
// LINES.put("B22", new Style(Shape.CIRCLE, Style.parseColor("#00aeef"), Style.WHITE));
// LINES.put("B23", new Style(Shape.CIRCLE, Style.parseColor("#56c5d0"), Style.WHITE));
// LINES.put("B24", new Style(Shape.CIRCLE, Style.parseColor("#a1d1e6"), Style.WHITE));
// LINES.put("B26", new Style(Shape.CIRCLE, Style.parseColor("#2e3092"), Style.WHITE));
// LINES.put("B27", new Style(Shape.CIRCLE, Style.parseColor("#00aeef"), Style.WHITE));
// LINES.put("B30", new Style(Shape.CIRCLE, Style.parseColor("#adbc72"), Style.WHITE));
// LINES.put("B31", new Style(Shape.CIRCLE, Style.parseColor("#62bb46"), Style.WHITE));
// LINES.put("B32", new Style(Shape.CIRCLE, Style.parseColor("#177752"), Style.WHITE));
// LINES.put("B42", new Style(Shape.CIRCLE, Style.parseColor("#177752"), Style.WHITE));
// LINES.put("B44", new Style(Shape.CIRCLE, Style.parseColor("#62bb46"), Style.WHITE));
// LINES.put("B47", new Style(Shape.CIRCLE, Style.parseColor("#adbc72"), Style.WHITE));
// LINES.put("B50", new Style(Shape.CIRCLE, Style.parseColor("#a25641"), Style.WHITE));
// LINES.put("B51", new Style(Shape.CIRCLE, Style.parseColor("#d2ab67"), Style.WHITE));
// LINES.put("B52", new Style(Shape.CIRCLE, Style.parseColor("#a25641"), Style.WHITE));
// LINES.put("B55", new Style(Shape.CIRCLE, Style.parseColor("#806a50"), Style.WHITE));
// LINES.put("B60", new Style(Shape.CIRCLE, Style.parseColor("#806a50"), Style.WHITE));
// LINES.put("B62", new Style(Shape.CIRCLE, Style.parseColor("#d2ab67"), Style.WHITE));
// LINES.put("B70", new Style(Shape.CIRCLE, Style.parseColor("#574187"), Style.WHITE));
// LINES.put("B71", new Style(Shape.CIRCLE, Style.parseColor("#874487"), Style.WHITE));
// LINES.put("B72", new Style(Shape.CIRCLE, Style.parseColor("#9b95c9"), Style.WHITE));
// LINES.put("B73", new Style(Shape.CIRCLE, Style.parseColor("#574187"), Style.WHITE));
// LINES.put("B74", new Style(Shape.CIRCLE, Style.parseColor("#9b95c9"), Style.WHITE));
// LINES.put("B75", new Style(Shape.CIRCLE, Style.parseColor("#874487"), Style.WHITE));
// LINES.put("B107", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// LINES.put("B118", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// LINES.put("B123", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// Bus - only used on bus plan
// LINES.put("B21", new Style(Shape.CIRCLE, Style.parseColor("#2e3092"), Style.WHITE));
// LINES.put("B22", new Style(Shape.CIRCLE, Style.parseColor("#00aeef"), Style.WHITE));
// LINES.put("B23", new Style(Shape.CIRCLE, Style.parseColor("#56c5d0"), Style.WHITE));
// LINES.put("B24", new Style(Shape.CIRCLE, Style.parseColor("#a1d1e6"), Style.WHITE));
// LINES.put("B26", new Style(Shape.CIRCLE, Style.parseColor("#2e3092"), Style.WHITE));
// LINES.put("B27", new Style(Shape.CIRCLE, Style.parseColor("#00aeef"), Style.WHITE));
// LINES.put("B30", new Style(Shape.CIRCLE, Style.parseColor("#adbc72"), Style.WHITE));
// LINES.put("B31", new Style(Shape.CIRCLE, Style.parseColor("#62bb46"), Style.WHITE));
// LINES.put("B32", new Style(Shape.CIRCLE, Style.parseColor("#177752"), Style.WHITE));
// LINES.put("B42", new Style(Shape.CIRCLE, Style.parseColor("#177752"), Style.WHITE));
// LINES.put("B44", new Style(Shape.CIRCLE, Style.parseColor("#62bb46"), Style.WHITE));
// LINES.put("B47", new Style(Shape.CIRCLE, Style.parseColor("#adbc72"), Style.WHITE));
// LINES.put("B50", new Style(Shape.CIRCLE, Style.parseColor("#a25641"), Style.WHITE));
// LINES.put("B51", new Style(Shape.CIRCLE, Style.parseColor("#d2ab67"), Style.WHITE));
// LINES.put("B52", new Style(Shape.CIRCLE, Style.parseColor("#a25641"), Style.WHITE));
// LINES.put("B55", new Style(Shape.CIRCLE, Style.parseColor("#806a50"), Style.WHITE));
// LINES.put("B60", new Style(Shape.CIRCLE, Style.parseColor("#806a50"), Style.WHITE));
// LINES.put("B62", new Style(Shape.CIRCLE, Style.parseColor("#d2ab67"), Style.WHITE));
// LINES.put("B70", new Style(Shape.CIRCLE, Style.parseColor("#574187"), Style.WHITE));
// LINES.put("B71", new Style(Shape.CIRCLE, Style.parseColor("#874487"), Style.WHITE));
// LINES.put("B72", new Style(Shape.CIRCLE, Style.parseColor("#9b95c9"), Style.WHITE));
// LINES.put("B73", new Style(Shape.CIRCLE, Style.parseColor("#574187"), Style.WHITE));
// LINES.put("B74", new Style(Shape.CIRCLE, Style.parseColor("#9b95c9"), Style.WHITE));
// LINES.put("B75", new Style(Shape.CIRCLE, Style.parseColor("#874487"), Style.WHITE));
// LINES.put("B107", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// LINES.put("B118", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// LINES.put("B123", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// Nightliner
STYLES.put("BNL3", new Style(Style.parseColor("#947139"), Style.WHITE));
STYLES.put("BNL4", new Style(Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("BNL5", new Style(Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("BNL6", new Style(Style.parseColor("#80c342"), Style.WHITE));
// Nightliner
STYLES.put("BNL3", new Style(Style.parseColor("#947139"), Style.WHITE));
STYLES.put("BNL4", new Style(Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("BNL5", new Style(Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("BNL6", new Style(Style.parseColor("#80c342"), Style.WHITE));
// Anruf-Linien-Taxi
STYLES.put("BALT6", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT11", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT12", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT13", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT14", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT16", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
}
// Anruf-Linien-Taxi
STYLES.put("BALT6", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT11", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT12", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT13", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT14", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT16", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
}
}

View file

@ -25,53 +25,50 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class LinzProvider extends AbstractEfaProvider
{
public static final String API_BASE = "https://www.linzag.at/linz2/";
public class LinzProvider extends AbstractEfaProvider {
public static final String API_BASE = "https://www.linzag.at/linz2/";
// http://www.linzag.at/static/
// http://www.linzag.at/static/
public LinzProvider()
{
super(NetworkId.LINZ, API_BASE);
public LinzProvider() {
super(NetworkId.LINZ, API_BASE);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
}
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
STYLES.put("B11", new Style(Style.Shape.RECT, Style.parseColor("#f27b02"), Style.WHITE));
STYLES.put("B12", new Style(Style.Shape.RECT, Style.parseColor("#00863a"), Style.WHITE));
STYLES.put("B17", new Style(Style.Shape.RECT, Style.parseColor("#f47a00"), Style.WHITE));
STYLES.put("B18", new Style(Style.Shape.RECT, Style.parseColor("#0066b5"), Style.WHITE));
STYLES.put("B19", new Style(Style.Shape.RECT, Style.parseColor("#f36aa8"), Style.WHITE));
STYLES.put("B25", new Style(Style.Shape.RECT, Style.parseColor("#d29f08"), Style.WHITE));
STYLES.put("B26", new Style(Style.Shape.RECT, Style.parseColor("#0070b6"), Style.WHITE));
STYLES.put("B27", new Style(Style.Shape.RECT, Style.parseColor("#96c41c"), Style.WHITE));
STYLES.put("B33", new Style(Style.Shape.RECT, Style.parseColor("#6d1f82"), Style.WHITE));
STYLES.put("B38", new Style(Style.Shape.RECT, Style.parseColor("#ef7b02"), Style.WHITE));
STYLES.put("B43", new Style(Style.Shape.RECT, Style.parseColor("#00ace3"), Style.WHITE));
STYLES.put("B45", new Style(Style.Shape.RECT, Style.parseColor("#db0c10"), Style.WHITE));
STYLES.put("B46", new Style(Style.Shape.RECT, Style.parseColor("#00acea"), Style.WHITE));
STYLES.put("B101", new Style(Style.Shape.RECT, Style.parseColor("#fdba00"), Style.WHITE));
STYLES.put("B102", new Style(Style.Shape.RECT, Style.parseColor("#9d701f"), Style.WHITE));
STYLES.put("B103", new Style(Style.Shape.RECT, Style.parseColor("#019793"), Style.WHITE));
STYLES.put("B104", new Style(Style.Shape.RECT, Style.parseColor("#699c23"), Style.WHITE));
STYLES.put("B105", new Style(Style.Shape.RECT, Style.parseColor("#004b9e"), Style.WHITE));
STYLES.put("B191", new Style(Style.Shape.RECT, Style.parseColor("#1293a8"), Style.WHITE));
STYLES.put("B192", new Style(Style.Shape.RECT, Style.parseColor("#947ab7"), Style.WHITE));
STYLES.put("BN2", new Style(Style.Shape.RECT, Style.parseColor("#005aac"), Style.WHITE)); // night
STYLES.put("BN3", new Style(Style.Shape.RECT, Style.parseColor("#b80178"), Style.WHITE)); // night
STYLES.put("BN4", new Style(Style.Shape.RECT, Style.parseColor("#93be01"), Style.WHITE)); // night
static {
STYLES.put("B11", new Style(Style.Shape.RECT, Style.parseColor("#f27b02"), Style.WHITE));
STYLES.put("B12", new Style(Style.Shape.RECT, Style.parseColor("#00863a"), Style.WHITE));
STYLES.put("B17", new Style(Style.Shape.RECT, Style.parseColor("#f47a00"), Style.WHITE));
STYLES.put("B18", new Style(Style.Shape.RECT, Style.parseColor("#0066b5"), Style.WHITE));
STYLES.put("B19", new Style(Style.Shape.RECT, Style.parseColor("#f36aa8"), Style.WHITE));
STYLES.put("B25", new Style(Style.Shape.RECT, Style.parseColor("#d29f08"), Style.WHITE));
STYLES.put("B26", new Style(Style.Shape.RECT, Style.parseColor("#0070b6"), Style.WHITE));
STYLES.put("B27", new Style(Style.Shape.RECT, Style.parseColor("#96c41c"), Style.WHITE));
STYLES.put("B33", new Style(Style.Shape.RECT, Style.parseColor("#6d1f82"), Style.WHITE));
STYLES.put("B38", new Style(Style.Shape.RECT, Style.parseColor("#ef7b02"), Style.WHITE));
STYLES.put("B43", new Style(Style.Shape.RECT, Style.parseColor("#00ace3"), Style.WHITE));
STYLES.put("B45", new Style(Style.Shape.RECT, Style.parseColor("#db0c10"), Style.WHITE));
STYLES.put("B46", new Style(Style.Shape.RECT, Style.parseColor("#00acea"), Style.WHITE));
STYLES.put("B101", new Style(Style.Shape.RECT, Style.parseColor("#fdba00"), Style.WHITE));
STYLES.put("B102", new Style(Style.Shape.RECT, Style.parseColor("#9d701f"), Style.WHITE));
STYLES.put("B103", new Style(Style.Shape.RECT, Style.parseColor("#019793"), Style.WHITE));
STYLES.put("B104", new Style(Style.Shape.RECT, Style.parseColor("#699c23"), Style.WHITE));
STYLES.put("B105", new Style(Style.Shape.RECT, Style.parseColor("#004b9e"), Style.WHITE));
STYLES.put("B191", new Style(Style.Shape.RECT, Style.parseColor("#1293a8"), Style.WHITE));
STYLES.put("B192", new Style(Style.Shape.RECT, Style.parseColor("#947ab7"), Style.WHITE));
STYLES.put("BN2", new Style(Style.Shape.RECT, Style.parseColor("#005aac"), Style.WHITE)); // night
STYLES.put("BN3", new Style(Style.Shape.RECT, Style.parseColor("#b80178"), Style.WHITE)); // night
STYLES.put("BN4", new Style(Style.Shape.RECT, Style.parseColor("#93be01"), Style.WHITE)); // night
STYLES.put("T1", new Style(Style.Shape.RECT, Style.parseColor("#dd0b12"), Style.WHITE));
STYLES.put("TN1", new Style(Style.Shape.RECT, Style.parseColor("#db0e16"), Style.WHITE)); // night
STYLES.put("T2", new Style(Style.Shape.RECT, Style.parseColor("#dd0b12"), Style.WHITE));
STYLES.put("T3", new Style(Style.Shape.RECT, Style.parseColor("#dd0b12"), Style.WHITE));
STYLES.put("T1", new Style(Style.Shape.RECT, Style.parseColor("#dd0b12"), Style.WHITE));
STYLES.put("TN1", new Style(Style.Shape.RECT, Style.parseColor("#db0e16"), Style.WHITE)); // night
STYLES.put("T2", new Style(Style.Shape.RECT, Style.parseColor("#dd0b12"), Style.WHITE));
STYLES.put("T3", new Style(Style.Shape.RECT, Style.parseColor("#dd0b12"), Style.WHITE));
STYLES.put("C50", new Style(Style.Shape.RECT, Style.parseColor("#4eae2c"), Style.WHITE)); // Pöstlingbergbahn
}
STYLES.put("C50", new Style(Style.Shape.RECT, Style.parseColor("#4eae2c"), Style.WHITE)); // Pöstlingbergbahn
}
}

View file

@ -20,95 +20,91 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public final class LocationUtils
{
/**
* @param lat1
* latitude of origin point in decimal degrees
* @param lon1
* longitude of origin point in deceimal degrees
* @param lat2
* latitude of destination point in decimal degrees
* @param lon2
* longitude of destination point in decimal degrees
*
* @return distance in meters
*/
public static float computeDistance(double lat1, double lon1, double lat2, double lon2)
{
// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
// using the "Inverse Formula" (section 4)
public final class LocationUtils {
/**
* @param lat1
* latitude of origin point in decimal degrees
* @param lon1
* longitude of origin point in deceimal degrees
* @param lat2
* latitude of destination point in decimal degrees
* @param lon2
* longitude of destination point in decimal degrees
*
* @return distance in meters
*/
public static float computeDistance(double lat1, double lon1, double lat2, double lon2) {
// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
// using the "Inverse Formula" (section 4)
final int MAXITERS = 20;
// Convert lat/long to radians
lat1 *= Math.PI / 180.0;
lat2 *= Math.PI / 180.0;
lon1 *= Math.PI / 180.0;
lon2 *= Math.PI / 180.0;
final int MAXITERS = 20;
// Convert lat/long to radians
lat1 *= Math.PI / 180.0;
lat2 *= Math.PI / 180.0;
lon1 *= Math.PI / 180.0;
lon2 *= Math.PI / 180.0;
final double a = 6378137.0; // WGS84 major axis
final double b = 6356752.3142; // WGS84 semi-major axis
final double f = (a - b) / a;
final double aSqMinusBSqOverBSq = (a * a - b * b) / (b * b);
final double a = 6378137.0; // WGS84 major axis
final double b = 6356752.3142; // WGS84 semi-major axis
final double f = (a - b) / a;
final double aSqMinusBSqOverBSq = (a * a - b * b) / (b * b);
final double L = lon2 - lon1;
double A = 0.0;
final double U1 = Math.atan((1.0 - f) * Math.tan(lat1));
final double U2 = Math.atan((1.0 - f) * Math.tan(lat2));
final double L = lon2 - lon1;
double A = 0.0;
final double U1 = Math.atan((1.0 - f) * Math.tan(lat1));
final double U2 = Math.atan((1.0 - f) * Math.tan(lat2));
final double cosU1 = Math.cos(U1);
final double cosU2 = Math.cos(U2);
final double sinU1 = Math.sin(U1);
final double sinU2 = Math.sin(U2);
final double cosU1cosU2 = cosU1 * cosU2;
final double sinU1sinU2 = sinU1 * sinU2;
final double cosU1 = Math.cos(U1);
final double cosU2 = Math.cos(U2);
final double sinU1 = Math.sin(U1);
final double sinU2 = Math.sin(U2);
final double cosU1cosU2 = cosU1 * cosU2;
final double sinU1sinU2 = sinU1 * sinU2;
double sigma = 0.0;
double deltaSigma = 0.0;
double cosSqAlpha = 0.0;
double cos2SM = 0.0;
double cosSigma = 0.0;
double sinSigma = 0.0;
double cosLambda = 0.0;
double sinLambda = 0.0;
double sigma = 0.0;
double deltaSigma = 0.0;
double cosSqAlpha = 0.0;
double cos2SM = 0.0;
double cosSigma = 0.0;
double sinSigma = 0.0;
double cosLambda = 0.0;
double sinLambda = 0.0;
double lambda = L; // initial guess
for (int iter = 0; iter < MAXITERS; iter++)
{
final double lambdaOrig = lambda;
cosLambda = Math.cos(lambda);
sinLambda = Math.sin(lambda);
final double t1 = cosU2 * sinLambda;
final double t2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda;
final double sinSqSigma = t1 * t1 + t2 * t2; // (14)
sinSigma = Math.sqrt(sinSqSigma);
cosSigma = sinU1sinU2 + cosU1cosU2 * cosLambda; // (15)
sigma = Math.atan2(sinSigma, cosSigma); // (16)
final double sinAlpha = (sinSigma == 0) ? 0.0 : cosU1cosU2 * sinLambda / sinSigma; // (17)
cosSqAlpha = 1.0 - sinAlpha * sinAlpha;
cos2SM = (cosSqAlpha == 0) ? 0.0 : cosSigma - 2.0 * sinU1sinU2 / cosSqAlpha; // (18)
double lambda = L; // initial guess
for (int iter = 0; iter < MAXITERS; iter++) {
final double lambdaOrig = lambda;
cosLambda = Math.cos(lambda);
sinLambda = Math.sin(lambda);
final double t1 = cosU2 * sinLambda;
final double t2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda;
final double sinSqSigma = t1 * t1 + t2 * t2; // (14)
sinSigma = Math.sqrt(sinSqSigma);
cosSigma = sinU1sinU2 + cosU1cosU2 * cosLambda; // (15)
sigma = Math.atan2(sinSigma, cosSigma); // (16)
final double sinAlpha = (sinSigma == 0) ? 0.0 : cosU1cosU2 * sinLambda / sinSigma; // (17)
cosSqAlpha = 1.0 - sinAlpha * sinAlpha;
cos2SM = (cosSqAlpha == 0) ? 0.0 : cosSigma - 2.0 * sinU1sinU2 / cosSqAlpha; // (18)
final double uSquared = cosSqAlpha * aSqMinusBSqOverBSq; // defn
A = 1 + (uSquared / 16384.0) * // (3)
(4096.0 + uSquared * (-768 + uSquared * (320.0 - 175.0 * uSquared)));
final double B = (uSquared / 1024.0) * // (4)
(256.0 + uSquared * (-128.0 + uSquared * (74.0 - 47.0 * uSquared)));
final double C = (f / 16.0) * cosSqAlpha * (4.0 + f * (4.0 - 3.0 * cosSqAlpha)); // (10)
final double cos2SMSq = cos2SM * cos2SM;
deltaSigma = B
* sinSigma
* // (6)
(cos2SM + (B / 4.0)
* (cosSigma * (-1.0 + 2.0 * cos2SMSq) - (B / 6.0) * cos2SM * (-3.0 + 4.0 * sinSigma * sinSigma) * (-3.0 + 4.0 * cos2SMSq)));
final double uSquared = cosSqAlpha * aSqMinusBSqOverBSq; // defn
A = 1 + (uSquared / 16384.0) * // (3)
(4096.0 + uSquared * (-768 + uSquared * (320.0 - 175.0 * uSquared)));
final double B = (uSquared / 1024.0) * // (4)
(256.0 + uSquared * (-128.0 + uSquared * (74.0 - 47.0 * uSquared)));
final double C = (f / 16.0) * cosSqAlpha * (4.0 + f * (4.0 - 3.0 * cosSqAlpha)); // (10)
final double cos2SMSq = cos2SM * cos2SM;
deltaSigma = B * sinSigma * // (6)
(cos2SM + (B / 4.0) * (cosSigma * (-1.0 + 2.0 * cos2SMSq)
- (B / 6.0) * cos2SM * (-3.0 + 4.0 * sinSigma * sinSigma) * (-3.0 + 4.0 * cos2SMSq)));
lambda = L + (1.0 - C) * f * sinAlpha * (sigma + C * sinSigma * (cos2SM + C * cosSigma * (-1.0 + 2.0 * cos2SM * cos2SM))); // (11)
lambda = L + (1.0 - C) * f * sinAlpha
* (sigma + C * sinSigma * (cos2SM + C * cosSigma * (-1.0 + 2.0 * cos2SM * cos2SM))); // (11)
final double delta = (lambda - lambdaOrig) / lambda;
final double delta = (lambda - lambdaOrig) / lambda;
if (Math.abs(delta) < 1.0e-12)
break;
}
if (Math.abs(delta) < 1.0e-12)
break;
}
return (float) (b * A * (sigma - deltaSigma));
}
return (float) (b * A * (sigma - deltaSigma));
}
}

View file

@ -26,57 +26,53 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class LuProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://mobiliteitszentral.hafas.de/hafas/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.BUS, Product.BUS };
public class LuProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://mobiliteitszentral.hafas.de/hafas/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS,
Product.BUS, Product.BUS };
public LuProvider()
{
super(NetworkId.LU, API_BASE, "fn", PRODUCTS_MAP);
public LuProvider() {
super(NetworkId.LU, API_BASE, "fn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("CRE".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("CRE".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("CITYBUS".equals(ucType))
return Product.BUS;
if ("NIGHTBUS".equals(ucType))
return Product.BUS;
if ("DIFFBUS".equals(ucType))
return Product.BUS;
if ("NAVETTE".equals(ucType))
return Product.BUS;
if ("CITYBUS".equals(ucType))
return Product.BUS;
if ("NIGHTBUS".equals(ucType))
return Product.BUS;
if ("DIFFBUS".equals(ucType))
return Product.BUS;
if ("NAVETTE".equals(ucType))
return Product.BUS;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -27,36 +27,32 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class MerseyProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://jp.merseytravel.gov.uk/nwm/";
public class MerseyProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://jp.merseytravel.gov.uk/nwm/";
public MerseyProvider()
{
super(NetworkId.MERSEY, API_BASE);
public MerseyProvider() {
super(NetworkId.MERSEY, API_BASE);
setLanguage("en");
setTimeZone("Europe/London");
}
setLanguage("en");
setTimeZone("Europe/London");
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
private static final Pattern P_POSITION_BOUND = Pattern.compile("([NESW]+)-bound", Pattern.CASE_INSENSITIVE);
private static final Pattern P_POSITION_BOUND = Pattern.compile("([NESW]+)-bound", Pattern.CASE_INSENSITIVE);
@Override
protected Position parsePosition(final String position)
{
if (position == null)
return null;
@Override
protected Position parsePosition(final String position) {
if (position == null)
return null;
final Matcher m = P_POSITION_BOUND.matcher(position);
if (m.matches())
return new Position(m.group(1));
final Matcher m = P_POSITION_BOUND.matcher(position);
if (m.matches())
return new Position(m.group(1));
return super.parsePosition(position);
}
return super.parsePosition(position);
}
}

View file

@ -33,55 +33,48 @@ import de.schildbach.pte.dto.Style;
*
* @author Andreas Schildbach
*/
public class MetProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://jp.ptv.vic.gov.au/ptv/";
public class MetProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://jp.ptv.vic.gov.au/ptv/";
public MetProvider()
{
super(NetworkId.MET, API_BASE);
public MetProvider() {
super(NetworkId.MET, API_BASE);
setLanguage("en");
setTimeZone("Australia/Melbourne");
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setSessionCookieName("BIGipServerpl_ptv_jp_lbvsvr");
}
setLanguage("en");
setTimeZone("Australia/Melbourne");
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setSessionCookieName("BIGipServerpl_ptv_jp_lbvsvr");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("Regional Train :".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Regional Train".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "V/Line");
}
else if ("1".equals(mot))
{
if (trainType == null && trainNum != null)
return new Line(id, network, Product.SUBURBAN_TRAIN, trainNum);
if ("Metropolitan Train".equals(trainName) && trainNum == null)
return new Line(id, network, Product.SUBURBAN_TRAIN, Strings.nullToEmpty(name));
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("Regional Train :".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Regional Train".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "V/Line");
} else if ("1".equals(mot)) {
if (trainType == null && trainNum != null)
return new Line(id, network, Product.SUBURBAN_TRAIN, trainNum);
if ("Metropolitan Train".equals(trainName) && trainNum == null)
return new Line(id, network, Product.SUBURBAN_TRAIN, Strings.nullToEmpty(name));
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
STYLES.put("R", new Style(Style.parseColor("#a24ba3"), Style.WHITE));
STYLES.put("S", new Style(Style.parseColor("#3a75c4"), Style.WHITE));
STYLES.put("T", new Style(Style.parseColor("#5bbf21"), Style.WHITE));
STYLES.put("B", new Style(Style.parseColor("#f77f00"), Style.WHITE));
static {
STYLES.put("R", new Style(Style.parseColor("#a24ba3"), Style.WHITE));
STYLES.put("S", new Style(Style.parseColor("#3a75c4"), Style.WHITE));
STYLES.put("T", new Style(Style.parseColor("#5bbf21"), Style.WHITE));
STYLES.put("B", new Style(Style.parseColor("#f77f00"), Style.WHITE));
// TODO NightRider buses (buses with numbers > 940): #f26522
}
// TODO NightRider buses (buses with numbers > 940): #f26522
}
}

View file

@ -22,24 +22,21 @@ import de.schildbach.pte.dto.Position;
/**
* @author Andreas Schildbach
*/
public class MvgProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://mobil.mvg-online.de/mvgMobil/";
public class MvgProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://mobil.mvg-online.de/mvgMobil/";
public MvgProvider()
{
super(NetworkId.MVG, API_BASE);
}
public MvgProvider() {
super(NetworkId.MVG, API_BASE);
}
@Override
protected Position parsePosition(final String position)
{
if (position == null)
return null;
@Override
protected Position parsePosition(final String position) {
if (position == null)
return null;
if (position.startsWith(" - "))
return super.parsePosition(position.substring(3));
if (position.startsWith(" - "))
return super.parsePosition(position.substring(3));
return super.parsePosition(position);
}
return super.parsePosition(position);
}
}

View file

@ -33,119 +33,108 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class MvvProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://efa.mvv-muenchen.de/mobile/";
public class MvvProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://efa.mvv-muenchen.de/mobile/";
public MvvProvider()
{
this(API_BASE);
}
public MvvProvider() {
this(API_BASE);
}
public MvvProvider(final String apiBase)
{
super(NetworkId.MVV, apiBase);
public MvvProvider(final String apiBase) {
super(NetworkId.MVV, apiBase);
setIncludeRegionId(false);
setStyles(STYLES);
setSessionCookieName("SIDefaalt");
}
setIncludeRegionId(false);
setStyles(STYLES);
setSessionCookieName("SIDefaalt");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("Mittelrheinbahn (trans regio)".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "MiRhBa");
if ("Süd-Thüringen-Bahn".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "STB");
if ("agilis".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "agilis");
if ("SBB".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "SBB");
if ("A".equals(trainNum))
return new Line(id, network, Product.SUBURBAN_TRAIN, "A");
if ("DB AG".equals(trainName))
return new Line(id, network, null, symbol);
}
else if ("1".equals(mot))
{
if ("S".equals(symbol) && "Pendelverkehr".equals(name))
return new Line(id, network, Product.SUBURBAN_TRAIN, "S⇆");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("Mittelrheinbahn (trans regio)".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "MiRhBa");
if ("Süd-Thüringen-Bahn".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "STB");
if ("agilis".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "agilis");
if ("SBB".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "SBB");
if ("A".equals(trainNum))
return new Line(id, network, Product.SUBURBAN_TRAIN, "A");
if ("DB AG".equals(trainName))
return new Line(id, network, null, symbol);
} else if ("1".equals(mot)) {
if ("S".equals(symbol) && "Pendelverkehr".equals(name))
return new Line(id, network, Product.SUBURBAN_TRAIN, "S⇆");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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+(.*)");
@Override
protected Position parsePosition(final String position)
{
if (position == null)
return null;
@Override
protected Position parsePosition(final String position) {
if (position == null)
return null;
final Matcher m = P_POSITION.matcher(position);
if (m.matches())
{
final char t = m.group(1).charAt(0);
final Position p = super.parsePosition(m.group(2));
if (t == 'S' || t == 'U')
return new Position(p.name + "(" + t + ")", p.section);
else
return p;
}
final Matcher m = P_POSITION.matcher(position);
if (m.matches()) {
final char t = m.group(1).charAt(0);
final Position p = super.parsePosition(m.group(2));
if (t == 'S' || t == 'U')
return new Position(p.name + "(" + t + ")", p.section);
else
return p;
}
return super.parsePosition(position);
}
return super.parsePosition(position);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
STYLES.put("SS1", new Style(Style.parseColor("#00ccff"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#66cc00"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#880099"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#ff0033"), Style.WHITE));
STYLES.put("SS6", new Style(Style.parseColor("#00aa66"), Style.WHITE));
STYLES.put("SS7", new Style(Style.parseColor("#993333"), Style.WHITE));
STYLES.put("SS8", new Style(Style.BLACK, Style.parseColor("#ffcc00")));
STYLES.put("SS20", new Style(Style.BLACK, Style.parseColor("#ffaaaa")));
STYLES.put("SS27", new Style(Style.parseColor("#ffaaaa"), Style.WHITE));
STYLES.put("SA", new Style(Style.parseColor("#231f20"), Style.WHITE));
static {
STYLES.put("SS1", new Style(Style.parseColor("#00ccff"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#66cc00"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#880099"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#ff0033"), Style.WHITE));
STYLES.put("SS6", new Style(Style.parseColor("#00aa66"), Style.WHITE));
STYLES.put("SS7", new Style(Style.parseColor("#993333"), Style.WHITE));
STYLES.put("SS8", new Style(Style.BLACK, Style.parseColor("#ffcc00")));
STYLES.put("SS20", new Style(Style.BLACK, Style.parseColor("#ffaaaa")));
STYLES.put("SS27", new Style(Style.parseColor("#ffaaaa"), Style.WHITE));
STYLES.put("SA", new Style(Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("T12", new Style(Style.parseColor("#883388"), Style.WHITE));
STYLES.put("T15", new Style(Style.parseColor("#3366CC"), Style.WHITE));
STYLES.put("T16", new Style(Style.parseColor("#CC8833"), Style.WHITE));
STYLES.put("T17", new Style(Style.parseColor("#993333"), Style.WHITE));
STYLES.put("T18", new Style(Style.parseColor("#66bb33"), Style.WHITE));
STYLES.put("T19", new Style(Style.parseColor("#cc0000"), Style.WHITE));
STYLES.put("T20", new Style(Style.parseColor("#00bbee"), Style.WHITE));
STYLES.put("T21", new Style(Style.parseColor("#33aa99"), Style.WHITE));
STYLES.put("T23", new Style(Style.parseColor("#fff000"), Style.WHITE));
STYLES.put("T25", new Style(Style.parseColor("#ff9999"), Style.WHITE));
STYLES.put("T27", new Style(Style.parseColor("#ff6600"), Style.WHITE));
STYLES.put("TN17", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN19", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN20", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN27", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("T12", new Style(Style.parseColor("#883388"), Style.WHITE));
STYLES.put("T15", new Style(Style.parseColor("#3366CC"), Style.WHITE));
STYLES.put("T16", new Style(Style.parseColor("#CC8833"), Style.WHITE));
STYLES.put("T17", new Style(Style.parseColor("#993333"), Style.WHITE));
STYLES.put("T18", new Style(Style.parseColor("#66bb33"), Style.WHITE));
STYLES.put("T19", new Style(Style.parseColor("#cc0000"), Style.WHITE));
STYLES.put("T20", new Style(Style.parseColor("#00bbee"), Style.WHITE));
STYLES.put("T21", new Style(Style.parseColor("#33aa99"), Style.WHITE));
STYLES.put("T23", new Style(Style.parseColor("#fff000"), Style.WHITE));
STYLES.put("T25", new Style(Style.parseColor("#ff9999"), Style.WHITE));
STYLES.put("T27", new Style(Style.parseColor("#ff6600"), Style.WHITE));
STYLES.put("TN17", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN19", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN20", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN27", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("UU1", new Style(Style.parseColor("#227700"), Style.WHITE));
STYLES.put("UU2", new Style(Style.parseColor("#bb0000"), Style.WHITE));
STYLES.put("UU2E", new Style(Style.parseColor("#bb0000"), Style.WHITE));
STYLES.put("UU3", new Style(Style.parseColor("#ee8800"), Style.WHITE));
STYLES.put("UU4", new Style(Style.parseColor("#00ccaa"), Style.WHITE));
STYLES.put("UU5", new Style(Style.parseColor("#bb7700"), Style.WHITE));
STYLES.put("UU6", new Style(Style.parseColor("#0000cc"), Style.WHITE));
STYLES.put("UU7", new Style(Style.parseColor("#227700"), Style.parseColor("#bb0000"), Style.WHITE, 0));
}
STYLES.put("UU1", new Style(Style.parseColor("#227700"), Style.WHITE));
STYLES.put("UU2", new Style(Style.parseColor("#bb0000"), Style.WHITE));
STYLES.put("UU2E", new Style(Style.parseColor("#bb0000"), Style.WHITE));
STYLES.put("UU3", new Style(Style.parseColor("#ee8800"), Style.WHITE));
STYLES.put("UU4", new Style(Style.parseColor("#00ccaa"), Style.WHITE));
STYLES.put("UU5", new Style(Style.parseColor("#bb7700"), Style.WHITE));
STYLES.put("UU6", new Style(Style.parseColor("#0000cc"), Style.WHITE));
STYLES.put("UU7", new Style(Style.parseColor("#227700"), Style.parseColor("#bb0000"), Style.WHITE, 0));
}
@Override
public Point[] getArea()
{
return new Point[] { Point.fromDouble(48.140377, 11.560643) };
}
@Override
public Point[] getArea() {
return new Point[] { Point.fromDouble(48.140377, 11.560643) };
}
}

View file

@ -32,115 +32,103 @@ import de.schildbach.pte.util.StringReplaceReader;
/**
* @author Andreas Schildbach
*/
public class NasaProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://reiseauskunft.insa.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.TRAM, Product.BUS, Product.ON_DEMAND };
public class NasaProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://reiseauskunft.insa.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.TRAM, Product.BUS,
Product.ON_DEMAND };
public NasaProvider()
{
super(NetworkId.NASA, API_BASE, "dn", PRODUCTS_MAP);
public NasaProvider() {
super(NetworkId.NASA, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStationBoardHasLocation(true);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStationBoardHasLocation(true);
}
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
{
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
} else if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
protected void addCustomReplaces(final StringReplaceReader reader)
{
reader.replace("\"Florian Geyer\"", "Florian Geyer");
}
@Override
protected void addCustomReplaces(final StringReplaceReader reader) {
reader.replace("\"Florian Geyer\"", "Florian Geyer");
}
@Override
protected Product normalizeType(String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(String type) {
final String ucType = type.toUpperCase();
if ("ECW".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("IXB".equals(ucType)) // ICE International
return Product.HIGH_SPEED_TRAIN;
if ("RRT".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("ECW".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("IXB".equals(ucType)) // ICE International
return Product.HIGH_SPEED_TRAIN;
if ("RRT".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("DPF".equals(ucType)) // mit Dampflok bespannter Zug
return Product.REGIONAL_TRAIN;
if ("DAM".equals(ucType)) // Harzer Schmalspurbahnen: mit Dampflok bespannter Zug
return Product.REGIONAL_TRAIN;
if ("TW".equals(ucType)) // Harzer Schmalspurbahnen: Triebwagen
return Product.REGIONAL_TRAIN;
if ("RR".equals(ucType)) // Polen
return Product.REGIONAL_TRAIN;
if ("BAHN".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("ZUGBAHN".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("DAMPFZUG".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("DPF".equals(ucType)) // mit Dampflok bespannter Zug
return Product.REGIONAL_TRAIN;
if ("DAM".equals(ucType)) // Harzer Schmalspurbahnen: mit Dampflok bespannter Zug
return Product.REGIONAL_TRAIN;
if ("TW".equals(ucType)) // Harzer Schmalspurbahnen: Triebwagen
return Product.REGIONAL_TRAIN;
if ("RR".equals(ucType)) // Polen
return Product.REGIONAL_TRAIN;
if ("BAHN".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("ZUGBAHN".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("DAMPFZUG".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("DPS".equals(ucType))
return Product.SUBURBAN_TRAIN;
if ("DPS".equals(ucType))
return Product.SUBURBAN_TRAIN;
if ("RUFBUS".equals(ucType)) // Rufbus
return Product.BUS;
if ("RBS".equals(ucType)) // Rufbus
return Product.BUS;
if ("RUFBUS".equals(ucType)) // Rufbus
return Product.BUS;
if ("RBS".equals(ucType)) // Rufbus
return Product.BUS;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -20,68 +20,67 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public enum NetworkId
{
// Europe
RT,
public enum NetworkId {
// Europe
RT,
// Germany
DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV, VGN, VVM, VMV, HVV, SH, GVH, BSVAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VVS, DING, KVV, VAGFR, NVBW, VVV,
// Germany
DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV, VGN, VVM, VMV, HVV, SH, GVH, BSVAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VVS, DING, KVV, VAGFR, NVBW, VVV,
// Austria
OEBB, VAO, VOR, WIEN, LINZ, VVT, IVB, STV,
// Austria
OEBB, VAO, VOR, WIEN, LINZ, VVT, IVB, STV,
// Switzerland
SBB, BVB, VBL, ZVV,
// Switzerland
SBB, BVB, VBL, ZVV,
// France
PACA, PARIS, FRENCHSOUTHWEST, FRANCESOUTHEAST, FRANCENORTHEAST,
// France
PACA, PARIS, FRENCHSOUTHWEST, FRANCESOUTHEAST, FRANCENORTHEAST,
// Belgium
SNCB,
// Belgium
SNCB,
// Netherlands
NS,
// Netherlands
NS,
// Denmark
DSB,
// Denmark
DSB,
// Sweden
SE,
// Sweden
SE,
// Norway
NRI,
// Norway
NRI,
// Finland
HSL,
// Finland
HSL,
// Luxembourg
LU,
// Luxembourg
LU,
// United Kingdom
TLEM, MERSEY,
// United Kingdom
TLEM, MERSEY,
// Ireland
TFI, EIREANN,
// Ireland
TFI, EIREANN,
// Poland
PL,
// Poland
PL,
// Italy
ATC, IT,
// Italy
ATC, IT,
// United Arab Emirates
DUB,
// United Arab Emirates
DUB,
// Israel
JET,
// Israel
JET,
// United States
SF, SEPTA, RTACHICAGO,
// United States
SF, SEPTA, RTACHICAGO,
// Canada
ONTARIO, QUEBEC,
// Canada
ONTARIO, QUEBEC,
// Australia
SYDNEY, MET
// Australia
SYDNEY, MET
}

View file

@ -40,154 +40,152 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
*
* @author Andreas Schildbach
*/
public interface NetworkProvider
{
public enum Capability
{
/* can suggest locations */
SUGGEST_LOCATIONS,
/* can determine nearby locations */
NEARBY_LOCATIONS,
/* can query for departures */
DEPARTURES,
/* can query trips */
TRIPS
}
public interface NetworkProvider {
public enum Capability {
/* can suggest locations */
SUGGEST_LOCATIONS,
/* can determine nearby locations */
NEARBY_LOCATIONS,
/* can query for departures */
DEPARTURES,
/* can query trips */
TRIPS
}
public enum Optimize
{
LEAST_DURATION, LEAST_CHANGES, LEAST_WALKING
}
public enum Optimize {
LEAST_DURATION, LEAST_CHANGES, LEAST_WALKING
}
public enum WalkSpeed
{
SLOW, NORMAL, FAST
}
public enum WalkSpeed {
SLOW, NORMAL, FAST
}
public enum Accessibility
{
NEUTRAL, LIMITED, BARRIER_FREE
}
public enum Accessibility {
NEUTRAL, LIMITED, BARRIER_FREE
}
public enum Option
{
BIKE
}
public enum Option {
BIKE
}
NetworkId id();
NetworkId id();
boolean hasCapabilities(final Capability... capabilities);
boolean hasCapabilities(final Capability... capabilities);
/**
* Find locations near to given location. At least one of lat/lon pair or station id must be present in that
* location.
*
* @param types
* types of locations to find
* @param location
* location to determine nearby stations
* @param maxDistance
* maximum distance in meters, or {@code 0}
* @param maxLocations
* maximum number of locations, or {@code 0}
* @return nearby stations
* @throws IOException
*/
NearbyLocationsResult queryNearbyLocations(EnumSet<LocationType> types, Location location, int maxDistance, int maxLocations) throws IOException;
/**
* Find locations near to given location. At least one of lat/lon pair or station id must be present in
* that location.
*
* @param types
* types of locations to find
* @param location
* location to determine nearby stations
* @param maxDistance
* maximum distance in meters, or {@code 0}
* @param maxLocations
* maximum number of locations, or {@code 0}
* @return nearby stations
* @throws IOException
*/
NearbyLocationsResult queryNearbyLocations(EnumSet<LocationType> types, Location location, int maxDistance,
int maxLocations) throws IOException;
/**
* Get departures at a given station, probably live
*
* @param stationId
* id of the station
* @param time
* desired time for departing, or {@code null} for the provider default
* @param maxDepartures
* maximum number of departures to get or {@code 0}
* @param equivs
* also query equivalent stations?
* @return result object containing the departures
* @throws IOException
*/
QueryDeparturesResult queryDepartures(String stationId, @Nullable Date time, int maxDepartures, boolean equivs) throws IOException;
/**
* Get departures at a given station, probably live
*
* @param stationId
* id of the station
* @param time
* desired time for departing, or {@code null} for the provider default
* @param maxDepartures
* maximum number of departures to get or {@code 0}
* @param equivs
* also query equivalent stations?
* @return result object containing the departures
* @throws IOException
*/
QueryDeparturesResult queryDepartures(String stationId, @Nullable Date time, int maxDepartures, boolean equivs)
throws IOException;
/**
* Meant for auto-completion of location names, like in an {@link android.widget.AutoCompleteTextView}
*
* @param constraint
* input by user so far
* @return location suggestions
* @throws IOException
*/
SuggestLocationsResult suggestLocations(CharSequence constraint) throws IOException;
/**
* Meant for auto-completion of location names, like in an {@link android.widget.AutoCompleteTextView}
*
* @param constraint
* input by user so far
* @return location suggestions
* @throws IOException
*/
SuggestLocationsResult suggestLocations(CharSequence constraint) throws IOException;
/**
* Typical products for a network
*
* @return products
*/
Set<Product> defaultProducts();
/**
* Typical products for a network
*
* @return products
*/
Set<Product> defaultProducts();
/**
* Query trips, asking for any ambiguousnesses
*
* @param from
* location to route from, mandatory
* @param via
* location to route via, may be {@code null}
* @param to
* location to route to, mandatory
* @param date
* desired date for departing, mandatory
* @param dep
* date is departure date? {@code true} for departure, {@code false} for arrival
* @param products
* products to take into account, or {@code null} for the provider default
* @param optimize
* optimize trip for one aspect, e.g. duration
* @param walkSpeed
* walking ability, or {@code null} for the provider default
* @param accessibility
* route accessibility, or {@code null} for the provider default
* @param options
* additional options, or {@code null} for the provider default
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible trips
* @throws IOException
*/
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep, @Nullable Set<Product> products,
@Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed, @Nullable Accessibility accessibility, @Nullable Set<Option> options)
throws IOException;
/**
* Query trips, asking for any ambiguousnesses
*
* @param from
* location to route from, mandatory
* @param via
* location to route via, may be {@code null}
* @param to
* location to route to, mandatory
* @param date
* desired date for departing, mandatory
* @param dep
* date is departure date? {@code true} for departure, {@code false} for arrival
* @param products
* products to take into account, or {@code null} for the provider default
* @param optimize
* optimize trip for one aspect, e.g. duration
* @param walkSpeed
* walking ability, or {@code null} for the provider default
* @param accessibility
* route accessibility, or {@code null} for the provider default
* @param options
* additional options, or {@code null} for the provider default
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible
* trips
* @throws IOException
*/
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException;
/**
* Query more trips (e.g. earlier or later)
*
* @param context
* context to query more trips from
* @param next
* {@code true} for get next trips, {@code false} for get previous trips
* @return result object that contains possible trips
* @throws IOException
*/
QueryTripsResult queryMoreTrips(QueryTripsContext context, boolean later) throws IOException;
/**
* Query more trips (e.g. earlier or later)
*
* @param context
* context to query more trips from
* @param next
* {@code true} for get next trips, {@code false} for get previous trips
* @return result object that contains possible trips
* @throws IOException
*/
QueryTripsResult queryMoreTrips(QueryTripsContext context, boolean later) throws IOException;
/**
* Get style of line
*
* @param network
* network to disambiguate line, may be {@code null}
* @param product
* line product to get style of, may be {@code null}
* @param label
* line label to get style of, may be {@code null}
* @return object containing background, foreground and optional border colors
*/
Style lineStyle(@Nullable String network, @Nullable Product product, @Nullable String label);
/**
* Get style of line
*
* @param network
* network to disambiguate line, may be {@code null}
* @param product
* line product to get style of, may be {@code null}
* @param label
* line label to get style of, may be {@code null}
* @return object containing background, foreground and optional border colors
*/
Style lineStyle(@Nullable String network, @Nullable Product product, @Nullable String label);
/**
* Gets the primary covered area of the network
*
* @return array containing points of a polygon (special case: just one coordinate defines just a center point)
* @throws IOException
*/
Point[] getArea() throws IOException;
/**
* Gets the primary covered area of the network
*
* @return array containing points of a polygon (special case: just one coordinate defines just a center
* point)
* @throws IOException
*/
Point[] getArea() throws IOException;
}

View file

@ -33,91 +33,85 @@ import de.schildbach.pte.dto.QueryTripsResult;
/**
* @author Andreas Schildbach
*/
public class NriProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://hafas.websrv05.reiseinfo.no/bin/dev/nri/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.TRAM, Product.SUBWAY,
Product.FERRY, Product.FERRY, Product.FERRY };
public class NriProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://hafas.websrv05.reiseinfo.no/bin/dev/nri/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.BUS,
Product.TRAM, Product.SUBWAY, Product.FERRY, Product.FERRY, Product.FERRY };
public NriProvider()
{
super(NetworkId.NRI, API_BASE, "on", PRODUCTS_MAP);
public NriProvider() {
super(NetworkId.NRI, API_BASE, "on", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
}
private static final String[] PLACES = { "Oslo", "Bergen" };
private static final String[] PLACES = { "Oslo", "Bergen" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
if (name.startsWith(place + " "))
return new String[] { place, name.substring(place.length() + 1) };
@Override
protected String[] splitStationName(final String name) {
for (final String place : PLACES)
if (name.startsWith(place + " "))
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
return queryMoreTripsXml(context, later);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
return queryMoreTripsXml(context, later);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("AIR".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("AIR".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("TRA".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("TRAIN".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("HEL".equals(ucType)) // Heli
return Product.REGIONAL_TRAIN;
if ("TRA".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("TRAIN".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("HEL".equals(ucType)) // Heli
return Product.REGIONAL_TRAIN;
if ("U".equals(ucType))
return Product.SUBWAY;
if ("U".equals(ucType))
return Product.SUBWAY;
if ("TRAM".equals(ucType))
return Product.TRAM;
if ("MTR".equals(ucType))
return Product.TRAM;
if ("TRAM".equals(ucType))
return Product.TRAM;
if ("MTR".equals(ucType))
return Product.TRAM;
if (ucType.startsWith("BUS"))
return Product.BUS;
if (ucType.startsWith("BUS"))
return Product.BUS;
if ("EXP".equals(ucType))
return Product.FERRY;
if ("EXP.BOAT".equals(ucType))
return Product.FERRY;
if ("FERRY".equals(ucType))
return Product.FERRY;
if ("FER".equals(ucType))
return Product.FERRY;
if ("SHIP".equals(ucType))
return Product.FERRY;
if ("SHI".equals(ucType))
return Product.FERRY;
if ("EXP".equals(ucType))
return Product.FERRY;
if ("EXP.BOAT".equals(ucType))
return Product.FERRY;
if ("FERRY".equals(ucType))
return Product.FERRY;
if ("FER".equals(ucType))
return Product.FERRY;
if ("SHIP".equals(ucType))
return Product.FERRY;
if ("SHI".equals(ucType))
return Product.FERRY;
// skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
// skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
}

View file

@ -30,57 +30,51 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class NsProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://hafas.bene-system.com/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
private static final Pattern HTML_NEARBY_STATIONS_PATTERN = Pattern.compile("<tr bgcolor=\"#(E7EEF9|99BAE4)\">(.*?)</tr>", Pattern.DOTALL);
public class NsProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://hafas.bene-system.com/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
private static final Pattern HTML_NEARBY_STATIONS_PATTERN = Pattern
.compile("<tr bgcolor=\"#(E7EEF9|99BAE4)\">(.*?)</tr>", Pattern.DOTALL);
public NsProvider()
{
super(NetworkId.NS, API_BASE, "nn", PRODUCTS_MAP);
public NsProvider() {
super(NetworkId.NS, API_BASE, "nn", PRODUCTS_MAP);
setHtmlNearbyStationsPattern(HTML_NEARBY_STATIONS_PATTERN);
setStationBoardHasLocation(true);
}
setHtmlNearbyStationsPattern(HTML_NEARBY_STATIONS_PATTERN);
setStationBoardHasLocation(true);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
uri.append("&L=profi");
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
uri.append("&L=profi");
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if (ucType.equals("SPR"))
return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Avignon
return Product.REGIONAL_TRAIN;
if (ucType.equals("SPR"))
return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Avignon
return Product.REGIONAL_TRAIN;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -34,82 +34,74 @@ import de.schildbach.pte.dto.QueryTripsResult;
/**
* @author Andreas Schildbach
*/
public class NvbwProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://www.efa-bw.de/nvbw/"; // no intermeditate stops
private final static String API_BASE_MOBILE = "http://www.efa-bw.de/android/";
public class NvbwProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://www.efa-bw.de/nvbw/"; // no intermeditate stops
private final static String API_BASE_MOBILE = "http://www.efa-bw.de/android/";
// http://efa2.naldo.de/naldo/
// http://efa2.naldo.de/naldo/
public NvbwProvider()
{
super(NetworkId.NVBW, API_BASE + DEFAULT_DEPARTURE_MONITOR_ENDPOINT, API_BASE_MOBILE + DEFAULT_TRIP_ENDPOINT, API_BASE
+ DEFAULT_STOPFINDER_ENDPOINT, API_BASE + DEFAULT_COORD_ENDPOINT);
public NvbwProvider() {
super(NetworkId.NVBW, API_BASE + DEFAULT_DEPARTURE_MONITOR_ENDPOINT, API_BASE_MOBILE + DEFAULT_TRIP_ENDPOINT,
API_BASE + DEFAULT_STOPFINDER_ENDPOINT, API_BASE + DEFAULT_COORD_ENDPOINT);
setIncludeRegionId(false);
setUseRouteIndexAsTripId(false);
setNumTripsRequested(12);
setSessionCookieName("EFABWLB");
}
setIncludeRegionId(false);
setUseRouteIndexAsTripId(false);
setNumTripsRequested(12);
setSessionCookieName("EFABWLB");
}
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
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if (("ICE".equals(trainName) || "InterCityExpress".equals(trainName)) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE");
if ("InterCity".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC");
if ("Fernreisezug externer EU".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, null);
if ("SuperCity".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "SC");
if ("InterRegio".equals(longName) && symbol == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
if ("REGIOBAHN".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("Meridian".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("CityBahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "CB");
if ("Trilex".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("Bay. Seenschifffahrt".equals(trainName) && symbol != null)
return new Line(id, network, Product.FERRY, symbol);
if ("Nahverkehrszug von Dritten".equals(trainName) && trainNum == null)
return new Line(id, network, null, "Zug");
if ("DB".equals(trainName) && trainNum == null)
return new Line(id, network, null, "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 new Line(id, network, Product.SUBURBAN_TRAIN, m.group(1));
}
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if (("ICE".equals(trainName) || "InterCityExpress".equals(trainName)) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE");
if ("InterCity".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC");
if ("Fernreisezug externer EU".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, null);
if ("SuperCity".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "SC");
if ("InterRegio".equals(longName) && symbol == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
if ("REGIOBAHN".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("Meridian".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("CityBahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "CB");
if ("Trilex".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("Bay. Seenschifffahrt".equals(trainName) && symbol != null)
return new Line(id, network, Product.FERRY, symbol);
if ("Nahverkehrszug von Dritten".equals(trainName) && trainNum == null)
return new Line(id, network, null, "Zug");
if ("DB".equals(trainName) && trainNum == null)
return new Line(id, network, null, "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 new Line(id, network, Product.SUBURBAN_TRAIN, m.group(1));
}
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException
{
return queryMoreTripsMobile(contextObj, later);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException {
return queryMoreTripsMobile(contextObj, later);
}
}

View file

@ -32,106 +32,93 @@ import de.schildbach.pte.util.StringReplaceReader;
/**
* @author Andreas Schildbach
*/
public class NvvProvider extends AbstractHafasProvider
{
private static final String API_BASE = "https://auskunft.nvv.de/auskunft/bin/jp/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.BUS, Product.FERRY, Product.ON_DEMAND, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN };
public class NvvProvider extends AbstractHafasProvider {
private static final String API_BASE = "https://auskunft.nvv.de/auskunft/bin/jp/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.BUS,
Product.FERRY, Product.ON_DEMAND, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN };
public NvvProvider()
{
super(NetworkId.NVV, API_BASE, "dn", PRODUCTS_MAP);
public NvvProvider() {
super(NetworkId.NVV, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
httpClient.setSslAcceptAllHostnames(true);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
httpClient.setSslAcceptAllHostnames(true);
}
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen",
"Darmstadt", "Aschaffenburg", "Berlin", "Fulda" };
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg",
"Kassel", "Hanau", "Göttingen", "Darmstadt", "Aschaffenburg", "Berlin", "Fulda" };
@Override
protected String[] splitStationName(final String name)
{
if (name.startsWith("F "))
return new String[] { "Frankfurt", name.substring(2) };
if (name.startsWith("OF "))
return new String[] { "Offenbach", name.substring(3) };
if (name.startsWith("MZ "))
return new String[] { "Mainz", name.substring(3) };
@Override
protected String[] splitStationName(final String name) {
if (name.startsWith("F "))
return new String[] { "Frankfurt", name.substring(2) };
if (name.startsWith("OF "))
return new String[] { "Offenbach", name.substring(3) };
if (name.startsWith("MZ "))
return new String[] { "Mainz", name.substring(3) };
for (final String place : PLACES)
{
if (name.startsWith(place + " - "))
return new String[] { place, name.substring(place.length() + 3) };
else if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
for (final String place : PLACES) {
if (name.startsWith(place + " - "))
return new String[] { place, name.substring(place.length() + 3) };
else if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
{
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?L=vs_rmv&near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
} else if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?L=vs_rmv&near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
protected void addCustomReplaces(final StringReplaceReader reader)
{
reader.replace("<ul>", " ");
reader.replace("</ul>", " ");
reader.replace("<li>", " ");
reader.replace("</li>", " ");
reader.replace("Park&Ride", "Park&amp;Ride");
reader.replace("C&A", "C&amp;A");
}
@Override
protected void addCustomReplaces(final StringReplaceReader reader) {
reader.replace("<ul>", " ");
reader.replace("</ul>", " ");
reader.replace("<li>", " ");
reader.replace("</li>", " ");
reader.replace("Park&Ride", "Park&amp;Ride");
reader.replace("C&A", "C&amp;A");
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("U-BAHN".equals(ucType))
return Product.SUBWAY;
if ("U-BAHN".equals(ucType))
return Product.SUBWAY;
if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich
return Product.BUS;
if ("LTAXI".equals(ucType))
return Product.BUS;
if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich
return Product.BUS;
if ("LTAXI".equals(ucType))
return Product.BUS;
if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt
return Product.ON_DEMAND;
if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt
return Product.ON_DEMAND;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -30,146 +30,134 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class OebbProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://fahrplan.oebb.at/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM,
Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND, Product.HIGH_SPEED_TRAIN };
public class OebbProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://fahrplan.oebb.at/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN,
Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND,
Product.HIGH_SPEED_TRAIN };
public OebbProvider()
{
super(NetworkId.OEBB, API_BASE, "dn", PRODUCTS_MAP);
public OebbProvider() {
super(NetworkId.OEBB, API_BASE, "dn", PRODUCTS_MAP);
setDominantPlanStopTime(true);
}
setDominantPlanStopTime(true);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
{
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Suchen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
} else if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Suchen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
private static final String[] PLACES = { "Wien", "Graz", "Linz/Donau", "Salzburg", "Innsbruck" };
private static final String[] PLACES = { "Wien", "Graz", "Linz/Donau", "Salzburg", "Innsbruck" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
if (name.startsWith(place + " "))
return new String[] { place, name.substring(place.length() + 1) };
@Override
protected String[] splitStationName(final String name) {
for (final String place : PLACES)
if (name.startsWith(place + " "))
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if (ucType.equals("RR")) // Finnland, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("EE")) // Rumänien, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("OZ")) // Schweden, Oeresundzug, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("UUU")) // Italien, Nacht, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("RR")) // Finnland, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("EE")) // Rumänien, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("OZ")) // Schweden, Oeresundzug, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("UUU")) // Italien, Nacht, Connections only?
return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("S2")) // Helsinki-Turku, Connections only?
return Product.REGIONAL_TRAIN;
if (ucType.equals("RE")) // RegionalExpress Deutschland
return Product.REGIONAL_TRAIN;
if (ucType.equals("DPN")) // Connections only? TODO nicht evtl. doch eher ne S-Bahn?
return Product.REGIONAL_TRAIN;
if (ucType.equals("IP")) // Ozd, Ungarn
return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Frankreich, Tours
return Product.REGIONAL_TRAIN;
if (ucType.equals("DPF")) // VX=Vogtland Express, Connections only?
return Product.REGIONAL_TRAIN;
if ("UAU".equals(ucType)) // Rußland
return Product.REGIONAL_TRAIN;
if (ucType.equals("S2")) // Helsinki-Turku, Connections only?
return Product.REGIONAL_TRAIN;
if (ucType.equals("RE")) // RegionalExpress Deutschland
return Product.REGIONAL_TRAIN;
if (ucType.equals("DPN")) // Connections only? TODO nicht evtl. doch eher ne S-Bahn?
return Product.REGIONAL_TRAIN;
if (ucType.equals("IP")) // Ozd, Ungarn
return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Frankreich, Tours
return Product.REGIONAL_TRAIN;
if (ucType.equals("DPF")) // VX=Vogtland Express, Connections only?
return Product.REGIONAL_TRAIN;
if ("UAU".equals(ucType)) // Rußland
return Product.REGIONAL_TRAIN;
if (ucType.equals("RSB")) // Schnellbahn Wien
return Product.SUBURBAN_TRAIN;
if (ucType.equals("RSB")) // Schnellbahn Wien
return Product.SUBURBAN_TRAIN;
if (ucType.equals("LKB")) // Connections only?
return Product.TRAM;
if (ucType.equals("LKB")) // Connections only?
return Product.TRAM;
if (ucType.equals("OBU")) // Connections only?
return Product.BUS;
if (ucType.equals("O-BUS")) // Stadtbus
return Product.BUS;
if (ucType.equals("O")) // Stadtbus
return Product.BUS;
if (ucType.equals("OBU")) // Connections only?
return Product.BUS;
if (ucType.equals("O-BUS")) // Stadtbus
return Product.BUS;
if (ucType.equals("O")) // Stadtbus
return Product.BUS;
if (ucType.equals("SCH")) // Connections only?
return Product.FERRY;
if (ucType.equals("F")) // Fähre
return Product.FERRY;
if (ucType.equals("SCH")) // Connections only?
return Product.FERRY;
if (ucType.equals("F")) // Fähre
return Product.FERRY;
if (ucType.equals("LIF"))
return Product.CABLECAR;
if (ucType.equals("LIFT")) // Graz Uhrturm
return Product.CABLECAR;
if (ucType.equals("SSB")) // Graz Schlossbergbahn
return Product.CABLECAR;
if (ucType.equals("LIF"))
return Product.CABLECAR;
if (ucType.equals("LIFT")) // Graz Uhrturm
return Product.CABLECAR;
if (ucType.equals("SSB")) // Graz Schlossbergbahn
return Product.CABLECAR;
if (ucType.equals("U70")) // U.K., Connections only?
return null;
if (ucType.equals("X70")) // U.K., Connections only?
return null;
if (ucType.equals("R84")) // U.K., Connections only?
return null;
if (ucType.equals("S84")) // U.K., Connections only?
return null;
if (ucType.equals("T84")) // U.K., Connections only?
return null;
if (ucType.equals("U70")) // U.K., Connections only?
return null;
if (ucType.equals("X70")) // U.K., Connections only?
return null;
if (ucType.equals("R84")) // U.K., Connections only?
return null;
if (ucType.equals("S84")) // U.K., Connections only?
return null;
if (ucType.equals("T84")) // U.K., Connections only?
return null;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -20,27 +20,23 @@ package de.schildbach.pte;
/**
* @author Stephane Berube
*/
public class OntarioProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "ca-on";
public class OntarioProvider extends AbstractNavitiaProvider {
private static String API_REGION = "ca-on";
public OntarioProvider(final String apiBase, final String authorization)
{
super(NetworkId.ONTARIO, apiBase, authorization);
public OntarioProvider(final String apiBase, final String authorization) {
super(NetworkId.ONTARIO, apiBase, authorization);
setTimeZone("America/Toronto");
}
setTimeZone("America/Toronto");
}
public OntarioProvider(final String authorization)
{
super(NetworkId.ONTARIO, authorization);
public OntarioProvider(final String authorization) {
super(NetworkId.ONTARIO, authorization);
setTimeZone("America/Toronto");
}
setTimeZone("America/Toronto");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
}

View file

@ -22,37 +22,33 @@ import de.schildbach.pte.dto.Product;
/**
* @author Kjell Braden <afflux@pentabarf.de>
*/
public class PacaProvider extends AbstractTsiProvider
{
public PacaProvider()
{
super(NetworkId.PACA, "PACA", "http://www.pacamobilite.fr/WebServices/TransinfoService/api");
}
public class PacaProvider extends AbstractTsiProvider {
public PacaProvider() {
super(NetworkId.PACA, "PACA", "http://www.pacamobilite.fr/WebServices/TransinfoService/api");
}
@Override
protected String translateToLocalProduct(final Product p)
{
switch (p)
{
case HIGH_SPEED_TRAIN:
return "RAPID_TRANSIT";
case REGIONAL_TRAIN:
return "TRAIN|LONG_DISTANCE_TRAIN";
case SUBURBAN_TRAIN:
return "LOCAL_TRAIN";
case SUBWAY:
return "METRO";
case TRAM:
return "TRAMWAY";
case BUS:
return "BUS|COACH";
case ON_DEMAND:
return "TOD";
case FERRY:
return "FERRY";
case CABLECAR:
default:
return null;
}
}
@Override
protected String translateToLocalProduct(final Product p) {
switch (p) {
case HIGH_SPEED_TRAIN:
return "RAPID_TRANSIT";
case REGIONAL_TRAIN:
return "TRAIN|LONG_DISTANCE_TRAIN";
case SUBURBAN_TRAIN:
return "LOCAL_TRAIN";
case SUBWAY:
return "METRO";
case TRAM:
return "TRAMWAY";
case BUS:
return "BUS|COACH";
case ON_DEMAND:
return "TOD";
case FERRY:
return "FERRY";
case CABLECAR:
default:
return null;
}
}
}

View file

@ -25,81 +25,66 @@ import de.schildbach.pte.util.WordUtils;
/**
* @author Antonio El Khoury
*/
public class ParisProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "fr-idf";
public class ParisProvider extends AbstractNavitiaProvider {
private static String API_REGION = "fr-idf";
public ParisProvider(final String apiBase, final String authorization)
{
super(NetworkId.PARIS, apiBase, authorization);
public ParisProvider(final String apiBase, final String authorization) {
super(NetworkId.PARIS, apiBase, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
public ParisProvider(final String authorization)
{
super(NetworkId.PARIS, authorization);
public ParisProvider(final String authorization) {
super(NetworkId.PARIS, authorization);
setTimeZone("Europe/Paris");
}
setTimeZone("Europe/Paris");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color)
{
switch (product)
{
case SUBURBAN_TRAIN:
{
// RER
if (code.compareTo("F") < 0)
{
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
// Transilien
else
{
return new Style(Shape.ROUNDED, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
}
case REGIONAL_TRAIN:
{
// TER + Intercités
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY:
{
// Metro
return new Style(Shape.CIRCLE, Style.parseColor(color), computeForegroundColor(color));
}
case TRAM:
{
// Tram
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
}
case BUS:
{
// Bus + Noctilien
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
}
case CABLECAR:
{
// Orlyval
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
default:
return super.getLineStyle(product, code, color);
}
}
@Override
protected Style getLineStyle(final Product product, final String code, final String color) {
switch (product) {
case SUBURBAN_TRAIN: {
// RER
if (code.compareTo("F") < 0) {
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
// Transilien
else {
return new Style(Shape.ROUNDED, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
}
}
case REGIONAL_TRAIN: {
// TER + Intercités
return new Style(Style.parseColor(color), computeForegroundColor(color));
}
case SUBWAY: {
// Metro
return new Style(Shape.CIRCLE, Style.parseColor(color), computeForegroundColor(color));
}
case TRAM: {
// Tram
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
}
case BUS: {
// Bus + Noctilien
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
}
case CABLECAR: {
// Orlyval
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
}
default:
return super.getLineStyle(product, code, color);
}
}
@Override
protected String getLocationName(String name)
{
return WordUtils.capitalizeFully(name);
}
@Override
protected String getLocationName(String name) {
return WordUtils.capitalizeFully(name);
}
}

View file

@ -27,80 +27,73 @@ import de.schildbach.pte.util.StringReplaceReader;
/**
* @author Andreas Schildbach
*/
public class PlProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://rozklad.bilkom.pl/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.SUBURBAN_TRAIN, Product.BUS, Product.BUS, Product.FERRY };
public class PlProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://rozklad.bilkom.pl/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.BUS, Product.FERRY };
public PlProvider()
{
super(NetworkId.PL, API_BASE, "pn", PRODUCTS_MAP);
public PlProvider() {
super(NetworkId.PL, API_BASE, "pn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
private static final String[] PLACES = { "Warszawa", "Kraków" };
private static final String[] PLACES = { "Warszawa", "Kraków" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
{
if (name.endsWith(", " + place))
return new String[] { place, name.substring(0, name.length() - place.length() - 2) };
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
@Override
protected String[] splitStationName(final String name) {
for (final String place : PLACES) {
if (name.endsWith(", " + place))
return new String[] { place, name.substring(0, name.length() - place.length() - 2) };
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected void addCustomReplaces(final StringReplaceReader reader)
{
reader.replace("dir=\"Sp ", " "); // Poland
reader.replace("dir=\"B ", " "); // Poland
reader.replace("dir=\"K ", " "); // Poland
reader.replace("dir=\"Eutingen i. G ", "dir=\"Eutingen\" "); // Poland
reader.replace("StargetLoc", "Süd\" targetLoc"); // Poland
reader.replace("platform=\"K ", " "); // Poland
}
@Override
protected void addCustomReplaces(final StringReplaceReader reader) {
reader.replace("dir=\"Sp ", " "); // Poland
reader.replace("dir=\"B ", " "); // Poland
reader.replace("dir=\"K ", " "); // Poland
reader.replace("dir=\"Eutingen i. G ", "dir=\"Eutingen\" "); // Poland
reader.replace("StargetLoc", "Süd\" targetLoc"); // Poland
reader.replace("platform=\"K ", " "); // Poland
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("AR".equals(ucType)) // Arriva Polaczen
return Product.REGIONAL_TRAIN;
if ("N".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("KW".equals(ucType)) // Koleje Wielkopolskie
return Product.REGIONAL_TRAIN;
if ("KS".equals(ucType)) // Koleje Śląskie
return Product.REGIONAL_TRAIN;
if ("REG".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("AR".equals(ucType)) // Arriva Polaczen
return Product.REGIONAL_TRAIN;
if ("N".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("KW".equals(ucType)) // Koleje Wielkopolskie
return Product.REGIONAL_TRAIN;
if ("KS".equals(ucType)) // Koleje Śląskie
return Product.REGIONAL_TRAIN;
if ("REG".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("LKA".equals(ucType)) // Łódzka Kolej Aglomeracyjna
return Product.SUBURBAN_TRAIN;
if ("LKA".equals(ucType)) // Łódzka Kolej Aglomeracyjna
return Product.SUBURBAN_TRAIN;
if ("IRB".equals(ucType)) // interREGIO Bus
return Product.BUS;
if ("ZKA".equals(ucType)) // Zastępcza Komunikacja Autobusowa (Schienenersatzverkehr)
return Product.BUS;
if ("IRB".equals(ucType)) // interREGIO Bus
return Product.BUS;
if ("ZKA".equals(ucType)) // Zastępcza Komunikacja Autobusowa (Schienenersatzverkehr)
return Product.BUS;
if ("FRE".equals(ucType))
return Product.FERRY;
if ("FRE".equals(ucType))
return Product.FERRY;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -20,27 +20,23 @@ package de.schildbach.pte;
/**
* @author Stephane Berube
*/
public class QuebecProvider extends AbstractNavitiaProvider
{
private static String API_REGION = "ca-qc";
public class QuebecProvider extends AbstractNavitiaProvider {
private static String API_REGION = "ca-qc";
public QuebecProvider(final String apiBase, final String authorization)
{
super(NetworkId.QUEBEC, apiBase, authorization);
public QuebecProvider(final String apiBase, final String authorization) {
super(NetworkId.QUEBEC, apiBase, authorization);
setTimeZone("America/Montreal");
}
setTimeZone("America/Montreal");
}
public QuebecProvider(final String authorization)
{
super(NetworkId.QUEBEC, authorization);
public QuebecProvider(final String authorization) {
super(NetworkId.QUEBEC, authorization);
setTimeZone("America/Montreal");
}
setTimeZone("America/Montreal");
}
@Override
public String region()
{
return API_REGION;
}
@Override
public String region() {
return API_REGION;
}
}

View file

@ -25,45 +25,42 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class RtProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://railteam.hafas.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public class RtProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://railteam.hafas.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public RtProvider()
{
super(NetworkId.RT, API_BASE, "dn", PRODUCTS_MAP);
public RtProvider() {
super(NetworkId.RT, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardHasStationTable(false);
}
setStationBoardHasStationTable(false);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
private static final Pattern P_NUMBER = Pattern.compile("\\d{4,5}");
private static final Pattern P_NUMBER = Pattern.compile("\\d{4,5}");
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("N".equals(ucType)) // Frankreich, Tours
return Product.REGIONAL_TRAIN;
if ("N".equals(ucType)) // Frankreich, Tours
return Product.REGIONAL_TRAIN;
if (ucType.equals("U70"))
return null;
if (ucType.equals("X70"))
return null;
if (ucType.equals("T84"))
return null;
if (ucType.equals("U70"))
return null;
if (ucType.equals("X70"))
return null;
if (ucType.equals("T84"))
return null;
if (P_NUMBER.matcher(type).matches())
return null;
if (P_NUMBER.matcher(type).matches())
return null;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -25,34 +25,30 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class RtaChicagoProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://tripplanner.rtachicago.com/ccg3/";
// "http://elb-jpinstances-1463028547.us-east-1.elb.amazonaws.com/ccg3/";
public class RtaChicagoProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://tripplanner.rtachicago.com/ccg3/";
// "http://elb-jpinstances-1463028547.us-east-1.elb.amazonaws.com/ccg3/";
public RtaChicagoProvider()
{
super(NetworkId.RTACHICAGO, API_BASE);
public RtaChicagoProvider() {
super(NetworkId.RTACHICAGO, API_BASE);
setLanguage("en");
setTimeZone("America/Chicago");
}
setLanguage("en");
setTimeZone("America/Chicago");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("UP-N".equals(symbol)) // Union Pacific North Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N");
if ("UP-NW".equals(symbol)) // Union Pacific Northwest Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N");
if ("UP-W".equals(symbol)) // Union Pacific West Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-NW");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("UP-N".equals(symbol)) // Union Pacific North Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N");
if ("UP-NW".equals(symbol)) // Union Pacific Northwest Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N");
if ("UP-W".equals(symbol)) // Union Pacific West Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-NW");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -25,77 +25,71 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class SbbProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://fahrplan.sbb.ch/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS, Product.CABLECAR, Product.REGIONAL_TRAIN, Product.TRAM };
public class SbbProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://fahrplan.sbb.ch/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS,
Product.CABLECAR, Product.REGIONAL_TRAIN, Product.TRAM };
public SbbProvider()
{
super(NetworkId.SBB, API_BASE, "dn", PRODUCTS_MAP);
public SbbProvider() {
super(NetworkId.SBB, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardHasStationTable(false);
}
setStationBoardHasStationTable(false);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("IN".equals(ucType)) // Italien Roma-Lecce
return Product.HIGH_SPEED_TRAIN;
if ("IT".equals(ucType)) // Italien Roma-Venezia
return Product.HIGH_SPEED_TRAIN;
if ("IN".equals(ucType)) // Italien Roma-Lecce
return Product.HIGH_SPEED_TRAIN;
if ("IT".equals(ucType)) // Italien Roma-Venezia
return Product.HIGH_SPEED_TRAIN;
if ("T".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("TE2".equals(ucType)) // Basel - Strasbourg
return Product.REGIONAL_TRAIN;
if ("T".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("TE2".equals(ucType)) // Basel - Strasbourg
return Product.REGIONAL_TRAIN;
if ("TX".equals(ucType))
return Product.BUS;
if ("NFO".equals(ucType))
return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus?
return Product.BUS;
if ("TX".equals(ucType))
return Product.BUS;
if ("NFO".equals(ucType))
return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus?
return Product.BUS;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -29,68 +29,62 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class SeProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://samtrafiken.hafas.de/bin/";
// http://reseplanerare.resrobot.se/bin/
// http://api.vasttrafik.se/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.BUS,
Product.REGIONAL_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY, Product.FERRY, Product.REGIONAL_TRAIN, null, null,
null };
public class SeProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://samtrafiken.hafas.de/bin/";
// http://reseplanerare.resrobot.se/bin/
// http://api.vasttrafik.se/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.BUS, Product.REGIONAL_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS,
Product.FERRY, Product.FERRY, Product.REGIONAL_TRAIN, null, null, null };
public SeProvider()
{
super(NetworkId.SE, API_BASE, "sn", PRODUCTS_MAP);
public SeProvider() {
super(NetworkId.SE, API_BASE, "sn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setUseIso8601(true);
setStationBoardHasStationTable(false);
setStationBoardCanDoEquivs(false);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setUseIso8601(true);
setStationBoardHasStationTable(false);
setStationBoardCanDoEquivs(false);
}
private static final Pattern P_SPLIT_NAME_PAREN = Pattern.compile("(.*) \\((.{3,}?) kn\\)");
private static final Pattern P_SPLIT_NAME_PAREN = Pattern.compile("(.*) \\((.{3,}?) kn\\)");
@Override
protected String[] splitStationName(final String name)
{
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches())
return new String[] { mParen.group(2), mParen.group(1) };
@Override
protected String[] splitStationName(final String name) {
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches())
return new String[] { mParen.group(2), mParen.group(1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
private static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Buss\\s*(.*)");
private static final Pattern P_NORMALIZE_LINE_SUBWAY = Pattern.compile("Tunnelbana\\s*(.*)");
private static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Buss\\s*(.*)");
private static final Pattern P_NORMALIZE_LINE_SUBWAY = Pattern.compile("Tunnelbana\\s*(.*)");
@Override
protected Line parseLineAndType(final String line)
{
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
if (mBus.matches())
return newLine(Product.BUS, mBus.group(1), null);
@Override
protected Line parseLineAndType(final String line) {
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
if (mBus.matches())
return newLine(Product.BUS, mBus.group(1), null);
final Matcher mSubway = P_NORMALIZE_LINE_SUBWAY.matcher(line);
if (mSubway.matches())
return newLine(Product.SUBWAY, "T" + mSubway.group(1), null);
final Matcher mSubway = P_NORMALIZE_LINE_SUBWAY.matcher(line);
if (mSubway.matches())
return newLine(Product.SUBWAY, "T" + mSubway.group(1), null);
return newLine(null, line, null);
}
return newLine(null, line, null);
}
}

View file

@ -54,266 +54,240 @@ import de.schildbach.pte.util.ParserUtils;
/**
* @author Andreas Schildbach
*/
public class SeptaProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://airs1.septa.org/bin/";
private static final Product[] PRODUCTS_MAP = { Product.SUBWAY, Product.TRAM, Product.BUS, Product.SUBURBAN_TRAIN };
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
public class SeptaProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://airs1.septa.org/bin/";
private static final Product[] PRODUCTS_MAP = { Product.SUBWAY, Product.TRAM, Product.BUS, Product.SUBURBAN_TRAIN };
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
public SeptaProvider()
{
super(NetworkId.SEPTA, API_BASE, "en", PRODUCTS_MAP);
public SeptaProvider() {
super(NetworkId.SEPTA, API_BASE, "en", PRODUCTS_MAP);
setStationBoardCanDoEquivs(false);
setTimeZone("EST");
}
setStationBoardCanDoEquivs(false);
setTimeZone("EST");
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
protected void appendDateTimeParameters(final StringBuilder uri, final Date time, final String dateParamName, final String timeParamName)
{
final Calendar c = new GregorianCalendar(timeZone);
c.setTime(time);
final int year = c.get(Calendar.YEAR);
final int month = c.get(Calendar.MONTH) + 1;
final int day = c.get(Calendar.DAY_OF_MONTH);
final int hour = c.get(Calendar.HOUR);
final int minute = c.get(Calendar.MINUTE);
final String amPm = c.get(Calendar.AM_PM) == Calendar.AM ? "am" : "pm";
uri.append('&').append(dateParamName).append('=');
uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d%02d%04d", month, day, year)));
uri.append('&').append(timeParamName).append('=');
uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d:%02d %s", hour, minute, amPm)));
}
@Override
protected void appendDateTimeParameters(final StringBuilder uri, final Date time, final String dateParamName,
final String timeParamName) {
final Calendar c = new GregorianCalendar(timeZone);
c.setTime(time);
final int year = c.get(Calendar.YEAR);
final int month = c.get(Calendar.MONTH) + 1;
final int day = c.get(Calendar.DAY_OF_MONTH);
final int hour = c.get(Calendar.HOUR);
final int minute = c.get(Calendar.MINUTE);
final String amPm = c.get(Calendar.AM_PM) == Calendar.AM ? "am" : "pm";
uri.append('&').append(dateParamName).append('=');
uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d%02d%04d", month, day, year)));
uri.append('&').append(timeParamName).append('=');
uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d:%02d %s", hour, minute, amPm)));
}
private static final Pattern P_DEPARTURES_PAGE_COARSE = Pattern
.compile(
".*?" //
+ "(?:" //
+ "<div class=\"hfsTitleText\">([^<]*)<.*?" // location
+ "\n(\\d{2}/\\d{2}/\\d{4})[^\n]*\n" // date
+ "Departure (\\d{1,2}:\\d{2} [AP]M)\n.*?" // time
+ "(?:<table class=\"resultTable\"[^>]*>(.+?)</table>|(No trains in this space of time))" //
+ "|(input cannot be interpreted)|(Verbindung zum Server konnte leider nicht hergestellt werden|kann vom Server derzeit leider nicht bearbeitet werden))" //
+ ".*?" //
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"(depboard-\\w*)\">(.*?)</tr>", Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
+ "<td class=\"time\">(\\d{1,2}:\\d{2} [AP]M)</td>\n" // plannedTime
+ "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" //
+ "(?:&nbsp;|<span class=\"rtLimit\\d\">(p&#252;nktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
+ ")?.*?" //
+ "<img class=\"product\" src=\"/hafas-res/img/products/(\\w+)_pic\\.gif\" width=\"\\d+\" height=\"\\d+\" alt=\"([^\"]*)\".*?" // type,
// line
+ "<strong>\n" //
+ "<a href=\"http://airs1\\.septa\\.org/bin/stboard\\.exe/en\\?input=(\\d+)&[^>]*>" // destinationId
+ "\\s*(.*?)\\s*</a>\n" // destination
+ "</strong>.*?" //
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_PAGE_COARSE = Pattern.compile(".*?" //
+ "(?:" //
+ "<div class=\"hfsTitleText\">([^<]*)<.*?" // location
+ "\n(\\d{2}/\\d{2}/\\d{4})[^\n]*\n" // date
+ "Departure (\\d{1,2}:\\d{2} [AP]M)\n.*?" // time
+ "(?:<table class=\"resultTable\"[^>]*>(.+?)</table>|(No trains in this space of time))" //
+ "|(input cannot be interpreted)|(Verbindung zum Server konnte leider nicht hergestellt werden|kann vom Server derzeit leider nicht bearbeitet werden))" //
+ ".*?" //
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"(depboard-\\w*)\">(.*?)</tr>",
Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
+ "<td class=\"time\">(\\d{1,2}:\\d{2} [AP]M)</td>\n" // plannedTime
+ "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" //
+ "(?:&nbsp;|<span class=\"rtLimit\\d\">(p&#252;nktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
+ ")?.*?" //
+ "<img class=\"product\" src=\"/hafas-res/img/products/(\\w+)_pic\\.gif\" width=\"\\d+\" height=\"\\d+\" alt=\"([^\"]*)\".*?" // type,
// line
+ "<strong>\n" //
+ "<a href=\"http://airs1\\.septa\\.org/bin/stboard\\.exe/en\\?input=(\\d+)&[^>]*>" // destinationId
+ "\\s*(.*?)\\s*</a>\n" // destination
+ "</strong>.*?" //
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
, Pattern.DOTALL);
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
checkNotNull(Strings.emptyToNull(stationId));
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
checkNotNull(Strings.emptyToNull(stationId));
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final QueryDeparturesResult result = new QueryDeparturesResult(header);
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final QueryDeparturesResult result = new QueryDeparturesResult(header);
// scrape page
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null);
final CharSequence page = httpClient.get(uri.toString());
// scrape page
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null);
final CharSequence page = httpClient.get(uri.toString());
// parse page
final Matcher mPageCoarse = P_DEPARTURES_PAGE_COARSE.matcher(page);
if (mPageCoarse.matches())
{
// messages
if (mPageCoarse.group(5) != null)
{
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId),
Collections.<Departure> emptyList(), null));
return result;
}
else if (mPageCoarse.group(6) != null)
return new QueryDeparturesResult(header, Status.INVALID_STATION);
else if (mPageCoarse.group(7) != null)
return new QueryDeparturesResult(header, Status.SERVICE_DOWN);
// parse page
final Matcher mPageCoarse = P_DEPARTURES_PAGE_COARSE.matcher(page);
if (mPageCoarse.matches()) {
// messages
if (mPageCoarse.group(5) != null) {
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId),
Collections.<Departure> emptyList(), null));
return result;
} else if (mPageCoarse.group(6) != null)
return new QueryDeparturesResult(header, Status.INVALID_STATION);
else if (mPageCoarse.group(7) != null)
return new QueryDeparturesResult(header, Status.SERVICE_DOWN);
final String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mPageCoarse.group(1)));
final Calendar currentTime = new GregorianCalendar(timeZone);
currentTime.clear();
ParserUtils.parseAmericanDate(currentTime, mPageCoarse.group(2));
ParserUtils.parseAmericanTime(currentTime, mPageCoarse.group(3));
final String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mPageCoarse.group(1)));
final Calendar currentTime = new GregorianCalendar(timeZone);
currentTime.clear();
ParserUtils.parseAmericanDate(currentTime, mPageCoarse.group(2));
ParserUtils.parseAmericanTime(currentTime, mPageCoarse.group(3));
final List<Departure> departures = new ArrayList<Departure>(8);
String oldZebra = null;
final List<Departure> departures = new ArrayList<Departure>(8);
String oldZebra = null;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mPageCoarse.group(4));
while (mDepCoarse.find())
{
final String zebra = mDepCoarse.group(1);
if (oldZebra != null && zebra.equals(oldZebra))
throw new IllegalArgumentException("missed row? last:" + zebra);
else
oldZebra = zebra;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mPageCoarse.group(4));
while (mDepCoarse.find()) {
final String zebra = mDepCoarse.group(1);
if (oldZebra != null && zebra.equals(oldZebra))
throw new IllegalArgumentException("missed row? last:" + zebra);
else
oldZebra = zebra;
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
if (mDepFine.matches())
{
final Calendar plannedTime = new GregorianCalendar(timeZone);
plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseAmericanTime(plannedTime, mDepFine.group(1));
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
if (mDepFine.matches()) {
final Calendar plannedTime = new GregorianCalendar(timeZone);
plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseAmericanTime(plannedTime, mDepFine.group(1));
if (plannedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
plannedTime.add(Calendar.DAY_OF_MONTH, 1);
if (plannedTime.getTimeInMillis()
- currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
plannedTime.add(Calendar.DAY_OF_MONTH, 1);
final Calendar predictedTime;
final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2));
if (prognosis != null)
{
predictedTime = new GregorianCalendar(timeZone);
if (prognosis.equals("pünktlich"))
{
predictedTime.setTimeInMillis(plannedTime.getTimeInMillis());
}
else
{
predictedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseAmericanTime(predictedTime, prognosis);
}
}
else
{
predictedTime = null;
}
final Calendar predictedTime;
final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2));
if (prognosis != null) {
predictedTime = new GregorianCalendar(timeZone);
if (prognosis.equals("pünktlich")) {
predictedTime.setTimeInMillis(plannedTime.getTimeInMillis());
} else {
predictedTime.setTimeInMillis(currentTime.getTimeInMillis());
ParserUtils.parseAmericanTime(predictedTime, prognosis);
}
} else {
predictedTime = null;
}
final String lineType = mDepFine.group(3);
final String lineType = mDepFine.group(3);
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final String destinationId = mDepFine.group(5);
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final Location destination;
if (destinationId != null)
{
final String[] destinationPlaceAndName = splitStationName(destinationName);
destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0], destinationPlaceAndName[1]);
}
else
{
destination = new Location(LocationType.ANY, null, null, destinationName);
}
final String destinationId = mDepFine.group(5);
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final Location destination;
if (destinationId != null) {
final String[] destinationPlaceAndName = splitStationName(destinationName);
destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0],
destinationPlaceAndName[1]);
} else {
destination = new Location(LocationType.ANY, null, null, destinationName);
}
final Position position = parsePosition(ParserUtils.resolveEntities(mDepFine.group(7)));
final Position position = parsePosition(ParserUtils.resolveEntities(mDepFine.group(7)));
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, destination, null, null);
final Departure dep = new Departure(plannedTime.getTime(),
predictedTime != null ? predictedTime.getTime() : null, line, position, destination, null,
null);
if (!departures.contains(dep))
departures.add(dep);
}
else
{
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + stationId);
}
}
if (!departures.contains(dep))
departures.add(dep);
} else {
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + stationId);
}
}
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]),
departures, null));
return result;
}
else
{
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
}
}
result.stationDepartures.add(new StationDepartures(
new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]), departures, null));
return result;
} else {
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
}
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
return queryMoreTripsXml(context, later);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
return queryMoreTripsXml(context, later);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
// Regional
if (ucType.equals("RAI"))
return Product.REGIONAL_TRAIN;
// Regional
if (ucType.equals("RAI"))
return Product.REGIONAL_TRAIN;
// Subway
if (ucType.equals("BSS"))
return Product.SUBWAY;
if (ucType.equals("BSL"))
return Product.SUBWAY;
if (ucType.equals("MFL"))
return Product.SUBWAY;
// Subway
if (ucType.equals("BSS"))
return Product.SUBWAY;
if (ucType.equals("BSL"))
return Product.SUBWAY;
if (ucType.equals("MFL"))
return Product.SUBWAY;
// Tram
if (ucType.equals("TRM"))
return Product.TRAM;
if (ucType.equals("NHS")) // Tro NHSL
return Product.TRAM;
// Tram
if (ucType.equals("TRM"))
return Product.TRAM;
if (ucType.equals("NHS")) // Tro NHSL
return Product.TRAM;
// Bus
if (ucType.equals("BUS"))
return Product.BUS;
if (ucType.equals("TRO"))
return Product.BUS;
// Bus
if (ucType.equals("BUS"))
return Product.BUS;
if (ucType.equals("TRO"))
return Product.BUS;
// from Connections:
// from Connections:
if (ucType.equals("RAIL"))
return Product.REGIONAL_TRAIN;
if (ucType.equals("RAIL"))
return Product.REGIONAL_TRAIN;
if (ucType.equals("SUBWAY"))
return Product.SUBWAY;
if (ucType.equals("SUBWAY"))
return Product.SUBWAY;
if (ucType.equals("TROLLEY"))
return Product.BUS;
if (ucType.equals("TROLLEY"))
return Product.BUS;
// skip parsing of "common" lines, because this is America
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
// skip parsing of "common" lines, because this is America
throw new IllegalStateException("cannot normalize type '" + type + "'");
}
}

View file

@ -30,132 +30,129 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class SfProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://tripplanner.transit.511.org/mtc/";
public class SfProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://tripplanner.transit.511.org/mtc/";
public SfProvider()
{
super(NetworkId.SF, API_BASE);
public SfProvider() {
super(NetworkId.SF, API_BASE);
setLanguage("en");
setTimeZone("America/Los_Angeles");
setUseRouteIndexAsTripId(false);
setFareCorrectionFactor(0.01f);
setStyles(STYLES);
}
setLanguage("en");
setTimeZone("America/Los_Angeles");
setUseRouteIndexAsTripId(false);
setFareCorrectionFactor(0.01f);
setStyles(STYLES);
}
@Override
protected String normalizeLocationName(final String name)
{
if (name == null || name.length() == 0)
return null;
@Override
protected String normalizeLocationName(final String name) {
if (name == null || name.length() == 0)
return null;
return super.normalizeLocationName(name).replace("$XINT$", "&");
}
return super.normalizeLocationName(name).replace("$XINT$", "&");
}
@Override
protected Position parsePosition(final String position)
{
if (position == null)
return null;
@Override
protected Position parsePosition(final String position) {
if (position == null)
return null;
final int i = position.lastIndexOf("##");
if (i < 0)
return position.length() < 16 ? super.parsePosition(position) : null;
final int i = position.lastIndexOf("##");
if (i < 0)
return position.length() < 16 ? super.parsePosition(position) : null;
final String name = position.substring(i + 2).trim();
if (name.isEmpty())
return null;
final String name = position.substring(i + 2).trim();
if (name.isEmpty())
return null;
return new Position(name);
}
return new Position(name);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if (("XAA".equals(symbol) || "Daly City / Fremont".equals(symbol)) && ("DALY/FREMONT".equals(name) || "Daly City / Fremont".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/FRMT");
if (("FRE".equals(symbol) || "Fremont / Daly City".equals(symbol)) && ("FREMONT/DALY".equals(name) || "Fremont / Daly City".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/DALY");
if (("XAC".equals(symbol) || "Fremont / Richmond".equals(symbol)) && "Fremont / Richmond".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/RICH");
if (("XAD".equals(symbol) || "Richmond / Fremont".equals(symbol)) && "Richmond / Fremont".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/FRMT");
if (("XAE".equals(symbol) || "Pittsburg Bay Point / SFO".equals(symbol))
&& ("BAY PT/SFIA".equals(name) || "Pittsburg Bay Point / SFO".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "PITT/SFIA");
if (("SFI".equals(symbol) || "SFO / Pittsburg Bay Point".equals(symbol))
&& ("SFIA/BAY PT".equals(name) || "SFO / Pittsburg Bay Point".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "SFIA/PITT");
if (("XAF".equals(symbol) || "Millbrae / Richmond".equals(symbol)) && ("MILL/RICH".equals(name) || "Millbrae / Richmond".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "MLBR/RICH");
if (("XAG".equals(symbol) || "Richmond / Millbrae".equals(symbol)) && ("RICH/MILL".equals(name) || "Richmond / Millbrae".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/MLBR");
if (("XAH".equals(symbol) || "Daly City / Dublin Pleasanton".equals(symbol))
&& ("DALY/DUBLIN".equals(name) || "Daly City / Dublin Pleasanton".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/DUBL");
if (("XAI".equals(symbol) || "Dublin Pleasanton / Daly City".equals(symbol))
&& ("DUBLIN/DALY".equals(name) || "Dublin Pleasanton / Daly City".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "DUBL/DALY");
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if (("XAA".equals(symbol) || "Daly City / Fremont".equals(symbol))
&& ("DALY/FREMONT".equals(name) || "Daly City / Fremont".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/FRMT");
if (("FRE".equals(symbol) || "Fremont / Daly City".equals(symbol))
&& ("FREMONT/DALY".equals(name) || "Fremont / Daly City".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/DALY");
if (("XAC".equals(symbol) || "Fremont / Richmond".equals(symbol)) && "Fremont / Richmond".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/RICH");
if (("XAD".equals(symbol) || "Richmond / Fremont".equals(symbol)) && "Richmond / Fremont".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/FRMT");
if (("XAE".equals(symbol) || "Pittsburg Bay Point / SFO".equals(symbol))
&& ("BAY PT/SFIA".equals(name) || "Pittsburg Bay Point / SFO".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "PITT/SFIA");
if (("SFI".equals(symbol) || "SFO / Pittsburg Bay Point".equals(symbol))
&& ("SFIA/BAY PT".equals(name) || "SFO / Pittsburg Bay Point".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "SFIA/PITT");
if (("XAF".equals(symbol) || "Millbrae / Richmond".equals(symbol))
&& ("MILL/RICH".equals(name) || "Millbrae / Richmond".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "MLBR/RICH");
if (("XAG".equals(symbol) || "Richmond / Millbrae".equals(symbol))
&& ("RICH/MILL".equals(name) || "Richmond / Millbrae".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/MLBR");
if (("XAH".equals(symbol) || "Daly City / Dublin Pleasanton".equals(symbol))
&& ("DALY/DUBLIN".equals(name) || "Daly City / Dublin Pleasanton".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/DUBL");
if (("XAI".equals(symbol) || "Dublin Pleasanton / Daly City".equals(symbol))
&& ("DUBLIN/DALY".equals(name) || "Dublin Pleasanton / Daly City".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "DUBL/DALY");
if ("BAB".equals(symbol) && "BABY BULLET".equals(trainNum)) // Caltrain Baby Bullet
return new Line(id, network, Product.REGIONAL_TRAIN, "BAB");
if ("BAB".equals(symbol) && "BABY BULLET".equals(trainNum)) // Caltrain Baby Bullet
return new Line(id, network, Product.REGIONAL_TRAIN, "BAB");
if ("LOC".equals(symbol) && "LOCAL".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "Local");
if ("CAP".equals(symbol) && "CAPITOL".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "Capitol");
if ("OAK".equals(symbol) && "OAK / Coliseum".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "OAK/Coliseum");
if ("LOC".equals(symbol) && "LOCAL".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "Local");
if ("CAP".equals(symbol) && "CAPITOL".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "Capitol");
if ("OAK".equals(symbol) && "OAK / Coliseum".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "OAK/Coliseum");
if ("Muni Rail".equals(trainName) && symbol != null) // Muni
return new Line(id, network, Product.TRAM, symbol);
if (trainType == null && "E".equals(trainNum)) // Muni Rail E
return new Line(id, network, Product.TRAM, "E");
if (trainType == null && "F".equals(trainNum)) // Muni Historic Streetcar
return new Line(id, network, Product.TRAM, "F");
if (trainType == null && "J".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "J");
if (trainType == null && "K".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "K");
if (trainType == null && "KT".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "KT");
if (trainType == null && "L".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "L");
if (trainType == null && "M".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "M");
if (trainType == null && "N".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "N");
if (trainType == null && "T".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "T");
}
if ("Muni Rail".equals(trainName) && symbol != null) // Muni
return new Line(id, network, Product.TRAM, symbol);
if (trainType == null && "E".equals(trainNum)) // Muni Rail E
return new Line(id, network, Product.TRAM, "E");
if (trainType == null && "F".equals(trainNum)) // Muni Historic Streetcar
return new Line(id, network, Product.TRAM, "F");
if (trainType == null && "J".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "J");
if (trainType == null && "K".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "K");
if (trainType == null && "KT".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "KT");
if (trainType == null && "L".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "L");
if (trainType == null && "M".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "M");
if (trainType == null && "N".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "N");
if (trainType == null && "T".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "T");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// BART
STYLES.put("RDALY/FRMT", new Style(Style.parseColor("#4EBF49"), Style.WHITE));
STYLES.put("RFRMT/DALY", new Style(Style.parseColor("#4EBF49"), Style.WHITE));
static {
// BART
STYLES.put("RDALY/FRMT", new Style(Style.parseColor("#4EBF49"), Style.WHITE));
STYLES.put("RFRMT/DALY", new Style(Style.parseColor("#4EBF49"), Style.WHITE));
STYLES.put("RFRMT/RICH", new Style(Style.parseColor("#FAA61A"), Style.WHITE));
STYLES.put("RRICH/FRMT", new Style(Style.parseColor("#FAA61A"), Style.WHITE));
STYLES.put("RFRMT/RICH", new Style(Style.parseColor("#FAA61A"), Style.WHITE));
STYLES.put("RRICH/FRMT", new Style(Style.parseColor("#FAA61A"), Style.WHITE));
STYLES.put("RSFIA/PITT", new Style(Style.parseColor("#FFE800"), Style.BLACK));
STYLES.put("RPITT/SFIA", new Style(Style.parseColor("#FFE800"), Style.BLACK));
STYLES.put("RSFIA/PITT", new Style(Style.parseColor("#FFE800"), Style.BLACK));
STYLES.put("RPITT/SFIA", new Style(Style.parseColor("#FFE800"), Style.BLACK));
STYLES.put("RMLBR/RICH", new Style(Style.parseColor("#F81A23"), Style.WHITE));
STYLES.put("RRICH/MLBR", new Style(Style.parseColor("#F81A23"), Style.WHITE));
STYLES.put("RMLBR/RICH", new Style(Style.parseColor("#F81A23"), Style.WHITE));
STYLES.put("RRICH/MLBR", new Style(Style.parseColor("#F81A23"), Style.WHITE));
STYLES.put("RDALY/DUBL", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
STYLES.put("RDUBL/DALY", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
}
STYLES.put("RDALY/DUBL", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
STYLES.put("RDUBL/DALY", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
}
}

View file

@ -45,155 +45,144 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class ShProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://nah.sh.hafas.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public class ShProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://nah.sh.hafas.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public ShProvider(final String jsonApiAuthorization)
{
super(NetworkId.SH, API_BASE, "dn", PRODUCTS_MAP);
public ShProvider(final String jsonApiAuthorization) {
super(NetworkId.SH, API_BASE, "dn", PRODUCTS_MAP);
setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"NAHSH\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"NAHSH\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
private static final String[] PLACES = { "Hamburg", "Kiel", "Lübeck", "Flensburg", "Neumünster" };
private static final String[] PLACES = { "Hamburg", "Kiel", "Lübeck", "Flensburg", "Neumünster" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
@Override
protected String[] splitStationName(final String name) {
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException
{
return jsonLocMatch(constraint);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
return jsonLocMatch(constraint);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
@Override
protected Fare parseJsonTripFare(final @Nullable String fareSetName, final @Nullable String fareSetDescription, String name,
final Currency currency, final float price)
{
if (!"Normalpreis".equals(fareSetDescription) || !name.startsWith("Einzelfahrkarte "))
return null;
name = name.substring(16);
if (name.startsWith("Übergang"))
return null;
if (name.startsWith("Kind "))
return new Fare("SH-Tarif", Type.CHILD, currency, price, name.substring(5), null);
else
return new Fare("SH-Tarif", Type.ADULT, currency, price, name, null);
}
@Override
protected Fare parseJsonTripFare(final @Nullable String fareSetName, final @Nullable String fareSetDescription,
String name, final Currency currency, final float price) {
if (!"Normalpreis".equals(fareSetDescription) || !name.startsWith("Einzelfahrkarte "))
return null;
name = name.substring(16);
if (name.startsWith("Übergang"))
return null;
if (name.startsWith("Kind "))
return new Fare("SH-Tarif", Type.CHILD, currency, price, name.substring(5), null);
else
return new Fare("SH-Tarif", Type.ADULT, currency, price, name, null);
}
protected static final Map<String, Style> STYLES = new HashMap<String, Style>();
protected static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Busse Kiel
putKielBusStyle("1", new Style(Style.parseColor("#7288af"), Style.WHITE));
putKielBusStyle("2", new Style(Style.parseColor("#50bbb4"), Style.WHITE));
putKielBusStyle("5", new Style(Style.parseColor("#f39222"), Style.WHITE));
putKielBusStyle("6", new Style(Style.parseColor("#aec436"), Style.WHITE));
putKielBusStyle("8", new Style(Style.parseColor("#bcb261"), Style.WHITE));
putKielBusStyle("9", new Style(Style.parseColor("#c99c7d"), Style.WHITE));
putKielBusStyle("11", new Style(Style.parseColor("#f9b000"), Style.WHITE));
putKielBusStyle("22", new Style(Style.parseColor("#8ea48a"), Style.WHITE));
putKielBusStyle("31", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("32", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("33", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("34", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("41", new Style(Style.parseColor("#8ba5d6"), Style.WHITE));
putKielBusStyle("42", new Style(Style.parseColor("#8ba5d6"), Style.WHITE));
putKielBusStyle("50", new Style(Style.parseColor("#00a138"), Style.WHITE));
putKielBusStyle("51", new Style(Style.parseColor("#00a138"), Style.WHITE));
putKielBusStyle("52", new Style(Style.parseColor("#00a138"), Style.WHITE));
putKielBusStyle("60S", new Style(Style.parseColor("#92b4af"), Style.WHITE));
putKielBusStyle("60", new Style(Style.parseColor("#92b4af"), Style.WHITE));
putKielBusStyle("61", new Style(Style.parseColor("#9d1380"), Style.WHITE));
putKielBusStyle("62", new Style(Style.parseColor("#9d1380"), Style.WHITE));
putKielBusStyle("71", new Style(Style.parseColor("#777e6f"), Style.WHITE));
putKielBusStyle("72", new Style(Style.parseColor("#777e6f"), Style.WHITE));
putKielBusStyle("81", new Style(Style.parseColor("#00836e"), Style.WHITE));
putKielBusStyle("91", new Style(Style.parseColor("#947e62"), Style.WHITE));
putKielBusStyle("92", new Style(Style.parseColor("#947e62"), Style.WHITE));
putKielBusStyle("100", new Style(Style.parseColor("#d40a11"), Style.WHITE));
putKielBusStyle("101", new Style(Style.parseColor("#d40a11"), Style.WHITE));
putKielBusStyle("300", new Style(Style.parseColor("#cf94c2"), Style.WHITE));
putKielBusStyle("501", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("502", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("503", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("503S", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("512", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("512S", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
}
static {
// Busse Kiel
putKielBusStyle("1", new Style(Style.parseColor("#7288af"), Style.WHITE));
putKielBusStyle("2", new Style(Style.parseColor("#50bbb4"), Style.WHITE));
putKielBusStyle("5", new Style(Style.parseColor("#f39222"), Style.WHITE));
putKielBusStyle("6", new Style(Style.parseColor("#aec436"), Style.WHITE));
putKielBusStyle("8", new Style(Style.parseColor("#bcb261"), Style.WHITE));
putKielBusStyle("9", new Style(Style.parseColor("#c99c7d"), Style.WHITE));
putKielBusStyle("11", new Style(Style.parseColor("#f9b000"), Style.WHITE));
putKielBusStyle("22", new Style(Style.parseColor("#8ea48a"), Style.WHITE));
putKielBusStyle("31", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("32", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("33", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("34", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("41", new Style(Style.parseColor("#8ba5d6"), Style.WHITE));
putKielBusStyle("42", new Style(Style.parseColor("#8ba5d6"), Style.WHITE));
putKielBusStyle("50", new Style(Style.parseColor("#00a138"), Style.WHITE));
putKielBusStyle("51", new Style(Style.parseColor("#00a138"), Style.WHITE));
putKielBusStyle("52", new Style(Style.parseColor("#00a138"), Style.WHITE));
putKielBusStyle("60S", new Style(Style.parseColor("#92b4af"), Style.WHITE));
putKielBusStyle("60", new Style(Style.parseColor("#92b4af"), Style.WHITE));
putKielBusStyle("61", new Style(Style.parseColor("#9d1380"), Style.WHITE));
putKielBusStyle("62", new Style(Style.parseColor("#9d1380"), Style.WHITE));
putKielBusStyle("71", new Style(Style.parseColor("#777e6f"), Style.WHITE));
putKielBusStyle("72", new Style(Style.parseColor("#777e6f"), Style.WHITE));
putKielBusStyle("81", new Style(Style.parseColor("#00836e"), Style.WHITE));
putKielBusStyle("91", new Style(Style.parseColor("#947e62"), Style.WHITE));
putKielBusStyle("92", new Style(Style.parseColor("#947e62"), Style.WHITE));
putKielBusStyle("100", new Style(Style.parseColor("#d40a11"), Style.WHITE));
putKielBusStyle("101", new Style(Style.parseColor("#d40a11"), Style.WHITE));
putKielBusStyle("300", new Style(Style.parseColor("#cf94c2"), Style.WHITE));
putKielBusStyle("501", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("502", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("503", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("503S", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("512", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("512S", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
}
private static void putKielBusStyle(final String name, final Style style)
{
STYLES.put("Autokraft Kiel GmbH|B" + name, style);
STYLES.put("Kieler Verkehrsgesellschaft mbH|B" + name, style);
}
private static void putKielBusStyle(final String name, final Style style) {
STYLES.put("Autokraft Kiel GmbH|B" + name, style);
STYLES.put("Kieler Verkehrsgesellschaft mbH|B" + name, style);
}
}

View file

@ -32,90 +32,79 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class SncbProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://www.belgianrail.be/jp/sncb-nmbs-routeplanner/";
// http://hari.b-rail.be/hafas/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, null, Product.HIGH_SPEED_TRAIN, null, null, Product.BUS,
Product.REGIONAL_TRAIN, null, Product.SUBWAY, Product.BUS, Product.TRAM, null, null, null, null, null };
public class SncbProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://www.belgianrail.be/jp/sncb-nmbs-routeplanner/";
// http://hari.b-rail.be/hafas/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, null, Product.HIGH_SPEED_TRAIN, null,
null, Product.BUS, Product.REGIONAL_TRAIN, null, Product.SUBWAY, Product.BUS, Product.TRAM, null, null,
null, null, null };
public SncbProvider()
{
super(NetworkId.SNCB, API_BASE, "nn", PRODUCTS_MAP);
public SncbProvider() {
super(NetworkId.SNCB, API_BASE, "nn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStationBoardHasLocation(true);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStationBoardHasLocation(true);
}
private static final String[] PLACES = { "Antwerpen", "Gent", "Charleroi", "Liege", "Liège", "Brussel" };
private static final String[] PLACES = { "Antwerpen", "Gent", "Charleroi", "Liege", "Liège", "Brussel" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
@Override
protected String[] splitStationName(final String name) {
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
{
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Zoek");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
} else if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Zoek");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("THALYS".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("THALYS".equals(ucType))
return Product.HIGH_SPEED_TRAIN;
if ("L".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("L".equals(ucType))
return Product.REGIONAL_TRAIN;
if ("MÉTRO".equals(ucType))
return Product.SUBWAY;
if ("MÉTRO".equals(ucType))
return Product.SUBWAY;
if ("TRAMWAY".equals(ucType))
return Product.TRAM;
if ("TRAMWAY".equals(ucType))
return Product.TRAM;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
}

View file

@ -27,27 +27,26 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class Standard
{
public static final int COLOR_BACKGROUND_HIGH_SPEED_TRAIN = Style.WHITE;
public static final int COLOR_BACKGROUND_REGIONAL_TRAIN = Style.GRAY;
public static final int COLOR_BACKGROUND_SUBURBAN_TRAIN = Style.parseColor("#006e34");
public static final int COLOR_BACKGROUND_SUBWAY = Style.parseColor("#003090");
public static final int COLOR_BACKGROUND_TRAM = Style.parseColor("#cc0000");
public static final int COLOR_BACKGROUND_BUS = Style.parseColor("#993399");
public static final int COLOR_BACKGROUND_FERRY = Style.BLUE;
public class Standard {
public static final int COLOR_BACKGROUND_HIGH_SPEED_TRAIN = Style.WHITE;
public static final int COLOR_BACKGROUND_REGIONAL_TRAIN = Style.GRAY;
public static final int COLOR_BACKGROUND_SUBURBAN_TRAIN = Style.parseColor("#006e34");
public static final int COLOR_BACKGROUND_SUBWAY = Style.parseColor("#003090");
public static final int COLOR_BACKGROUND_TRAM = Style.parseColor("#cc0000");
public static final int COLOR_BACKGROUND_BUS = Style.parseColor("#993399");
public static final int COLOR_BACKGROUND_FERRY = Style.BLUE;
public static final Map<Product, Style> STYLES = new HashMap<Product, Style>();
public static final Map<Product, Style> STYLES = new HashMap<Product, Style>();
static
{
STYLES.put(Product.HIGH_SPEED_TRAIN, new Style(Shape.RECT, COLOR_BACKGROUND_HIGH_SPEED_TRAIN, Style.RED, Style.RED));
STYLES.put(Product.REGIONAL_TRAIN, new Style(Shape.RECT, COLOR_BACKGROUND_REGIONAL_TRAIN, Style.WHITE));
STYLES.put(Product.SUBURBAN_TRAIN, new Style(Shape.CIRCLE, COLOR_BACKGROUND_SUBURBAN_TRAIN, Style.WHITE));
STYLES.put(Product.SUBWAY, new Style(Shape.RECT, COLOR_BACKGROUND_SUBWAY, Style.WHITE));
STYLES.put(Product.TRAM, new Style(Shape.RECT, COLOR_BACKGROUND_TRAM, Style.WHITE));
STYLES.put(Product.BUS, new Style(COLOR_BACKGROUND_BUS, Style.WHITE));
STYLES.put(Product.FERRY, new Style(Shape.CIRCLE, COLOR_BACKGROUND_FERRY, Style.WHITE));
STYLES.put(null, new Style(Style.DKGRAY, Style.WHITE));
}
static {
STYLES.put(Product.HIGH_SPEED_TRAIN,
new Style(Shape.RECT, COLOR_BACKGROUND_HIGH_SPEED_TRAIN, Style.RED, Style.RED));
STYLES.put(Product.REGIONAL_TRAIN, new Style(Shape.RECT, COLOR_BACKGROUND_REGIONAL_TRAIN, Style.WHITE));
STYLES.put(Product.SUBURBAN_TRAIN, new Style(Shape.CIRCLE, COLOR_BACKGROUND_SUBURBAN_TRAIN, Style.WHITE));
STYLES.put(Product.SUBWAY, new Style(Shape.RECT, COLOR_BACKGROUND_SUBWAY, Style.WHITE));
STYLES.put(Product.TRAM, new Style(Shape.RECT, COLOR_BACKGROUND_TRAM, Style.WHITE));
STYLES.put(Product.BUS, new Style(COLOR_BACKGROUND_BUS, Style.WHITE));
STYLES.put(Product.FERRY, new Style(Shape.CIRCLE, COLOR_BACKGROUND_FERRY, Style.WHITE));
STYLES.put(null, new Style(Style.DKGRAY, Style.WHITE));
}
}

View file

@ -25,28 +25,24 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class StvProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://fahrplan.verbundlinie.at/stv/";
public class StvProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://fahrplan.verbundlinie.at/stv/";
public StvProvider()
{
super(NetworkId.STV, API_BASE);
public StvProvider() {
super(NetworkId.STV, API_BASE);
setIncludeRegionId(false);
}
setIncludeRegionId(false);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("M".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "M" + trainNum);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("M".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "M" + trainNum);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -33,442 +33,434 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class SydneyProvider extends AbstractEfaProvider
{
private final static String API_BASE = "https://tp.transportnsw.info/nsw/";
public class SydneyProvider extends AbstractEfaProvider {
private final static String API_BASE = "https://tp.transportnsw.info/nsw/";
public SydneyProvider()
{
super(NetworkId.SYDNEY, API_BASE);
public SydneyProvider() {
super(NetworkId.SYDNEY, API_BASE);
setLanguage("en");
setTimeZone("Australia/Sydney");
setUseProxFootSearch(false);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
}
setLanguage("en");
setTimeZone("Australia/Sydney");
setUseProxFootSearch(false);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
if (products != null)
{
for (final Product p : products)
{
if (p == Product.BUS)
uri.append("&inclMOT_11=on"); // school bus
}
}
if (products != null) {
for (final Product p : products) {
if (p == Product.BUS)
uri.append("&inclMOT_11=on"); // school bus
}
}
uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on");
uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on");
return uri.toString();
}
return uri.toString();
}
@Override
protected String normalizeLocationName(final String name)
{
if (name == null || name.length() == 0)
return null;
@Override
protected String normalizeLocationName(final String name) {
if (name == null || name.length() == 0)
return null;
return super.normalizeLocationName(name).replace("$XINT$", "&");
}
return super.normalizeLocationName(name).replace("$XINT$", "&");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("1".equals(mot))
{
if ("BMT".equals(symbol) || "Blue Mountains Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "BMT");
if ("CCN".equals(symbol) || "Central Coast & Newcastle Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "CCN");
if ("SHL".equals(symbol) || "Southern Highlands Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SHL");
if ("SCO".equals(symbol) || "South Coast Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SCO");
if ("HUN".equals(symbol) || "Hunter Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "HUN");
if ("SWR".equals(symbol)) // South West Rail Link
return new Line(id, network, Product.SUBURBAN_TRAIN, "SWR");
if ("NRC".equals(symbol) || (symbol != null && symbol.startsWith("North Coast NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "NRC");
if ("WST".equals(symbol) || (symbol != null && symbol.startsWith("Western NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "WST");
if ("STH".equals(symbol) || (symbol != null && symbol.startsWith("Southern NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "STH");
if ("NRW".equals(symbol) || (symbol != null && symbol.startsWith("North Western NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "NRW");
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("1".equals(mot)) {
if ("BMT".equals(symbol) || "Blue Mountains Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "BMT");
if ("CCN".equals(symbol) || "Central Coast & Newcastle Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "CCN");
if ("SHL".equals(symbol) || "Southern Highlands Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SHL");
if ("SCO".equals(symbol) || "South Coast Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SCO");
if ("HUN".equals(symbol) || "Hunter Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "HUN");
if ("SWR".equals(symbol)) // South West Rail Link
return new Line(id, network, Product.SUBURBAN_TRAIN, "SWR");
if ("NRC".equals(symbol) || (symbol != null && symbol.startsWith("North Coast NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "NRC");
if ("WST".equals(symbol) || (symbol != null && symbol.startsWith("Western NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "WST");
if ("STH".equals(symbol) || (symbol != null && symbol.startsWith("Southern NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "STH");
if ("NRW".equals(symbol) || (symbol != null && symbol.startsWith("North Western NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "NRW");
if ("T1".equals(symbol) || "T1 North Shore & Northern Line".equals(symbol) || "T1 North Shore and Northern Line".equals(symbol)
|| "T1 Northern Line".equals(symbol) || "T1 Western Line".equals(symbol)
|| "T1 North Shore, Northern & Western Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T1");
if ("T2".equals(symbol) || "T2 Inner West & South Line".equals(symbol) || "T2 Airport Line".equals(symbol)
|| "T2 Airport, Inner West & South Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T2");
if ("T3".equals(symbol) || "T3 Bankstown Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T3");
if ("T4".equals(symbol) || "T4 Eastern Suburbs & Illawarra Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T4");
if ("T5".equals(symbol) || "T5 Cumberland Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T5");
if ("T6".equals(symbol) || "T6 Carlingford Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T6");
if ("T7".equals(symbol) || "T7 Olympic Park Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T7");
if ("T1".equals(symbol) || "T1 North Shore & Northern Line".equals(symbol)
|| "T1 North Shore and Northern Line".equals(symbol) || "T1 Northern Line".equals(symbol)
|| "T1 Western Line".equals(symbol) || "T1 North Shore, Northern & Western Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T1");
if ("T2".equals(symbol) || "T2 Inner West & South Line".equals(symbol) || "T2 Airport Line".equals(symbol)
|| "T2 Airport, Inner West & South Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T2");
if ("T3".equals(symbol) || "T3 Bankstown Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T3");
if ("T4".equals(symbol) || "T4 Eastern Suburbs & Illawarra Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T4");
if ("T5".equals(symbol) || "T5 Cumberland Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T5");
if ("T6".equals(symbol) || "T6 Carlingford Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T6");
if ("T7".equals(symbol) || "T7 Olympic Park Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T7");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
}
else if ("4".equals(mot))
{
if ("L1".equals(symbol) || "L1 Dulwich Hill Line".equals(symbol))
return new Line(id, network, Product.TRAM, "L1");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name
+ "' long='" + longName + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='"
+ trainName + "'");
} else if ("4".equals(mot)) {
if ("L1".equals(symbol) || "L1 Dulwich Hill Line".equals(symbol))
return new Line(id, network, Product.TRAM, "L1");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
}
else if ("9".equals(mot))
{
if ("F1".equals(symbol) || "F1 Manly".equals(symbol))
return new Line(id, network, Product.FERRY, "F1");
if ("F2".equals(symbol) || "F2 Taronga Zoo".equals(symbol))
return new Line(id, network, Product.FERRY, "F2");
if ("F3".equals(symbol) || "F3 Parramatta River".equals(symbol))
return new Line(id, network, Product.FERRY, "F3");
if ("F4".equals(symbol) || "F4 Darling Harbour".equals(symbol))
return new Line(id, network, Product.FERRY, "F4");
if ("F5".equals(symbol) || "F5 Neutral Bay".equals(symbol))
return new Line(id, network, Product.FERRY, "F5");
if ("F6".equals(symbol) || "F6 Mosman Bay".equals(symbol))
return new Line(id, network, Product.FERRY, "F6");
if ("F7".equals(symbol) || "F7 Eastern Suburbs".equals(symbol))
return new Line(id, network, Product.FERRY, "F7");
if (("Private ferry servic".equals(trainName) || "Private ferry and fa".equals(trainName)) && symbol != null)
return new Line(id, network, Product.FERRY, symbol);
if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name))
return new Line(id, network, Product.FERRY, "MFF");
if ("LneCv".equals(symbol) || "Lane Cove Ferry".equals(name))
return new Line(id, network, Product.FERRY, "LneCv");
if ("EmpBa".equals(symbol) || "Woy Woy to Empire Bay Ferry".equals(name))
return new Line(id, network, Product.FERRY, "EmpBa");
if ("Stkn".equals(symbol) || "Stockton Ferry".equals(name))
return new Line(id, network, Product.FERRY, "Stkn");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name
+ "' long='" + longName + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='"
+ trainName + "'");
} else if ("9".equals(mot)) {
if ("F1".equals(symbol) || "F1 Manly".equals(symbol))
return new Line(id, network, Product.FERRY, "F1");
if ("F2".equals(symbol) || "F2 Taronga Zoo".equals(symbol))
return new Line(id, network, Product.FERRY, "F2");
if ("F3".equals(symbol) || "F3 Parramatta River".equals(symbol))
return new Line(id, network, Product.FERRY, "F3");
if ("F4".equals(symbol) || "F4 Darling Harbour".equals(symbol))
return new Line(id, network, Product.FERRY, "F4");
if ("F5".equals(symbol) || "F5 Neutral Bay".equals(symbol))
return new Line(id, network, Product.FERRY, "F5");
if ("F6".equals(symbol) || "F6 Mosman Bay".equals(symbol))
return new Line(id, network, Product.FERRY, "F6");
if ("F7".equals(symbol) || "F7 Eastern Suburbs".equals(symbol))
return new Line(id, network, Product.FERRY, "F7");
if (("Private ferry servic".equals(trainName) || "Private ferry and fa".equals(trainName))
&& symbol != null)
return new Line(id, network, Product.FERRY, symbol);
if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name))
return new Line(id, network, Product.FERRY, "MFF");
if ("LneCv".equals(symbol) || "Lane Cove Ferry".equals(name))
return new Line(id, network, Product.FERRY, "LneCv");
if ("EmpBa".equals(symbol) || "Woy Woy to Empire Bay Ferry".equals(name))
return new Line(id, network, Product.FERRY, "EmpBa");
if ("Stkn".equals(symbol) || "Stockton Ferry".equals(name))
return new Line(id, network, Product.FERRY, "Stkn");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
}
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name
+ "' long='" + longName + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='"
+ trainName + "'");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
STYLES.put("SBMT", new Style(Style.parseColor("#f5a81d"), Style.WHITE));
STYLES.put("SCCN", new Style(Style.parseColor("#d11f2f"), Style.WHITE));
STYLES.put("SSHL", new Style(Style.parseColor("#843135"), Style.WHITE));
STYLES.put("SSCO", new Style(Style.parseColor("#0083bf"), Style.WHITE));
STYLES.put("SHUN", new Style(Style.parseColor("#509e45"), Style.WHITE));
static {
STYLES.put("SBMT", new Style(Style.parseColor("#f5a81d"), Style.WHITE));
STYLES.put("SCCN", new Style(Style.parseColor("#d11f2f"), Style.WHITE));
STYLES.put("SSHL", new Style(Style.parseColor("#843135"), Style.WHITE));
STYLES.put("SSCO", new Style(Style.parseColor("#0083bf"), Style.WHITE));
STYLES.put("SHUN", new Style(Style.parseColor("#509e45"), Style.WHITE));
STYLES.put("ST1", new Style(Style.parseColor("#f4a00e"), Style.WHITE));
STYLES.put("ST2", new Style(Style.parseColor("#48a338"), Style.WHITE));
STYLES.put("ST3", new Style(Style.parseColor("#f25223"), Style.WHITE));
STYLES.put("ST4", new Style(Style.parseColor("#1081c5"), Style.WHITE));
STYLES.put("ST5", new Style(Style.parseColor("#c72c9e"), Style.WHITE));
STYLES.put("ST6", new Style(Style.parseColor("#3a5b9a"), Style.WHITE));
STYLES.put("ST7", new Style(Style.parseColor("#97a2ad"), Style.WHITE));
STYLES.put("ST1", new Style(Style.parseColor("#f4a00e"), Style.WHITE));
STYLES.put("ST2", new Style(Style.parseColor("#48a338"), Style.WHITE));
STYLES.put("ST3", new Style(Style.parseColor("#f25223"), Style.WHITE));
STYLES.put("ST4", new Style(Style.parseColor("#1081c5"), Style.WHITE));
STYLES.put("ST5", new Style(Style.parseColor("#c72c9e"), Style.WHITE));
STYLES.put("ST6", new Style(Style.parseColor("#3a5b9a"), Style.WHITE));
STYLES.put("ST7", new Style(Style.parseColor("#97a2ad"), Style.WHITE));
STYLES.put("TL1", new Style(Style.parseColor("#c01a2c"), Style.WHITE));
STYLES.put("TL1", new Style(Style.parseColor("#c01a2c"), Style.WHITE));
STYLES.put("B130", new Style(Style.parseColor("#878787"), Style.WHITE));
STYLES.put("B131", new Style(Style.parseColor("#bcbcbc"), Style.WHITE));
STYLES.put("B132", new Style(Style.parseColor("#f08cb5"), Style.WHITE));
STYLES.put("B135", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B136", new Style(Style.parseColor("#f18f00"), Style.WHITE));
STYLES.put("B137", new Style(Style.parseColor("#f18f00"), Style.WHITE));
STYLES.put("B139", new Style(Style.parseColor("#009fc8"), Style.WHITE));
STYLES.put("BL60", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B140", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B142", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B143", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B144", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE50", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B151", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B153", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B155", new Style(Style.parseColor("#1d1d1b"), Style.WHITE));
STYLES.put("B156", new Style(Style.parseColor("#1d1d1b"), Style.WHITE));
STYLES.put("B158", new Style(Style.parseColor("#a05c00"), Style.WHITE));
STYLES.put("B159", new Style(Style.parseColor("#a05c00"), Style.WHITE));
STYLES.put("BE65", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE66", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B168", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE68", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B169", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("BE69", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("BE70", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B171", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE71", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B173", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("B175", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B176", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE76", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE77", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B178", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE78", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BL78", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B179", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE79", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B180", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BL80", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B183", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE83", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B184", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL84", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE84", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B185", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL85", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE85", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE86", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B187", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL87", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE87", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B188", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL88", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE88", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE89", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B190", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL90", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B200", new Style(Style.parseColor("#c27ab1"), Style.WHITE));
STYLES.put("B201", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B202", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B203", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B205", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B206", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B207", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B208", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B209", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B225", new Style(Style.parseColor("#f08cb5"), Style.WHITE));
STYLES.put("B227", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B228", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B229", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B230", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B236", new Style(Style.parseColor("#aa6500"), Style.WHITE));
STYLES.put("B238", new Style(Style.parseColor("#fbc684"), Style.BLACK));
STYLES.put("B243", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B244", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B245", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B246", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B247", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B248", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B249", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B251", new Style(Style.parseColor("#747b0e"), Style.WHITE));
STYLES.put("B252", new Style(Style.parseColor("#747b0e"), Style.WHITE));
STYLES.put("B253", new Style(Style.parseColor("#004a9a"), Style.WHITE));
STYLES.put("B254", new Style(Style.parseColor("#004a9a"), Style.WHITE));
STYLES.put("B257", new Style(Style.parseColor("#fbba00"), Style.BLACK));
STYLES.put("B261", new Style(Style.parseColor("#e56606"), Style.WHITE));
STYLES.put("B263", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B265", new Style(Style.parseColor("#c8007c"), Style.WHITE));
STYLES.put("B267", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B269", new Style(Style.parseColor("#cad400"), Style.BLACK));
STYLES.put("B273", new Style(Style.parseColor("#b5aba1"), Style.WHITE));
STYLES.put("B272", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B275", new Style(Style.parseColor("#aa6500"), Style.WHITE));
STYLES.put("B285", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B286", new Style(Style.parseColor("#b2b2b2"), Style.WHITE));
STYLES.put("B288", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B290", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B292", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B293", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B294", new Style(Style.parseColor("#8ac199"), Style.WHITE));
STYLES.put("B295", new Style(Style.parseColor("#bee4f6"), Style.BLACK));
STYLES.put("B297", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B300", new Style(Style.parseColor("#636466"), Style.WHITE));
STYLES.put("B301", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B302", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B303", new Style(Style.parseColor("#00704a"), Style.WHITE));
STYLES.put("BX03", new Style(Style.parseColor("#00704a"), Style.WHITE));
STYLES.put("B305", new Style(Style.parseColor("#abcc58"), Style.WHITE));
STYLES.put("B308", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B309", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BX09", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BL09", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B310", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BX10", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B311", new Style(Style.parseColor("#cab900"), Style.WHITE));
STYLES.put("B313", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B314", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B316", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B317", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B323", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B324", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("BL24", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("B325", new Style(Style.parseColor("#22317f"), Style.WHITE));
STYLES.put("B326", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B327", new Style(Style.parseColor("#d54b0b"), Style.WHITE));
STYLES.put("B333", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B339", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("BX39", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("BX40", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("B343", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B348", new Style(Style.parseColor("#007db1"), Style.WHITE));
STYLES.put("B352", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B353", new Style(Style.parseColor("#abcc58"), Style.WHITE));
STYLES.put("B355", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B360", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B361", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B370", new Style(Style.parseColor("#009ddc"), Style.WHITE));
STYLES.put("B372", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B373", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX73", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B374", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX74", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B376", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B377", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX77", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B378", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("B380", new Style(Style.parseColor("#0070ba"), Style.WHITE));
STYLES.put("B381", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B382", new Style(Style.parseColor("#f9b122"), Style.WHITE));
STYLES.put("B386", new Style(Style.parseColor("#943e01"), Style.WHITE));
STYLES.put("B387", new Style(Style.parseColor("#943e01"), Style.WHITE));
STYLES.put("B389", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("BX84", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("BX89", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("B391", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B392", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX92", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B393", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B394", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BL94", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX94", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B395", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B396", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX96", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B397", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX97", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B399", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX99", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B400", new Style(Style.parseColor("#eb4498"), Style.WHITE));
STYLES.put("B401", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#ec881d"), Style.WHITE));
STYLES.put("B407", new Style(Style.parseColor("#a8005b"), Style.WHITE));
STYLES.put("B408", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B410", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B412", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B413", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B415", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#8a5e3c"), Style.WHITE));
STYLES.put("B422", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B423", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B426", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B428", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("BL23", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B430", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B438", new Style(Style.parseColor("#2b3990"), Style.WHITE));
STYLES.put("B439", new Style(Style.parseColor("#2b3990"), Style.WHITE));
STYLES.put("B440", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B441", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B442", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B443", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B444", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B445", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B448", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B458", new Style(Style.parseColor("#0093d0"), Style.WHITE));
STYLES.put("B459", new Style(Style.parseColor("#0093d0"), Style.WHITE));
STYLES.put("B460", new Style(Style.parseColor("#ef4136"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#00aeef"), Style.WHITE));
STYLES.put("B462", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B463", new Style(Style.parseColor("#ec881d"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B466", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B470", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B473", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B476", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B477", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B478", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B479", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B480", new Style(Style.parseColor("#0054a6"), Style.WHITE));
STYLES.put("B483", new Style(Style.parseColor("#0054a6"), Style.WHITE));
STYLES.put("B487", new Style(Style.parseColor("#ec008c"), Style.WHITE));
STYLES.put("B490", new Style(Style.parseColor("#a54399"), Style.WHITE));
STYLES.put("B491", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("B492", new Style(Style.parseColor("#a54399"), Style.WHITE));
STYLES.put("B495", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B500", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BX00", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B501", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B502", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("B504", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("BX04", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("B505", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B506", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BX06", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B507", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B508", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B510", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B513", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B515", new Style(Style.parseColor("#8ab2df"), Style.WHITE));
STYLES.put("BX15", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B518", new Style(Style.parseColor("#8ab2df"), Style.WHITE));
STYLES.put("BX18", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B520", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B521", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B523", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B524", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B525", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("B526", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("BL37", new Style(Style.parseColor("#c95c30"), Style.WHITE));
STYLES.put("BL38", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("BL39", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B544", new Style(Style.parseColor("#b59d00"), Style.WHITE));
STYLES.put("B545", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B546", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B547", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("B549", new Style(Style.parseColor("#f28c00"), Style.WHITE));
STYLES.put("B550", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B551", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B552", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B555", new Style(Style.parseColor("#00b3f0"), Style.WHITE));
STYLES.put("B890", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B891", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B892", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B895", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("BL28", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("BM10", new Style(Style.parseColor("#e9559f"), Style.WHITE));
STYLES.put("BM20", new Style(Style.parseColor("#f7941e"), Style.WHITE));
STYLES.put("BM30", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("BM40", new Style(Style.parseColor("#ca220e"), Style.WHITE));
STYLES.put("BM41", new Style(Style.parseColor("#b2d33e"), Style.WHITE));
STYLES.put("BM50", new Style(Style.parseColor("#92278f"), Style.WHITE));
STYLES.put("BM52", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BM54", new Style(Style.parseColor("#0070ba"), Style.WHITE));
STYLES.put("BN", new Style(Style.parseColor("#051925"), Style.WHITE));
STYLES.put("B130", new Style(Style.parseColor("#878787"), Style.WHITE));
STYLES.put("B131", new Style(Style.parseColor("#bcbcbc"), Style.WHITE));
STYLES.put("B132", new Style(Style.parseColor("#f08cb5"), Style.WHITE));
STYLES.put("B135", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B136", new Style(Style.parseColor("#f18f00"), Style.WHITE));
STYLES.put("B137", new Style(Style.parseColor("#f18f00"), Style.WHITE));
STYLES.put("B139", new Style(Style.parseColor("#009fc8"), Style.WHITE));
STYLES.put("BL60", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B140", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B142", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B143", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B144", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE50", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B151", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B153", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B155", new Style(Style.parseColor("#1d1d1b"), Style.WHITE));
STYLES.put("B156", new Style(Style.parseColor("#1d1d1b"), Style.WHITE));
STYLES.put("B158", new Style(Style.parseColor("#a05c00"), Style.WHITE));
STYLES.put("B159", new Style(Style.parseColor("#a05c00"), Style.WHITE));
STYLES.put("BE65", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE66", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B168", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE68", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B169", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("BE69", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("BE70", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B171", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE71", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B173", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("B175", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B176", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE76", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE77", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B178", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE78", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BL78", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B179", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE79", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B180", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BL80", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B183", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE83", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B184", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL84", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE84", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B185", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL85", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE85", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE86", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B187", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL87", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE87", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B188", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL88", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE88", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE89", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B190", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL90", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B200", new Style(Style.parseColor("#c27ab1"), Style.WHITE));
STYLES.put("B201", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B202", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B203", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B205", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B206", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B207", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B208", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B209", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B225", new Style(Style.parseColor("#f08cb5"), Style.WHITE));
STYLES.put("B227", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B228", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B229", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B230", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B236", new Style(Style.parseColor("#aa6500"), Style.WHITE));
STYLES.put("B238", new Style(Style.parseColor("#fbc684"), Style.BLACK));
STYLES.put("B243", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B244", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B245", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B246", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B247", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B248", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B249", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B251", new Style(Style.parseColor("#747b0e"), Style.WHITE));
STYLES.put("B252", new Style(Style.parseColor("#747b0e"), Style.WHITE));
STYLES.put("B253", new Style(Style.parseColor("#004a9a"), Style.WHITE));
STYLES.put("B254", new Style(Style.parseColor("#004a9a"), Style.WHITE));
STYLES.put("B257", new Style(Style.parseColor("#fbba00"), Style.BLACK));
STYLES.put("B261", new Style(Style.parseColor("#e56606"), Style.WHITE));
STYLES.put("B263", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B265", new Style(Style.parseColor("#c8007c"), Style.WHITE));
STYLES.put("B267", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B269", new Style(Style.parseColor("#cad400"), Style.BLACK));
STYLES.put("B273", new Style(Style.parseColor("#b5aba1"), Style.WHITE));
STYLES.put("B272", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B275", new Style(Style.parseColor("#aa6500"), Style.WHITE));
STYLES.put("B285", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B286", new Style(Style.parseColor("#b2b2b2"), Style.WHITE));
STYLES.put("B288", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B290", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B292", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B293", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B294", new Style(Style.parseColor("#8ac199"), Style.WHITE));
STYLES.put("B295", new Style(Style.parseColor("#bee4f6"), Style.BLACK));
STYLES.put("B297", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B300", new Style(Style.parseColor("#636466"), Style.WHITE));
STYLES.put("B301", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B302", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B303", new Style(Style.parseColor("#00704a"), Style.WHITE));
STYLES.put("BX03", new Style(Style.parseColor("#00704a"), Style.WHITE));
STYLES.put("B305", new Style(Style.parseColor("#abcc58"), Style.WHITE));
STYLES.put("B308", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B309", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BX09", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BL09", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B310", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BX10", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B311", new Style(Style.parseColor("#cab900"), Style.WHITE));
STYLES.put("B313", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B314", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B316", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B317", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B323", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B324", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("BL24", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("B325", new Style(Style.parseColor("#22317f"), Style.WHITE));
STYLES.put("B326", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B327", new Style(Style.parseColor("#d54b0b"), Style.WHITE));
STYLES.put("B333", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B339", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("BX39", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("BX40", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("B343", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B348", new Style(Style.parseColor("#007db1"), Style.WHITE));
STYLES.put("B352", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B353", new Style(Style.parseColor("#abcc58"), Style.WHITE));
STYLES.put("B355", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B360", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B361", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B370", new Style(Style.parseColor("#009ddc"), Style.WHITE));
STYLES.put("B372", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B373", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX73", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B374", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX74", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B376", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B377", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX77", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B378", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("B380", new Style(Style.parseColor("#0070ba"), Style.WHITE));
STYLES.put("B381", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B382", new Style(Style.parseColor("#f9b122"), Style.WHITE));
STYLES.put("B386", new Style(Style.parseColor("#943e01"), Style.WHITE));
STYLES.put("B387", new Style(Style.parseColor("#943e01"), Style.WHITE));
STYLES.put("B389", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("BX84", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("BX89", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("B391", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B392", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX92", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B393", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B394", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BL94", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX94", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B395", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B396", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX96", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B397", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX97", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B399", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX99", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B400", new Style(Style.parseColor("#eb4498"), Style.WHITE));
STYLES.put("B401", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#ec881d"), Style.WHITE));
STYLES.put("B407", new Style(Style.parseColor("#a8005b"), Style.WHITE));
STYLES.put("B408", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B410", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B412", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B413", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B415", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#8a5e3c"), Style.WHITE));
STYLES.put("B422", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B423", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B426", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B428", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("BL23", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B430", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B438", new Style(Style.parseColor("#2b3990"), Style.WHITE));
STYLES.put("B439", new Style(Style.parseColor("#2b3990"), Style.WHITE));
STYLES.put("B440", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B441", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B442", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B443", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B444", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B445", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B448", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B458", new Style(Style.parseColor("#0093d0"), Style.WHITE));
STYLES.put("B459", new Style(Style.parseColor("#0093d0"), Style.WHITE));
STYLES.put("B460", new Style(Style.parseColor("#ef4136"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#00aeef"), Style.WHITE));
STYLES.put("B462", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B463", new Style(Style.parseColor("#ec881d"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B466", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B470", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B473", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B476", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B477", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B478", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B479", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B480", new Style(Style.parseColor("#0054a6"), Style.WHITE));
STYLES.put("B483", new Style(Style.parseColor("#0054a6"), Style.WHITE));
STYLES.put("B487", new Style(Style.parseColor("#ec008c"), Style.WHITE));
STYLES.put("B490", new Style(Style.parseColor("#a54399"), Style.WHITE));
STYLES.put("B491", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("B492", new Style(Style.parseColor("#a54399"), Style.WHITE));
STYLES.put("B495", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B500", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BX00", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B501", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B502", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("B504", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("BX04", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("B505", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B506", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BX06", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B507", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B508", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B510", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B513", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B515", new Style(Style.parseColor("#8ab2df"), Style.WHITE));
STYLES.put("BX15", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B518", new Style(Style.parseColor("#8ab2df"), Style.WHITE));
STYLES.put("BX18", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B520", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B521", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B523", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B524", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B525", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("B526", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("BL37", new Style(Style.parseColor("#c95c30"), Style.WHITE));
STYLES.put("BL38", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("BL39", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B544", new Style(Style.parseColor("#b59d00"), Style.WHITE));
STYLES.put("B545", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B546", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B547", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("B549", new Style(Style.parseColor("#f28c00"), Style.WHITE));
STYLES.put("B550", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B551", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B552", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B555", new Style(Style.parseColor("#00b3f0"), Style.WHITE));
STYLES.put("B890", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B891", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B892", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B895", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("BL28", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("BM10", new Style(Style.parseColor("#e9559f"), Style.WHITE));
STYLES.put("BM20", new Style(Style.parseColor("#f7941e"), Style.WHITE));
STYLES.put("BM30", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("BM40", new Style(Style.parseColor("#ca220e"), Style.WHITE));
STYLES.put("BM41", new Style(Style.parseColor("#b2d33e"), Style.WHITE));
STYLES.put("BM50", new Style(Style.parseColor("#92278f"), Style.WHITE));
STYLES.put("BM52", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BM54", new Style(Style.parseColor("#0070ba"), Style.WHITE));
STYLES.put("BN", new Style(Style.parseColor("#051925"), Style.WHITE));
STYLES.put("FF1", new Style(Style.parseColor("#0c754b"), Style.WHITE));
STYLES.put("FF2", new Style(Style.parseColor("#1e4230"), Style.WHITE));
STYLES.put("FF3", new Style(Style.parseColor("#8acf24"), Style.WHITE));
STYLES.put("FF4", new Style(Style.parseColor("#0b974a"), Style.WHITE));
STYLES.put("FF5", new Style(Style.parseColor("#2a5d3d"), Style.WHITE));
STYLES.put("FF6", new Style(Style.parseColor("#19ae4d"), Style.WHITE));
STYLES.put("FF7", new Style(Style.parseColor("#2bb683"), Style.WHITE));
}
STYLES.put("FF1", new Style(Style.parseColor("#0c754b"), Style.WHITE));
STYLES.put("FF2", new Style(Style.parseColor("#1e4230"), Style.WHITE));
STYLES.put("FF3", new Style(Style.parseColor("#8acf24"), Style.WHITE));
STYLES.put("FF4", new Style(Style.parseColor("#0b974a"), Style.WHITE));
STYLES.put("FF5", new Style(Style.parseColor("#2a5d3d"), Style.WHITE));
STYLES.put("FF6", new Style(Style.parseColor("#19ae4d"), Style.WHITE));
STYLES.put("FF7", new Style(Style.parseColor("#2bb683"), Style.WHITE));
}
}

View file

@ -27,41 +27,36 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class TfiProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://www.journeyplanner.transportforireland.ie/nta/";
public class TfiProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://www.journeyplanner.transportforireland.ie/nta/";
// http://www.journeyplanner.transportforireland.ie/ultraLite/
// http://www.journeyplanner.transportforireland.ie/ultraLite/
public TfiProvider()
{
super(NetworkId.TFI, API_BASE);
public TfiProvider() {
super(NetworkId.TFI, API_BASE);
setLanguage("en");
setTimeZone("Europe/London");
}
setLanguage("en");
setTimeZone("Europe/London");
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("DART".equals(name))
return new Line(id, network, Product.SUBURBAN_TRAIN, "DART");
if ("Rail".equals(trainName) && trainNum == null)
return new Line(id, network, null, "Rail");
if ("Train".equals(name) && "Train".equals(symbol))
return new Line(id, network, null, "Train");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("DART".equals(name))
return new Line(id, network, Product.SUBURBAN_TRAIN, "DART");
if ("Rail".equals(trainName) && trainNum == null)
return new Line(id, network, null, "Rail");
if ("Train".equals(name) && "Train".equals(symbol))
return new Line(id, network, null, "Train");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -32,85 +32,76 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class TlemProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://www.travelineeastmidlands.co.uk/em/";
public class TlemProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://www.travelineeastmidlands.co.uk/em/";
// http://www.travelineeastmidlands.co.uk/em/
// http://www.travelinesw.com/swe/
// http://www.travelinesoutheast.org.uk/se/
// http://www.travelineeastanglia.org.uk/ea/
// http://www.travelinemidlands.co.uk/wmtis/
// http://jp.networkwestmidlands.com/centro/
// http://www.travelineeastmidlands.co.uk/em/
// http://www.travelinesw.com/swe/
// http://www.travelinesoutheast.org.uk/se/
// http://www.travelineeastanglia.org.uk/ea/
// http://www.travelinemidlands.co.uk/wmtis/
// http://jp.networkwestmidlands.com/centro/
public TlemProvider()
{
super(NetworkId.TLEM, API_BASE);
public TlemProvider() {
super(NetworkId.TLEM, API_BASE);
setLanguage("en");
setTimeZone("Europe/London");
setUseProxFootSearch(false);
setStyles(STYLES);
}
setLanguage("en");
setTimeZone("Europe/London");
setUseProxFootSearch(false);
setStyles(STYLES);
}
@Override
protected String normalizeLocationName(final String name)
{
final String normalizedName = super.normalizeLocationName(name);
if (normalizedName != null && normalizedName.endsWith(" ()"))
return normalizedName.substring(0, normalizedName.length() - 3);
else
return normalizedName;
}
@Override
protected String normalizeLocationName(final String name) {
final String normalizedName = super.normalizeLocationName(name);
if (normalizedName != null && normalizedName.endsWith(" ()"))
return normalizedName.substring(0, normalizedName.length() - 3);
else
return normalizedName;
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("1".equals(mot))
{
if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName)))
return new Line(id, network, Product.SUBURBAN_TRAIN, "DLR");
}
else if ("13".equals(mot))
{
if ("OO".equals(trainType) || "Ordinary passenger (o.pas.)".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "OO" + Strings.nullToEmpty(trainNum));
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("1".equals(mot)) {
if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName)))
return new Line(id, network, Product.SUBURBAN_TRAIN, "DLR");
} else if ("13".equals(mot)) {
if ("OO".equals(trainType) || "Ordinary passenger (o.pas.)".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "OO" + Strings.nullToEmpty(trainNum));
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// London
STYLES.put("UBakerloo", new Style(Style.parseColor("#9D5324"), Style.WHITE));
STYLES.put("UCentral", new Style(Style.parseColor("#D52B1E"), Style.WHITE));
STYLES.put("UCircle", new Style(Style.parseColor("#FECB00"), Style.BLACK));
STYLES.put("UDistrict", new Style(Style.parseColor("#007934"), Style.WHITE));
STYLES.put("UEast London", new Style(Style.parseColor("#FFA100"), Style.WHITE));
STYLES.put("UHammersmith & City", new Style(Style.parseColor("#C5858F"), Style.BLACK));
STYLES.put("UJubilee", new Style(Style.parseColor("#818A8F"), Style.WHITE));
STYLES.put("UMetropolitan", new Style(Style.parseColor("#850057"), Style.WHITE));
STYLES.put("UNorthern", new Style(Style.BLACK, Style.WHITE));
STYLES.put("UPiccadilly", new Style(Style.parseColor("#0018A8"), Style.WHITE));
STYLES.put("UVictoria", new Style(Style.parseColor("#00A1DE"), Style.WHITE));
STYLES.put("UWaterloo & City", new Style(Style.parseColor("#76D2B6"), Style.BLACK));
static {
// London
STYLES.put("UBakerloo", new Style(Style.parseColor("#9D5324"), Style.WHITE));
STYLES.put("UCentral", new Style(Style.parseColor("#D52B1E"), Style.WHITE));
STYLES.put("UCircle", new Style(Style.parseColor("#FECB00"), Style.BLACK));
STYLES.put("UDistrict", new Style(Style.parseColor("#007934"), Style.WHITE));
STYLES.put("UEast London", new Style(Style.parseColor("#FFA100"), Style.WHITE));
STYLES.put("UHammersmith & City", new Style(Style.parseColor("#C5858F"), Style.BLACK));
STYLES.put("UJubilee", new Style(Style.parseColor("#818A8F"), Style.WHITE));
STYLES.put("UMetropolitan", new Style(Style.parseColor("#850057"), Style.WHITE));
STYLES.put("UNorthern", new Style(Style.BLACK, Style.WHITE));
STYLES.put("UPiccadilly", new Style(Style.parseColor("#0018A8"), Style.WHITE));
STYLES.put("UVictoria", new Style(Style.parseColor("#00A1DE"), Style.WHITE));
STYLES.put("UWaterloo & City", new Style(Style.parseColor("#76D2B6"), Style.BLACK));
STYLES.put("SDLR", new Style(Style.parseColor("#00B2A9"), Style.WHITE));
STYLES.put("SLO", new Style(Style.parseColor("#f46f1a"), Style.WHITE));
STYLES.put("SDLR", new Style(Style.parseColor("#00B2A9"), Style.WHITE));
STYLES.put("SLO", new Style(Style.parseColor("#f46f1a"), Style.WHITE));
STYLES.put("TTramlink 1", new Style(Style.rgb(193, 215, 46), Style.WHITE));
STYLES.put("TTramlink 2", new Style(Style.rgb(193, 215, 46), Style.WHITE));
STYLES.put("TTramlink 3", new Style(Style.rgb(124, 194, 66), Style.BLACK));
}
STYLES.put("TTramlink 1", new Style(Style.rgb(193, 215, 46), Style.WHITE));
STYLES.put("TTramlink 2", new Style(Style.rgb(193, 215, 46), Style.WHITE));
STYLES.put("TTramlink 3", new Style(Style.rgb(124, 194, 66), Style.BLACK));
}
}

View file

@ -30,46 +30,41 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class VagfrProvider extends AbstractEfaProvider
{
private final static String API_BASE = "https://efaserver.vag-freiburg.de/vagfr/";
public class VagfrProvider extends AbstractEfaProvider {
private final static String API_BASE = "https://efaserver.vag-freiburg.de/vagfr/";
public VagfrProvider()
{
super(NetworkId.VAGFR, API_BASE);
public VagfrProvider() {
super(NetworkId.VAGFR, API_BASE);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setSessionCookieName("EFABWLB");
}
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setSessionCookieName("EFABWLB");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if (("N".equals(trainType) || "Nahverkehrszug".equals(trainName)) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "N" + trainNum);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if (("N".equals(trainType) || "Nahverkehrszug".equals(trainName)) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "N" + trainNum);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// Tram
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#33b540"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#f79210"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#ef58a1"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#0994ce"), Style.WHITE));
static {
// Tram
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#33b540"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#f79210"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#ef58a1"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#0994ce"), Style.WHITE));
// Nachtbus
STYLES.put("N46", new Style(Style.parseColor("#28bda5"), Style.WHITE));
STYLES.put("N47", new Style(Style.parseColor("#d6de20"), Style.WHITE));
}
// Nachtbus
STYLES.put("N46", new Style(Style.parseColor("#28bda5"), Style.WHITE));
STYLES.put("N47", new Style(Style.parseColor("#d6de20"), Style.WHITE));
}
}

View file

@ -43,123 +43,112 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VaoProvider extends AbstractHafasProvider
{
private static final String API_BASE = "https://app.verkehrsauskunft.at/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, null, Product.TRAM,
Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY, Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN,
null, null, null };
public class VaoProvider extends AbstractHafasProvider {
private static final String API_BASE = "https://app.verkehrsauskunft.at/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
public VaoProvider(final String jsonApiAuthorization)
{
super(NetworkId.VAO, API_BASE, "dn", PRODUCTS_MAP);
public VaoProvider(final String jsonApiAuthorization) {
super(NetworkId.VAO, API_BASE, "dn", PRODUCTS_MAP);
setJsonApiVersion("1.11");
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
setJsonApiVersion("1.11");
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
private static final Pattern P_SPLIT_NAME_ONE_COMMA = Pattern.compile("([^,]*), ([^,]{3,64})");
private static final Pattern P_SPLIT_NAME_ONE_COMMA = Pattern.compile("([^,]*), ([^,]{3,64})");
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitPOI(poi);
}
return super.splitPOI(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitAddress(address);
}
return super.splitAddress(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException
{
return jsonLocMatch(constraint);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
return jsonLocMatch(constraint);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Salzburg S-Bahn
STYLES.put("Salzburg AG|SS1", new Style(Style.parseColor("#b61d33"), Style.WHITE));
STYLES.put("Salzburg AG|SS11", new Style(Style.parseColor("#b61d33"), Style.WHITE));
STYLES.put("OEBB|SS2", new Style(Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("OEBB|SS3", new Style(Style.parseColor("#0aa537"), Style.WHITE));
STYLES.put("BLB|SS4", new Style(Style.parseColor("#a862a4"), Style.WHITE));
static {
// Salzburg S-Bahn
STYLES.put("Salzburg AG|SS1", new Style(Style.parseColor("#b61d33"), Style.WHITE));
STYLES.put("Salzburg AG|SS11", new Style(Style.parseColor("#b61d33"), Style.WHITE));
STYLES.put("OEBB|SS2", new Style(Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("OEBB|SS3", new Style(Style.parseColor("#0aa537"), Style.WHITE));
STYLES.put("BLB|SS4", new Style(Style.parseColor("#a862a4"), Style.WHITE));
// Salzburg Bus
STYLES.put("Salzburg AG|B1", new Style(Style.parseColor("#e3000f"), Style.WHITE));
STYLES.put("Salzburg AG|B2", new Style(Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("Salzburg AG|B3", new Style(Style.parseColor("#956b27"), Style.WHITE));
STYLES.put("Salzburg AG|B4", new Style(Style.parseColor("#ffcc00"), Style.WHITE));
STYLES.put("Salzburg AG|B5", new Style(Style.parseColor("#04bbee"), Style.WHITE));
STYLES.put("Salzburg AG|B6", new Style(Style.parseColor("#85bc22"), Style.WHITE));
STYLES.put("Salzburg AG|B7", new Style(Style.parseColor("#009a9b"), Style.WHITE));
STYLES.put("Salzburg AG|B8", new Style(Style.parseColor("#f39100"), Style.WHITE));
STYLES.put("Salzburg AG|B10", new Style(Style.parseColor("#f8baa2"), Style.BLACK));
STYLES.put("Salzburg AG|B12", new Style(Style.parseColor("#b9dfde"), Style.WHITE));
STYLES.put("Salzburg AG|B14", new Style(Style.parseColor("#cfe09a"), Style.WHITE));
}
// Salzburg Bus
STYLES.put("Salzburg AG|B1", new Style(Style.parseColor("#e3000f"), Style.WHITE));
STYLES.put("Salzburg AG|B2", new Style(Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("Salzburg AG|B3", new Style(Style.parseColor("#956b27"), Style.WHITE));
STYLES.put("Salzburg AG|B4", new Style(Style.parseColor("#ffcc00"), Style.WHITE));
STYLES.put("Salzburg AG|B5", new Style(Style.parseColor("#04bbee"), Style.WHITE));
STYLES.put("Salzburg AG|B6", new Style(Style.parseColor("#85bc22"), Style.WHITE));
STYLES.put("Salzburg AG|B7", new Style(Style.parseColor("#009a9b"), Style.WHITE));
STYLES.put("Salzburg AG|B8", new Style(Style.parseColor("#f39100"), Style.WHITE));
STYLES.put("Salzburg AG|B10", new Style(Style.parseColor("#f8baa2"), Style.BLACK));
STYLES.put("Salzburg AG|B12", new Style(Style.parseColor("#b9dfde"), Style.WHITE));
STYLES.put("Salzburg AG|B14", new Style(Style.parseColor("#cfe09a"), Style.WHITE));
}
}

View file

@ -30,92 +30,84 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VbbProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://fahrinfo.vbb.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN };
private static final Set<Product> ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND = EnumSet
.complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND));
public class VbbProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://fahrinfo.vbb.de/bin/";
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS,
Product.FERRY, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN };
private static final Set<Product> ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND = EnumSet
.complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND));
public VbbProvider()
{
super(NetworkId.VBB, API_BASE, "dn", PRODUCTS_MAP);
public VbbProvider() {
super(NetworkId.VBB, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsUseWeight(false);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setClientType(null);
}
setJsonGetStopsUseWeight(false);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setClientType(null);
}
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?");
private static final Pattern P_SPLIT_NAME_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?");
private static final Pattern P_SPLIT_NAME_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
@Override
protected String[] splitStationName(String name)
{
final Matcher mSu = P_SPLIT_NAME_SU.matcher(name);
if (!mSu.matches())
throw new IllegalStateException(name);
name = mSu.group(1);
final String su = mSu.group(2);
@Override
protected String[] splitStationName(String name) {
final Matcher mSu = P_SPLIT_NAME_SU.matcher(name);
if (!mSu.matches())
throw new IllegalStateException(name);
name = mSu.group(1);
final String su = mSu.group(2);
final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name);
if (!mBus.matches())
throw new IllegalStateException(name);
name = mBus.group(1);
final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name);
if (!mBus.matches())
throw new IllegalStateException(name);
name = mBus.group(1);
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches())
return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) };
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches())
return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) };
final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (mComma.matches())
return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) };
final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (mComma.matches())
return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
private String normalizePlace(final String place)
{
if ("Bln".equals(place))
return "Berlin";
else
return place;
}
private String normalizePlace(final String place) {
if ("Bln".equals(place))
return "Berlin";
else
return place;
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public Set<Product> defaultProducts()
{
return ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND;
}
@Override
public Set<Product> defaultProducts() {
return ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND;
}
@Override
protected Line parseLineAndType(final String lineAndType)
{
if ("X#".equals(lineAndType))
return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
else
return super.parseLineAndType(lineAndType);
}
@Override
protected Line parseLineAndType(final String lineAndType) {
if ("X#".equals(lineAndType))
return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
else
return super.parseLineAndType(lineAndType);
}
}

View file

@ -25,74 +25,70 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VblProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://mobil.vbl.ch/vblmobil/";
public class VblProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://mobil.vbl.ch/vblmobil/";
public VblProvider()
{
super(NetworkId.VBL, API_BASE);
public VblProvider() {
super(NetworkId.VBL, API_BASE);
setUseRouteIndexAsTripId(false);
}
setUseRouteIndexAsTripId(false);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("BLS".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "BLS" + trainNum);
if ("ASM".equals(trainType) && trainNum != null) // Aare Seeland mobil
return new Line(id, network, Product.REGIONAL_TRAIN, "ASM" + trainNum);
if ("SOB".equals(trainType) && trainNum != null) // Schweizerische Südostbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "SOB" + trainNum);
if ("RhB".equals(trainType) && trainNum != null) // Rhätische Bahn
return new Line(id, network, Product.REGIONAL_TRAIN, "RhB" + trainNum);
if ("AB-".equals(trainType) && trainNum != null) // Appenzeller Bahnen
return new Line(id, network, Product.REGIONAL_TRAIN, "AB" + trainNum);
if ("BDW".equals(trainType) && trainNum != null) // BDWM Transport
return new Line(id, network, Product.REGIONAL_TRAIN, "BDW" + trainNum);
if ("ZB".equals(trainType) && trainNum != null) // Zentralbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "ZB" + trainNum);
if ("TPF".equals(trainType) && trainNum != null) // Transports publics fribourgeois
return new Line(id, network, Product.REGIONAL_TRAIN, "TPF" + trainNum);
if ("MGB".equals(trainType) && trainNum != null) // Matterhorn Gotthard Bahn
return new Line(id, network, Product.REGIONAL_TRAIN, "MGB" + trainNum);
if ("CJ".equals(trainType) && trainNum != null) // Chemins de fer du Jura
return new Line(id, network, Product.REGIONAL_TRAIN, "CJ" + trainNum);
if ("LEB".equals(trainType) && trainNum != null) // Lausanne-Echallens-Bercher
return new Line(id, network, Product.REGIONAL_TRAIN, "LEB" + trainNum);
if ("FAR".equals(trainType) && trainNum != null) // Ferrovie Autolinee Regionali Ticinesi
return new Line(id, network, Product.REGIONAL_TRAIN, "FAR" + trainNum);
if ("WAB".equals(trainType) && trainNum != null) // Wengernalpbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "WAB" + trainNum);
if ("JB".equals(trainType) && trainNum != null) // Jungfraubahn
return new Line(id, network, Product.REGIONAL_TRAIN, "JB" + trainNum);
if ("NSt".equals(trainType) && trainNum != null) // Nyon-St-Cergue-Morez
return new Line(id, network, Product.REGIONAL_TRAIN, "NSt" + trainNum);
if ("RA".equals(trainType) && trainNum != null) // Regionalps
return new Line(id, network, Product.REGIONAL_TRAIN, "RA" + trainNum);
if ("TRN".equals(trainType) && trainNum != null) // Transport Publics Neuchâtelois
return new Line(id, network, Product.REGIONAL_TRAIN, "TRN" + trainNum);
if ("TPC".equals(trainType) && trainNum != null) // Transports Publics du Chablais
return new Line(id, network, Product.REGIONAL_TRAIN, "TPC" + trainNum);
if ("MVR".equals(trainType) && trainNum != null) // Montreux-Vevey-Riviera
return new Line(id, network, Product.REGIONAL_TRAIN, "MVR" + trainNum);
if ("MOB".equals(trainType) && trainNum != null) // Montreux-Oberland Bernois
return new Line(id, network, Product.REGIONAL_TRAIN, "MOB" + trainNum);
if ("TRA".equals(trainType) && trainNum != null) // Transports Vallée de Joux-Yverdon-Ste-Croix
return new Line(id, network, Product.REGIONAL_TRAIN, "TRA" + trainNum);
if ("TMR".equals(trainType) && trainNum != null) // Transports de Martigny et Régions
return new Line(id, network, Product.REGIONAL_TRAIN, "TMR" + trainNum);
if ("GGB".equals(trainType) && trainNum != null) // Gornergratbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "GGB" + trainNum);
if ("BLM".equals(trainType) && trainNum != null) // Lauterbrunnen-Mürren
return new Line(id, network, Product.REGIONAL_TRAIN, "BLM" + trainNum);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("BLS".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "BLS" + trainNum);
if ("ASM".equals(trainType) && trainNum != null) // Aare Seeland mobil
return new Line(id, network, Product.REGIONAL_TRAIN, "ASM" + trainNum);
if ("SOB".equals(trainType) && trainNum != null) // Schweizerische Südostbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "SOB" + trainNum);
if ("RhB".equals(trainType) && trainNum != null) // Rhätische Bahn
return new Line(id, network, Product.REGIONAL_TRAIN, "RhB" + trainNum);
if ("AB-".equals(trainType) && trainNum != null) // Appenzeller Bahnen
return new Line(id, network, Product.REGIONAL_TRAIN, "AB" + trainNum);
if ("BDW".equals(trainType) && trainNum != null) // BDWM Transport
return new Line(id, network, Product.REGIONAL_TRAIN, "BDW" + trainNum);
if ("ZB".equals(trainType) && trainNum != null) // Zentralbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "ZB" + trainNum);
if ("TPF".equals(trainType) && trainNum != null) // Transports publics fribourgeois
return new Line(id, network, Product.REGIONAL_TRAIN, "TPF" + trainNum);
if ("MGB".equals(trainType) && trainNum != null) // Matterhorn Gotthard Bahn
return new Line(id, network, Product.REGIONAL_TRAIN, "MGB" + trainNum);
if ("CJ".equals(trainType) && trainNum != null) // Chemins de fer du Jura
return new Line(id, network, Product.REGIONAL_TRAIN, "CJ" + trainNum);
if ("LEB".equals(trainType) && trainNum != null) // Lausanne-Echallens-Bercher
return new Line(id, network, Product.REGIONAL_TRAIN, "LEB" + trainNum);
if ("FAR".equals(trainType) && trainNum != null) // Ferrovie Autolinee Regionali Ticinesi
return new Line(id, network, Product.REGIONAL_TRAIN, "FAR" + trainNum);
if ("WAB".equals(trainType) && trainNum != null) // Wengernalpbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "WAB" + trainNum);
if ("JB".equals(trainType) && trainNum != null) // Jungfraubahn
return new Line(id, network, Product.REGIONAL_TRAIN, "JB" + trainNum);
if ("NSt".equals(trainType) && trainNum != null) // Nyon-St-Cergue-Morez
return new Line(id, network, Product.REGIONAL_TRAIN, "NSt" + trainNum);
if ("RA".equals(trainType) && trainNum != null) // Regionalps
return new Line(id, network, Product.REGIONAL_TRAIN, "RA" + trainNum);
if ("TRN".equals(trainType) && trainNum != null) // Transport Publics Neuchâtelois
return new Line(id, network, Product.REGIONAL_TRAIN, "TRN" + trainNum);
if ("TPC".equals(trainType) && trainNum != null) // Transports Publics du Chablais
return new Line(id, network, Product.REGIONAL_TRAIN, "TPC" + trainNum);
if ("MVR".equals(trainType) && trainNum != null) // Montreux-Vevey-Riviera
return new Line(id, network, Product.REGIONAL_TRAIN, "MVR" + trainNum);
if ("MOB".equals(trainType) && trainNum != null) // Montreux-Oberland Bernois
return new Line(id, network, Product.REGIONAL_TRAIN, "MOB" + trainNum);
if ("TRA".equals(trainType) && trainNum != null) // Transports Vallée de Joux-Yverdon-Ste-Croix
return new Line(id, network, Product.REGIONAL_TRAIN, "TRA" + trainNum);
if ("TMR".equals(trainType) && trainNum != null) // Transports de Martigny et Régions
return new Line(id, network, Product.REGIONAL_TRAIN, "TMR" + trainNum);
if ("GGB".equals(trainType) && trainNum != null) // Gornergratbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "GGB" + trainNum);
if ("BLM".equals(trainType) && trainNum != null) // Lauterbrunnen-Mürren
return new Line(id, network, Product.REGIONAL_TRAIN, "BLM" + trainNum);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -43,224 +43,215 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VbnProvider extends AbstractHafasProvider
{
private static final String API_BASE = "https://fahrplaner.vbn.de/hafas/";
// http://fahrplaner.vsninfo.de/hafas/
// http://fahrplan.rsag-online.de/hafas/
// http://fahrplanauskunft.verkehrsverbund-warnow.de/bin/
public class VbnProvider extends AbstractHafasProvider {
private static final String API_BASE = "https://fahrplaner.vbn.de/hafas/";
// http://fahrplaner.vsninfo.de/hafas/
// http://fahrplan.rsag-online.de/hafas/
// http://fahrplanauskunft.verkehrsverbund-warnow.de/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public VbnProvider(final String jsonApiAuthorization)
{
super(NetworkId.VBN, API_BASE, "dn", PRODUCTS_MAP);
public VbnProvider(final String jsonApiAuthorization) {
super(NetworkId.VBN, API_BASE, "dn", PRODUCTS_MAP);
setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"VBN\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"VBN\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Osnabrück", "Göttingen", "Rostock", "Warnemünde" };
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Osnabrück", "Göttingen",
"Rostock", "Warnemünde" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
{
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
@Override
protected String[] splitStationName(final String name) {
for (final String place : PLACES) {
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitAddress(address);
}
return super.splitAddress(address);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public Set<Product> defaultProducts() {
return Product.ALL;
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException
{
return jsonLocMatch(constraint);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
return jsonLocMatch(constraint);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Rostock
STYLES.put("DB Regio AG|SS1", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("DB Regio AG|SS2", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("DB Regio AG|SS3", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
static {
// Rostock
STYLES.put("DB Regio AG|SS1", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("DB Regio AG|SS2", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("DB Regio AG|SS3", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T1", new Style(Shape.RECT, Style.parseColor("#712090"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T2", new Style(Shape.RECT, Style.parseColor("#f47216"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T3", new Style(Shape.RECT, Style.parseColor("#870e12"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T4", new Style(Shape.RECT, Style.parseColor("#d136a3"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T5", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T6", new Style(Shape.RECT, Style.parseColor("#fab20b"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T1", new Style(Shape.RECT, Style.parseColor("#712090"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T2", new Style(Shape.RECT, Style.parseColor("#f47216"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T3", new Style(Shape.RECT, Style.parseColor("#870e12"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T4", new Style(Shape.RECT, Style.parseColor("#d136a3"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T5", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T6", new Style(Shape.RECT, Style.parseColor("#fab20b"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B15", new Style(Style.parseColor("#008dc6"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B16", new Style(Style.parseColor("#1d3c85"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B17", new Style(Style.parseColor("#5784cc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B18", new Style(Style.parseColor("#0887c9"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B19", new Style(Style.parseColor("#166ab8"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 19A", new Style(Style.WHITE, Style.parseColor("#166ab8")));
STYLES.put("Rostocker Straßenbahn AG|PRFT 20A", new Style(Style.WHITE, Style.parseColor("#1959a6")));
STYLES.put("Rostocker Straßenbahn AG|B22", new Style(Style.parseColor("#3871c1"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B23", new Style(Style.parseColor("#173e7d"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B25", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B26", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B27", new Style(Style.parseColor("#6e87cd"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B28", new Style(Style.parseColor("#4fc6f4"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 30A", new Style(Style.WHITE, Style.parseColor("#1082ce")));
STYLES.put("Rostocker Straßenbahn AG|B31", new Style(Style.parseColor("#3a9fdf"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B34", new Style(Style.parseColor("#1c63b7"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B35", new Style(Style.parseColor("#1969bc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 35A", new Style(Style.WHITE, Style.parseColor("#1969bc")));
STYLES.put("Rostocker Straßenbahn AG|B36", new Style(Style.parseColor("#1c63b7"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B37", new Style(Style.parseColor("#36aee8"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B38", new Style(Style.parseColor("#6e87cd"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B39", new Style(Style.parseColor("#173e7d"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B45", new Style(Style.parseColor("#66cef5"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 45A", new Style(Style.WHITE, Style.parseColor("#66cef5")));
STYLES.put("Rostocker Straßenbahn AG|B49", new Style(Style.parseColor("#202267"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|BF1", new Style(Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT F1A", new Style(Style.WHITE, Style.parseColor("#231f20")));
STYLES.put("Rostocker Straßenbahn AG|BF2", new Style(Style.parseColor("#656263"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B15", new Style(Style.parseColor("#008dc6"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B16", new Style(Style.parseColor("#1d3c85"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B17", new Style(Style.parseColor("#5784cc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B18", new Style(Style.parseColor("#0887c9"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B19", new Style(Style.parseColor("#166ab8"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 19A", new Style(Style.WHITE, Style.parseColor("#166ab8")));
STYLES.put("Rostocker Straßenbahn AG|PRFT 20A", new Style(Style.WHITE, Style.parseColor("#1959a6")));
STYLES.put("Rostocker Straßenbahn AG|B22", new Style(Style.parseColor("#3871c1"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B23", new Style(Style.parseColor("#173e7d"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B25", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B26", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B27", new Style(Style.parseColor("#6e87cd"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B28", new Style(Style.parseColor("#4fc6f4"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 30A", new Style(Style.WHITE, Style.parseColor("#1082ce")));
STYLES.put("Rostocker Straßenbahn AG|B31", new Style(Style.parseColor("#3a9fdf"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B34", new Style(Style.parseColor("#1c63b7"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B35", new Style(Style.parseColor("#1969bc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 35A", new Style(Style.WHITE, Style.parseColor("#1969bc")));
STYLES.put("Rostocker Straßenbahn AG|B36", new Style(Style.parseColor("#1c63b7"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B37", new Style(Style.parseColor("#36aee8"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B38", new Style(Style.parseColor("#6e87cd"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B39", new Style(Style.parseColor("#173e7d"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B45", new Style(Style.parseColor("#66cef5"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 45A", new Style(Style.WHITE, Style.parseColor("#66cef5")));
STYLES.put("Rostocker Straßenbahn AG|B49", new Style(Style.parseColor("#202267"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|BF1", new Style(Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT F1A", new Style(Style.WHITE, Style.parseColor("#231f20")));
STYLES.put("Rostocker Straßenbahn AG|BF2", new Style(Style.parseColor("#656263"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B101", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B102", new Style(Style.parseColor("#2699d6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B103", new Style(Style.parseColor("#d18f00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B104", new Style(Style.parseColor("#006f9e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B105", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B106", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B107", new Style(Style.parseColor("#a62341"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B108", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B109", new Style(Style.parseColor("#aa7fa6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B110", new Style(Style.parseColor("#95c11f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B111", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B112", new Style(Style.parseColor("#e50069"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B113", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B114", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B115", new Style(Style.parseColor("#74b959"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B116", new Style(Style.parseColor("#0085ac"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B118", new Style(Style.parseColor("#f9b000"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B119", new Style(Style.parseColor("#055da9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B120", new Style(Style.parseColor("#74b959"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B121", new Style(Style.parseColor("#e63323"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B122", new Style(Style.parseColor("#009870"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B123", new Style(Style.parseColor("#f39200"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B124", new Style(Style.parseColor("#9dc41a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B125", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B127", new Style(Style.parseColor("#079897"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B128", new Style(Style.parseColor("#7263a9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B129", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B131", new Style(Style.parseColor("#0075bf"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B132", new Style(Style.parseColor("#ef7d00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B134", new Style(Style.parseColor("#008e5c"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B135", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B136", new Style(Style.parseColor("#aa7fa6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B137", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B138", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B139", new Style(Style.parseColor("#f8ac00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B140", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B200", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B201", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B203", new Style(Style.parseColor("#f59c00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B204", new Style(Style.parseColor("#b3cf3b"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B205", new Style(Style.parseColor("#dd6ca7"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B208", new Style(Style.parseColor("#9dc41a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B210", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B211", new Style(Style.parseColor("#95c11f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B213", new Style(Style.parseColor("#a877b2"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B215", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B216", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B220", new Style(Style.parseColor("#0090d7"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B221", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B222", new Style(Style.parseColor("#f088b6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B223", new Style(Style.parseColor("#f9b000"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B224", new Style(Style.parseColor("#004f9f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B225", new Style(Style.parseColor("#7263a9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B230", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B231", new Style(Style.parseColor("#00853e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B232", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B233", new Style(Style.parseColor("#123274"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B235", new Style(Style.parseColor("#ba0066"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B240", new Style(Style.parseColor("#7263a9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B241", new Style(Style.parseColor("#ea5297"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B244", new Style(Style.parseColor("#f7ab59"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B245", new Style(Style.parseColor("#76b82a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B246", new Style(Style.parseColor("#f39a8b"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B247", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B250", new Style(Style.parseColor("#009741"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B251", new Style(Style.parseColor("#033572"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B252", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B260", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B270", new Style(Style.parseColor("#fbbe5e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B271", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B272", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B273", new Style(Style.parseColor("#004899"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B280", new Style(Style.parseColor("#e41b18"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B281", new Style(Style.parseColor("#f9b000"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B282", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B283", new Style(Style.parseColor("#ec619f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B284", new Style(Style.parseColor("#951b81"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B285", new Style(Style.parseColor("#a42522"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B286", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B290", new Style(Style.parseColor("#312783"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B291", new Style(Style.parseColor("#a71680"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B292", new Style(Style.parseColor("#cabe46"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B101", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B102", new Style(Style.parseColor("#2699d6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B103", new Style(Style.parseColor("#d18f00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B104", new Style(Style.parseColor("#006f9e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B105", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B106", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B107", new Style(Style.parseColor("#a62341"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B108", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B109", new Style(Style.parseColor("#aa7fa6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B110", new Style(Style.parseColor("#95c11f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B111", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B112", new Style(Style.parseColor("#e50069"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B113", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B114", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B115", new Style(Style.parseColor("#74b959"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B116", new Style(Style.parseColor("#0085ac"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B118", new Style(Style.parseColor("#f9b000"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B119", new Style(Style.parseColor("#055da9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B120", new Style(Style.parseColor("#74b959"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B121", new Style(Style.parseColor("#e63323"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B122", new Style(Style.parseColor("#009870"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B123", new Style(Style.parseColor("#f39200"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B124", new Style(Style.parseColor("#9dc41a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B125", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B127", new Style(Style.parseColor("#079897"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B128", new Style(Style.parseColor("#7263a9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B129", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B131", new Style(Style.parseColor("#0075bf"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B132", new Style(Style.parseColor("#ef7d00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B134", new Style(Style.parseColor("#008e5c"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B135", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B136", new Style(Style.parseColor("#aa7fa6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B137", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B138", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B139", new Style(Style.parseColor("#f8ac00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B140", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B200", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B201", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B203", new Style(Style.parseColor("#f59c00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B204", new Style(Style.parseColor("#b3cf3b"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B205", new Style(Style.parseColor("#dd6ca7"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B208", new Style(Style.parseColor("#9dc41a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B210", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B211", new Style(Style.parseColor("#95c11f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B213", new Style(Style.parseColor("#a877b2"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B215", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B216", new Style(Style.parseColor("#935b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B220", new Style(Style.parseColor("#0090d7"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B221", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B222", new Style(Style.parseColor("#f088b6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B223", new Style(Style.parseColor("#f9b000"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B224", new Style(Style.parseColor("#004f9f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B225", new Style(Style.parseColor("#7263a9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B230", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B231", new Style(Style.parseColor("#00853e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B232", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B233", new Style(Style.parseColor("#123274"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B235", new Style(Style.parseColor("#ba0066"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B240", new Style(Style.parseColor("#7263a9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B241", new Style(Style.parseColor("#ea5297"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B244", new Style(Style.parseColor("#f7ab59"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B245", new Style(Style.parseColor("#76b82a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B246", new Style(Style.parseColor("#f39a8b"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B247", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B250", new Style(Style.parseColor("#009741"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B251", new Style(Style.parseColor("#033572"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B252", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B260", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B270", new Style(Style.parseColor("#fbbe5e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B271", new Style(Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B272", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B273", new Style(Style.parseColor("#004899"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B280", new Style(Style.parseColor("#e41b18"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B281", new Style(Style.parseColor("#f9b000"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B282", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B283", new Style(Style.parseColor("#ec619f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B284", new Style(Style.parseColor("#951b81"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B285", new Style(Style.parseColor("#a42522"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B286", new Style(Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B290", new Style(Style.parseColor("#312783"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B291", new Style(Style.parseColor("#a71680"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B292", new Style(Style.parseColor("#cabe46"), Style.WHITE));
STYLES.put("Rostocker Fähren|F", new Style(Shape.CIRCLE, Style.parseColor("#17a4da"), Style.WHITE));
}
STYLES.put("Rostocker Fähren|F", new Style(Shape.CIRCLE, Style.parseColor("#17a4da"), Style.WHITE));
}
}

View file

@ -30,40 +30,36 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VgnProvider extends AbstractEfaProvider
{
private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
public class VgnProvider extends AbstractEfaProvider {
private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
public VgnProvider(final String apiBase)
{
super(NetworkId.VGN, apiBase, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, null, null);
}
public VgnProvider(final String apiBase) {
super(NetworkId.VGN, apiBase, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, null, null);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("R5(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R5(z)");
if ("R7(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R7(z)");
if ("R8(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R8(z)");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("R5(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R5(z)");
if ("R7(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R7(z)");
if ("R8(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R8(z)");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date date,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
return super.xsltTripRequestParameters(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options)
+ "&itdLPxx_showTariffLevel=1";
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
return super.xsltTripRequestParameters(from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
options) + "&itdLPxx_showTariffLevel=1";
}
}

View file

@ -29,70 +29,59 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VgsProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://www.saarfahrplan.de/cgi-bin/"; // http://www.vgs-online.de/cgi-bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.CABLECAR, Product.ON_DEMAND,
Product.BUS };
public class VgsProvider extends AbstractHafasProvider {
private static final String API_BASE = "http://www.saarfahrplan.de/cgi-bin/"; // http://www.vgs-online.de/cgi-bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM,
Product.BUS, Product.CABLECAR, Product.ON_DEMAND, Product.BUS };
public VgsProvider()
{
super(NetworkId.VGS, API_BASE, "dn", PRODUCTS_MAP);
public VgsProvider() {
super(NetworkId.VGS, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardHasStationTable(false);
}
setStationBoardHasStationTable(false);
}
@Override
protected String[] splitStationName(final String name)
{
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
@Override
protected String[] splitStationName(final String name) {
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
{
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
} else if (location.type == LocationType.STATION && location.hasId()) {
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
return htmlNearbyStations(uri.toString());
} else {
throw new IllegalArgumentException("cannot handle: " + location);
}
}
}

View file

@ -30,57 +30,54 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VmsProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://www.vms.de/vms2/";
public class VmsProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://www.vms.de/vms2/";
public VmsProvider()
{
super(NetworkId.VMS, API_BASE);
public VmsProvider() {
super(NetworkId.VMS, API_BASE);
setUseLineRestriction(false);
}
setUseLineRestriction(false);
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(
super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed, accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
uri.append("&inclMOT_11=on");
uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on");
uri.append("&inclMOT_11=on");
uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on");
return uri.toString();
}
return uri.toString();
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("Ilztalbahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "ITB");
if ("Meridian".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "M");
if ("CityBahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "CB");
if ("CityBahn".equals(longName) && "C11".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Zug".equals(longName) && ("C11".equals(symbol) || "C13".equals(symbol) || "C14".equals(symbol) || "C15".equals(symbol)))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("Ilztalbahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "ITB");
if ("Meridian".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "M");
if ("CityBahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "CB");
if ("CityBahn".equals(longName) && "C11".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Zug".equals(longName)
&& ("C11".equals(symbol) || "C13".equals(symbol) || "C14".equals(symbol) || "C15".equals(symbol)))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("RE 3".equals(symbol) && "Zug".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "RE3");
}
if ("RE 3".equals(symbol) && "Zug".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "RE3");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -20,17 +20,15 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class VmvProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://80.146.180.107/vmv2/";
public class VmvProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://80.146.180.107/vmv2/";
// http://80.146.180.107/vmv/
// http://80.146.180.107/delfi/
// http://80.146.180.107/vmv/
// http://80.146.180.107/delfi/
public VmvProvider()
{
super(NetworkId.VMV, API_BASE);
public VmvProvider() {
super(NetworkId.VMV, API_BASE);
setUseRouteIndexAsTripId(false);
}
setUseRouteIndexAsTripId(false);
}
}

View file

@ -35,79 +35,70 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class VorProvider extends AbstractEfaProvider
{
private final static String API_BASE = "https://efa.vor.at/vor/";
public class VorProvider extends AbstractEfaProvider {
private final static String API_BASE = "https://efa.vor.at/vor/";
public VorProvider()
{
super(NetworkId.VOR, API_BASE);
public VorProvider() {
super(NetworkId.VOR, API_BASE);
setHttpReferer(API_BASE + DEFAULT_TRIP_ENDPOINT);
setHttpPost(true);
setIncludeRegionId(false);
setStyles(STYLES);
setRequestUrlEncoding(Charsets.UTF_8);
}
setHttpReferer(API_BASE + DEFAULT_TRIP_ENDPOINT);
setHttpPost(true);
setIncludeRegionId(false);
setStyles(STYLES);
setRequestUrlEncoding(Charsets.UTF_8);
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
if (products != null)
{
for (final Product p : products)
{
if (p == Product.BUS)
uri.append("&inclMOT_11=on"); // night bus
}
}
if (products != null) {
for (final Product p : products) {
if (p == Product.BUS)
uri.append("&inclMOT_11=on"); // night bus
}
}
return uri.toString();
}
return uri.toString();
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("WLB".equals(trainNum) && trainType == null)
return new Line(id, network, Product.TRAM, "WLB");
}
else if ("1".equals(mot))
{
if ("LILO".equals(symbol) && "Lokalbahn".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "LILO");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("WLB".equals(trainNum) && trainType == null)
return new Line(id, network, Product.TRAM, "WLB");
} else if ("1".equals(mot)) {
if ("LILO".equals(symbol) && "Lokalbahn".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "LILO");
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// Wien
STYLES.put("SS1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1e5cb3"), Style.WHITE));
STYLES.put("SS2", new Style(Style.Shape.ROUNDED, Style.parseColor("#59c594"), Style.WHITE));
STYLES.put("SS3", new Style(Style.Shape.ROUNDED, Style.parseColor("#c8154c"), Style.WHITE));
STYLES.put("SS7", new Style(Style.Shape.ROUNDED, Style.parseColor("#dc35a3"), Style.WHITE));
STYLES.put("SS40", new Style(Style.Shape.ROUNDED, Style.parseColor("#f24d3e"), Style.WHITE));
STYLES.put("SS45", new Style(Style.Shape.ROUNDED, Style.parseColor("#0f8572"), Style.WHITE));
STYLES.put("SS50", new Style(Style.Shape.ROUNDED, Style.parseColor("#34b6e5"), Style.WHITE));
STYLES.put("SS60", new Style(Style.Shape.ROUNDED, Style.parseColor("#82b429"), Style.WHITE));
STYLES.put("SS80", new Style(Style.Shape.ROUNDED, Style.parseColor("#e96619"), Style.WHITE));
static {
// Wien
STYLES.put("SS1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1e5cb3"), Style.WHITE));
STYLES.put("SS2", new Style(Style.Shape.ROUNDED, Style.parseColor("#59c594"), Style.WHITE));
STYLES.put("SS3", new Style(Style.Shape.ROUNDED, Style.parseColor("#c8154c"), Style.WHITE));
STYLES.put("SS7", new Style(Style.Shape.ROUNDED, Style.parseColor("#dc35a3"), Style.WHITE));
STYLES.put("SS40", new Style(Style.Shape.ROUNDED, Style.parseColor("#f24d3e"), Style.WHITE));
STYLES.put("SS45", new Style(Style.Shape.ROUNDED, Style.parseColor("#0f8572"), Style.WHITE));
STYLES.put("SS50", new Style(Style.Shape.ROUNDED, Style.parseColor("#34b6e5"), Style.WHITE));
STYLES.put("SS60", new Style(Style.Shape.ROUNDED, Style.parseColor("#82b429"), Style.WHITE));
STYLES.put("SS80", new Style(Style.Shape.ROUNDED, Style.parseColor("#e96619"), Style.WHITE));
STYLES.put("UU1", new Style(Style.Shape.RECT, Style.parseColor("#c6292a"), Style.WHITE));
STYLES.put("UU2", new Style(Style.Shape.RECT, Style.parseColor("#a82783"), Style.WHITE));
STYLES.put("UU3", new Style(Style.Shape.RECT, Style.parseColor("#f39315"), Style.WHITE));
STYLES.put("UU4", new Style(Style.Shape.RECT, Style.parseColor("#23a740"), Style.WHITE));
STYLES.put("UU6", new Style(Style.Shape.RECT, Style.parseColor("#be762c"), Style.WHITE));
}
STYLES.put("UU1", new Style(Style.Shape.RECT, Style.parseColor("#c6292a"), Style.WHITE));
STYLES.put("UU2", new Style(Style.Shape.RECT, Style.parseColor("#a82783"), Style.WHITE));
STYLES.put("UU3", new Style(Style.Shape.RECT, Style.parseColor("#f39315"), Style.WHITE));
STYLES.put("UU4", new Style(Style.Shape.RECT, Style.parseColor("#23a740"), Style.WHITE));
STYLES.put("UU6", new Style(Style.Shape.RECT, Style.parseColor("#be762c"), Style.WHITE));
}
}

View file

@ -32,382 +32,379 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class VrnProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://fahrplanauskunft.vrn.de/vrn/";
public class VrnProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://fahrplanauskunft.vrn.de/vrn/";
// http://fahrplanauskunft.vrn.de/vrn_mobile/
// http://efa9.vrn.de/vrt/
// http://fahrplanauskunft.vrn.de/vrn_mobile/
// http://efa9.vrn.de/vrt/
public VrnProvider()
{
super(NetworkId.VRN, API_BASE);
public VrnProvider() {
super(NetworkId.VRN, API_BASE);
setRequestUrlEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
setRequestUrlEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("InterRegio".equals(longName) && symbol == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("InterRegio".equals(longName) && symbol == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
}
if (name != null && name.startsWith("RNV Moonliner "))
return super.parseLine(id, network, mot, symbol, "M" + name.substring(14), longName, trainType, trainNum, trainName);
else if (name != null && (name.startsWith("RNV ") || name.startsWith("SWK ")))
return super.parseLine(id, network, mot, symbol, name.substring(4), longName, trainType, trainNum, trainName);
else
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
if (name != null && name.startsWith("RNV Moonliner "))
return super.parseLine(id, network, mot, symbol, "M" + name.substring(14), longName, trainType, trainNum,
trainName);
else if (name != null && (name.startsWith("RNV ") || name.startsWith("SWK ")))
return super.parseLine(id, network, mot, symbol, name.substring(4), longName, trainType, trainNum,
trainName);
else
return super.parseLine(id, network, 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
{
// Straßen- und Stadtbahn Mannheim-Ludwigshafen rnv
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#b00346"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#d6ad00"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T4X", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T4A", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE));
STYLES.put("T5A", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE));
STYLES.put("T5X", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#956c29"), Style.WHITE));
STYLES.put("T6A", new Style(Shape.RECT, Style.parseColor("#956c29"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#ffcc00"), Style.BLACK));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#e17600"), Style.WHITE));
STYLES.put("T9", new Style(Shape.RECT, Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("T10", new Style(Shape.RECT, Style.parseColor("#a71680"), Style.WHITE));
// STYLES.put("T15", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE));
STYLES.put("TX", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE));
static {
// Straßen- und Stadtbahn Mannheim-Ludwigshafen rnv
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#b00346"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#d6ad00"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T4X", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T4A", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE));
STYLES.put("T5A", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE));
STYLES.put("T5X", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#956c29"), Style.WHITE));
STYLES.put("T6A", new Style(Shape.RECT, Style.parseColor("#956c29"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#ffcc00"), Style.BLACK));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#e17600"), Style.WHITE));
STYLES.put("T9", new Style(Shape.RECT, Style.parseColor("#e6007e"), Style.WHITE));
STYLES.put("T10", new Style(Shape.RECT, Style.parseColor("#a71680"), Style.WHITE));
// STYLES.put("T15", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE));
STYLES.put("TX", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE));
// Busse Mannheim
STYLES.put("B2", new Style(Shape.CIRCLE, Style.parseColor("#b00346"), Style.WHITE));
STYLES.put("B4", new Style(Shape.CIRCLE, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("B5", new Style(Shape.CIRCLE, Style.parseColor("#00975f"), Style.BLACK));
STYLES.put("B7", new Style(Shape.CIRCLE, Style.parseColor("#ffcc00"), Style.BLACK));
STYLES.put("B40", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B41", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B42", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B43", new Style(Shape.CIRCLE, Style.parseColor("#589bd4"), Style.WHITE));
STYLES.put("B44", new Style(Shape.CIRCLE, Style.parseColor("#009a93"), Style.WHITE));
STYLES.put("B45", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B46", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B47", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B48", new Style(Shape.CIRCLE, Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B49", new Style(Shape.CIRCLE, Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B50", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B51", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B52", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B53", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B54", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B55", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B56", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B57", new Style(Shape.CIRCLE, Style.parseColor("#5bc5f2"), Style.WHITE));
STYLES.put("B57E", new Style(Shape.CIRCLE, Style.parseColor("#5bc5f2"), Style.WHITE));
STYLES.put("B58", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B59", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B60", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B61", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B62", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B63", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B64", new Style(Shape.CIRCLE, Style.parseColor("#0091a6"), Style.WHITE));
// Busse Mannheim
STYLES.put("B2", new Style(Shape.CIRCLE, Style.parseColor("#b00346"), Style.WHITE));
STYLES.put("B4", new Style(Shape.CIRCLE, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("B5", new Style(Shape.CIRCLE, Style.parseColor("#00975f"), Style.BLACK));
STYLES.put("B7", new Style(Shape.CIRCLE, Style.parseColor("#ffcc00"), Style.BLACK));
STYLES.put("B40", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B41", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B42", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B43", new Style(Shape.CIRCLE, Style.parseColor("#589bd4"), Style.WHITE));
STYLES.put("B44", new Style(Shape.CIRCLE, Style.parseColor("#009a93"), Style.WHITE));
STYLES.put("B45", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B46", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B47", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B48", new Style(Shape.CIRCLE, Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B49", new Style(Shape.CIRCLE, Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B50", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B51", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B52", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B53", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B54", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B55", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B56", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B57", new Style(Shape.CIRCLE, Style.parseColor("#5bc5f2"), Style.WHITE));
STYLES.put("B57E", new Style(Shape.CIRCLE, Style.parseColor("#5bc5f2"), Style.WHITE));
STYLES.put("B58", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B59", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B60", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B61", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B62", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B63", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B64", new Style(Shape.CIRCLE, Style.parseColor("#0091a6"), Style.WHITE));
// Stadtbus Ludwigshafen
STYLES.put("B70", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B71", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B72", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B73", new Style(Shape.CIRCLE, Style.parseColor("#8bc5bd"), Style.WHITE));
STYLES.put("B74", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B75", new Style(Shape.CIRCLE, Style.parseColor("#008f88"), Style.WHITE));
STYLES.put("B76", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B77", new Style(Shape.CIRCLE, Style.parseColor("#c290b8"), Style.WHITE));
STYLES.put("B78", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B79E", new Style(Shape.CIRCLE, Standard.COLOR_BACKGROUND_BUS, Style.WHITE));
STYLES.put("B84", new Style(Shape.CIRCLE, Style.parseColor("#8d2176"), Style.WHITE));
STYLES.put("B85", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B86", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B87", new Style(Shape.CIRCLE, Style.parseColor("#69598f"), Style.WHITE));
STYLES.put("B88", new Style(Shape.CIRCLE, Style.parseColor("#8bc5bd"), Style.WHITE));
// Stadtbus Ludwigshafen
STYLES.put("B70", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B71", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B72", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B73", new Style(Shape.CIRCLE, Style.parseColor("#8bc5bd"), Style.WHITE));
STYLES.put("B74", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B75", new Style(Shape.CIRCLE, Style.parseColor("#008f88"), Style.WHITE));
STYLES.put("B76", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B77", new Style(Shape.CIRCLE, Style.parseColor("#c290b8"), Style.WHITE));
STYLES.put("B78", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B79E", new Style(Shape.CIRCLE, Standard.COLOR_BACKGROUND_BUS, Style.WHITE));
STYLES.put("B84", new Style(Shape.CIRCLE, Style.parseColor("#8d2176"), Style.WHITE));
STYLES.put("B85", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B86", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B87", new Style(Shape.CIRCLE, Style.parseColor("#69598f"), Style.WHITE));
STYLES.put("B88", new Style(Shape.CIRCLE, Style.parseColor("#8bc5bd"), Style.WHITE));
// Nachtbus Ludwigshafen
STYLES.put("B90", new Style(Shape.CIRCLE, Style.parseColor("#86bc25"), Style.WHITE));
// STYLES.put("B91", new Style(Shape.CIRCLE, Style.parseColor("#898F93"), Style.WHITE));
STYLES.put("B94", new Style(Shape.CIRCLE, Style.parseColor("#83d0f5"), Style.WHITE));
STYLES.put("B96", new Style(Shape.CIRCLE, Style.parseColor("#c05d18"), Style.WHITE));
STYLES.put("B97", new Style(Shape.CIRCLE, Style.parseColor("#ffed00"), Style.BLACK));
// Nachtbus Ludwigshafen-Mannheim
STYLES.put("B6", new Style(Shape.CIRCLE, Style.parseColor("#956c29"), Style.WHITE));
// Nachtbus Ludwigshafen
STYLES.put("B90", new Style(Shape.CIRCLE, Style.parseColor("#86bc25"), Style.WHITE));
// STYLES.put("B91", new Style(Shape.CIRCLE, Style.parseColor("#898F93"), Style.WHITE));
STYLES.put("B94", new Style(Shape.CIRCLE, Style.parseColor("#83d0f5"), Style.WHITE));
STYLES.put("B96", new Style(Shape.CIRCLE, Style.parseColor("#c05d18"), Style.WHITE));
STYLES.put("B97", new Style(Shape.CIRCLE, Style.parseColor("#ffed00"), Style.BLACK));
// Nachtbus Ludwigshafen-Mannheim
STYLES.put("B6", new Style(Shape.CIRCLE, Style.parseColor("#956c29"), Style.WHITE));
// Straßenbahn Heidelberg
STYLES.put("T21", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T22", new Style(Shape.RECT, Style.parseColor("#fdc300"), Style.BLACK));
STYLES.put("T23", new Style(Shape.RECT, Style.parseColor("#e48f00"), Style.WHITE));
STYLES.put("T24", new Style(Shape.RECT, Style.parseColor("#8d2176"), Style.WHITE));
STYLES.put("T26", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE));
// Straßenbahn Heidelberg
STYLES.put("T21", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("T22", new Style(Shape.RECT, Style.parseColor("#fdc300"), Style.BLACK));
STYLES.put("T23", new Style(Shape.RECT, Style.parseColor("#e48f00"), Style.WHITE));
STYLES.put("T24", new Style(Shape.RECT, Style.parseColor("#8d2176"), Style.WHITE));
STYLES.put("T26", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE));
// Stadtbus Heidelberg rnv
STYLES.put("B27", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B28", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B29", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B30", new Style(Shape.CIRCLE, Style.parseColor("#baabd4"), Style.WHITE));
STYLES.put("B31", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B32", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B33", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B34", new Style(Shape.CIRCLE, Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B35", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B36", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B37", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B38", new Style(Shape.CIRCLE, Style.parseColor("#0097b5"), Style.WHITE));
STYLES.put("B39", new Style(Shape.CIRCLE, Style.parseColor("#512985"), Style.WHITE));
// Stadtbus Heidelberg rnv
STYLES.put("B27", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B28", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B29", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B30", new Style(Shape.CIRCLE, Style.parseColor("#baabd4"), Style.WHITE));
STYLES.put("B31", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE));
STYLES.put("B32", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B33", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B34", new Style(Shape.CIRCLE, Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B35", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B36", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B37", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B38", new Style(Shape.CIRCLE, Style.parseColor("#0097b5"), Style.WHITE));
STYLES.put("B39", new Style(Shape.CIRCLE, Style.parseColor("#512985"), Style.WHITE));
// Moonliner Heidelberg
STYLES.put("BM1", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM2", new Style(Style.parseColor("#F9A75E"), Style.parseColor("#0A3F88")));
STYLES.put("BM3", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM4", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM5", new Style(Style.parseColor("#FFF100"), Style.parseColor("#0A3F88")));
// Moonliner Heidelberg
STYLES.put("BM1", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM2", new Style(Style.parseColor("#F9A75E"), Style.parseColor("#0A3F88")));
STYLES.put("BM3", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM4", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM5", new Style(Style.parseColor("#FFF100"), Style.parseColor("#0A3F88")));
// Bus Rheinpfalz
STYLES.put("B484", new Style(Style.parseColor("#BE1E2E"), Style.WHITE));
STYLES.put("B570", new Style(Style.parseColor("#9B2590"), Style.WHITE));
STYLES.put("B571", new Style(Style.parseColor("#303192"), Style.WHITE));
STYLES.put("B572", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B574", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B580", new Style(Style.parseColor("#00A8E7"), Style.WHITE));
STYLES.put("B581", new Style(Style.parseColor("#F7941D"), Style.WHITE));
// Bus Rheinpfalz
STYLES.put("B484", new Style(Style.parseColor("#BE1E2E"), Style.WHITE));
STYLES.put("B570", new Style(Style.parseColor("#9B2590"), Style.WHITE));
STYLES.put("B571", new Style(Style.parseColor("#303192"), Style.WHITE));
STYLES.put("B572", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B574", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B580", new Style(Style.parseColor("#00A8E7"), Style.WHITE));
STYLES.put("B581", new Style(Style.parseColor("#F7941D"), Style.WHITE));
// S-Bahn Rhein-Neckar
STYLES.put("SS1", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#0077C0"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#4F2E92"), Style.WHITE));
STYLES.put("SS33", new Style(Style.parseColor("#4F2E92"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#00A651"), Style.BLACK));
STYLES.put("SS5", new Style(Style.parseColor("#F89735"), Style.WHITE));
STYLES.put("SS51", new Style(Style.parseColor("#F89735"), Style.WHITE));
// S-Bahn Rhein-Neckar
STYLES.put("SS1", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#0077C0"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#4F2E92"), Style.WHITE));
STYLES.put("SS33", new Style(Style.parseColor("#4F2E92"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#00A651"), Style.BLACK));
STYLES.put("SS5", new Style(Style.parseColor("#F89735"), Style.WHITE));
STYLES.put("SS51", new Style(Style.parseColor("#F89735"), Style.WHITE));
// Bus Bad Bergzabern
STYLES.put("B540", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B541", new Style(Style.parseColor("#C10625"), Style.WHITE));
STYLES.put("B543", new Style(Style.parseColor("#417B1C"), Style.WHITE));
STYLES.put("B544", new Style(Style.parseColor("#00527E"), Style.WHITE));
// Bus Bad Bergzabern
STYLES.put("B540", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B541", new Style(Style.parseColor("#C10625"), Style.WHITE));
STYLES.put("B543", new Style(Style.parseColor("#417B1C"), Style.WHITE));
STYLES.put("B544", new Style(Style.parseColor("#00527E"), Style.WHITE));
// Bus Grünstadt und Umgebung
STYLES.put("B451", new Style(Style.parseColor("#1AA94A"), Style.WHITE));
STYLES.put("B453", new Style(Style.parseColor("#F495BF"), Style.WHITE));
STYLES.put("B454", new Style(Style.parseColor("#60B7D4"), Style.WHITE));
STYLES.put("B455", new Style(Style.parseColor("#FECC2F"), Style.WHITE));
STYLES.put("B457", new Style(Style.parseColor("#AAA23D"), Style.WHITE));
STYLES.put("B458", new Style(Style.parseColor("#E54D6F"), Style.WHITE));
STYLES.put("B460", new Style(Style.parseColor("#9F0833"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#F68D31"), Style.WHITE));
// Bus Grünstadt und Umgebung
STYLES.put("B451", new Style(Style.parseColor("#1AA94A"), Style.WHITE));
STYLES.put("B453", new Style(Style.parseColor("#F495BF"), Style.WHITE));
STYLES.put("B454", new Style(Style.parseColor("#60B7D4"), Style.WHITE));
STYLES.put("B455", new Style(Style.parseColor("#FECC2F"), Style.WHITE));
STYLES.put("B457", new Style(Style.parseColor("#AAA23D"), Style.WHITE));
STYLES.put("B458", new Style(Style.parseColor("#E54D6F"), Style.WHITE));
STYLES.put("B460", new Style(Style.parseColor("#9F0833"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#F68D31"), Style.WHITE));
// Bus Sinsheim
STYLES.put("B741", new Style(Style.parseColor("#459959"), Style.WHITE));
STYLES.put("B761", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B762", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B763", new Style(Style.parseColor("#FFC20A"), Style.WHITE));
STYLES.put("B765", new Style(Style.parseColor("#066D6C"), Style.WHITE));
STYLES.put("B768", new Style(Style.parseColor("#0FAD99"), Style.WHITE));
STYLES.put("B782", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B795", new Style(Style.parseColor("#0056A7"), Style.WHITE));
STYLES.put("B796", new Style(Style.parseColor("#F47922"), Style.WHITE));
STYLES.put("B797", new Style(Style.parseColor("#A62653"), Style.WHITE));
// Bus Sinsheim
STYLES.put("B741", new Style(Style.parseColor("#459959"), Style.WHITE));
STYLES.put("B761", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B762", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B763", new Style(Style.parseColor("#FFC20A"), Style.WHITE));
STYLES.put("B765", new Style(Style.parseColor("#066D6C"), Style.WHITE));
STYLES.put("B768", new Style(Style.parseColor("#0FAD99"), Style.WHITE));
STYLES.put("B782", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B795", new Style(Style.parseColor("#0056A7"), Style.WHITE));
STYLES.put("B796", new Style(Style.parseColor("#F47922"), Style.WHITE));
STYLES.put("B797", new Style(Style.parseColor("#A62653"), Style.WHITE));
// Bus Wonnegau-Altrhein
STYLES.put("B427", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B435", new Style(Style.parseColor("#A3788C"), Style.WHITE));
STYLES.put("B660", new Style(Style.parseColor("#0FAD99"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#8169AF"), Style.WHITE));
STYLES.put("B663", new Style(Style.parseColor("#7FB6A4"), Style.WHITE));
STYLES.put("B921", new Style(Style.parseColor("#F7941D"), Style.WHITE));
STYLES.put("B437", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#BFB677"), Style.WHITE));
STYLES.put("B434", new Style(Style.parseColor("#A65631"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#CA5744"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#5D8AC6"), Style.WHITE));
STYLES.put("B432", new Style(Style.parseColor("#82A958"), Style.WHITE));
// Bus Wonnegau-Altrhein
STYLES.put("B427", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B435", new Style(Style.parseColor("#A3788C"), Style.WHITE));
STYLES.put("B660", new Style(Style.parseColor("#0FAD99"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#8169AF"), Style.WHITE));
STYLES.put("B663", new Style(Style.parseColor("#7FB6A4"), Style.WHITE));
STYLES.put("B921", new Style(Style.parseColor("#F7941D"), Style.WHITE));
STYLES.put("B437", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#BFB677"), Style.WHITE));
STYLES.put("B434", new Style(Style.parseColor("#A65631"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#CA5744"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#5D8AC6"), Style.WHITE));
STYLES.put("B432", new Style(Style.parseColor("#82A958"), Style.WHITE));
// Bus Odenwald-Mitte
STYLES.put("B667", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B684", new Style(Style.parseColor("#039CDB"), Style.WHITE));
STYLES.put("B687", new Style(Style.parseColor("#86D1D1"), Style.WHITE));
STYLES.put("B691", new Style(Style.parseColor("#BBAFD6"), Style.WHITE));
STYLES.put("B697", new Style(Style.parseColor("#002B5C"), Style.WHITE));
STYLES.put("B698", new Style(Style.parseColor("#AA568D"), Style.WHITE));
// Bus Odenwald-Mitte
STYLES.put("B667", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B684", new Style(Style.parseColor("#039CDB"), Style.WHITE));
STYLES.put("B687", new Style(Style.parseColor("#86D1D1"), Style.WHITE));
STYLES.put("B691", new Style(Style.parseColor("#BBAFD6"), Style.WHITE));
STYLES.put("B697", new Style(Style.parseColor("#002B5C"), Style.WHITE));
STYLES.put("B698", new Style(Style.parseColor("#AA568D"), Style.WHITE));
// Bus Saarbrücken und Umland
STYLES.put("B231", new Style(Style.parseColor("#94C11C"), Style.WHITE));
STYLES.put("B232", new Style(Style.parseColor("#A12785"), Style.WHITE));
STYLES.put("B233", new Style(Style.parseColor("#0098D8"), Style.WHITE));
STYLES.put("B234", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B235", new Style(Style.parseColor("#C10525"), Style.WHITE));
STYLES.put("B236", new Style(Style.parseColor("#104291"), Style.WHITE));
STYLES.put("B237", new Style(Style.parseColor("#23AD7A"), Style.WHITE));
STYLES.put("B238", new Style(Style.parseColor("#F39100"), Style.WHITE));
STYLES.put("B240", new Style(Style.parseColor("#E5007D"), Style.WHITE));
// Bus Saarbrücken und Umland
STYLES.put("B231", new Style(Style.parseColor("#94C11C"), Style.WHITE));
STYLES.put("B232", new Style(Style.parseColor("#A12785"), Style.WHITE));
STYLES.put("B233", new Style(Style.parseColor("#0098D8"), Style.WHITE));
STYLES.put("B234", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B235", new Style(Style.parseColor("#C10525"), Style.WHITE));
STYLES.put("B236", new Style(Style.parseColor("#104291"), Style.WHITE));
STYLES.put("B237", new Style(Style.parseColor("#23AD7A"), Style.WHITE));
STYLES.put("B238", new Style(Style.parseColor("#F39100"), Style.WHITE));
STYLES.put("B240", new Style(Style.parseColor("#E5007D"), Style.WHITE));
// Bus Neckargemünd
STYLES.put("B735", new Style(Style.parseColor("#F47922"), Style.WHITE));
STYLES.put("B743", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B752", new Style(Style.parseColor("#0D7253"), Style.WHITE));
STYLES.put("B753", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B754", new Style(Style.parseColor("#F99D1D"), Style.WHITE));
STYLES.put("B817", new Style(Style.parseColor("#0080A6"), Style.WHITE));
// Bus Neckargemünd
STYLES.put("B735", new Style(Style.parseColor("#F47922"), Style.WHITE));
STYLES.put("B743", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B752", new Style(Style.parseColor("#0D7253"), Style.WHITE));
STYLES.put("B753", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B754", new Style(Style.parseColor("#F99D1D"), Style.WHITE));
STYLES.put("B817", new Style(Style.parseColor("#0080A6"), Style.WHITE));
// Bus Ladenburg
STYLES.put("B625", new Style(Style.parseColor("#006F45"), Style.WHITE));
STYLES.put("B626", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B627", new Style(Style.parseColor("#A62653"), Style.WHITE));
STYLES.put("B628", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B629", new Style(Style.parseColor("#008B9E"), Style.WHITE));
// Bus Ladenburg
STYLES.put("B625", new Style(Style.parseColor("#006F45"), Style.WHITE));
STYLES.put("B626", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B627", new Style(Style.parseColor("#A62653"), Style.WHITE));
STYLES.put("B628", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B629", new Style(Style.parseColor("#008B9E"), Style.WHITE));
// Bus Worms
STYLES.put("B407", new Style(Style.parseColor("#F58581"), Style.WHITE));
STYLES.put("B402", new Style(Style.parseColor("#078F47"), Style.WHITE));
STYLES.put("B410", new Style(Style.parseColor("#9D368F"), Style.WHITE));
STYLES.put("B408", new Style(Style.parseColor("#A79A39"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE));
STYLES.put("B4906", new Style(Style.parseColor("#BEBEC1"), Style.WHITE));
STYLES.put("B4905", new Style(Style.parseColor("#BEBEC1"), Style.WHITE));
STYLES.put("B409", new Style(Style.parseColor("#8691B3"), Style.WHITE));
// Bus Worms
STYLES.put("B407", new Style(Style.parseColor("#F58581"), Style.WHITE));
STYLES.put("B402", new Style(Style.parseColor("#078F47"), Style.WHITE));
STYLES.put("B410", new Style(Style.parseColor("#9D368F"), Style.WHITE));
STYLES.put("B408", new Style(Style.parseColor("#A79A39"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE));
STYLES.put("B4906", new Style(Style.parseColor("#BEBEC1"), Style.WHITE));
STYLES.put("B4905", new Style(Style.parseColor("#BEBEC1"), Style.WHITE));
STYLES.put("B409", new Style(Style.parseColor("#8691B3"), Style.WHITE));
// Bus Kaiserslautern
STYLES.put("B101", new Style(Style.parseColor("#F36F23"), Style.WHITE));
STYLES.put("B102", new Style(Style.parseColor("#B64A9B"), Style.WHITE));
STYLES.put("B103", new Style(Style.parseColor("#FFF100"), Style.BLACK));
STYLES.put("B104", new Style(Style.parseColor("#71BF44"), Style.WHITE));
STYLES.put("B105", new Style(Style.parseColor("#007F3E"), Style.WHITE));
STYLES.put("B106", new Style(Style.parseColor("#FBA61C"), Style.BLACK));
STYLES.put("B107", new Style(Style.parseColor("#A05A35"), Style.WHITE));
STYLES.put("B108", new Style(Style.parseColor("#A05A35"), Style.BLACK));
STYLES.put("B111", new Style(Style.parseColor("#0B4EA2"), Style.WHITE));
STYLES.put("B112", new Style(Style.parseColor("#00A5E3"), Style.WHITE));
STYLES.put("B114", new Style(Style.parseColor("#E10086"), Style.WHITE));
STYLES.put("B115", new Style(Style.parseColor("#E71B24"), Style.WHITE));
STYLES.put("B117", new Style(Style.parseColor("#E71B24"), Style.WHITE));
// Bus Kaiserslautern
STYLES.put("B101", new Style(Style.parseColor("#F36F23"), Style.WHITE));
STYLES.put("B102", new Style(Style.parseColor("#B64A9B"), Style.WHITE));
STYLES.put("B103", new Style(Style.parseColor("#FFF100"), Style.BLACK));
STYLES.put("B104", new Style(Style.parseColor("#71BF44"), Style.WHITE));
STYLES.put("B105", new Style(Style.parseColor("#007F3E"), Style.WHITE));
STYLES.put("B106", new Style(Style.parseColor("#FBA61C"), Style.BLACK));
STYLES.put("B107", new Style(Style.parseColor("#A05A35"), Style.WHITE));
STYLES.put("B108", new Style(Style.parseColor("#A05A35"), Style.BLACK));
STYLES.put("B111", new Style(Style.parseColor("#0B4EA2"), Style.WHITE));
STYLES.put("B112", new Style(Style.parseColor("#00A5E3"), Style.WHITE));
STYLES.put("B114", new Style(Style.parseColor("#E10086"), Style.WHITE));
STYLES.put("B115", new Style(Style.parseColor("#E71B24"), Style.WHITE));
STYLES.put("B117", new Style(Style.parseColor("#E71B24"), Style.WHITE));
// Bus Weinheim
STYLES.put("B631", new Style(Style.parseColor("#949599"), Style.WHITE));
STYLES.put("B632", new Style(Style.parseColor("#003D72"), Style.WHITE));
STYLES.put("B632A", new Style(Style.parseColor("#0083C2"), Style.WHITE));
STYLES.put("B633", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B634", new Style(Style.parseColor("#F58221"), Style.WHITE));
STYLES.put("B681", new Style(Style.parseColor("#00B7BD"), Style.WHITE));
STYLES.put("B682", new Style(Style.parseColor("#D1AC75"), Style.WHITE));
STYLES.put("B688", new Style(Style.parseColor("#72BAAF"), Style.WHITE));
// Bus Weinheim
STYLES.put("B631", new Style(Style.parseColor("#949599"), Style.WHITE));
STYLES.put("B632", new Style(Style.parseColor("#003D72"), Style.WHITE));
STYLES.put("B632A", new Style(Style.parseColor("#0083C2"), Style.WHITE));
STYLES.put("B633", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B634", new Style(Style.parseColor("#F58221"), Style.WHITE));
STYLES.put("B681", new Style(Style.parseColor("#00B7BD"), Style.WHITE));
STYLES.put("B682", new Style(Style.parseColor("#D1AC75"), Style.WHITE));
STYLES.put("B688", new Style(Style.parseColor("#72BAAF"), Style.WHITE));
// Bus Schwetzingen-Hockenheim und Umgebung
STYLES.put("B710", new Style(Style.parseColor("#C10625"), Style.WHITE));
STYLES.put("B711", new Style(Style.parseColor("#417B1C"), Style.WHITE));
STYLES.put("B712", new Style(Style.parseColor("#A12486"), Style.WHITE));
STYLES.put("B713", new Style(Style.parseColor("#0398D8"), Style.WHITE));
STYLES.put("B715", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B716", new Style(Style.parseColor("#93C11C"), Style.WHITE));
STYLES.put("B717", new Style(Style.parseColor("#004F7A"), Style.WHITE));
STYLES.put("B718", new Style(Style.parseColor("#EE7221"), Style.WHITE));
STYLES.put("B732", new Style(Style.parseColor("#008692"), Style.WHITE));
STYLES.put("B738", new Style(Style.parseColor("#9C9D9D"), Style.WHITE));
STYLES.put("B128", new Style(Style.parseColor("#9C9D9D"), Style.WHITE));
// Bus Schwetzingen-Hockenheim und Umgebung
STYLES.put("B710", new Style(Style.parseColor("#C10625"), Style.WHITE));
STYLES.put("B711", new Style(Style.parseColor("#417B1C"), Style.WHITE));
STYLES.put("B712", new Style(Style.parseColor("#A12486"), Style.WHITE));
STYLES.put("B713", new Style(Style.parseColor("#0398D8"), Style.WHITE));
STYLES.put("B715", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B716", new Style(Style.parseColor("#93C11C"), Style.WHITE));
STYLES.put("B717", new Style(Style.parseColor("#004F7A"), Style.WHITE));
STYLES.put("B718", new Style(Style.parseColor("#EE7221"), Style.WHITE));
STYLES.put("B732", new Style(Style.parseColor("#008692"), Style.WHITE));
STYLES.put("B738", new Style(Style.parseColor("#9C9D9D"), Style.WHITE));
STYLES.put("B128", new Style(Style.parseColor("#9C9D9D"), Style.WHITE));
// Bus Odenwald-Süd
STYLES.put("B686", new Style(Style.parseColor("#E2001A"), Style.WHITE));
STYLES.put("B683", new Style(Style.parseColor("#C74E1B"), Style.WHITE));
STYLES.put("B692", new Style(Style.parseColor("#F7A800"), Style.WHITE));
STYLES.put("B685", new Style(Style.parseColor("#B1C903"), Style.WHITE));
STYLES.put("B688", new Style(Style.parseColor("#54C3EC"), Style.WHITE));
// Bus Odenwald-Süd
STYLES.put("B686", new Style(Style.parseColor("#E2001A"), Style.WHITE));
STYLES.put("B683", new Style(Style.parseColor("#C74E1B"), Style.WHITE));
STYLES.put("B692", new Style(Style.parseColor("#F7A800"), Style.WHITE));
STYLES.put("B685", new Style(Style.parseColor("#B1C903"), Style.WHITE));
STYLES.put("B688", new Style(Style.parseColor("#54C3EC"), Style.WHITE));
// Bus Neustadt/Wstr. und Umgebung
STYLES.put("B500", new Style(Style.parseColor("#459959"), Style.WHITE));
STYLES.put("B501", new Style(Style.parseColor("#F57F22"), Style.WHITE));
STYLES.put("B503", new Style(Style.parseColor("#0058A9"), Style.WHITE));
STYLES.put("B504", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B505", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B506", new Style(Style.parseColor("#FFC21C"), Style.WHITE));
STYLES.put("B507", new Style(Style.parseColor("#A62653"), Style.WHITE));
STYLES.put("B508", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B509", new Style(Style.parseColor("#F03F23"), Style.WHITE));
STYLES.put("B510", new Style(Style.parseColor("#E7ACC6"), Style.WHITE));
STYLES.put("B512", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B517", new Style(Style.parseColor("#066D6C"), Style.WHITE));
// Bus Neustadt/Wstr. und Umgebung
STYLES.put("B500", new Style(Style.parseColor("#459959"), Style.WHITE));
STYLES.put("B501", new Style(Style.parseColor("#F57F22"), Style.WHITE));
STYLES.put("B503", new Style(Style.parseColor("#0058A9"), Style.WHITE));
STYLES.put("B504", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B505", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B506", new Style(Style.parseColor("#FFC21C"), Style.WHITE));
STYLES.put("B507", new Style(Style.parseColor("#A62653"), Style.WHITE));
STYLES.put("B508", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B509", new Style(Style.parseColor("#F03F23"), Style.WHITE));
STYLES.put("B510", new Style(Style.parseColor("#E7ACC6"), Style.WHITE));
STYLES.put("B512", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B517", new Style(Style.parseColor("#066D6C"), Style.WHITE));
// Bus Neckar-Odenwald-Kreis
STYLES.put("B821", new Style(Style.parseColor("#263791"), Style.WHITE));
STYLES.put("B822", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B823", new Style(Style.parseColor("#056736"), Style.WHITE));
STYLES.put("B824", new Style(Style.parseColor("#9A8174"), Style.WHITE));
STYLES.put("B828", new Style(Style.parseColor("#9A8174"), Style.WHITE));
STYLES.put("B832", new Style(Style.parseColor("#F7941D"), Style.WHITE));
STYLES.put("B833", new Style(Style.parseColor("#C1B404"), Style.WHITE));
STYLES.put("B834", new Style(Style.parseColor("#90C73E"), Style.WHITE));
STYLES.put("B835", new Style(Style.parseColor("#662D91"), Style.WHITE));
STYLES.put("B836", new Style(Style.parseColor("#EE2026"), Style.WHITE));
STYLES.put("B837", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B838", new Style(Style.parseColor("#8B711B"), Style.WHITE));
STYLES.put("B839", new Style(Style.parseColor("#662D91"), Style.WHITE));
STYLES.put("B841", new Style(Style.parseColor("#C0B296"), Style.WHITE));
STYLES.put("B843", new Style(Style.parseColor("#DBE122"), Style.WHITE));
STYLES.put("B844", new Style(Style.parseColor("#93B366"), Style.WHITE));
STYLES.put("B849", new Style(Style.parseColor("#E19584"), Style.WHITE));
STYLES.put("B857", new Style(Style.parseColor("#C01B2A"), Style.WHITE));
STYLES.put("B857", new Style(Style.parseColor("#D2B10C"), Style.WHITE));
// Bus Neckar-Odenwald-Kreis
STYLES.put("B821", new Style(Style.parseColor("#263791"), Style.WHITE));
STYLES.put("B822", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B823", new Style(Style.parseColor("#056736"), Style.WHITE));
STYLES.put("B824", new Style(Style.parseColor("#9A8174"), Style.WHITE));
STYLES.put("B828", new Style(Style.parseColor("#9A8174"), Style.WHITE));
STYLES.put("B832", new Style(Style.parseColor("#F7941D"), Style.WHITE));
STYLES.put("B833", new Style(Style.parseColor("#C1B404"), Style.WHITE));
STYLES.put("B834", new Style(Style.parseColor("#90C73E"), Style.WHITE));
STYLES.put("B835", new Style(Style.parseColor("#662D91"), Style.WHITE));
STYLES.put("B836", new Style(Style.parseColor("#EE2026"), Style.WHITE));
STYLES.put("B837", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B838", new Style(Style.parseColor("#8B711B"), Style.WHITE));
STYLES.put("B839", new Style(Style.parseColor("#662D91"), Style.WHITE));
STYLES.put("B841", new Style(Style.parseColor("#C0B296"), Style.WHITE));
STYLES.put("B843", new Style(Style.parseColor("#DBE122"), Style.WHITE));
STYLES.put("B844", new Style(Style.parseColor("#93B366"), Style.WHITE));
STYLES.put("B849", new Style(Style.parseColor("#E19584"), Style.WHITE));
STYLES.put("B857", new Style(Style.parseColor("#C01B2A"), Style.WHITE));
STYLES.put("B857", new Style(Style.parseColor("#D2B10C"), Style.WHITE));
// Bus Landkreis Germersheim
STYLES.put("B550", new Style(Style.parseColor("#870B36"), Style.WHITE));
STYLES.put("B552", new Style(Style.parseColor("#96387C"), Style.WHITE));
STYLES.put("B554", new Style(Style.parseColor("#EE542E"), Style.WHITE));
STYLES.put("B555", new Style(Style.parseColor("#EC2E6B"), Style.WHITE));
STYLES.put("B556", new Style(Style.parseColor("#D7DF21"), Style.WHITE));
STYLES.put("B557", new Style(Style.parseColor("#BD7BB4"), Style.WHITE));
STYLES.put("B558", new Style(Style.parseColor("#ED5956"), Style.WHITE));
STYLES.put("B559", new Style(Style.parseColor("#EE4F5E"), Style.WHITE));
STYLES.put("B595", new Style(Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("B596", new Style(Style.parseColor("#73479C"), Style.WHITE));
STYLES.put("B546", new Style(Style.parseColor("#E81D34"), Style.WHITE));
STYLES.put("B547", new Style(Style.parseColor("#991111"), Style.WHITE));
STYLES.put("B548", new Style(Style.parseColor("#974E04"), Style.WHITE));
STYLES.put("B549", new Style(Style.parseColor("#F7A5AD"), Style.WHITE));
STYLES.put("B593", new Style(Style.parseColor("#D1B0A3"), Style.WHITE));
STYLES.put("B594", new Style(Style.parseColor("#FAA86F"), Style.WHITE));
STYLES.put("B598", new Style(Style.parseColor("#71BF44"), Style.WHITE));
STYLES.put("B590", new Style(Style.parseColor("#C50A54"), Style.WHITE));
STYLES.put("B592", new Style(Style.parseColor("#00B6BD"), Style.WHITE));
STYLES.put("B599", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
// Bus Landkreis Germersheim
STYLES.put("B550", new Style(Style.parseColor("#870B36"), Style.WHITE));
STYLES.put("B552", new Style(Style.parseColor("#96387C"), Style.WHITE));
STYLES.put("B554", new Style(Style.parseColor("#EE542E"), Style.WHITE));
STYLES.put("B555", new Style(Style.parseColor("#EC2E6B"), Style.WHITE));
STYLES.put("B556", new Style(Style.parseColor("#D7DF21"), Style.WHITE));
STYLES.put("B557", new Style(Style.parseColor("#BD7BB4"), Style.WHITE));
STYLES.put("B558", new Style(Style.parseColor("#ED5956"), Style.WHITE));
STYLES.put("B559", new Style(Style.parseColor("#EE4F5E"), Style.WHITE));
STYLES.put("B595", new Style(Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("B596", new Style(Style.parseColor("#73479C"), Style.WHITE));
STYLES.put("B546", new Style(Style.parseColor("#E81D34"), Style.WHITE));
STYLES.put("B547", new Style(Style.parseColor("#991111"), Style.WHITE));
STYLES.put("B548", new Style(Style.parseColor("#974E04"), Style.WHITE));
STYLES.put("B549", new Style(Style.parseColor("#F7A5AD"), Style.WHITE));
STYLES.put("B593", new Style(Style.parseColor("#D1B0A3"), Style.WHITE));
STYLES.put("B594", new Style(Style.parseColor("#FAA86F"), Style.WHITE));
STYLES.put("B598", new Style(Style.parseColor("#71BF44"), Style.WHITE));
STYLES.put("B590", new Style(Style.parseColor("#C50A54"), Style.WHITE));
STYLES.put("B592", new Style(Style.parseColor("#00B6BD"), Style.WHITE));
STYLES.put("B599", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
// Bus Südliche Weinstraße
STYLES.put("B525", new Style(Style.parseColor("#009EE0"), Style.WHITE));
STYLES.put("B523", new Style(Style.parseColor("#F4A10B"), Style.WHITE));
STYLES.put("B524", new Style(Style.parseColor("#FFEC00"), Style.BLACK));
STYLES.put("B531", new Style(Style.parseColor("#2DA84D"), Style.WHITE));
STYLES.put("B532", new Style(Style.parseColor("#00FD00"), Style.BLACK));
STYLES.put("B520", new Style(Style.parseColor("#FF3333"), Style.WHITE));
STYLES.put("B530", new Style(Style.parseColor("#E84A93"), Style.WHITE));
// Bus Südliche Weinstraße
STYLES.put("B525", new Style(Style.parseColor("#009EE0"), Style.WHITE));
STYLES.put("B523", new Style(Style.parseColor("#F4A10B"), Style.WHITE));
STYLES.put("B524", new Style(Style.parseColor("#FFEC00"), Style.BLACK));
STYLES.put("B531", new Style(Style.parseColor("#2DA84D"), Style.WHITE));
STYLES.put("B532", new Style(Style.parseColor("#00FD00"), Style.BLACK));
STYLES.put("B520", new Style(Style.parseColor("#FF3333"), Style.WHITE));
STYLES.put("B530", new Style(Style.parseColor("#E84A93"), Style.WHITE));
// Bus Speyer
STYLES.put("B561", new Style(Style.parseColor("#003D72"), Style.WHITE));
STYLES.put("B562", new Style(Style.parseColor("#F58221"), Style.WHITE));
STYLES.put("B563", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B564", new Style(Style.parseColor("#006C3B"), Style.WHITE));
STYLES.put("B565", new Style(Style.parseColor("#00B7BD"), Style.WHITE));
STYLES.put("B566", new Style(Style.parseColor("#D1AC75"), Style.WHITE));
STYLES.put("B567", new Style(Style.parseColor("#95080A"), Style.WHITE));
STYLES.put("B568", new Style(Style.parseColor("#0067B3"), Style.WHITE));
STYLES.put("B569", new Style(Style.parseColor("#71BF44"), Style.WHITE));
// Bus Speyer
STYLES.put("B561", new Style(Style.parseColor("#003D72"), Style.WHITE));
STYLES.put("B562", new Style(Style.parseColor("#F58221"), Style.WHITE));
STYLES.put("B563", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B564", new Style(Style.parseColor("#006C3B"), Style.WHITE));
STYLES.put("B565", new Style(Style.parseColor("#00B7BD"), Style.WHITE));
STYLES.put("B566", new Style(Style.parseColor("#D1AC75"), Style.WHITE));
STYLES.put("B567", new Style(Style.parseColor("#95080A"), Style.WHITE));
STYLES.put("B568", new Style(Style.parseColor("#0067B3"), Style.WHITE));
STYLES.put("B569", new Style(Style.parseColor("#71BF44"), Style.WHITE));
// Bus Frankenthal/Pfalz
STYLES.put("B462", new Style(Style.parseColor("#93C11C"), Style.WHITE));
STYLES.put("B463", new Style(Style.parseColor("#A12486"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#0398D8"), Style.WHITE));
STYLES.put("B466", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B467", new Style(Style.parseColor("#C10625"), Style.WHITE));
}
// Bus Frankenthal/Pfalz
STYLES.put("B462", new Style(Style.parseColor("#93C11C"), Style.WHITE));
STYLES.put("B463", new Style(Style.parseColor("#A12486"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#0398D8"), Style.WHITE));
STYLES.put("B466", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B467", new Style(Style.parseColor("#C10625"), Style.WHITE));
}
}

View file

@ -36,426 +36,416 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class VrrProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://efa.vrr.de/standard/";
public class VrrProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://efa.vrr.de/standard/";
// http://app.vrr.de/companion-vrr/
// http://app.vrr.de/companion-vrr/
public VrrProvider()
{
this(API_BASE);
}
public VrrProvider() {
this(API_BASE);
}
public VrrProvider(final String apiBase)
{
super(NetworkId.VRR, apiBase);
public VrrProvider(final String apiBase) {
super(NetworkId.VRR, apiBase);
setIncludeRegionId(false);
setUseProxFootSearch(false);
setNeedsSpEncId(true);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setRequestUrlEncoding(Charsets.ISO_8859_1);
setSessionCookieName("vrr-efa-lb");
}
setIncludeRegionId(false);
setUseProxFootSearch(false);
setNeedsSpEncId(true);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
setRequestUrlEncoding(Charsets.ISO_8859_1);
setSessionCookieName("vrr-efa-lb");
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
if (products != null)
{
for (final Product p : products)
{
if (p == Product.CABLECAR)
uri.append("&inclMOT_11=on"); // Schwebebahn
}
}
if (products != null) {
for (final Product p : products) {
if (p == Product.CABLECAR)
uri.append("&inclMOT_11=on"); // Schwebebahn
}
}
return uri.toString();
}
return uri.toString();
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("Regionalbahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("NordWestBahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("Regionalbahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("NordWestBahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if (trainType == null && "SEV7".equals(trainNum))
return new Line(id, network, Product.BUS, trainNum);
}
else if ("11".equals(mot))
{
// Wuppertaler Schwebebahn & SkyTrain D'dorf
if ("Schwebebahn".equals(trainName) || (longName != null && longName.startsWith("Schwebebahn")))
return new Line(id, network, Product.CABLECAR, name);
if (trainType == null && "SEV7".equals(trainNum))
return new Line(id, network, Product.BUS, trainNum);
} else if ("11".equals(mot)) {
// Wuppertaler Schwebebahn & SkyTrain D'dorf
if ("Schwebebahn".equals(trainName) || (longName != null && longName.startsWith("Schwebebahn")))
return new Line(id, network, Product.CABLECAR, name);
// H-Bahn TU Dortmund
if ("H-Bahn".equals(trainName) || (longName != null && longName.startsWith("H-Bahn")))
return new Line(id, network, Product.CABLECAR, name);
}
// H-Bahn TU Dortmund
if ("H-Bahn".equals(trainName) || (longName != null && longName.startsWith("H-Bahn")))
return new Line(id, network, Product.CABLECAR, name);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, 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
{
// Schnellbusse VRR
STYLES.put("vrr|BSB", new Style(Style.parseColor("#00919d"), Style.WHITE));
static {
// Schnellbusse VRR
STYLES.put("vrr|BSB", new Style(Style.parseColor("#00919d"), Style.WHITE));
// Dortmund
STYLES.put("dsw|UU41", new Style(Shape.RECT, Style.parseColor("#ffe700"), Style.GRAY));
STYLES.put("dsw|UU42", new Style(Shape.RECT, Style.parseColor("#fcb913"), Style.WHITE));
STYLES.put("dsw|UU43", new Style(Shape.RECT, Style.parseColor("#409387"), Style.WHITE));
STYLES.put("dsw|UU44", new Style(Shape.RECT, Style.parseColor("#66a3b1"), Style.WHITE));
STYLES.put("dsw|UU45", new Style(Shape.RECT, Style.parseColor("#ee1c23"), Style.WHITE));
STYLES.put("dsw|UU46", new Style(Shape.RECT, Style.parseColor("#756fb3"), Style.WHITE));
STYLES.put("dsw|UU47", new Style(Shape.RECT, Style.parseColor("#8dc63e"), Style.WHITE));
STYLES.put("dsw|UU49", new Style(Shape.RECT, Style.parseColor("#f7acbc"), Style.WHITE));
STYLES.put("dsw|BNE", new Style(Shape.RECT, Style.parseColor("#2e2382"), Style.WHITE));
// Dortmund
STYLES.put("dsw|UU41", new Style(Shape.RECT, Style.parseColor("#ffe700"), Style.GRAY));
STYLES.put("dsw|UU42", new Style(Shape.RECT, Style.parseColor("#fcb913"), Style.WHITE));
STYLES.put("dsw|UU43", new Style(Shape.RECT, Style.parseColor("#409387"), Style.WHITE));
STYLES.put("dsw|UU44", new Style(Shape.RECT, Style.parseColor("#66a3b1"), Style.WHITE));
STYLES.put("dsw|UU45", new Style(Shape.RECT, Style.parseColor("#ee1c23"), Style.WHITE));
STYLES.put("dsw|UU46", new Style(Shape.RECT, Style.parseColor("#756fb3"), Style.WHITE));
STYLES.put("dsw|UU47", new Style(Shape.RECT, Style.parseColor("#8dc63e"), Style.WHITE));
STYLES.put("dsw|UU49", new Style(Shape.RECT, Style.parseColor("#f7acbc"), Style.WHITE));
STYLES.put("dsw|BNE", new Style(Shape.RECT, Style.parseColor("#2e2382"), Style.WHITE));
// Düsseldorf
STYLES.put("rbg|UU70", new Style(Shape.RECT, Style.parseColor("#69b0cd"), Style.WHITE));
STYLES.put("rbg|UU71", new Style(Shape.RECT, Style.parseColor("#66cef6"), Style.WHITE));
STYLES.put("rbg|UU72", new Style(Shape.RECT, Style.parseColor("#4cc4c5"), Style.WHITE));
STYLES.put("rbg|UU73", new Style(Shape.RECT, Style.parseColor("#4763b8"), Style.WHITE));
STYLES.put("rbg|UU74", new Style(Shape.RECT, Style.parseColor("#27297c"), Style.WHITE));
STYLES.put("rbg|UU75", new Style(Shape.RECT, Style.parseColor("#079acb"), Style.WHITE));
STYLES.put("rbg|UU76", new Style(Shape.RECT, Style.parseColor("#1969bc"), Style.WHITE));
STYLES.put("rbg|UU77", new Style(Shape.RECT, Style.parseColor("#6d90d2"), Style.WHITE));
STYLES.put("rbg|UU78", new Style(Shape.RECT, Style.parseColor("#02a7eb"), Style.WHITE));
STYLES.put("rbg|UU79", new Style(Shape.RECT, Style.parseColor("#00aaa0"), Style.WHITE));
STYLES.put("rbg|UU83", new Style(Shape.RECT, Style.parseColor("#2743a0"), Style.WHITE));
STYLES.put("rbg|T701", new Style(Shape.RECT, Style.parseColor("#f57215"), Style.WHITE));
STYLES.put("rbg|T704", new Style(Shape.RECT, Style.parseColor("#c01c23"), Style.WHITE));
STYLES.put("rbg|T705", new Style(Shape.RECT, Style.parseColor("#bd0c8e"), Style.WHITE));
STYLES.put("rbg|T706", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("rbg|T707", new Style(Shape.RECT, Style.parseColor("#72177a"), Style.WHITE));
STYLES.put("rbg|T708", new Style(Shape.RECT, Style.parseColor("#f680b4"), Style.WHITE));
STYLES.put("rbg|T709", new Style(Shape.RECT, Style.parseColor("#ef269d"), Style.WHITE));
STYLES.put("rbg|BNE1", new Style(Shape.RECT, Style.parseColor("#fec210"), Style.BLACK));
STYLES.put("rbg|BNE2", new Style(Shape.RECT, Style.parseColor("#f17cb0"), Style.WHITE));
STYLES.put("rbg|BNE3", new Style(Shape.RECT, Style.parseColor("#99ca3b"), Style.WHITE));
STYLES.put("rbg|BNE4", new Style(Shape.RECT, Style.parseColor("#ee1d23"), Style.WHITE));
STYLES.put("rbg|BNE5", new Style(Shape.RECT, Style.parseColor("#90268f"), Style.WHITE));
STYLES.put("rbg|BNE6", new Style(Shape.RECT, Style.parseColor("#f47921"), Style.WHITE));
STYLES.put("rbg|BNE7", new Style(Shape.RECT, Style.parseColor("#009247"), Style.WHITE));
STYLES.put("rbg|BNE8", new Style(Shape.RECT, Style.parseColor("#bdaa8b"), Style.BLACK));
// Krefeld
STYLES.put("swk|T041", new Style(Style.parseColor("#ee4036"), Style.WHITE));
STYLES.put("swk|T042", new Style(Style.parseColor("#f49392"), Style.WHITE));
STYLES.put("swk|T043", new Style(Style.parseColor("#bc6ead"), Style.WHITE));
STYLES.put("swk|T044", new Style(Style.parseColor("#f36c21"), Style.WHITE));
STYLES.put("swk|B045", new Style(Style.parseColor("#00b5e6"), Style.WHITE));
STYLES.put("swk|B046", new Style(Style.parseColor("#695073"), Style.WHITE));
STYLES.put("swk|B047", new Style(Style.parseColor("#fbce99"), Style.WHITE));
STYLES.put("swk|B051", new Style(Style.parseColor("#a1cf73"), Style.WHITE));
STYLES.put("swk|B052", new Style(Style.parseColor("#f68f2a"), Style.WHITE));
STYLES.put("swk|B054", new Style(Style.parseColor("#048546"), Style.WHITE));
STYLES.put("swk|B055", new Style(Style.parseColor("#00b2b7"), Style.WHITE));
STYLES.put("swk|B056", new Style(Style.parseColor("#a2689d"), Style.WHITE));
STYLES.put("swk|B057", new Style(Style.parseColor("#3bc4e6"), Style.WHITE));
STYLES.put("swk|B058", new Style(Style.parseColor("#0081c6"), Style.WHITE));
STYLES.put("swk|B059", new Style(Style.parseColor("#9ad099"), Style.WHITE));
STYLES.put("swk|B060", new Style(Style.parseColor("#aac3bf"), Style.WHITE));
STYLES.put("swk|B061", new Style(Style.parseColor("#ce8d29"), Style.WHITE));
STYLES.put("swk|B062", new Style(Style.parseColor("#ae7544"), Style.WHITE));
STYLES.put("swk|B068", new Style(Style.parseColor("#1857a7"), Style.WHITE));
STYLES.put("swk|B069", new Style(Style.parseColor("#cd7762"), Style.WHITE));
STYLES.put("rvn|B076", new Style(Style.parseColor("#56a44d"), Style.WHITE));
STYLES.put("rvn|B077", new Style(Style.parseColor("#fcef08"), Style.WHITE));
STYLES.put("rvn|B079", new Style(Style.parseColor("#98a3a4"), Style.WHITE));
STYLES.put("swk|BNE5", new Style(Style.parseColor("#99d64c"), Style.WHITE));
STYLES.put("swk|BNE6", new Style(Style.parseColor("#f6811d"), Style.WHITE));
STYLES.put("swk|BNE7", new Style(Style.parseColor("#5dcbe8"), Style.WHITE));
STYLES.put("swk|BNE8", new Style(Style.parseColor("#187fcb"), Style.WHITE));
STYLES.put("swk|BNE10", new Style(Style.parseColor("#a32240"), Style.WHITE));
STYLES.put("swk|BNE27", new Style(Style.parseColor("#138544"), Style.WHITE));
// Düsseldorf
STYLES.put("rbg|UU70", new Style(Shape.RECT, Style.parseColor("#69b0cd"), Style.WHITE));
STYLES.put("rbg|UU71", new Style(Shape.RECT, Style.parseColor("#66cef6"), Style.WHITE));
STYLES.put("rbg|UU72", new Style(Shape.RECT, Style.parseColor("#4cc4c5"), Style.WHITE));
STYLES.put("rbg|UU73", new Style(Shape.RECT, Style.parseColor("#4763b8"), Style.WHITE));
STYLES.put("rbg|UU74", new Style(Shape.RECT, Style.parseColor("#27297c"), Style.WHITE));
STYLES.put("rbg|UU75", new Style(Shape.RECT, Style.parseColor("#079acb"), Style.WHITE));
STYLES.put("rbg|UU76", new Style(Shape.RECT, Style.parseColor("#1969bc"), Style.WHITE));
STYLES.put("rbg|UU77", new Style(Shape.RECT, Style.parseColor("#6d90d2"), Style.WHITE));
STYLES.put("rbg|UU78", new Style(Shape.RECT, Style.parseColor("#02a7eb"), Style.WHITE));
STYLES.put("rbg|UU79", new Style(Shape.RECT, Style.parseColor("#00aaa0"), Style.WHITE));
STYLES.put("rbg|UU83", new Style(Shape.RECT, Style.parseColor("#2743a0"), Style.WHITE));
STYLES.put("rbg|T701", new Style(Shape.RECT, Style.parseColor("#f57215"), Style.WHITE));
STYLES.put("rbg|T704", new Style(Shape.RECT, Style.parseColor("#c01c23"), Style.WHITE));
STYLES.put("rbg|T705", new Style(Shape.RECT, Style.parseColor("#bd0c8e"), Style.WHITE));
STYLES.put("rbg|T706", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("rbg|T707", new Style(Shape.RECT, Style.parseColor("#72177a"), Style.WHITE));
STYLES.put("rbg|T708", new Style(Shape.RECT, Style.parseColor("#f680b4"), Style.WHITE));
STYLES.put("rbg|T709", new Style(Shape.RECT, Style.parseColor("#ef269d"), Style.WHITE));
STYLES.put("rbg|BNE1", new Style(Shape.RECT, Style.parseColor("#fec210"), Style.BLACK));
STYLES.put("rbg|BNE2", new Style(Shape.RECT, Style.parseColor("#f17cb0"), Style.WHITE));
STYLES.put("rbg|BNE3", new Style(Shape.RECT, Style.parseColor("#99ca3b"), Style.WHITE));
STYLES.put("rbg|BNE4", new Style(Shape.RECT, Style.parseColor("#ee1d23"), Style.WHITE));
STYLES.put("rbg|BNE5", new Style(Shape.RECT, Style.parseColor("#90268f"), Style.WHITE));
STYLES.put("rbg|BNE6", new Style(Shape.RECT, Style.parseColor("#f47921"), Style.WHITE));
STYLES.put("rbg|BNE7", new Style(Shape.RECT, Style.parseColor("#009247"), Style.WHITE));
STYLES.put("rbg|BNE8", new Style(Shape.RECT, Style.parseColor("#bdaa8b"), Style.BLACK));
// Essen
STYLES.put("eva|UU17", new Style(Shape.RECT, Style.parseColor("#68b6e3"), Style.WHITE));
STYLES.put("eva|T101", new Style(Shape.RECT, Style.parseColor("#986b17"), Style.WHITE));
STYLES.put("eva|T103", new Style(Shape.RECT, Style.parseColor("#ffcc00"), Style.WHITE));
STYLES.put("eva|T105", new Style(Shape.RECT, Style.parseColor("#b6cd00"), Style.WHITE));
STYLES.put("eva|T106", new Style(Shape.RECT, Style.parseColor("#a695ba"), Style.WHITE));
STYLES.put("eva|T108", new Style(Shape.RECT, Style.parseColor("#eca900"), Style.WHITE));
STYLES.put("eva|T109", new Style(Shape.RECT, Style.parseColor("#00933a"), Style.WHITE));
STYLES.put("eva|BNE1",new Style(Shape.RECT, Style.parseColor("#f7a500"), Style.WHITE));
STYLES.put("eva|BNE2",new Style(Shape.RECT, Style.parseColor("#009dcc"), Style.WHITE));
STYLES.put("eva|BNE3",new Style(Shape.RECT, Style.parseColor("#534395"), Style.WHITE));
STYLES.put("eva|BNE4",new Style(Shape.RECT, Style.parseColor("#f29ec4"), Style.WHITE));
STYLES.put("eva|BNE5",new Style(Shape.RECT, Style.parseColor("#00964e"), Style.WHITE));
STYLES.put("eva|BNE6",new Style(Shape.RECT, Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("eva|BNE7",new Style(Shape.RECT, Style.parseColor("#6e9ed4"), Style.WHITE));
STYLES.put("eva|BNE8",new Style(Shape.RECT, Style.parseColor("#877bb0"), Style.WHITE));
STYLES.put("eva|BNE9",new Style(Shape.RECT, Style.parseColor("#ed6da6"), Style.WHITE));
STYLES.put("eva|BNE10",new Style(Shape.RECT, Style.parseColor("#ab901c"), Style.WHITE));
STYLES.put("eva|BNE11",new Style(Shape.RECT, Style.parseColor("#e3000b"), Style.WHITE));
STYLES.put("eva|BNE12",new Style(Shape.RECT, Style.parseColor("#92120a"), Style.WHITE));
STYLES.put("eva|BNE13",new Style(Shape.RECT, Style.parseColor("#ffde0c"), Style.BLACK));
STYLES.put("eva|BNE14",new Style(Shape.RECT, Style.parseColor("#ee7100"), Style.WHITE));
STYLES.put("eva|BNE15",new Style(Shape.RECT, Style.parseColor("#94c11a"), Style.WHITE));
STYLES.put("eva|BNE16",new Style(Shape.RECT, Style.parseColor("#004e9e"), Style.WHITE));
// Krefeld
STYLES.put("swk|T041", new Style(Style.parseColor("#ee4036"), Style.WHITE));
STYLES.put("swk|T042", new Style(Style.parseColor("#f49392"), Style.WHITE));
STYLES.put("swk|T043", new Style(Style.parseColor("#bc6ead"), Style.WHITE));
STYLES.put("swk|T044", new Style(Style.parseColor("#f36c21"), Style.WHITE));
STYLES.put("swk|B045", new Style(Style.parseColor("#00b5e6"), Style.WHITE));
STYLES.put("swk|B046", new Style(Style.parseColor("#695073"), Style.WHITE));
STYLES.put("swk|B047", new Style(Style.parseColor("#fbce99"), Style.WHITE));
STYLES.put("swk|B051", new Style(Style.parseColor("#a1cf73"), Style.WHITE));
STYLES.put("swk|B052", new Style(Style.parseColor("#f68f2a"), Style.WHITE));
STYLES.put("swk|B054", new Style(Style.parseColor("#048546"), Style.WHITE));
STYLES.put("swk|B055", new Style(Style.parseColor("#00b2b7"), Style.WHITE));
STYLES.put("swk|B056", new Style(Style.parseColor("#a2689d"), Style.WHITE));
STYLES.put("swk|B057", new Style(Style.parseColor("#3bc4e6"), Style.WHITE));
STYLES.put("swk|B058", new Style(Style.parseColor("#0081c6"), Style.WHITE));
STYLES.put("swk|B059", new Style(Style.parseColor("#9ad099"), Style.WHITE));
STYLES.put("swk|B060", new Style(Style.parseColor("#aac3bf"), Style.WHITE));
STYLES.put("swk|B061", new Style(Style.parseColor("#ce8d29"), Style.WHITE));
STYLES.put("swk|B062", new Style(Style.parseColor("#ae7544"), Style.WHITE));
STYLES.put("swk|B068", new Style(Style.parseColor("#1857a7"), Style.WHITE));
STYLES.put("swk|B069", new Style(Style.parseColor("#cd7762"), Style.WHITE));
STYLES.put("rvn|B076", new Style(Style.parseColor("#56a44d"), Style.WHITE));
STYLES.put("rvn|B077", new Style(Style.parseColor("#fcef08"), Style.WHITE));
STYLES.put("rvn|B079", new Style(Style.parseColor("#98a3a4"), Style.WHITE));
STYLES.put("swk|BNE5", new Style(Style.parseColor("#99d64c"), Style.WHITE));
STYLES.put("swk|BNE6", new Style(Style.parseColor("#f6811d"), Style.WHITE));
STYLES.put("swk|BNE7", new Style(Style.parseColor("#5dcbe8"), Style.WHITE));
STYLES.put("swk|BNE8", new Style(Style.parseColor("#187fcb"), Style.WHITE));
STYLES.put("swk|BNE10", new Style(Style.parseColor("#a32240"), Style.WHITE));
STYLES.put("swk|BNE27", new Style(Style.parseColor("#138544"), Style.WHITE));
// Duisburg
STYLES.put("dvg|B905", new Style(Style.parseColor("#c8242b"), Style.WHITE));
STYLES.put("dvg|B906", new Style(Style.parseColor("#b5ab3a"), Style.WHITE));
STYLES.put("dvg|B907", new Style(Style.parseColor("#6891c3"), Style.WHITE));
STYLES.put("dvg|B909", new Style(Style.parseColor("#217e5b"), Style.WHITE));
STYLES.put("dvg|B910", new Style(Style.parseColor("#d48018"), Style.WHITE));
STYLES.put("dvg|B917", new Style(Style.parseColor("#23b14b"), Style.WHITE));
STYLES.put("dvg|B919", new Style(Style.parseColor("#078b4a"), Style.WHITE));
STYLES.put("dvg|B922", new Style(Style.parseColor("#0072bb"), Style.WHITE));
STYLES.put("dvg|B923", new Style(Style.parseColor("#00b1c4"), Style.WHITE));
STYLES.put("dvg|B924", new Style(Style.parseColor("#f37921"), Style.WHITE));
STYLES.put("dvg|B925", new Style(Style.parseColor("#4876b8"), Style.WHITE));
STYLES.put("dvg|B926", new Style(Style.parseColor("#649b43"), Style.WHITE));
STYLES.put("dvg|B928", new Style(Style.parseColor("#c4428c"), Style.WHITE));
STYLES.put("dvg|B933", new Style(Style.parseColor("#975615"), Style.WHITE));
STYLES.put("dvg|B934", new Style(Style.parseColor("#009074"), Style.WHITE));
STYLES.put("dvg|B937", new Style(Style.parseColor("#6f78b5"), Style.WHITE));
STYLES.put("dvg|B940", new Style(Style.parseColor("#bbbb30"), Style.WHITE));
STYLES.put("dvg|B942", new Style(Style.parseColor("#930408"), Style.WHITE));
STYLES.put("dvg|B944", new Style(Style.parseColor("#c52157"), Style.WHITE));
STYLES.put("dvg|B946", new Style(Style.parseColor("#1cbddc"), Style.WHITE));
STYLES.put("dvg|BNE1", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE2", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE3", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE4", new Style(Style.parseColor("#000000"), Style.WHITE));
// Essen
STYLES.put("eva|UU17", new Style(Shape.RECT, Style.parseColor("#68b6e3"), Style.WHITE));
STYLES.put("eva|T101", new Style(Shape.RECT, Style.parseColor("#986b17"), Style.WHITE));
STYLES.put("eva|T103", new Style(Shape.RECT, Style.parseColor("#ffcc00"), Style.WHITE));
STYLES.put("eva|T105", new Style(Shape.RECT, Style.parseColor("#b6cd00"), Style.WHITE));
STYLES.put("eva|T106", new Style(Shape.RECT, Style.parseColor("#a695ba"), Style.WHITE));
STYLES.put("eva|T108", new Style(Shape.RECT, Style.parseColor("#eca900"), Style.WHITE));
STYLES.put("eva|T109", new Style(Shape.RECT, Style.parseColor("#00933a"), Style.WHITE));
STYLES.put("eva|BNE1", new Style(Shape.RECT, Style.parseColor("#f7a500"), Style.WHITE));
STYLES.put("eva|BNE2", new Style(Shape.RECT, Style.parseColor("#009dcc"), Style.WHITE));
STYLES.put("eva|BNE3", new Style(Shape.RECT, Style.parseColor("#534395"), Style.WHITE));
STYLES.put("eva|BNE4", new Style(Shape.RECT, Style.parseColor("#f29ec4"), Style.WHITE));
STYLES.put("eva|BNE5", new Style(Shape.RECT, Style.parseColor("#00964e"), Style.WHITE));
STYLES.put("eva|BNE6", new Style(Shape.RECT, Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("eva|BNE7", new Style(Shape.RECT, Style.parseColor("#6e9ed4"), Style.WHITE));
STYLES.put("eva|BNE8", new Style(Shape.RECT, Style.parseColor("#877bb0"), Style.WHITE));
STYLES.put("eva|BNE9", new Style(Shape.RECT, Style.parseColor("#ed6da6"), Style.WHITE));
STYLES.put("eva|BNE10", new Style(Shape.RECT, Style.parseColor("#ab901c"), Style.WHITE));
STYLES.put("eva|BNE11", new Style(Shape.RECT, Style.parseColor("#e3000b"), Style.WHITE));
STYLES.put("eva|BNE12", new Style(Shape.RECT, Style.parseColor("#92120a"), Style.WHITE));
STYLES.put("eva|BNE13", new Style(Shape.RECT, Style.parseColor("#ffde0c"), Style.BLACK));
STYLES.put("eva|BNE14", new Style(Shape.RECT, Style.parseColor("#ee7100"), Style.WHITE));
STYLES.put("eva|BNE15", new Style(Shape.RECT, Style.parseColor("#94c11a"), Style.WHITE));
STYLES.put("eva|BNE16", new Style(Shape.RECT, Style.parseColor("#004e9e"), Style.WHITE));
// Oberhausen
STYLES.put("sto|B952", new Style(Style.parseColor("#f59598"), Style.WHITE));
STYLES.put("sto|B953", new Style(Style.parseColor("#5eb6d9"), Style.WHITE));
STYLES.put("sto|B954", new Style(Style.parseColor("#f89d3d"), Style.WHITE));
STYLES.put("sto|B955", new Style(Style.parseColor("#8879b8"), Style.WHITE));
STYLES.put("sto|B956", new Style(Style.parseColor("#23b24b"), Style.WHITE));
STYLES.put("sto|B957", new Style(Style.parseColor("#ebc531"), Style.WHITE));
STYLES.put("sto|B960", new Style(Style.parseColor("#aed57f"), Style.WHITE));
STYLES.put("sto|B961", new Style(Style.parseColor("#a46f73"), Style.WHITE));
STYLES.put("sto|B962", new Style(Style.parseColor("#0a776f"), Style.WHITE));
STYLES.put("sto|B966", new Style(Style.parseColor("#c8b3d6"), Style.WHITE));
STYLES.put("sto|B976", new Style(Style.parseColor("#d063a5"), Style.WHITE));
STYLES.put("sto|BNE1", new Style(Style.parseColor("#e22225"), Style.WHITE));
STYLES.put("sto|BNE2", new Style(Style.parseColor("#28ad78"), Style.WHITE));
STYLES.put("sto|BNE3", new Style(Style.parseColor("#85499c"), Style.WHITE));
STYLES.put("sto|BNE4", new Style(Style.parseColor("#395aa8"), Style.WHITE));
STYLES.put("sto|BNE5", new Style(Style.parseColor("#ede929"), Style.WHITE));
STYLES.put("sto|BNE6", new Style(Style.parseColor("#d488ba"), Style.WHITE));
STYLES.put("sto|BNE7", new Style(Style.parseColor("#fbae3e"), Style.WHITE));
STYLES.put("sto|BNE10", new Style(Style.parseColor("#270039"), Style.WHITE));
// Duisburg
STYLES.put("dvg|B905", new Style(Style.parseColor("#c8242b"), Style.WHITE));
STYLES.put("dvg|B906", new Style(Style.parseColor("#b5ab3a"), Style.WHITE));
STYLES.put("dvg|B907", new Style(Style.parseColor("#6891c3"), Style.WHITE));
STYLES.put("dvg|B909", new Style(Style.parseColor("#217e5b"), Style.WHITE));
STYLES.put("dvg|B910", new Style(Style.parseColor("#d48018"), Style.WHITE));
STYLES.put("dvg|B917", new Style(Style.parseColor("#23b14b"), Style.WHITE));
STYLES.put("dvg|B919", new Style(Style.parseColor("#078b4a"), Style.WHITE));
STYLES.put("dvg|B922", new Style(Style.parseColor("#0072bb"), Style.WHITE));
STYLES.put("dvg|B923", new Style(Style.parseColor("#00b1c4"), Style.WHITE));
STYLES.put("dvg|B924", new Style(Style.parseColor("#f37921"), Style.WHITE));
STYLES.put("dvg|B925", new Style(Style.parseColor("#4876b8"), Style.WHITE));
STYLES.put("dvg|B926", new Style(Style.parseColor("#649b43"), Style.WHITE));
STYLES.put("dvg|B928", new Style(Style.parseColor("#c4428c"), Style.WHITE));
STYLES.put("dvg|B933", new Style(Style.parseColor("#975615"), Style.WHITE));
STYLES.put("dvg|B934", new Style(Style.parseColor("#009074"), Style.WHITE));
STYLES.put("dvg|B937", new Style(Style.parseColor("#6f78b5"), Style.WHITE));
STYLES.put("dvg|B940", new Style(Style.parseColor("#bbbb30"), Style.WHITE));
STYLES.put("dvg|B942", new Style(Style.parseColor("#930408"), Style.WHITE));
STYLES.put("dvg|B944", new Style(Style.parseColor("#c52157"), Style.WHITE));
STYLES.put("dvg|B946", new Style(Style.parseColor("#1cbddc"), Style.WHITE));
STYLES.put("dvg|BNE1", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE2", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE3", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE4", new Style(Style.parseColor("#000000"), Style.WHITE));
// Mülheim an der Ruhr
STYLES.put("vrr|T102", new Style(Style.parseColor("#756fb3"), Style.WHITE));
STYLES.put("vrr|B132", new Style(Style.parseColor("#a3c3d1"), Style.BLACK));
STYLES.put("vrr|B133", new Style(Style.parseColor("#a9a575"), Style.BLACK));
STYLES.put("vrr|B134", new Style(Style.parseColor("#806a63"), Style.WHITE));
STYLES.put("vrr|B135", new Style(Style.parseColor("#425159"), Style.WHITE));
// Oberhausen
STYLES.put("sto|B952", new Style(Style.parseColor("#f59598"), Style.WHITE));
STYLES.put("sto|B953", new Style(Style.parseColor("#5eb6d9"), Style.WHITE));
STYLES.put("sto|B954", new Style(Style.parseColor("#f89d3d"), Style.WHITE));
STYLES.put("sto|B955", new Style(Style.parseColor("#8879b8"), Style.WHITE));
STYLES.put("sto|B956", new Style(Style.parseColor("#23b24b"), Style.WHITE));
STYLES.put("sto|B957", new Style(Style.parseColor("#ebc531"), Style.WHITE));
STYLES.put("sto|B960", new Style(Style.parseColor("#aed57f"), Style.WHITE));
STYLES.put("sto|B961", new Style(Style.parseColor("#a46f73"), Style.WHITE));
STYLES.put("sto|B962", new Style(Style.parseColor("#0a776f"), Style.WHITE));
STYLES.put("sto|B966", new Style(Style.parseColor("#c8b3d6"), Style.WHITE));
STYLES.put("sto|B976", new Style(Style.parseColor("#d063a5"), Style.WHITE));
STYLES.put("sto|BNE1", new Style(Style.parseColor("#e22225"), Style.WHITE));
STYLES.put("sto|BNE2", new Style(Style.parseColor("#28ad78"), Style.WHITE));
STYLES.put("sto|BNE3", new Style(Style.parseColor("#85499c"), Style.WHITE));
STYLES.put("sto|BNE4", new Style(Style.parseColor("#395aa8"), Style.WHITE));
STYLES.put("sto|BNE5", new Style(Style.parseColor("#ede929"), Style.WHITE));
STYLES.put("sto|BNE6", new Style(Style.parseColor("#d488ba"), Style.WHITE));
STYLES.put("sto|BNE7", new Style(Style.parseColor("#fbae3e"), Style.WHITE));
STYLES.put("sto|BNE10", new Style(Style.parseColor("#270039"), Style.WHITE));
// Neuss
STYLES.put("swn|B842", new Style(Style.parseColor("#fdcc10"), Style.WHITE));
STYLES.put("swn|B843", new Style(Style.parseColor("#808180"), Style.WHITE));
STYLES.put("swn|B844", new Style(Style.parseColor("#cb1f25"), Style.WHITE));
STYLES.put("swn|B848", new Style(Style.parseColor("#be4e26"), Style.WHITE));
STYLES.put("swn|B849", new Style(Style.parseColor("#c878b1"), Style.WHITE));
STYLES.put("swn|B854", new Style(Style.parseColor("#35bb93"), Style.WHITE));
STYLES.put("swn|BNE1", new Style(Style.parseColor("#ff9900"), Style.WHITE));
STYLES.put("swn|BNE2", new Style(Style.parseColor("#0000ff"), Style.WHITE));
STYLES.put("swn|BNE3", new Style(Style.parseColor("#ff0000"), Style.WHITE));
STYLES.put("swn|BNE4", new Style(Style.parseColor("#ff9900"), Style.WHITE));
STYLES.put("swn|BNE5", new Style(Style.parseColor("#9900cc"), Style.WHITE));
STYLES.put("swn|BNE6", new Style(Style.parseColor("#00cc99"), Style.WHITE));
// Mülheim an der Ruhr
STYLES.put("vrr|T102", new Style(Style.parseColor("#756fb3"), Style.WHITE));
STYLES.put("vrr|B132", new Style(Style.parseColor("#a3c3d1"), Style.BLACK));
STYLES.put("vrr|B133", new Style(Style.parseColor("#a9a575"), Style.BLACK));
STYLES.put("vrr|B134", new Style(Style.parseColor("#806a63"), Style.WHITE));
STYLES.put("vrr|B135", new Style(Style.parseColor("#425159"), Style.WHITE));
// Remscheid
STYLES.put("swr|B655", new Style(Style.parseColor("#dbcd00"), Style.WHITE));
STYLES.put("swr|B657", new Style(Style.parseColor("#deb993"), Style.WHITE));
STYLES.put("swr|B659", new Style(Style.parseColor("#f59b00"), Style.WHITE));
STYLES.put("swr|B660", new Style(Style.parseColor("#f5a387"), Style.WHITE));
STYLES.put("swr|B664", new Style(Style.parseColor("#b1a8d3"), Style.WHITE));
STYLES.put("swr|B666", new Style(Style.parseColor("#0074be"), Style.WHITE));
STYLES.put("swr|B673", new Style(Style.parseColor("#ee7555"), Style.WHITE));
STYLES.put("swr|B675", new Style(Style.parseColor("#004e9e"), Style.WHITE));
STYLES.put("swr|B680", new Style(Style.parseColor("#c78711"), Style.WHITE));
STYLES.put("swr|BNE14", new Style(Style.parseColor("#2d247b"), Style.WHITE));
STYLES.put("swr|BNE17", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("swr|BNE18", new Style(Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("swr|BNE20", new Style(Style.parseColor("#0a5d34"), Style.WHITE));
// Neuss
STYLES.put("swn|B842", new Style(Style.parseColor("#fdcc10"), Style.WHITE));
STYLES.put("swn|B843", new Style(Style.parseColor("#808180"), Style.WHITE));
STYLES.put("swn|B844", new Style(Style.parseColor("#cb1f25"), Style.WHITE));
STYLES.put("swn|B848", new Style(Style.parseColor("#be4e26"), Style.WHITE));
STYLES.put("swn|B849", new Style(Style.parseColor("#c878b1"), Style.WHITE));
STYLES.put("swn|B854", new Style(Style.parseColor("#35bb93"), Style.WHITE));
STYLES.put("swn|BNE1", new Style(Style.parseColor("#ff9900"), Style.WHITE));
STYLES.put("swn|BNE2", new Style(Style.parseColor("#0000ff"), Style.WHITE));
STYLES.put("swn|BNE3", new Style(Style.parseColor("#ff0000"), Style.WHITE));
STYLES.put("swn|BNE4", new Style(Style.parseColor("#ff9900"), Style.WHITE));
STYLES.put("swn|BNE5", new Style(Style.parseColor("#9900cc"), Style.WHITE));
STYLES.put("swn|BNE6", new Style(Style.parseColor("#00cc99"), Style.WHITE));
// Solingen
STYLES.put("sws|B681", new Style(Style.parseColor("#016f42"), Style.WHITE));
STYLES.put("sws|B682", new Style(Style.parseColor("#009b78"), Style.WHITE));
STYLES.put("sws|B684", new Style(Style.parseColor("#009247"), Style.WHITE));
STYLES.put("sws|B685", new Style(Style.parseColor("#539138"), Style.WHITE));
STYLES.put("sws|B686", new Style(Style.parseColor("#a6c539"), Style.WHITE));
STYLES.put("sws|B687", new Style(Style.parseColor("#406ab4"), Style.WHITE));
STYLES.put("sws|B689", new Style(Style.parseColor("#8d5e48"), Style.WHITE));
STYLES.put("sws|B690", new Style(Style.parseColor("#0099cd"), Style.WHITE));
STYLES.put("sws|B691", new Style(Style.parseColor("#963838"), Style.WHITE));
STYLES.put("sws|B693", new Style(Style.parseColor("#9a776f"), Style.WHITE));
STYLES.put("sws|B695", new Style(Style.parseColor("#bf4b75"), Style.WHITE));
STYLES.put("sws|B696", new Style(Style.parseColor("#6c77b4"), Style.WHITE));
STYLES.put("sws|B697", new Style(Style.parseColor("#00baf1"), Style.WHITE));
STYLES.put("sws|B698", new Style(Style.parseColor("#444fa1"), Style.WHITE));
STYLES.put("sws|B699", new Style(Style.parseColor("#c4812f"), Style.WHITE));
STYLES.put("sws|BNE21", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE22", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE24", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE25", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE28", new Style(Style.parseColor("#000000"), Style.WHITE));
// Remscheid
STYLES.put("swr|B655", new Style(Style.parseColor("#dbcd00"), Style.WHITE));
STYLES.put("swr|B657", new Style(Style.parseColor("#deb993"), Style.WHITE));
STYLES.put("swr|B659", new Style(Style.parseColor("#f59b00"), Style.WHITE));
STYLES.put("swr|B660", new Style(Style.parseColor("#f5a387"), Style.WHITE));
STYLES.put("swr|B664", new Style(Style.parseColor("#b1a8d3"), Style.WHITE));
STYLES.put("swr|B666", new Style(Style.parseColor("#0074be"), Style.WHITE));
STYLES.put("swr|B673", new Style(Style.parseColor("#ee7555"), Style.WHITE));
STYLES.put("swr|B675", new Style(Style.parseColor("#004e9e"), Style.WHITE));
STYLES.put("swr|B680", new Style(Style.parseColor("#c78711"), Style.WHITE));
STYLES.put("swr|BNE14", new Style(Style.parseColor("#2d247b"), Style.WHITE));
STYLES.put("swr|BNE17", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("swr|BNE18", new Style(Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("swr|BNE20", new Style(Style.parseColor("#0a5d34"), Style.WHITE));
// Busse Wuppertal
STYLES.put("wsw|B600", new Style(Style.parseColor("#cc4e97"), Style.WHITE));
STYLES.put("wsw|B603", new Style(Style.parseColor("#a77251"), Style.WHITE));
STYLES.put("wsw|B604", new Style(Style.parseColor("#f39100"), Style.WHITE));
STYLES.put("wsw|B606", new Style(Style.parseColor("#88301b"), Style.WHITE));
STYLES.put("wsw|B607", new Style(Style.parseColor("#629e38"), Style.WHITE));
STYLES.put("wsw|B609", new Style(Style.parseColor("#53ae2e"), Style.WHITE));
STYLES.put("wsw|B610", new Style(Style.parseColor("#eb5575"), Style.WHITE));
STYLES.put("wsw|B611", new Style(Style.parseColor("#896a9a"), Style.WHITE));
STYLES.put("wsw|B612", new Style(Style.parseColor("#cd7c00"), Style.WHITE));
STYLES.put("wsw|B613", new Style(Style.parseColor("#491d5c"), Style.WHITE));
STYLES.put("wsw|B614", new Style(Style.parseColor("#00a7c1"), Style.WHITE));
STYLES.put("wsw|B616", new Style(Style.parseColor("#e4003a"), Style.WHITE));
STYLES.put("wsw|B617", new Style(Style.parseColor("#95114d"), Style.WHITE));
STYLES.put("wsw|B618", new Style(Style.parseColor("#cf8360"), Style.WHITE));
STYLES.put("wsw|B619", new Style(Style.parseColor("#304c9d"), Style.WHITE));
STYLES.put("wsw|B622", new Style(Style.parseColor("#aabd81"), Style.WHITE));
STYLES.put("wsw|B623", new Style(Style.parseColor("#e04a23"), Style.WHITE));
STYLES.put("wsw|B624", new Style(Style.parseColor("#0e9580"), Style.WHITE));
STYLES.put("wsw|B625", new Style(Style.parseColor("#7aad3b"), Style.WHITE));
STYLES.put("wsw|B628", new Style(Style.parseColor("#80753b"), Style.WHITE));
STYLES.put("wsw|B629", new Style(Style.parseColor("#dd72a1"), Style.WHITE));
STYLES.put("wsw|B630", new Style(Style.parseColor("#0074be"), Style.WHITE));
STYLES.put("wsw|B631", new Style(Style.parseColor("#5a8858"), Style.WHITE));
STYLES.put("wsw|B632", new Style(Style.parseColor("#ebac3d"), Style.WHITE));
STYLES.put("wsw|B633", new Style(Style.parseColor("#4c2182"), Style.WHITE));
STYLES.put("wsw|B635", new Style(Style.parseColor("#cb6c2b"), Style.WHITE));
STYLES.put("wsw|B638", new Style(Style.parseColor("#588d58"), Style.WHITE));
STYLES.put("wsw|B639", new Style(Style.parseColor("#0097c1"), Style.WHITE));
STYLES.put("wsw|B640", new Style(Style.parseColor("#89ba7a"), Style.WHITE));
STYLES.put("wsw|B642", new Style(Style.parseColor("#4b72aa"), Style.WHITE));
STYLES.put("wsw|B643", new Style(Style.parseColor("#009867"), Style.WHITE));
STYLES.put("wsw|B644", new Style(Style.parseColor("#a57400"), Style.WHITE));
STYLES.put("wsw|B645", new Style(Style.parseColor("#aeba0e"), Style.WHITE));
STYLES.put("wsw|B646", new Style(Style.parseColor("#008db5"), Style.WHITE));
STYLES.put("wsw|B650", new Style(Style.parseColor("#f5bd00"), Style.WHITE));
STYLES.put("wsw|BNE1", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE2", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE3", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE4", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE5", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE6", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE7", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE8", new Style(Style.parseColor("#000000"), Style.WHITE));
// Solingen
STYLES.put("sws|B681", new Style(Style.parseColor("#016f42"), Style.WHITE));
STYLES.put("sws|B682", new Style(Style.parseColor("#009b78"), Style.WHITE));
STYLES.put("sws|B684", new Style(Style.parseColor("#009247"), Style.WHITE));
STYLES.put("sws|B685", new Style(Style.parseColor("#539138"), Style.WHITE));
STYLES.put("sws|B686", new Style(Style.parseColor("#a6c539"), Style.WHITE));
STYLES.put("sws|B687", new Style(Style.parseColor("#406ab4"), Style.WHITE));
STYLES.put("sws|B689", new Style(Style.parseColor("#8d5e48"), Style.WHITE));
STYLES.put("sws|B690", new Style(Style.parseColor("#0099cd"), Style.WHITE));
STYLES.put("sws|B691", new Style(Style.parseColor("#963838"), Style.WHITE));
STYLES.put("sws|B693", new Style(Style.parseColor("#9a776f"), Style.WHITE));
STYLES.put("sws|B695", new Style(Style.parseColor("#bf4b75"), Style.WHITE));
STYLES.put("sws|B696", new Style(Style.parseColor("#6c77b4"), Style.WHITE));
STYLES.put("sws|B697", new Style(Style.parseColor("#00baf1"), Style.WHITE));
STYLES.put("sws|B698", new Style(Style.parseColor("#444fa1"), Style.WHITE));
STYLES.put("sws|B699", new Style(Style.parseColor("#c4812f"), Style.WHITE));
STYLES.put("sws|BNE21", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE22", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE24", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE25", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE28", new Style(Style.parseColor("#000000"), Style.WHITE));
// H-Bahn Dortmund
STYLES.put("dsw|CHB1", new Style(Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("dsw|CHB2", new Style(Style.parseColor("#e5007c"), Style.WHITE));
// Busse Wuppertal
STYLES.put("wsw|B600", new Style(Style.parseColor("#cc4e97"), Style.WHITE));
STYLES.put("wsw|B603", new Style(Style.parseColor("#a77251"), Style.WHITE));
STYLES.put("wsw|B604", new Style(Style.parseColor("#f39100"), Style.WHITE));
STYLES.put("wsw|B606", new Style(Style.parseColor("#88301b"), Style.WHITE));
STYLES.put("wsw|B607", new Style(Style.parseColor("#629e38"), Style.WHITE));
STYLES.put("wsw|B609", new Style(Style.parseColor("#53ae2e"), Style.WHITE));
STYLES.put("wsw|B610", new Style(Style.parseColor("#eb5575"), Style.WHITE));
STYLES.put("wsw|B611", new Style(Style.parseColor("#896a9a"), Style.WHITE));
STYLES.put("wsw|B612", new Style(Style.parseColor("#cd7c00"), Style.WHITE));
STYLES.put("wsw|B613", new Style(Style.parseColor("#491d5c"), Style.WHITE));
STYLES.put("wsw|B614", new Style(Style.parseColor("#00a7c1"), Style.WHITE));
STYLES.put("wsw|B616", new Style(Style.parseColor("#e4003a"), Style.WHITE));
STYLES.put("wsw|B617", new Style(Style.parseColor("#95114d"), Style.WHITE));
STYLES.put("wsw|B618", new Style(Style.parseColor("#cf8360"), Style.WHITE));
STYLES.put("wsw|B619", new Style(Style.parseColor("#304c9d"), Style.WHITE));
STYLES.put("wsw|B622", new Style(Style.parseColor("#aabd81"), Style.WHITE));
STYLES.put("wsw|B623", new Style(Style.parseColor("#e04a23"), Style.WHITE));
STYLES.put("wsw|B624", new Style(Style.parseColor("#0e9580"), Style.WHITE));
STYLES.put("wsw|B625", new Style(Style.parseColor("#7aad3b"), Style.WHITE));
STYLES.put("wsw|B628", new Style(Style.parseColor("#80753b"), Style.WHITE));
STYLES.put("wsw|B629", new Style(Style.parseColor("#dd72a1"), Style.WHITE));
STYLES.put("wsw|B630", new Style(Style.parseColor("#0074be"), Style.WHITE));
STYLES.put("wsw|B631", new Style(Style.parseColor("#5a8858"), Style.WHITE));
STYLES.put("wsw|B632", new Style(Style.parseColor("#ebac3d"), Style.WHITE));
STYLES.put("wsw|B633", new Style(Style.parseColor("#4c2182"), Style.WHITE));
STYLES.put("wsw|B635", new Style(Style.parseColor("#cb6c2b"), Style.WHITE));
STYLES.put("wsw|B638", new Style(Style.parseColor("#588d58"), Style.WHITE));
STYLES.put("wsw|B639", new Style(Style.parseColor("#0097c1"), Style.WHITE));
STYLES.put("wsw|B640", new Style(Style.parseColor("#89ba7a"), Style.WHITE));
STYLES.put("wsw|B642", new Style(Style.parseColor("#4b72aa"), Style.WHITE));
STYLES.put("wsw|B643", new Style(Style.parseColor("#009867"), Style.WHITE));
STYLES.put("wsw|B644", new Style(Style.parseColor("#a57400"), Style.WHITE));
STYLES.put("wsw|B645", new Style(Style.parseColor("#aeba0e"), Style.WHITE));
STYLES.put("wsw|B646", new Style(Style.parseColor("#008db5"), Style.WHITE));
STYLES.put("wsw|B650", new Style(Style.parseColor("#f5bd00"), Style.WHITE));
STYLES.put("wsw|BNE1", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE2", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE3", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE4", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE5", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE6", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE7", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE8", new Style(Style.parseColor("#000000"), Style.WHITE));
// Schwebebahn Wuppertal
STYLES.put("wsw|C60", new Style(Style.parseColor("#003090"), Style.WHITE));
// H-Bahn Dortmund
STYLES.put("dsw|CHB1", new Style(Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("dsw|CHB2", new Style(Style.parseColor("#e5007c"), Style.WHITE));
// Stadtbahn Köln-Bonn
STYLES.put("vrs|T1", new Style(Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("vrs|T3", new Style(Style.parseColor("#f680c5"), Style.WHITE));
STYLES.put("vrs|T4", new Style(Style.parseColor("#f24dae"), Style.WHITE));
STYLES.put("vrs|T5", new Style(Style.parseColor("#9c8dce"), Style.WHITE));
STYLES.put("vrs|T7", new Style(Style.parseColor("#f57947"), Style.WHITE));
STYLES.put("vrs|T9", new Style(Style.parseColor("#f5777b"), Style.WHITE));
STYLES.put("vrs|T12", new Style(Style.parseColor("#80cc28"), Style.WHITE));
STYLES.put("vrs|T13", new Style(Style.parseColor("#9e7b65"), Style.WHITE));
STYLES.put("vrs|T15", new Style(Style.parseColor("#4dbd38"), Style.WHITE));
STYLES.put("vrs|T16", new Style(Style.parseColor("#33baab"), Style.WHITE));
STYLES.put("vrs|T18", new Style(Style.parseColor("#05a1e6"), Style.WHITE));
STYLES.put("vrs|T61", new Style(Style.parseColor("#80cc28"), Style.WHITE));
STYLES.put("vrs|T62", new Style(Style.parseColor("#4dbd38"), Style.WHITE));
STYLES.put("vrs|T63", new Style(Style.parseColor("#73d2f6"), Style.WHITE));
STYLES.put("vrs|T65", new Style(Style.parseColor("#b3db18"), Style.WHITE));
STYLES.put("vrs|T66", new Style(Style.parseColor("#ec008c"), Style.WHITE));
STYLES.put("vrs|T67", new Style(Style.parseColor("#f680c5"), Style.WHITE));
STYLES.put("vrs|T68", new Style(Style.parseColor("#ca93d0"), Style.WHITE));
// Schwebebahn Wuppertal
STYLES.put("wsw|C60", new Style(Style.parseColor("#003090"), Style.WHITE));
// Stadtbahn Bielefeld
STYLES.put("owl|T1", new Style(Style.parseColor("#00aeef"), Style.WHITE));
STYLES.put("owl|T2", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("owl|T3", new Style(Style.parseColor("#fff200"), Style.BLACK));
STYLES.put("owl|T4", new Style(Style.parseColor("#e2001a"), Style.WHITE));
// Stadtbahn Köln-Bonn
STYLES.put("vrs|T1", new Style(Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("vrs|T3", new Style(Style.parseColor("#f680c5"), Style.WHITE));
STYLES.put("vrs|T4", new Style(Style.parseColor("#f24dae"), Style.WHITE));
STYLES.put("vrs|T5", new Style(Style.parseColor("#9c8dce"), Style.WHITE));
STYLES.put("vrs|T7", new Style(Style.parseColor("#f57947"), Style.WHITE));
STYLES.put("vrs|T9", new Style(Style.parseColor("#f5777b"), Style.WHITE));
STYLES.put("vrs|T12", new Style(Style.parseColor("#80cc28"), Style.WHITE));
STYLES.put("vrs|T13", new Style(Style.parseColor("#9e7b65"), Style.WHITE));
STYLES.put("vrs|T15", new Style(Style.parseColor("#4dbd38"), Style.WHITE));
STYLES.put("vrs|T16", new Style(Style.parseColor("#33baab"), Style.WHITE));
STYLES.put("vrs|T18", new Style(Style.parseColor("#05a1e6"), Style.WHITE));
STYLES.put("vrs|T61", new Style(Style.parseColor("#80cc28"), Style.WHITE));
STYLES.put("vrs|T62", new Style(Style.parseColor("#4dbd38"), Style.WHITE));
STYLES.put("vrs|T63", new Style(Style.parseColor("#73d2f6"), Style.WHITE));
STYLES.put("vrs|T65", new Style(Style.parseColor("#b3db18"), Style.WHITE));
STYLES.put("vrs|T66", new Style(Style.parseColor("#ec008c"), Style.WHITE));
STYLES.put("vrs|T67", new Style(Style.parseColor("#f680c5"), Style.WHITE));
STYLES.put("vrs|T68", new Style(Style.parseColor("#ca93d0"), Style.WHITE));
// Busse Bonn
STYLES.put("vrs|B63", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B16", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B66", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B67", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B68", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B18", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B61", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|B62", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|B65", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|BSB55", new Style(Style.parseColor("#00919e"), Style.WHITE));
STYLES.put("vrs|BSB60", new Style(Style.parseColor("#8f9867"), Style.WHITE));
STYLES.put("vrs|BSB69", new Style(Style.parseColor("#db5f1f"), Style.WHITE));
STYLES.put("vrs|B529", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B537", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B541", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B550", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B163", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B551", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B600", new Style(Style.parseColor("#817db7"), Style.WHITE));
STYLES.put("vrs|B601", new Style(Style.parseColor("#831b82"), Style.WHITE));
STYLES.put("vrs|B602", new Style(Style.parseColor("#dd6ba6"), Style.WHITE));
STYLES.put("vrs|B603", new Style(Style.parseColor("#e6007d"), Style.WHITE));
STYLES.put("vrs|B604", new Style(Style.parseColor("#009f5d"), Style.WHITE));
STYLES.put("vrs|B605", new Style(Style.parseColor("#007b3b"), Style.WHITE));
STYLES.put("vrs|B606", new Style(Style.parseColor("#9cbf11"), Style.WHITE));
STYLES.put("vrs|B607", new Style(Style.parseColor("#60ad2a"), Style.WHITE));
STYLES.put("vrs|B608", new Style(Style.parseColor("#f8a600"), Style.WHITE));
STYLES.put("vrs|B609", new Style(Style.parseColor("#ef7100"), Style.WHITE));
STYLES.put("vrs|B610", new Style(Style.parseColor("#3ec1f1"), Style.WHITE));
STYLES.put("vrs|B611", new Style(Style.parseColor("#0099db"), Style.WHITE));
STYLES.put("vrs|B612", new Style(Style.parseColor("#ce9d53"), Style.WHITE));
STYLES.put("vrs|B613", new Style(Style.parseColor("#7b3600"), Style.WHITE));
STYLES.put("vrs|B614", new Style(Style.parseColor("#806839"), Style.WHITE));
STYLES.put("vrs|B615", new Style(Style.parseColor("#532700"), Style.WHITE));
STYLES.put("vrs|B630", new Style(Style.parseColor("#c41950"), Style.WHITE));
STYLES.put("vrs|B631", new Style(Style.parseColor("#9b1c44"), Style.WHITE));
STYLES.put("vrs|B633", new Style(Style.parseColor("#88cdc7"), Style.WHITE));
STYLES.put("vrs|B635", new Style(Style.parseColor("#cec800"), Style.WHITE));
STYLES.put("vrs|B636", new Style(Style.parseColor("#af0223"), Style.WHITE));
STYLES.put("vrs|B637", new Style(Style.parseColor("#e3572a"), Style.WHITE));
STYLES.put("vrs|B638", new Style(Style.parseColor("#af5836"), Style.WHITE));
STYLES.put("vrs|B640", new Style(Style.parseColor("#004f81"), Style.WHITE));
STYLES.put("vrs|BT650", new Style(Style.parseColor("#54baa2"), Style.WHITE));
STYLES.put("vrs|BT651", new Style(Style.parseColor("#005738"), Style.WHITE));
STYLES.put("vrs|BT680", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B800", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B812", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B843", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B845", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B852", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B855", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B856", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B857", new Style(Style.parseColor("#4e6578"), Style.WHITE));
}
// Stadtbahn Bielefeld
STYLES.put("owl|T1", new Style(Style.parseColor("#00aeef"), Style.WHITE));
STYLES.put("owl|T2", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("owl|T3", new Style(Style.parseColor("#fff200"), Style.BLACK));
STYLES.put("owl|T4", new Style(Style.parseColor("#e2001a"), Style.WHITE));
@Override
public Style lineStyle(final @Nullable String network, final @Nullable Product product, final @Nullable String label)
{
if (product == Product.BUS && label != null && label.startsWith("SB"))
return super.lineStyle(network, product, "SB");
// Busse Bonn
STYLES.put("vrs|B63", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B16", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B66", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B67", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B68", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B18", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B61", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|B62", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|B65", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|BSB55", new Style(Style.parseColor("#00919e"), Style.WHITE));
STYLES.put("vrs|BSB60", new Style(Style.parseColor("#8f9867"), Style.WHITE));
STYLES.put("vrs|BSB69", new Style(Style.parseColor("#db5f1f"), Style.WHITE));
STYLES.put("vrs|B529", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B537", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B541", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B550", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B163", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B551", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B600", new Style(Style.parseColor("#817db7"), Style.WHITE));
STYLES.put("vrs|B601", new Style(Style.parseColor("#831b82"), Style.WHITE));
STYLES.put("vrs|B602", new Style(Style.parseColor("#dd6ba6"), Style.WHITE));
STYLES.put("vrs|B603", new Style(Style.parseColor("#e6007d"), Style.WHITE));
STYLES.put("vrs|B604", new Style(Style.parseColor("#009f5d"), Style.WHITE));
STYLES.put("vrs|B605", new Style(Style.parseColor("#007b3b"), Style.WHITE));
STYLES.put("vrs|B606", new Style(Style.parseColor("#9cbf11"), Style.WHITE));
STYLES.put("vrs|B607", new Style(Style.parseColor("#60ad2a"), Style.WHITE));
STYLES.put("vrs|B608", new Style(Style.parseColor("#f8a600"), Style.WHITE));
STYLES.put("vrs|B609", new Style(Style.parseColor("#ef7100"), Style.WHITE));
STYLES.put("vrs|B610", new Style(Style.parseColor("#3ec1f1"), Style.WHITE));
STYLES.put("vrs|B611", new Style(Style.parseColor("#0099db"), Style.WHITE));
STYLES.put("vrs|B612", new Style(Style.parseColor("#ce9d53"), Style.WHITE));
STYLES.put("vrs|B613", new Style(Style.parseColor("#7b3600"), Style.WHITE));
STYLES.put("vrs|B614", new Style(Style.parseColor("#806839"), Style.WHITE));
STYLES.put("vrs|B615", new Style(Style.parseColor("#532700"), Style.WHITE));
STYLES.put("vrs|B630", new Style(Style.parseColor("#c41950"), Style.WHITE));
STYLES.put("vrs|B631", new Style(Style.parseColor("#9b1c44"), Style.WHITE));
STYLES.put("vrs|B633", new Style(Style.parseColor("#88cdc7"), Style.WHITE));
STYLES.put("vrs|B635", new Style(Style.parseColor("#cec800"), Style.WHITE));
STYLES.put("vrs|B636", new Style(Style.parseColor("#af0223"), Style.WHITE));
STYLES.put("vrs|B637", new Style(Style.parseColor("#e3572a"), Style.WHITE));
STYLES.put("vrs|B638", new Style(Style.parseColor("#af5836"), Style.WHITE));
STYLES.put("vrs|B640", new Style(Style.parseColor("#004f81"), Style.WHITE));
STYLES.put("vrs|BT650", new Style(Style.parseColor("#54baa2"), Style.WHITE));
STYLES.put("vrs|BT651", new Style(Style.parseColor("#005738"), Style.WHITE));
STYLES.put("vrs|BT680", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B800", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B812", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B843", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B845", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B852", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B855", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B856", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B857", new Style(Style.parseColor("#4e6578"), Style.WHITE));
}
return super.lineStyle(network, product, label);
}
@Override
public Style lineStyle(final @Nullable String network, final @Nullable Product product,
final @Nullable String label) {
if (product == Product.BUS && label != null && label.startsWith("SB"))
return super.lineStyle(network, product, "SB");
return super.lineStyle(network, product, label);
}
}

File diff suppressed because it is too large Load diff

View file

@ -20,14 +20,12 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class VvmProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://efa.mobilitaetsverbund.de/web/";
public class VvmProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://efa.mobilitaetsverbund.de/web/";
public VvmProvider()
{
super(NetworkId.VVM, API_BASE);
public VvmProvider() {
super(NetworkId.VVM, API_BASE);
setNeedsSpEncId(true);
}
setNeedsSpEncId(true);
}
}

View file

@ -27,51 +27,46 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VvoProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://efa.vvo-online.de:8080/dvb/";
public class VvoProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://efa.vvo-online.de:8080/dvb/";
public VvoProvider()
{
this(API_BASE);
}
public VvoProvider() {
this(API_BASE);
}
public VvoProvider(final String apiBase)
{
super(NetworkId.VVO, apiBase);
public VvoProvider(final String apiBase) {
super(NetworkId.VVO, apiBase);
setRequestUrlEncoding(Charsets.UTF_8);
}
setRequestUrlEncoding(Charsets.UTF_8);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("Twoje Linie Kolejowe".equals(trainName) && symbol != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TLK" + symbol);
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("Twoje Linie Kolejowe".equals(trainName) && symbol != null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TLK" + symbol);
if ("Regionalbahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("Ostdeutsche Eisenbahn GmbH".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "OE");
if ("Meridian".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "M");
if ("trilex".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("Trilex".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("U 28".equals(symbol)) // Nationalparkbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "U28");
if ("SB 71".equals(symbol)) // Städtebahn Sachsen
return new Line(id, network, Product.REGIONAL_TRAIN, "SB71");
if ("Regionalbahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("Ostdeutsche Eisenbahn GmbH".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "OE");
if ("Meridian".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "M");
if ("trilex".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("Trilex".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("U 28".equals(symbol)) // Nationalparkbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "U28");
if ("SB 71".equals(symbol)) // Städtebahn Sachsen
return new Line(id, network, Product.REGIONAL_TRAIN, "SB71");
if ("Fernbus".equals(trainName) && trainNum == null)
return new Line(id, network, Product.BUS, trainName);
}
if ("Fernbus".equals(trainName) && trainNum == null)
return new Line(id, network, Product.BUS, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -26,40 +26,34 @@ import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VvsProvider extends AbstractEfaProvider
{
private static final String API_BASE = "http://www2.vvs.de/vvs/";
public class VvsProvider extends AbstractEfaProvider {
private static final String API_BASE = "http://www2.vvs.de/vvs/";
public VvsProvider()
{
this(API_BASE);
}
public VvsProvider() {
this(API_BASE);
}
public VvsProvider(final String apiBase)
{
super(NetworkId.VVS, apiBase);
public VvsProvider(final String apiBase) {
super(NetworkId.VVS, apiBase);
setIncludeRegionId(false);
setNumTripsRequested(4);
}
setIncludeRegionId(false);
setNumTripsRequested(4);
}
@Override
public Point[] getArea()
{
return new Point[] { Point.fromDouble(48.784068, 9.181713) };
}
@Override
public Point[] getArea() {
return new Point[] { Point.fromDouble(48.784068, 9.181713) };
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum,
final @Nullable String trainName)
{
if ("0".equals(mot))
{
if ("IC".equals(trainNum))
return new Line(id, network, Product.HIGH_SPEED_TRAIN, trainNum);
}
@Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
if ("0".equals(mot)) {
if ("IC".equals(trainNum))
return new Line(id, network, Product.HIGH_SPEED_TRAIN, trainNum);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
}
}

View file

@ -20,14 +20,12 @@ package de.schildbach.pte;
/**
* @author Andreas Schildbach
*/
public class VvtProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://efa.vvt.at/vvtadr/";
public class VvtProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://efa.vvt.at/vvtadr/";
public VvtProvider()
{
super(NetworkId.VVT, API_BASE);
public VvtProvider() {
super(NetworkId.VVT, API_BASE);
setUseRouteIndexAsTripId(false);
}
setUseRouteIndexAsTripId(false);
}
}

View file

@ -22,12 +22,10 @@ package de.schildbach.pte;
*
* @author Andreas Schildbach
*/
public class VvvProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://195.30.98.162:8081/vvv2/";
public class VvvProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://195.30.98.162:8081/vvv2/";
public VvvProvider()
{
super(NetworkId.VVV, API_BASE);
}
public VvvProvider() {
super(NetworkId.VVV, API_BASE);
}
}

View file

@ -34,58 +34,53 @@ import de.schildbach.pte.dto.Style;
/**
* @author Andreas Schildbach
*/
public class WienProvider extends AbstractEfaProvider
{
private final static String API_BASE = "http://www.wienerlinien.at/ogd_routing/";
public class WienProvider extends AbstractEfaProvider {
private final static String API_BASE = "http://www.wienerlinien.at/ogd_routing/";
public WienProvider()
{
super(NetworkId.WIEN, API_BASE);
public WienProvider() {
super(NetworkId.WIEN, API_BASE);
setIncludeRegionId(false);
setStyles(STYLES);
setRequestUrlEncoding(Charsets.UTF_8);
}
setIncludeRegionId(false);
setStyles(STYLES);
setRequestUrlEncoding(Charsets.UTF_8);
}
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
{
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options));
@Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) {
final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
optimize, walkSpeed, accessibility, options));
if (products != null)
{
for (final Product p : products)
{
if (p == Product.BUS)
uri.append("&inclMOT_11=on"); // night bus
}
}
if (products != null) {
for (final Product p : products) {
if (p == Product.BUS)
uri.append("&inclMOT_11=on"); // night bus
}
}
return uri.toString();
}
return uri.toString();
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Wien
STYLES.put("SS1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1e5cb3"), Style.WHITE));
STYLES.put("SS2", new Style(Style.Shape.ROUNDED, Style.parseColor("#59c594"), Style.WHITE));
STYLES.put("SS3", new Style(Style.Shape.ROUNDED, Style.parseColor("#c8154c"), Style.WHITE));
STYLES.put("SS7", new Style(Style.Shape.ROUNDED, Style.parseColor("#dc35a3"), Style.WHITE));
STYLES.put("SS40", new Style(Style.Shape.ROUNDED, Style.parseColor("#f24d3e"), Style.WHITE));
STYLES.put("SS45", new Style(Style.Shape.ROUNDED, Style.parseColor("#0f8572"), Style.WHITE));
STYLES.put("SS50", new Style(Style.Shape.ROUNDED, Style.parseColor("#34b6e5"), Style.WHITE));
STYLES.put("SS60", new Style(Style.Shape.ROUNDED, Style.parseColor("#82b429"), Style.WHITE));
STYLES.put("SS80", new Style(Style.Shape.ROUNDED, Style.parseColor("#e96619"), Style.WHITE));
static {
// Wien
STYLES.put("SS1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1e5cb3"), Style.WHITE));
STYLES.put("SS2", new Style(Style.Shape.ROUNDED, Style.parseColor("#59c594"), Style.WHITE));
STYLES.put("SS3", new Style(Style.Shape.ROUNDED, Style.parseColor("#c8154c"), Style.WHITE));
STYLES.put("SS7", new Style(Style.Shape.ROUNDED, Style.parseColor("#dc35a3"), Style.WHITE));
STYLES.put("SS40", new Style(Style.Shape.ROUNDED, Style.parseColor("#f24d3e"), Style.WHITE));
STYLES.put("SS45", new Style(Style.Shape.ROUNDED, Style.parseColor("#0f8572"), Style.WHITE));
STYLES.put("SS50", new Style(Style.Shape.ROUNDED, Style.parseColor("#34b6e5"), Style.WHITE));
STYLES.put("SS60", new Style(Style.Shape.ROUNDED, Style.parseColor("#82b429"), Style.WHITE));
STYLES.put("SS80", new Style(Style.Shape.ROUNDED, Style.parseColor("#e96619"), Style.WHITE));
STYLES.put("UU1", new Style(Style.Shape.RECT, Style.parseColor("#c6292a"), Style.WHITE));
STYLES.put("UU2", new Style(Style.Shape.RECT, Style.parseColor("#a82783"), Style.WHITE));
STYLES.put("UU3", new Style(Style.Shape.RECT, Style.parseColor("#f39315"), Style.WHITE));
STYLES.put("UU4", new Style(Style.Shape.RECT, Style.parseColor("#23a740"), Style.WHITE));
STYLES.put("UU6", new Style(Style.Shape.RECT, Style.parseColor("#be762c"), Style.WHITE));
}
STYLES.put("UU1", new Style(Style.Shape.RECT, Style.parseColor("#c6292a"), Style.WHITE));
STYLES.put("UU2", new Style(Style.Shape.RECT, Style.parseColor("#a82783"), Style.WHITE));
STYLES.put("UU3", new Style(Style.Shape.RECT, Style.parseColor("#f39315"), Style.WHITE));
STYLES.put("UU4", new Style(Style.Shape.RECT, Style.parseColor("#23a740"), Style.WHITE));
STYLES.put("UU6", new Style(Style.Shape.RECT, Style.parseColor("#be762c"), Style.WHITE));
}
}

View file

@ -31,201 +31,189 @@ import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class ZvvProvider extends AbstractHafasProvider
{
private static final String API_BASE = "https://online.fahrplan.zvv.ch/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS, Product.CABLECAR, Product.SUBWAY, Product.TRAM };
public class ZvvProvider extends AbstractHafasProvider {
private static final String API_BASE = "https://online.fahrplan.zvv.ch/bin/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS,
Product.CABLECAR, Product.SUBWAY, Product.TRAM };
public ZvvProvider()
{
super(NetworkId.ZVV, API_BASE, "dn", PRODUCTS_MAP);
public ZvvProvider() {
super(NetworkId.ZVV, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
private static final String[] OPERATORS = { "SBB", "SZU" };
private static final String[] PLACES = { "Zürich", "Winterthur" };
private static final String[] OPERATORS = { "SBB", "SZU" };
private static final String[] PLACES = { "Zürich", "Winterthur" };
@Override
protected String[] splitStationName(String name)
{
for (final String operator : OPERATORS)
{
if (name.endsWith(" " + operator))
{
name = name.substring(0, name.length() - operator.length() - 1);
break;
}
@Override
protected String[] splitStationName(String name) {
for (final String operator : OPERATORS) {
if (name.endsWith(" " + operator)) {
name = name.substring(0, name.length() - operator.length() - 1);
break;
}
if (name.endsWith(" (" + operator + ")"))
{
name = name.substring(0, name.length() - operator.length() - 3);
break;
}
}
if (name.endsWith(" (" + operator + ")")) {
name = name.substring(0, name.length() - operator.length() - 3);
break;
}
}
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + ","))
return new String[] { place, name.substring(place.length() + 1) };
for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + ","))
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name);
}
return super.splitStationName(name);
}
@Override
protected String[] splitPOI(final String poi)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitPOI(final String poi) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi);
}
return super.splitStationName(poi);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
@Override
protected String[] splitAddress(final String address) {
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
return super.splitStationName(address);
}
@Override
protected Line parseLineAndType(final String lineAndType)
{
final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType);
if (m.matches())
{
final String number = m.group(1).replaceAll("\\s+", "");
final String type = m.group(2);
@Override
protected Line parseLineAndType(final String lineAndType) {
final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType);
if (m.matches()) {
final String number = m.group(1).replaceAll("\\s+", "");
final String type = m.group(2);
if ("Bus".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Bus"), null);
if ("Bus-NF".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Bus", "Bus-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Tro".equals(type) || "Trolley".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Tro"), null);
if ("Tro-NF".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Tro", "Tro-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Trm".equals(type))
return newLine(Product.TRAM, stripPrefix(number, "Trm"), null);
if ("Trm-NF".equals(type))
return newLine(Product.TRAM, stripPrefix(number, "Trm", "Trm-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Bus".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Bus"), null);
if ("Bus-NF".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Bus", "Bus-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Tro".equals(type) || "Trolley".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Tro"), null);
if ("Tro-NF".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Tro", "Tro-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Trm".equals(type))
return newLine(Product.TRAM, stripPrefix(number, "Trm"), null);
if ("Trm-NF".equals(type))
return newLine(Product.TRAM, stripPrefix(number, "Trm", "Trm-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("S18".equals(number))
return newLine(Product.SUBURBAN_TRAIN, "S18", null);
if ("S18".equals(number))
return newLine(Product.SUBURBAN_TRAIN, "S18", null);
if (type.length() > 0)
{
final Product product = normalizeType(type);
if (product != null)
return newLine(product, number, null);
}
if (type.length() > 0) {
final Product product = normalizeType(type);
if (product != 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);
}
throw new IllegalStateException("cannot normalize line#type " + lineAndType);
}
throw new IllegalStateException("cannot normalize line#type " + lineAndType);
}
private String stripPrefix(final String str, final String... prefixes)
{
for (final String prefix : prefixes)
if (str.startsWith(prefix))
return str.substring(prefix.length());
private String stripPrefix(final String str, final String... prefixes) {
for (final String prefix : prefixes)
if (str.startsWith(prefix))
return str.substring(prefix.length());
return str;
}
return str;
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
@Override
protected Product normalizeType(final String type) {
final String ucType = type.toUpperCase();
if ("N".equals(ucType)) // Nachtbus
return Product.BUS;
if ("TX".equals(ucType))
return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus?
return Product.BUS;
if ("N".equals(ucType)) // Nachtbus
return Product.BUS;
if ("TX".equals(ucType))
return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus?
return Product.BUS;
if ("D-SCHIFF".equals(ucType))
return Product.FERRY;
if ("DAMPFSCH".equals(ucType))
return Product.FERRY;
if ("D-SCHIFF".equals(ucType))
return Product.FERRY;
if ("DAMPFSCH".equals(ucType))
return Product.FERRY;
if ("BERGBAHN".equals(ucType))
return Product.CABLECAR;
if ("LSB".equals(ucType)) // Luftseilbahn
return Product.CABLECAR;
if ("SLB".equals(ucType)) // Sesselliftbahn
return Product.CABLECAR;
if ("BERGBAHN".equals(ucType))
return Product.CABLECAR;
if ("LSB".equals(ucType)) // Luftseilbahn
return Product.CABLECAR;
if ("SLB".equals(ucType)) // Sesselliftbahn
return Product.CABLECAR;
return super.normalizeType(type);
}
return super.normalizeType(type);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// S-Bahn
STYLES.put("SS2", new Style(Shape.RECT, Style.parseColor("#70c82c"), Style.WHITE));
STYLES.put("SS3", new Style(Shape.RECT, Style.parseColor("#587AC2"), Style.WHITE));
STYLES.put("SS4", new Style(Shape.RECT, Style.parseColor("#EE7267"), Style.WHITE));
STYLES.put("SS5", new Style(Shape.RECT, Style.parseColor("#6aadc3"), Style.WHITE));
STYLES.put("SS6", new Style(Shape.RECT, Style.parseColor("#6f41a4"), Style.WHITE));
STYLES.put("SS7", new Style(Shape.RECT, Style.parseColor("#fbb809"), Style.BLACK));
STYLES.put("SS8", new Style(Shape.RECT, Style.parseColor("#562691"), Style.WHITE));
STYLES.put("SS9", new Style(Shape.RECT, Style.parseColor("#069A5D"), Style.WHITE));
STYLES.put("SS10", new Style(Shape.RECT, Style.parseColor("#fbc434"), Style.BLACK));
STYLES.put("SS11", new Style(Shape.RECT, Style.parseColor("#ae90cf"), Style.WHITE));
STYLES.put("SS12", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("SS13", new Style(Shape.RECT, Style.parseColor("#905723"), Style.WHITE));
STYLES.put("SS14", new Style(Shape.RECT, Style.parseColor("#753c0c"), Style.WHITE));
STYLES.put("SS15", new Style(Shape.RECT, Style.parseColor("#c79f73"), Style.WHITE));
STYLES.put("SS16", new Style(Shape.RECT, Style.parseColor("#68c971"), Style.WHITE));
STYLES.put("SS17", new Style(Shape.RECT, Style.parseColor("#3b99b5"), Style.WHITE));
STYLES.put("SS18", new Style(Shape.RECT, Style.parseColor("#f14337"), Style.WHITE));
STYLES.put("SS21", new Style(Shape.RECT, Style.parseColor("#9acaee"), Style.WHITE));
STYLES.put("SS22", new Style(Shape.RECT, Style.parseColor("#8dd24e"), Style.WHITE));
STYLES.put("SS24", new Style(Shape.RECT, Style.parseColor("#ab7745"), Style.WHITE));
STYLES.put("SS26", new Style(Shape.RECT, Style.parseColor("#0e87aa"), Style.WHITE));
STYLES.put("SS29", new Style(Shape.RECT, Style.parseColor("#3dba56"), Style.WHITE));
STYLES.put("SS30", new Style(Shape.RECT, Style.parseColor("#0b8ed8"), Style.WHITE));
STYLES.put("SS33", new Style(Shape.RECT, Style.parseColor("#51aae3"), Style.WHITE));
STYLES.put("SS35", new Style(Shape.RECT, Style.parseColor("#81c0eb"), Style.WHITE));
STYLES.put("SS40", new Style(Shape.RECT, Style.parseColor("#ae90cf"), Style.WHITE));
STYLES.put("SS41", new Style(Shape.RECT, Style.parseColor("#f89a83"), Style.WHITE));
STYLES.put("SS55", new Style(Shape.RECT, Style.parseColor("#905723"), Style.WHITE));
static {
// S-Bahn
STYLES.put("SS2", new Style(Shape.RECT, Style.parseColor("#70c82c"), Style.WHITE));
STYLES.put("SS3", new Style(Shape.RECT, Style.parseColor("#587AC2"), Style.WHITE));
STYLES.put("SS4", new Style(Shape.RECT, Style.parseColor("#EE7267"), Style.WHITE));
STYLES.put("SS5", new Style(Shape.RECT, Style.parseColor("#6aadc3"), Style.WHITE));
STYLES.put("SS6", new Style(Shape.RECT, Style.parseColor("#6f41a4"), Style.WHITE));
STYLES.put("SS7", new Style(Shape.RECT, Style.parseColor("#fbb809"), Style.BLACK));
STYLES.put("SS8", new Style(Shape.RECT, Style.parseColor("#562691"), Style.WHITE));
STYLES.put("SS9", new Style(Shape.RECT, Style.parseColor("#069A5D"), Style.WHITE));
STYLES.put("SS10", new Style(Shape.RECT, Style.parseColor("#fbc434"), Style.BLACK));
STYLES.put("SS11", new Style(Shape.RECT, Style.parseColor("#ae90cf"), Style.WHITE));
STYLES.put("SS12", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("SS13", new Style(Shape.RECT, Style.parseColor("#905723"), Style.WHITE));
STYLES.put("SS14", new Style(Shape.RECT, Style.parseColor("#753c0c"), Style.WHITE));
STYLES.put("SS15", new Style(Shape.RECT, Style.parseColor("#c79f73"), Style.WHITE));
STYLES.put("SS16", new Style(Shape.RECT, Style.parseColor("#68c971"), Style.WHITE));
STYLES.put("SS17", new Style(Shape.RECT, Style.parseColor("#3b99b5"), Style.WHITE));
STYLES.put("SS18", new Style(Shape.RECT, Style.parseColor("#f14337"), Style.WHITE));
STYLES.put("SS21", new Style(Shape.RECT, Style.parseColor("#9acaee"), Style.WHITE));
STYLES.put("SS22", new Style(Shape.RECT, Style.parseColor("#8dd24e"), Style.WHITE));
STYLES.put("SS24", new Style(Shape.RECT, Style.parseColor("#ab7745"), Style.WHITE));
STYLES.put("SS26", new Style(Shape.RECT, Style.parseColor("#0e87aa"), Style.WHITE));
STYLES.put("SS29", new Style(Shape.RECT, Style.parseColor("#3dba56"), Style.WHITE));
STYLES.put("SS30", new Style(Shape.RECT, Style.parseColor("#0b8ed8"), Style.WHITE));
STYLES.put("SS33", new Style(Shape.RECT, Style.parseColor("#51aae3"), Style.WHITE));
STYLES.put("SS35", new Style(Shape.RECT, Style.parseColor("#81c0eb"), Style.WHITE));
STYLES.put("SS40", new Style(Shape.RECT, Style.parseColor("#ae90cf"), Style.WHITE));
STYLES.put("SS41", new Style(Shape.RECT, Style.parseColor("#f89a83"), Style.WHITE));
STYLES.put("SS55", new Style(Shape.RECT, Style.parseColor("#905723"), Style.WHITE));
// Tram
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#19ae48"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#453fa0"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#8c5a2c"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#d6973c"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#99d420"), Style.BLACK));
STYLES.put("T9", new Style(Shape.RECT, Style.parseColor("#453fa0"), Style.WHITE));
STYLES.put("T10", new Style(Shape.RECT, Style.parseColor("#ee1998"), Style.WHITE));
STYLES.put("T11", new Style(Shape.RECT, Style.parseColor("#19ae48"), Style.WHITE));
STYLES.put("T12", new Style(Shape.RECT, Style.parseColor("#85d7e3"), Style.BLACK));
STYLES.put("T13", new Style(Shape.RECT, Style.parseColor("#fdd205"), Style.BLACK));
STYLES.put("T14", new Style(Shape.RECT, Style.parseColor("#2cbbf2"), Style.WHITE));
STYLES.put("T15", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T17", new Style(Shape.RECT, Style.parseColor("#9e1a6e"), Style.WHITE));
// Tram
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#19ae48"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#453fa0"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#8c5a2c"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#d6973c"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#99d420"), Style.BLACK));
STYLES.put("T9", new Style(Shape.RECT, Style.parseColor("#453fa0"), Style.WHITE));
STYLES.put("T10", new Style(Shape.RECT, Style.parseColor("#ee1998"), Style.WHITE));
STYLES.put("T11", new Style(Shape.RECT, Style.parseColor("#19ae48"), Style.WHITE));
STYLES.put("T12", new Style(Shape.RECT, Style.parseColor("#85d7e3"), Style.BLACK));
STYLES.put("T13", new Style(Shape.RECT, Style.parseColor("#fdd205"), Style.BLACK));
STYLES.put("T14", new Style(Shape.RECT, Style.parseColor("#2cbbf2"), Style.WHITE));
STYLES.put("T15", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T17", new Style(Shape.RECT, Style.parseColor("#9e1a6e"), Style.WHITE));
// Bus/Trolley
STYLES.put("B31", new Style(Shape.RECT, Style.parseColor("#999bd3"), Style.WHITE));
STYLES.put("B32", new Style(Shape.RECT, Style.parseColor("#d8a1d6"), Style.BLACK));
STYLES.put("B33", new Style(Shape.RECT, Style.parseColor("#e4e793"), Style.BLACK));
}
// Bus/Trolley
STYLES.put("B31", new Style(Shape.RECT, Style.parseColor("#999bd3"), Style.WHITE));
STYLES.put("B32", new Style(Shape.RECT, Style.parseColor("#d8a1d6"), Style.BLACK));
STYLES.put("B33", new Style(Shape.RECT, Style.parseColor("#e4e793"), Style.BLACK));
}
}

View file

@ -35,78 +35,70 @@ import com.google.common.base.Objects;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class Departure implements Serializable
{
final public @Nullable Date plannedTime;
final public @Nullable Date predictedTime;
final public Line line;
final public @Nullable Position position;
final public @Nullable Location destination;
final public @Nullable int[] capacity;
final public @Nullable String message;
public final class Departure implements Serializable {
final public @Nullable Date plannedTime;
final public @Nullable Date predictedTime;
final public Line line;
final public @Nullable Position position;
final public @Nullable Location destination;
final public @Nullable int[] capacity;
final public @Nullable String message;
public Departure(final Date plannedTime, final Date predictedTime, final Line line, final Position position, final Location destination,
final int[] capacity, final String message)
{
this.plannedTime = plannedTime;
this.predictedTime = predictedTime;
checkArgument(plannedTime != null || predictedTime != null);
this.line = checkNotNull(line);
this.position = position;
this.destination = destination;
this.capacity = capacity;
this.message = message;
}
public Departure(final Date plannedTime, final Date predictedTime, final Line line, final Position position,
final Location destination, final int[] capacity, final String message) {
this.plannedTime = plannedTime;
this.predictedTime = predictedTime;
checkArgument(plannedTime != null || predictedTime != null);
this.line = checkNotNull(line);
this.position = position;
this.destination = destination;
this.capacity = capacity;
this.message = message;
}
public Date getTime()
{
if (predictedTime != null)
return predictedTime;
else
return plannedTime;
}
public Date getTime() {
if (predictedTime != null)
return predictedTime;
else
return plannedTime;
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this);
if (plannedTime != null)
helper.add("planned", String.format(Locale.US, "%ta %<tR", plannedTime));
if (predictedTime != null)
helper.add("predicted", String.format(Locale.US, "%ta %<tR", predictedTime));
return helper.addValue(line).addValue(position).add("destination", destination).omitNullValues().toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this);
if (plannedTime != null)
helper.add("planned", String.format(Locale.US, "%ta %<tR", plannedTime));
if (predictedTime != null)
helper.add("predicted", String.format(Locale.US, "%ta %<tR", predictedTime));
return helper.addValue(line).addValue(position).add("destination", destination).omitNullValues().toString();
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Departure))
return false;
final Departure other = (Departure) o;
if (!Objects.equal(this.plannedTime, other.plannedTime))
return false;
if (!Objects.equal(this.predictedTime, other.predictedTime))
return false;
if (!Objects.equal(this.line, other.line))
return false;
if (!Objects.equal(this.destination, other.destination))
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Departure))
return false;
final Departure other = (Departure) o;
if (!Objects.equal(this.plannedTime, other.plannedTime))
return false;
if (!Objects.equal(this.predictedTime, other.predictedTime))
return false;
if (!Objects.equal(this.line, other.line))
return false;
if (!Objects.equal(this.destination, other.destination))
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(plannedTime, predictedTime, line, destination);
}
@Override
public int hashCode() {
return Objects.hashCode(plannedTime, predictedTime, line, destination);
}
public static final Comparator<Departure> TIME_COMPARATOR = new Comparator<Departure>()
{
public int compare(final Departure departure0, final Departure departure1)
{
return departure0.getTime().compareTo(departure1.getTime());
}
};
public static final Comparator<Departure> TIME_COMPARATOR = new Comparator<Departure>() {
public int compare(final Departure departure0, final Departure departure1) {
return departure0.getTime().compareTo(departure1.getTime());
}
};
}

View file

@ -30,65 +30,60 @@ import com.google.common.base.Objects;
/**
* @author Andreas Schildbach
*/
public final class Fare implements Serializable
{
public enum Type
{
ADULT, CHILD, YOUTH, STUDENT, MILITARY, SENIOR, DISABLED
}
public final class Fare implements Serializable {
public enum Type {
ADULT, CHILD, YOUTH, STUDENT, MILITARY, SENIOR, DISABLED
}
private static final long serialVersionUID = -6136489996930976421L;
private static final long serialVersionUID = -6136489996930976421L;
public final String network;
public final Type type;
public final Currency currency;
public final float fare;
public final @Nullable String unitName;
public final @Nullable String units;
public final String network;
public final Type type;
public final Currency currency;
public final float fare;
public final @Nullable String unitName;
public final @Nullable String units;
public Fare(final String network, final Type type, final Currency currency, final float fare, final String unitName, final String units)
{
this.network = checkNotNull(network);
this.type = checkNotNull(type);
this.currency = checkNotNull(currency);
this.fare = fare;
this.unitName = unitName;
this.units = units;
}
public Fare(final String network, final Type type, final Currency currency, final float fare, final String unitName,
final String units) {
this.network = checkNotNull(network);
this.type = checkNotNull(type);
this.currency = checkNotNull(currency);
this.fare = fare;
this.unitName = unitName;
this.units = units;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Fare))
return false;
final Fare other = (Fare) o;
if (!Objects.equal(this.network, other.network))
return false;
if (!Objects.equal(this.type, other.type))
return false;
if (!Objects.equal(this.currency, other.currency))
return false;
if (this.fare != other.fare)
return false;
if (!Objects.equal(this.unitName, other.unitName))
return false;
if (!Objects.equal(this.units, other.units))
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Fare))
return false;
final Fare other = (Fare) o;
if (!Objects.equal(this.network, other.network))
return false;
if (!Objects.equal(this.type, other.type))
return false;
if (!Objects.equal(this.currency, other.currency))
return false;
if (this.fare != other.fare)
return false;
if (!Objects.equal(this.unitName, other.unitName))
return false;
if (!Objects.equal(this.units, other.units))
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(network, type, currency, fare, unitName, units);
}
@Override
public int hashCode() {
return Objects.hashCode(network, type, currency, fare, unitName, units);
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this).addValue(network).addValue(type).addValue(currency).addValue(fare).addValue(unitName).addValue(units)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).addValue(network).addValue(type).addValue(currency).addValue(fare)
.addValue(unitName).addValue(units).toString();
}
}

View file

@ -30,125 +30,113 @@ import com.google.common.collect.Ordering;
/**
* @author Andreas Schildbach
*/
public final class Line implements Serializable, Comparable<Line>
{
public enum Attr
{
CIRCLE_CLOCKWISE, CIRCLE_ANTICLOCKWISE, SERVICE_REPLACEMENT, LINE_AIRPORT, WHEEL_CHAIR_ACCESS, BICYCLE_CARRIAGE
}
public final class Line implements Serializable, Comparable<Line> {
public enum Attr {
CIRCLE_CLOCKWISE, CIRCLE_ANTICLOCKWISE, SERVICE_REPLACEMENT, LINE_AIRPORT, WHEEL_CHAIR_ACCESS, BICYCLE_CARRIAGE
}
private static final long serialVersionUID = -5642533805998375070L;
private static final long serialVersionUID = -5642533805998375070L;
public final @Nullable String id;
public final @Nullable String network;
public final @Nullable Product product;
public final @Nullable String label;
public final @Nullable String name;
public final @Nullable Style style;
public final @Nullable Set<Attr> attrs;
public final @Nullable String message;
public final @Nullable String id;
public final @Nullable String network;
public final @Nullable Product product;
public final @Nullable String label;
public final @Nullable String name;
public final @Nullable Style style;
public final @Nullable Set<Attr> attrs;
public final @Nullable String message;
public static final Line FOOTWAY = new Line(null, null, null, null);
public static final Line TRANSFER = new Line(null, null, null, null);
public static final Line SECURE_CONNECTION = new Line(null, null, null, null);
public static final Line DO_NOT_CHANGE = new Line(null, null, null, null);
public static final Line FOOTWAY = new Line(null, null, null, null);
public static final Line TRANSFER = new Line(null, null, null, null);
public static final Line SECURE_CONNECTION = new Line(null, null, null, null);
public static final Line DO_NOT_CHANGE = new Line(null, null, null, null);
public Line(final String id, final String network, final Product product, final String label)
{
this(id, network, product, label, null, null, null, null);
}
public Line(final String id, final String network, final Product product, final String label) {
this(id, network, product, label, null, null, null, null);
}
public Line(final String id, final String network, final Product product, final String label, final Style style)
{
this(id, network, product, label, null, style, null, null);
}
public Line(final String id, final String network, final Product product, final String label, final Style style) {
this(id, network, product, label, null, style, null, null);
}
public Line(final String id, final String network, final Product product, final String label, final String name, final Style style)
{
this(id, network, product, label, name, style, null, null);
}
public Line(final String id, final String network, final Product product, final String label, final String name,
final Style style) {
this(id, network, product, label, name, style, null, null);
}
public Line(final String id, final String network, final Product product, final String label, final Style style, final String message)
{
this(id, network, product, label, null, style, null, message);
}
public Line(final String id, final String network, final Product product, final String label, final Style style,
final String message) {
this(id, network, product, label, null, style, null, message);
}
public Line(final String id, final String network, final Product product, final String label, final Style style, final Set<Attr> attrs)
{
this(id, network, product, label, null, style, attrs, null);
}
public Line(final String id, final String network, final Product product, final String label, final Style style,
final Set<Attr> attrs) {
this(id, network, product, label, null, style, attrs, null);
}
public Line(final String id, final String network, final Product product, final String label, final Style style, final Set<Attr> attrs,
final String message)
{
this(id, network, product, label, null, style, attrs, message);
}
public Line(final String id, final String network, final Product product, final String label, final Style style,
final Set<Attr> attrs, final String message) {
this(id, network, product, label, null, style, attrs, message);
}
public Line(final String id, final String network, final Product product, final String label, final String name, final Style style,
final Set<Attr> attrs, final String message)
{
this.id = id;
this.network = network;
this.product = product;
this.label = label;
this.name = name;
this.style = style;
this.attrs = attrs;
this.message = message;
}
public Line(final String id, final String network, final Product product, final String label, final String name,
final Style style, final Set<Attr> attrs, final String message) {
this.id = id;
this.network = network;
this.product = product;
this.label = label;
this.name = name;
this.style = style;
this.attrs = attrs;
this.message = message;
}
public char productCode()
{
final Product product = this.product;
return product != null ? product.code : Product.UNKNOWN;
}
public char productCode() {
final Product product = this.product;
return product != null ? product.code : Product.UNKNOWN;
}
public boolean hasAttr(final Attr attr)
{
final Set<Attr> attrs = this.attrs;
return attrs != null && attrs.contains(attr);
}
public boolean hasAttr(final Attr attr) {
final Set<Attr> attrs = this.attrs;
return attrs != null && attrs.contains(attr);
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Line))
return false;
final Line other = (Line) o;
if (!Objects.equal(this.network, other.network))
return false;
if (!Objects.equal(this.product, other.product))
return false;
if (!Objects.equal(this.label, other.label))
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Line))
return false;
final Line other = (Line) o;
if (!Objects.equal(this.network, other.network))
return false;
if (!Objects.equal(this.product, other.product))
return false;
if (!Objects.equal(this.label, other.label))
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(network, product, label);
}
@Override
public int hashCode() {
return Objects.hashCode(network, product, label);
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this) //
.addValue(network) //
.addValue(product) //
.addValue(label) //
.addValue(name) //
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this) //
.addValue(network) //
.addValue(product) //
.addValue(label) //
.addValue(name) //
.toString();
}
public int compareTo(final Line other)
{
return ComparisonChain.start() //
.compare(this.network, other.network, Ordering.natural().nullsLast()) //
.compare(this.product, other.product, Ordering.natural().nullsLast()) //
.compare(this.label, other.label, Ordering.natural().nullsLast()) //
.result();
}
public int compareTo(final Line other) {
return ComparisonChain.start() //
.compare(this.network, other.network, Ordering.natural().nullsLast()) //
.compare(this.product, other.product, Ordering.natural().nullsLast()) //
.compare(this.label, other.label, Ordering.natural().nullsLast()) //
.result();
}
}

View file

@ -30,41 +30,37 @@ import com.google.common.base.Objects;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class LineDestination implements Serializable
{
final public Line line;
final public @Nullable Location destination;
public final class LineDestination implements Serializable {
final public Line line;
final public @Nullable Location destination;
public LineDestination(final Line line, final Location destination)
{
this.line = checkNotNull(line);
this.destination = destination;
}
public LineDestination(final Line line, final Location destination) {
this.line = checkNotNull(line);
this.destination = destination;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof LineDestination))
return false;
final LineDestination other = (LineDestination) o;
if (!Objects.equal(this.line, other.line))
return false;
if (!Objects.equal(this.destination, other.destination))
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof LineDestination))
return false;
final LineDestination other = (LineDestination) o;
if (!Objects.equal(this.line, other.line))
return false;
if (!Objects.equal(this.destination, other.destination))
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(line, destination);
}
@Override
public int hashCode() {
return Objects.hashCode(line, destination);
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this).add("line", line).add("destination", destination).omitNullValues().toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("line", line).add("destination", destination).omitNullValues()
.toString();
}
}

View file

@ -34,179 +34,159 @@ import com.google.common.base.Strings;
/**
* @author Andreas Schildbach
*/
public final class Location implements Serializable
{
private static final long serialVersionUID = -2124775933106309127L;
public final class Location implements Serializable {
private static final long serialVersionUID = -2124775933106309127L;
public final LocationType type;
public final @Nullable String id;
public final int lat, lon;
public final @Nullable String place;
public final @Nullable String name;
public final @Nullable Set<Product> products;
public final LocationType type;
public final @Nullable String id;
public final int lat, lon;
public final @Nullable String place;
public final @Nullable String name;
public final @Nullable Set<Product> products;
public Location(final LocationType type, final String id, final int lat, final int lon, final String place, final String name,
final Set<Product> products)
{
this.type = checkNotNull(type);
this.id = id;
this.lat = lat;
this.lon = lon;
this.place = place;
this.name = name;
this.products = products;
public Location(final LocationType type, final String id, final int lat, final int lon, final String place,
final String name, final Set<Product> products) {
this.type = checkNotNull(type);
this.id = id;
this.lat = lat;
this.lon = lon;
this.place = place;
this.name = name;
this.products = products;
checkArgument(id == null || id.length() > 0, "ID cannot be the empty string");
checkArgument(place == null || name != null, "place '%s' without name cannot exist", place);
if (type == LocationType.COORD)
{
checkArgument(hasLocation(), "coordinates missing");
checkArgument(place == null && name == null, "coordinates cannot have place or name");
}
}
checkArgument(id == null || id.length() > 0, "ID cannot be the empty string");
checkArgument(place == null || name != null, "place '%s' without name cannot exist", place);
if (type == LocationType.COORD) {
checkArgument(hasLocation(), "coordinates missing");
checkArgument(place == null && name == null, "coordinates cannot have place or name");
}
}
public Location(final LocationType type, final String id, final int lat, final int lon, final String place, final String name)
{
this(type, id, lat, lon, place, name, null);
}
public Location(final LocationType type, final String id, final int lat, final int lon, final String place,
final String name) {
this(type, id, lat, lon, place, name, null);
}
public Location(final LocationType type, final String id, final Point coord, final String place, final String name, final Set<Product> products)
{
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name, products);
}
public Location(final LocationType type, final String id, final Point coord, final String place, final String name,
final Set<Product> products) {
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name, products);
}
public Location(final LocationType type, final String id, final Point coord, final String place, final String name)
{
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name);
}
public Location(final LocationType type, final String id, final Point coord, final String place,
final String name) {
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name);
}
public Location(final LocationType type, final String id, final String place, final String name)
{
this(type, id, 0, 0, place, name);
}
public Location(final LocationType type, final String id, final String place, final String name) {
this(type, id, 0, 0, place, name);
}
public Location(final LocationType type, final String id, final int lat, final int lon)
{
this(type, id, lat, lon, null, null);
}
public Location(final LocationType type, final String id, final int lat, final int lon) {
this(type, id, lat, lon, null, null);
}
public Location(final LocationType type, final String id, final Point coord)
{
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0);
}
public Location(final LocationType type, final String id, final Point coord) {
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0);
}
public Location(final LocationType type, final String id)
{
this(type, id, null, null);
}
public Location(final LocationType type, final String id) {
this(type, id, null, null);
}
public static Location coord(final int lat, final int lon)
{
return new Location(LocationType.COORD, null, lat, lon);
}
public static Location coord(final int lat, final int lon) {
return new Location(LocationType.COORD, null, lat, lon);
}
public static Location coord(final Point coord)
{
return new Location(LocationType.COORD, null, coord.lat, coord.lon);
}
public static Location coord(final Point coord) {
return new Location(LocationType.COORD, null, coord.lat, coord.lon);
}
public final boolean hasId()
{
return !Strings.isNullOrEmpty(id);
}
public final boolean hasId() {
return !Strings.isNullOrEmpty(id);
}
public final boolean hasLocation()
{
return lat != 0 || lon != 0;
}
public final boolean hasLocation() {
return lat != 0 || lon != 0;
}
public double getLatAsDouble()
{
return lat / 1E6;
}
public double getLatAsDouble() {
return lat / 1E6;
}
public double getLonAsDouble()
{
return lon / 1E6;
}
public double getLonAsDouble() {
return lon / 1E6;
}
public final boolean hasName()
{
return name != null;
}
public final boolean hasName() {
return name != null;
}
public final boolean isIdentified()
{
if (type == LocationType.STATION)
return hasId();
public final boolean isIdentified() {
if (type == LocationType.STATION)
return hasId();
if (type == LocationType.POI)
return true;
if (type == LocationType.POI)
return true;
if (type == LocationType.ADDRESS || type == LocationType.COORD)
return hasLocation();
if (type == LocationType.ADDRESS || type == LocationType.COORD)
return hasLocation();
return false;
}
return false;
}
private static final String[] NON_UNIQUE_NAMES = { "Hauptbahnhof", "Hbf", "Bahnhof", "Bf", "Busbahnhof", "ZOB", "Schiffstation", "Schiffst.",
"Zentrum", "Dorf", "Kirche", "Nord", "Ost", "Süd", "West" };
private static final String[] NON_UNIQUE_NAMES = { "Hauptbahnhof", "Hbf", "Bahnhof", "Bf", "Busbahnhof", "ZOB",
"Schiffstation", "Schiffst.", "Zentrum", "Dorf", "Kirche", "Nord", "Ost", "Süd", "West" };
static
{
Arrays.sort(NON_UNIQUE_NAMES);
}
static {
Arrays.sort(NON_UNIQUE_NAMES);
}
public final String uniqueShortName()
{
if (place != null && name != null && Arrays.binarySearch(NON_UNIQUE_NAMES, name) >= 0)
return place + ", " + name;
else if (name != null)
return name;
else if (hasId())
return id;
else
return null;
}
public final String uniqueShortName() {
if (place != null && name != null && Arrays.binarySearch(NON_UNIQUE_NAMES, name) >= 0)
return place + ", " + name;
else if (name != null)
return name;
else if (hasId())
return id;
else
return null;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Location))
return false;
final Location other = (Location) o;
if (!Objects.equal(this.type, other.type))
return false;
if (this.id != null)
return Objects.equal(this.id, other.id);
if (this.lat != 0 && this.lon != 0)
return this.lat == other.lat && this.lon == other.lon;
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Location))
return false;
final Location other = (Location) o;
if (!Objects.equal(this.type, other.type))
return false;
if (this.id != null)
return Objects.equal(this.id, other.id);
if (this.lat != 0 && this.lon != 0)
return this.lat == other.lat && this.lon == other.lon;
// only discriminate by name/place if no ids are given
if (!Objects.equal(this.name, other.name))
return false;
if (!Objects.equal(this.place, other.place))
return false;
return true;
}
// only discriminate by name/place if no ids are given
if (!Objects.equal(this.name, other.name))
return false;
if (!Objects.equal(this.place, other.place))
return false;
return true;
}
@Override
public int hashCode()
{
if (id != null)
return Objects.hashCode(type, id);
else
return Objects.hashCode(type, lat, lon);
}
@Override
public int hashCode() {
if (id != null)
return Objects.hashCode(type, id);
else
return Objects.hashCode(type, lat, lon);
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(type).addValue(id);
if (hasLocation())
helper.addValue(lat + "/" + lon);
return helper.add("place", place).add("name", name).add("products", products).omitNullValues().toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(type).addValue(id);
if (hasLocation())
helper.addValue(lat + "/" + lon);
return helper.add("place", place).add("name", name).add("products", products).omitNullValues().toString();
}
}

View file

@ -20,16 +20,15 @@ package de.schildbach.pte.dto;
/**
* @author Andreas Schildbach
*/
public enum LocationType
{
/** Location can represent any of the below. Mainly meant for user input. */
ANY,
/** Location represents a station or stop. */
STATION,
/** Location represents a point of interest. */
POI,
/** Location represents a postal address. */
ADDRESS,
/** Location represents a just a plain coordinate, e.g. acquired by GPS. */
COORD
public enum LocationType {
/** Location can represent any of the below. Mainly meant for user input. */
ANY,
/** Location represents a station or stop. */
STATION,
/** Location represents a point of interest. */
POI,
/** Location represents a postal address. */
ADDRESS,
/** Location represents a just a plain coordinate, e.g. acquired by GPS. */
COORD
}

View file

@ -31,37 +31,32 @@ import com.google.common.base.MoreObjects.ToStringHelper;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class NearbyLocationsResult implements Serializable
{
public enum Status
{
OK, INVALID_ID, SERVICE_DOWN
}
public final class NearbyLocationsResult implements Serializable {
public enum Status {
OK, INVALID_ID, SERVICE_DOWN
}
public final @Nullable ResultHeader header;
public final Status status;
public final List<Location> locations;
public final @Nullable ResultHeader header;
public final Status status;
public final List<Location> locations;
public NearbyLocationsResult(final ResultHeader header, final List<Location> locations)
{
this.header = header;
this.status = Status.OK;
this.locations = checkNotNull(locations);
}
public NearbyLocationsResult(final ResultHeader header, final List<Location> locations) {
this.header = header;
this.status = Status.OK;
this.locations = checkNotNull(locations);
}
public NearbyLocationsResult(final ResultHeader header, final Status status)
{
this.header = header;
this.status = checkNotNull(status);
this.locations = null;
}
public NearbyLocationsResult(final ResultHeader header, final Status status) {
this.header = header;
this.status = checkNotNull(status);
this.locations = null;
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (locations != null)
helper.add("size", locations.size()).add("locations", locations);
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (locations != null)
helper.add("size", locations.size()).add("locations", locations);
return helper.toString();
}
}

View file

@ -24,57 +24,49 @@ import com.google.common.base.Objects;
/**
* @author Andreas Schildbach
*/
public final class Point implements Serializable
{
private static final long serialVersionUID = -256077054671402897L;
public final class Point implements Serializable {
private static final long serialVersionUID = -256077054671402897L;
public final int lat, lon;
public final int lat, lon;
public Point(final int lat, final int lon)
{
this.lat = lat;
this.lon = lon;
}
public Point(final int lat, final int lon) {
this.lat = lat;
this.lon = lon;
}
public static Point fromDouble(final double lat, final double lon)
{
return new Point((int) Math.round(lat * 1E6), (int) Math.round(lon * 1E6));
}
public static Point fromDouble(final double lat, final double lon) {
return new Point((int) Math.round(lat * 1E6), (int) Math.round(lon * 1E6));
}
public double getLatAsDouble()
{
return lat / 1E6;
}
public double getLatAsDouble() {
return lat / 1E6;
}
public double getLonAsDouble()
{
return lon / 1E6;
}
public double getLonAsDouble() {
return lon / 1E6;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Point))
return false;
final Point other = (Point) o;
if (this.lat != other.lat)
return false;
if (this.lon != other.lon)
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Point))
return false;
final Point other = (Point) o;
if (this.lat != other.lat)
return false;
if (this.lon != other.lon)
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(lat, lon);
}
@Override
public int hashCode() {
return Objects.hashCode(lat, lon);
}
@Override
public String toString()
{
return lat + "/" + lon;
}
@Override
public String toString() {
return lat + "/" + lon;
}
}

View file

@ -29,53 +29,47 @@ import com.google.common.base.Objects;
/**
* @author Andreas Schildbach
*/
public final class Position implements Serializable
{
private static final long serialVersionUID = 5800904192562764917L;
public final class Position implements Serializable {
private static final long serialVersionUID = 5800904192562764917L;
public final String name;
public final @Nullable String section;
public final String name;
public final @Nullable String section;
public Position(final String name)
{
this(name, null);
}
public Position(final String name) {
this(name, null);
}
public Position(final String name, final String section)
{
this.name = checkNotNull(name);
// checkArgument(name.length() <= 5, "name too long: %s", name);
this.section = section;
checkArgument(section == null || section.length() <= 3, "section too long: %s", section);
}
public Position(final String name, final String section) {
this.name = checkNotNull(name);
// checkArgument(name.length() <= 5, "name too long: %s", name);
this.section = section;
checkArgument(section == null || section.length() <= 3, "section too long: %s", section);
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Position))
return false;
final Position other = (Position) o;
if (!Objects.equal(this.name, other.name))
return false;
if (!Objects.equal(this.section, other.section))
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Position))
return false;
final Position other = (Position) o;
if (!Objects.equal(this.name, other.name))
return false;
if (!Objects.equal(this.section, other.section))
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(name, section);
}
@Override
public int hashCode() {
return Objects.hashCode(name, section);
}
@Override
public String toString()
{
final StringBuilder builder = new StringBuilder(name);
if (section != null)
builder.append(section);
return builder.toString();
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(name);
if (section != null)
builder.append(section);
return builder.toString();
}
}

View file

@ -23,64 +23,60 @@ import java.util.Set;
/**
* @author Andreas Schildbach
*/
public enum Product
{
HIGH_SPEED_TRAIN('I'), REGIONAL_TRAIN('R'), SUBURBAN_TRAIN('S'), SUBWAY('U'), TRAM('T'), BUS('B'), FERRY('F'), CABLECAR('C'), ON_DEMAND('P');
public enum Product {
HIGH_SPEED_TRAIN('I'), REGIONAL_TRAIN('R'), SUBURBAN_TRAIN('S'), SUBWAY('U'), TRAM('T'), BUS('B'), FERRY(
'F'), CABLECAR('C'), ON_DEMAND('P');
public static final char UNKNOWN = '?';
public static final Set<Product> ALL = EnumSet.allOf(Product.class);
public static final char UNKNOWN = '?';
public static final Set<Product> ALL = EnumSet.allOf(Product.class);
public final char code;
public final char code;
private Product(final char code)
{
this.code = code;
}
private Product(final char code) {
this.code = code;
}
public static Product fromCode(final char code)
{
if (code == HIGH_SPEED_TRAIN.code)
return HIGH_SPEED_TRAIN;
else if (code == REGIONAL_TRAIN.code)
return REGIONAL_TRAIN;
else if (code == SUBURBAN_TRAIN.code)
return SUBURBAN_TRAIN;
else if (code == SUBWAY.code)
return SUBWAY;
else if (code == TRAM.code)
return TRAM;
else if (code == BUS.code)
return BUS;
else if (code == FERRY.code)
return FERRY;
else if (code == CABLECAR.code)
return CABLECAR;
else if (code == ON_DEMAND.code)
return ON_DEMAND;
else
throw new IllegalArgumentException("unknown code: '" + code + "'");
}
public static Product fromCode(final char code) {
if (code == HIGH_SPEED_TRAIN.code)
return HIGH_SPEED_TRAIN;
else if (code == REGIONAL_TRAIN.code)
return REGIONAL_TRAIN;
else if (code == SUBURBAN_TRAIN.code)
return SUBURBAN_TRAIN;
else if (code == SUBWAY.code)
return SUBWAY;
else if (code == TRAM.code)
return TRAM;
else if (code == BUS.code)
return BUS;
else if (code == FERRY.code)
return FERRY;
else if (code == CABLECAR.code)
return CABLECAR;
else if (code == ON_DEMAND.code)
return ON_DEMAND;
else
throw new IllegalArgumentException("unknown code: '" + code + "'");
}
public static Set<Product> fromCodes(final char[] codes)
{
if (codes == null)
return null;
public static Set<Product> fromCodes(final char[] codes) {
if (codes == null)
return null;
final Set<Product> products = EnumSet.noneOf(Product.class);
for (int i = 0; i < codes.length; i++)
products.add(Product.fromCode(codes[i]));
return products;
}
final Set<Product> products = EnumSet.noneOf(Product.class);
for (int i = 0; i < codes.length; i++)
products.add(Product.fromCode(codes[i]));
return products;
}
public static char[] toCodes(final Set<Product> products)
{
if (products == null)
return null;
public static char[] toCodes(final Set<Product> products) {
if (products == null)
return null;
final char[] codes = new char[products.size()];
int i = 0;
for (final Product product : products)
codes[i++] = product.code;
return codes;
}
final char[] codes = new char[products.size()];
int i = 0;
for (final Product product : products)
codes[i++] = product.code;
return codes;
}
}

View file

@ -32,47 +32,40 @@ import com.google.common.base.MoreObjects.ToStringHelper;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class QueryDeparturesResult implements Serializable
{
public enum Status
{
OK, INVALID_STATION, SERVICE_DOWN
}
public final class QueryDeparturesResult implements Serializable {
public enum Status {
OK, INVALID_STATION, SERVICE_DOWN
}
public final @Nullable ResultHeader header;
public final Status status;
public final List<StationDepartures> stationDepartures = new LinkedList<StationDepartures>();
public final @Nullable ResultHeader header;
public final Status status;
public final List<StationDepartures> stationDepartures = new LinkedList<StationDepartures>();
public QueryDeparturesResult(final ResultHeader header)
{
this.header = header;
this.status = Status.OK;
}
public QueryDeparturesResult(final ResultHeader header) {
this.header = header;
this.status = Status.OK;
}
public QueryDeparturesResult(final ResultHeader header, final Status status)
{
this.header = header;
this.status = checkNotNull(status);
}
public QueryDeparturesResult(final ResultHeader header, final Status status) {
this.header = header;
this.status = checkNotNull(status);
}
public StationDepartures findStationDepartures(final String stationId)
{
for (final StationDepartures departures : stationDepartures)
{
final Location location = departures.location;
if (location != null && stationId.equals(location.id))
return departures;
}
public StationDepartures findStationDepartures(final String stationId) {
for (final StationDepartures departures : stationDepartures) {
final Location location = departures.location;
if (location != null && stationId.equals(location.id))
return departures;
}
return null;
}
return null;
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (stationDepartures != null)
helper.add("size", stationDepartures.size()).add("stationDepartures", stationDepartures);
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (stationDepartures != null)
helper.add("size", stationDepartures.size()).add("stationDepartures", stationDepartures);
return helper.toString();
}
}

View file

@ -22,9 +22,8 @@ import java.io.Serializable;
/**
* @author Andreas Schildbach
*/
public interface QueryTripsContext extends Serializable
{
boolean canQueryLater();
public interface QueryTripsContext extends Serializable {
boolean canQueryLater();
boolean canQueryEarlier();
boolean canQueryEarlier();
}

View file

@ -31,95 +31,86 @@ import com.google.common.base.MoreObjects.ToStringHelper;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class QueryTripsResult implements Serializable
{
public enum Status
{
OK, AMBIGUOUS, TOO_CLOSE, UNKNOWN_FROM, UNKNOWN_VIA, UNKNOWN_TO, UNRESOLVABLE_ADDRESS, NO_TRIPS, INVALID_DATE, SERVICE_DOWN;
}
public final class QueryTripsResult implements Serializable {
public enum Status {
OK, AMBIGUOUS, TOO_CLOSE, UNKNOWN_FROM, UNKNOWN_VIA, UNKNOWN_TO, UNRESOLVABLE_ADDRESS, NO_TRIPS, INVALID_DATE, SERVICE_DOWN;
}
public final @Nullable ResultHeader header;
public final Status status;
public final @Nullable ResultHeader header;
public final Status status;
public final List<Location> ambiguousFrom;
public final List<Location> ambiguousVia;
public final List<Location> ambiguousTo;
public final List<Location> ambiguousFrom;
public final List<Location> ambiguousVia;
public final List<Location> ambiguousTo;
public final String queryUri;
public final Location from;
public final Location via;
public final Location to;
public final QueryTripsContext context;
public final List<Trip> trips;
public final String queryUri;
public final Location from;
public final Location via;
public final Location to;
public final QueryTripsContext context;
public final List<Trip> trips;
public QueryTripsResult(final ResultHeader header, final String queryUri, final Location from, final Location via, final Location to,
final QueryTripsContext context, final List<Trip> trips)
{
this.header = header;
this.status = Status.OK;
this.queryUri = queryUri;
this.from = from;
this.via = via;
this.to = to;
this.context = checkNotNull(context);
this.trips = checkNotNull(trips);
public QueryTripsResult(final ResultHeader header, final String queryUri, final Location from, final Location via,
final Location to, final QueryTripsContext context, final List<Trip> trips) {
this.header = header;
this.status = Status.OK;
this.queryUri = queryUri;
this.from = from;
this.via = via;
this.to = to;
this.context = checkNotNull(context);
this.trips = checkNotNull(trips);
this.ambiguousFrom = null;
this.ambiguousVia = null;
this.ambiguousTo = null;
}
this.ambiguousFrom = null;
this.ambiguousVia = null;
this.ambiguousTo = null;
}
public QueryTripsResult(final ResultHeader header, final List<Location> ambiguousFrom, final List<Location> ambiguousVia,
final List<Location> ambiguousTo)
{
this.header = header;
this.status = Status.AMBIGUOUS;
this.ambiguousFrom = ambiguousFrom;
this.ambiguousVia = ambiguousVia;
this.ambiguousTo = ambiguousTo;
public QueryTripsResult(final ResultHeader header, final List<Location> ambiguousFrom,
final List<Location> ambiguousVia, final List<Location> ambiguousTo) {
this.header = header;
this.status = Status.AMBIGUOUS;
this.ambiguousFrom = ambiguousFrom;
this.ambiguousVia = ambiguousVia;
this.ambiguousTo = ambiguousTo;
this.queryUri = null;
this.from = null;
this.via = null;
this.to = null;
this.context = null;
this.trips = null;
}
this.queryUri = null;
this.from = null;
this.via = null;
this.to = null;
this.context = null;
this.trips = null;
}
public QueryTripsResult(final ResultHeader header, final Status status)
{
this.header = header;
this.status = checkNotNull(status);
public QueryTripsResult(final ResultHeader header, final Status status) {
this.header = header;
this.status = checkNotNull(status);
this.ambiguousFrom = null;
this.ambiguousVia = null;
this.ambiguousTo = null;
this.queryUri = null;
this.from = null;
this.via = null;
this.to = null;
this.context = null;
this.trips = null;
}
this.ambiguousFrom = null;
this.ambiguousVia = null;
this.ambiguousTo = null;
this.queryUri = null;
this.from = null;
this.via = null;
this.to = null;
this.context = null;
this.trips = null;
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (status == Status.OK)
{
if (trips != null)
helper.add("size", trips.size()).add("trips", trips);
}
else if (status == Status.AMBIGUOUS)
{
if (ambiguousFrom != null)
helper.add("size", ambiguousFrom.size()).add("ambiguousFrom", ambiguousFrom);
if (ambiguousVia != null)
helper.add("size", ambiguousVia.size()).add("ambiguousVia", ambiguousVia);
if (ambiguousTo != null)
helper.add("size", ambiguousTo.size()).add("ambiguousTo", ambiguousTo);
}
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (status == Status.OK) {
if (trips != null)
helper.add("size", trips.size()).add("trips", trips);
} else if (status == Status.AMBIGUOUS) {
if (ambiguousFrom != null)
helper.add("size", ambiguousFrom.size()).add("ambiguousFrom", ambiguousFrom);
if (ambiguousVia != null)
helper.add("size", ambiguousVia.size()).add("ambiguousVia", ambiguousVia);
if (ambiguousTo != null)
helper.add("size", ambiguousTo.size()).add("ambiguousTo", ambiguousTo);
}
return helper.toString();
}
}

View file

@ -31,32 +31,29 @@ import de.schildbach.pte.NetworkId;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class ResultHeader implements Serializable
{
public final NetworkId network;
public final String serverProduct;
public final @Nullable String serverVersion;
public final long serverTime;
public final Object context;
public final class ResultHeader implements Serializable {
public final NetworkId network;
public final String serverProduct;
public final @Nullable String serverVersion;
public final long serverTime;
public final Object context;
public ResultHeader(final NetworkId network, final String serverProduct)
{
this(network, serverProduct, null, 0, null);
}
public ResultHeader(final NetworkId network, final String serverProduct) {
this(network, serverProduct, null, 0, null);
}
public ResultHeader(final NetworkId network, final String serverProduct, final String serverVersion, final long serverTime, final Object context)
{
this.network = checkNotNull(network);
this.serverProduct = checkNotNull(serverProduct);
this.serverVersion = serverVersion;
this.serverTime = serverTime;
this.context = context;
}
public ResultHeader(final NetworkId network, final String serverProduct, final String serverVersion,
final long serverTime, final Object context) {
this.network = checkNotNull(network);
this.serverProduct = checkNotNull(serverProduct);
this.serverVersion = serverVersion;
this.serverTime = serverTime;
this.context = context;
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this).add("serverProduct", serverProduct).add("serverVersion", serverVersion).add("serverTime", serverTime)
.add("context", context).omitNullValues().toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("serverProduct", serverProduct).add("serverVersion", serverVersion)
.add("serverTime", serverTime).add("context", context).omitNullValues().toString();
}
}

View file

@ -32,48 +32,44 @@ import com.google.common.base.Objects;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class StationDepartures implements Serializable
{
public final Location location;
public final List<Departure> departures;
public final @Nullable List<LineDestination> lines;
public final class StationDepartures implements Serializable {
public final Location location;
public final List<Departure> departures;
public final @Nullable List<LineDestination> lines;
public StationDepartures(final Location location, final List<Departure> departures, final List<LineDestination> lines)
{
this.location = checkNotNull(location);
this.departures = checkNotNull(departures);
this.lines = lines;
}
public StationDepartures(final Location location, final List<Departure> departures,
final List<LineDestination> lines) {
this.location = checkNotNull(location);
this.departures = checkNotNull(departures);
this.lines = lines;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof StationDepartures))
return false;
final StationDepartures other = (StationDepartures) o;
if (!Objects.equal(this.location, other.location))
return false;
if (!Objects.equal(this.departures, other.departures))
return false;
if (!Objects.equal(this.lines, other.lines))
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof StationDepartures))
return false;
final StationDepartures other = (StationDepartures) o;
if (!Objects.equal(this.location, other.location))
return false;
if (!Objects.equal(this.departures, other.departures))
return false;
if (!Objects.equal(this.lines, other.lines))
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(location, departures, lines);
}
@Override
public int hashCode() {
return Objects.hashCode(location, departures, lines);
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(location);
if (departures != null)
helper.add("size", departures.size()).add("departures", departures);
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(location);
if (departures != null)
helper.add("size", departures.size()).add("departures", departures);
return helper.toString();
}
}

View file

@ -32,271 +32,251 @@ import com.google.common.base.Objects;
/**
* @author Andreas Schildbach
*/
public final class Stop implements Serializable
{
private static final long serialVersionUID = 5034616799626145715L;
public final class Stop implements Serializable {
private static final long serialVersionUID = 5034616799626145715L;
public final Location location;
public final @Nullable Date plannedArrivalTime;
public final @Nullable Date predictedArrivalTime;
public final @Nullable Position plannedArrivalPosition;
public final @Nullable Position predictedArrivalPosition;
public final boolean arrivalCancelled;
public final @Nullable Date plannedDepartureTime;
public final @Nullable Date predictedDepartureTime;
public final @Nullable Position plannedDeparturePosition;
public final @Nullable Position predictedDeparturePosition;
public final boolean departureCancelled;
public final Location location;
public final @Nullable Date plannedArrivalTime;
public final @Nullable Date predictedArrivalTime;
public final @Nullable Position plannedArrivalPosition;
public final @Nullable Position predictedArrivalPosition;
public final boolean arrivalCancelled;
public final @Nullable Date plannedDepartureTime;
public final @Nullable Date predictedDepartureTime;
public final @Nullable Position plannedDeparturePosition;
public final @Nullable Position predictedDeparturePosition;
public final boolean departureCancelled;
public Stop(final Location location, final Date plannedArrivalTime, final Date predictedArrivalTime, final Position plannedArrivalPosition,
final Position predictedArrivalPosition, final Date plannedDepartureTime, final Date predictedDepartureTime,
final Position plannedDeparturePosition, final Position predictedDeparturePosition)
{
this(location, plannedArrivalTime, predictedArrivalTime, plannedArrivalPosition, predictedArrivalPosition, false, plannedDepartureTime,
predictedDepartureTime, plannedDeparturePosition, predictedDeparturePosition, false);
}
public Stop(final Location location, final Date plannedArrivalTime, final Date predictedArrivalTime,
final Position plannedArrivalPosition, final Position predictedArrivalPosition,
final Date plannedDepartureTime, final Date predictedDepartureTime, final Position plannedDeparturePosition,
final Position predictedDeparturePosition) {
this(location, plannedArrivalTime, predictedArrivalTime, plannedArrivalPosition, predictedArrivalPosition,
false, plannedDepartureTime, predictedDepartureTime, plannedDeparturePosition,
predictedDeparturePosition, false);
}
public Stop(final Location location, final Date plannedArrivalTime, final Date predictedArrivalTime, final Position plannedArrivalPosition,
final Position predictedArrivalPosition, final boolean arrivalCancelled, final Date plannedDepartureTime,
final Date predictedDepartureTime, final Position plannedDeparturePosition, final Position predictedDeparturePosition,
final boolean departureCancelled)
{
this.location = checkNotNull(location);
this.plannedArrivalTime = plannedArrivalTime;
this.predictedArrivalTime = predictedArrivalTime;
this.plannedArrivalPosition = plannedArrivalPosition;
this.predictedArrivalPosition = predictedArrivalPosition;
this.arrivalCancelled = arrivalCancelled;
this.plannedDepartureTime = plannedDepartureTime;
this.predictedDepartureTime = predictedDepartureTime;
this.plannedDeparturePosition = plannedDeparturePosition;
this.predictedDeparturePosition = predictedDeparturePosition;
this.departureCancelled = departureCancelled;
}
public Stop(final Location location, final Date plannedArrivalTime, final Date predictedArrivalTime,
final Position plannedArrivalPosition, final Position predictedArrivalPosition,
final boolean arrivalCancelled, final Date plannedDepartureTime, final Date predictedDepartureTime,
final Position plannedDeparturePosition, final Position predictedDeparturePosition,
final boolean departureCancelled) {
this.location = checkNotNull(location);
this.plannedArrivalTime = plannedArrivalTime;
this.predictedArrivalTime = predictedArrivalTime;
this.plannedArrivalPosition = plannedArrivalPosition;
this.predictedArrivalPosition = predictedArrivalPosition;
this.arrivalCancelled = arrivalCancelled;
this.plannedDepartureTime = plannedDepartureTime;
this.predictedDepartureTime = predictedDepartureTime;
this.plannedDeparturePosition = plannedDeparturePosition;
this.predictedDeparturePosition = predictedDeparturePosition;
this.departureCancelled = departureCancelled;
}
public Stop(final Location location, final boolean departure, final Date plannedTime, final Date predictedTime, final Position plannedPosition,
final Position predictedPosition)
{
this(location, departure, plannedTime, predictedTime, plannedPosition, predictedPosition, false);
}
public Stop(final Location location, final boolean departure, final Date plannedTime, final Date predictedTime,
final Position plannedPosition, final Position predictedPosition) {
this(location, departure, plannedTime, predictedTime, plannedPosition, predictedPosition, false);
}
public Stop(final Location location, final boolean departure, final Date plannedTime, final Date predictedTime, final Position plannedPosition,
final Position predictedPosition, final boolean cancelled)
{
this.location = checkNotNull(location);
this.plannedArrivalTime = !departure ? plannedTime : null;
this.predictedArrivalTime = !departure ? predictedTime : null;
this.plannedArrivalPosition = !departure ? plannedPosition : null;
this.predictedArrivalPosition = !departure ? predictedPosition : null;
this.arrivalCancelled = !departure ? cancelled : false;
this.plannedDepartureTime = departure ? plannedTime : null;
this.predictedDepartureTime = departure ? predictedTime : null;
this.plannedDeparturePosition = departure ? plannedPosition : null;
this.predictedDeparturePosition = departure ? predictedPosition : null;
this.departureCancelled = departure ? cancelled : false;
}
public Stop(final Location location, final boolean departure, final Date plannedTime, final Date predictedTime,
final Position plannedPosition, final Position predictedPosition, final boolean cancelled) {
this.location = checkNotNull(location);
this.plannedArrivalTime = !departure ? plannedTime : null;
this.predictedArrivalTime = !departure ? predictedTime : null;
this.plannedArrivalPosition = !departure ? plannedPosition : null;
this.predictedArrivalPosition = !departure ? predictedPosition : null;
this.arrivalCancelled = !departure ? cancelled : false;
this.plannedDepartureTime = departure ? plannedTime : null;
this.predictedDepartureTime = departure ? predictedTime : null;
this.plannedDeparturePosition = departure ? plannedPosition : null;
this.predictedDeparturePosition = departure ? predictedPosition : null;
this.departureCancelled = departure ? cancelled : false;
}
public Stop(final Location location, final Date plannedArrivalTime, final Position plannedArrivalPosition, final Date plannedDepartureTime,
final Position plannedDeparturePosition)
{
this.location = checkNotNull(location);
this.plannedArrivalTime = plannedArrivalTime;
this.predictedArrivalTime = null;
this.plannedArrivalPosition = plannedArrivalPosition;
this.predictedArrivalPosition = null;
this.arrivalCancelled = false;
this.plannedDepartureTime = plannedDepartureTime;
this.predictedDepartureTime = null;
this.plannedDeparturePosition = plannedDeparturePosition;
this.predictedDeparturePosition = null;
this.departureCancelled = false;
}
public Stop(final Location location, final Date plannedArrivalTime, final Position plannedArrivalPosition,
final Date plannedDepartureTime, final Position plannedDeparturePosition) {
this.location = checkNotNull(location);
this.plannedArrivalTime = plannedArrivalTime;
this.predictedArrivalTime = null;
this.plannedArrivalPosition = plannedArrivalPosition;
this.predictedArrivalPosition = null;
this.arrivalCancelled = false;
this.plannedDepartureTime = plannedDepartureTime;
this.predictedDepartureTime = null;
this.plannedDeparturePosition = plannedDeparturePosition;
this.predictedDeparturePosition = null;
this.departureCancelled = false;
}
public Date getArrivalTime()
{
return getArrivalTime(false);
}
public Date getArrivalTime() {
return getArrivalTime(false);
}
public Date getArrivalTime(final boolean preferPlanTime)
{
if (preferPlanTime && plannedArrivalTime != null)
return plannedArrivalTime;
else if (predictedArrivalTime != null)
return predictedArrivalTime;
else if (plannedArrivalTime != null)
return plannedArrivalTime;
else
return null;
}
public Date getArrivalTime(final boolean preferPlanTime) {
if (preferPlanTime && plannedArrivalTime != null)
return plannedArrivalTime;
else if (predictedArrivalTime != null)
return predictedArrivalTime;
else if (plannedArrivalTime != null)
return plannedArrivalTime;
else
return null;
}
public boolean isArrivalTimePredicted()
{
return isArrivalTimePredicted(false);
}
public boolean isArrivalTimePredicted() {
return isArrivalTimePredicted(false);
}
public boolean isArrivalTimePredicted(final boolean preferPlanTime)
{
if (preferPlanTime && plannedArrivalTime != null)
return false;
else
return predictedArrivalTime != null;
}
public boolean isArrivalTimePredicted(final boolean preferPlanTime) {
if (preferPlanTime && plannedArrivalTime != null)
return false;
else
return predictedArrivalTime != null;
}
public Long getArrivalDelay()
{
final Date plannedArrivalTime = this.plannedArrivalTime;
final Date predictedArrivalTime = this.predictedArrivalTime;
if (plannedArrivalTime != null && predictedArrivalTime != null)
return predictedArrivalTime.getTime() - plannedArrivalTime.getTime();
else
return null;
}
public Long getArrivalDelay() {
final Date plannedArrivalTime = this.plannedArrivalTime;
final Date predictedArrivalTime = this.predictedArrivalTime;
if (plannedArrivalTime != null && predictedArrivalTime != null)
return predictedArrivalTime.getTime() - plannedArrivalTime.getTime();
else
return null;
}
public Position getArrivalPosition()
{
if (predictedArrivalPosition != null)
return predictedArrivalPosition;
else if (plannedArrivalPosition != null)
return plannedArrivalPosition;
else
return null;
}
public Position getArrivalPosition() {
if (predictedArrivalPosition != null)
return predictedArrivalPosition;
else if (plannedArrivalPosition != null)
return plannedArrivalPosition;
else
return null;
}
public boolean isArrivalPositionPredicted()
{
return predictedArrivalPosition != null;
}
public boolean isArrivalPositionPredicted() {
return predictedArrivalPosition != null;
}
public Date getDepartureTime()
{
return getDepartureTime(false);
}
public Date getDepartureTime() {
return getDepartureTime(false);
}
public Date getDepartureTime(final boolean preferPlanTime)
{
if (preferPlanTime && plannedDepartureTime != null)
return plannedDepartureTime;
else if (predictedDepartureTime != null)
return predictedDepartureTime;
else if (plannedDepartureTime != null)
return plannedDepartureTime;
else
return null;
}
public Date getDepartureTime(final boolean preferPlanTime) {
if (preferPlanTime && plannedDepartureTime != null)
return plannedDepartureTime;
else if (predictedDepartureTime != null)
return predictedDepartureTime;
else if (plannedDepartureTime != null)
return plannedDepartureTime;
else
return null;
}
public boolean isDepartureTimePredicted()
{
return isDepartureTimePredicted(false);
}
public boolean isDepartureTimePredicted() {
return isDepartureTimePredicted(false);
}
public boolean isDepartureTimePredicted(final boolean preferPlanTime)
{
if (preferPlanTime && plannedDepartureTime != null)
return false;
else
return predictedDepartureTime != null;
}
public boolean isDepartureTimePredicted(final boolean preferPlanTime) {
if (preferPlanTime && plannedDepartureTime != null)
return false;
else
return predictedDepartureTime != null;
}
public Long getDepartureDelay()
{
final Date plannedDepartureTime = this.plannedDepartureTime;
final Date predictedDepartureTime = this.predictedDepartureTime;
if (plannedDepartureTime != null && predictedDepartureTime != null)
return predictedDepartureTime.getTime() - plannedDepartureTime.getTime();
else
return null;
}
public Long getDepartureDelay() {
final Date plannedDepartureTime = this.plannedDepartureTime;
final Date predictedDepartureTime = this.predictedDepartureTime;
if (plannedDepartureTime != null && predictedDepartureTime != null)
return predictedDepartureTime.getTime() - plannedDepartureTime.getTime();
else
return null;
}
public Position getDeparturePosition()
{
if (predictedDeparturePosition != null)
return predictedDeparturePosition;
else if (plannedDeparturePosition != null)
return plannedDeparturePosition;
else
return null;
}
public Position getDeparturePosition() {
if (predictedDeparturePosition != null)
return predictedDeparturePosition;
else if (plannedDeparturePosition != null)
return plannedDeparturePosition;
else
return null;
}
public boolean isDeparturePositionPredicted()
{
return predictedDeparturePosition != null;
}
public boolean isDeparturePositionPredicted() {
return predictedDeparturePosition != null;
}
public Date getMinTime()
{
final Date predictedDepartureTime = this.predictedDepartureTime;
if (plannedDepartureTime == null || (predictedDepartureTime != null && predictedDepartureTime.before(plannedDepartureTime)))
return predictedDepartureTime;
else
return plannedDepartureTime;
}
public Date getMinTime() {
final Date predictedDepartureTime = this.predictedDepartureTime;
if (plannedDepartureTime == null
|| (predictedDepartureTime != null && predictedDepartureTime.before(plannedDepartureTime)))
return predictedDepartureTime;
else
return plannedDepartureTime;
}
public Date getMaxTime()
{
final Date predictedArrivalTime = this.predictedArrivalTime;
if (plannedArrivalTime == null || (predictedArrivalTime != null && predictedArrivalTime.after(plannedArrivalTime)))
return predictedArrivalTime;
else
return plannedArrivalTime;
}
public Date getMaxTime() {
final Date predictedArrivalTime = this.predictedArrivalTime;
if (plannedArrivalTime == null
|| (predictedArrivalTime != null && predictedArrivalTime.after(plannedArrivalTime)))
return predictedArrivalTime;
else
return plannedArrivalTime;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Stop))
return false;
final Stop other = (Stop) o;
if (!Objects.equal(this.location, other.location))
return false;
if (!Objects.equal(this.plannedArrivalTime, other.plannedArrivalTime))
return false;
if (!Objects.equal(this.predictedArrivalTime, other.predictedArrivalTime))
return false;
if (!Objects.equal(this.plannedArrivalPosition, other.plannedArrivalPosition))
return false;
if (!Objects.equal(this.predictedArrivalPosition, other.predictedArrivalPosition))
return false;
if (this.arrivalCancelled != other.arrivalCancelled)
return false;
if (!Objects.equal(this.plannedDepartureTime, other.plannedDepartureTime))
return false;
if (!Objects.equal(this.predictedDepartureTime, other.predictedDepartureTime))
return false;
if (!Objects.equal(this.plannedDeparturePosition, other.plannedDeparturePosition))
return false;
if (!Objects.equal(this.predictedDeparturePosition, other.predictedDeparturePosition))
return false;
if (this.departureCancelled != other.departureCancelled)
return false;
return true;
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof Stop))
return false;
final Stop other = (Stop) o;
if (!Objects.equal(this.location, other.location))
return false;
if (!Objects.equal(this.plannedArrivalTime, other.plannedArrivalTime))
return false;
if (!Objects.equal(this.predictedArrivalTime, other.predictedArrivalTime))
return false;
if (!Objects.equal(this.plannedArrivalPosition, other.plannedArrivalPosition))
return false;
if (!Objects.equal(this.predictedArrivalPosition, other.predictedArrivalPosition))
return false;
if (this.arrivalCancelled != other.arrivalCancelled)
return false;
if (!Objects.equal(this.plannedDepartureTime, other.plannedDepartureTime))
return false;
if (!Objects.equal(this.predictedDepartureTime, other.predictedDepartureTime))
return false;
if (!Objects.equal(this.plannedDeparturePosition, other.plannedDeparturePosition))
return false;
if (!Objects.equal(this.predictedDeparturePosition, other.predictedDeparturePosition))
return false;
if (this.departureCancelled != other.departureCancelled)
return false;
return true;
}
@Override
public int hashCode()
{
return Objects.hashCode(location, plannedArrivalTime, predictedArrivalTime, plannedArrivalPosition, predictedArrivalPosition,
arrivalCancelled, plannedDepartureTime, predictedDepartureTime, plannedDeparturePosition, predictedDeparturePosition,
departureCancelled);
}
@Override
public int hashCode() {
return Objects.hashCode(location, plannedArrivalTime, predictedArrivalTime, plannedArrivalPosition,
predictedArrivalPosition, arrivalCancelled, plannedDepartureTime, predictedDepartureTime,
plannedDeparturePosition, predictedDeparturePosition, departureCancelled);
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(location);
if (plannedArrivalTime != null)
helper.add("plannedArrivalTime", String.format(Locale.US, "%ta %<tR", plannedArrivalTime));
if (arrivalCancelled)
helper.addValue("cancelled");
else if (predictedArrivalTime != null)
helper.add("predictedArrivalTime", String.format(Locale.US, "%ta %<tR", predictedArrivalTime));
if (plannedDepartureTime != null)
helper.add("plannedDepartureTime", String.format(Locale.US, "%ta %<tR", plannedDepartureTime));
if (departureCancelled)
helper.addValue("cancelled");
else if (predictedDepartureTime != null)
helper.add("predictedDepartureTime", String.format(Locale.US, "%ta %<tR", predictedDepartureTime));
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(location);
if (plannedArrivalTime != null)
helper.add("plannedArrivalTime", String.format(Locale.US, "%ta %<tR", plannedArrivalTime));
if (arrivalCancelled)
helper.addValue("cancelled");
else if (predictedArrivalTime != null)
helper.add("predictedArrivalTime", String.format(Locale.US, "%ta %<tR", predictedArrivalTime));
if (plannedDepartureTime != null)
helper.add("plannedDepartureTime", String.format(Locale.US, "%ta %<tR", plannedDepartureTime));
if (departureCancelled)
helper.addValue("cancelled");
else if (predictedDepartureTime != null)
helper.add("predictedDepartureTime", String.format(Locale.US, "%ta %<tR", predictedDepartureTime));
return helper.toString();
}
}

View file

@ -25,142 +25,126 @@ import java.io.Serializable;
/**
* @author Andreas Schildbach
*/
public class Style implements Serializable
{
private static final long serialVersionUID = 7145603493425043304L;
public class Style implements Serializable {
private static final long serialVersionUID = 7145603493425043304L;
public final Shape shape;
public final int backgroundColor, backgroundColor2;
public final int foregroundColor;
public final int borderColor;
public final Shape shape;
public final int backgroundColor, backgroundColor2;
public final int foregroundColor;
public final int borderColor;
public enum Shape
{
RECT, ROUNDED, CIRCLE
}
public enum Shape {
RECT, ROUNDED, CIRCLE
}
public Style(final int backgroundColor, final int foregroundColor)
{
this.shape = Shape.ROUNDED;
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = 0;
}
public Style(final int backgroundColor, final int foregroundColor) {
this.shape = Shape.ROUNDED;
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = 0;
}
public Style(final Shape shape, final int backgroundColor, final int foregroundColor)
{
this.shape = checkNotNull(shape);
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = 0;
}
public Style(final Shape shape, final int backgroundColor, final int foregroundColor) {
this.shape = checkNotNull(shape);
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = 0;
}
public Style(final Shape shape, final int backgroundColor, final int foregroundColor, final int borderColor)
{
this.shape = checkNotNull(shape);
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final Shape shape, final int backgroundColor, final int foregroundColor, final int borderColor) {
this.shape = checkNotNull(shape);
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final Shape shape, final int backgroundColor, final int backgroundColor2, final int foregroundColor, final int borderColor)
{
this.shape = checkNotNull(shape);
this.backgroundColor = backgroundColor;
this.backgroundColor2 = backgroundColor2;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final Shape shape, final int backgroundColor, final int backgroundColor2, final int foregroundColor,
final int borderColor) {
this.shape = checkNotNull(shape);
this.backgroundColor = backgroundColor;
this.backgroundColor2 = backgroundColor2;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final int backgroundColor, final int foregroundColor, final int borderColor)
{
this.shape = Shape.ROUNDED;
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final int backgroundColor, final int foregroundColor, final int borderColor) {
this.shape = Shape.ROUNDED;
this.backgroundColor = backgroundColor;
this.backgroundColor2 = 0;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final int backgroundColor, final int backgroundColor2, final int foregroundColor, final int borderColor)
{
this.shape = Shape.ROUNDED;
this.backgroundColor = backgroundColor;
this.backgroundColor2 = backgroundColor2;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public Style(final int backgroundColor, final int backgroundColor2, final int foregroundColor,
final int borderColor) {
this.shape = Shape.ROUNDED;
this.backgroundColor = backgroundColor;
this.backgroundColor2 = backgroundColor2;
this.foregroundColor = foregroundColor;
this.borderColor = borderColor;
}
public final boolean hasBorder()
{
return borderColor != 0;
}
public final boolean hasBorder() {
return borderColor != 0;
}
public static final int BLACK = 0xFF000000;
public static final int DKGRAY = 0xFF444444;
public static final int GRAY = 0xFF888888;
public static final int LTGRAY = 0xFFCCCCCC;
public static final int WHITE = 0xFFFFFFFF;
public static final int RED = 0xFFFF0000;
public static final int GREEN = 0xFF00FF00;
public static final int BLUE = 0xFF0000FF;
public static final int YELLOW = 0xFFFFFF00;
public static final int CYAN = 0xFF00FFFF;
public static final int MAGENTA = 0xFFFF00FF;
public static final int TRANSPARENT = 0;
public static final int BLACK = 0xFF000000;
public static final int DKGRAY = 0xFF444444;
public static final int GRAY = 0xFF888888;
public static final int LTGRAY = 0xFFCCCCCC;
public static final int WHITE = 0xFFFFFFFF;
public static final int RED = 0xFFFF0000;
public static final int GREEN = 0xFF00FF00;
public static final int BLUE = 0xFF0000FF;
public static final int YELLOW = 0xFFFFFF00;
public static final int CYAN = 0xFF00FFFF;
public static final int MAGENTA = 0xFFFF00FF;
public static final int TRANSPARENT = 0;
public static int parseColor(final String colorStr)
{
checkNotNull(colorStr);
checkArgument((colorStr.length() == 7 || colorStr.length() == 9) && colorStr.charAt(0) == '#', "Unknown color: %s", colorStr);
try
{
// Use a long to avoid rollovers on #ffXXXXXX
long color = Long.parseLong(colorStr.substring(1), 16);
if (colorStr.length() == 7)
color |= 0xff000000; // Amend the alpha value
return (int) color;
}
catch (final NumberFormatException x)
{
throw new IllegalArgumentException("Not a number: " + colorStr);
}
}
public static int parseColor(final String colorStr) {
checkNotNull(colorStr);
checkArgument((colorStr.length() == 7 || colorStr.length() == 9) && colorStr.charAt(0) == '#',
"Unknown color: %s", colorStr);
try {
// Use a long to avoid rollovers on #ffXXXXXX
long color = Long.parseLong(colorStr.substring(1), 16);
if (colorStr.length() == 7)
color |= 0xff000000; // Amend the alpha value
return (int) color;
} catch (final NumberFormatException x) {
throw new IllegalArgumentException("Not a number: " + colorStr);
}
}
public static int rgb(final int red, final int green, final int blue)
{
return (0xFF << 24) | (red << 16) | (green << 8) | blue;
}
public static int rgb(final int red, final int green, final int blue) {
return (0xFF << 24) | (red << 16) | (green << 8) | blue;
}
public static int red(final int color)
{
return (color >> 16) & 0xff;
}
public static int red(final int color) {
return (color >> 16) & 0xff;
}
public static int green(final int color)
{
return (color >> 8) & 0xff;
}
public static int green(final int color) {
return (color >> 8) & 0xff;
}
public static int blue(final int color)
{
return color & 0xff;
}
public static int blue(final int color) {
return color & 0xff;
}
public static float perceivedBrightness(final int color)
{
// formula for perceived brightness computation: http://www.w3.org/TR/AERT#color-contrast
return (0.299f * Style.red(color) + 0.587f * Style.green(color) + 0.114f * Style.blue(color)) / 256;
}
public static float perceivedBrightness(final int color) {
// formula for perceived brightness computation: http://www.w3.org/TR/AERT#color-contrast
return (0.299f * Style.red(color) + 0.587f * Style.green(color) + 0.114f * Style.blue(color)) / 256;
}
public static int deriveForegroundColor(final int backgroundColor)
{
// dark colors, white font. Or light colors, black font
if (perceivedBrightness(backgroundColor) < 0.5)
return WHITE;
else
return BLACK;
}
public static int deriveForegroundColor(final int backgroundColor) {
// dark colors, white font. Or light colors, black font
if (perceivedBrightness(backgroundColor) < 0.5)
return WHITE;
else
return BLACK;
}
}

View file

@ -34,47 +34,41 @@ import com.google.common.base.MoreObjects.ToStringHelper;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class SuggestLocationsResult implements Serializable
{
public enum Status
{
OK, SERVICE_DOWN
}
public final class SuggestLocationsResult implements Serializable {
public enum Status {
OK, SERVICE_DOWN
}
public final @Nullable ResultHeader header;
public final Status status;
private final List<SuggestedLocation> suggestedLocations;
public final @Nullable ResultHeader header;
public final Status status;
private final List<SuggestedLocation> suggestedLocations;
public SuggestLocationsResult(final ResultHeader header, final List<SuggestedLocation> suggestedLocations)
{
this.header = header;
this.status = Status.OK;
this.suggestedLocations = new LinkedList<SuggestedLocation>(suggestedLocations);
Collections.sort(this.suggestedLocations);
}
public SuggestLocationsResult(final ResultHeader header, final List<SuggestedLocation> suggestedLocations) {
this.header = header;
this.status = Status.OK;
this.suggestedLocations = new LinkedList<SuggestedLocation>(suggestedLocations);
Collections.sort(this.suggestedLocations);
}
public SuggestLocationsResult(final ResultHeader header, final Status status)
{
this.header = header;
this.status = checkNotNull(status);
this.suggestedLocations = null;
}
public SuggestLocationsResult(final ResultHeader header, final Status status) {
this.header = header;
this.status = checkNotNull(status);
this.suggestedLocations = null;
}
public List<Location> getLocations()
{
final List<Location> locations = new ArrayList<Location>(suggestedLocations.size());
for (final SuggestedLocation location : suggestedLocations)
locations.add(location.location);
public List<Location> getLocations() {
final List<Location> locations = new ArrayList<Location>(suggestedLocations.size());
for (final SuggestedLocation location : suggestedLocations)
locations.add(location.location);
return locations;
}
return locations;
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (suggestedLocations != null)
helper.add("size", suggestedLocations.size()).add("suggestedLocations", suggestedLocations);
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(status);
if (suggestedLocations != null)
helper.add("size", suggestedLocations.size()).add("suggestedLocations", suggestedLocations);
return helper.toString();
}
}

View file

@ -27,58 +27,51 @@ import com.google.common.base.Objects;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public final class SuggestedLocation implements Serializable, Comparable<SuggestedLocation>
{
public final Location location;
public final int priority;
public final class SuggestedLocation implements Serializable, Comparable<SuggestedLocation> {
public final Location location;
public final int priority;
public SuggestedLocation(final Location location, final int priority)
{
this.location = checkNotNull(location);
this.priority = priority;
}
public SuggestedLocation(final Location location, final int priority) {
this.location = checkNotNull(location);
this.priority = priority;
}
public SuggestedLocation(final Location location)
{
this(location, 0);
}
public SuggestedLocation(final Location location) {
this(location, 0);
}
public int compareTo(final SuggestedLocation other)
{
// prefer quality
if (this.priority > other.priority)
return -1;
else if (this.priority < other.priority)
return 1;
public int compareTo(final SuggestedLocation other) {
// prefer quality
if (this.priority > other.priority)
return -1;
else if (this.priority < other.priority)
return 1;
// prefer stations
final int compareLocationType = this.location.type.compareTo(other.location.type);
if (compareLocationType != 0)
return compareLocationType;
// prefer stations
final int compareLocationType = this.location.type.compareTo(other.location.type);
if (compareLocationType != 0)
return compareLocationType;
return 0;
}
return 0;
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof SuggestedLocation))
return false;
final SuggestedLocation other = (SuggestedLocation) o;
return Objects.equal(this.location, other.location);
}
@Override
public boolean equals(final Object o) {
if (o == this)
return true;
if (!(o instanceof SuggestedLocation))
return false;
final SuggestedLocation other = (SuggestedLocation) o;
return Objects.equal(this.location, other.location);
}
@Override
public int hashCode()
{
return Objects.hashCode(location);
}
@Override
public int hashCode() {
return Objects.hashCode(location);
}
@Override
public String toString()
{
return priority + ":" + location;
}
@Override
public String toString() {
return priority + ":" + location;
}
}

View file

@ -36,457 +36,406 @@ import com.google.common.base.Objects;
/**
* @author Andreas Schildbach
*/
public final class Trip implements Serializable
{
private static final long serialVersionUID = 2508466068307110312L;
private String id;
public final Location from;
public final Location to;
public final List<Leg> legs;
public final List<Fare> fares;
public final int[] capacity;
public final Integer numChanges;
public Trip(final String id, final Location from, final Location to, final List<Leg> legs, final List<Fare> fares, final int[] capacity,
final Integer numChanges)
{
this.id = id;
this.from = checkNotNull(from);
this.to = checkNotNull(to);
this.legs = checkNotNull(legs);
this.fares = fares;
this.capacity = capacity;
this.numChanges = numChanges;
checkArgument(!legs.isEmpty());
}
public Date getFirstDepartureTime()
{
return legs.get(0).getDepartureTime();
}
public @Nullable Public getFirstPublicLeg()
{
for (final Leg leg : legs)
if (leg instanceof Public)
return (Public) leg;
return null;
}
public @Nullable Date getFirstPublicLegDepartureTime()
{
final Public firstPublicLeg = getFirstPublicLeg();
if (firstPublicLeg != null)
return firstPublicLeg.getDepartureTime();
else
return null;
}
public Date getLastArrivalTime()
{
return legs.get(legs.size() - 1).getArrivalTime();
}
public @Nullable Public getLastPublicLeg()
{
for (int i = legs.size() - 1; i >= 0; i--)
{
final Leg leg = legs.get(i);
if (leg instanceof Public)
return (Public) leg;
}
return null;
}
public @Nullable Date getLastPublicLegArrivalTime()
{
final Public lastPublicLeg = getLastPublicLeg();
if (lastPublicLeg != null)
return lastPublicLeg.getArrivalTime();
else
return null;
}
/**
* Duration of whole trip in milliseconds, including leading and trailing individual legs.
*
* @return duration in ms
*/
public long getDuration()
{
final Date first = getFirstDepartureTime();
final Date last = getLastArrivalTime();
return last.getTime() - first.getTime();
}
/**
* Duration of the public leg part in milliseconds. This includes individual legs between public legs, but excludes
* individual legs that lead or trail the trip.
*
* @return duration in ms, or null if there are no public legs
*/
public @Nullable Long getPublicDuration()
{
final Date first = getFirstPublicLegDepartureTime();
final Date last = getLastPublicLegArrivalTime();
if (first != null && last != null)
return last.getTime() - first.getTime();
else
return null;
}
/** Minimum time occuring in this trip. */
public Date getMinTime()
{
Date minTime = null;
for (final Leg leg : legs)
if (minTime == null || leg.getMinTime().before(minTime))
minTime = leg.getMinTime();
return minTime;
}
/** Maximum time occuring in this trip. */
public Date getMaxTime()
{
Date maxTime = null;
for (final Leg leg : legs)
if (maxTime == null || leg.getMaxTime().after(maxTime))
maxTime = leg.getMaxTime();
return maxTime;
}
/** Returns true if no legs overlap, false otherwise. */
public boolean isTravelable()
{
Date time = null;
for (final Leg leg : legs)
{
final Date departureTime = leg.getDepartureTime();
if (time != null && departureTime.before(time))
return false;
time = departureTime;
final Date arrivalTime = leg.getArrivalTime();
if (time != null && arrivalTime.before(time))
return false;
time = arrivalTime;
}
return true;
}
/** If an individual leg overlaps, try to adjust so that it doesn't. */
public void adjustUntravelableIndividualLegs()
{
final int numLegs = legs.size();
if (numLegs < 1)
return;
for (int i = 1; i < numLegs; i++)
{
final Trip.Leg leg = legs.get(i);
if (leg instanceof Trip.Individual)
{
final Trip.Leg previous = legs.get(i - 1);
if (leg.getDepartureTime().before(previous.getArrivalTime()))
legs.set(i, ((Trip.Individual) leg).movedClone(previous.getArrivalTime()));
}
}
}
public Set<Product> products()
{
final Set<Product> products = EnumSet.noneOf(Product.class);
for (final Leg leg : legs)
if (leg instanceof Public)
products.add(((Public) leg).line.product);
return products;
}
public String getId()
{
if (id == null)
id = buildSubstituteId();
return id;
}
private String buildSubstituteId()
{
final StringBuilder builder = new StringBuilder();
for (final Leg leg : legs)
{
builder.append(leg.departure.hasId() ? leg.departure.id : leg.departure.lat + '/' + leg.departure.lon).append('-');
builder.append(leg.arrival.hasId() ? leg.arrival.id : leg.arrival.lat + '/' + leg.arrival.lon).append('-');
if (leg instanceof Individual)
{
builder.append(((Individual) leg).min);
}
else if (leg instanceof Public)
{
final Public publicLeg = (Public) leg;
final Date plannedDepartureTime = publicLeg.departureStop.plannedDepartureTime;
if (plannedDepartureTime != null)
builder.append(plannedDepartureTime.getTime()).append('-');
final Date plannedArrivalTime = publicLeg.arrivalStop.plannedArrivalTime;
if (plannedArrivalTime != null)
builder.append(plannedArrivalTime.getTime()).append('-');
final Line line = publicLeg.line;
builder.append(line.productCode());
builder.append(line.label);
}
builder.append('|');
}
builder.setLength(builder.length() - 1);
return builder.toString();
}
@Override
public boolean equals(Object o)
{
if (o == this)
return true;
if (!(o instanceof Trip))
return false;
final Trip other = (Trip) o;
return Objects.equal(this.getId(), other.getId());
}
@Override
public int hashCode()
{
return Objects.hashCode(getId());
}
@Override
public String toString()
{
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(getId());
final Date firstPublicLegDepartureTime = getFirstPublicLegDepartureTime();
final Date lastPublicLegArrivalTime = getLastPublicLegArrivalTime();
helper.addValue(firstPublicLegDepartureTime != null ? String.format(Locale.US, "%ta %<tR", firstPublicLegDepartureTime) : "null" + '-'
+ lastPublicLegArrivalTime != null ? String.format(Locale.US, "%ta %<tR", lastPublicLegArrivalTime) : "null");
helper.add("numChanges", numChanges);
return helper.toString();
}
public abstract static class Leg implements Serializable
{
private static final long serialVersionUID = 8498461220084523265L;
public final Location departure;
public final Location arrival;
public List<Point> path;
public Leg(final Location departure, final Location arrival, final List<Point> path)
{
this.departure = checkNotNull(departure);
this.arrival = checkNotNull(arrival);
this.path = path;
}
/** Coarse departure time. */
public abstract Date getDepartureTime();
/** Coarse arrival time. */
public abstract Date getArrivalTime();
/** Minimum time occuring in this leg. */
public abstract Date getMinTime();
/** Maximum time occuring in this leg. */
public abstract Date getMaxTime();
}
public final static class Public extends Leg
{
private static final long serialVersionUID = 1312066446239817422L;
public final Line line;
public final @Nullable Location destination;
public final Stop departureStop;
public final Stop arrivalStop;
public final @Nullable List<Stop> intermediateStops;
public final @Nullable String message;
public Public(final Line line, final Location destination, final Stop departureStop, final Stop arrivalStop,
final List<Stop> intermediateStops, final List<Point> path, final String message)
{
super(departureStop.location, arrivalStop.location, path);
this.line = checkNotNull(line);
this.destination = destination;
this.departureStop = checkNotNull(departureStop);
this.arrivalStop = checkNotNull(arrivalStop);
this.intermediateStops = intermediateStops;
this.message = message;
checkNotNull(departureStop.getDepartureTime());
checkNotNull(arrivalStop.getArrivalTime());
}
@Override
public Date getDepartureTime()
{
return departureStop.getDepartureTime(false);
}
public Date getDepartureTime(final boolean preferPlanTime)
{
return departureStop.getDepartureTime(preferPlanTime);
}
public boolean isDepartureTimePredicted()
{
return departureStop.isDepartureTimePredicted(false);
}
public Long getDepartureDelay()
{
return departureStop.getDepartureDelay();
}
public Position getDeparturePosition()
{
return departureStop.getDeparturePosition();
}
public boolean isDeparturePositionPredicted()
{
return departureStop.isDeparturePositionPredicted();
}
@Override
public Date getArrivalTime()
{
return arrivalStop.getArrivalTime(false);
}
public Date getArrivalTime(final boolean preferPlanTime)
{
return arrivalStop.getArrivalTime(preferPlanTime);
}
public boolean isArrivalTimePredicted()
{
return arrivalStop.isArrivalTimePredicted(false);
}
public Long getArrivalDelay()
{
return arrivalStop.getArrivalDelay();
}
public Position getArrivalPosition()
{
return arrivalStop.getArrivalPosition();
}
public boolean isArrivalPositionPredicted()
{
return arrivalStop.isArrivalPositionPredicted();
}
@Override
public Date getMinTime()
{
return departureStop.getMinTime();
}
@Override
public Date getMaxTime()
{
return arrivalStop.getMaxTime();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this).add("line", line).add("destination", destination).add("departureStop", departureStop)
.add("arrivalStop", arrivalStop).omitNullValues().toString();
}
}
public final static class Individual extends Leg
{
public enum Type
{
WALK, BIKE, CAR, TRANSFER
}
private static final long serialVersionUID = -6651381862837233925L;
public final Type type;
public final Date departureTime;
public final Date arrivalTime;
public final int min;
public final int distance;
public Individual(final Type type, final Location departure, final Date departureTime, final Location arrival, final Date arrivalTime,
final List<Point> path, final int distance)
{
super(departure, arrival, path);
this.type = checkNotNull(type);
this.departureTime = checkNotNull(departureTime);
this.arrivalTime = checkNotNull(arrivalTime);
this.min = (int) ((arrivalTime.getTime() - departureTime.getTime()) / 1000 / 60);
this.distance = distance;
}
public Individual movedClone(final Date departureTime)
{
final Date arrivalTime = new Date(departureTime.getTime() + this.arrivalTime.getTime() - this.departureTime.getTime());
return new Trip.Individual(this.type, this.departure, departureTime, this.arrival, arrivalTime, this.path, this.distance);
}
@Override
public Date getDepartureTime()
{
return departureTime;
}
@Override
public Date getArrivalTime()
{
return arrivalTime;
}
@Override
public Date getMinTime()
{
return departureTime;
}
@Override
public Date getMaxTime()
{
return arrivalTime;
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this).addValue(type).add("departure", departure).add("arrival", arrival).add("min", min)
.add("distance", distance).omitNullValues().toString();
}
}
public final class Trip implements Serializable {
private static final long serialVersionUID = 2508466068307110312L;
private String id;
public final Location from;
public final Location to;
public final List<Leg> legs;
public final List<Fare> fares;
public final int[] capacity;
public final Integer numChanges;
public Trip(final String id, final Location from, final Location to, final List<Leg> legs, final List<Fare> fares,
final int[] capacity, final Integer numChanges) {
this.id = id;
this.from = checkNotNull(from);
this.to = checkNotNull(to);
this.legs = checkNotNull(legs);
this.fares = fares;
this.capacity = capacity;
this.numChanges = numChanges;
checkArgument(!legs.isEmpty());
}
public Date getFirstDepartureTime() {
return legs.get(0).getDepartureTime();
}
public @Nullable Public getFirstPublicLeg() {
for (final Leg leg : legs)
if (leg instanceof Public)
return (Public) leg;
return null;
}
public @Nullable Date getFirstPublicLegDepartureTime() {
final Public firstPublicLeg = getFirstPublicLeg();
if (firstPublicLeg != null)
return firstPublicLeg.getDepartureTime();
else
return null;
}
public Date getLastArrivalTime() {
return legs.get(legs.size() - 1).getArrivalTime();
}
public @Nullable Public getLastPublicLeg() {
for (int i = legs.size() - 1; i >= 0; i--) {
final Leg leg = legs.get(i);
if (leg instanceof Public)
return (Public) leg;
}
return null;
}
public @Nullable Date getLastPublicLegArrivalTime() {
final Public lastPublicLeg = getLastPublicLeg();
if (lastPublicLeg != null)
return lastPublicLeg.getArrivalTime();
else
return null;
}
/**
* Duration of whole trip in milliseconds, including leading and trailing individual legs.
*
* @return duration in ms
*/
public long getDuration() {
final Date first = getFirstDepartureTime();
final Date last = getLastArrivalTime();
return last.getTime() - first.getTime();
}
/**
* Duration of the public leg part in milliseconds. This includes individual legs between public legs, but
* excludes individual legs that lead or trail the trip.
*
* @return duration in ms, or null if there are no public legs
*/
public @Nullable Long getPublicDuration() {
final Date first = getFirstPublicLegDepartureTime();
final Date last = getLastPublicLegArrivalTime();
if (first != null && last != null)
return last.getTime() - first.getTime();
else
return null;
}
/** Minimum time occuring in this trip. */
public Date getMinTime() {
Date minTime = null;
for (final Leg leg : legs)
if (minTime == null || leg.getMinTime().before(minTime))
minTime = leg.getMinTime();
return minTime;
}
/** Maximum time occuring in this trip. */
public Date getMaxTime() {
Date maxTime = null;
for (final Leg leg : legs)
if (maxTime == null || leg.getMaxTime().after(maxTime))
maxTime = leg.getMaxTime();
return maxTime;
}
/** Returns true if no legs overlap, false otherwise. */
public boolean isTravelable() {
Date time = null;
for (final Leg leg : legs) {
final Date departureTime = leg.getDepartureTime();
if (time != null && departureTime.before(time))
return false;
time = departureTime;
final Date arrivalTime = leg.getArrivalTime();
if (time != null && arrivalTime.before(time))
return false;
time = arrivalTime;
}
return true;
}
/** If an individual leg overlaps, try to adjust so that it doesn't. */
public void adjustUntravelableIndividualLegs() {
final int numLegs = legs.size();
if (numLegs < 1)
return;
for (int i = 1; i < numLegs; i++) {
final Trip.Leg leg = legs.get(i);
if (leg instanceof Trip.Individual) {
final Trip.Leg previous = legs.get(i - 1);
if (leg.getDepartureTime().before(previous.getArrivalTime()))
legs.set(i, ((Trip.Individual) leg).movedClone(previous.getArrivalTime()));
}
}
}
public Set<Product> products() {
final Set<Product> products = EnumSet.noneOf(Product.class);
for (final Leg leg : legs)
if (leg instanceof Public)
products.add(((Public) leg).line.product);
return products;
}
public String getId() {
if (id == null)
id = buildSubstituteId();
return id;
}
private String buildSubstituteId() {
final StringBuilder builder = new StringBuilder();
for (final Leg leg : legs) {
builder.append(leg.departure.hasId() ? leg.departure.id : leg.departure.lat + '/' + leg.departure.lon)
.append('-');
builder.append(leg.arrival.hasId() ? leg.arrival.id : leg.arrival.lat + '/' + leg.arrival.lon).append('-');
if (leg instanceof Individual) {
builder.append(((Individual) leg).min);
} else if (leg instanceof Public) {
final Public publicLeg = (Public) leg;
final Date plannedDepartureTime = publicLeg.departureStop.plannedDepartureTime;
if (plannedDepartureTime != null)
builder.append(plannedDepartureTime.getTime()).append('-');
final Date plannedArrivalTime = publicLeg.arrivalStop.plannedArrivalTime;
if (plannedArrivalTime != null)
builder.append(plannedArrivalTime.getTime()).append('-');
final Line line = publicLeg.line;
builder.append(line.productCode());
builder.append(line.label);
}
builder.append('|');
}
builder.setLength(builder.length() - 1);
return builder.toString();
}
@Override
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof Trip))
return false;
final Trip other = (Trip) o;
return Objects.equal(this.getId(), other.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(getId());
final Date firstPublicLegDepartureTime = getFirstPublicLegDepartureTime();
final Date lastPublicLegArrivalTime = getLastPublicLegArrivalTime();
helper.addValue(
firstPublicLegDepartureTime != null ? String.format(Locale.US, "%ta %<tR", firstPublicLegDepartureTime)
: "null" + '-' + lastPublicLegArrivalTime != null
? String.format(Locale.US, "%ta %<tR", lastPublicLegArrivalTime) : "null");
helper.add("numChanges", numChanges);
return helper.toString();
}
public abstract static class Leg implements Serializable {
private static final long serialVersionUID = 8498461220084523265L;
public final Location departure;
public final Location arrival;
public List<Point> path;
public Leg(final Location departure, final Location arrival, final List<Point> path) {
this.departure = checkNotNull(departure);
this.arrival = checkNotNull(arrival);
this.path = path;
}
/** Coarse departure time. */
public abstract Date getDepartureTime();
/** Coarse arrival time. */
public abstract Date getArrivalTime();
/** Minimum time occuring in this leg. */
public abstract Date getMinTime();
/** Maximum time occuring in this leg. */
public abstract Date getMaxTime();
}
public final static class Public extends Leg {
private static final long serialVersionUID = 1312066446239817422L;
public final Line line;
public final @Nullable Location destination;
public final Stop departureStop;
public final Stop arrivalStop;
public final @Nullable List<Stop> intermediateStops;
public final @Nullable String message;
public Public(final Line line, final Location destination, final Stop departureStop, final Stop arrivalStop,
final List<Stop> intermediateStops, final List<Point> path, final String message) {
super(departureStop.location, arrivalStop.location, path);
this.line = checkNotNull(line);
this.destination = destination;
this.departureStop = checkNotNull(departureStop);
this.arrivalStop = checkNotNull(arrivalStop);
this.intermediateStops = intermediateStops;
this.message = message;
checkNotNull(departureStop.getDepartureTime());
checkNotNull(arrivalStop.getArrivalTime());
}
@Override
public Date getDepartureTime() {
return departureStop.getDepartureTime(false);
}
public Date getDepartureTime(final boolean preferPlanTime) {
return departureStop.getDepartureTime(preferPlanTime);
}
public boolean isDepartureTimePredicted() {
return departureStop.isDepartureTimePredicted(false);
}
public Long getDepartureDelay() {
return departureStop.getDepartureDelay();
}
public Position getDeparturePosition() {
return departureStop.getDeparturePosition();
}
public boolean isDeparturePositionPredicted() {
return departureStop.isDeparturePositionPredicted();
}
@Override
public Date getArrivalTime() {
return arrivalStop.getArrivalTime(false);
}
public Date getArrivalTime(final boolean preferPlanTime) {
return arrivalStop.getArrivalTime(preferPlanTime);
}
public boolean isArrivalTimePredicted() {
return arrivalStop.isArrivalTimePredicted(false);
}
public Long getArrivalDelay() {
return arrivalStop.getArrivalDelay();
}
public Position getArrivalPosition() {
return arrivalStop.getArrivalPosition();
}
public boolean isArrivalPositionPredicted() {
return arrivalStop.isArrivalPositionPredicted();
}
@Override
public Date getMinTime() {
return departureStop.getMinTime();
}
@Override
public Date getMaxTime() {
return arrivalStop.getMaxTime();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("line", line).add("destination", destination)
.add("departureStop", departureStop).add("arrivalStop", arrivalStop).omitNullValues().toString();
}
}
public final static class Individual extends Leg {
public enum Type {
WALK, BIKE, CAR, TRANSFER
}
private static final long serialVersionUID = -6651381862837233925L;
public final Type type;
public final Date departureTime;
public final Date arrivalTime;
public final int min;
public final int distance;
public Individual(final Type type, final Location departure, final Date departureTime, final Location arrival,
final Date arrivalTime, final List<Point> path, final int distance) {
super(departure, arrival, path);
this.type = checkNotNull(type);
this.departureTime = checkNotNull(departureTime);
this.arrivalTime = checkNotNull(arrivalTime);
this.min = (int) ((arrivalTime.getTime() - departureTime.getTime()) / 1000 / 60);
this.distance = distance;
}
public Individual movedClone(final Date departureTime) {
final Date arrivalTime = new Date(
departureTime.getTime() + this.arrivalTime.getTime() - this.departureTime.getTime());
return new Trip.Individual(this.type, this.departure, departureTime, this.arrival, arrivalTime, this.path,
this.distance);
}
@Override
public Date getDepartureTime() {
return departureTime;
}
@Override
public Date getArrivalTime() {
return arrivalTime;
}
@Override
public Date getMinTime() {
return departureTime;
}
@Override
public Date getMaxTime() {
return arrivalTime;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).addValue(type).add("departure", departure).add("arrival", arrival)
.add("min", min).add("distance", distance).omitNullValues().toString();
}
}
}

View file

@ -27,42 +27,36 @@ import de.schildbach.pte.util.HttpClient;
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public abstract class AbstractHttpException extends IOException
{
private final URL url;
private final Reader errorReader;
public abstract class AbstractHttpException extends IOException {
private final URL url;
private final Reader errorReader;
public AbstractHttpException(final URL url)
{
this(url, null);
}
public AbstractHttpException(final URL url) {
this(url, null);
}
public AbstractHttpException(final URL url, final Reader errorReader)
{
super(url.toString());
this.url = url;
this.errorReader = errorReader;
}
public AbstractHttpException(final URL url, final Reader errorReader) {
super(url.toString());
this.url = url;
this.errorReader = errorReader;
}
public URL getUrl()
{
return url;
}
public URL getUrl() {
return url;
}
public Reader getErrorReader()
{
return errorReader;
}
public Reader getErrorReader() {
return errorReader;
}
public CharSequence scrapeErrorStream() throws IOException
{
if (errorReader == null)
return null;
public CharSequence scrapeErrorStream() throws IOException {
if (errorReader == null)
return null;
final StringBuilder error = new StringBuilder(HttpClient.SCRAPE_INITIAL_CAPACITY);
HttpClient.copy(errorReader, error);
errorReader.close();
final StringBuilder error = new StringBuilder(HttpClient.SCRAPE_INITIAL_CAPACITY);
HttpClient.copy(errorReader, error);
errorReader.close();
return error;
}
return error;
}
}

Some files were not shown because too many files have changed in this diff Show more