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

View file

@ -33,113 +33,108 @@ import de.schildbach.pte.dto.Style;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class AvvProvider extends AbstractEfaProvider public class AvvProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "https://efa.avv-augsburg.de/avv2/";
private final static String API_BASE = "https://efa.avv-augsburg.de/avv2/";
public AvvProvider() public AvvProvider() {
{ super(NetworkId.AVV, API_BASE);
super(NetworkId.AVV, API_BASE);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
} }
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); optimize, walkSpeed, accessibility, options));
uri.append("&inclMOT_11=on"); // night bus uri.append("&inclMOT_11=on"); // night bus
uri.append("&inclMOT_13=on"); uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on"); uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on"); uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on"); uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on"); uri.append("&inclMOT_17=on");
return uri.toString(); return uri.toString();
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("Regionalbahn".equals(trainName) && symbol != null)
{ return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Regionalbahn".equals(trainName) && symbol != null) if ("Staudenbahn SVG".equals(trainNum) && trainType == null && trainName == null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, "SVG");
if ("Staudenbahn SVG".equals(trainNum) && trainType == null && trainName == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "SVG");
// Streikfahrplan // Streikfahrplan
if ("R1S".equals(symbol)) if ("R1S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R4S".equals(symbol)) if ("R4S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R6S".equals(symbol)) if ("R6S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R7S".equals(symbol)) if ("R7S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("R8S".equals(symbol)) if ("R8S".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, 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 static {
{ STYLES.put("B", new Style(Style.Shape.CIRCLE, Style.parseColor("#abb1b1"), Style.BLACK));
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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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 * @author Andreas Schildbach
*/ */
public final class BahnProvider extends AbstractHafasProvider public final class BahnProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "https://reiseauskunft.bahn.de/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND, null, null, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND, null, null, null, null };
null, null };
public BahnProvider() public BahnProvider() {
{ super(NetworkId.DB, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.DB, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardEndpoint("https://mobile.bahn.de/bin/mobil/bhftafel.exe/dn"); setStationBoardEndpoint("https://mobile.bahn.de/bin/mobil/bhftafel.exe/dn");
setStationBoardHasStationTable(false); setStationBoardHasStationTable(false);
setJsonGetStopsUseWeight(false); setJsonGetStopsUseWeight(false);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name);
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name); if (m.matches())
if (m.matches()) return new String[] { m.group(2), m.group(1) };
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
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 @Override
protected String normalizeLineName(final String lineName) protected String normalizeLineName(final String lineName) {
{ final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName);
final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName); if (mTram.matches())
if (mTram.matches()) return mTram.group(1);
return mTram.group(1);
return super.normalizeLineName(lineName); return super.normalizeLineName(lineName);
} }
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("N".equals(ucType)) if ("N".equals(ucType))
return null; 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 * @author Andreas Schildbach
*/ */
public class BayernProvider extends AbstractEfaProvider public class BayernProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://mobile.defas-fgi.de/beg/";
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 DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2"; private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
private static final String STOP_FINDER_ENDPOINT = "XML_STOPFINDER_REQUEST"; private static final String STOP_FINDER_ENDPOINT = "XML_STOPFINDER_REQUEST";
public BayernProvider() public BayernProvider() {
{ super(NetworkId.BAYERN, API_BASE, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, STOP_FINDER_ENDPOINT, null);
super(NetworkId.BAYERN, API_BASE, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, STOP_FINDER_ENDPOINT, null);
setRequestUrlEncoding(Charsets.UTF_8); setRequestUrlEncoding(Charsets.UTF_8);
setIncludeRegionId(false); setIncludeRegionId(false);
setNumTripsRequested(12); setNumTripsRequested(12);
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
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 ("M".equals(trainType) && trainNum != null && trainName != null && trainName.endsWith("Meridian")) if ("ZUG".equals(trainType) && trainNum != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "M" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, trainNum);
if ("ZUG".equals(trainType) && trainNum != null) } else if ("1".equals(mot)) {
return new Line(id, network, Product.REGIONAL_TRAIN, trainNum); if ("ABR".equals(trainType) || "ABELLIO Rail NRW GmbH".equals(trainName))
} return new Line(id, network, Product.SUBURBAN_TRAIN, "ABR" + trainNum);
else if ("1".equals(mot)) if ("SBB".equals(trainType) || "SBB GmbH".equals(trainName))
{ return new Line(id, network, Product.REGIONAL_TRAIN, "SBB" + Strings.nullToEmpty(trainNum));
if ("ABR".equals(trainType) || "ABELLIO Rail NRW GmbH".equals(trainName)) } else if ("5".equals(mot)) {
return new Line(id, network, Product.SUBURBAN_TRAIN, "ABR" + trainNum); if (name != null && name.startsWith("Stadtbus Linie ")) // Lindau
if ("SBB".equals(trainType) || "SBB GmbH".equals(trainName)) return super.parseLine(id, network, mot, symbol, name.substring(15), longName, trainType, trainNum,
return new Line(id, network, Product.REGIONAL_TRAIN, "SBB" + Strings.nullToEmpty(trainNum)); trainName);
} else
else if ("5".equals(mot)) return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName);
{ } else if ("16".equals(mot)) {
if (name != null && name.startsWith("Stadtbus Linie ")) // Lindau if ("EC".equals(trainType) && trainNum != null)
return super.parseLine(id, network, mot, symbol, name.substring(15), longName, trainType, trainNum, trainName); return new Line(id, network, Product.HIGH_SPEED_TRAIN, "EC" + trainNum);
else if ("IC".equals(trainType) && trainNum != null)
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName); return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC" + trainNum);
} if ("ICE".equals(trainType) && trainNum != null)
else if ("16".equals(mot)) return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE" + trainNum);
{ if ("CNL".equals(trainType) && trainNum != null)
if ("EC".equals(trainType) && trainNum != null) return new Line(id, network, Product.HIGH_SPEED_TRAIN, "CNL" + trainNum);
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "EC" + trainNum); if ("THA".equals(trainType) && trainNum != null) // Thalys
if ("IC".equals(trainType) && trainNum != null) return new Line(id, network, Product.HIGH_SPEED_TRAIN, "THA" + trainNum);
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC" + trainNum); if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse
if ("ICE".equals(trainType) && trainNum != null) return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TGV" + trainNum);
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE" + trainNum); if ("RJ".equals(trainType) && trainNum != null) // railjet
if ("CNL".equals(trainType) && trainNum != null) return new Line(id, network, Product.HIGH_SPEED_TRAIN, "RJ" + trainNum);
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "CNL" + trainNum); if ("WB".equals(trainType) && trainNum != null) // WESTbahn
if ("THA".equals(trainType) && trainNum != null) // Thalys return new Line(id, network, Product.HIGH_SPEED_TRAIN, "WB" + trainNum);
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "THA" + trainNum); if ("HKX".equals(trainType) && trainNum != null) // Hamburg-Köln-Express
if ("TGV".equals(trainType) && trainNum != null) // Train a grande Vitesse return new Line(id, network, Product.HIGH_SPEED_TRAIN, "HKX" + trainNum);
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TGV" + trainNum); if ("D".equals(trainType) && trainNum != null) // Schnellzug
if ("RJ".equals(trainType) && trainNum != null) // railjet return new Line(id, network, Product.HIGH_SPEED_TRAIN, "D" + trainNum);
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 if ("IR".equals(trainType) && trainNum != null) // InterRegio
return new Line(id, network, Product.REGIONAL_TRAIN, "IR" + trainNum); 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 @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation())
if (location.hasLocation()) return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations);
return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations);
if (location.type != LocationType.STATION) if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type); throw new IllegalArgumentException("cannot handle: " + location.type);
throw new IllegalArgumentException("station"); // TODO throw new IllegalArgumentException("station"); // TODO
} }
@Override @Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
throws IOException final int maxDepartures, final boolean equivs) throws IOException {
{ checkNotNull(Strings.emptyToNull(stationId));
checkNotNull(Strings.emptyToNull(stationId));
return queryDeparturesMobile(stationId, time, maxDepartures, equivs); return queryDeparturesMobile(stationId, time, maxDepartures, equivs);
} }
@Override @Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
{ return mobileStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString()));
return mobileStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString())); }
}
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); optimize, walkSpeed, accessibility, options));
if (products != null) if (products != null) {
{ for (final Product p : products) {
for (final Product p : products) if (p == Product.HIGH_SPEED_TRAIN)
{ uri.append("&inclMOT_15=on&inclMOT_16=on");
if (p == Product.HIGH_SPEED_TRAIN)
uri.append("&inclMOT_15=on&inclMOT_16=on");
if (p == Product.REGIONAL_TRAIN) if (p == Product.REGIONAL_TRAIN)
uri.append("&inclMOT_13=on"); uri.append("&inclMOT_13=on");
} }
} }
uri.append("&inclMOT_11=on"); uri.append("&inclMOT_11=on");
uri.append("&inclMOT_14=on"); uri.append("&inclMOT_14=on");
uri.append("&calcOneDirection=1"); uri.append("&calcOneDirection=1");
return uri.toString(); return uri.toString();
} }
@Override @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException {
{ return queryMoreTripsMobile(contextObj, later);
return queryMoreTripsMobile(contextObj, later); }
}
} }

View file

@ -34,102 +34,99 @@ import de.schildbach.pte.dto.Style;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class BsvagProvider extends AbstractEfaProvider public class BsvagProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://bsvg.efa.de/bsvagstd/";
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() public BsvagProvider() {
{ super(NetworkId.BSVAG, API_BASE);
super(NetworkId.BSVAG, API_BASE);
setRequestUrlEncoding(Charsets.UTF_8); setRequestUrlEncoding(Charsets.UTF_8);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
setSessionCookieName("HASESSIONID"); setSessionCookieName("HASESSIONID");
} }
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); 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 static {
{ // Braunschweig
// Braunschweig STYLES.put("TM1", new Style(Style.parseColor("#62c2a2"), Style.WHITE));
STYLES.put("TM1", new Style(Style.parseColor("#62c2a2"), Style.WHITE)); STYLES.put("TM2", new Style(Style.parseColor("#b35e89"), Style.WHITE));
STYLES.put("TM2", new Style(Style.parseColor("#b35e89"), Style.WHITE)); STYLES.put("TM3", new Style(Style.parseColor("#f9b5b9"), Style.WHITE));
STYLES.put("TM3", new Style(Style.parseColor("#f9b5b9"), Style.WHITE)); STYLES.put("TM4", new Style(Style.parseColor("#811114"), Style.WHITE));
STYLES.put("TM4", new Style(Style.parseColor("#811114"), Style.WHITE)); STYLES.put("TM5", new Style(Style.parseColor("#ffd00b"), Style.WHITE));
STYLES.put("TM5", new Style(Style.parseColor("#ffd00b"), Style.WHITE));
STYLES.put("BM11", new Style(Style.parseColor("#88891e"), Style.WHITE)); STYLES.put("BM11", new Style(Style.parseColor("#88891e"), Style.WHITE));
STYLES.put("BM13", new Style(Style.parseColor("#24a06d"), Style.WHITE)); STYLES.put("BM13", new Style(Style.parseColor("#24a06d"), Style.WHITE));
STYLES.put("BM16", new Style(Style.parseColor("#f8991b"), Style.WHITE)); STYLES.put("BM16", new Style(Style.parseColor("#f8991b"), Style.WHITE));
STYLES.put("BM19", new Style(Style.parseColor("#2c2768"), Style.WHITE)); STYLES.put("BM19", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("BM29", 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("B412", new Style(Style.parseColor("#094f34"), Style.WHITE));
STYLES.put("B414", new Style(Style.parseColor("#00bce4"), Style.WHITE)); STYLES.put("B414", new Style(Style.parseColor("#00bce4"), Style.WHITE));
STYLES.put("B415", new Style(Style.parseColor("#b82837"), Style.WHITE)); STYLES.put("B415", new Style(Style.parseColor("#b82837"), Style.WHITE));
STYLES.put("B417", new Style(Style.parseColor("#2a2768"), Style.WHITE)); STYLES.put("B417", new Style(Style.parseColor("#2a2768"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#c12056"), Style.WHITE)); STYLES.put("B418", new Style(Style.parseColor("#c12056"), Style.WHITE));
STYLES.put("B420", new Style(Style.parseColor("#b7d55b"), Style.WHITE)); STYLES.put("B420", new Style(Style.parseColor("#b7d55b"), Style.WHITE));
STYLES.put("B422", new Style(Style.parseColor("#16bce4"), Style.WHITE)); STYLES.put("B422", new Style(Style.parseColor("#16bce4"), Style.WHITE));
STYLES.put("B424", new Style(Style.parseColor("#ffdf65"), Style.WHITE)); STYLES.put("B424", new Style(Style.parseColor("#ffdf65"), Style.WHITE));
STYLES.put("B427", new Style(Style.parseColor("#b5d55b"), Style.WHITE)); STYLES.put("B427", new Style(Style.parseColor("#b5d55b"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#fddb62"), Style.WHITE)); STYLES.put("B431", new Style(Style.parseColor("#fddb62"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#ed0e65"), Style.WHITE)); STYLES.put("B433", new Style(Style.parseColor("#ed0e65"), Style.WHITE));
STYLES.put("B434", new Style(Style.parseColor("#bf2555"), Style.WHITE)); STYLES.put("B434", new Style(Style.parseColor("#bf2555"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#0080a2"), Style.WHITE)); STYLES.put("B436", new Style(Style.parseColor("#0080a2"), Style.WHITE));
STYLES.put("B437", new Style(Style.parseColor("#fdd11a"), Style.WHITE)); STYLES.put("B437", new Style(Style.parseColor("#fdd11a"), Style.WHITE));
STYLES.put("B442", new Style(Style.parseColor("#cc3f68"), Style.WHITE)); STYLES.put("B442", new Style(Style.parseColor("#cc3f68"), Style.WHITE));
STYLES.put("B443", new Style(Style.parseColor("#405a80"), Style.WHITE)); STYLES.put("B443", new Style(Style.parseColor("#405a80"), Style.WHITE));
STYLES.put("B445", new Style(Style.parseColor("#3ca14a"), Style.WHITE)); STYLES.put("B445", new Style(Style.parseColor("#3ca14a"), Style.WHITE));
STYLES.put("B450", new Style(Style.parseColor("#f2635a"), Style.WHITE)); STYLES.put("B450", new Style(Style.parseColor("#f2635a"), Style.WHITE));
STYLES.put("B451", new Style(Style.parseColor("#f5791e"), Style.WHITE)); STYLES.put("B451", new Style(Style.parseColor("#f5791e"), Style.WHITE));
STYLES.put("B452", new Style(Style.parseColor("#f0a3ca"), Style.WHITE)); STYLES.put("B452", new Style(Style.parseColor("#f0a3ca"), Style.WHITE));
STYLES.put("B455", new Style(Style.parseColor("#395f95"), Style.WHITE)); STYLES.put("B455", new Style(Style.parseColor("#395f95"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#00b8a0"), Style.WHITE)); STYLES.put("B461", new Style(Style.parseColor("#00b8a0"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#00a14b"), Style.WHITE)); STYLES.put("B464", new Style(Style.parseColor("#00a14b"), Style.WHITE));
STYLES.put("B465", new Style(Style.parseColor("#77234b"), Style.WHITE)); STYLES.put("B465", new Style(Style.parseColor("#77234b"), Style.WHITE));
STYLES.put("B471", new Style(Style.parseColor("#380559"), Style.WHITE)); STYLES.put("B471", new Style(Style.parseColor("#380559"), Style.WHITE));
STYLES.put("B480", new Style(Style.parseColor("#2c2768"), Style.WHITE)); STYLES.put("B480", new Style(Style.parseColor("#2c2768"), Style.WHITE));
STYLES.put("B481", new Style(Style.parseColor("#007ec1"), Style.WHITE)); STYLES.put("B481", new Style(Style.parseColor("#007ec1"), Style.WHITE));
STYLES.put("B484", new Style(Style.parseColor("#dc8998"), Style.WHITE)); STYLES.put("B484", new Style(Style.parseColor("#dc8998"), Style.WHITE));
STYLES.put("B485", new Style(Style.parseColor("#ea8d52"), Style.WHITE)); STYLES.put("B485", new Style(Style.parseColor("#ea8d52"), Style.WHITE));
STYLES.put("B493", new Style(Style.parseColor("#f24825"), Style.WHITE)); STYLES.put("B493", new Style(Style.parseColor("#f24825"), Style.WHITE));
STYLES.put("B560", new Style(Style.parseColor("#9f6fb0"), Style.WHITE)); STYLES.put("B560", new Style(Style.parseColor("#9f6fb0"), Style.WHITE));
// Wolfsburg // Wolfsburg
STYLES.put("B201", new Style(Style.parseColor("#f1471c"), Style.WHITE)); STYLES.put("B201", new Style(Style.parseColor("#f1471c"), Style.WHITE));
STYLES.put("B202", new Style(Style.parseColor("#127bca"), Style.WHITE)); STYLES.put("B202", new Style(Style.parseColor("#127bca"), Style.WHITE));
STYLES.put("B203", new Style(Style.parseColor("#f35c95"), Style.WHITE)); STYLES.put("B203", new Style(Style.parseColor("#f35c95"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#00a650"), Style.WHITE)); STYLES.put("B204", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("B205", new Style(Style.parseColor("#f67c13"), 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("B206", new Style(Style.WHITE, Style.parseColor("#00adef"), Style.parseColor("#00adef")));
STYLES.put("B207", new Style(Style.parseColor("#94d221"), Style.WHITE)); STYLES.put("B207", new Style(Style.parseColor("#94d221"), Style.WHITE));
STYLES.put("B208", new Style(Style.parseColor("#00adef"), Style.WHITE)); STYLES.put("B208", new Style(Style.parseColor("#00adef"), Style.WHITE));
STYLES.put("B209", new Style(Style.parseColor("#bf7f50"), Style.WHITE)); STYLES.put("B209", new Style(Style.parseColor("#bf7f50"), Style.WHITE));
STYLES.put("B211", new Style(Style.parseColor("#be65ba"), Style.WHITE)); STYLES.put("B211", new Style(Style.parseColor("#be65ba"), Style.WHITE));
STYLES.put("B212", 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("B213", new Style(Style.parseColor("#918f90"), Style.WHITE));
STYLES.put("B218", new Style(Style.parseColor("#a950ae"), Style.WHITE)); STYLES.put("B218", new Style(Style.parseColor("#a950ae"), Style.WHITE));
STYLES.put("B219", new Style(Style.parseColor("#bf7f50"), Style.WHITE)); STYLES.put("B219", new Style(Style.parseColor("#bf7f50"), Style.WHITE));
STYLES.put("B230", new Style(Style.parseColor("#ca93d0"), 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("B231", new Style(Style.WHITE, Style.parseColor("#fab20a"), Style.parseColor("#fab20a")));
STYLES.put("B244", new Style(Style.parseColor("#66cef6"), Style.WHITE)); STYLES.put("B244", new Style(Style.parseColor("#66cef6"), Style.WHITE));
STYLES.put("B267", new Style(Style.parseColor("#918f90"), 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 * @author Andreas Schildbach
*/ */
public class BvbProvider extends AbstractEfaProvider public class BvbProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://www.efa-bvb.ch/bvb/";
private final static String API_BASE = "http://www.efa-bvb.ch/bvb/";
public BvbProvider() public BvbProvider() {
{ super(NetworkId.BVB, API_BASE);
super(NetworkId.BVB, API_BASE); }
}
@Override @Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
{ return xmlStopfinderRequest(new Location(LocationType.STATION, null, null, constraint.toString()));
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 * @author Andreas Schildbach
*/ */
public final class BvgProvider extends AbstractHafasProvider public final class BvgProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://bvg-apps.hafas.de/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY, Product.FERRY, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.ON_DEMAND };
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.ON_DEMAND };
public BvgProvider() public BvgProvider() {
{ super(NetworkId.BVG, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.BVG, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsUseWeight(false); setJsonGetStopsUseWeight(false);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES); setStyles(STYLES);
} }
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?"); 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_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
@Override @Override
protected String[] splitStationName(String name) protected String[] splitStationName(String name) {
{ final Matcher mSu = P_SPLIT_NAME_SU.matcher(name);
final Matcher mSu = P_SPLIT_NAME_SU.matcher(name); if (!mSu.matches())
if (!mSu.matches()) throw new IllegalStateException(name);
throw new IllegalStateException(name); name = mSu.group(1);
name = mSu.group(1); final String su = mSu.group(2);
final String su = mSu.group(2);
final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name); final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name);
if (!mBus.matches()) if (!mBus.matches())
throw new IllegalStateException(name); throw new IllegalStateException(name);
name = mBus.group(1); name = mBus.group(1);
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name); final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches()) if (mParen.matches())
return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) }; return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) };
final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name); final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (mComma.matches()) if (mComma.matches())
return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) }; return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) };
return super.splitStationName(name); return super.splitStationName(name);
} }
private String normalizePlace(final String place) private String normalizePlace(final String place) {
{ if ("Bln".equals(place))
if ("Bln".equals(place)) return "Berlin";
return "Berlin"; else
else return place;
return place; }
}
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
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 @Override
protected String normalizeLineName(final String lineName) protected String normalizeLineName(final String lineName) {
{ final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName);
final Matcher mTram = P_NORMALIZE_LINE_NAME_TRAM.matcher(lineName); if (mTram.matches())
if (mTram.matches()) return mTram.group(1);
return mTram.group(1);
return super.normalizeLineName(lineName); return super.normalizeLineName(lineName);
} }
@Override @Override
protected Line parseLineAndType(final String lineAndType) protected Line parseLineAndType(final String lineAndType) {
{ if ("X#".equals(lineAndType))
if ("X#".equals(lineAndType)) return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex else
else return super.parseLineAndType(lineAndType);
return super.parseLineAndType(lineAndType); }
}
@Override @Override
protected Line newLine(final Product product, final String normalizedName, final String comment, final Attr... attrs) protected Line newLine(final Product product, final String normalizedName, final String comment,
{ final Attr... attrs) {
if (product == Product.SUBURBAN_TRAIN && "S41".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_CLOCKWISE)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_CLOCKWISE));
if (product == Product.SUBURBAN_TRAIN && "S42".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S42".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_ANTICLOCKWISE)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.CIRCLE_ANTICLOCKWISE));
if (product == Product.BUS && "S41".equals(normalizedName)) if (product == Product.BUS && "S41".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE)); return super.newLine(product, normalizedName, comment,
if (product == Product.BUS && "S42".equals(normalizedName)) concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE));
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE)); 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)) if (product == Product.BUS && "TXL".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == Product.SUBURBAN_TRAIN && "S9".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S9".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
if (product == Product.SUBURBAN_TRAIN && "S45".equals(normalizedName)) if (product == Product.SUBURBAN_TRAIN && "S45".equals(normalizedName))
return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT)); return super.newLine(product, normalizedName, comment, concatAttrs(attrs, Attr.LINE_AIRPORT));
return super.newLine(product, normalizedName, comment, attrs); return super.newLine(product, normalizedName, comment, attrs);
} }
private Attr[] concatAttrs(final Attr[] attrs1, final Attr... attrs2) private Attr[] concatAttrs(final Attr[] attrs1, final Attr... attrs2) {
{ final int attrs1length = attrs1.length;
final int attrs1length = attrs1.length; final int attrs2length = attrs2.length;
final int attrs2length = attrs2.length;
final Attr[] newAttrs = new Attr[attrs1length + attrs2length]; final Attr[] newAttrs = new Attr[attrs1length + attrs2length];
for (int i = 0; i < attrs1length; i++) for (int i = 0; i < attrs1length; i++)
newAttrs[i] = attrs1[i]; newAttrs[i] = attrs1[i];
for (int i = 0; i < attrs2length; i++) for (int i = 0; i < attrs2length; i++)
newAttrs[attrs1length + i] = attrs2[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 static {
{ STYLES.put("SS1", new Style(Style.rgb(221, 77, 174), Style.WHITE));
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("SS2", new Style(Style.rgb(16, 132, 73), Style.WHITE)); STYLES.put("SS25", 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("SS3", new Style(Style.rgb(22, 106, 184), Style.WHITE)); STYLES.put("SS41", new Style(Style.rgb(162, 63, 48), 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("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("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("SS46", new Style(Style.rgb(191, 128, 55), Style.WHITE)); STYLES.put("SS47", 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("SS5", new Style(Style.rgb(243, 103, 23), Style.WHITE)); STYLES.put("SS7", new Style(Style.rgb(119, 96, 176), 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("SS75", new Style(Style.rgb(119, 96, 176), Style.WHITE)); STYLES.put("SS8", new Style(Style.rgb(85, 184, 49), 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("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("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("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("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("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("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("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("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("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("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("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("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("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("TM1", new Style(Shape.RECT, Style.parseColor("#eb8614"), Style.WHITE));
STYLES.put("TM2", new Style(Shape.RECT, Style.parseColor("#68c52f"), 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("TM4", new Style(Shape.RECT, Style.parseColor("#cf1b22"), Style.WHITE));
STYLES.put("TM5", new Style(Shape.RECT, Style.parseColor("#bf8037"), 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("TM6", new Style(Shape.RECT, Style.parseColor("#1e5ca2"), Style.WHITE));
STYLES.put("TM8", new Style(Shape.RECT, Style.parseColor("#f46717"), 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("TM10", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("TM13", new Style(Shape.RECT, Style.parseColor("#36ab94"), 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("TM17", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T12", new Style(Shape.RECT, Style.parseColor("#7d64b2"), 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("T16", new Style(Shape.RECT, Style.parseColor("#1e5ca2"), Style.WHITE));
STYLES.put("T18", new Style(Shape.RECT, Style.parseColor("#f46717"), 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("T21", new Style(Shape.RECT, Style.parseColor("#7d64b2"), Style.WHITE));
STYLES.put("T27", new Style(Shape.RECT, Style.parseColor("#a23f30"), 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("T37", new Style(Shape.RECT, Style.parseColor("#a23f30"), Style.WHITE));
STYLES.put("T50", new Style(Shape.RECT, Style.parseColor("#36ab94"), 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("T60", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T61", 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("T62", new Style(Shape.RECT, Style.parseColor("#125030"), Style.WHITE));
STYLES.put("T63", new Style(Shape.RECT, Style.parseColor("#36ab94"), 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("T67", new Style(Shape.RECT, Style.parseColor("#108449"), Style.WHITE));
STYLES.put("T68", 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("B", new Style(Shape.RECT, Style.parseColor("#993399"), Style.WHITE));
STYLES.put("BN", new Style(Shape.RECT, Style.BLACK, 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("FF1", new Style(Style.BLUE, Style.WHITE)); // Potsdam
STYLES.put("FF10", new Style(Style.BLUE, Style.WHITE)); STYLES.put("FF10", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF11", 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("FF12", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF21", 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("FF23", new Style(Style.BLUE, Style.WHITE));
STYLES.put("FF24", new Style(Style.BLUE, Style.WHITE)); STYLES.put("FF24", new Style(Style.BLUE, Style.WHITE));
// Regional lines Brandenburg: // Regional lines Brandenburg:
STYLES.put("RRE1", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE)); 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("RRE2", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRE3", new Style(Shape.RECT, Style.parseColor("#F57921"), Style.WHITE)); 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("RRE4", new Style(Shape.RECT, Style.parseColor("#952D4F"), Style.WHITE));
STYLES.put("RRE5", new Style(Shape.RECT, Style.parseColor("#0072BC"), 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("RRE6", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRE7", new Style(Shape.RECT, Style.parseColor("#00854A"), 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("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("#059EDB"), Style.WHITE));
STYLES.put("RRE11", new Style(Shape.RECT, Style.parseColor("#EE1C23"), 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("RRE15", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("RRE18", new Style(Shape.RECT, Style.parseColor("#00A65E"), Style.WHITE)); 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("RRB10", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RRB12", new Style(Shape.RECT, Style.parseColor("#A3238E"), 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("#F68B1F"), Style.WHITE));
STYLES.put("RRB13", new Style(Shape.RECT, Style.parseColor("#00A65E"), 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("RRB14", new Style(Shape.RECT, Style.parseColor("#A3238E"), Style.WHITE));
STYLES.put("RRB20", new Style(Shape.RECT, Style.parseColor("#00854A"), 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("RRB21", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("RRB22", new Style(Shape.RECT, Style.parseColor("#0087CB"), 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("ROE25", new Style(Shape.RECT, Style.parseColor("#0087CB"), Style.WHITE));
STYLES.put("RNE26", new Style(Shape.RECT, Style.parseColor("#00A896"), 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("RNE27", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRB30", new Style(Shape.RECT, Style.parseColor("#00A65E"), 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("RRB31", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RMR33", new Style(Shape.RECT, Style.parseColor("#EE1C23"), 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("ROE35", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("ROE36", new Style(Shape.RECT, Style.parseColor("#A7653F"), 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("RRB43", new Style(Shape.RECT, Style.parseColor("#5E6DB3"), Style.WHITE));
STYLES.put("RRB45", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK)); 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("ROE46", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RMR51", 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("RRB51", new Style(Shape.RECT, Style.parseColor("#DB6EAB"), Style.WHITE));
STYLES.put("RRB54", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK)); 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("RRB55", new Style(Shape.RECT, Style.parseColor("#F57921"), Style.WHITE));
STYLES.put("ROE60", new Style(Shape.RECT, Style.parseColor("#60BB46"), 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("ROE63", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK));
STYLES.put("ROE65", new Style(Shape.RECT, Style.parseColor("#0072BC"), Style.WHITE)); 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("RRB66", new Style(Shape.RECT, Style.parseColor("#60BB46"), Style.WHITE));
STYLES.put("RPE70", new Style(Shape.RECT, Style.parseColor("#FFD403"), Style.BLACK)); 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("RPE73", new Style(Shape.RECT, Style.parseColor("#00A896"), Style.WHITE));
STYLES.put("RPE74", new Style(Shape.RECT, Style.parseColor("#0072BC"), 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("T89", new Style(Shape.RECT, Style.parseColor("#EE1C23"), Style.WHITE));
STYLES.put("RRB91", new Style(Shape.RECT, Style.parseColor("#A7653F"), 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)); STYLES.put("RRB93", new Style(Shape.RECT, Style.parseColor("#A7653F"), Style.WHITE));
} }
@Override @Override
public Point[] getArea() public Point[] getArea() {
{ return new Point[] { Point.fromDouble(52.674189, 13.074604), Point.fromDouble(52.341100, 13.757130) };
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 * @author Andreas Schildbach
*/ */
public class DingProvider extends AbstractEfaProvider public class DingProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://www.ding-ulm.de/ding2/";
private final static String API_BASE = "http://www.ding-ulm.de/ding2/";
// http://www.ding.eu/swu // http://www.ding.eu/swu
public DingProvider() public DingProvider() {
{ super(NetworkId.DING, API_BASE);
super(NetworkId.DING, API_BASE); }
}
} }

View file

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

View file

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

View file

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

View file

@ -25,63 +25,52 @@ import de.schildbach.pte.dto.Style.Shape;
* @author Nicolas Derive * @author Nicolas Derive
* @author Stéphane Guillou * @author Stéphane Guillou
*/ */
public class FranceNorthEastProvider extends AbstractNavitiaProvider public class FranceNorthEastProvider extends AbstractNavitiaProvider {
{ private static String API_REGION = "fr-ne";
private static String API_REGION = "fr-ne"; // dataset available at: https://navitia.opendatasoft.com/explore/dataset/fr-ne/
// dataset available at: https://navitia.opendatasoft.com/explore/dataset/fr-ne/
public FranceNorthEastProvider(final String apiBase, final String authorization) public FranceNorthEastProvider(final String apiBase, final String authorization) {
{ super(NetworkId.FRANCENORTHEAST, apiBase, authorization);
super(NetworkId.FRANCENORTHEAST, apiBase, authorization);
setTimeZone("Europe/Paris"); setTimeZone("Europe/Paris");
} }
public FranceNorthEastProvider(final String authorization) public FranceNorthEastProvider(final String authorization) {
{ super(NetworkId.FRANCENORTHEAST, authorization);
super(NetworkId.FRANCENORTHEAST, authorization);
setTimeZone("Europe/Paris"); setTimeZone("Europe/Paris");
} }
@Override @Override
public String region() public String region() {
{ return API_REGION;
return API_REGION; }
}
@Override @Override
protected Style getLineStyle(final Product product, final String code, final String color) protected Style getLineStyle(final Product product, final String code, final String color) {
{ switch (product) {
switch (product) case REGIONAL_TRAIN: {
{ // Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF)
case REGIONAL_TRAIN: return new Style(Style.parseColor(color), computeForegroundColor(color));
{ }
// Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF) case SUBURBAN_TRAIN: {
return new Style(Style.parseColor(color), computeForegroundColor(color)); // Rail (route_type = 2) for Transilien (SNCF)
} return new Style(Style.parseColor(color), computeForegroundColor(color));
case SUBURBAN_TRAIN: }
{ case TRAM: {
// Rail (route_type = 2) for Transilien (SNCF) // Tram (route_type = 0) for Strasboug (CTS) and Nancy (Stan)
return new Style(Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color));
} }
case TRAM: case BUS: {
{ // Bus (route_type = 3)
// Tram (route_type = 0) for Strasboug (CTS) and Nancy (Stan) return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color)); }
} case SUBWAY: {
case BUS: // Subway (route_type = 1) for Lille (Transpole)
{ return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
// Bus (route_type = 3) }
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); default:
} throw new IllegalArgumentException("Unhandled product: " + product);
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 * @author Anthony Chaput
*/ */
public class FranceSouthEastProvider extends AbstractNavitiaProvider public class FranceSouthEastProvider extends AbstractNavitiaProvider {
{ private static String API_REGION = "fr-se";
private static String API_REGION = "fr-se";
public FranceSouthEastProvider(final String apiBase, final String authorization) public FranceSouthEastProvider(final String apiBase, final String authorization) {
{ super(NetworkId.FRANCESOUTHEAST, apiBase, authorization);
super(NetworkId.FRANCESOUTHEAST, apiBase, authorization);
setTimeZone("Europe/Paris"); setTimeZone("Europe/Paris");
} }
public FranceSouthEastProvider(final String authorization) public FranceSouthEastProvider(final String authorization) {
{ super(NetworkId.FRANCESOUTHEAST, authorization);
super(NetworkId.FRANCESOUTHEAST, authorization);
setTimeZone("Europe/Paris"); setTimeZone("Europe/Paris");
} }
@Override @Override
public String region() public String region() {
{ return API_REGION;
return API_REGION; }
}
@Override @Override
protected Style getLineStyle(final Product product, final String code, final String color) protected Style getLineStyle(final Product product, final String code, final String color) {
{ switch (product) {
switch (product) case REGIONAL_TRAIN: {
{ // TER + Intercités
case REGIONAL_TRAIN: return new Style(Style.parseColor(color), computeForegroundColor(color));
{ }
// TER + Intercités case SUBURBAN_TRAIN: {
return new Style(Style.parseColor(color), computeForegroundColor(color)); return new Style(Style.parseColor(color), computeForegroundColor(color));
} }
case SUBURBAN_TRAIN: case TRAM: {
{ // Tram
return new Style(Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
} }
case TRAM: case BUS: {
{ // Bus + Transgironde
// Tram return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color)); }
} case FERRY: {
case BUS: // Batcub
{ return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
// Bus + Transgironde }
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); case SUBWAY: {
} // Toulouse subway (from Tisseo network)
case FERRY: return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
{ }
// Batcub default:
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); return super.getLineStyle(product, code, 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 * @author Nicolas Derive
*/ */
public class FrenchSouthWestProvider extends AbstractNavitiaProvider public class FrenchSouthWestProvider extends AbstractNavitiaProvider {
{ private static String API_REGION = "fr-sw";
private static String API_REGION = "fr-sw";
public FrenchSouthWestProvider(final String apiBase, final String authorization) public FrenchSouthWestProvider(final String apiBase, final String authorization) {
{ super(NetworkId.FRENCHSOUTHWEST, apiBase, authorization);
super(NetworkId.FRENCHSOUTHWEST, apiBase, authorization);
setTimeZone("Europe/Paris"); setTimeZone("Europe/Paris");
} }
public FrenchSouthWestProvider(final String authorization) public FrenchSouthWestProvider(final String authorization) {
{ super(NetworkId.FRENCHSOUTHWEST, authorization);
super(NetworkId.FRENCHSOUTHWEST, authorization);
setTimeZone("Europe/Paris"); setTimeZone("Europe/Paris");
} }
@Override @Override
public String region() public String region() {
{ return API_REGION;
return API_REGION; }
}
@Override @Override
protected Style getLineStyle(final Product product, final String code, final String color) protected Style getLineStyle(final Product product, final String code, final String color) {
{ switch (product) {
switch (product) case REGIONAL_TRAIN: {
{ // TER + Intercités
case REGIONAL_TRAIN: return new Style(Style.parseColor(color), computeForegroundColor(color));
{ }
// TER + Intercités case SUBURBAN_TRAIN: {
return new Style(Style.parseColor(color), computeForegroundColor(color)); return new Style(Style.parseColor(color), computeForegroundColor(color));
} }
case SUBURBAN_TRAIN: case TRAM: {
{ // Tram
return new Style(Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
} }
case TRAM: case BUS: {
{ // Bus + Transgironde
// Tram return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color)); }
} case FERRY: {
case BUS: // Batcub
{ return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
// Bus + Transgironde }
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); case SUBWAY: {
} // Toulouse subway (from Tisseo network)
case FERRY: return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
{ }
// Batcub default:
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); return super.getLineStyle(product, code, 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 * @author Andreas Schildbach
*/ */
public class GvhProvider extends AbstractEfaProvider public class GvhProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://bhb.efa.de/bhb/";
private static final String API_BASE = "http://bhb.efa.de/bhb/";
// http://www.efa.de/efaws2/cmsembedded_gvh/ // http://www.efa.de/efaws2/cmsembedded_gvh/
// http://bhb.efa.de/bhb/ // http://bhb.efa.de/bhb/
// http://mobil.efa.de/mobile3/ // http://mobil.efa.de/mobile3/
public GvhProvider() public GvhProvider() {
{ this(API_BASE);
this(API_BASE); }
}
public GvhProvider(final String apiBase) public GvhProvider(final String apiBase) {
{ super(NetworkId.GVH, apiBase);
super(NetworkId.GVH, apiBase);
setStyles(STYLES); setStyles(STYLES);
setSessionCookieName("HASESSIONID"); setSessionCookieName("HASESSIONID");
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("S4".equals(trainNum))
{ return new Line(id, network, Product.SUBURBAN_TRAIN, "S4");
if ("S4".equals(trainNum)) if (longName != null && longName.startsWith("Bus ") && name != null)
return new Line(id, network, Product.SUBURBAN_TRAIN, "S4"); return new Line(id, network, Product.BUS, name);
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 static {
{ // Hannover
// Hannover STYLES.put("SS1", new Style(Style.Shape.CIRCLE, Style.parseColor("#816ba8"), Style.WHITE));
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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("BN62", new Style(Style.Shape.CIRCLE, Style.WHITE, Style.parseColor("#1a70b8")));
// Hamburg // Hamburg
// STYLES.put("SS1", new Style(Style.parseColor("#00933B"), Style.WHITE)); // 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("SS11", new Style(Style.WHITE, Style.parseColor("#00933B"),
// STYLES.put("SS2", new Style(Style.WHITE, Style.parseColor("#9D271A"), Style.parseColor("#9D271A"))); // Style.parseColor("#00933B")));
// STYLES.put("SS21", new Style(Style.parseColor("#9D271A"), Style.WHITE)); // STYLES.put("SS2", new Style(Style.WHITE, Style.parseColor("#9D271A"),
// STYLES.put("SS3", new Style(Style.parseColor("#411273"), Style.WHITE)); // Style.parseColor("#9D271A")));
// STYLES.put("SS31", new Style(Style.parseColor("#411273"), Style.WHITE)); // 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("UU1", new Style(Style.parseColor("#044895"), Style.WHITE));
STYLES.put("UU2", new Style(Style.parseColor("#DC2B19"), Style.WHITE)); STYLES.put("UU2", new Style(Style.parseColor("#DC2B19"), Style.WHITE));
STYLES.put("UU3", new Style(Style.parseColor("#EE9D16"), Style.WHITE)); STYLES.put("UU3", new Style(Style.parseColor("#EE9D16"), Style.WHITE));
STYLES.put("UU4", new Style(Style.parseColor("#13A59D"), 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 * @author Andreas Schildbach
*/ */
public class InvgProvider extends AbstractHafasProvider public class InvgProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://fpa.invg.de/bin/";
private static final String API_BASE = "http://fpa.invg.de/bin/"; // http://invg.hafas.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 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;
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
public InvgProvider() public InvgProvider() {
{ super(NetworkId.INVG, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.INVG, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardCanDoEquivs(false); setStationBoardCanDoEquivs(false);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES); setStyles(STYLES);
setExtXmlEndpoint(API_BASE + "extxml.exe"); setExtXmlEndpoint(API_BASE + "extxml.exe");
} }
@Override @Override
protected boolean hasCapability(final Capability capability) protected boolean hasCapability(final Capability capability) {
{ if (capability == Capability.TRIPS)
if (capability == Capability.TRIPS) return false;
return false; else
else return super.hasCapability(capability);
return super.hasCapability(capability); }
}
private static final String[] PLACES = { "Ingolstadt", "München" }; private static final String[] PLACES = { "Ingolstadt", "München" };
@Override @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
for (final String place : PLACES) for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + "-")) if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) }; return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxStations) throws IOException final int maxDistance, final int maxStations) throws IOException {
{ if (location.type == LocationType.STATION && location.hasId()) {
if (location.type == LocationType.STATION && location.hasId()) final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
{ uri.append("?near=Anzeigen");
final StringBuilder uri = new StringBuilder(stationBoardEndpoint); uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("?near=Anzeigen"); uri.append("&input=").append(normalizeStationId(location.id));
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString()); return htmlNearbyStations(uri.toString());
} } else {
else throw new IllegalArgumentException("cannot handle: " + location);
{ }
throw new IllegalArgumentException("cannot handle: " + location); }
}
}
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(".*?" //
.compile( + "(?:" //
".*?" // + "<div class=\"summary clearfix\">.*?<div class=\"block\">.*?(<div>.*?</div>.*?<div class=\"last\">.*?</div>).*?</div>.*?" //
+ "(?:" // + "<div class=\"linkGroup\">.*?input=(\\d+).*?" // locationId
+ "<div class=\"summary clearfix\">.*?<div class=\"block\">.*?(<div>.*?</div>.*?<div class=\"last\">.*?</div>).*?</div>.*?" // + "(?:<table class=\"resultTable\" cellspacing=\"0\">(.*?)</table>|(verkehren an dieser Haltestelle keine))"//
+ "<div class=\"linkGroup\">.*?input=(\\d+).*?" // locationId + "|(Eingabe kann nicht interpretiert)|(Verbindung zum Server konnte leider nicht hergestellt werden|kann vom Server derzeit leider nicht bearbeitet werden))" //
+ "(?:<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(
, Pattern.DOTALL); ".*?" //
private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(".*?" // + "<span class=\"output\">(.*?)<.*?" // location
+ "<span class=\"output\">(.*?)<.*?" // location + "<span class=\"output\">\n(\\d{2}\\.\\d{2}\\.\\d{2}).*?" // date
+ "<span class=\"output\">\n(\\d{2}\\.\\d{2}\\.\\d{2}).*?" // date + "Abfahrt (\\d{1,2}:\\d{2}).*?" // time
+ "Abfahrt (\\d{1,2}:\\d{2}).*?" // time , Pattern.DOTALL);
, Pattern.DOTALL); private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"(depboard-\\w*)\">(.*?)</tr>",
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"(depboard-\\w*)\">(.*?)</tr>", Pattern.DOTALL); Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" // 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" // + "<td class=\"time\">(\\d{1,2}:\\d{2})</td>\n" // plannedTime
+ "(?:&nbsp;|<span class=\"rtLimit\\d\">(p&#252;nktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime + "(?:<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 + "<img class=\"product\" src=\"/hafas-res/img/products/(\\w+)_pic\\.gif\"[^>]*>\\s*(.*?)\\s*</.*?" // type,
+ "<strong>\n" // // line
+ "<a href=\"http://fpa\\.invg\\.de/bin/stboard\\.exe/dn\\?input=(\\d+)&[^>]*>" // destinationId + "<strong>\n" //
+ "\\s*(.*?)\\s*</a>\n" // destination + "<a href=\"http://fpa\\.invg\\.de/bin/stboard\\.exe/dn\\?input=(\\d+)&[^>]*>" // destinationId
+ "</strong>.*?" // + "\\s*(.*?)\\s*</a>\n" // destination
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position + "</strong>.*?" //
, Pattern.DOTALL); + "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
, Pattern.DOTALL);
@Override @Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
throws IOException final int maxDepartures, final boolean equivs) throws IOException {
{ checkNotNull(Strings.emptyToNull(stationId));
checkNotNull(Strings.emptyToNull(stationId));
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT); final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final QueryDeparturesResult result = new QueryDeparturesResult(header); final QueryDeparturesResult result = new QueryDeparturesResult(header);
// scrape page // scrape page
final StringBuilder uri = new StringBuilder(stationBoardEndpoint); final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null); appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null);
final CharSequence page = httpClient.get(uri.toString()); final CharSequence page = httpClient.get(uri.toString());
// parse page // parse page
final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page); final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page);
if (mHeadCoarse.matches()) if (mHeadCoarse.matches()) {
{ // messages
// messages if (mHeadCoarse.group(4) != null) {
if (mHeadCoarse.group(4) != null) result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId),
{ Collections.<Departure> emptyList(), null));
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId), return result;
Collections.<Departure> emptyList(), null)); } else if (mHeadCoarse.group(5) != null)
return result; return new QueryDeparturesResult(header, Status.INVALID_STATION);
} else if (mHeadCoarse.group(6) != null)
else if (mHeadCoarse.group(5) != null) return new QueryDeparturesResult(header, Status.SERVICE_DOWN);
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)); final Matcher mHeadFine = P_DEPARTURES_HEAD_FINE.matcher(mHeadCoarse.group(1));
if (mHeadFine.matches()) if (mHeadFine.matches()) {
{ final String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mHeadFine.group(1)));
final String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mHeadFine.group(1))); final Calendar currentTime = new GregorianCalendar(timeZone);
final Calendar currentTime = new GregorianCalendar(timeZone); currentTime.clear();
currentTime.clear(); ParserUtils.parseGermanDate(currentTime, mHeadFine.group(2));
ParserUtils.parseGermanDate(currentTime, mHeadFine.group(2)); ParserUtils.parseEuropeanTime(currentTime, mHeadFine.group(3));
ParserUtils.parseEuropeanTime(currentTime, mHeadFine.group(3)); final List<Departure> departures = new ArrayList<Departure>(8);
final List<Departure> departures = new ArrayList<Departure>(8); String oldZebra = null;
String oldZebra = null;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(3)); final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(3));
while (mDepCoarse.find()) while (mDepCoarse.find()) {
{ final String zebra = mDepCoarse.group(1);
final String zebra = mDepCoarse.group(1); if (oldZebra != null && zebra.equals(oldZebra))
if (oldZebra != null && zebra.equals(oldZebra)) throw new IllegalArgumentException("missed row? last:" + zebra);
throw new IllegalArgumentException("missed row? last:" + zebra); else
else oldZebra = zebra;
oldZebra = zebra;
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2)); final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
if (mDepFine.matches()) if (mDepFine.matches()) {
{ final Calendar plannedTime = new GregorianCalendar(timeZone);
final Calendar plannedTime = new GregorianCalendar(timeZone); plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
plannedTime.setTimeInMillis(currentTime.getTimeInMillis()); ParserUtils.parseEuropeanTime(plannedTime, mDepFine.group(1));
ParserUtils.parseEuropeanTime(plannedTime, mDepFine.group(1));
if (plannedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS) if (plannedTime.getTimeInMillis()
plannedTime.add(Calendar.DAY_OF_MONTH, 1); - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
plannedTime.add(Calendar.DAY_OF_MONTH, 1);
final Calendar predictedTime; final Calendar predictedTime;
final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2)); final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2));
if (prognosis != null) if (prognosis != null) {
{ predictedTime = new GregorianCalendar(timeZone);
predictedTime = new GregorianCalendar(timeZone); if (prognosis.equals("pünktlich")) {
if (prognosis.equals("pünktlich")) predictedTime.setTimeInMillis(plannedTime.getTimeInMillis());
{ } else {
predictedTime.setTimeInMillis(plannedTime.getTimeInMillis()); predictedTime.setTimeInMillis(currentTime.getTimeInMillis());
} ParserUtils.parseEuropeanTime(predictedTime, prognosis);
else }
{ } else {
predictedTime.setTimeInMillis(currentTime.getTimeInMillis()); predictedTime = null;
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 destinationId = mDepFine.group(5);
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6)); final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final Location destination; final Location destination;
if (destinationId != null) if (destinationId != null) {
{ final String[] destinationPlaceAndName = splitStationName(destinationName);
final String[] destinationPlaceAndName = splitStationName(destinationName); destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0],
destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0], destinationPlaceAndName[1]); destinationPlaceAndName[1]);
} } else {
else destination = new Location(LocationType.ANY, null, null, destinationName);
{ }
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, final Departure dep = new Departure(plannedTime.getTime(),
position, destination, null, null); predictedTime != null ? predictedTime.getTime() : null, line, position, destination,
null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);
} } else {
else throw new IllegalArgumentException(
{ "cannot parse '" + mDepCoarse.group(2) + "' on " + stationId);
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + stationId); }
} }
}
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, locationId, placeAndName[0], placeAndName[1]), result.stationDepartures.add(new StationDepartures(
departures, null)); new Location(LocationType.STATION, locationId, placeAndName[0], placeAndName[1]), departures,
return result; null));
} return result;
else } else {
{ throw new IllegalArgumentException("cannot parse '" + mHeadCoarse.group(1) + "' on " + stationId);
throw new IllegalArgumentException("cannot parse '" + mHeadCoarse.group(1) + "' on " + stationId); }
} } else {
} throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
else }
{ }
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
}
}
@Override @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
{ return queryMoreTripsXml(context, later);
return queryMoreTripsXml(context, later); }
}
protected static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Bus\\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_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_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_X = Pattern.compile("Bus\\s*X\\s*(\\d+)");
@Override @Override
protected Line parseLine(final String type, final String line, final boolean wheelchairAccess) protected Line parseLine(final String type, final String line, final boolean wheelchairAccess) {
{ if ("1".equals(type)) {
if ("1".equals(type)) final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
{ if (mBus.matches()) {
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line); final String label = mBus.group(1);
if (mBus.matches()) return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
{ }
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); final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line);
if (mNachtbus.matches()) if (mNachtbus.matches()) {
{ final String label = "N" + mNachtbus.group(1);
final String label = "N" + mNachtbus.group(1); return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label)); }
}
final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line); final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line);
if (mBusS.matches()) if (mBusS.matches()) {
{ final String label = "S" + mBusS.group(1);
final String label = "S" + mBusS.group(1); return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label)); }
}
final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line); final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line);
if (mBusX.matches()) if (mBusX.matches()) {
{ final String label = "X" + mBusX.group(1);
final String label = "X" + mBusX.group(1); return new Line(null, null, Product.BUS, label, lineStyle(null, Product.BUS, label));
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 @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ if ("1".equals(type))
if ("1".equals(type)) return Product.BUS;
return Product.BUS;
// skip parsing of "common" lines // skip parsing of "common" lines
throw new IllegalStateException("cannot normalize type '" + type + "'"); 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 static {
{ STYLES.put("B10", new Style(Style.parseColor("#DA2510"), Style.WHITE));
STYLES.put("B10", new Style(Style.parseColor("#DA2510"), Style.WHITE)); STYLES.put("B11", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("B11", new Style(Style.parseColor("#EE9B78"), Style.BLACK)); STYLES.put("B15", new Style(Style.parseColor("#84C326"), Style.BLACK));
STYLES.put("B15", new Style(Style.parseColor("#84C326"), Style.BLACK)); STYLES.put("B16", new Style(Style.parseColor("#5D452E"), Style.WHITE));
STYLES.put("B16", new Style(Style.parseColor("#5D452E"), Style.WHITE)); STYLES.put("B17", new Style(Style.parseColor("#E81100"), Style.BLACK));
STYLES.put("B17", new Style(Style.parseColor("#E81100"), Style.BLACK)); STYLES.put("B18", new Style(Style.parseColor("#79316C"), Style.WHITE));
STYLES.put("B18", new Style(Style.parseColor("#79316C"), Style.WHITE)); STYLES.put("B20", new Style(Style.parseColor("#EA891C"), Style.BLACK));
STYLES.put("B20", new Style(Style.parseColor("#EA891C"), Style.BLACK)); STYLES.put("B21", new Style(Style.parseColor("#31B2EA"), Style.BLACK));
STYLES.put("B21", new Style(Style.parseColor("#31B2EA"), Style.BLACK)); STYLES.put("B25", new Style(Style.parseColor("#7F65A0"), Style.WHITE));
STYLES.put("B25", new Style(Style.parseColor("#7F65A0"), Style.WHITE)); STYLES.put("B26", new Style(Style.parseColor("#00BF73"), Style.WHITE)); // not present in Fahrplan
STYLES.put("B26", new Style(Style.parseColor("#00BF73"), Style.WHITE)); // not present in Fahrplan 2012/2013 // 2012/2013
STYLES.put("B30", new Style(Style.parseColor("#901E78"), Style.WHITE)); STYLES.put("B30", new Style(Style.parseColor("#901E78"), Style.WHITE));
STYLES.put("B31", new Style(Style.parseColor("#DCE722"), Style.BLACK)); STYLES.put("B31", new Style(Style.parseColor("#DCE722"), Style.BLACK));
STYLES.put("B40", new Style(Style.parseColor("#009240"), Style.WHITE)); STYLES.put("B40", new Style(Style.parseColor("#009240"), Style.WHITE));
STYLES.put("B41", new Style(Style.parseColor("#7BC5B1"), Style.BLACK)); STYLES.put("B41", new Style(Style.parseColor("#7BC5B1"), Style.BLACK));
STYLES.put("B44", new Style(Style.parseColor("#EA77A6"), Style.WHITE)); STYLES.put("B44", new Style(Style.parseColor("#EA77A6"), Style.WHITE));
STYLES.put("B50", new Style(Style.parseColor("#FACF00"), Style.BLACK)); STYLES.put("B50", new Style(Style.parseColor("#FACF00"), Style.BLACK));
STYLES.put("B51", new Style(Style.parseColor("#C13C00"), Style.WHITE)); STYLES.put("B51", new Style(Style.parseColor("#C13C00"), Style.WHITE));
STYLES.put("B52", new Style(Style.parseColor("#94F0D4"), Style.BLACK)); STYLES.put("B52", new Style(Style.parseColor("#94F0D4"), Style.BLACK));
STYLES.put("B53", new Style(Style.parseColor("#BEB405"), Style.BLACK)); STYLES.put("B53", new Style(Style.parseColor("#BEB405"), Style.BLACK));
STYLES.put("B55", new Style(Style.parseColor("#FFF500"), Style.BLACK)); STYLES.put("B55", new Style(Style.parseColor("#FFF500"), Style.BLACK));
STYLES.put("B60", new Style(Style.parseColor("#0072B7"), Style.WHITE)); 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("B61", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan
STYLES.put("B62", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan 2012/2013 // 2012/2013
STYLES.put("B65", new Style(Style.parseColor("#B7DDD2"), Style.BLACK)); STYLES.put("B62", new Style(Style.rgb(204, 184, 122), Style.BLACK)); // not present in Fahrplan
STYLES.put("B70", new Style(Style.parseColor("#D49016"), Style.BLACK)); // 2012/2013
STYLES.put("B71", new Style(Style.parseColor("#996600"), Style.BLACK)); // not present in Fahrplan 2012/2013 STYLES.put("B65", new Style(Style.parseColor("#B7DDD2"), Style.BLACK));
STYLES.put("B85", new Style(Style.parseColor("#F6BAD3"), Style.BLACK)); STYLES.put("B70", new Style(Style.parseColor("#D49016"), Style.BLACK));
STYLES.put("B111", new Style(Style.parseColor("#EE9B78"), 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("B9221", new Style(Style.rgb(217, 217, 255), Style.BLACK));
STYLES.put("B9226", new Style(Style.rgb(191, 255, 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("BN1", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN2", 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("BN3", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN4", 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("BN5", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN6", 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("BN7", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN8", 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("BN9", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN10", 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("BN11", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN12", 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("BN13", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN14", 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("BN15", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN16", 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("BN17", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BN18", 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("BN19", new Style(Style.parseColor("#00116C"), Style.WHITE));
STYLES.put("BS1", 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("BS2", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS3", 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("BS4", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS5", 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("BS6", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS7", 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("BS8", new Style(Style.rgb(178, 25, 0), Style.WHITE));
STYLES.put("BS9", 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("BX11", new Style(Style.parseColor("#EE9B78"), Style.BLACK));
STYLES.put("BX12", new Style(Style.parseColor("#B11839"), Style.BLACK)); STYLES.put("BX12", new Style(Style.parseColor("#B11839"), Style.BLACK));
STYLES.put("BX80", new Style(Style.parseColor("#FFFF40"), 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("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 * @author Antonio El Khoury
*/ */
public class ItalyProvider extends AbstractNavitiaProvider public class ItalyProvider extends AbstractNavitiaProvider {
{ private static String API_REGION = "it";
private static String API_REGION = "it";
public ItalyProvider(final String apiBase, final String authorization) public ItalyProvider(final String apiBase, final String authorization) {
{ super(NetworkId.IT, apiBase, authorization);
super(NetworkId.IT, apiBase, authorization);
setTimeZone("Europe/Rome"); setTimeZone("Europe/Rome");
} }
public ItalyProvider(final String authorization) public ItalyProvider(final String authorization) {
{ super(NetworkId.IT, authorization);
super(NetworkId.IT, authorization);
setTimeZone("Europe/Rome"); setTimeZone("Europe/Rome");
} }
@Override @Override
public String region() public String region() {
{ return API_REGION;
return API_REGION; }
}
@Override @Override
protected String getLocationName(String name) protected String getLocationName(String name) {
{ return WordUtils.capitalizeFully(name);
return WordUtils.capitalizeFully(name); }
}
} }

View file

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

View file

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

View file

@ -31,140 +31,132 @@ import de.schildbach.pte.dto.Style.Shape;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class KvvProvider extends AbstractEfaProvider public class KvvProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://213.144.24.66/kvv2/";
private final static String API_BASE = "http://213.144.24.66/kvv2/";
public KvvProvider() public KvvProvider() {
{ this(API_BASE);
this(API_BASE); }
}
public KvvProvider(final String apiBase) public KvvProvider(final String apiBase) {
{ super(NetworkId.KVV, apiBase);
super(NetworkId.KVV, apiBase);
setStyles(STYLES); setStyles(STYLES);
setSessionCookieName("HASESSIONID"); 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 @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
@Nullable String name, @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, @Nullable String symbol, @Nullable String name, @Nullable String longName, final @Nullable String trainType,
final @Nullable String trainName) final @Nullable String trainNum, final @Nullable String trainName) {
{ if (symbol != null) {
if (symbol != null) final Matcher m = P_LINE.matcher(symbol);
{ if (m.matches())
final Matcher m = P_LINE.matcher(symbol); symbol = m.group(1);
if (m.matches()) }
symbol = m.group(1);
}
if (name != null) if (name != null) {
{ final Matcher m = P_LINE.matcher(name);
final Matcher m = P_LINE.matcher(name); if (m.matches())
if (m.matches()) name = m.group(1);
name = m.group(1); }
}
if (longName != null) if (longName != null) {
{ final Matcher m = P_LINE.matcher(longName);
final Matcher m = P_LINE.matcher(longName); if (m.matches())
if (m.matches()) longName = m.group(1);
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 static {
{ // S-Bahn
// S-Bahn STYLES.put("SS1", new Style(Style.parseColor("#00a76c"), Style.WHITE));
STYLES.put("SS1", new Style(Style.parseColor("#00a76c"), Style.WHITE)); STYLES.put("SS11", 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("SS2", new Style(Style.parseColor("#9f68ab"), Style.WHITE)); STYLES.put("SS3", new Style(Style.parseColor("#00a99d"), Style.BLACK));
STYLES.put("SS3", new Style(Style.parseColor("#00a99d"), Style.BLACK)); STYLES.put("SS31", new Style(Style.parseColor("#00a99d"), Style.WHITE));
STYLES.put("SS31", new Style(Style.parseColor("#00a99d"), Style.WHITE)); STYLES.put("SS32", 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("SS33", new Style(Style.parseColor("#00a99d"), Style.WHITE)); STYLES.put("SS4", new Style(Style.parseColor("#9f184c"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#9f184c"), Style.WHITE)); STYLES.put("SS41", 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("SS5", new Style(Style.parseColor("#f69795"), Style.BLACK)); STYLES.put("SS51", 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("SS52", new Style(Style.parseColor("#f69795"), Style.BLACK)); STYLES.put("SS6", new Style(Style.parseColor("#292369"), Style.WHITE));
STYLES.put("SS6", new Style(Style.parseColor("#292369"), Style.WHITE)); STYLES.put("SS7", new Style(Style.parseColor("#fff200"), Style.BLACK));
STYLES.put("SS7", new Style(Style.parseColor("#fff200"), Style.BLACK)); STYLES.put("SS9", new Style(Style.parseColor("#fab499"), Style.BLACK));
STYLES.put("SS9", new Style(Style.parseColor("#fab499"), Style.BLACK));
// S-Bahn RheinNeckar // S-Bahn RheinNeckar
STYLES.put("ddb|SS3", new Style(Style.parseColor("#ffdd00"), Style.BLACK)); 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|SS33", new Style(Style.parseColor("#8d5ca6"), Style.WHITE));
STYLES.put("ddb|SS4", new Style(Style.parseColor("#00a650"), Style.WHITE)); STYLES.put("ddb|SS4", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("ddb|SS5", new Style(Style.parseColor("#f89835"), Style.WHITE)); STYLES.put("ddb|SS5", new Style(Style.parseColor("#f89835"), Style.WHITE));
// Tram // Tram
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE)); 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("T1E", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#0071bc"), 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("T2E", new Style(Shape.RECT, Style.parseColor("#0071bc"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#947139"), 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("T3E", new Style(Shape.RECT, Style.parseColor("#947139"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#ffcb04"), Style.BLACK)); 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("T4E", new Style(Shape.RECT, Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#00c0f3"), Style.WHITE)); 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("T5E", new Style(Shape.RECT, Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#80c342"), 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("T6E", new Style(Shape.RECT, Style.parseColor("#80c342"), Style.WHITE));
STYLES.put("T7", new Style(Shape.RECT, Style.parseColor("#58595b"), 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("T7E", new Style(Shape.RECT, Style.parseColor("#58595b"), Style.WHITE));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#f7931d"), Style.BLACK)); STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#f7931d"), Style.BLACK));
STYLES.put("T8E", 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 // Bus - only used on bus plan
// LINES.put("B21", new Style(Shape.CIRCLE, Style.parseColor("#2e3092"), Style.WHITE)); // 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("B22", new Style(Shape.CIRCLE, Style.parseColor("#00aeef"), Style.WHITE));
// LINES.put("B23", new Style(Shape.CIRCLE, Style.parseColor("#56c5d0"), 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("B24", new Style(Shape.CIRCLE, Style.parseColor("#a1d1e6"), Style.WHITE));
// LINES.put("B26", new Style(Shape.CIRCLE, Style.parseColor("#2e3092"), 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("B27", new Style(Shape.CIRCLE, Style.parseColor("#00aeef"), Style.WHITE));
// LINES.put("B30", new Style(Shape.CIRCLE, Style.parseColor("#adbc72"), 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("B31", new Style(Shape.CIRCLE, Style.parseColor("#62bb46"), Style.WHITE));
// LINES.put("B32", new Style(Shape.CIRCLE, Style.parseColor("#177752"), 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("B42", new Style(Shape.CIRCLE, Style.parseColor("#177752"), Style.WHITE));
// LINES.put("B44", new Style(Shape.CIRCLE, Style.parseColor("#62bb46"), 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("B47", new Style(Shape.CIRCLE, Style.parseColor("#adbc72"), Style.WHITE));
// LINES.put("B50", new Style(Shape.CIRCLE, Style.parseColor("#a25641"), 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("B51", new Style(Shape.CIRCLE, Style.parseColor("#d2ab67"), Style.WHITE));
// LINES.put("B52", new Style(Shape.CIRCLE, Style.parseColor("#a25641"), 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("B55", new Style(Shape.CIRCLE, Style.parseColor("#806a50"), Style.WHITE));
// LINES.put("B60", 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("B62", new Style(Shape.CIRCLE, Style.parseColor("#d2ab67"), Style.WHITE));
// LINES.put("B70", new Style(Shape.CIRCLE, Style.parseColor("#574187"), 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("B71", new Style(Shape.CIRCLE, Style.parseColor("#874487"), Style.WHITE));
// LINES.put("B72", new Style(Shape.CIRCLE, Style.parseColor("#9b95c9"), 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("B73", new Style(Shape.CIRCLE, Style.parseColor("#574187"), Style.WHITE));
// LINES.put("B74", new Style(Shape.CIRCLE, Style.parseColor("#9b95c9"), 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("B75", new Style(Shape.CIRCLE, Style.parseColor("#874487"), Style.WHITE));
// LINES.put("B107", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), 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("B118", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// LINES.put("B123", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE)); // LINES.put("B123", new Style(Shape.CIRCLE, Style.parseColor("#9d9fa1"), Style.WHITE));
// Nightliner // Nightliner
STYLES.put("BNL3", new Style(Style.parseColor("#947139"), Style.WHITE)); STYLES.put("BNL3", new Style(Style.parseColor("#947139"), Style.WHITE));
STYLES.put("BNL4", new Style(Style.parseColor("#ffcb04"), Style.BLACK)); STYLES.put("BNL4", new Style(Style.parseColor("#ffcb04"), Style.BLACK));
STYLES.put("BNL5", new Style(Style.parseColor("#00c0f3"), Style.WHITE)); STYLES.put("BNL5", new Style(Style.parseColor("#00c0f3"), Style.WHITE));
STYLES.put("BNL6", new Style(Style.parseColor("#80c342"), Style.WHITE)); STYLES.put("BNL6", new Style(Style.parseColor("#80c342"), Style.WHITE));
// Anruf-Linien-Taxi // Anruf-Linien-Taxi
STYLES.put("BALT6", new Style(Shape.RECT, Style.BLACK, Style.YELLOW)); STYLES.put("BALT6", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT11", 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("BALT12", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT13", 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("BALT14", new Style(Shape.RECT, Style.BLACK, Style.YELLOW));
STYLES.put("BALT16", 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 * @author Andreas Schildbach
*/ */
public class LinzProvider extends AbstractEfaProvider public class LinzProvider extends AbstractEfaProvider {
{ public static final String API_BASE = "https://www.linzag.at/linz2/";
public static final String API_BASE = "https://www.linzag.at/linz2/";
// http://www.linzag.at/static/ // http://www.linzag.at/static/
public LinzProvider() public LinzProvider() {
{ super(NetworkId.LINZ, API_BASE);
super(NetworkId.LINZ, API_BASE);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); 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 static {
{ STYLES.put("B11", new Style(Style.Shape.RECT, Style.parseColor("#f27b02"), Style.WHITE));
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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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 * @author Andreas Schildbach
*/ */
public final class LocationUtils public final class LocationUtils {
{ /**
/** * @param lat1
* @param lat1 * latitude of origin point in decimal degrees
* latitude of origin point in decimal degrees * @param lon1
* @param lon1 * longitude of origin point in deceimal degrees
* longitude of origin point in deceimal degrees * @param lat2
* @param lat2 * latitude of destination point in decimal degrees
* latitude of destination point in decimal degrees * @param lon2
* @param lon2 * longitude of destination point in decimal degrees
* longitude of destination point in decimal degrees *
* * @return distance in meters
* @return distance in meters */
*/ public static float computeDistance(double lat1, double lon1, double lat2, double lon2) {
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)
// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
// using the "Inverse Formula" (section 4)
final int MAXITERS = 20; final int MAXITERS = 20;
// Convert lat/long to radians // Convert lat/long to radians
lat1 *= Math.PI / 180.0; lat1 *= Math.PI / 180.0;
lat2 *= Math.PI / 180.0; lat2 *= Math.PI / 180.0;
lon1 *= Math.PI / 180.0; lon1 *= Math.PI / 180.0;
lon2 *= Math.PI / 180.0; lon2 *= Math.PI / 180.0;
final double a = 6378137.0; // WGS84 major axis final double a = 6378137.0; // WGS84 major axis
final double b = 6356752.3142; // WGS84 semi-major axis final double b = 6356752.3142; // WGS84 semi-major axis
final double f = (a - b) / a; final double f = (a - b) / a;
final double aSqMinusBSqOverBSq = (a * a - b * b) / (b * b); final double aSqMinusBSqOverBSq = (a * a - b * b) / (b * b);
final double L = lon2 - lon1; final double L = lon2 - lon1;
double A = 0.0; double A = 0.0;
final double U1 = Math.atan((1.0 - f) * Math.tan(lat1)); final double U1 = Math.atan((1.0 - f) * Math.tan(lat1));
final double U2 = Math.atan((1.0 - f) * Math.tan(lat2)); final double U2 = Math.atan((1.0 - f) * Math.tan(lat2));
final double cosU1 = Math.cos(U1); final double cosU1 = Math.cos(U1);
final double cosU2 = Math.cos(U2); final double cosU2 = Math.cos(U2);
final double sinU1 = Math.sin(U1); final double sinU1 = Math.sin(U1);
final double sinU2 = Math.sin(U2); final double sinU2 = Math.sin(U2);
final double cosU1cosU2 = cosU1 * cosU2; final double cosU1cosU2 = cosU1 * cosU2;
final double sinU1sinU2 = sinU1 * sinU2; final double sinU1sinU2 = sinU1 * sinU2;
double sigma = 0.0; double sigma = 0.0;
double deltaSigma = 0.0; double deltaSigma = 0.0;
double cosSqAlpha = 0.0; double cosSqAlpha = 0.0;
double cos2SM = 0.0; double cos2SM = 0.0;
double cosSigma = 0.0; double cosSigma = 0.0;
double sinSigma = 0.0; double sinSigma = 0.0;
double cosLambda = 0.0; double cosLambda = 0.0;
double sinLambda = 0.0; double sinLambda = 0.0;
double lambda = L; // initial guess double lambda = L; // initial guess
for (int iter = 0; iter < MAXITERS; iter++) for (int iter = 0; iter < MAXITERS; iter++) {
{ final double lambdaOrig = lambda;
final double lambdaOrig = lambda; cosLambda = Math.cos(lambda);
cosLambda = Math.cos(lambda); sinLambda = Math.sin(lambda);
sinLambda = Math.sin(lambda); final double t1 = cosU2 * sinLambda;
final double t1 = cosU2 * sinLambda; final double t2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda;
final double t2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda; final double sinSqSigma = t1 * t1 + t2 * t2; // (14)
final double sinSqSigma = t1 * t1 + t2 * t2; // (14) sinSigma = Math.sqrt(sinSqSigma);
sinSigma = Math.sqrt(sinSqSigma); cosSigma = sinU1sinU2 + cosU1cosU2 * cosLambda; // (15)
cosSigma = sinU1sinU2 + cosU1cosU2 * cosLambda; // (15) sigma = Math.atan2(sinSigma, cosSigma); // (16)
sigma = Math.atan2(sinSigma, cosSigma); // (16) final double sinAlpha = (sinSigma == 0) ? 0.0 : cosU1cosU2 * sinLambda / sinSigma; // (17)
final double sinAlpha = (sinSigma == 0) ? 0.0 : cosU1cosU2 * sinLambda / sinSigma; // (17) cosSqAlpha = 1.0 - sinAlpha * sinAlpha;
cosSqAlpha = 1.0 - sinAlpha * sinAlpha; cos2SM = (cosSqAlpha == 0) ? 0.0 : cosSigma - 2.0 * sinU1sinU2 / cosSqAlpha; // (18)
cos2SM = (cosSqAlpha == 0) ? 0.0 : cosSigma - 2.0 * sinU1sinU2 / cosSqAlpha; // (18)
final double uSquared = cosSqAlpha * aSqMinusBSqOverBSq; // defn final double uSquared = cosSqAlpha * aSqMinusBSqOverBSq; // defn
A = 1 + (uSquared / 16384.0) * // (3) A = 1 + (uSquared / 16384.0) * // (3)
(4096.0 + uSquared * (-768 + uSquared * (320.0 - 175.0 * uSquared))); (4096.0 + uSquared * (-768 + uSquared * (320.0 - 175.0 * uSquared)));
final double B = (uSquared / 1024.0) * // (4) final double B = (uSquared / 1024.0) * // (4)
(256.0 + uSquared * (-128.0 + uSquared * (74.0 - 47.0 * uSquared))); (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 C = (f / 16.0) * cosSqAlpha * (4.0 + f * (4.0 - 3.0 * cosSqAlpha)); // (10)
final double cos2SMSq = cos2SM * cos2SM; final double cos2SMSq = cos2SM * cos2SM;
deltaSigma = B deltaSigma = B * sinSigma * // (6)
* sinSigma (cos2SM + (B / 4.0) * (cosSigma * (-1.0 + 2.0 * cos2SMSq)
* // (6) - (B / 6.0) * cos2SM * (-3.0 + 4.0 * sinSigma * sinSigma) * (-3.0 + 4.0 * cos2SMSq)));
(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) if (Math.abs(delta) < 1.0e-12)
break; 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 * @author Andreas Schildbach
*/ */
public class LuProvider extends AbstractHafasProvider public class LuProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://mobiliteitszentral.hafas.de/hafas/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.BUS, Product.BUS }; Product.BUS, Product.BUS };
public LuProvider() public LuProvider() {
{ super(NetworkId.LU, API_BASE, "fn", PRODUCTS_MAP);
super(NetworkId.LU, API_BASE, "fn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
} }
@Override @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("CRE".equals(ucType)) if ("CRE".equals(ucType))
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if ("CITYBUS".equals(ucType)) if ("CITYBUS".equals(ucType))
return Product.BUS; return Product.BUS;
if ("NIGHTBUS".equals(ucType)) if ("NIGHTBUS".equals(ucType))
return Product.BUS; return Product.BUS;
if ("DIFFBUS".equals(ucType)) if ("DIFFBUS".equals(ucType))
return Product.BUS; return Product.BUS;
if ("NAVETTE".equals(ucType)) if ("NAVETTE".equals(ucType))
return Product.BUS; 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 * @author Andreas Schildbach
*/ */
public class MerseyProvider extends AbstractEfaProvider public class MerseyProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://jp.merseytravel.gov.uk/nwm/";
private final static String API_BASE = "http://jp.merseytravel.gov.uk/nwm/";
public MerseyProvider() public MerseyProvider() {
{ super(NetworkId.MERSEY, API_BASE);
super(NetworkId.MERSEY, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("Europe/London"); setTimeZone("Europe/London");
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
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 @Override
protected Position parsePosition(final String position) protected Position parsePosition(final String position) {
{ if (position == null)
if (position == null) return null;
return null;
final Matcher m = P_POSITION_BOUND.matcher(position); final Matcher m = P_POSITION_BOUND.matcher(position);
if (m.matches()) if (m.matches())
return new Position(m.group(1)); 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 * @author Andreas Schildbach
*/ */
public class MetProvider extends AbstractEfaProvider public class MetProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://jp.ptv.vic.gov.au/ptv/";
private final static String API_BASE = "http://jp.ptv.vic.gov.au/ptv/";
public MetProvider() public MetProvider() {
{ super(NetworkId.MET, API_BASE);
super(NetworkId.MET, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("Australia/Melbourne"); setTimeZone("Australia/Melbourne");
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
setSessionCookieName("BIGipServerpl_ptv_jp_lbvsvr"); setSessionCookieName("BIGipServerpl_ptv_jp_lbvsvr");
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("Regional Train :".equals(longName))
{ return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Regional Train :".equals(longName)) if ("Regional Train".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("Regional Train".equals(trainName)) if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, null); return new Line(id, network, Product.REGIONAL_TRAIN, "V/Line");
if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName)) } else if ("1".equals(mot)) {
return new Line(id, network, Product.REGIONAL_TRAIN, "V/Line"); if (trainType == null && trainNum != null)
} return new Line(id, network, Product.SUBURBAN_TRAIN, trainNum);
else if ("1".equals(mot)) if ("Metropolitan Train".equals(trainName) && trainNum == null)
{ return new Line(id, network, Product.SUBURBAN_TRAIN, Strings.nullToEmpty(name));
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 static {
{ STYLES.put("R", new Style(Style.parseColor("#a24ba3"), Style.WHITE));
STYLES.put("R", new Style(Style.parseColor("#a24ba3"), Style.WHITE)); STYLES.put("S", new Style(Style.parseColor("#3a75c4"), Style.WHITE));
STYLES.put("S", new Style(Style.parseColor("#3a75c4"), Style.WHITE)); STYLES.put("T", new Style(Style.parseColor("#5bbf21"), Style.WHITE));
STYLES.put("T", new Style(Style.parseColor("#5bbf21"), Style.WHITE)); STYLES.put("B", new Style(Style.parseColor("#f77f00"), 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 * @author Andreas Schildbach
*/ */
public class MvgProvider extends AbstractEfaProvider public class MvgProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://mobil.mvg-online.de/mvgMobil/";
private static final String API_BASE = "http://mobil.mvg-online.de/mvgMobil/";
public MvgProvider() public MvgProvider() {
{ super(NetworkId.MVG, API_BASE);
super(NetworkId.MVG, API_BASE); }
}
@Override @Override
protected Position parsePosition(final String position) protected Position parsePosition(final String position) {
{ if (position == null)
if (position == null) return null;
return null;
if (position.startsWith(" - ")) if (position.startsWith(" - "))
return super.parsePosition(position.substring(3)); 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 * @author Andreas Schildbach
*/ */
public class MvvProvider extends AbstractEfaProvider public class MvvProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://efa.mvv-muenchen.de/mobile/";
private static final String API_BASE = "http://efa.mvv-muenchen.de/mobile/";
public MvvProvider() public MvvProvider() {
{ this(API_BASE);
this(API_BASE); }
}
public MvvProvider(final String apiBase) public MvvProvider(final String apiBase) {
{ super(NetworkId.MVV, apiBase);
super(NetworkId.MVV, apiBase);
setIncludeRegionId(false); setIncludeRegionId(false);
setStyles(STYLES); setStyles(STYLES);
setSessionCookieName("SIDefaalt"); setSessionCookieName("SIDefaalt");
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("Mittelrheinbahn (trans regio)".equals(trainName))
{ return new Line(id, network, Product.REGIONAL_TRAIN, "MiRhBa");
if ("Mittelrheinbahn (trans regio)".equals(trainName)) if ("Süd-Thüringen-Bahn".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "MiRhBa"); return new Line(id, network, Product.REGIONAL_TRAIN, "STB");
if ("Süd-Thüringen-Bahn".equals(longName)) if ("agilis".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "STB"); return new Line(id, network, Product.REGIONAL_TRAIN, "agilis");
if ("agilis".equals(longName)) if ("SBB".equals(trainName))
return new Line(id, network, Product.REGIONAL_TRAIN, "agilis"); return new Line(id, network, Product.REGIONAL_TRAIN, "SBB");
if ("SBB".equals(trainName)) if ("A".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "SBB"); return new Line(id, network, Product.SUBURBAN_TRAIN, "A");
if ("A".equals(trainNum)) if ("DB AG".equals(trainName))
return new Line(id, network, Product.SUBURBAN_TRAIN, "A"); return new Line(id, network, null, symbol);
if ("DB AG".equals(trainName)) } else if ("1".equals(mot)) {
return new Line(id, network, null, symbol); if ("S".equals(symbol) && "Pendelverkehr".equals(name))
} return new Line(id, network, Product.SUBURBAN_TRAIN, "S⇆");
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 @Override
protected Position parsePosition(final String position) protected Position parsePosition(final String position) {
{ if (position == null)
if (position == null) return null;
return null;
final Matcher m = P_POSITION.matcher(position); final Matcher m = P_POSITION.matcher(position);
if (m.matches()) if (m.matches()) {
{ final char t = m.group(1).charAt(0);
final char t = m.group(1).charAt(0); final Position p = super.parsePosition(m.group(2));
final Position p = super.parsePosition(m.group(2)); if (t == 'S' || t == 'U')
if (t == 'S' || t == 'U') return new Position(p.name + "(" + t + ")", p.section);
return new Position(p.name + "(" + t + ")", p.section); else
else return p;
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 static {
{ STYLES.put("SS1", new Style(Style.parseColor("#00ccff"), Style.WHITE));
STYLES.put("SS1", new Style(Style.parseColor("#00ccff"), Style.WHITE)); STYLES.put("SS2", new Style(Style.parseColor("#66cc00"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#66cc00"), Style.WHITE)); STYLES.put("SS3", new Style(Style.parseColor("#880099"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#880099"), Style.WHITE)); STYLES.put("SS4", new Style(Style.parseColor("#ff0033"), Style.WHITE));
STYLES.put("SS4", new Style(Style.parseColor("#ff0033"), Style.WHITE)); STYLES.put("SS6", new Style(Style.parseColor("#00aa66"), Style.WHITE));
STYLES.put("SS6", new Style(Style.parseColor("#00aa66"), Style.WHITE)); STYLES.put("SS7", new Style(Style.parseColor("#993333"), Style.WHITE));
STYLES.put("SS7", new Style(Style.parseColor("#993333"), Style.WHITE)); STYLES.put("SS8", new Style(Style.BLACK, Style.parseColor("#ffcc00")));
STYLES.put("SS8", new Style(Style.BLACK, Style.parseColor("#ffcc00"))); STYLES.put("SS20", new Style(Style.BLACK, Style.parseColor("#ffaaaa")));
STYLES.put("SS20", new Style(Style.BLACK, Style.parseColor("#ffaaaa"))); STYLES.put("SS27", new Style(Style.parseColor("#ffaaaa"), Style.WHITE));
STYLES.put("SS27", new Style(Style.parseColor("#ffaaaa"), Style.WHITE)); STYLES.put("SA", new Style(Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("SA", new Style(Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("T12", new Style(Style.parseColor("#883388"), Style.WHITE)); STYLES.put("T12", new Style(Style.parseColor("#883388"), Style.WHITE));
STYLES.put("T15", new Style(Style.parseColor("#3366CC"), Style.WHITE)); STYLES.put("T15", new Style(Style.parseColor("#3366CC"), Style.WHITE));
STYLES.put("T16", new Style(Style.parseColor("#CC8833"), Style.WHITE)); STYLES.put("T16", new Style(Style.parseColor("#CC8833"), Style.WHITE));
STYLES.put("T17", new Style(Style.parseColor("#993333"), Style.WHITE)); STYLES.put("T17", new Style(Style.parseColor("#993333"), Style.WHITE));
STYLES.put("T18", new Style(Style.parseColor("#66bb33"), Style.WHITE)); STYLES.put("T18", new Style(Style.parseColor("#66bb33"), Style.WHITE));
STYLES.put("T19", new Style(Style.parseColor("#cc0000"), Style.WHITE)); STYLES.put("T19", new Style(Style.parseColor("#cc0000"), Style.WHITE));
STYLES.put("T20", new Style(Style.parseColor("#00bbee"), Style.WHITE)); STYLES.put("T20", new Style(Style.parseColor("#00bbee"), Style.WHITE));
STYLES.put("T21", new Style(Style.parseColor("#33aa99"), Style.WHITE)); STYLES.put("T21", new Style(Style.parseColor("#33aa99"), Style.WHITE));
STYLES.put("T23", new Style(Style.parseColor("#fff000"), Style.WHITE)); STYLES.put("T23", new Style(Style.parseColor("#fff000"), Style.WHITE));
STYLES.put("T25", new Style(Style.parseColor("#ff9999"), Style.WHITE)); STYLES.put("T25", new Style(Style.parseColor("#ff9999"), Style.WHITE));
STYLES.put("T27", new Style(Style.parseColor("#ff6600"), 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("TN17", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN19", 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("TN20", new Style(Style.parseColor("#999999"), Style.parseColor("#ffff00")));
STYLES.put("TN27", 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("UU1", new Style(Style.parseColor("#227700"), Style.WHITE));
STYLES.put("UU2", new Style(Style.parseColor("#bb0000"), Style.WHITE)); STYLES.put("UU2", new Style(Style.parseColor("#bb0000"), Style.WHITE));
STYLES.put("UU2E", 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("UU3", new Style(Style.parseColor("#ee8800"), Style.WHITE));
STYLES.put("UU4", new Style(Style.parseColor("#00ccaa"), Style.WHITE)); STYLES.put("UU4", new Style(Style.parseColor("#00ccaa"), Style.WHITE));
STYLES.put("UU5", new Style(Style.parseColor("#bb7700"), Style.WHITE)); STYLES.put("UU5", new Style(Style.parseColor("#bb7700"), Style.WHITE));
STYLES.put("UU6", new Style(Style.parseColor("#0000cc"), 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("UU7", new Style(Style.parseColor("#227700"), Style.parseColor("#bb0000"), Style.WHITE, 0));
} }
@Override @Override
public Point[] getArea() public Point[] getArea() {
{ return new Point[] { Point.fromDouble(48.140377, 11.560643) };
return new Point[] { Point.fromDouble(48.140377, 11.560643) }; }
}
} }

View file

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

View file

@ -20,68 +20,67 @@ package de.schildbach.pte;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public enum NetworkId public enum NetworkId {
{ // Europe
// Europe RT,
RT,
// Germany // 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, 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 // Austria
OEBB, VAO, VOR, WIEN, LINZ, VVT, IVB, STV, OEBB, VAO, VOR, WIEN, LINZ, VVT, IVB, STV,
// Switzerland // Switzerland
SBB, BVB, VBL, ZVV, SBB, BVB, VBL, ZVV,
// France // France
PACA, PARIS, FRENCHSOUTHWEST, FRANCESOUTHEAST, FRANCENORTHEAST, PACA, PARIS, FRENCHSOUTHWEST, FRANCESOUTHEAST, FRANCENORTHEAST,
// Belgium // Belgium
SNCB, SNCB,
// Netherlands // Netherlands
NS, NS,
// Denmark // Denmark
DSB, DSB,
// Sweden // Sweden
SE, SE,
// Norway // Norway
NRI, NRI,
// Finland // Finland
HSL, HSL,
// Luxembourg // Luxembourg
LU, LU,
// United Kingdom // United Kingdom
TLEM, MERSEY, TLEM, MERSEY,
// Ireland // Ireland
TFI, EIREANN, TFI, EIREANN,
// Poland // Poland
PL, PL,
// Italy // Italy
ATC, IT, ATC, IT,
// United Arab Emirates // United Arab Emirates
DUB, DUB,
// Israel // Israel
JET, JET,
// United States // United States
SF, SEPTA, RTACHICAGO, SF, SEPTA, RTACHICAGO,
// Canada // Canada
ONTARIO, QUEBEC, ONTARIO, QUEBEC,
// Australia // Australia
SYDNEY, MET SYDNEY, MET
} }

View file

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

View file

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

View file

@ -30,57 +30,51 @@ import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class NsProvider extends AbstractHafasProvider public class NsProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://hafas.bene-system.com/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND }; Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
private static final Pattern HTML_NEARBY_STATIONS_PATTERN = Pattern.compile("<tr bgcolor=\"#(E7EEF9|99BAE4)\">(.*?)</tr>", Pattern.DOTALL); private static final Pattern HTML_NEARBY_STATIONS_PATTERN = Pattern
.compile("<tr bgcolor=\"#(E7EEF9|99BAE4)\">(.*?)</tr>", Pattern.DOTALL);
public NsProvider() public NsProvider() {
{ super(NetworkId.NS, API_BASE, "nn", PRODUCTS_MAP);
super(NetworkId.NS, API_BASE, "nn", PRODUCTS_MAP);
setHtmlNearbyStationsPattern(HTML_NEARBY_STATIONS_PATTERN); setHtmlNearbyStationsPattern(HTML_NEARBY_STATIONS_PATTERN);
setStationBoardHasLocation(true); setStationBoardHasLocation(true);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.type == LocationType.STATION && location.hasId()) {
if (location.type == LocationType.STATION && location.hasId()) final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
{ uri.append("?near=Anzeigen");
final StringBuilder uri = new StringBuilder(stationBoardEndpoint); uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("?near=Anzeigen"); uri.append("&input=").append(normalizeStationId(location.id));
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50); uri.append("&L=profi");
uri.append("&input=").append(normalizeStationId(location.id));
uri.append("&L=profi");
return htmlNearbyStations(uri.toString()); return htmlNearbyStations(uri.toString());
} } else {
else throw new IllegalArgumentException("cannot handle: " + location);
{ }
throw new IllegalArgumentException("cannot handle: " + location); }
}
}
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if (ucType.equals("SPR")) if (ucType.equals("SPR"))
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Avignon if (ucType.equals("N")) // Avignon
return Product.REGIONAL_TRAIN; 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 * @author Andreas Schildbach
*/ */
public class NvbwProvider extends AbstractEfaProvider 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 = "http://www.efa-bw.de/nvbw/"; // no intermeditate stops private final static String API_BASE_MOBILE = "http://www.efa-bw.de/android/";
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() public NvbwProvider() {
{ super(NetworkId.NVBW, API_BASE + DEFAULT_DEPARTURE_MONITOR_ENDPOINT, API_BASE_MOBILE + DEFAULT_TRIP_ENDPOINT,
super(NetworkId.NVBW, API_BASE + DEFAULT_DEPARTURE_MONITOR_ENDPOINT, API_BASE_MOBILE + DEFAULT_TRIP_ENDPOINT, API_BASE API_BASE + DEFAULT_STOPFINDER_ENDPOINT, API_BASE + DEFAULT_COORD_ENDPOINT);
+ DEFAULT_STOPFINDER_ENDPOINT, API_BASE + DEFAULT_COORD_ENDPOINT);
setIncludeRegionId(false); setIncludeRegionId(false);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setNumTripsRequested(12); setNumTripsRequested(12);
setSessionCookieName("EFABWLB"); 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 @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if (("ICE".equals(trainName) || "InterCityExpress".equals(trainName)) && trainNum == null)
{ return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE");
if (("ICE".equals(trainName) || "InterCityExpress".equals(trainName)) && trainNum == null) if ("InterCity".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "ICE"); return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC");
if ("InterCity".equals(trainName) && trainNum == null) if ("Fernreisezug externer EU".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "IC"); return new Line(id, network, Product.HIGH_SPEED_TRAIN, null);
if ("Fernreisezug externer EU".equals(trainName) && trainNum == null) if ("SuperCity".equals(trainName) && trainNum == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, null); return new Line(id, network, Product.HIGH_SPEED_TRAIN, "SC");
if ("SuperCity".equals(trainName) && trainNum == null) if ("InterRegio".equals(longName) && symbol == null)
return new Line(id, network, Product.HIGH_SPEED_TRAIN, "SC"); return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
if ("InterRegio".equals(longName) && symbol == null) if ("REGIOBAHN".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "IR"); return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("REGIOBAHN".equals(trainName) && trainNum == null) if ("Meridian".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, null); return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Meridian".equals(trainName) && symbol != null) if ("CityBahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); return new Line(id, network, Product.REGIONAL_TRAIN, "CB");
if ("CityBahn".equals(trainName) && trainNum == null) if ("Trilex".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "CB"); return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("Trilex".equals(trainName) && trainNum == null) if ("Bay. Seenschifffahrt".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX"); return new Line(id, network, Product.FERRY, symbol);
if ("Bay. Seenschifffahrt".equals(trainName) && symbol != null) if ("Nahverkehrszug von Dritten".equals(trainName) && trainNum == null)
return new Line(id, network, Product.FERRY, symbol); return new Line(id, network, null, "Zug");
if ("Nahverkehrszug von Dritten".equals(trainName) && trainNum == null) if ("DB".equals(trainName) && trainNum == null)
return new Line(id, network, null, "Zug"); return new Line(id, network, null, "DB");
if ("DB".equals(trainName) && trainNum == null) } else if ("1".equals(mot)) {
return new Line(id, network, null, "DB"); if (symbol != null && symbol.equals(name)) {
} final Matcher m = P_LINE_S_AVG_VBK.matcher(symbol);
else if ("1".equals(mot)) if (m.matches())
{ return new Line(id, network, Product.SUBURBAN_TRAIN, m.group(1));
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 @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException {
{ return queryMoreTripsMobile(contextObj, later);
return queryMoreTripsMobile(contextObj, later); }
}
} }

View file

@ -32,106 +32,93 @@ import de.schildbach.pte.util.StringReplaceReader;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class NvvProvider extends AbstractHafasProvider public class NvvProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "https://auskunft.nvv.de/auskunft/bin/jp/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.BUS,
Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.BUS, Product.FERRY, Product.ON_DEMAND, Product.REGIONAL_TRAIN, Product.FERRY, Product.ON_DEMAND, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN };
Product.REGIONAL_TRAIN };
public NvvProvider() public NvvProvider() {
{ super(NetworkId.NVV, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.NVV, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
httpClient.setSslAcceptAllHostnames(true); httpClient.setSslAcceptAllHostnames(true);
} }
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen", private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg",
"Darmstadt", "Aschaffenburg", "Berlin", "Fulda" }; "Kassel", "Hanau", "Göttingen", "Darmstadt", "Aschaffenburg", "Berlin", "Fulda" };
@Override @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ if (name.startsWith("F "))
if (name.startsWith("F ")) return new String[] { "Frankfurt", name.substring(2) };
return new String[] { "Frankfurt", name.substring(2) }; if (name.startsWith("OF "))
if (name.startsWith("OF ")) return new String[] { "Offenbach", name.substring(3) };
return new String[] { "Offenbach", name.substring(3) }; if (name.startsWith("MZ "))
if (name.startsWith("MZ ")) return new String[] { "Mainz", name.substring(3) };
return new String[] { "Mainz", name.substring(3) };
for (final String place : PLACES) for (final String place : PLACES) {
{ if (name.startsWith(place + " - "))
if (name.startsWith(place + " - ")) return new String[] { place, name.substring(place.length() + 3) };
return new String[] { place, name.substring(place.length() + 3) }; else if (name.startsWith(place + " ") || name.startsWith(place + "-"))
else if (name.startsWith(place + " ") || name.startsWith(place + "-")) return new String[] { place, name.substring(place.length() + 1) };
return new String[] { place, name.substring(place.length() + 1) }; }
}
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation()) {
if (location.hasLocation()) return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
{ } else if (location.type == LocationType.STATION && location.hasId()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations); final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
} uri.append("?L=vs_rmv&near=Anzeigen");
else if (location.type == LocationType.STATION && location.hasId()) uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
{ uri.append("&input=").append(normalizeStationId(location.id));
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()); return htmlNearbyStations(uri.toString());
} } else {
else throw new IllegalArgumentException("cannot handle: " + location);
{ }
throw new IllegalArgumentException("cannot handle: " + location); }
}
}
@Override @Override
protected void addCustomReplaces(final StringReplaceReader reader) protected void addCustomReplaces(final StringReplaceReader reader) {
{ reader.replace("<ul>", " ");
reader.replace("<ul>", " "); reader.replace("</ul>", " ");
reader.replace("</ul>", " "); reader.replace("<li>", " ");
reader.replace("<li>", " "); reader.replace("</li>", " ");
reader.replace("</li>", " "); reader.replace("Park&Ride", "Park&amp;Ride");
reader.replace("Park&Ride", "Park&amp;Ride"); reader.replace("C&A", "C&amp;A");
reader.replace("C&A", "C&amp;A"); }
}
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("U-BAHN".equals(ucType)) if ("U-BAHN".equals(ucType))
return Product.SUBWAY; return Product.SUBWAY;
if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich
return Product.BUS; return Product.BUS;
if ("LTAXI".equals(ucType)) if ("LTAXI".equals(ucType))
return Product.BUS; return Product.BUS;
if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt
return Product.ON_DEMAND; 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 * @author Andreas Schildbach
*/ */
public class OebbProvider extends AbstractHafasProvider public class OebbProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://fahrplan.oebb.at/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN,
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND,
Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND, Product.HIGH_SPEED_TRAIN }; Product.HIGH_SPEED_TRAIN };
public OebbProvider() public OebbProvider() {
{ super(NetworkId.OEBB, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.OEBB, API_BASE, "dn", PRODUCTS_MAP);
setDominantPlanStopTime(true); setDominantPlanStopTime(true);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation()) {
if (location.hasLocation()) return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
{ } else if (location.type == LocationType.STATION && location.hasId()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations); final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
} uri.append("?near=Suchen");
else if (location.type == LocationType.STATION && location.hasId()) uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
{ uri.append("&input=").append(normalizeStationId(location.id));
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()); return htmlNearbyStations(uri.toString());
} } else {
else throw new IllegalArgumentException("cannot handle: " + location);
{ }
throw new IllegalArgumentException("cannot handle: " + location); }
}
}
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ for (final String place : PLACES)
for (final String place : PLACES) if (name.startsWith(place + " "))
if (name.startsWith(place + " ")) return new String[] { place, name.substring(place.length() + 1) };
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if (ucType.equals("RR")) // Finnland, Connections only? if (ucType.equals("RR")) // Finnland, Connections only?
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("EE")) // Rumänien, Connections only? if (ucType.equals("EE")) // Rumänien, Connections only?
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("OZ")) // Schweden, Oeresundzug, Connections only? if (ucType.equals("OZ")) // Schweden, Oeresundzug, Connections only?
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("UUU")) // Italien, Nacht, Connections only? if (ucType.equals("UUU")) // Italien, Nacht, Connections only?
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if (ucType.equals("S2")) // Helsinki-Turku, Connections only? if (ucType.equals("S2")) // Helsinki-Turku, Connections only?
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("RE")) // RegionalExpress Deutschland if (ucType.equals("RE")) // RegionalExpress Deutschland
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("DPN")) // Connections only? TODO nicht evtl. doch eher ne S-Bahn? if (ucType.equals("DPN")) // Connections only? TODO nicht evtl. doch eher ne S-Bahn?
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("IP")) // Ozd, Ungarn if (ucType.equals("IP")) // Ozd, Ungarn
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("N")) // Frankreich, Tours if (ucType.equals("N")) // Frankreich, Tours
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("DPF")) // VX=Vogtland Express, Connections only? if (ucType.equals("DPF")) // VX=Vogtland Express, Connections only?
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if ("UAU".equals(ucType)) // Rußland if ("UAU".equals(ucType)) // Rußland
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("RSB")) // Schnellbahn Wien if (ucType.equals("RSB")) // Schnellbahn Wien
return Product.SUBURBAN_TRAIN; return Product.SUBURBAN_TRAIN;
if (ucType.equals("LKB")) // Connections only? if (ucType.equals("LKB")) // Connections only?
return Product.TRAM; return Product.TRAM;
if (ucType.equals("OBU")) // Connections only? if (ucType.equals("OBU")) // Connections only?
return Product.BUS; return Product.BUS;
if (ucType.equals("O-BUS")) // Stadtbus if (ucType.equals("O-BUS")) // Stadtbus
return Product.BUS; return Product.BUS;
if (ucType.equals("O")) // Stadtbus if (ucType.equals("O")) // Stadtbus
return Product.BUS; return Product.BUS;
if (ucType.equals("SCH")) // Connections only? if (ucType.equals("SCH")) // Connections only?
return Product.FERRY; return Product.FERRY;
if (ucType.equals("F")) // Fähre if (ucType.equals("F")) // Fähre
return Product.FERRY; return Product.FERRY;
if (ucType.equals("LIF")) if (ucType.equals("LIF"))
return Product.CABLECAR; return Product.CABLECAR;
if (ucType.equals("LIFT")) // Graz Uhrturm if (ucType.equals("LIFT")) // Graz Uhrturm
return Product.CABLECAR; return Product.CABLECAR;
if (ucType.equals("SSB")) // Graz Schlossbergbahn if (ucType.equals("SSB")) // Graz Schlossbergbahn
return Product.CABLECAR; return Product.CABLECAR;
if (ucType.equals("U70")) // U.K., Connections only? if (ucType.equals("U70")) // U.K., Connections only?
return null; return null;
if (ucType.equals("X70")) // U.K., Connections only? if (ucType.equals("X70")) // U.K., Connections only?
return null; return null;
if (ucType.equals("R84")) // U.K., Connections only? if (ucType.equals("R84")) // U.K., Connections only?
return null; return null;
if (ucType.equals("S84")) // U.K., Connections only? if (ucType.equals("S84")) // U.K., Connections only?
return null; return null;
if (ucType.equals("T84")) // U.K., Connections only? if (ucType.equals("T84")) // U.K., Connections only?
return null; return null;
return super.normalizeType(type); return super.normalizeType(type);
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -25,45 +25,42 @@ import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class RtProvider extends AbstractHafasProvider public class RtProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://railteam.hafas.de/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND }; Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public RtProvider() public RtProvider() {
{ super(NetworkId.RT, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.RT, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardHasStationTable(false); setStationBoardHasStationTable(false);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
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 @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("N".equals(ucType)) // Frankreich, Tours if ("N".equals(ucType)) // Frankreich, Tours
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("U70")) if (ucType.equals("U70"))
return null; return null;
if (ucType.equals("X70")) if (ucType.equals("X70"))
return null; return null;
if (ucType.equals("T84")) if (ucType.equals("T84"))
return null; return null;
if (P_NUMBER.matcher(type).matches()) if (P_NUMBER.matcher(type).matches())
return null; 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 * @author Andreas Schildbach
*/ */
public class RtaChicagoProvider extends AbstractEfaProvider public class RtaChicagoProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://tripplanner.rtachicago.com/ccg3/";
private final static String API_BASE = "http://tripplanner.rtachicago.com/ccg3/"; // "http://elb-jpinstances-1463028547.us-east-1.elb.amazonaws.com/ccg3/";
// "http://elb-jpinstances-1463028547.us-east-1.elb.amazonaws.com/ccg3/";
public RtaChicagoProvider() public RtaChicagoProvider() {
{ super(NetworkId.RTACHICAGO, API_BASE);
super(NetworkId.RTACHICAGO, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("America/Chicago"); setTimeZone("America/Chicago");
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
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-N".equals(symbol)) // Union Pacific North Line if ("UP-NW".equals(symbol)) // Union Pacific Northwest Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N"); return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N");
if ("UP-NW".equals(symbol)) // Union Pacific Northwest Line if ("UP-W".equals(symbol)) // Union Pacific West Line
return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-N"); return new Line(id, network, Product.SUBURBAN_TRAIN, "UP-NW");
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 * @author Andreas Schildbach
*/ */
public class SbbProvider extends AbstractHafasProvider public class SbbProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://fahrplan.sbb.ch/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS,
Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS, Product.CABLECAR, Product.REGIONAL_TRAIN, Product.TRAM }; Product.CABLECAR, Product.REGIONAL_TRAIN, Product.TRAM };
public SbbProvider() public SbbProvider() {
{ super(NetworkId.SBB, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.SBB, API_BASE, "dn", PRODUCTS_MAP);
setStationBoardHasStationTable(false); setStationBoardHasStationTable(false);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("IN".equals(ucType)) // Italien Roma-Lecce if ("IN".equals(ucType)) // Italien Roma-Lecce
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if ("IT".equals(ucType)) // Italien Roma-Venezia if ("IT".equals(ucType)) // Italien Roma-Venezia
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if ("T".equals(ucType)) if ("T".equals(ucType))
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if ("TE2".equals(ucType)) // Basel - Strasbourg if ("TE2".equals(ucType)) // Basel - Strasbourg
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if ("TX".equals(ucType)) if ("TX".equals(ucType))
return Product.BUS; return Product.BUS;
if ("NFO".equals(ucType)) if ("NFO".equals(ucType))
return Product.BUS; return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus? if ("KB".equals(ucType)) // Kleinbus?
return Product.BUS; 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 * @author Andreas Schildbach
*/ */
public class SeProvider extends AbstractHafasProvider public class SeProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://samtrafiken.hafas.de/bin/";
private static final String API_BASE = "http://samtrafiken.hafas.de/bin/"; // http://reseplanerare.resrobot.se/bin/
// http://reseplanerare.resrobot.se/bin/ // http://api.vasttrafik.se/bin/
// http://api.vasttrafik.se/bin/ private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.REGIONAL_TRAIN, Product.BUS, Product.REGIONAL_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS,
Product.REGIONAL_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY, Product.FERRY, Product.REGIONAL_TRAIN, null, null, Product.FERRY, Product.FERRY, Product.REGIONAL_TRAIN, null, null, null };
null };
public SeProvider() public SeProvider() {
{ super(NetworkId.SE, API_BASE, "sn", PRODUCTS_MAP);
super(NetworkId.SE, API_BASE, "sn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setUseIso8601(true); setUseIso8601(true);
setStationBoardHasStationTable(false); setStationBoardHasStationTable(false);
setStationBoardCanDoEquivs(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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name); if (mParen.matches())
if (mParen.matches()) return new String[] { mParen.group(2), mParen.group(1) };
return new String[] { mParen.group(2), mParen.group(1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(2), m.group(1) };
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_BUS = Pattern.compile("Buss\\s*(.*)");
private static final Pattern P_NORMALIZE_LINE_SUBWAY = Pattern.compile("Tunnelbana\\s*(.*)"); private static final Pattern P_NORMALIZE_LINE_SUBWAY = Pattern.compile("Tunnelbana\\s*(.*)");
@Override @Override
protected Line parseLineAndType(final String line) protected Line parseLineAndType(final String line) {
{ final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line); if (mBus.matches())
if (mBus.matches()) return newLine(Product.BUS, mBus.group(1), null);
return newLine(Product.BUS, mBus.group(1), null);
final Matcher mSubway = P_NORMALIZE_LINE_SUBWAY.matcher(line); final Matcher mSubway = P_NORMALIZE_LINE_SUBWAY.matcher(line);
if (mSubway.matches()) if (mSubway.matches())
return newLine(Product.SUBWAY, "T" + mSubway.group(1), null); 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 * @author Andreas Schildbach
*/ */
public class SeptaProvider extends AbstractHafasProvider public class SeptaProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://airs1.septa.org/bin/";
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 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;
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
public SeptaProvider() public SeptaProvider() {
{ super(NetworkId.SEPTA, API_BASE, "en", PRODUCTS_MAP);
super(NetworkId.SEPTA, API_BASE, "en", PRODUCTS_MAP);
setStationBoardCanDoEquivs(false); setStationBoardCanDoEquivs(false);
setTimeZone("EST"); setTimeZone("EST");
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.type == LocationType.STATION && location.hasId()) {
if (location.type == LocationType.STATION && location.hasId()) final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
{ uri.append("?near=Anzeigen");
final StringBuilder uri = new StringBuilder(stationBoardEndpoint); uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("?near=Anzeigen"); uri.append("&input=").append(normalizeStationId(location.id));
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString()); return htmlNearbyStations(uri.toString());
} } else {
else throw new IllegalArgumentException("cannot handle: " + location);
{ }
throw new IllegalArgumentException("cannot handle: " + location); }
}
}
@Override @Override
protected void appendDateTimeParameters(final StringBuilder uri, final Date time, final String dateParamName, final String timeParamName) protected void appendDateTimeParameters(final StringBuilder uri, final Date time, final String dateParamName,
{ final String timeParamName) {
final Calendar c = new GregorianCalendar(timeZone); final Calendar c = new GregorianCalendar(timeZone);
c.setTime(time); c.setTime(time);
final int year = c.get(Calendar.YEAR); final int year = c.get(Calendar.YEAR);
final int month = c.get(Calendar.MONTH) + 1; final int month = c.get(Calendar.MONTH) + 1;
final int day = c.get(Calendar.DAY_OF_MONTH); final int day = c.get(Calendar.DAY_OF_MONTH);
final int hour = c.get(Calendar.HOUR); final int hour = c.get(Calendar.HOUR);
final int minute = c.get(Calendar.MINUTE); final int minute = c.get(Calendar.MINUTE);
final String amPm = c.get(Calendar.AM_PM) == Calendar.AM ? "am" : "pm"; final String amPm = c.get(Calendar.AM_PM) == Calendar.AM ? "am" : "pm";
uri.append('&').append(dateParamName).append('='); uri.append('&').append(dateParamName).append('=');
uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d%02d%04d", month, day, year))); uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d%02d%04d", month, day, year)));
uri.append('&').append(timeParamName).append('='); uri.append('&').append(timeParamName).append('=');
uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d:%02d %s", hour, minute, amPm))); uri.append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d:%02d %s", hour, minute, amPm)));
} }
private static final Pattern P_DEPARTURES_PAGE_COARSE = Pattern private static final Pattern P_DEPARTURES_PAGE_COARSE = Pattern.compile(".*?" //
.compile( + "(?:" //
".*?" // + "<div class=\"hfsTitleText\">([^<]*)<.*?" // location
+ "(?:" // + "\n(\\d{2}/\\d{2}/\\d{4})[^\n]*\n" // date
+ "<div class=\"hfsTitleText\">([^<]*)<.*?" // location + "Departure (\\d{1,2}:\\d{2} [AP]M)\n.*?" // time
+ "\n(\\d{2}/\\d{2}/\\d{4})[^\n]*\n" // date + "(?:<table class=\"resultTable\"[^>]*>(.+?)</table>|(No trains in this space of time))" //
+ "Departure (\\d{1,2}:\\d{2} [AP]M)\n.*?" // time + "|(input cannot be interpreted)|(Verbindung zum Server konnte leider nicht hergestellt werden|kann vom Server derzeit leider nicht bearbeitet werden))" //
+ "(?:<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); 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(".*?" //
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" // + "<td class=\"time\">(\\d{1,2}:\\d{2} [AP]M)</td>\n" // plannedTime
+ "<td class=\"time\">(\\d{1,2}:\\d{2} [AP]M)</td>\n" // plannedTime + "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" //
+ "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" // + "(?:&nbsp;|<span class=\"rtLimit\\d\">(p&#252;nktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
+ "(?:&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,
+ "<img class=\"product\" src=\"/hafas-res/img/products/(\\w+)_pic\\.gif\" width=\"\\d+\" height=\"\\d+\" alt=\"([^\"]*)\".*?" // type, // line
// line + "<strong>\n" //
+ "<strong>\n" // + "<a href=\"http://airs1\\.septa\\.org/bin/stboard\\.exe/en\\?input=(\\d+)&[^>]*>" // destinationId
+ "<a href=\"http://airs1\\.septa\\.org/bin/stboard\\.exe/en\\?input=(\\d+)&[^>]*>" // destinationId + "\\s*(.*?)\\s*</a>\n" // destination
+ "\\s*(.*?)\\s*</a>\n" // destination + "</strong>.*?" //
+ "</strong>.*?" // + "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position , Pattern.DOTALL);
, Pattern.DOTALL);
@Override @Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
throws IOException final int maxDepartures, final boolean equivs) throws IOException {
{ checkNotNull(Strings.emptyToNull(stationId));
checkNotNull(Strings.emptyToNull(stationId));
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT); final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
final QueryDeparturesResult result = new QueryDeparturesResult(header); final QueryDeparturesResult result = new QueryDeparturesResult(header);
// scrape page // scrape page
final StringBuilder uri = new StringBuilder(stationBoardEndpoint); final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null); appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, false, null);
final CharSequence page = httpClient.get(uri.toString()); final CharSequence page = httpClient.get(uri.toString());
// parse page // parse page
final Matcher mPageCoarse = P_DEPARTURES_PAGE_COARSE.matcher(page); final Matcher mPageCoarse = P_DEPARTURES_PAGE_COARSE.matcher(page);
if (mPageCoarse.matches()) if (mPageCoarse.matches()) {
{ // messages
// messages if (mPageCoarse.group(5) != null) {
if (mPageCoarse.group(5) != null) result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId),
{ Collections.<Departure> emptyList(), null));
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId), return result;
Collections.<Departure> emptyList(), null)); } else if (mPageCoarse.group(6) != null)
return result; return new QueryDeparturesResult(header, Status.INVALID_STATION);
} else if (mPageCoarse.group(7) != null)
else if (mPageCoarse.group(6) != null) return new QueryDeparturesResult(header, Status.SERVICE_DOWN);
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 String[] placeAndName = splitStationName(ParserUtils.resolveEntities(mPageCoarse.group(1)));
final Calendar currentTime = new GregorianCalendar(timeZone); final Calendar currentTime = new GregorianCalendar(timeZone);
currentTime.clear(); currentTime.clear();
ParserUtils.parseAmericanDate(currentTime, mPageCoarse.group(2)); ParserUtils.parseAmericanDate(currentTime, mPageCoarse.group(2));
ParserUtils.parseAmericanTime(currentTime, mPageCoarse.group(3)); ParserUtils.parseAmericanTime(currentTime, mPageCoarse.group(3));
final List<Departure> departures = new ArrayList<Departure>(8); final List<Departure> departures = new ArrayList<Departure>(8);
String oldZebra = null; String oldZebra = null;
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mPageCoarse.group(4)); final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mPageCoarse.group(4));
while (mDepCoarse.find()) while (mDepCoarse.find()) {
{ final String zebra = mDepCoarse.group(1);
final String zebra = mDepCoarse.group(1); if (oldZebra != null && zebra.equals(oldZebra))
if (oldZebra != null && zebra.equals(oldZebra)) throw new IllegalArgumentException("missed row? last:" + zebra);
throw new IllegalArgumentException("missed row? last:" + zebra); else
else oldZebra = zebra;
oldZebra = zebra;
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2)); final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
if (mDepFine.matches()) if (mDepFine.matches()) {
{ final Calendar plannedTime = new GregorianCalendar(timeZone);
final Calendar plannedTime = new GregorianCalendar(timeZone); plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
plannedTime.setTimeInMillis(currentTime.getTimeInMillis()); ParserUtils.parseAmericanTime(plannedTime, mDepFine.group(1));
ParserUtils.parseAmericanTime(plannedTime, mDepFine.group(1));
if (plannedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS) if (plannedTime.getTimeInMillis()
plannedTime.add(Calendar.DAY_OF_MONTH, 1); - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
plannedTime.add(Calendar.DAY_OF_MONTH, 1);
final Calendar predictedTime; final Calendar predictedTime;
final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2)); final String prognosis = ParserUtils.resolveEntities(mDepFine.group(2));
if (prognosis != null) if (prognosis != null) {
{ predictedTime = new GregorianCalendar(timeZone);
predictedTime = new GregorianCalendar(timeZone); if (prognosis.equals("pünktlich")) {
if (prognosis.equals("pünktlich")) predictedTime.setTimeInMillis(plannedTime.getTimeInMillis());
{ } else {
predictedTime.setTimeInMillis(plannedTime.getTimeInMillis()); predictedTime.setTimeInMillis(currentTime.getTimeInMillis());
} ParserUtils.parseAmericanTime(predictedTime, prognosis);
else }
{ } else {
predictedTime.setTimeInMillis(currentTime.getTimeInMillis()); predictedTime = null;
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 destinationId = mDepFine.group(5);
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6)); final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final Location destination; final Location destination;
if (destinationId != null) if (destinationId != null) {
{ final String[] destinationPlaceAndName = splitStationName(destinationName);
final String[] destinationPlaceAndName = splitStationName(destinationName); destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0],
destination = new Location(LocationType.STATION, destinationId, destinationPlaceAndName[0], destinationPlaceAndName[1]); destinationPlaceAndName[1]);
} } else {
else destination = new Location(LocationType.ANY, null, null, destinationName);
{ }
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, final Departure dep = new Departure(plannedTime.getTime(),
position, destination, null, null); predictedTime != null ? predictedTime.getTime() : null, line, position, destination, null,
null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);
} } else {
else throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + stationId);
{ }
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + stationId); }
}
}
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]), result.stationDepartures.add(new StationDepartures(
departures, null)); new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]), departures, null));
return result; return result;
} } else {
else throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
{ }
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId); }
}
}
@Override @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
{ return queryMoreTripsXml(context, later);
return queryMoreTripsXml(context, later); }
}
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_LAST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(2), m.group(1) };
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
// Regional // Regional
if (ucType.equals("RAI")) if (ucType.equals("RAI"))
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
// Subway // Subway
if (ucType.equals("BSS")) if (ucType.equals("BSS"))
return Product.SUBWAY; return Product.SUBWAY;
if (ucType.equals("BSL")) if (ucType.equals("BSL"))
return Product.SUBWAY; return Product.SUBWAY;
if (ucType.equals("MFL")) if (ucType.equals("MFL"))
return Product.SUBWAY; return Product.SUBWAY;
// Tram // Tram
if (ucType.equals("TRM")) if (ucType.equals("TRM"))
return Product.TRAM; return Product.TRAM;
if (ucType.equals("NHS")) // Tro NHSL if (ucType.equals("NHS")) // Tro NHSL
return Product.TRAM; return Product.TRAM;
// Bus // Bus
if (ucType.equals("BUS")) if (ucType.equals("BUS"))
return Product.BUS; return Product.BUS;
if (ucType.equals("TRO")) if (ucType.equals("TRO"))
return Product.BUS; return Product.BUS;
// from Connections: // from Connections:
if (ucType.equals("RAIL")) if (ucType.equals("RAIL"))
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if (ucType.equals("SUBWAY")) if (ucType.equals("SUBWAY"))
return Product.SUBWAY; return Product.SUBWAY;
if (ucType.equals("TROLLEY")) if (ucType.equals("TROLLEY"))
return Product.BUS; return Product.BUS;
// skip parsing of "common" lines, because this is America // skip parsing of "common" lines, because this is America
throw new IllegalStateException("cannot normalize type '" + type + "'"); throw new IllegalStateException("cannot normalize type '" + type + "'");
} }
} }

View file

@ -30,132 +30,129 @@ import de.schildbach.pte.dto.Style;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class SfProvider extends AbstractEfaProvider public class SfProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://tripplanner.transit.511.org/mtc/";
private final static String API_BASE = "http://tripplanner.transit.511.org/mtc/";
public SfProvider() public SfProvider() {
{ super(NetworkId.SF, API_BASE);
super(NetworkId.SF, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("America/Los_Angeles"); setTimeZone("America/Los_Angeles");
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setFareCorrectionFactor(0.01f); setFareCorrectionFactor(0.01f);
setStyles(STYLES); setStyles(STYLES);
} }
@Override @Override
protected String normalizeLocationName(final String name) protected String normalizeLocationName(final String name) {
{ if (name == null || name.length() == 0)
if (name == null || name.length() == 0) return null;
return null;
return super.normalizeLocationName(name).replace("$XINT$", "&"); return super.normalizeLocationName(name).replace("$XINT$", "&");
} }
@Override @Override
protected Position parsePosition(final String position) protected Position parsePosition(final String position) {
{ if (position == null)
if (position == null) return null;
return null;
final int i = position.lastIndexOf("##"); final int i = position.lastIndexOf("##");
if (i < 0) if (i < 0)
return position.length() < 16 ? super.parsePosition(position) : null; return position.length() < 16 ? super.parsePosition(position) : null;
final String name = position.substring(i + 2).trim(); final String name = position.substring(i + 2).trim();
if (name.isEmpty()) if (name.isEmpty())
return null; return null;
return new Position(name); return new Position(name);
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if (("XAA".equals(symbol) || "Daly City / Fremont".equals(symbol))
{ && ("DALY/FREMONT".equals(name) || "Daly City / Fremont".equals(name)))
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");
return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/FRMT"); if (("FRE".equals(symbol) || "Fremont / Daly City".equals(symbol))
if (("FRE".equals(symbol) || "Fremont / Daly City".equals(symbol)) && ("FREMONT/DALY".equals(name) || "Fremont / Daly City".equals(name))) && ("FREMONT/DALY".equals(name) || "Fremont / Daly City".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/DALY"); return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/DALY");
if (("XAC".equals(symbol) || "Fremont / Richmond".equals(symbol)) && "Fremont / Richmond".equals(name)) if (("XAC".equals(symbol) || "Fremont / Richmond".equals(symbol)) && "Fremont / Richmond".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/RICH"); return new Line(id, network, Product.REGIONAL_TRAIN, "FRMT/RICH");
if (("XAD".equals(symbol) || "Richmond / Fremont".equals(symbol)) && "Richmond / Fremont".equals(name)) if (("XAD".equals(symbol) || "Richmond / Fremont".equals(symbol)) && "Richmond / Fremont".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/FRMT"); return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/FRMT");
if (("XAE".equals(symbol) || "Pittsburg Bay Point / SFO".equals(symbol)) if (("XAE".equals(symbol) || "Pittsburg Bay Point / SFO".equals(symbol))
&& ("BAY PT/SFIA".equals(name) || "Pittsburg Bay Point / SFO".equals(name))) && ("BAY PT/SFIA".equals(name) || "Pittsburg Bay Point / SFO".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "PITT/SFIA"); return new Line(id, network, Product.REGIONAL_TRAIN, "PITT/SFIA");
if (("SFI".equals(symbol) || "SFO / Pittsburg Bay Point".equals(symbol)) if (("SFI".equals(symbol) || "SFO / Pittsburg Bay Point".equals(symbol))
&& ("SFIA/BAY PT".equals(name) || "SFO / Pittsburg Bay Point".equals(name))) && ("SFIA/BAY PT".equals(name) || "SFO / Pittsburg Bay Point".equals(name)))
return new Line(id, network, Product.REGIONAL_TRAIN, "SFIA/PITT"); 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))) if (("XAF".equals(symbol) || "Millbrae / Richmond".equals(symbol))
return new Line(id, network, Product.REGIONAL_TRAIN, "MLBR/RICH"); && ("MILL/RICH".equals(name) || "Millbrae / Richmond".equals(name)))
if (("XAG".equals(symbol) || "Richmond / Millbrae".equals(symbol)) && ("RICH/MILL".equals(name) || "Richmond / Millbrae".equals(name))) return new Line(id, network, Product.REGIONAL_TRAIN, "MLBR/RICH");
return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/MLBR"); if (("XAG".equals(symbol) || "Richmond / Millbrae".equals(symbol))
if (("XAH".equals(symbol) || "Daly City / Dublin Pleasanton".equals(symbol)) && ("RICH/MILL".equals(name) || "Richmond / Millbrae".equals(name)))
&& ("DALY/DUBLIN".equals(name) || "Daly City / Dublin Pleasanton".equals(name))) return new Line(id, network, Product.REGIONAL_TRAIN, "RICH/MLBR");
return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/DUBL"); if (("XAH".equals(symbol) || "Daly City / Dublin Pleasanton".equals(symbol))
if (("XAI".equals(symbol) || "Dublin Pleasanton / Daly City".equals(symbol)) && ("DALY/DUBLIN".equals(name) || "Daly City / Dublin Pleasanton".equals(name)))
&& ("DUBLIN/DALY".equals(name) || "Dublin Pleasanton / Daly City".equals(name))) return new Line(id, network, Product.REGIONAL_TRAIN, "DALY/DUBL");
return new Line(id, network, Product.REGIONAL_TRAIN, "DUBL/DALY"); 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 if ("BAB".equals(symbol) && "BABY BULLET".equals(trainNum)) // Caltrain Baby Bullet
return new Line(id, network, Product.REGIONAL_TRAIN, "BAB"); return new Line(id, network, Product.REGIONAL_TRAIN, "BAB");
if ("LOC".equals(symbol) && "LOCAL".equals(name)) if ("LOC".equals(symbol) && "LOCAL".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "Local"); return new Line(id, network, Product.REGIONAL_TRAIN, "Local");
if ("CAP".equals(symbol) && "CAPITOL".equals(name)) if ("CAP".equals(symbol) && "CAPITOL".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "Capitol"); return new Line(id, network, Product.REGIONAL_TRAIN, "Capitol");
if ("OAK".equals(symbol) && "OAK / Coliseum".equals(name)) if ("OAK".equals(symbol) && "OAK / Coliseum".equals(name))
return new Line(id, network, Product.REGIONAL_TRAIN, "OAK/Coliseum"); return new Line(id, network, Product.REGIONAL_TRAIN, "OAK/Coliseum");
if ("Muni Rail".equals(trainName) && symbol != null) // Muni if ("Muni Rail".equals(trainName) && symbol != null) // Muni
return new Line(id, network, Product.TRAM, symbol); return new Line(id, network, Product.TRAM, symbol);
if (trainType == null && "E".equals(trainNum)) // Muni Rail E if (trainType == null && "E".equals(trainNum)) // Muni Rail E
return new Line(id, network, Product.TRAM, "E"); return new Line(id, network, Product.TRAM, "E");
if (trainType == null && "F".equals(trainNum)) // Muni Historic Streetcar if (trainType == null && "F".equals(trainNum)) // Muni Historic Streetcar
return new Line(id, network, Product.TRAM, "F"); return new Line(id, network, Product.TRAM, "F");
if (trainType == null && "J".equals(trainNum)) // Muni Metro if (trainType == null && "J".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "J"); return new Line(id, network, Product.TRAM, "J");
if (trainType == null && "K".equals(trainNum)) // Muni Metro if (trainType == null && "K".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "K"); return new Line(id, network, Product.TRAM, "K");
if (trainType == null && "KT".equals(trainNum)) // Muni Metro if (trainType == null && "KT".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "KT"); return new Line(id, network, Product.TRAM, "KT");
if (trainType == null && "L".equals(trainNum)) // Muni Metro if (trainType == null && "L".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "L"); return new Line(id, network, Product.TRAM, "L");
if (trainType == null && "M".equals(trainNum)) // Muni Metro if (trainType == null && "M".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "M"); return new Line(id, network, Product.TRAM, "M");
if (trainType == null && "N".equals(trainNum)) // Muni Metro if (trainType == null && "N".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "N"); return new Line(id, network, Product.TRAM, "N");
if (trainType == null && "T".equals(trainNum)) // Muni Metro if (trainType == null && "T".equals(trainNum)) // Muni Metro
return new Line(id, network, Product.TRAM, "T"); 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 static {
{ // BART
// BART STYLES.put("RDALY/FRMT", new Style(Style.parseColor("#4EBF49"), Style.WHITE));
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/DALY", new Style(Style.parseColor("#4EBF49"), Style.WHITE));
STYLES.put("RFRMT/RICH", 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("RRICH/FRMT", new Style(Style.parseColor("#FAA61A"), Style.WHITE));
STYLES.put("RSFIA/PITT", 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("RPITT/SFIA", new Style(Style.parseColor("#FFE800"), Style.BLACK));
STYLES.put("RMLBR/RICH", 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("RRICH/MLBR", new Style(Style.parseColor("#F81A23"), Style.WHITE));
STYLES.put("RDALY/DUBL", 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)); 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 * @author Andreas Schildbach
*/ */
public class ShProvider extends AbstractHafasProvider public class ShProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://nah.sh.hafas.de/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND }; Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public ShProvider(final String jsonApiAuthorization) public ShProvider(final String jsonApiAuthorization) {
{ super(NetworkId.SH, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.SH, API_BASE, "dn", PRODUCTS_MAP);
setJsonApiVersion("1.10"); setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"NAHSH\"}"); setJsonApiClient("{\"id\":\"NAHSH\"}");
setJsonApiAuthorization(jsonApiAuthorization); setJsonApiAuthorization(jsonApiAuthorization);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES); 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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ for (final String place : PLACES)
for (final String place : PLACES) if (name.startsWith(place + " ") || name.startsWith(place + "-"))
if (name.startsWith(place + " ") || name.startsWith(place + "-")) return new String[] { place, name.substring(place.length() + 1) };
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation())
if (location.hasLocation()) return jsonLocGeoPos(types, location.lat, location.lon);
return jsonLocGeoPos(types, location.lat, location.lon); else
else throw new IllegalArgumentException("cannot handle: " + location);
throw new IllegalArgumentException("cannot handle: " + location); }
}
@Override @Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
throws IOException final int maxDepartures, final boolean equivs) throws IOException {
{ return jsonStationBoard(stationId, time, maxDepartures, equivs);
return jsonStationBoard(stationId, time, maxDepartures, equivs); }
}
@Override @Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
{ return jsonLocMatch(constraint);
return jsonLocMatch(constraint); }
}
@Override @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return jsonTripSearch(from, to, date, dep, products, null);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
{ final JsonContext jsonContext = (JsonContext) context;
final JsonContext jsonContext = (JsonContext) context; return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
later ? jsonContext.laterContext : jsonContext.earlierContext); }
}
@Override @Override
protected Fare parseJsonTripFare(final @Nullable String fareSetName, final @Nullable String fareSetDescription, String name, protected Fare parseJsonTripFare(final @Nullable String fareSetName, final @Nullable String fareSetDescription,
final Currency currency, final float price) String name, final Currency currency, final float price) {
{ if (!"Normalpreis".equals(fareSetDescription) || !name.startsWith("Einzelfahrkarte "))
if (!"Normalpreis".equals(fareSetDescription) || !name.startsWith("Einzelfahrkarte ")) return null;
return null; name = name.substring(16);
name = name.substring(16); if (name.startsWith("Übergang"))
if (name.startsWith("Übergang")) return null;
return null; if (name.startsWith("Kind "))
if (name.startsWith("Kind ")) return new Fare("SH-Tarif", Type.CHILD, currency, price, name.substring(5), null);
return new Fare("SH-Tarif", Type.CHILD, currency, price, name.substring(5), null); else
else return new Fare("SH-Tarif", Type.ADULT, currency, price, name, null);
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 static {
{ // Busse Kiel
// Busse Kiel putKielBusStyle("1", new Style(Style.parseColor("#7288af"), Style.WHITE));
putKielBusStyle("1", new Style(Style.parseColor("#7288af"), Style.WHITE)); putKielBusStyle("2", new Style(Style.parseColor("#50bbb4"), Style.WHITE));
putKielBusStyle("2", new Style(Style.parseColor("#50bbb4"), Style.WHITE)); putKielBusStyle("5", new Style(Style.parseColor("#f39222"), Style.WHITE));
putKielBusStyle("5", new Style(Style.parseColor("#f39222"), Style.WHITE)); putKielBusStyle("6", new Style(Style.parseColor("#aec436"), Style.WHITE));
putKielBusStyle("6", new Style(Style.parseColor("#aec436"), Style.WHITE)); putKielBusStyle("8", new Style(Style.parseColor("#bcb261"), Style.WHITE));
putKielBusStyle("8", new Style(Style.parseColor("#bcb261"), Style.WHITE)); putKielBusStyle("9", new Style(Style.parseColor("#c99c7d"), Style.WHITE));
putKielBusStyle("9", new Style(Style.parseColor("#c99c7d"), Style.WHITE)); putKielBusStyle("11", new Style(Style.parseColor("#f9b000"), Style.WHITE));
putKielBusStyle("11", new Style(Style.parseColor("#f9b000"), Style.WHITE)); putKielBusStyle("22", new Style(Style.parseColor("#8ea48a"), Style.WHITE));
putKielBusStyle("22", new Style(Style.parseColor("#8ea48a"), Style.WHITE)); putKielBusStyle("31", new Style(Style.parseColor("#009ee3"), Style.WHITE));
putKielBusStyle("31", new Style(Style.parseColor("#009ee3"), Style.WHITE)); putKielBusStyle("32", 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("33", new Style(Style.parseColor("#009ee3"), Style.WHITE)); putKielBusStyle("34", 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("41", new Style(Style.parseColor("#8ba5d6"), Style.WHITE)); putKielBusStyle("42", 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("50", new Style(Style.parseColor("#00a138"), Style.WHITE)); putKielBusStyle("51", 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("52", new Style(Style.parseColor("#00a138"), Style.WHITE)); putKielBusStyle("60S", new Style(Style.parseColor("#92b4af"), Style.WHITE));
putKielBusStyle("60S", new Style(Style.parseColor("#92b4af"), Style.WHITE)); putKielBusStyle("60", 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("61", new Style(Style.parseColor("#9d1380"), Style.WHITE)); putKielBusStyle("62", 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("71", new Style(Style.parseColor("#777e6f"), Style.WHITE)); putKielBusStyle("72", 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("81", new Style(Style.parseColor("#00836e"), Style.WHITE)); putKielBusStyle("91", new Style(Style.parseColor("#947e62"), Style.WHITE));
putKielBusStyle("91", new Style(Style.parseColor("#947e62"), Style.WHITE)); putKielBusStyle("92", 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("100", new Style(Style.parseColor("#d40a11"), Style.WHITE)); putKielBusStyle("101", 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("300", new Style(Style.parseColor("#cf94c2"), Style.WHITE)); putKielBusStyle("501", new Style(Style.parseColor("#0f3f93"), Style.WHITE));
putKielBusStyle("501", new Style(Style.parseColor("#0f3f93"), Style.WHITE)); putKielBusStyle("502", 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("503", new Style(Style.parseColor("#0f3f93"), Style.WHITE)); putKielBusStyle("503S", 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("512", new Style(Style.parseColor("#0f3f93"), Style.WHITE)); putKielBusStyle("512S", 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) private static void putKielBusStyle(final String name, final Style style) {
{ STYLES.put("Autokraft Kiel GmbH|B" + name, style);
STYLES.put("Autokraft Kiel GmbH|B" + name, style); STYLES.put("Kieler Verkehrsgesellschaft mbH|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 * @author Andreas Schildbach
*/ */
public class SncbProvider extends AbstractHafasProvider public class SncbProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://www.belgianrail.be/jp/sncb-nmbs-routeplanner/";
private static final String API_BASE = "http://www.belgianrail.be/jp/sncb-nmbs-routeplanner/"; // http://hari.b-rail.be/hafas/bin/
// http://hari.b-rail.be/hafas/bin/ private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, null, Product.HIGH_SPEED_TRAIN, null,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, null, Product.HIGH_SPEED_TRAIN, null, null, Product.BUS, null, Product.BUS, Product.REGIONAL_TRAIN, null, Product.SUBWAY, Product.BUS, Product.TRAM, null, null,
Product.REGIONAL_TRAIN, null, Product.SUBWAY, Product.BUS, Product.TRAM, null, null, null, null, null }; null, null, null };
public SncbProvider() public SncbProvider() {
{ super(NetworkId.SNCB, API_BASE, "nn", PRODUCTS_MAP);
super(NetworkId.SNCB, API_BASE, "nn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStationBoardHasLocation(true); 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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ for (final String place : PLACES)
for (final String place : PLACES) if (name.startsWith(place + " ") || name.startsWith(place + "-"))
if (name.startsWith(place + " ") || name.startsWith(place + "-")) return new String[] { place, name.substring(place.length() + 1) };
return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation()) {
if (location.hasLocation()) return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations);
{ } else if (location.type == LocationType.STATION && location.hasId()) {
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations); final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
} uri.append("?near=Zoek");
else if (location.type == LocationType.STATION && location.hasId()) uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
{ uri.append("&input=").append(normalizeStationId(location.id));
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()); return htmlNearbyStations(uri.toString());
} } else {
else throw new IllegalArgumentException("cannot handle: " + location);
{ }
throw new IllegalArgumentException("cannot handle: " + location); }
}
}
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("THALYS".equals(ucType)) if ("THALYS".equals(ucType))
return Product.HIGH_SPEED_TRAIN; return Product.HIGH_SPEED_TRAIN;
if ("L".equals(ucType)) if ("L".equals(ucType))
return Product.REGIONAL_TRAIN; return Product.REGIONAL_TRAIN;
if ("MÉTRO".equals(ucType)) if ("MÉTRO".equals(ucType))
return Product.SUBWAY; return Product.SUBWAY;
if ("TRAMWAY".equals(ucType)) if ("TRAMWAY".equals(ucType))
return Product.TRAM; 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 * @author Andreas Schildbach
*/ */
public class Standard public class Standard {
{ public static final int COLOR_BACKGROUND_HIGH_SPEED_TRAIN = Style.WHITE;
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_REGIONAL_TRAIN = Style.GRAY; public static final int COLOR_BACKGROUND_SUBURBAN_TRAIN = Style.parseColor("#006e34");
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_SUBWAY = Style.parseColor("#003090"); public static final int COLOR_BACKGROUND_TRAM = Style.parseColor("#cc0000");
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_BUS = Style.parseColor("#993399"); public static final int COLOR_BACKGROUND_FERRY = Style.BLUE;
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 static {
{ STYLES.put(Product.HIGH_SPEED_TRAIN,
STYLES.put(Product.HIGH_SPEED_TRAIN, new Style(Shape.RECT, COLOR_BACKGROUND_HIGH_SPEED_TRAIN, Style.RED, Style.RED)); 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.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.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.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.TRAM, new Style(Shape.RECT, COLOR_BACKGROUND_TRAM, Style.WHITE));
STYLES.put(Product.BUS, new Style(COLOR_BACKGROUND_BUS, 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(Product.FERRY, new Style(Shape.CIRCLE, COLOR_BACKGROUND_FERRY, Style.WHITE));
STYLES.put(null, new Style(Style.DKGRAY, 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 * @author Andreas Schildbach
*/ */
public class StvProvider extends AbstractEfaProvider public class StvProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://fahrplan.verbundlinie.at/stv/";
private final static String API_BASE = "http://fahrplan.verbundlinie.at/stv/";
public StvProvider() public StvProvider() {
{ super(NetworkId.STV, API_BASE);
super(NetworkId.STV, API_BASE);
setIncludeRegionId(false); setIncludeRegionId(false);
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("M".equals(trainType) && trainNum != null)
{ return new Line(id, network, Product.REGIONAL_TRAIN, "M" + trainNum);
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 * @author Andreas Schildbach
*/ */
public class SydneyProvider extends AbstractEfaProvider public class SydneyProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "https://tp.transportnsw.info/nsw/";
private final static String API_BASE = "https://tp.transportnsw.info/nsw/";
public SydneyProvider() public SydneyProvider() {
{ super(NetworkId.SYDNEY, API_BASE);
super(NetworkId.SYDNEY, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("Australia/Sydney"); setTimeZone("Australia/Sydney");
setUseProxFootSearch(false); setUseProxFootSearch(false);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
} }
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); optimize, walkSpeed, accessibility, options));
if (products != null) if (products != null) {
{ for (final Product p : products) {
for (final Product p : products) if (p == Product.BUS)
{ uri.append("&inclMOT_11=on"); // school bus
if (p == Product.BUS) }
uri.append("&inclMOT_11=on"); // school bus }
}
}
uri.append("&inclMOT_13=on"); uri.append("&inclMOT_13=on");
uri.append("&inclMOT_14=on"); uri.append("&inclMOT_14=on");
uri.append("&inclMOT_15=on"); uri.append("&inclMOT_15=on");
uri.append("&inclMOT_16=on"); uri.append("&inclMOT_16=on");
uri.append("&inclMOT_17=on"); uri.append("&inclMOT_17=on");
return uri.toString(); return uri.toString();
} }
@Override @Override
protected String normalizeLocationName(final String name) protected String normalizeLocationName(final String name) {
{ if (name == null || name.length() == 0)
if (name == null || name.length() == 0) return null;
return null;
return super.normalizeLocationName(name).replace("$XINT$", "&"); return super.normalizeLocationName(name).replace("$XINT$", "&");
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("1".equals(mot)) {
if ("1".equals(mot)) if ("BMT".equals(symbol) || "Blue Mountains Line".equals(symbol))
{ return new Line(id, network, Product.SUBURBAN_TRAIN, "BMT");
if ("BMT".equals(symbol) || "Blue Mountains Line".equals(symbol)) if ("CCN".equals(symbol) || "Central Coast & Newcastle Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "BMT"); return new Line(id, network, Product.SUBURBAN_TRAIN, "CCN");
if ("CCN".equals(symbol) || "Central Coast & Newcastle Line".equals(symbol)) if ("SHL".equals(symbol) || "Southern Highlands Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "CCN"); return new Line(id, network, Product.SUBURBAN_TRAIN, "SHL");
if ("SHL".equals(symbol) || "Southern Highlands Line".equals(symbol)) if ("SCO".equals(symbol) || "South Coast Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SHL"); return new Line(id, network, Product.SUBURBAN_TRAIN, "SCO");
if ("SCO".equals(symbol) || "South Coast Line".equals(symbol)) if ("HUN".equals(symbol) || "Hunter Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SCO"); return new Line(id, network, Product.SUBURBAN_TRAIN, "HUN");
if ("HUN".equals(symbol) || "Hunter Line".equals(symbol)) if ("SWR".equals(symbol)) // South West Rail Link
return new Line(id, network, Product.SUBURBAN_TRAIN, "HUN"); return new Line(id, network, Product.SUBURBAN_TRAIN, "SWR");
if ("SWR".equals(symbol)) // South West Rail Link if ("NRC".equals(symbol) || (symbol != null && symbol.startsWith("North Coast NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "SWR"); return new Line(id, network, Product.SUBURBAN_TRAIN, "NRC");
if ("NRC".equals(symbol) || (symbol != null && symbol.startsWith("North Coast NSW Line"))) if ("WST".equals(symbol) || (symbol != null && symbol.startsWith("Western NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "NRC"); return new Line(id, network, Product.SUBURBAN_TRAIN, "WST");
if ("WST".equals(symbol) || (symbol != null && symbol.startsWith("Western NSW Line"))) if ("STH".equals(symbol) || (symbol != null && symbol.startsWith("Southern NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "WST"); return new Line(id, network, Product.SUBURBAN_TRAIN, "STH");
if ("STH".equals(symbol) || (symbol != null && symbol.startsWith("Southern NSW Line"))) if ("NRW".equals(symbol) || (symbol != null && symbol.startsWith("North Western NSW Line")))
return new Line(id, network, Product.SUBURBAN_TRAIN, "STH"); return new Line(id, network, Product.SUBURBAN_TRAIN, "NRW");
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) if ("T1".equals(symbol) || "T1 North Shore & Northern Line".equals(symbol)
|| "T1 Northern Line".equals(symbol) || "T1 Western Line".equals(symbol) || "T1 North Shore and Northern Line".equals(symbol) || "T1 Northern Line".equals(symbol)
|| "T1 North Shore, Northern & Western 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"); 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) if ("T2".equals(symbol) || "T2 Inner West & South Line".equals(symbol) || "T2 Airport Line".equals(symbol)
|| "T2 Airport, Inner West & South Line".equals(symbol)) || "T2 Airport, Inner West & South Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T2"); return new Line(id, network, Product.SUBURBAN_TRAIN, "T2");
if ("T3".equals(symbol) || "T3 Bankstown Line".equals(symbol)) if ("T3".equals(symbol) || "T3 Bankstown Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T3"); return new Line(id, network, Product.SUBURBAN_TRAIN, "T3");
if ("T4".equals(symbol) || "T4 Eastern Suburbs & Illawarra Line".equals(symbol)) if ("T4".equals(symbol) || "T4 Eastern Suburbs & Illawarra Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T4"); return new Line(id, network, Product.SUBURBAN_TRAIN, "T4");
if ("T5".equals(symbol) || "T5 Cumberland Line".equals(symbol)) if ("T5".equals(symbol) || "T5 Cumberland Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T5"); return new Line(id, network, Product.SUBURBAN_TRAIN, "T5");
if ("T6".equals(symbol) || "T6 Carlingford Line".equals(symbol)) if ("T6".equals(symbol) || "T6 Carlingford Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T6"); return new Line(id, network, Product.SUBURBAN_TRAIN, "T6");
if ("T7".equals(symbol) || "T7 Olympic Park Line".equals(symbol)) if ("T7".equals(symbol) || "T7 Olympic Park Line".equals(symbol))
return new Line(id, network, Product.SUBURBAN_TRAIN, "T7"); return new Line(id, network, Product.SUBURBAN_TRAIN, "T7");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'"); + "' long='" + longName + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='"
} + trainName + "'");
else if ("4".equals(mot)) } else if ("4".equals(mot)) {
{ if ("L1".equals(symbol) || "L1 Dulwich Hill Line".equals(symbol))
if ("L1".equals(symbol) || "L1 Dulwich Hill Line".equals(symbol)) return new Line(id, network, Product.TRAM, "L1");
return new Line(id, network, Product.TRAM, "L1");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'"); + "' long='" + longName + "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='"
} + trainName + "'");
else if ("9".equals(mot)) } else if ("9".equals(mot)) {
{ if ("F1".equals(symbol) || "F1 Manly".equals(symbol))
if ("F1".equals(symbol) || "F1 Manly".equals(symbol)) return new Line(id, network, Product.FERRY, "F1");
return new Line(id, network, Product.FERRY, "F1"); if ("F2".equals(symbol) || "F2 Taronga Zoo".equals(symbol))
if ("F2".equals(symbol) || "F2 Taronga Zoo".equals(symbol)) return new Line(id, network, Product.FERRY, "F2");
return new Line(id, network, Product.FERRY, "F2"); if ("F3".equals(symbol) || "F3 Parramatta River".equals(symbol))
if ("F3".equals(symbol) || "F3 Parramatta River".equals(symbol)) return new Line(id, network, Product.FERRY, "F3");
return new Line(id, network, Product.FERRY, "F3"); if ("F4".equals(symbol) || "F4 Darling Harbour".equals(symbol))
if ("F4".equals(symbol) || "F4 Darling Harbour".equals(symbol)) return new Line(id, network, Product.FERRY, "F4");
return new Line(id, network, Product.FERRY, "F4"); if ("F5".equals(symbol) || "F5 Neutral Bay".equals(symbol))
if ("F5".equals(symbol) || "F5 Neutral Bay".equals(symbol)) return new Line(id, network, Product.FERRY, "F5");
return new Line(id, network, Product.FERRY, "F5"); if ("F6".equals(symbol) || "F6 Mosman Bay".equals(symbol))
if ("F6".equals(symbol) || "F6 Mosman Bay".equals(symbol)) return new Line(id, network, Product.FERRY, "F6");
return new Line(id, network, Product.FERRY, "F6"); if ("F7".equals(symbol) || "F7 Eastern Suburbs".equals(symbol))
if ("F7".equals(symbol) || "F7 Eastern Suburbs".equals(symbol)) return new Line(id, network, Product.FERRY, "F7");
return new Line(id, network, Product.FERRY, "F7"); if (("Private ferry servic".equals(trainName) || "Private ferry and fa".equals(trainName))
if (("Private ferry servic".equals(trainName) || "Private ferry and fa".equals(trainName)) && symbol != null) && symbol != null)
return new Line(id, network, Product.FERRY, symbol); return new Line(id, network, Product.FERRY, symbol);
if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name)) if ("MFF".equals(symbol) || "Manly Fast Ferry".equals(name))
return new Line(id, network, Product.FERRY, "MFF"); return new Line(id, network, Product.FERRY, "MFF");
if ("LneCv".equals(symbol) || "Lane Cove Ferry".equals(name)) if ("LneCv".equals(symbol) || "Lane Cove Ferry".equals(name))
return new Line(id, network, Product.FERRY, "LneCv"); return new Line(id, network, Product.FERRY, "LneCv");
if ("EmpBa".equals(symbol) || "Woy Woy to Empire Bay Ferry".equals(name)) if ("EmpBa".equals(symbol) || "Woy Woy to Empire Bay Ferry".equals(name))
return new Line(id, network, Product.FERRY, "EmpBa"); return new Line(id, network, Product.FERRY, "EmpBa");
if ("Stkn".equals(symbol) || "Stockton Ferry".equals(name)) if ("Stkn".equals(symbol) || "Stockton Ferry".equals(name))
return new Line(id, network, Product.FERRY, "Stkn"); return new Line(id, network, Product.FERRY, "Stkn");
throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name + "' long='" + longName throw new IllegalStateException("cannot normalize mot='" + mot + "' symbol='" + symbol + "' name='" + name
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'"); + "' 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 static {
{ STYLES.put("SBMT", new Style(Style.parseColor("#f5a81d"), Style.WHITE));
STYLES.put("SBMT", new Style(Style.parseColor("#f5a81d"), Style.WHITE)); STYLES.put("SCCN", new Style(Style.parseColor("#d11f2f"), Style.WHITE));
STYLES.put("SCCN", new Style(Style.parseColor("#d11f2f"), Style.WHITE)); STYLES.put("SSHL", new Style(Style.parseColor("#843135"), Style.WHITE));
STYLES.put("SSHL", new Style(Style.parseColor("#843135"), Style.WHITE)); STYLES.put("SSCO", new Style(Style.parseColor("#0083bf"), Style.WHITE));
STYLES.put("SSCO", new Style(Style.parseColor("#0083bf"), Style.WHITE)); STYLES.put("SHUN", new Style(Style.parseColor("#509e45"), Style.WHITE));
STYLES.put("SHUN", new Style(Style.parseColor("#509e45"), Style.WHITE));
STYLES.put("ST1", new Style(Style.parseColor("#f4a00e"), Style.WHITE)); STYLES.put("ST1", new Style(Style.parseColor("#f4a00e"), Style.WHITE));
STYLES.put("ST2", new Style(Style.parseColor("#48a338"), Style.WHITE)); STYLES.put("ST2", new Style(Style.parseColor("#48a338"), Style.WHITE));
STYLES.put("ST3", new Style(Style.parseColor("#f25223"), Style.WHITE)); STYLES.put("ST3", new Style(Style.parseColor("#f25223"), Style.WHITE));
STYLES.put("ST4", new Style(Style.parseColor("#1081c5"), Style.WHITE)); STYLES.put("ST4", new Style(Style.parseColor("#1081c5"), Style.WHITE));
STYLES.put("ST5", new Style(Style.parseColor("#c72c9e"), Style.WHITE)); STYLES.put("ST5", new Style(Style.parseColor("#c72c9e"), Style.WHITE));
STYLES.put("ST6", new Style(Style.parseColor("#3a5b9a"), Style.WHITE)); STYLES.put("ST6", new Style(Style.parseColor("#3a5b9a"), Style.WHITE));
STYLES.put("ST7", new Style(Style.parseColor("#97a2ad"), 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("B130", new Style(Style.parseColor("#878787"), Style.WHITE));
STYLES.put("B131", new Style(Style.parseColor("#bcbcbc"), Style.WHITE)); STYLES.put("B131", new Style(Style.parseColor("#bcbcbc"), Style.WHITE));
STYLES.put("B132", new Style(Style.parseColor("#f08cb5"), Style.WHITE)); STYLES.put("B132", new Style(Style.parseColor("#f08cb5"), Style.WHITE));
STYLES.put("B135", new Style(Style.parseColor("#80ba27"), Style.WHITE)); STYLES.put("B135", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B136", new Style(Style.parseColor("#f18f00"), Style.WHITE)); STYLES.put("B136", new Style(Style.parseColor("#f18f00"), Style.WHITE));
STYLES.put("B137", 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("B139", new Style(Style.parseColor("#009fc8"), Style.WHITE));
STYLES.put("BL60", new Style(Style.parseColor("#cad400"), Style.WHITE)); STYLES.put("BL60", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B140", new Style(Style.parseColor("#e63329"), Style.WHITE)); STYLES.put("B140", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B142", new Style(Style.parseColor("#80ba27"), Style.WHITE)); STYLES.put("B142", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B143", new Style(Style.parseColor("#e63329"), Style.WHITE)); STYLES.put("B143", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B144", 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("BE50", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B151", 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("B153", new Style(Style.parseColor("#80ba27"), Style.WHITE));
STYLES.put("B155", new Style(Style.parseColor("#1d1d1b"), Style.WHITE)); STYLES.put("B155", new Style(Style.parseColor("#1d1d1b"), Style.WHITE));
STYLES.put("B156", 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("B158", new Style(Style.parseColor("#a05c00"), Style.WHITE));
STYLES.put("B159", 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("BE65", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE66", new Style(Style.parseColor("#ab3a8d"), Style.WHITE)); STYLES.put("BE66", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B168", 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("BE68", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B169", new Style(Style.parseColor("#a0c9ed"), Style.WHITE)); STYLES.put("B169", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("BE69", 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("BE70", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B171", new Style(Style.parseColor("#ab3a8d"), Style.WHITE)); STYLES.put("B171", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE71", 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("B173", new Style(Style.parseColor("#a0c9ed"), Style.WHITE));
STYLES.put("B175", new Style(Style.parseColor("#ab3a8d"), Style.WHITE)); STYLES.put("B175", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B176", 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("BE76", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE77", 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("B178", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("BE78", 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("BL78", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B179", 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("BE79", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B180", 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("BL80", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B183", new Style(Style.parseColor("#e63329"), Style.WHITE)); STYLES.put("B183", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE83", new Style(Style.parseColor("#701c74"), Style.WHITE)); STYLES.put("BE83", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B184", new Style(Style.parseColor("#e63329"), Style.WHITE)); STYLES.put("B184", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL84", 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("BE84", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("B185", 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("BL85", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BE85", new Style(Style.parseColor("#701c74"), Style.WHITE)); STYLES.put("BE85", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE86", 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("B187", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL87", 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("BE87", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B188", new Style(Style.parseColor("#e63329"), Style.WHITE)); STYLES.put("B188", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL88", 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("BE88", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("BE89", 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("B190", new Style(Style.parseColor("#e63329"), Style.WHITE));
STYLES.put("BL90", 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("B200", new Style(Style.parseColor("#c27ab1"), Style.WHITE));
STYLES.put("B201", new Style(Style.parseColor("#d0043c"), Style.WHITE)); STYLES.put("B201", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B202", 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("B203", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#701c74"), Style.WHITE)); STYLES.put("B204", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B205", 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("B206", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B207", 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("B208", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B209", 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("B225", new Style(Style.parseColor("#f08cb5"), Style.WHITE));
STYLES.put("B227", new Style(Style.parseColor("#ffed00"), Style.BLACK)); STYLES.put("B227", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B228", 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("B229", new Style(Style.parseColor("#ffed00"), Style.BLACK));
STYLES.put("B230", 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("B236", new Style(Style.parseColor("#aa6500"), Style.WHITE));
STYLES.put("B238", new Style(Style.parseColor("#fbc684"), Style.BLACK)); STYLES.put("B238", new Style(Style.parseColor("#fbc684"), Style.BLACK));
STYLES.put("B243", new Style(Style.parseColor("#b8d484"), Style.WHITE)); STYLES.put("B243", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B244", 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("B245", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B246", 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("B247", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B248", 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("B249", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B251", new Style(Style.parseColor("#747b0e"), Style.WHITE)); STYLES.put("B251", new Style(Style.parseColor("#747b0e"), Style.WHITE));
STYLES.put("B252", 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("B253", new Style(Style.parseColor("#004a9a"), Style.WHITE));
STYLES.put("B254", 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("B257", new Style(Style.parseColor("#fbba00"), Style.BLACK));
STYLES.put("B261", new Style(Style.parseColor("#e56606"), Style.WHITE)); STYLES.put("B261", new Style(Style.parseColor("#e56606"), Style.WHITE));
STYLES.put("B263", new Style(Style.parseColor("#d0043c"), Style.WHITE)); STYLES.put("B263", new Style(Style.parseColor("#d0043c"), Style.WHITE));
STYLES.put("B265", new Style(Style.parseColor("#c8007c"), Style.WHITE)); STYLES.put("B265", new Style(Style.parseColor("#c8007c"), Style.WHITE));
STYLES.put("B267", new Style(Style.parseColor("#b8d484"), Style.WHITE)); STYLES.put("B267", new Style(Style.parseColor("#b8d484"), Style.WHITE));
STYLES.put("B269", new Style(Style.parseColor("#cad400"), Style.BLACK)); STYLES.put("B269", new Style(Style.parseColor("#cad400"), Style.BLACK));
STYLES.put("B273", new Style(Style.parseColor("#b5aba1"), Style.WHITE)); STYLES.put("B273", new Style(Style.parseColor("#b5aba1"), Style.WHITE));
STYLES.put("B272", new Style(Style.parseColor("#701c74"), Style.WHITE)); STYLES.put("B272", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B275", new Style(Style.parseColor("#aa6500"), Style.WHITE)); STYLES.put("B275", new Style(Style.parseColor("#aa6500"), Style.WHITE));
STYLES.put("B285", new Style(Style.parseColor("#cad400"), Style.WHITE)); STYLES.put("B285", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B286", new Style(Style.parseColor("#b2b2b2"), Style.WHITE)); STYLES.put("B286", new Style(Style.parseColor("#b2b2b2"), Style.WHITE));
STYLES.put("B288", new Style(Style.parseColor("#009984"), Style.WHITE)); STYLES.put("B288", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B290", new Style(Style.parseColor("#e5007d"), Style.WHITE)); STYLES.put("B290", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B292", new Style(Style.parseColor("#009984"), Style.WHITE)); STYLES.put("B292", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B293", new Style(Style.parseColor("#701c74"), Style.WHITE)); STYLES.put("B293", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B294", new Style(Style.parseColor("#8ac199"), Style.WHITE)); STYLES.put("B294", new Style(Style.parseColor("#8ac199"), Style.WHITE));
STYLES.put("B295", new Style(Style.parseColor("#bee4f6"), Style.BLACK)); STYLES.put("B295", new Style(Style.parseColor("#bee4f6"), Style.BLACK));
STYLES.put("B297", new Style(Style.parseColor("#701c74"), Style.WHITE)); STYLES.put("B297", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B300", new Style(Style.parseColor("#636466"), Style.WHITE)); STYLES.put("B300", new Style(Style.parseColor("#636466"), Style.WHITE));
STYLES.put("B301", new Style(Style.parseColor("#e4358b"), Style.WHITE)); STYLES.put("B301", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B302", 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("B303", new Style(Style.parseColor("#00704a"), Style.WHITE));
STYLES.put("BX03", 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("B305", new Style(Style.parseColor("#abcc58"), Style.WHITE));
STYLES.put("B308", new Style(Style.parseColor("#ad208e"), Style.WHITE)); STYLES.put("B308", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B309", new Style(Style.parseColor("#eb5b25"), Style.WHITE)); STYLES.put("B309", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("BX09", 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("BL09", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B310", 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("BX10", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B311", new Style(Style.parseColor("#cab900"), Style.WHITE)); STYLES.put("B311", new Style(Style.parseColor("#cab900"), Style.WHITE));
STYLES.put("B313", new Style(Style.parseColor("#e4358b"), Style.WHITE)); STYLES.put("B313", new Style(Style.parseColor("#e4358b"), Style.WHITE));
STYLES.put("B314", new Style(Style.parseColor("#f59d21"), Style.WHITE)); STYLES.put("B314", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B316", 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("B317", new Style(Style.parseColor("#f59d21"), Style.WHITE));
STYLES.put("B323", new Style(Style.parseColor("#009fe3"), Style.WHITE)); STYLES.put("B323", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B324", new Style(Style.parseColor("#4da32f"), Style.WHITE)); STYLES.put("B324", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("BL24", 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("B325", new Style(Style.parseColor("#22317f"), Style.WHITE));
STYLES.put("B326", new Style(Style.parseColor("#ab3a8d"), Style.WHITE)); STYLES.put("B326", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B327", new Style(Style.parseColor("#d54b0b"), Style.WHITE)); STYLES.put("B327", new Style(Style.parseColor("#d54b0b"), Style.WHITE));
STYLES.put("B333", new Style(Style.parseColor("#009fe3"), Style.WHITE)); STYLES.put("B333", new Style(Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B339", new Style(Style.parseColor("#9d5da2"), Style.WHITE)); STYLES.put("B339", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("BX39", 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("BX40", new Style(Style.parseColor("#9d5da2"), Style.WHITE));
STYLES.put("B343", new Style(Style.parseColor("#f192b3"), Style.WHITE)); STYLES.put("B343", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B348", new Style(Style.parseColor("#007db1"), Style.WHITE)); STYLES.put("B348", new Style(Style.parseColor("#007db1"), Style.WHITE));
STYLES.put("B352", new Style(Style.parseColor("#ad208e"), Style.WHITE)); STYLES.put("B352", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B353", new Style(Style.parseColor("#abcc58"), Style.WHITE)); STYLES.put("B353", new Style(Style.parseColor("#abcc58"), Style.WHITE));
STYLES.put("B355", new Style(Style.parseColor("#ad208e"), Style.WHITE)); STYLES.put("B355", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("B360", new Style(Style.parseColor("#f192b3"), Style.WHITE)); STYLES.put("B360", new Style(Style.parseColor("#f192b3"), Style.WHITE));
STYLES.put("B361", 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("B370", new Style(Style.parseColor("#009ddc"), Style.WHITE));
STYLES.put("B372", new Style(Style.parseColor("#006944"), Style.WHITE)); STYLES.put("B372", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B373", 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("BX73", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B374", 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("BX74", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("B376", 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("B377", new Style(Style.parseColor("#006944"), Style.WHITE));
STYLES.put("BX77", 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("B378", new Style(Style.parseColor("#4da32f"), Style.WHITE));
STYLES.put("B380", new Style(Style.parseColor("#0070ba"), Style.WHITE)); STYLES.put("B380", new Style(Style.parseColor("#0070ba"), Style.WHITE));
STYLES.put("B381", new Style(Style.parseColor("#eb5b25"), Style.WHITE)); STYLES.put("B381", new Style(Style.parseColor("#eb5b25"), Style.WHITE));
STYLES.put("B382", new Style(Style.parseColor("#f9b122"), Style.WHITE)); STYLES.put("B382", new Style(Style.parseColor("#f9b122"), Style.WHITE));
STYLES.put("B386", new Style(Style.parseColor("#943e01"), Style.WHITE)); STYLES.put("B386", new Style(Style.parseColor("#943e01"), Style.WHITE));
STYLES.put("B387", 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("B389", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("BX84", 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("BX89", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("B391", new Style(Style.parseColor("#009984"), Style.WHITE)); STYLES.put("B391", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B392", 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("BX92", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B393", 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("B394", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BL94", 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("BX94", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("B395", 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("B396", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX96", 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("B397", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX97", 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("B399", new Style(Style.parseColor("#009984"), Style.WHITE));
STYLES.put("BX99", 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("B400", new Style(Style.parseColor("#eb4498"), Style.WHITE));
STYLES.put("B401", new Style(Style.parseColor("#f06597"), Style.WHITE)); STYLES.put("B401", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#ec881d"), Style.WHITE)); STYLES.put("B406", new Style(Style.parseColor("#ec881d"), Style.WHITE));
STYLES.put("B407", new Style(Style.parseColor("#a8005b"), Style.WHITE)); STYLES.put("B407", new Style(Style.parseColor("#a8005b"), Style.WHITE));
STYLES.put("B408", new Style(Style.parseColor("#ed1d24"), Style.WHITE)); STYLES.put("B408", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B410", new Style(Style.parseColor("#6c207e"), Style.WHITE)); STYLES.put("B410", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B412", new Style(Style.parseColor("#006838"), Style.WHITE)); STYLES.put("B412", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B413", 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("B415", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#8a5e3c"), Style.WHITE)); STYLES.put("B418", new Style(Style.parseColor("#8a5e3c"), Style.WHITE));
STYLES.put("B422", new Style(Style.parseColor("#39b54a"), Style.WHITE)); STYLES.put("B422", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B423", 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("B426", new Style(Style.parseColor("#39b54a"), Style.WHITE));
STYLES.put("B428", 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("BL23", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B430", new Style(Style.parseColor("#f06597"), Style.WHITE)); STYLES.put("B430", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#ed1d24"), Style.WHITE)); STYLES.put("B431", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B433", 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("B436", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B438", new Style(Style.parseColor("#2b3990"), Style.WHITE)); STYLES.put("B438", new Style(Style.parseColor("#2b3990"), Style.WHITE));
STYLES.put("B439", 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("B440", new Style(Style.parseColor("#f06597"), Style.WHITE));
STYLES.put("B441", new Style(Style.parseColor("#fbb040"), Style.WHITE)); STYLES.put("B441", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B442", 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("B443", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B444", 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("B445", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B448", new Style(Style.parseColor("#6c207e"), Style.WHITE)); STYLES.put("B448", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("B458", new Style(Style.parseColor("#0093d0"), Style.WHITE)); STYLES.put("B458", new Style(Style.parseColor("#0093d0"), Style.WHITE));
STYLES.put("B459", 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("B460", new Style(Style.parseColor("#ef4136"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#00aeef"), Style.WHITE)); STYLES.put("B461", new Style(Style.parseColor("#00aeef"), Style.WHITE));
STYLES.put("B462", new Style(Style.parseColor("#603913"), Style.WHITE)); STYLES.put("B462", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B463", new Style(Style.parseColor("#ec881d"), Style.WHITE)); STYLES.put("B463", new Style(Style.parseColor("#ec881d"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#603913"), Style.WHITE)); STYLES.put("B464", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B466", new Style(Style.parseColor("#006838"), Style.WHITE)); STYLES.put("B466", new Style(Style.parseColor("#006838"), Style.WHITE));
STYLES.put("B470", new Style(Style.parseColor("#603913"), Style.WHITE)); STYLES.put("B470", new Style(Style.parseColor("#603913"), Style.WHITE));
STYLES.put("B473", new Style(Style.parseColor("#ed1d24"), Style.WHITE)); STYLES.put("B473", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B476", new Style(Style.parseColor("#1c75bc"), Style.WHITE)); STYLES.put("B476", new Style(Style.parseColor("#1c75bc"), Style.WHITE));
STYLES.put("B477", 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("B478", new Style(Style.parseColor("#fbb040"), Style.WHITE));
STYLES.put("B479", new Style(Style.parseColor("#ed1d24"), Style.WHITE)); STYLES.put("B479", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B480", new Style(Style.parseColor("#0054a6"), Style.WHITE)); STYLES.put("B480", new Style(Style.parseColor("#0054a6"), Style.WHITE));
STYLES.put("B483", 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("B487", new Style(Style.parseColor("#ec008c"), Style.WHITE));
STYLES.put("B490", new Style(Style.parseColor("#a54399"), Style.WHITE)); STYLES.put("B490", new Style(Style.parseColor("#a54399"), Style.WHITE));
STYLES.put("B491", new Style(Style.parseColor("#fdb913"), Style.WHITE)); STYLES.put("B491", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("B492", new Style(Style.parseColor("#a54399"), Style.WHITE)); STYLES.put("B492", new Style(Style.parseColor("#a54399"), Style.WHITE));
STYLES.put("B495", new Style(Style.parseColor("#ed1d24"), Style.WHITE)); STYLES.put("B495", new Style(Style.parseColor("#ed1d24"), Style.WHITE));
STYLES.put("B500", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("B500", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BX00", 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("B501", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B502", new Style(Style.parseColor("#27aae1"), Style.WHITE)); STYLES.put("B502", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("B504", 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("BX04", new Style(Style.parseColor("#27aae1"), Style.WHITE));
STYLES.put("B505", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("B505", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B506", 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("BX06", new Style(Style.parseColor("#701c74"), Style.WHITE));
STYLES.put("B507", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("B507", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B508", new Style(Style.parseColor("#e5007d"), Style.WHITE)); STYLES.put("B508", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B510", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("B510", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B513", new Style(Style.parseColor("#cad400"), Style.WHITE)); STYLES.put("B513", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B515", new Style(Style.parseColor("#8ab2df"), Style.WHITE)); STYLES.put("B515", new Style(Style.parseColor("#8ab2df"), Style.WHITE));
STYLES.put("BX15", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("BX15", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B518", new Style(Style.parseColor("#8ab2df"), Style.WHITE)); STYLES.put("B518", new Style(Style.parseColor("#8ab2df"), Style.WHITE));
STYLES.put("BX18", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("BX18", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("B520", 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("B521", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B523", 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("B524", new Style(Style.parseColor("#56af31"), Style.WHITE));
STYLES.put("B525", new Style(Style.parseColor("#fdb913"), Style.WHITE)); STYLES.put("B525", new Style(Style.parseColor("#fdb913"), Style.WHITE));
STYLES.put("B526", 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("BL37", new Style(Style.parseColor("#c95c30"), Style.WHITE));
STYLES.put("BL38", new Style(Style.parseColor("#6c207e"), Style.WHITE)); STYLES.put("BL38", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("BL39", 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("B544", new Style(Style.parseColor("#b59d00"), Style.WHITE));
STYLES.put("B545", new Style(Style.parseColor("#e5007d"), Style.WHITE)); STYLES.put("B545", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B546", new Style(Style.parseColor("#ab3a8d"), Style.WHITE)); STYLES.put("B546", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B547", new Style(Style.parseColor("#ffdd00"), Style.BLACK)); STYLES.put("B547", new Style(Style.parseColor("#ffdd00"), Style.BLACK));
STYLES.put("B549", new Style(Style.parseColor("#f28c00"), Style.WHITE)); STYLES.put("B549", new Style(Style.parseColor("#f28c00"), Style.WHITE));
STYLES.put("B550", new Style(Style.parseColor("#e5007d"), Style.WHITE)); STYLES.put("B550", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B551", new Style(Style.parseColor("#cad400"), Style.WHITE)); STYLES.put("B551", new Style(Style.parseColor("#cad400"), Style.WHITE));
STYLES.put("B552", new Style(Style.parseColor("#ab3a8d"), Style.WHITE)); STYLES.put("B552", new Style(Style.parseColor("#ab3a8d"), Style.WHITE));
STYLES.put("B555", new Style(Style.parseColor("#00b3f0"), 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("B890", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B891", 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("B892", new Style(Style.parseColor("#eb5b25"), Style.parseColor("#ffed00")));
STYLES.put("B895", 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("BL28", new Style(Style.parseColor("#6c207e"), Style.WHITE));
STYLES.put("BM10", new Style(Style.parseColor("#e9559f"), Style.WHITE)); STYLES.put("BM10", new Style(Style.parseColor("#e9559f"), Style.WHITE));
STYLES.put("BM20", new Style(Style.parseColor("#f7941e"), Style.WHITE)); STYLES.put("BM20", new Style(Style.parseColor("#f7941e"), Style.WHITE));
STYLES.put("BM30", new Style(Style.parseColor("#ad208e"), Style.WHITE)); STYLES.put("BM30", new Style(Style.parseColor("#ad208e"), Style.WHITE));
STYLES.put("BM40", new Style(Style.parseColor("#ca220e"), Style.WHITE)); STYLES.put("BM40", new Style(Style.parseColor("#ca220e"), Style.WHITE));
STYLES.put("BM41", new Style(Style.parseColor("#b2d33e"), Style.WHITE)); STYLES.put("BM41", new Style(Style.parseColor("#b2d33e"), Style.WHITE));
STYLES.put("BM50", new Style(Style.parseColor("#92278f"), Style.WHITE)); STYLES.put("BM50", new Style(Style.parseColor("#92278f"), Style.WHITE));
STYLES.put("BM52", new Style(Style.parseColor("#9c8dc3"), Style.WHITE)); STYLES.put("BM52", new Style(Style.parseColor("#9c8dc3"), Style.WHITE));
STYLES.put("BM54", new Style(Style.parseColor("#0070ba"), Style.WHITE)); STYLES.put("BM54", new Style(Style.parseColor("#0070ba"), Style.WHITE));
STYLES.put("BN", new Style(Style.parseColor("#051925"), Style.WHITE)); STYLES.put("BN", new Style(Style.parseColor("#051925"), Style.WHITE));
STYLES.put("FF1", new Style(Style.parseColor("#0c754b"), Style.WHITE)); STYLES.put("FF1", new Style(Style.parseColor("#0c754b"), Style.WHITE));
STYLES.put("FF2", new Style(Style.parseColor("#1e4230"), Style.WHITE)); STYLES.put("FF2", new Style(Style.parseColor("#1e4230"), Style.WHITE));
STYLES.put("FF3", new Style(Style.parseColor("#8acf24"), Style.WHITE)); STYLES.put("FF3", new Style(Style.parseColor("#8acf24"), Style.WHITE));
STYLES.put("FF4", new Style(Style.parseColor("#0b974a"), Style.WHITE)); STYLES.put("FF4", new Style(Style.parseColor("#0b974a"), Style.WHITE));
STYLES.put("FF5", new Style(Style.parseColor("#2a5d3d"), Style.WHITE)); STYLES.put("FF5", new Style(Style.parseColor("#2a5d3d"), Style.WHITE));
STYLES.put("FF6", new Style(Style.parseColor("#19ae4d"), Style.WHITE)); STYLES.put("FF6", new Style(Style.parseColor("#19ae4d"), Style.WHITE));
STYLES.put("FF7", new Style(Style.parseColor("#2bb683"), 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 * @author Andreas Schildbach
*/ */
public class TfiProvider extends AbstractEfaProvider public class TfiProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://www.journeyplanner.transportforireland.ie/nta/";
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() public TfiProvider() {
{ super(NetworkId.TFI, API_BASE);
super(NetworkId.TFI, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("Europe/London"); setTimeZone("Europe/London");
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("DART".equals(name))
{ return new Line(id, network, Product.SUBURBAN_TRAIN, "DART");
if ("DART".equals(name)) if ("Rail".equals(trainName) && trainNum == null)
return new Line(id, network, Product.SUBURBAN_TRAIN, "DART"); return new Line(id, network, null, "Rail");
if ("Rail".equals(trainName) && trainNum == null) if ("Train".equals(name) && "Train".equals(symbol))
return new Line(id, network, null, "Rail"); return new Line(id, network, null, "Train");
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 * @author Andreas Schildbach
*/ */
public class TlemProvider extends AbstractEfaProvider public class TlemProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://www.travelineeastmidlands.co.uk/em/";
private final static String API_BASE = "http://www.travelineeastmidlands.co.uk/em/";
// http://www.travelineeastmidlands.co.uk/em/ // http://www.travelineeastmidlands.co.uk/em/
// http://www.travelinesw.com/swe/ // http://www.travelinesw.com/swe/
// http://www.travelinesoutheast.org.uk/se/ // http://www.travelinesoutheast.org.uk/se/
// http://www.travelineeastanglia.org.uk/ea/ // http://www.travelineeastanglia.org.uk/ea/
// http://www.travelinemidlands.co.uk/wmtis/ // http://www.travelinemidlands.co.uk/wmtis/
// http://jp.networkwestmidlands.com/centro/ // http://jp.networkwestmidlands.com/centro/
public TlemProvider() public TlemProvider() {
{ super(NetworkId.TLEM, API_BASE);
super(NetworkId.TLEM, API_BASE);
setLanguage("en"); setLanguage("en");
setTimeZone("Europe/London"); setTimeZone("Europe/London");
setUseProxFootSearch(false); setUseProxFootSearch(false);
setStyles(STYLES); setStyles(STYLES);
} }
@Override @Override
protected String normalizeLocationName(final String name) protected String normalizeLocationName(final String name) {
{ final String normalizedName = super.normalizeLocationName(name);
final String normalizedName = super.normalizeLocationName(name); if (normalizedName != null && normalizedName.endsWith(" ()"))
if (normalizedName != null && normalizedName.endsWith(" ()")) return normalizedName.substring(0, normalizedName.length() - 3);
return normalizedName.substring(0, normalizedName.length() - 3); else
else return normalizedName;
return normalizedName; }
}
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("1".equals(mot)) {
if ("1".equals(mot)) if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName)))
{ return new Line(id, network, Product.SUBURBAN_TRAIN, "DLR");
if (trainType == null && ("DLR".equals(trainNum) || "Light Railway".equals(trainName))) } else if ("13".equals(mot)) {
return new Line(id, network, Product.SUBURBAN_TRAIN, "DLR"); if ("OO".equals(trainType) || "Ordinary passenger (o.pas.)".equals(trainName))
} return new Line(id, network, Product.REGIONAL_TRAIN, "OO" + Strings.nullToEmpty(trainNum));
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 static {
{ // London
// London STYLES.put("UBakerloo", new Style(Style.parseColor("#9D5324"), Style.WHITE));
STYLES.put("UBakerloo", new Style(Style.parseColor("#9D5324"), Style.WHITE)); STYLES.put("UCentral", new Style(Style.parseColor("#D52B1E"), Style.WHITE));
STYLES.put("UCentral", new Style(Style.parseColor("#D52B1E"), Style.WHITE)); STYLES.put("UCircle", new Style(Style.parseColor("#FECB00"), Style.BLACK));
STYLES.put("UCircle", new Style(Style.parseColor("#FECB00"), Style.BLACK)); STYLES.put("UDistrict", new Style(Style.parseColor("#007934"), Style.WHITE));
STYLES.put("UDistrict", new Style(Style.parseColor("#007934"), Style.WHITE)); STYLES.put("UEast London", new Style(Style.parseColor("#FFA100"), 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("UHammersmith & City", new Style(Style.parseColor("#C5858F"), Style.BLACK)); STYLES.put("UJubilee", new Style(Style.parseColor("#818A8F"), Style.WHITE));
STYLES.put("UJubilee", new Style(Style.parseColor("#818A8F"), Style.WHITE)); STYLES.put("UMetropolitan", new Style(Style.parseColor("#850057"), Style.WHITE));
STYLES.put("UMetropolitan", new Style(Style.parseColor("#850057"), Style.WHITE)); STYLES.put("UNorthern", new Style(Style.BLACK, Style.WHITE));
STYLES.put("UNorthern", new Style(Style.BLACK, Style.WHITE)); STYLES.put("UPiccadilly", new Style(Style.parseColor("#0018A8"), Style.WHITE));
STYLES.put("UPiccadilly", new Style(Style.parseColor("#0018A8"), Style.WHITE)); STYLES.put("UVictoria", new Style(Style.parseColor("#00A1DE"), 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("UWaterloo & City", new Style(Style.parseColor("#76D2B6"), Style.BLACK));
STYLES.put("SDLR", new Style(Style.parseColor("#00B2A9"), Style.WHITE)); STYLES.put("SDLR", new Style(Style.parseColor("#00B2A9"), Style.WHITE));
STYLES.put("SLO", new Style(Style.parseColor("#f46f1a"), 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 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 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 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 * @author Andreas Schildbach
*/ */
public class VagfrProvider extends AbstractEfaProvider public class VagfrProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "https://efaserver.vag-freiburg.de/vagfr/";
private final static String API_BASE = "https://efaserver.vag-freiburg.de/vagfr/";
public VagfrProvider() public VagfrProvider() {
{ super(NetworkId.VAGFR, API_BASE);
super(NetworkId.VAGFR, API_BASE);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
setSessionCookieName("EFABWLB"); setSessionCookieName("EFABWLB");
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if (("N".equals(trainType) || "Nahverkehrszug".equals(trainName)) && trainNum != null)
{ return new Line(id, network, Product.REGIONAL_TRAIN, "N" + trainNum);
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 static {
{ // Tram
// Tram STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
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("T2", new Style(Shape.RECT, Style.parseColor("#33b540"), Style.WHITE)); STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#f79210"), 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("T4", new Style(Shape.RECT, Style.parseColor("#ef58a1"), Style.WHITE)); STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#0994ce"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#0994ce"), Style.WHITE));
// Nachtbus // Nachtbus
STYLES.put("N46", new Style(Style.parseColor("#28bda5"), Style.WHITE)); STYLES.put("N46", new Style(Style.parseColor("#28bda5"), Style.WHITE));
STYLES.put("N47", new Style(Style.parseColor("#d6de20"), 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 * @author Andreas Schildbach
*/ */
public class VaoProvider extends AbstractHafasProvider public class VaoProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "https://app.verkehrsauskunft.at/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, null, Product.TRAM, null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY, Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
null, null, null };
public VaoProvider(final String jsonApiAuthorization) public VaoProvider(final String jsonApiAuthorization) {
{ super(NetworkId.VAO, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.VAO, API_BASE, "dn", PRODUCTS_MAP);
setJsonApiVersion("1.11"); setJsonApiVersion("1.11");
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\"}"); setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\"}");
setJsonApiAuthorization(jsonApiAuthorization); setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES); setStyles(STYLES);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name);
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(name); if (m.matches())
if (m.matches()) return new String[] { m.group(2), m.group(1) };
return new String[] { m.group(2), m.group(1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_ONE_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(2), m.group(1) };
return new String[] { m.group(2), m.group(1) };
return super.splitPOI(poi); return super.splitPOI(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitAddress(address); return super.splitAddress(address);
} }
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation())
if (location.hasLocation()) return jsonLocGeoPos(types, location.lat, location.lon);
return jsonLocGeoPos(types, location.lat, location.lon); else
else throw new IllegalArgumentException("cannot handle: " + location);
throw new IllegalArgumentException("cannot handle: " + location); }
}
@Override @Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
throws IOException final int maxDepartures, final boolean equivs) throws IOException {
{ return jsonStationBoard(stationId, time, maxDepartures, equivs);
return jsonStationBoard(stationId, time, maxDepartures, equivs); }
}
@Override @Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
{ return jsonLocMatch(constraint);
return jsonLocMatch(constraint); }
}
@Override @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return jsonTripSearch(from, to, date, dep, products, null);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
{ final JsonContext jsonContext = (JsonContext) context;
final JsonContext jsonContext = (JsonContext) context; return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
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 static {
{ // Salzburg S-Bahn
// Salzburg S-Bahn STYLES.put("Salzburg AG|SS1", new Style(Style.parseColor("#b61d33"), Style.WHITE));
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("Salzburg AG|SS11", new Style(Style.parseColor("#b61d33"), Style.WHITE)); STYLES.put("OEBB|SS2", new Style(Style.parseColor("#0069b4"), 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("OEBB|SS3", new Style(Style.parseColor("#0aa537"), Style.WHITE)); STYLES.put("BLB|SS4", new Style(Style.parseColor("#a862a4"), Style.WHITE));
STYLES.put("BLB|SS4", new Style(Style.parseColor("#a862a4"), Style.WHITE));
// Salzburg Bus // Salzburg Bus
STYLES.put("Salzburg AG|B1", new Style(Style.parseColor("#e3000f"), Style.WHITE)); 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|B2", new Style(Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("Salzburg AG|B3", new Style(Style.parseColor("#956b27"), 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|B4", new Style(Style.parseColor("#ffcc00"), Style.WHITE));
STYLES.put("Salzburg AG|B5", new Style(Style.parseColor("#04bbee"), 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|B6", new Style(Style.parseColor("#85bc22"), Style.WHITE));
STYLES.put("Salzburg AG|B7", new Style(Style.parseColor("#009a9b"), 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|B8", new Style(Style.parseColor("#f39100"), Style.WHITE));
STYLES.put("Salzburg AG|B10", new Style(Style.parseColor("#f8baa2"), Style.BLACK)); 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|B12", new Style(Style.parseColor("#b9dfde"), Style.WHITE));
STYLES.put("Salzburg AG|B14", new Style(Style.parseColor("#cfe09a"), 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 * @author Andreas Schildbach
*/ */
public class VbbProvider extends AbstractHafasProvider public class VbbProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "http://fahrinfo.vbb.de/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY, Product.FERRY, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN };
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN }; private static final Set<Product> ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND = EnumSet
private static final Set<Product> ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND = EnumSet .complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND));
.complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND));
public VbbProvider() public VbbProvider() {
{ super(NetworkId.VBB, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.VBB, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsUseWeight(false); setJsonGetStopsUseWeight(false);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setClientType(null); setClientType(null);
} }
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?"); 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_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
@Override @Override
protected String[] splitStationName(String name) protected String[] splitStationName(String name) {
{ final Matcher mSu = P_SPLIT_NAME_SU.matcher(name);
final Matcher mSu = P_SPLIT_NAME_SU.matcher(name); if (!mSu.matches())
if (!mSu.matches()) throw new IllegalStateException(name);
throw new IllegalStateException(name); name = mSu.group(1);
name = mSu.group(1); final String su = mSu.group(2);
final String su = mSu.group(2);
final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name); final Matcher mBus = P_SPLIT_NAME_BUS.matcher(name);
if (!mBus.matches()) if (!mBus.matches())
throw new IllegalStateException(name); throw new IllegalStateException(name);
name = mBus.group(1); name = mBus.group(1);
final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name); final Matcher mParen = P_SPLIT_NAME_PAREN.matcher(name);
if (mParen.matches()) if (mParen.matches())
return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) }; return new String[] { normalizePlace(mParen.group(2)), (su != null ? su + " " : "") + mParen.group(1) };
final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name); final Matcher mComma = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (mComma.matches()) if (mComma.matches())
return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) }; return new String[] { normalizePlace(mComma.group(1)), mComma.group(2) };
return super.splitStationName(name); return super.splitStationName(name);
} }
private String normalizePlace(final String place) private String normalizePlace(final String place) {
{ if ("Bln".equals(place))
if ("Bln".equals(place)) return "Berlin";
return "Berlin"; else
else return place;
return place; }
}
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND;
return ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND; }
}
@Override @Override
protected Line parseLineAndType(final String lineAndType) protected Line parseLineAndType(final String lineAndType) {
{ if ("X#".equals(lineAndType))
if ("X#".equals(lineAndType)) return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex
return newLine(Product.HIGH_SPEED_TRAIN, "X", null); // InterConnex else
else return super.parseLineAndType(lineAndType);
return super.parseLineAndType(lineAndType); }
}
} }

View file

@ -25,74 +25,70 @@ import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class VblProvider extends AbstractEfaProvider public class VblProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://mobil.vbl.ch/vblmobil/";
private final static String API_BASE = "http://mobil.vbl.ch/vblmobil/";
public VblProvider() public VblProvider() {
{ super(NetworkId.VBL, API_BASE);
super(NetworkId.VBL, API_BASE);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("BLS".equals(trainType) && trainNum != null)
{ return new Line(id, network, Product.REGIONAL_TRAIN, "BLS" + trainNum);
if ("BLS".equals(trainType) && trainNum != null) if ("ASM".equals(trainType) && trainNum != null) // Aare Seeland mobil
return new Line(id, network, Product.REGIONAL_TRAIN, "BLS" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "ASM" + trainNum);
if ("ASM".equals(trainType) && trainNum != null) // Aare Seeland mobil if ("SOB".equals(trainType) && trainNum != null) // Schweizerische Südostbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "ASM" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "SOB" + trainNum);
if ("SOB".equals(trainType) && trainNum != null) // Schweizerische Südostbahn if ("RhB".equals(trainType) && trainNum != null) // Rhätische Bahn
return new Line(id, network, Product.REGIONAL_TRAIN, "SOB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "RhB" + trainNum);
if ("RhB".equals(trainType) && trainNum != null) // Rhätische Bahn if ("AB-".equals(trainType) && trainNum != null) // Appenzeller Bahnen
return new Line(id, network, Product.REGIONAL_TRAIN, "RhB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "AB" + trainNum);
if ("AB-".equals(trainType) && trainNum != null) // Appenzeller Bahnen if ("BDW".equals(trainType) && trainNum != null) // BDWM Transport
return new Line(id, network, Product.REGIONAL_TRAIN, "AB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "BDW" + trainNum);
if ("BDW".equals(trainType) && trainNum != null) // BDWM Transport if ("ZB".equals(trainType) && trainNum != null) // Zentralbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "BDW" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "ZB" + trainNum);
if ("ZB".equals(trainType) && trainNum != null) // Zentralbahn if ("TPF".equals(trainType) && trainNum != null) // Transports publics fribourgeois
return new Line(id, network, Product.REGIONAL_TRAIN, "ZB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "TPF" + trainNum);
if ("TPF".equals(trainType) && trainNum != null) // Transports publics fribourgeois if ("MGB".equals(trainType) && trainNum != null) // Matterhorn Gotthard Bahn
return new Line(id, network, Product.REGIONAL_TRAIN, "TPF" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "MGB" + trainNum);
if ("MGB".equals(trainType) && trainNum != null) // Matterhorn Gotthard Bahn if ("CJ".equals(trainType) && trainNum != null) // Chemins de fer du Jura
return new Line(id, network, Product.REGIONAL_TRAIN, "MGB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "CJ" + trainNum);
if ("CJ".equals(trainType) && trainNum != null) // Chemins de fer du Jura if ("LEB".equals(trainType) && trainNum != null) // Lausanne-Echallens-Bercher
return new Line(id, network, Product.REGIONAL_TRAIN, "CJ" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "LEB" + trainNum);
if ("LEB".equals(trainType) && trainNum != null) // Lausanne-Echallens-Bercher if ("FAR".equals(trainType) && trainNum != null) // Ferrovie Autolinee Regionali Ticinesi
return new Line(id, network, Product.REGIONAL_TRAIN, "LEB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "FAR" + trainNum);
if ("FAR".equals(trainType) && trainNum != null) // Ferrovie Autolinee Regionali Ticinesi if ("WAB".equals(trainType) && trainNum != null) // Wengernalpbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "FAR" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "WAB" + trainNum);
if ("WAB".equals(trainType) && trainNum != null) // Wengernalpbahn if ("JB".equals(trainType) && trainNum != null) // Jungfraubahn
return new Line(id, network, Product.REGIONAL_TRAIN, "WAB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "JB" + trainNum);
if ("JB".equals(trainType) && trainNum != null) // Jungfraubahn if ("NSt".equals(trainType) && trainNum != null) // Nyon-St-Cergue-Morez
return new Line(id, network, Product.REGIONAL_TRAIN, "JB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "NSt" + trainNum);
if ("NSt".equals(trainType) && trainNum != null) // Nyon-St-Cergue-Morez if ("RA".equals(trainType) && trainNum != null) // Regionalps
return new Line(id, network, Product.REGIONAL_TRAIN, "NSt" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "RA" + trainNum);
if ("RA".equals(trainType) && trainNum != null) // Regionalps if ("TRN".equals(trainType) && trainNum != null) // Transport Publics Neuchâtelois
return new Line(id, network, Product.REGIONAL_TRAIN, "RA" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "TRN" + trainNum);
if ("TRN".equals(trainType) && trainNum != null) // Transport Publics Neuchâtelois if ("TPC".equals(trainType) && trainNum != null) // Transports Publics du Chablais
return new Line(id, network, Product.REGIONAL_TRAIN, "TRN" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "TPC" + trainNum);
if ("TPC".equals(trainType) && trainNum != null) // Transports Publics du Chablais if ("MVR".equals(trainType) && trainNum != null) // Montreux-Vevey-Riviera
return new Line(id, network, Product.REGIONAL_TRAIN, "TPC" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "MVR" + trainNum);
if ("MVR".equals(trainType) && trainNum != null) // Montreux-Vevey-Riviera if ("MOB".equals(trainType) && trainNum != null) // Montreux-Oberland Bernois
return new Line(id, network, Product.REGIONAL_TRAIN, "MVR" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "MOB" + trainNum);
if ("MOB".equals(trainType) && trainNum != null) // Montreux-Oberland Bernois if ("TRA".equals(trainType) && trainNum != null) // Transports Vallée de Joux-Yverdon-Ste-Croix
return new Line(id, network, Product.REGIONAL_TRAIN, "MOB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "TRA" + trainNum);
if ("TRA".equals(trainType) && trainNum != null) // Transports Vallée de Joux-Yverdon-Ste-Croix if ("TMR".equals(trainType) && trainNum != null) // Transports de Martigny et Régions
return new Line(id, network, Product.REGIONAL_TRAIN, "TRA" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "TMR" + trainNum);
if ("TMR".equals(trainType) && trainNum != null) // Transports de Martigny et Régions if ("GGB".equals(trainType) && trainNum != null) // Gornergratbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "TMR" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "GGB" + trainNum);
if ("GGB".equals(trainType) && trainNum != null) // Gornergratbahn if ("BLM".equals(trainType) && trainNum != null) // Lauterbrunnen-Mürren
return new Line(id, network, Product.REGIONAL_TRAIN, "GGB" + trainNum); return new Line(id, network, Product.REGIONAL_TRAIN, "BLM" + 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 * @author Andreas Schildbach
*/ */
public class VbnProvider extends AbstractHafasProvider public class VbnProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "https://fahrplaner.vbn.de/hafas/";
private static final String API_BASE = "https://fahrplaner.vbn.de/hafas/"; // http://fahrplaner.vsninfo.de/hafas/
// http://fahrplaner.vsninfo.de/hafas/ // http://fahrplan.rsag-online.de/hafas/
// http://fahrplan.rsag-online.de/hafas/ // http://fahrplanauskunft.verkehrsverbund-warnow.de/bin/
// http://fahrplanauskunft.verkehrsverbund-warnow.de/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, private static final Product[] PRODUCTS_MAP = { 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 }; 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) public VbnProvider(final String jsonApiAuthorization) {
{ super(NetworkId.VBN, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.VBN, API_BASE, "dn", PRODUCTS_MAP);
setJsonApiVersion("1.10"); setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"VBN\"}"); setJsonApiClient("{\"id\":\"VBN\"}");
setJsonApiAuthorization(jsonApiAuthorization); setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES); 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 @Override
protected String[] splitStationName(final String name) protected String[] splitStationName(final String name) {
{ for (final String place : PLACES) {
for (final String place : PLACES) if (name.startsWith(place + " ") || name.startsWith(place + "-"))
{ return new String[] { place, name.substring(place.length() + 1) };
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 @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitAddress(address); return super.splitAddress(address);
} }
@Override @Override
public Set<Product> defaultProducts() public Set<Product> defaultProducts() {
{ return Product.ALL;
return Product.ALL; }
}
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxLocations) throws IOException final int maxDistance, final int maxLocations) throws IOException {
{ if (location.hasLocation())
if (location.hasLocation()) return jsonLocGeoPos(types, location.lat, location.lon);
return jsonLocGeoPos(types, location.lat, location.lon); else
else throw new IllegalArgumentException("cannot handle: " + location);
throw new IllegalArgumentException("cannot handle: " + location); }
}
@Override @Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
throws IOException final int maxDepartures, final boolean equivs) throws IOException {
{ return jsonStationBoard(stationId, time, maxDepartures, equivs);
return jsonStationBoard(stationId, time, maxDepartures, equivs); }
}
@Override @Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
{ return jsonLocMatch(constraint);
return jsonLocMatch(constraint); }
}
@Override @Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep, public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException 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); return jsonTripSearch(from, to, date, dep, products, null);
} }
@Override @Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
{ final JsonContext jsonContext = (JsonContext) context;
final JsonContext jsonContext = (JsonContext) context; return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
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 static {
{ // Rostock
// Rostock STYLES.put("DB Regio AG|SS1", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
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|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("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|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|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|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|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|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|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|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|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|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|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|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 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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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 * @author Andreas Schildbach
*/ */
public class VgnProvider extends AbstractEfaProvider public class VgnProvider extends AbstractEfaProvider {
{ private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST"; private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
public VgnProvider(final String apiBase) public VgnProvider(final String apiBase) {
{ super(NetworkId.VGN, apiBase, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, null, null);
super(NetworkId.VGN, apiBase, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, null, null); }
}
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("R5(z)".equals(trainNum))
{ return new Line(id, network, Product.REGIONAL_TRAIN, "R5(z)");
if ("R5(z)".equals(trainNum)) if ("R7(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R5(z)"); return new Line(id, network, Product.REGIONAL_TRAIN, "R7(z)");
if ("R7(z)".equals(trainNum)) if ("R8(z)".equals(trainNum))
return new Line(id, network, Product.REGIONAL_TRAIN, "R7(z)"); return new Line(id, network, Product.REGIONAL_TRAIN, "R8(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 @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date date, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date date, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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) return super.xsltTripRequestParameters(from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
+ "&itdLPxx_showTariffLevel=1"; options) + "&itdLPxx_showTariffLevel=1";
} }
} }

View file

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

View file

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

View file

@ -35,79 +35,70 @@ import de.schildbach.pte.dto.Style;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class VorProvider extends AbstractEfaProvider public class VorProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "https://efa.vor.at/vor/";
private final static String API_BASE = "https://efa.vor.at/vor/";
public VorProvider() public VorProvider() {
{ super(NetworkId.VOR, API_BASE);
super(NetworkId.VOR, API_BASE);
setHttpReferer(API_BASE + DEFAULT_TRIP_ENDPOINT); setHttpReferer(API_BASE + DEFAULT_TRIP_ENDPOINT);
setHttpPost(true); setHttpPost(true);
setIncludeRegionId(false); setIncludeRegionId(false);
setStyles(STYLES); setStyles(STYLES);
setRequestUrlEncoding(Charsets.UTF_8); setRequestUrlEncoding(Charsets.UTF_8);
} }
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); optimize, walkSpeed, accessibility, options));
if (products != null) if (products != null) {
{ for (final Product p : products) {
for (final Product p : products) if (p == Product.BUS)
{ uri.append("&inclMOT_11=on"); // night bus
if (p == Product.BUS) }
uri.append("&inclMOT_11=on"); // night bus }
}
}
return uri.toString(); return uri.toString();
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("WLB".equals(trainNum) && trainType == null)
{ return new Line(id, network, Product.TRAM, "WLB");
if ("WLB".equals(trainNum) && trainType == null) } else if ("1".equals(mot)) {
return new Line(id, network, Product.TRAM, "WLB"); if ("LILO".equals(symbol) && "Lokalbahn".equals(trainName))
} return new Line(id, network, Product.REGIONAL_TRAIN, "LILO");
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 static {
{ // Wien
// Wien STYLES.put("SS1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1e5cb3"), Style.WHITE));
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("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("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("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("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("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("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("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("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("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("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("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("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("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 * @author Andreas Schildbach
*/ */
public class VrnProvider extends AbstractEfaProvider public class VrnProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://fahrplanauskunft.vrn.de/vrn/";
private static final String API_BASE = "http://fahrplanauskunft.vrn.de/vrn/";
// http://fahrplanauskunft.vrn.de/vrn_mobile/ // http://fahrplanauskunft.vrn.de/vrn_mobile/
// http://efa9.vrn.de/vrt/ // http://efa9.vrn.de/vrt/
public VrnProvider() public VrnProvider() {
{ super(NetworkId.VRN, API_BASE);
super(NetworkId.VRN, API_BASE);
setRequestUrlEncoding(Charsets.UTF_8); setRequestUrlEncoding(Charsets.UTF_8);
setStyles(STYLES); setStyles(STYLES);
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("InterRegio".equals(longName) && symbol == null)
{ return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
if ("InterRegio".equals(longName) && symbol == null) }
return new Line(id, network, Product.REGIONAL_TRAIN, "IR");
}
if (name != null && name.startsWith("RNV Moonliner ")) if (name != null && name.startsWith("RNV Moonliner "))
return super.parseLine(id, network, mot, symbol, "M" + name.substring(14), longName, trainType, trainNum, trainName); return super.parseLine(id, network, mot, symbol, "M" + name.substring(14), longName, trainType, trainNum,
else if (name != null && (name.startsWith("RNV ") || name.startsWith("SWK "))) trainName);
return super.parseLine(id, network, mot, symbol, name.substring(4), longName, trainType, trainNum, trainName); else if (name != null && (name.startsWith("RNV ") || name.startsWith("SWK ")))
else return super.parseLine(id, network, mot, symbol, name.substring(4), longName, trainType, trainNum,
return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName); 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 static {
{ // Straßen- und Stadtbahn Mannheim-Ludwigshafen rnv
// Straßen- und Stadtbahn Mannheim-Ludwigshafen rnv STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE));
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("T2", new Style(Shape.RECT, Style.parseColor("#b00346"), Style.WHITE)); STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#d6ad00"), 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("T4", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE)); STYLES.put("T4X", 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("T4A", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE)); STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#00975f"), 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("T5A", new Style(Shape.RECT, Style.parseColor("#00975f"), Style.WHITE)); STYLES.put("T5X", 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("T6", new Style(Shape.RECT, Style.parseColor("#956c29"), Style.WHITE)); STYLES.put("T6A", 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("T7", new Style(Shape.RECT, Style.parseColor("#ffcc00"), Style.BLACK)); STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#e17600"), Style.WHITE));
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("T9", new Style(Shape.RECT, Style.parseColor("#e6007e"), Style.WHITE)); STYLES.put("T10", new Style(Shape.RECT, Style.parseColor("#a71680"), 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("T15", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE)); STYLES.put("TX", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE));
STYLES.put("TX", new Style(Shape.RECT, Style.parseColor("#7c7c7b"), Style.WHITE));
// Busse Mannheim // Busse Mannheim
STYLES.put("B2", new Style(Shape.CIRCLE, Style.parseColor("#b00346"), Style.WHITE)); 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("B4", new Style(Shape.CIRCLE, Style.parseColor("#e30613"), Style.WHITE));
STYLES.put("B5", new Style(Shape.CIRCLE, Style.parseColor("#00975f"), Style.BLACK)); 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("B7", new Style(Shape.CIRCLE, Style.parseColor("#ffcc00"), Style.BLACK));
STYLES.put("B40", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE)); 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("B41", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B42", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), 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("B43", new Style(Shape.CIRCLE, Style.parseColor("#589bd4"), Style.WHITE));
STYLES.put("B44", new Style(Shape.CIRCLE, Style.parseColor("#009a93"), 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("B45", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B46", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), 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("B47", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B48", new Style(Shape.CIRCLE, Style.parseColor("#009fe3"), 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("B49", new Style(Shape.CIRCLE, Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B50", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), 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("B51", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), Style.WHITE));
STYLES.put("B52", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), 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("B53", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), Style.WHITE));
STYLES.put("B54", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), 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("B55", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B56", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), 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("B57", new Style(Shape.CIRCLE, Style.parseColor("#5bc5f2"), Style.WHITE));
STYLES.put("B57E", 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("B58", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B59", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), 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("B60", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE));
STYLES.put("B61", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), 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("B62", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B63", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), 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)); STYLES.put("B64", new Style(Shape.CIRCLE, Style.parseColor("#0091a6"), Style.WHITE));
// Stadtbus Ludwigshafen // Stadtbus Ludwigshafen
STYLES.put("B70", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), Style.WHITE)); 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("B71", new Style(Shape.CIRCLE, Style.parseColor("#a89bb1"), Style.WHITE));
STYLES.put("B72", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), 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("B73", new Style(Shape.CIRCLE, Style.parseColor("#8bc5bd"), Style.WHITE));
STYLES.put("B74", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), 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("B75", new Style(Shape.CIRCLE, Style.parseColor("#008f88"), Style.WHITE));
STYLES.put("B76", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), 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("B77", new Style(Shape.CIRCLE, Style.parseColor("#c290b8"), Style.WHITE));
STYLES.put("B78", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), 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("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("B84", new Style(Shape.CIRCLE, Style.parseColor("#8d2176"), Style.WHITE));
STYLES.put("B85", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), 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("B86", new Style(Shape.CIRCLE, Style.parseColor("#82d0f5"), Style.WHITE));
STYLES.put("B87", new Style(Shape.CIRCLE, Style.parseColor("#69598f"), 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)); STYLES.put("B88", new Style(Shape.CIRCLE, Style.parseColor("#8bc5bd"), Style.WHITE));
// Nachtbus Ludwigshafen // Nachtbus Ludwigshafen
STYLES.put("B90", new Style(Shape.CIRCLE, Style.parseColor("#86bc25"), Style.WHITE)); 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("B91", new Style(Shape.CIRCLE, Style.parseColor("#898F93"), Style.WHITE));
STYLES.put("B94", new Style(Shape.CIRCLE, Style.parseColor("#83d0f5"), 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("B96", new Style(Shape.CIRCLE, Style.parseColor("#c05d18"), Style.WHITE));
STYLES.put("B97", new Style(Shape.CIRCLE, Style.parseColor("#ffed00"), Style.BLACK)); STYLES.put("B97", new Style(Shape.CIRCLE, Style.parseColor("#ffed00"), Style.BLACK));
// Nachtbus Ludwigshafen-Mannheim // Nachtbus Ludwigshafen-Mannheim
STYLES.put("B6", new Style(Shape.CIRCLE, Style.parseColor("#956c29"), Style.WHITE)); STYLES.put("B6", new Style(Shape.CIRCLE, Style.parseColor("#956c29"), Style.WHITE));
// Straßenbahn Heidelberg // Straßenbahn Heidelberg
STYLES.put("T21", new Style(Shape.RECT, Style.parseColor("#e30613"), Style.WHITE)); 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("T22", new Style(Shape.RECT, Style.parseColor("#fdc300"), Style.BLACK));
STYLES.put("T23", new Style(Shape.RECT, Style.parseColor("#e48f00"), Style.WHITE)); 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("T24", new Style(Shape.RECT, Style.parseColor("#8d2176"), Style.WHITE));
STYLES.put("T26", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE)); STYLES.put("T26", new Style(Shape.RECT, Style.parseColor("#f39b9a"), Style.WHITE));
// Stadtbus Heidelberg rnv // Stadtbus Heidelberg rnv
STYLES.put("B27", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), Style.WHITE)); 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("B28", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B29", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), 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("B30", new Style(Shape.CIRCLE, Style.parseColor("#baabd4"), Style.WHITE));
STYLES.put("B31", new Style(Shape.CIRCLE, Style.parseColor("#4b96d2"), 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("B32", new Style(Shape.CIRCLE, Style.parseColor("#a1c3d6"), Style.WHITE));
STYLES.put("B33", new Style(Shape.CIRCLE, Style.parseColor("#0069b4"), 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("B34", new Style(Shape.CIRCLE, Style.parseColor("#009fe3"), Style.WHITE));
STYLES.put("B35", new Style(Shape.CIRCLE, Style.parseColor("#4e2583"), 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("B36", new Style(Shape.CIRCLE, Style.parseColor("#b2a0cd"), Style.WHITE));
STYLES.put("B37", new Style(Shape.CIRCLE, Style.parseColor("#10bbef"), 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("B38", new Style(Shape.CIRCLE, Style.parseColor("#0097b5"), Style.WHITE));
STYLES.put("B39", new Style(Shape.CIRCLE, Style.parseColor("#512985"), Style.WHITE)); STYLES.put("B39", new Style(Shape.CIRCLE, Style.parseColor("#512985"), Style.WHITE));
// Moonliner Heidelberg // Moonliner Heidelberg
STYLES.put("BM1", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88"))); STYLES.put("BM1", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM2", new Style(Style.parseColor("#F9A75E"), 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("BM3", new Style(Style.parseColor("#FFCB06"), Style.parseColor("#0A3F88")));
STYLES.put("BM4", 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"))); STYLES.put("BM5", new Style(Style.parseColor("#FFF100"), Style.parseColor("#0A3F88")));
// Bus Rheinpfalz // Bus Rheinpfalz
STYLES.put("B484", new Style(Style.parseColor("#BE1E2E"), Style.WHITE)); STYLES.put("B484", new Style(Style.parseColor("#BE1E2E"), Style.WHITE));
STYLES.put("B570", new Style(Style.parseColor("#9B2590"), Style.WHITE)); STYLES.put("B570", new Style(Style.parseColor("#9B2590"), Style.WHITE));
STYLES.put("B571", new Style(Style.parseColor("#303192"), Style.WHITE)); STYLES.put("B571", new Style(Style.parseColor("#303192"), Style.WHITE));
STYLES.put("B572", new Style(Style.parseColor("#00A651"), Style.WHITE)); STYLES.put("B572", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B574", new Style(Style.parseColor("#00ADEE"), Style.WHITE)); STYLES.put("B574", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B580", new Style(Style.parseColor("#00A8E7"), Style.WHITE)); STYLES.put("B580", new Style(Style.parseColor("#00A8E7"), Style.WHITE));
STYLES.put("B581", new Style(Style.parseColor("#F7941D"), Style.WHITE)); STYLES.put("B581", new Style(Style.parseColor("#F7941D"), Style.WHITE));
// S-Bahn Rhein-Neckar // S-Bahn Rhein-Neckar
STYLES.put("SS1", new Style(Style.parseColor("#EE1C25"), Style.WHITE)); STYLES.put("SS1", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("SS2", new Style(Style.parseColor("#0077C0"), Style.WHITE)); STYLES.put("SS2", new Style(Style.parseColor("#0077C0"), Style.WHITE));
STYLES.put("SS3", new Style(Style.parseColor("#4F2E92"), Style.WHITE)); STYLES.put("SS3", new Style(Style.parseColor("#4F2E92"), Style.WHITE));
STYLES.put("SS33", 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("SS4", new Style(Style.parseColor("#00A651"), Style.BLACK));
STYLES.put("SS5", new Style(Style.parseColor("#F89735"), Style.WHITE)); STYLES.put("SS5", new Style(Style.parseColor("#F89735"), Style.WHITE));
STYLES.put("SS51", new Style(Style.parseColor("#F89735"), Style.WHITE)); STYLES.put("SS51", new Style(Style.parseColor("#F89735"), Style.WHITE));
// Bus Bad Bergzabern // Bus Bad Bergzabern
STYLES.put("B540", new Style(Style.parseColor("#FDC500"), Style.WHITE)); STYLES.put("B540", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B541", new Style(Style.parseColor("#C10625"), Style.WHITE)); STYLES.put("B541", new Style(Style.parseColor("#C10625"), Style.WHITE));
STYLES.put("B543", new Style(Style.parseColor("#417B1C"), Style.WHITE)); STYLES.put("B543", new Style(Style.parseColor("#417B1C"), Style.WHITE));
STYLES.put("B544", new Style(Style.parseColor("#00527E"), Style.WHITE)); STYLES.put("B544", new Style(Style.parseColor("#00527E"), Style.WHITE));
// Bus Grünstadt und Umgebung // Bus Grünstadt und Umgebung
STYLES.put("B451", new Style(Style.parseColor("#1AA94A"), Style.WHITE)); STYLES.put("B451", new Style(Style.parseColor("#1AA94A"), Style.WHITE));
STYLES.put("B453", new Style(Style.parseColor("#F495BF"), Style.WHITE)); STYLES.put("B453", new Style(Style.parseColor("#F495BF"), Style.WHITE));
STYLES.put("B454", new Style(Style.parseColor("#60B7D4"), Style.WHITE)); STYLES.put("B454", new Style(Style.parseColor("#60B7D4"), Style.WHITE));
STYLES.put("B455", new Style(Style.parseColor("#FECC2F"), Style.WHITE)); STYLES.put("B455", new Style(Style.parseColor("#FECC2F"), Style.WHITE));
STYLES.put("B457", new Style(Style.parseColor("#AAA23D"), Style.WHITE)); STYLES.put("B457", new Style(Style.parseColor("#AAA23D"), Style.WHITE));
STYLES.put("B458", new Style(Style.parseColor("#E54D6F"), Style.WHITE)); STYLES.put("B458", new Style(Style.parseColor("#E54D6F"), Style.WHITE));
STYLES.put("B460", new Style(Style.parseColor("#9F0833"), Style.WHITE)); STYLES.put("B460", new Style(Style.parseColor("#9F0833"), Style.WHITE));
STYLES.put("B461", new Style(Style.parseColor("#F68D31"), Style.WHITE)); STYLES.put("B461", new Style(Style.parseColor("#F68D31"), Style.WHITE));
// Bus Sinsheim // Bus Sinsheim
STYLES.put("B741", new Style(Style.parseColor("#459959"), Style.WHITE)); STYLES.put("B741", new Style(Style.parseColor("#459959"), Style.WHITE));
STYLES.put("B761", new Style(Style.parseColor("#BECE31"), Style.WHITE)); STYLES.put("B761", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B762", new Style(Style.parseColor("#5997C1"), Style.WHITE)); STYLES.put("B762", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B763", new Style(Style.parseColor("#FFC20A"), Style.WHITE)); STYLES.put("B763", new Style(Style.parseColor("#FFC20A"), Style.WHITE));
STYLES.put("B765", new Style(Style.parseColor("#066D6C"), Style.WHITE)); STYLES.put("B765", new Style(Style.parseColor("#066D6C"), Style.WHITE));
STYLES.put("B768", new Style(Style.parseColor("#0FAD99"), Style.WHITE)); STYLES.put("B768", new Style(Style.parseColor("#0FAD99"), Style.WHITE));
STYLES.put("B782", new Style(Style.parseColor("#3BC1CF"), Style.WHITE)); STYLES.put("B782", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B795", new Style(Style.parseColor("#0056A7"), Style.WHITE)); STYLES.put("B795", new Style(Style.parseColor("#0056A7"), Style.WHITE));
STYLES.put("B796", new Style(Style.parseColor("#F47922"), Style.WHITE)); STYLES.put("B796", new Style(Style.parseColor("#F47922"), Style.WHITE));
STYLES.put("B797", new Style(Style.parseColor("#A62653"), Style.WHITE)); STYLES.put("B797", new Style(Style.parseColor("#A62653"), Style.WHITE));
// Bus Wonnegau-Altrhein // Bus Wonnegau-Altrhein
STYLES.put("B427", new Style(Style.parseColor("#00A651"), Style.WHITE)); STYLES.put("B427", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B435", new Style(Style.parseColor("#A3788C"), Style.WHITE)); STYLES.put("B435", new Style(Style.parseColor("#A3788C"), Style.WHITE));
STYLES.put("B660", new Style(Style.parseColor("#0FAD99"), Style.WHITE)); STYLES.put("B660", new Style(Style.parseColor("#0FAD99"), Style.WHITE));
STYLES.put("B436", new Style(Style.parseColor("#8169AF"), Style.WHITE)); STYLES.put("B436", new Style(Style.parseColor("#8169AF"), Style.WHITE));
STYLES.put("B663", new Style(Style.parseColor("#7FB6A4"), Style.WHITE)); STYLES.put("B663", new Style(Style.parseColor("#7FB6A4"), Style.WHITE));
STYLES.put("B921", new Style(Style.parseColor("#F7941D"), Style.WHITE)); STYLES.put("B921", new Style(Style.parseColor("#F7941D"), Style.WHITE));
STYLES.put("B437", new Style(Style.parseColor("#00ADEE"), Style.WHITE)); STYLES.put("B437", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B418", new Style(Style.parseColor("#BFB677"), Style.WHITE)); STYLES.put("B418", new Style(Style.parseColor("#BFB677"), Style.WHITE));
STYLES.put("B434", new Style(Style.parseColor("#A65631"), Style.WHITE)); STYLES.put("B434", new Style(Style.parseColor("#A65631"), Style.WHITE));
STYLES.put("B431", new Style(Style.parseColor("#CA5744"), Style.WHITE)); STYLES.put("B431", new Style(Style.parseColor("#CA5744"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE)); STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE));
STYLES.put("B433", new Style(Style.parseColor("#5D8AC6"), Style.WHITE)); STYLES.put("B433", new Style(Style.parseColor("#5D8AC6"), Style.WHITE));
STYLES.put("B432", new Style(Style.parseColor("#82A958"), Style.WHITE)); STYLES.put("B432", new Style(Style.parseColor("#82A958"), Style.WHITE));
// Bus Odenwald-Mitte // Bus Odenwald-Mitte
STYLES.put("B667", new Style(Style.parseColor("#00A651"), Style.WHITE)); STYLES.put("B667", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B684", new Style(Style.parseColor("#039CDB"), Style.WHITE)); STYLES.put("B684", new Style(Style.parseColor("#039CDB"), Style.WHITE));
STYLES.put("B687", new Style(Style.parseColor("#86D1D1"), Style.WHITE)); STYLES.put("B687", new Style(Style.parseColor("#86D1D1"), Style.WHITE));
STYLES.put("B691", new Style(Style.parseColor("#BBAFD6"), Style.WHITE)); STYLES.put("B691", new Style(Style.parseColor("#BBAFD6"), Style.WHITE));
STYLES.put("B697", new Style(Style.parseColor("#002B5C"), Style.WHITE)); STYLES.put("B697", new Style(Style.parseColor("#002B5C"), Style.WHITE));
STYLES.put("B698", new Style(Style.parseColor("#AA568D"), Style.WHITE)); STYLES.put("B698", new Style(Style.parseColor("#AA568D"), Style.WHITE));
// Bus Saarbrücken und Umland // Bus Saarbrücken und Umland
STYLES.put("B231", new Style(Style.parseColor("#94C11C"), Style.WHITE)); STYLES.put("B231", new Style(Style.parseColor("#94C11C"), Style.WHITE));
STYLES.put("B232", new Style(Style.parseColor("#A12785"), Style.WHITE)); STYLES.put("B232", new Style(Style.parseColor("#A12785"), Style.WHITE));
STYLES.put("B233", new Style(Style.parseColor("#0098D8"), Style.WHITE)); STYLES.put("B233", new Style(Style.parseColor("#0098D8"), Style.WHITE));
STYLES.put("B234", new Style(Style.parseColor("#FDC500"), Style.WHITE)); STYLES.put("B234", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B235", new Style(Style.parseColor("#C10525"), Style.WHITE)); STYLES.put("B235", new Style(Style.parseColor("#C10525"), Style.WHITE));
STYLES.put("B236", new Style(Style.parseColor("#104291"), Style.WHITE)); STYLES.put("B236", new Style(Style.parseColor("#104291"), Style.WHITE));
STYLES.put("B237", new Style(Style.parseColor("#23AD7A"), Style.WHITE)); STYLES.put("B237", new Style(Style.parseColor("#23AD7A"), Style.WHITE));
STYLES.put("B238", new Style(Style.parseColor("#F39100"), Style.WHITE)); STYLES.put("B238", new Style(Style.parseColor("#F39100"), Style.WHITE));
STYLES.put("B240", new Style(Style.parseColor("#E5007D"), Style.WHITE)); STYLES.put("B240", new Style(Style.parseColor("#E5007D"), Style.WHITE));
// Bus Neckargemünd // Bus Neckargemünd
STYLES.put("B735", new Style(Style.parseColor("#F47922"), Style.WHITE)); STYLES.put("B735", new Style(Style.parseColor("#F47922"), Style.WHITE));
STYLES.put("B743", new Style(Style.parseColor("#EE1C25"), Style.WHITE)); STYLES.put("B743", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B752", new Style(Style.parseColor("#0D7253"), Style.WHITE)); STYLES.put("B752", new Style(Style.parseColor("#0D7253"), Style.WHITE));
STYLES.put("B753", new Style(Style.parseColor("#3BC1CF"), Style.WHITE)); STYLES.put("B753", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B754", new Style(Style.parseColor("#F99D1D"), Style.WHITE)); STYLES.put("B754", new Style(Style.parseColor("#F99D1D"), Style.WHITE));
STYLES.put("B817", new Style(Style.parseColor("#0080A6"), Style.WHITE)); STYLES.put("B817", new Style(Style.parseColor("#0080A6"), Style.WHITE));
// Bus Ladenburg // Bus Ladenburg
STYLES.put("B625", new Style(Style.parseColor("#006F45"), Style.WHITE)); STYLES.put("B625", new Style(Style.parseColor("#006F45"), Style.WHITE));
STYLES.put("B626", new Style(Style.parseColor("#5997C1"), Style.WHITE)); STYLES.put("B626", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B627", new Style(Style.parseColor("#A62653"), Style.WHITE)); STYLES.put("B627", new Style(Style.parseColor("#A62653"), Style.WHITE));
STYLES.put("B628", new Style(Style.parseColor("#EE1C25"), Style.WHITE)); STYLES.put("B628", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B629", new Style(Style.parseColor("#008B9E"), Style.WHITE)); STYLES.put("B629", new Style(Style.parseColor("#008B9E"), Style.WHITE));
// Bus Worms // Bus Worms
STYLES.put("B407", new Style(Style.parseColor("#F58581"), Style.WHITE)); STYLES.put("B407", new Style(Style.parseColor("#F58581"), Style.WHITE));
STYLES.put("B402", new Style(Style.parseColor("#078F47"), Style.WHITE)); STYLES.put("B402", new Style(Style.parseColor("#078F47"), Style.WHITE));
STYLES.put("B410", new Style(Style.parseColor("#9D368F"), Style.WHITE)); STYLES.put("B410", new Style(Style.parseColor("#9D368F"), Style.WHITE));
STYLES.put("B408", new Style(Style.parseColor("#A79A39"), Style.WHITE)); STYLES.put("B408", new Style(Style.parseColor("#A79A39"), Style.WHITE));
STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE)); STYLES.put("B406", new Style(Style.parseColor("#00A99D"), Style.WHITE));
STYLES.put("B4906", new Style(Style.parseColor("#BEBEC1"), Style.WHITE)); STYLES.put("B4906", new Style(Style.parseColor("#BEBEC1"), Style.WHITE));
STYLES.put("B4905", 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)); STYLES.put("B409", new Style(Style.parseColor("#8691B3"), Style.WHITE));
// Bus Kaiserslautern // Bus Kaiserslautern
STYLES.put("B101", new Style(Style.parseColor("#F36F23"), Style.WHITE)); STYLES.put("B101", new Style(Style.parseColor("#F36F23"), Style.WHITE));
STYLES.put("B102", new Style(Style.parseColor("#B64A9B"), Style.WHITE)); STYLES.put("B102", new Style(Style.parseColor("#B64A9B"), Style.WHITE));
STYLES.put("B103", new Style(Style.parseColor("#FFF100"), Style.BLACK)); STYLES.put("B103", new Style(Style.parseColor("#FFF100"), Style.BLACK));
STYLES.put("B104", new Style(Style.parseColor("#71BF44"), Style.WHITE)); STYLES.put("B104", new Style(Style.parseColor("#71BF44"), Style.WHITE));
STYLES.put("B105", new Style(Style.parseColor("#007F3E"), Style.WHITE)); STYLES.put("B105", new Style(Style.parseColor("#007F3E"), Style.WHITE));
STYLES.put("B106", new Style(Style.parseColor("#FBA61C"), Style.BLACK)); STYLES.put("B106", new Style(Style.parseColor("#FBA61C"), Style.BLACK));
STYLES.put("B107", new Style(Style.parseColor("#A05A35"), Style.WHITE)); STYLES.put("B107", new Style(Style.parseColor("#A05A35"), Style.WHITE));
STYLES.put("B108", new Style(Style.parseColor("#A05A35"), Style.BLACK)); STYLES.put("B108", new Style(Style.parseColor("#A05A35"), Style.BLACK));
STYLES.put("B111", new Style(Style.parseColor("#0B4EA2"), Style.WHITE)); STYLES.put("B111", new Style(Style.parseColor("#0B4EA2"), Style.WHITE));
STYLES.put("B112", new Style(Style.parseColor("#00A5E3"), Style.WHITE)); STYLES.put("B112", new Style(Style.parseColor("#00A5E3"), Style.WHITE));
STYLES.put("B114", new Style(Style.parseColor("#E10086"), Style.WHITE)); STYLES.put("B114", new Style(Style.parseColor("#E10086"), Style.WHITE));
STYLES.put("B115", new Style(Style.parseColor("#E71B24"), Style.WHITE)); STYLES.put("B115", new Style(Style.parseColor("#E71B24"), Style.WHITE));
STYLES.put("B117", new Style(Style.parseColor("#E71B24"), Style.WHITE)); STYLES.put("B117", new Style(Style.parseColor("#E71B24"), Style.WHITE));
// Bus Weinheim // Bus Weinheim
STYLES.put("B631", new Style(Style.parseColor("#949599"), Style.WHITE)); STYLES.put("B631", new Style(Style.parseColor("#949599"), Style.WHITE));
STYLES.put("B632", new Style(Style.parseColor("#003D72"), Style.WHITE)); STYLES.put("B632", new Style(Style.parseColor("#003D72"), Style.WHITE));
STYLES.put("B632A", new Style(Style.parseColor("#0083C2"), Style.WHITE)); STYLES.put("B632A", new Style(Style.parseColor("#0083C2"), Style.WHITE));
STYLES.put("B633", new Style(Style.parseColor("#EE1C25"), Style.WHITE)); STYLES.put("B633", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B634", new Style(Style.parseColor("#F58221"), Style.WHITE)); STYLES.put("B634", new Style(Style.parseColor("#F58221"), Style.WHITE));
STYLES.put("B681", new Style(Style.parseColor("#00B7BD"), Style.WHITE)); STYLES.put("B681", new Style(Style.parseColor("#00B7BD"), Style.WHITE));
STYLES.put("B682", new Style(Style.parseColor("#D1AC75"), Style.WHITE)); STYLES.put("B682", new Style(Style.parseColor("#D1AC75"), Style.WHITE));
STYLES.put("B688", new Style(Style.parseColor("#72BAAF"), Style.WHITE)); STYLES.put("B688", new Style(Style.parseColor("#72BAAF"), Style.WHITE));
// Bus Schwetzingen-Hockenheim und Umgebung // Bus Schwetzingen-Hockenheim und Umgebung
STYLES.put("B710", new Style(Style.parseColor("#C10625"), Style.WHITE)); STYLES.put("B710", new Style(Style.parseColor("#C10625"), Style.WHITE));
STYLES.put("B711", new Style(Style.parseColor("#417B1C"), Style.WHITE)); STYLES.put("B711", new Style(Style.parseColor("#417B1C"), Style.WHITE));
STYLES.put("B712", new Style(Style.parseColor("#A12486"), Style.WHITE)); STYLES.put("B712", new Style(Style.parseColor("#A12486"), Style.WHITE));
STYLES.put("B713", new Style(Style.parseColor("#0398D8"), Style.WHITE)); STYLES.put("B713", new Style(Style.parseColor("#0398D8"), Style.WHITE));
STYLES.put("B715", new Style(Style.parseColor("#FDC500"), Style.WHITE)); STYLES.put("B715", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B716", new Style(Style.parseColor("#93C11C"), Style.WHITE)); STYLES.put("B716", new Style(Style.parseColor("#93C11C"), Style.WHITE));
STYLES.put("B717", new Style(Style.parseColor("#004F7A"), Style.WHITE)); STYLES.put("B717", new Style(Style.parseColor("#004F7A"), Style.WHITE));
STYLES.put("B718", new Style(Style.parseColor("#EE7221"), Style.WHITE)); STYLES.put("B718", new Style(Style.parseColor("#EE7221"), Style.WHITE));
STYLES.put("B732", new Style(Style.parseColor("#008692"), Style.WHITE)); STYLES.put("B732", new Style(Style.parseColor("#008692"), Style.WHITE));
STYLES.put("B738", new Style(Style.parseColor("#9C9D9D"), Style.WHITE)); STYLES.put("B738", new Style(Style.parseColor("#9C9D9D"), Style.WHITE));
STYLES.put("B128", new Style(Style.parseColor("#9C9D9D"), Style.WHITE)); STYLES.put("B128", new Style(Style.parseColor("#9C9D9D"), Style.WHITE));
// Bus Odenwald-Süd // Bus Odenwald-Süd
STYLES.put("B686", new Style(Style.parseColor("#E2001A"), Style.WHITE)); STYLES.put("B686", new Style(Style.parseColor("#E2001A"), Style.WHITE));
STYLES.put("B683", new Style(Style.parseColor("#C74E1B"), Style.WHITE)); STYLES.put("B683", new Style(Style.parseColor("#C74E1B"), Style.WHITE));
STYLES.put("B692", new Style(Style.parseColor("#F7A800"), Style.WHITE)); STYLES.put("B692", new Style(Style.parseColor("#F7A800"), Style.WHITE));
STYLES.put("B685", new Style(Style.parseColor("#B1C903"), Style.WHITE)); STYLES.put("B685", new Style(Style.parseColor("#B1C903"), Style.WHITE));
STYLES.put("B688", new Style(Style.parseColor("#54C3EC"), Style.WHITE)); STYLES.put("B688", new Style(Style.parseColor("#54C3EC"), Style.WHITE));
// Bus Neustadt/Wstr. und Umgebung // Bus Neustadt/Wstr. und Umgebung
STYLES.put("B500", new Style(Style.parseColor("#459959"), Style.WHITE)); STYLES.put("B500", new Style(Style.parseColor("#459959"), Style.WHITE));
STYLES.put("B501", new Style(Style.parseColor("#F57F22"), Style.WHITE)); STYLES.put("B501", new Style(Style.parseColor("#F57F22"), Style.WHITE));
STYLES.put("B503", new Style(Style.parseColor("#0058A9"), Style.WHITE)); STYLES.put("B503", new Style(Style.parseColor("#0058A9"), Style.WHITE));
STYLES.put("B504", new Style(Style.parseColor("#BECE31"), Style.WHITE)); STYLES.put("B504", new Style(Style.parseColor("#BECE31"), Style.WHITE));
STYLES.put("B505", 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("B506", new Style(Style.parseColor("#FFC21C"), Style.WHITE));
STYLES.put("B507", new Style(Style.parseColor("#A62653"), Style.WHITE)); STYLES.put("B507", new Style(Style.parseColor("#A62653"), Style.WHITE));
STYLES.put("B508", new Style(Style.parseColor("#3BC1CF"), Style.WHITE)); STYLES.put("B508", new Style(Style.parseColor("#3BC1CF"), Style.WHITE));
STYLES.put("B509", new Style(Style.parseColor("#F03F23"), Style.WHITE)); STYLES.put("B509", new Style(Style.parseColor("#F03F23"), Style.WHITE));
STYLES.put("B510", new Style(Style.parseColor("#E7ACC6"), Style.WHITE)); STYLES.put("B510", new Style(Style.parseColor("#E7ACC6"), Style.WHITE));
STYLES.put("B512", new Style(Style.parseColor("#5997C1"), Style.WHITE)); STYLES.put("B512", new Style(Style.parseColor("#5997C1"), Style.WHITE));
STYLES.put("B517", new Style(Style.parseColor("#066D6C"), Style.WHITE)); STYLES.put("B517", new Style(Style.parseColor("#066D6C"), Style.WHITE));
// Bus Neckar-Odenwald-Kreis // Bus Neckar-Odenwald-Kreis
STYLES.put("B821", new Style(Style.parseColor("#263791"), Style.WHITE)); STYLES.put("B821", new Style(Style.parseColor("#263791"), Style.WHITE));
STYLES.put("B822", new Style(Style.parseColor("#00ADEE"), Style.WHITE)); STYLES.put("B822", new Style(Style.parseColor("#00ADEE"), Style.WHITE));
STYLES.put("B823", new Style(Style.parseColor("#056736"), Style.WHITE)); STYLES.put("B823", new Style(Style.parseColor("#056736"), Style.WHITE));
STYLES.put("B824", new Style(Style.parseColor("#9A8174"), Style.WHITE)); STYLES.put("B824", new Style(Style.parseColor("#9A8174"), Style.WHITE));
STYLES.put("B828", 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("B832", new Style(Style.parseColor("#F7941D"), Style.WHITE));
STYLES.put("B833", new Style(Style.parseColor("#C1B404"), Style.WHITE)); STYLES.put("B833", new Style(Style.parseColor("#C1B404"), Style.WHITE));
STYLES.put("B834", new Style(Style.parseColor("#90C73E"), Style.WHITE)); STYLES.put("B834", new Style(Style.parseColor("#90C73E"), Style.WHITE));
STYLES.put("B835", new Style(Style.parseColor("#662D91"), Style.WHITE)); STYLES.put("B835", new Style(Style.parseColor("#662D91"), Style.WHITE));
STYLES.put("B836", new Style(Style.parseColor("#EE2026"), Style.WHITE)); STYLES.put("B836", new Style(Style.parseColor("#EE2026"), Style.WHITE));
STYLES.put("B837", new Style(Style.parseColor("#00A651"), Style.WHITE)); STYLES.put("B837", new Style(Style.parseColor("#00A651"), Style.WHITE));
STYLES.put("B838", new Style(Style.parseColor("#8B711B"), Style.WHITE)); STYLES.put("B838", new Style(Style.parseColor("#8B711B"), Style.WHITE));
STYLES.put("B839", new Style(Style.parseColor("#662D91"), Style.WHITE)); STYLES.put("B839", new Style(Style.parseColor("#662D91"), Style.WHITE));
STYLES.put("B841", new Style(Style.parseColor("#C0B296"), Style.WHITE)); STYLES.put("B841", new Style(Style.parseColor("#C0B296"), Style.WHITE));
STYLES.put("B843", new Style(Style.parseColor("#DBE122"), Style.WHITE)); STYLES.put("B843", new Style(Style.parseColor("#DBE122"), Style.WHITE));
STYLES.put("B844", new Style(Style.parseColor("#93B366"), Style.WHITE)); STYLES.put("B844", new Style(Style.parseColor("#93B366"), Style.WHITE));
STYLES.put("B849", new Style(Style.parseColor("#E19584"), 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("#C01B2A"), Style.WHITE));
STYLES.put("B857", new Style(Style.parseColor("#D2B10C"), Style.WHITE)); STYLES.put("B857", new Style(Style.parseColor("#D2B10C"), Style.WHITE));
// Bus Landkreis Germersheim // Bus Landkreis Germersheim
STYLES.put("B550", new Style(Style.parseColor("#870B36"), Style.WHITE)); STYLES.put("B550", new Style(Style.parseColor("#870B36"), Style.WHITE));
STYLES.put("B552", new Style(Style.parseColor("#96387C"), Style.WHITE)); STYLES.put("B552", new Style(Style.parseColor("#96387C"), Style.WHITE));
STYLES.put("B554", new Style(Style.parseColor("#EE542E"), Style.WHITE)); STYLES.put("B554", new Style(Style.parseColor("#EE542E"), Style.WHITE));
STYLES.put("B555", new Style(Style.parseColor("#EC2E6B"), Style.WHITE)); STYLES.put("B555", new Style(Style.parseColor("#EC2E6B"), Style.WHITE));
STYLES.put("B556", new Style(Style.parseColor("#D7DF21"), Style.WHITE)); STYLES.put("B556", new Style(Style.parseColor("#D7DF21"), Style.WHITE));
STYLES.put("B557", new Style(Style.parseColor("#BD7BB4"), Style.WHITE)); STYLES.put("B557", new Style(Style.parseColor("#BD7BB4"), Style.WHITE));
STYLES.put("B558", new Style(Style.parseColor("#ED5956"), Style.WHITE)); STYLES.put("B558", new Style(Style.parseColor("#ED5956"), Style.WHITE));
STYLES.put("B559", new Style(Style.parseColor("#EE4F5E"), Style.WHITE)); STYLES.put("B559", new Style(Style.parseColor("#EE4F5E"), Style.WHITE));
STYLES.put("B595", new Style(Style.parseColor("#00A65E"), Style.WHITE)); STYLES.put("B595", new Style(Style.parseColor("#00A65E"), Style.WHITE));
STYLES.put("B596", new Style(Style.parseColor("#73479C"), Style.WHITE)); STYLES.put("B596", new Style(Style.parseColor("#73479C"), Style.WHITE));
STYLES.put("B546", new Style(Style.parseColor("#E81D34"), Style.WHITE)); STYLES.put("B546", new Style(Style.parseColor("#E81D34"), Style.WHITE));
STYLES.put("B547", new Style(Style.parseColor("#991111"), Style.WHITE)); STYLES.put("B547", new Style(Style.parseColor("#991111"), Style.WHITE));
STYLES.put("B548", new Style(Style.parseColor("#974E04"), Style.WHITE)); STYLES.put("B548", new Style(Style.parseColor("#974E04"), Style.WHITE));
STYLES.put("B549", new Style(Style.parseColor("#F7A5AD"), Style.WHITE)); STYLES.put("B549", new Style(Style.parseColor("#F7A5AD"), Style.WHITE));
STYLES.put("B593", new Style(Style.parseColor("#D1B0A3"), Style.WHITE)); STYLES.put("B593", new Style(Style.parseColor("#D1B0A3"), Style.WHITE));
STYLES.put("B594", new Style(Style.parseColor("#FAA86F"), Style.WHITE)); STYLES.put("B594", new Style(Style.parseColor("#FAA86F"), Style.WHITE));
STYLES.put("B598", new Style(Style.parseColor("#71BF44"), Style.WHITE)); STYLES.put("B598", new Style(Style.parseColor("#71BF44"), Style.WHITE));
STYLES.put("B590", new Style(Style.parseColor("#C50A54"), Style.WHITE)); STYLES.put("B590", new Style(Style.parseColor("#C50A54"), Style.WHITE));
STYLES.put("B592", new Style(Style.parseColor("#00B6BD"), Style.WHITE)); STYLES.put("B592", new Style(Style.parseColor("#00B6BD"), Style.WHITE));
STYLES.put("B599", new Style(Style.parseColor("#00AEEF"), Style.WHITE)); STYLES.put("B599", new Style(Style.parseColor("#00AEEF"), Style.WHITE));
// Bus Südliche Weinstraße // Bus Südliche Weinstraße
STYLES.put("B525", new Style(Style.parseColor("#009EE0"), Style.WHITE)); STYLES.put("B525", new Style(Style.parseColor("#009EE0"), Style.WHITE));
STYLES.put("B523", new Style(Style.parseColor("#F4A10B"), Style.WHITE)); STYLES.put("B523", new Style(Style.parseColor("#F4A10B"), Style.WHITE));
STYLES.put("B524", new Style(Style.parseColor("#FFEC00"), Style.BLACK)); STYLES.put("B524", new Style(Style.parseColor("#FFEC00"), Style.BLACK));
STYLES.put("B531", new Style(Style.parseColor("#2DA84D"), Style.WHITE)); STYLES.put("B531", new Style(Style.parseColor("#2DA84D"), Style.WHITE));
STYLES.put("B532", new Style(Style.parseColor("#00FD00"), Style.BLACK)); STYLES.put("B532", new Style(Style.parseColor("#00FD00"), Style.BLACK));
STYLES.put("B520", new Style(Style.parseColor("#FF3333"), Style.WHITE)); STYLES.put("B520", new Style(Style.parseColor("#FF3333"), Style.WHITE));
STYLES.put("B530", new Style(Style.parseColor("#E84A93"), Style.WHITE)); STYLES.put("B530", new Style(Style.parseColor("#E84A93"), Style.WHITE));
// Bus Speyer // Bus Speyer
STYLES.put("B561", new Style(Style.parseColor("#003D72"), Style.WHITE)); STYLES.put("B561", new Style(Style.parseColor("#003D72"), Style.WHITE));
STYLES.put("B562", new Style(Style.parseColor("#F58221"), Style.WHITE)); STYLES.put("B562", new Style(Style.parseColor("#F58221"), Style.WHITE));
STYLES.put("B563", new Style(Style.parseColor("#EE1C25"), Style.WHITE)); STYLES.put("B563", new Style(Style.parseColor("#EE1C25"), Style.WHITE));
STYLES.put("B564", new Style(Style.parseColor("#006C3B"), Style.WHITE)); STYLES.put("B564", new Style(Style.parseColor("#006C3B"), Style.WHITE));
STYLES.put("B565", new Style(Style.parseColor("#00B7BD"), Style.WHITE)); STYLES.put("B565", new Style(Style.parseColor("#00B7BD"), Style.WHITE));
STYLES.put("B566", new Style(Style.parseColor("#D1AC75"), Style.WHITE)); STYLES.put("B566", new Style(Style.parseColor("#D1AC75"), Style.WHITE));
STYLES.put("B567", new Style(Style.parseColor("#95080A"), Style.WHITE)); STYLES.put("B567", new Style(Style.parseColor("#95080A"), Style.WHITE));
STYLES.put("B568", new Style(Style.parseColor("#0067B3"), Style.WHITE)); STYLES.put("B568", new Style(Style.parseColor("#0067B3"), Style.WHITE));
STYLES.put("B569", new Style(Style.parseColor("#71BF44"), Style.WHITE)); STYLES.put("B569", new Style(Style.parseColor("#71BF44"), Style.WHITE));
// Bus Frankenthal/Pfalz // Bus Frankenthal/Pfalz
STYLES.put("B462", new Style(Style.parseColor("#93C11C"), Style.WHITE)); STYLES.put("B462", new Style(Style.parseColor("#93C11C"), Style.WHITE));
STYLES.put("B463", new Style(Style.parseColor("#A12486"), Style.WHITE)); STYLES.put("B463", new Style(Style.parseColor("#A12486"), Style.WHITE));
STYLES.put("B464", new Style(Style.parseColor("#0398D8"), Style.WHITE)); STYLES.put("B464", new Style(Style.parseColor("#0398D8"), Style.WHITE));
STYLES.put("B466", new Style(Style.parseColor("#FDC500"), Style.WHITE)); STYLES.put("B466", new Style(Style.parseColor("#FDC500"), Style.WHITE));
STYLES.put("B467", new Style(Style.parseColor("#C10625"), 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 * @author Andreas Schildbach
*/ */
public class VrrProvider extends AbstractEfaProvider public class VrrProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://efa.vrr.de/standard/";
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() public VrrProvider() {
{ this(API_BASE);
this(API_BASE); }
}
public VrrProvider(final String apiBase) public VrrProvider(final String apiBase) {
{ super(NetworkId.VRR, apiBase);
super(NetworkId.VRR, apiBase);
setIncludeRegionId(false); setIncludeRegionId(false);
setUseProxFootSearch(false); setUseProxFootSearch(false);
setNeedsSpEncId(true); setNeedsSpEncId(true);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
setRequestUrlEncoding(Charsets.ISO_8859_1); setRequestUrlEncoding(Charsets.ISO_8859_1);
setSessionCookieName("vrr-efa-lb"); setSessionCookieName("vrr-efa-lb");
} }
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); optimize, walkSpeed, accessibility, options));
if (products != null) if (products != null) {
{ for (final Product p : products) {
for (final Product p : products) if (p == Product.CABLECAR)
{ uri.append("&inclMOT_11=on"); // Schwebebahn
if (p == Product.CABLECAR) }
uri.append("&inclMOT_11=on"); // Schwebebahn }
}
}
return uri.toString(); return uri.toString();
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("Regionalbahn".equals(trainName) && symbol != null)
{ return new Line(id, network, Product.REGIONAL_TRAIN, symbol);
if ("Regionalbahn".equals(trainName) && symbol != null) if ("NordWestBahn".equals(trainName) && symbol != null)
return new Line(id, network, Product.REGIONAL_TRAIN, symbol); 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)) if (trainType == null && "SEV7".equals(trainNum))
return new Line(id, network, Product.BUS, trainNum); return new Line(id, network, Product.BUS, trainNum);
} } else if ("11".equals(mot)) {
else if ("11".equals(mot)) // Wuppertaler Schwebebahn & SkyTrain D'dorf
{ if ("Schwebebahn".equals(trainName) || (longName != null && longName.startsWith("Schwebebahn")))
// Wuppertaler Schwebebahn & SkyTrain D'dorf return new Line(id, network, Product.CABLECAR, name);
if ("Schwebebahn".equals(trainName) || (longName != null && longName.startsWith("Schwebebahn")))
return new Line(id, network, Product.CABLECAR, name);
// H-Bahn TU Dortmund // H-Bahn TU Dortmund
if ("H-Bahn".equals(trainName) || (longName != null && longName.startsWith("H-Bahn"))) if ("H-Bahn".equals(trainName) || (longName != null && longName.startsWith("H-Bahn")))
return new Line(id, network, Product.CABLECAR, name); 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 static {
{ // Schnellbusse VRR
// Schnellbusse VRR STYLES.put("vrr|BSB", new Style(Style.parseColor("#00919d"), Style.WHITE));
STYLES.put("vrr|BSB", new Style(Style.parseColor("#00919d"), Style.WHITE));
// Dortmund // Dortmund
STYLES.put("dsw|UU41", new Style(Shape.RECT, Style.parseColor("#ffe700"), Style.GRAY)); 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|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|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|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|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|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|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|UU49", new Style(Shape.RECT, Style.parseColor("#f7acbc"), Style.WHITE));
STYLES.put("dsw|BNE", new Style(Shape.RECT, Style.parseColor("#2e2382"), Style.WHITE)); STYLES.put("dsw|BNE", new Style(Shape.RECT, Style.parseColor("#2e2382"), Style.WHITE));
// Düsseldorf // Düsseldorf
STYLES.put("rbg|UU70", new Style(Shape.RECT, Style.parseColor("#69b0cd"), Style.WHITE)); 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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|BNE7", new Style(Shape.RECT, Style.parseColor("#009247"), Style.WHITE));
STYLES.put("rbg|BNE8", new Style(Shape.RECT, Style.parseColor("#bdaa8b"), Style.BLACK)); STYLES.put("rbg|BNE8", new Style(Shape.RECT, Style.parseColor("#bdaa8b"), Style.BLACK));
// Krefeld // Krefeld
STYLES.put("swk|T041", new Style(Style.parseColor("#ee4036"), Style.WHITE)); 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|T042", new Style(Style.parseColor("#f49392"), Style.WHITE));
STYLES.put("swk|T043", new Style(Style.parseColor("#bc6ead"), 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|T044", new Style(Style.parseColor("#f36c21"), Style.WHITE));
STYLES.put("swk|B045", new Style(Style.parseColor("#00b5e6"), 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|B046", new Style(Style.parseColor("#695073"), Style.WHITE));
STYLES.put("swk|B047", new Style(Style.parseColor("#fbce99"), 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|B051", new Style(Style.parseColor("#a1cf73"), Style.WHITE));
STYLES.put("swk|B052", new Style(Style.parseColor("#f68f2a"), 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|B054", new Style(Style.parseColor("#048546"), Style.WHITE));
STYLES.put("swk|B055", new Style(Style.parseColor("#00b2b7"), 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|B056", new Style(Style.parseColor("#a2689d"), Style.WHITE));
STYLES.put("swk|B057", new Style(Style.parseColor("#3bc4e6"), 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|B058", new Style(Style.parseColor("#0081c6"), Style.WHITE));
STYLES.put("swk|B059", new Style(Style.parseColor("#9ad099"), 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|B060", new Style(Style.parseColor("#aac3bf"), Style.WHITE));
STYLES.put("swk|B061", new Style(Style.parseColor("#ce8d29"), 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|B062", new Style(Style.parseColor("#ae7544"), Style.WHITE));
STYLES.put("swk|B068", new Style(Style.parseColor("#1857a7"), 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("swk|B069", new Style(Style.parseColor("#cd7762"), Style.WHITE));
STYLES.put("rvn|B076", new Style(Style.parseColor("#56a44d"), 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|B077", new Style(Style.parseColor("#fcef08"), Style.WHITE));
STYLES.put("rvn|B079", new Style(Style.parseColor("#98a3a4"), 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|BNE5", new Style(Style.parseColor("#99d64c"), Style.WHITE));
STYLES.put("swk|BNE6", new Style(Style.parseColor("#f6811d"), 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|BNE7", new Style(Style.parseColor("#5dcbe8"), Style.WHITE));
STYLES.put("swk|BNE8", new Style(Style.parseColor("#187fcb"), 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|BNE10", new Style(Style.parseColor("#a32240"), Style.WHITE));
STYLES.put("swk|BNE27", new Style(Style.parseColor("#138544"), Style.WHITE)); STYLES.put("swk|BNE27", new Style(Style.parseColor("#138544"), Style.WHITE));
// Essen // Essen
STYLES.put("eva|UU17", new Style(Shape.RECT, Style.parseColor("#68b6e3"), Style.WHITE)); 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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|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|BNE15", new Style(Shape.RECT, Style.parseColor("#94c11a"), Style.WHITE));
STYLES.put("eva|BNE16",new Style(Shape.RECT, Style.parseColor("#004e9e"), Style.WHITE)); STYLES.put("eva|BNE16", new Style(Shape.RECT, Style.parseColor("#004e9e"), Style.WHITE));
// Duisburg // Duisburg
STYLES.put("dvg|B905", new Style(Style.parseColor("#c8242b"), Style.WHITE)); 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|B906", new Style(Style.parseColor("#b5ab3a"), Style.WHITE));
STYLES.put("dvg|B907", new Style(Style.parseColor("#6891c3"), 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|B909", new Style(Style.parseColor("#217e5b"), Style.WHITE));
STYLES.put("dvg|B910", new Style(Style.parseColor("#d48018"), 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|B917", new Style(Style.parseColor("#23b14b"), Style.WHITE));
STYLES.put("dvg|B919", new Style(Style.parseColor("#078b4a"), 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|B922", new Style(Style.parseColor("#0072bb"), Style.WHITE));
STYLES.put("dvg|B923", new Style(Style.parseColor("#00b1c4"), 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|B924", new Style(Style.parseColor("#f37921"), Style.WHITE));
STYLES.put("dvg|B925", new Style(Style.parseColor("#4876b8"), 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|B926", new Style(Style.parseColor("#649b43"), Style.WHITE));
STYLES.put("dvg|B928", new Style(Style.parseColor("#c4428c"), 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|B933", new Style(Style.parseColor("#975615"), Style.WHITE));
STYLES.put("dvg|B934", new Style(Style.parseColor("#009074"), 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|B937", new Style(Style.parseColor("#6f78b5"), Style.WHITE));
STYLES.put("dvg|B940", new Style(Style.parseColor("#bbbb30"), 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|B942", new Style(Style.parseColor("#930408"), Style.WHITE));
STYLES.put("dvg|B944", new Style(Style.parseColor("#c52157"), 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|B946", new Style(Style.parseColor("#1cbddc"), Style.WHITE));
STYLES.put("dvg|BNE1", new Style(Style.parseColor("#000000"), 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|BNE2", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("dvg|BNE3", 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)); STYLES.put("dvg|BNE4", new Style(Style.parseColor("#000000"), Style.WHITE));
// Oberhausen // Oberhausen
STYLES.put("sto|B952", new Style(Style.parseColor("#f59598"), Style.WHITE)); 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|B953", new Style(Style.parseColor("#5eb6d9"), Style.WHITE));
STYLES.put("sto|B954", new Style(Style.parseColor("#f89d3d"), 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|B955", new Style(Style.parseColor("#8879b8"), Style.WHITE));
STYLES.put("sto|B956", new Style(Style.parseColor("#23b24b"), 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|B957", new Style(Style.parseColor("#ebc531"), Style.WHITE));
STYLES.put("sto|B960", new Style(Style.parseColor("#aed57f"), 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|B961", new Style(Style.parseColor("#a46f73"), Style.WHITE));
STYLES.put("sto|B962", new Style(Style.parseColor("#0a776f"), 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|B966", new Style(Style.parseColor("#c8b3d6"), Style.WHITE));
STYLES.put("sto|B976", new Style(Style.parseColor("#d063a5"), 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|BNE1", new Style(Style.parseColor("#e22225"), Style.WHITE));
STYLES.put("sto|BNE2", new Style(Style.parseColor("#28ad78"), 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|BNE3", new Style(Style.parseColor("#85499c"), Style.WHITE));
STYLES.put("sto|BNE4", new Style(Style.parseColor("#395aa8"), 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|BNE5", new Style(Style.parseColor("#ede929"), Style.WHITE));
STYLES.put("sto|BNE6", new Style(Style.parseColor("#d488ba"), 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|BNE7", new Style(Style.parseColor("#fbae3e"), Style.WHITE));
STYLES.put("sto|BNE10", new Style(Style.parseColor("#270039"), Style.WHITE)); STYLES.put("sto|BNE10", new Style(Style.parseColor("#270039"), Style.WHITE));
// Mülheim an der Ruhr // Mülheim an der Ruhr
STYLES.put("vrr|T102", new Style(Style.parseColor("#756fb3"), Style.WHITE)); 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|B132", new Style(Style.parseColor("#a3c3d1"), Style.BLACK));
STYLES.put("vrr|B133", new Style(Style.parseColor("#a9a575"), 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|B134", new Style(Style.parseColor("#806a63"), Style.WHITE));
STYLES.put("vrr|B135", new Style(Style.parseColor("#425159"), Style.WHITE)); STYLES.put("vrr|B135", new Style(Style.parseColor("#425159"), Style.WHITE));
// Neuss // Neuss
STYLES.put("swn|B842", new Style(Style.parseColor("#fdcc10"), Style.WHITE)); 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|B843", new Style(Style.parseColor("#808180"), Style.WHITE));
STYLES.put("swn|B844", new Style(Style.parseColor("#cb1f25"), 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|B848", new Style(Style.parseColor("#be4e26"), Style.WHITE));
STYLES.put("swn|B849", new Style(Style.parseColor("#c878b1"), 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|B854", new Style(Style.parseColor("#35bb93"), Style.WHITE));
STYLES.put("swn|BNE1", new Style(Style.parseColor("#ff9900"), 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|BNE2", new Style(Style.parseColor("#0000ff"), Style.WHITE));
STYLES.put("swn|BNE3", new Style(Style.parseColor("#ff0000"), 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|BNE4", new Style(Style.parseColor("#ff9900"), Style.WHITE));
STYLES.put("swn|BNE5", new Style(Style.parseColor("#9900cc"), Style.WHITE)); STYLES.put("swn|BNE5", new Style(Style.parseColor("#9900cc"), Style.WHITE));
STYLES.put("swn|BNE6", new Style(Style.parseColor("#00cc99"), Style.WHITE)); STYLES.put("swn|BNE6", new Style(Style.parseColor("#00cc99"), Style.WHITE));
// Remscheid // Remscheid
STYLES.put("swr|B655", new Style(Style.parseColor("#dbcd00"), Style.WHITE)); 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|B657", new Style(Style.parseColor("#deb993"), Style.WHITE));
STYLES.put("swr|B659", new Style(Style.parseColor("#f59b00"), 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|B660", new Style(Style.parseColor("#f5a387"), Style.WHITE));
STYLES.put("swr|B664", new Style(Style.parseColor("#b1a8d3"), 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|B666", new Style(Style.parseColor("#0074be"), Style.WHITE));
STYLES.put("swr|B673", new Style(Style.parseColor("#ee7555"), 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|B675", new Style(Style.parseColor("#004e9e"), Style.WHITE));
STYLES.put("swr|B680", new Style(Style.parseColor("#c78711"), 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|BNE14", new Style(Style.parseColor("#2d247b"), Style.WHITE));
STYLES.put("swr|BNE17", new Style(Style.parseColor("#ef7c00"), 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|BNE18", new Style(Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("swr|BNE20", new Style(Style.parseColor("#0a5d34"), Style.WHITE)); STYLES.put("swr|BNE20", new Style(Style.parseColor("#0a5d34"), Style.WHITE));
// Solingen // Solingen
STYLES.put("sws|B681", new Style(Style.parseColor("#016f42"), Style.WHITE)); 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|B682", new Style(Style.parseColor("#009b78"), Style.WHITE));
STYLES.put("sws|B684", new Style(Style.parseColor("#009247"), 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|B685", new Style(Style.parseColor("#539138"), Style.WHITE));
STYLES.put("sws|B686", new Style(Style.parseColor("#a6c539"), 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|B687", new Style(Style.parseColor("#406ab4"), Style.WHITE));
STYLES.put("sws|B689", new Style(Style.parseColor("#8d5e48"), 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|B690", new Style(Style.parseColor("#0099cd"), Style.WHITE));
STYLES.put("sws|B691", new Style(Style.parseColor("#963838"), 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|B693", new Style(Style.parseColor("#9a776f"), Style.WHITE));
STYLES.put("sws|B695", new Style(Style.parseColor("#bf4b75"), 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|B696", new Style(Style.parseColor("#6c77b4"), Style.WHITE));
STYLES.put("sws|B697", new Style(Style.parseColor("#00baf1"), 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|B698", new Style(Style.parseColor("#444fa1"), Style.WHITE));
STYLES.put("sws|B699", new Style(Style.parseColor("#c4812f"), 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|BNE21", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE22", 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|BNE24", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("sws|BNE25", 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)); STYLES.put("sws|BNE28", new Style(Style.parseColor("#000000"), Style.WHITE));
// Busse Wuppertal // Busse Wuppertal
STYLES.put("wsw|B600", new Style(Style.parseColor("#cc4e97"), Style.WHITE)); 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|B603", new Style(Style.parseColor("#a77251"), Style.WHITE));
STYLES.put("wsw|B604", new Style(Style.parseColor("#f39100"), 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|B606", new Style(Style.parseColor("#88301b"), Style.WHITE));
STYLES.put("wsw|B607", new Style(Style.parseColor("#629e38"), 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|B609", new Style(Style.parseColor("#53ae2e"), Style.WHITE));
STYLES.put("wsw|B610", new Style(Style.parseColor("#eb5575"), 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|B611", new Style(Style.parseColor("#896a9a"), Style.WHITE));
STYLES.put("wsw|B612", new Style(Style.parseColor("#cd7c00"), 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|B613", new Style(Style.parseColor("#491d5c"), Style.WHITE));
STYLES.put("wsw|B614", new Style(Style.parseColor("#00a7c1"), 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|B616", new Style(Style.parseColor("#e4003a"), Style.WHITE));
STYLES.put("wsw|B617", new Style(Style.parseColor("#95114d"), 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|B618", new Style(Style.parseColor("#cf8360"), Style.WHITE));
STYLES.put("wsw|B619", new Style(Style.parseColor("#304c9d"), 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|B622", new Style(Style.parseColor("#aabd81"), Style.WHITE));
STYLES.put("wsw|B623", new Style(Style.parseColor("#e04a23"), 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|B624", new Style(Style.parseColor("#0e9580"), Style.WHITE));
STYLES.put("wsw|B625", new Style(Style.parseColor("#7aad3b"), 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|B628", new Style(Style.parseColor("#80753b"), Style.WHITE));
STYLES.put("wsw|B629", new Style(Style.parseColor("#dd72a1"), 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|B630", new Style(Style.parseColor("#0074be"), Style.WHITE));
STYLES.put("wsw|B631", new Style(Style.parseColor("#5a8858"), 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|B632", new Style(Style.parseColor("#ebac3d"), Style.WHITE));
STYLES.put("wsw|B633", new Style(Style.parseColor("#4c2182"), 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|B635", new Style(Style.parseColor("#cb6c2b"), Style.WHITE));
STYLES.put("wsw|B638", new Style(Style.parseColor("#588d58"), 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|B639", new Style(Style.parseColor("#0097c1"), Style.WHITE));
STYLES.put("wsw|B640", new Style(Style.parseColor("#89ba7a"), 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|B642", new Style(Style.parseColor("#4b72aa"), Style.WHITE));
STYLES.put("wsw|B643", new Style(Style.parseColor("#009867"), 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|B644", new Style(Style.parseColor("#a57400"), Style.WHITE));
STYLES.put("wsw|B645", new Style(Style.parseColor("#aeba0e"), 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|B646", new Style(Style.parseColor("#008db5"), Style.WHITE));
STYLES.put("wsw|B650", new Style(Style.parseColor("#f5bd00"), 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|BNE1", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE2", 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|BNE3", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE4", 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|BNE5", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE6", 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|BNE7", new Style(Style.parseColor("#000000"), Style.WHITE));
STYLES.put("wsw|BNE8", new Style(Style.parseColor("#000000"), Style.WHITE)); STYLES.put("wsw|BNE8", new Style(Style.parseColor("#000000"), Style.WHITE));
// H-Bahn Dortmund // H-Bahn Dortmund
STYLES.put("dsw|CHB1", new Style(Style.parseColor("#e5007c"), Style.WHITE)); STYLES.put("dsw|CHB1", new Style(Style.parseColor("#e5007c"), Style.WHITE));
STYLES.put("dsw|CHB2", new Style(Style.parseColor("#e5007c"), Style.WHITE)); STYLES.put("dsw|CHB2", new Style(Style.parseColor("#e5007c"), Style.WHITE));
// Schwebebahn Wuppertal // Schwebebahn Wuppertal
STYLES.put("wsw|C60", new Style(Style.parseColor("#003090"), Style.WHITE)); STYLES.put("wsw|C60", new Style(Style.parseColor("#003090"), Style.WHITE));
// Stadtbahn Köln-Bonn // Stadtbahn Köln-Bonn
STYLES.put("vrs|T1", new Style(Style.parseColor("#ed1c24"), Style.WHITE)); 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|T3", new Style(Style.parseColor("#f680c5"), Style.WHITE));
STYLES.put("vrs|T4", new Style(Style.parseColor("#f24dae"), 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|T5", new Style(Style.parseColor("#9c8dce"), Style.WHITE));
STYLES.put("vrs|T7", new Style(Style.parseColor("#f57947"), 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|T9", new Style(Style.parseColor("#f5777b"), Style.WHITE));
STYLES.put("vrs|T12", new Style(Style.parseColor("#80cc28"), 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|T13", new Style(Style.parseColor("#9e7b65"), Style.WHITE));
STYLES.put("vrs|T15", new Style(Style.parseColor("#4dbd38"), 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|T16", new Style(Style.parseColor("#33baab"), Style.WHITE));
STYLES.put("vrs|T18", new Style(Style.parseColor("#05a1e6"), 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|T61", new Style(Style.parseColor("#80cc28"), Style.WHITE));
STYLES.put("vrs|T62", new Style(Style.parseColor("#4dbd38"), 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|T63", new Style(Style.parseColor("#73d2f6"), Style.WHITE));
STYLES.put("vrs|T65", new Style(Style.parseColor("#b3db18"), 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|T66", new Style(Style.parseColor("#ec008c"), Style.WHITE));
STYLES.put("vrs|T67", new Style(Style.parseColor("#f680c5"), Style.WHITE)); STYLES.put("vrs|T67", new Style(Style.parseColor("#f680c5"), Style.WHITE));
STYLES.put("vrs|T68", new Style(Style.parseColor("#ca93d0"), Style.WHITE)); STYLES.put("vrs|T68", new Style(Style.parseColor("#ca93d0"), Style.WHITE));
// Stadtbahn Bielefeld // Stadtbahn Bielefeld
STYLES.put("owl|T1", new Style(Style.parseColor("#00aeef"), Style.WHITE)); 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|T2", new Style(Style.parseColor("#00a650"), Style.WHITE));
STYLES.put("owl|T3", new Style(Style.parseColor("#fff200"), Style.BLACK)); STYLES.put("owl|T3", new Style(Style.parseColor("#fff200"), Style.BLACK));
STYLES.put("owl|T4", new Style(Style.parseColor("#e2001a"), Style.WHITE)); STYLES.put("owl|T4", new Style(Style.parseColor("#e2001a"), Style.WHITE));
// Busse Bonn // Busse Bonn
STYLES.put("vrs|B63", new Style(Style.parseColor("#0065ae"), Style.WHITE)); 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|B16", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B66", 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|B67", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B68", 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|B18", new Style(Style.parseColor("#0065ae"), Style.WHITE));
STYLES.put("vrs|B61", new Style(Style.parseColor("#e4000b"), 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|B62", new Style(Style.parseColor("#e4000b"), Style.WHITE));
STYLES.put("vrs|B65", 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|BSB55", new Style(Style.parseColor("#00919e"), Style.WHITE));
STYLES.put("vrs|BSB60", new Style(Style.parseColor("#8f9867"), 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|BSB69", new Style(Style.parseColor("#db5f1f"), Style.WHITE));
STYLES.put("vrs|B529", new Style(Style.parseColor("#2e2383"), 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|B537", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B541", 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|B550", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B163", 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|B551", new Style(Style.parseColor("#2e2383"), Style.WHITE));
STYLES.put("vrs|B600", new Style(Style.parseColor("#817db7"), 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|B601", new Style(Style.parseColor("#831b82"), Style.WHITE));
STYLES.put("vrs|B602", new Style(Style.parseColor("#dd6ba6"), 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|B603", new Style(Style.parseColor("#e6007d"), Style.WHITE));
STYLES.put("vrs|B604", new Style(Style.parseColor("#009f5d"), 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|B605", new Style(Style.parseColor("#007b3b"), Style.WHITE));
STYLES.put("vrs|B606", new Style(Style.parseColor("#9cbf11"), 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|B607", new Style(Style.parseColor("#60ad2a"), Style.WHITE));
STYLES.put("vrs|B608", new Style(Style.parseColor("#f8a600"), 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|B609", new Style(Style.parseColor("#ef7100"), Style.WHITE));
STYLES.put("vrs|B610", new Style(Style.parseColor("#3ec1f1"), 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|B611", new Style(Style.parseColor("#0099db"), Style.WHITE));
STYLES.put("vrs|B612", new Style(Style.parseColor("#ce9d53"), 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|B613", new Style(Style.parseColor("#7b3600"), Style.WHITE));
STYLES.put("vrs|B614", new Style(Style.parseColor("#806839"), 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|B615", new Style(Style.parseColor("#532700"), Style.WHITE));
STYLES.put("vrs|B630", new Style(Style.parseColor("#c41950"), 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|B631", new Style(Style.parseColor("#9b1c44"), Style.WHITE));
STYLES.put("vrs|B633", new Style(Style.parseColor("#88cdc7"), 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|B635", new Style(Style.parseColor("#cec800"), Style.WHITE));
STYLES.put("vrs|B636", new Style(Style.parseColor("#af0223"), 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|B637", new Style(Style.parseColor("#e3572a"), Style.WHITE));
STYLES.put("vrs|B638", new Style(Style.parseColor("#af5836"), 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|B640", new Style(Style.parseColor("#004f81"), Style.WHITE));
STYLES.put("vrs|BT650", new Style(Style.parseColor("#54baa2"), 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|BT651", new Style(Style.parseColor("#005738"), Style.WHITE));
STYLES.put("vrs|BT680", new Style(Style.parseColor("#4e6578"), 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|B800", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B812", 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|B843", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B845", 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|B852", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B855", 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|B856", new Style(Style.parseColor("#4e6578"), Style.WHITE));
STYLES.put("vrs|B857", new Style(Style.parseColor("#4e6578"), Style.WHITE)); STYLES.put("vrs|B857", new Style(Style.parseColor("#4e6578"), Style.WHITE));
} }
@Override @Override
public Style lineStyle(final @Nullable String network, final @Nullable Product product, final @Nullable String label) public Style lineStyle(final @Nullable String network, final @Nullable Product product,
{ final @Nullable String label) {
if (product == Product.BUS && label != null && label.startsWith("SB")) if (product == Product.BUS && label != null && label.startsWith("SB"))
return super.lineStyle(network, product, "SB"); return super.lineStyle(network, product, "SB");
return super.lineStyle(network, product, label); 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 * @author Andreas Schildbach
*/ */
public class VvmProvider extends AbstractEfaProvider public class VvmProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://efa.mobilitaetsverbund.de/web/";
private final static String API_BASE = "http://efa.mobilitaetsverbund.de/web/";
public VvmProvider() public VvmProvider() {
{ super(NetworkId.VVM, API_BASE);
super(NetworkId.VVM, API_BASE);
setNeedsSpEncId(true); setNeedsSpEncId(true);
} }
} }

View file

@ -27,51 +27,46 @@ import de.schildbach.pte.dto.Product;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class VvoProvider extends AbstractEfaProvider public class VvoProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://efa.vvo-online.de:8080/dvb/";
private final static String API_BASE = "http://efa.vvo-online.de:8080/dvb/";
public VvoProvider() public VvoProvider() {
{ this(API_BASE);
this(API_BASE); }
}
public VvoProvider(final String apiBase) public VvoProvider(final String apiBase) {
{ super(NetworkId.VVO, apiBase);
super(NetworkId.VVO, apiBase);
setRequestUrlEncoding(Charsets.UTF_8); setRequestUrlEncoding(Charsets.UTF_8);
} }
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("Twoje Linie Kolejowe".equals(trainName) && symbol != null)
{ return new Line(id, network, Product.HIGH_SPEED_TRAIN, "TLK" + symbol);
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) if ("Regionalbahn".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, null); return new Line(id, network, Product.REGIONAL_TRAIN, null);
if ("Ostdeutsche Eisenbahn GmbH".equals(longName)) if ("Ostdeutsche Eisenbahn GmbH".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "OE"); return new Line(id, network, Product.REGIONAL_TRAIN, "OE");
if ("Meridian".equals(longName)) if ("Meridian".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "M"); return new Line(id, network, Product.REGIONAL_TRAIN, "M");
if ("trilex".equals(longName)) if ("trilex".equals(longName))
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX"); return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("Trilex".equals(trainName) && trainNum == null) if ("Trilex".equals(trainName) && trainNum == null)
return new Line(id, network, Product.REGIONAL_TRAIN, "TLX"); return new Line(id, network, Product.REGIONAL_TRAIN, "TLX");
if ("U 28".equals(symbol)) // Nationalparkbahn if ("U 28".equals(symbol)) // Nationalparkbahn
return new Line(id, network, Product.REGIONAL_TRAIN, "U28"); return new Line(id, network, Product.REGIONAL_TRAIN, "U28");
if ("SB 71".equals(symbol)) // Städtebahn Sachsen if ("SB 71".equals(symbol)) // Städtebahn Sachsen
return new Line(id, network, Product.REGIONAL_TRAIN, "SB71"); return new Line(id, network, Product.REGIONAL_TRAIN, "SB71");
if ("Fernbus".equals(trainName) && trainNum == null) if ("Fernbus".equals(trainName) && trainNum == null)
return new Line(id, network, Product.BUS, trainName); 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 * @author Andreas Schildbach
*/ */
public class VvsProvider extends AbstractEfaProvider public class VvsProvider extends AbstractEfaProvider {
{ private static final String API_BASE = "http://www2.vvs.de/vvs/";
private static final String API_BASE = "http://www2.vvs.de/vvs/";
public VvsProvider() public VvsProvider() {
{ this(API_BASE);
this(API_BASE); }
}
public VvsProvider(final String apiBase) public VvsProvider(final String apiBase) {
{ super(NetworkId.VVS, apiBase);
super(NetworkId.VVS, apiBase);
setIncludeRegionId(false); setIncludeRegionId(false);
setNumTripsRequested(4); setNumTripsRequested(4);
} }
@Override @Override
public Point[] getArea() public Point[] getArea() {
{ return new Point[] { Point.fromDouble(48.784068, 9.181713) };
return new Point[] { Point.fromDouble(48.784068, 9.181713) }; }
}
@Override @Override
protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, final @Nullable String symbol, protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot,
final @Nullable String name, final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String symbol, final @Nullable String name, final @Nullable String longName,
final @Nullable String trainName) final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) {
{ if ("0".equals(mot)) {
if ("0".equals(mot)) if ("IC".equals(trainNum))
{ return new Line(id, network, Product.HIGH_SPEED_TRAIN, trainNum);
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 * @author Andreas Schildbach
*/ */
public class VvtProvider extends AbstractEfaProvider public class VvtProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://efa.vvt.at/vvtadr/";
private final static String API_BASE = "http://efa.vvt.at/vvtadr/";
public VvtProvider() public VvtProvider() {
{ super(NetworkId.VVT, API_BASE);
super(NetworkId.VVT, API_BASE);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
} }
} }

View file

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

View file

@ -34,58 +34,53 @@ import de.schildbach.pte.dto.Style;
/** /**
* @author Andreas Schildbach * @author Andreas Schildbach
*/ */
public class WienProvider extends AbstractEfaProvider public class WienProvider extends AbstractEfaProvider {
{ private final static String API_BASE = "http://www.wienerlinien.at/ogd_routing/";
private final static String API_BASE = "http://www.wienerlinien.at/ogd_routing/";
public WienProvider() public WienProvider() {
{ super(NetworkId.WIEN, API_BASE);
super(NetworkId.WIEN, API_BASE);
setIncludeRegionId(false); setIncludeRegionId(false);
setStyles(STYLES); setStyles(STYLES);
setRequestUrlEncoding(Charsets.UTF_8); setRequestUrlEncoding(Charsets.UTF_8);
} }
@Override @Override
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time, protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to,
final boolean dep, final @Nullable Collection<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed, final Date time, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) 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, final StringBuilder uri = new StringBuilder(super.xsltTripRequestParameters(from, via, to, time, dep, products,
accessibility, options)); optimize, walkSpeed, accessibility, options));
if (products != null) if (products != null) {
{ for (final Product p : products) {
for (final Product p : products) if (p == Product.BUS)
{ uri.append("&inclMOT_11=on"); // night bus
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 static {
{ // Wien
// Wien STYLES.put("SS1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1e5cb3"), Style.WHITE));
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("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("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("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("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("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("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("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("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("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("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("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("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("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 * @author Andreas Schildbach
*/ */
public class ZvvProvider extends AbstractHafasProvider public class ZvvProvider extends AbstractHafasProvider {
{ private static final String API_BASE = "https://online.fahrplan.zvv.ch/bin/";
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,
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS,
Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS, Product.CABLECAR, Product.SUBWAY, Product.TRAM }; Product.CABLECAR, Product.SUBWAY, Product.TRAM };
public ZvvProvider() public ZvvProvider() {
{ super(NetworkId.ZVV, API_BASE, "dn", PRODUCTS_MAP);
super(NetworkId.ZVV, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8); setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8); setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES); setStyles(STYLES);
} }
private static final String[] OPERATORS = { "SBB", "SZU" }; private static final String[] OPERATORS = { "SBB", "SZU" };
private static final String[] PLACES = { "Zürich", "Winterthur" }; private static final String[] PLACES = { "Zürich", "Winterthur" };
@Override @Override
protected String[] splitStationName(String name) protected String[] splitStationName(String name) {
{ for (final String operator : OPERATORS) {
for (final String operator : OPERATORS) if (name.endsWith(" " + operator)) {
{ name = name.substring(0, name.length() - operator.length() - 1);
if (name.endsWith(" " + operator)) break;
{ }
name = name.substring(0, name.length() - operator.length() - 1);
break;
}
if (name.endsWith(" (" + operator + ")")) if (name.endsWith(" (" + operator + ")")) {
{ name = name.substring(0, name.length() - operator.length() - 3);
name = name.substring(0, name.length() - operator.length() - 3); break;
break; }
} }
}
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name); final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
if (m.matches()) if (m.matches())
return new String[] { m.group(1), m.group(2) }; return new String[] { m.group(1), m.group(2) };
for (final String place : PLACES) for (final String place : PLACES)
if (name.startsWith(place + " ") || name.startsWith(place + ",")) if (name.startsWith(place + " ") || name.startsWith(place + ","))
return new String[] { place, name.substring(place.length() + 1) }; return new String[] { place, name.substring(place.length() + 1) };
return super.splitStationName(name); return super.splitStationName(name);
} }
@Override @Override
protected String[] splitPOI(final String poi) protected String[] splitPOI(final String poi) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(poi); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(poi); return super.splitStationName(poi);
} }
@Override @Override
protected String[] splitAddress(final String address) protected String[] splitAddress(final String address) {
{ final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches())
if (m.matches()) return new String[] { m.group(1), m.group(2) };
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address); return super.splitStationName(address);
} }
@Override @Override
protected Line parseLineAndType(final String lineAndType) protected Line parseLineAndType(final String lineAndType) {
{ final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType);
final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType); if (m.matches()) {
if (m.matches()) final String number = m.group(1).replaceAll("\\s+", "");
{ final String type = m.group(2);
final String number = m.group(1).replaceAll("\\s+", "");
final String type = m.group(2);
if ("Bus".equals(type)) if ("Bus".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Bus"), null); return newLine(Product.BUS, stripPrefix(number, "Bus"), null);
if ("Bus-NF".equals(type)) if ("Bus-NF".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Bus", "Bus-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS); return newLine(Product.BUS, stripPrefix(number, "Bus", "Bus-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Tro".equals(type) || "Trolley".equals(type)) if ("Tro".equals(type) || "Trolley".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Tro"), null); return newLine(Product.BUS, stripPrefix(number, "Tro"), null);
if ("Tro-NF".equals(type)) if ("Tro-NF".equals(type))
return newLine(Product.BUS, stripPrefix(number, "Tro", "Tro-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS); return newLine(Product.BUS, stripPrefix(number, "Tro", "Tro-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("Trm".equals(type)) if ("Trm".equals(type))
return newLine(Product.TRAM, stripPrefix(number, "Trm"), null); return newLine(Product.TRAM, stripPrefix(number, "Trm"), null);
if ("Trm-NF".equals(type)) if ("Trm-NF".equals(type))
return newLine(Product.TRAM, stripPrefix(number, "Trm", "Trm-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS); return newLine(Product.TRAM, stripPrefix(number, "Trm", "Trm-NF"), null, Line.Attr.WHEEL_CHAIR_ACCESS);
if ("S18".equals(number)) if ("S18".equals(number))
return newLine(Product.SUBURBAN_TRAIN, "S18", null); return newLine(Product.SUBURBAN_TRAIN, "S18", null);
if (type.length() > 0) if (type.length() > 0) {
{ final Product product = normalizeType(type);
final Product product = normalizeType(type); if (product != null)
if (product != null) return newLine(product, number, null);
return newLine(product, number, null); }
}
throw new IllegalStateException("cannot normalize type " + type + " number " + number + " line#type " + lineAndType); throw new IllegalStateException(
} "cannot normalize type " + type + " number " + number + " line#type " + lineAndType);
}
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) private String stripPrefix(final String str, final String... prefixes) {
{ for (final String prefix : prefixes)
for (final String prefix : prefixes) if (str.startsWith(prefix))
if (str.startsWith(prefix)) return str.substring(prefix.length());
return str.substring(prefix.length());
return str; return str;
} }
@Override @Override
protected Product normalizeType(final String type) protected Product normalizeType(final String type) {
{ final String ucType = type.toUpperCase();
final String ucType = type.toUpperCase();
if ("N".equals(ucType)) // Nachtbus if ("N".equals(ucType)) // Nachtbus
return Product.BUS; return Product.BUS;
if ("TX".equals(ucType)) if ("TX".equals(ucType))
return Product.BUS; return Product.BUS;
if ("KB".equals(ucType)) // Kleinbus? if ("KB".equals(ucType)) // Kleinbus?
return Product.BUS; return Product.BUS;
if ("D-SCHIFF".equals(ucType)) if ("D-SCHIFF".equals(ucType))
return Product.FERRY; return Product.FERRY;
if ("DAMPFSCH".equals(ucType)) if ("DAMPFSCH".equals(ucType))
return Product.FERRY; return Product.FERRY;
if ("BERGBAHN".equals(ucType)) if ("BERGBAHN".equals(ucType))
return Product.CABLECAR; return Product.CABLECAR;
if ("LSB".equals(ucType)) // Luftseilbahn if ("LSB".equals(ucType)) // Luftseilbahn
return Product.CABLECAR; return Product.CABLECAR;
if ("SLB".equals(ucType)) // Sesselliftbahn if ("SLB".equals(ucType)) // Sesselliftbahn
return Product.CABLECAR; 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 static {
{ // S-Bahn
// S-Bahn STYLES.put("SS2", new Style(Shape.RECT, Style.parseColor("#70c82c"), Style.WHITE));
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("SS3", new Style(Shape.RECT, Style.parseColor("#587AC2"), Style.WHITE)); STYLES.put("SS4", new Style(Shape.RECT, Style.parseColor("#EE7267"), 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("SS5", new Style(Shape.RECT, Style.parseColor("#6aadc3"), Style.WHITE)); STYLES.put("SS6", new Style(Shape.RECT, Style.parseColor("#6f41a4"), 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("SS7", new Style(Shape.RECT, Style.parseColor("#fbb809"), Style.BLACK)); STYLES.put("SS8", new Style(Shape.RECT, Style.parseColor("#562691"), Style.WHITE));
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("SS9", new Style(Shape.RECT, Style.parseColor("#069A5D"), Style.WHITE)); STYLES.put("SS10", new Style(Shape.RECT, Style.parseColor("#fbc434"), Style.BLACK));
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("SS11", new Style(Shape.RECT, Style.parseColor("#ae90cf"), Style.WHITE)); STYLES.put("SS12", new Style(Shape.RECT, Style.parseColor("#ed1c24"), 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("SS13", new Style(Shape.RECT, Style.parseColor("#905723"), Style.WHITE)); STYLES.put("SS14", new Style(Shape.RECT, Style.parseColor("#753c0c"), 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("SS15", new Style(Shape.RECT, Style.parseColor("#c79f73"), Style.WHITE)); STYLES.put("SS16", new Style(Shape.RECT, Style.parseColor("#68c971"), 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("SS17", new Style(Shape.RECT, Style.parseColor("#3b99b5"), Style.WHITE)); STYLES.put("SS18", new Style(Shape.RECT, Style.parseColor("#f14337"), 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("SS21", new Style(Shape.RECT, Style.parseColor("#9acaee"), Style.WHITE)); STYLES.put("SS22", new Style(Shape.RECT, Style.parseColor("#8dd24e"), 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("SS24", new Style(Shape.RECT, Style.parseColor("#ab7745"), Style.WHITE)); STYLES.put("SS26", new Style(Shape.RECT, Style.parseColor("#0e87aa"), 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("SS29", new Style(Shape.RECT, Style.parseColor("#3dba56"), Style.WHITE)); STYLES.put("SS30", new Style(Shape.RECT, Style.parseColor("#0b8ed8"), 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("SS33", new Style(Shape.RECT, Style.parseColor("#51aae3"), Style.WHITE)); STYLES.put("SS35", new Style(Shape.RECT, Style.parseColor("#81c0eb"), 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("SS40", new Style(Shape.RECT, Style.parseColor("#ae90cf"), Style.WHITE)); STYLES.put("SS41", new Style(Shape.RECT, Style.parseColor("#f89a83"), 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));
STYLES.put("SS55", new Style(Shape.RECT, Style.parseColor("#905723"), Style.WHITE));
// Tram // Tram
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE)); 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("T3", new Style(Shape.RECT, Style.parseColor("#19ae48"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#453fa0"), 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("T5", new Style(Shape.RECT, Style.parseColor("#8c5a2c"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#d6973c"), 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("T7", new Style(Shape.RECT, Style.parseColor("#231f20"), Style.WHITE));
STYLES.put("T8", new Style(Shape.RECT, Style.parseColor("#99d420"), Style.BLACK)); 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("T9", new Style(Shape.RECT, Style.parseColor("#453fa0"), Style.WHITE));
STYLES.put("T10", new Style(Shape.RECT, Style.parseColor("#ee1998"), 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("T11", new Style(Shape.RECT, Style.parseColor("#19ae48"), Style.WHITE));
STYLES.put("T12", new Style(Shape.RECT, Style.parseColor("#85d7e3"), Style.BLACK)); 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("T13", new Style(Shape.RECT, Style.parseColor("#fdd205"), Style.BLACK));
STYLES.put("T14", new Style(Shape.RECT, Style.parseColor("#2cbbf2"), Style.WHITE)); 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("T15", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T17", new Style(Shape.RECT, Style.parseColor("#9e1a6e"), Style.WHITE)); STYLES.put("T17", new Style(Shape.RECT, Style.parseColor("#9e1a6e"), Style.WHITE));
// Bus/Trolley // Bus/Trolley
STYLES.put("B31", new Style(Shape.RECT, Style.parseColor("#999bd3"), Style.WHITE)); 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("B32", new Style(Shape.RECT, Style.parseColor("#d8a1d6"), Style.BLACK));
STYLES.put("B33", new Style(Shape.RECT, Style.parseColor("#e4e793"), 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 * @author Andreas Schildbach
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public final class Departure implements Serializable public final class Departure implements Serializable {
{ final public @Nullable Date plannedTime;
final public @Nullable Date plannedTime; final public @Nullable Date predictedTime;
final public @Nullable Date predictedTime; final public Line line;
final public Line line; final public @Nullable Position position;
final public @Nullable Position position; final public @Nullable Location destination;
final public @Nullable Location destination; final public @Nullable int[] capacity;
final public @Nullable int[] capacity; final public @Nullable String message;
final public @Nullable String message;
public Departure(final Date plannedTime, final Date predictedTime, final Line line, final Position position, final Location destination, public Departure(final Date plannedTime, final Date predictedTime, final Line line, final Position position,
final int[] capacity, final String message) final Location destination, final int[] capacity, final String message) {
{ this.plannedTime = plannedTime;
this.plannedTime = plannedTime; this.predictedTime = predictedTime;
this.predictedTime = predictedTime; checkArgument(plannedTime != null || predictedTime != null);
checkArgument(plannedTime != null || predictedTime != null); this.line = checkNotNull(line);
this.line = checkNotNull(line); this.position = position;
this.position = position; this.destination = destination;
this.destination = destination; this.capacity = capacity;
this.capacity = capacity; this.message = message;
this.message = message; }
}
public Date getTime() public Date getTime() {
{ if (predictedTime != null)
if (predictedTime != null) return predictedTime;
return predictedTime; else
else return plannedTime;
return plannedTime; }
}
@Override @Override
public String toString() public String toString() {
{ final ToStringHelper helper = MoreObjects.toStringHelper(this);
final ToStringHelper helper = MoreObjects.toStringHelper(this); if (plannedTime != null)
if (plannedTime != null) helper.add("planned", String.format(Locale.US, "%ta %<tR", plannedTime));
helper.add("planned", String.format(Locale.US, "%ta %<tR", plannedTime)); if (predictedTime != null)
if (predictedTime != null) helper.add("predicted", String.format(Locale.US, "%ta %<tR", predictedTime));
helper.add("predicted", String.format(Locale.US, "%ta %<tR", predictedTime)); return helper.addValue(line).addValue(position).add("destination", destination).omitNullValues().toString();
return helper.addValue(line).addValue(position).add("destination", destination).omitNullValues().toString(); }
}
@Override @Override
public boolean equals(final Object o) public boolean equals(final Object o) {
{ if (o == this)
if (o == this) return true;
return true; if (!(o instanceof Departure))
if (!(o instanceof Departure)) return false;
return false; final Departure other = (Departure) o;
final Departure other = (Departure) o; if (!Objects.equal(this.plannedTime, other.plannedTime))
if (!Objects.equal(this.plannedTime, other.plannedTime)) return false;
return false; if (!Objects.equal(this.predictedTime, other.predictedTime))
if (!Objects.equal(this.predictedTime, other.predictedTime)) return false;
return false; if (!Objects.equal(this.line, other.line))
if (!Objects.equal(this.line, other.line)) return false;
return false; if (!Objects.equal(this.destination, other.destination))
if (!Objects.equal(this.destination, other.destination)) return false;
return false; return true;
return true; }
}
@Override @Override
public int hashCode() public int hashCode() {
{ return Objects.hashCode(plannedTime, predictedTime, line, destination);
return Objects.hashCode(plannedTime, predictedTime, line, destination); }
}
public static final Comparator<Departure> TIME_COMPARATOR = new Comparator<Departure>() public static final Comparator<Departure> TIME_COMPARATOR = new Comparator<Departure>() {
{ public int compare(final Departure departure0, final Departure departure1) {
public int compare(final Departure departure0, final Departure departure1) return departure0.getTime().compareTo(departure1.getTime());
{ }
return departure0.getTime().compareTo(departure1.getTime()); };
}
};
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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