diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 395dc018..22f378f4 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -1763,8 +1763,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider trainNum = null; } + final String network = lineId.substring(0, lineId.indexOf(':')); final String lineLabel = parseLine(productType, symbol, symbol, null, trainType, trainNum, productName); - line = new Line(lineId, lineLabel, lineStyle(lineLabel)); + line = new Line(lineId, lineLabel, lineStyle(network, lineLabel)); } XmlPullUtil.exit(pp, "m"); @@ -1941,6 +1942,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider XmlPullUtil.next(pp); } } + + XmlPullUtil.require(pp, "motDivaParams"); + final String divaNetwork = XmlPullUtil.attr(pp, "network"); + XmlPullUtil.exit(pp, "itdServingLine"); final String trainType = ParserUtils.firstNotEmpty(slTrainType, itdTrainType); @@ -1948,7 +1953,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider final String label = parseLine(slMotType, slSymbol, slNumber, slNumber, trainType, slTrainNum, trainName); - return new Line(slStateless, label, lineStyle(label), itdMessage); + return new Line(slStateless, label, lineStyle(divaNetwork, label), itdMessage); } private static final Pattern P_STATION_NAME_WHITESPACE = Pattern.compile("\\s+"); @@ -2682,7 +2687,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider final Set lineAttrs = new HashSet(); if (wheelChairAccess || lowFloorVehicle) lineAttrs.add(Line.Attr.WHEEL_CHAIR_ACCESS); - final Line line = new Line(lineId, lineLabel, lineStyle(lineLabel), lineAttrs); + final Line line = new Line(lineId, lineLabel, lineStyle(divaNetwork, lineLabel), lineAttrs); final Stop departure = new Stop(departureLocation, true, departureTargetTime != null ? departureTargetTime : departureTime, departureTime != null ? departureTime : null, departurePosition, null); diff --git a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java index 82e2a7c0..192db23e 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java @@ -3005,14 +3005,14 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider if (attrs.length == 0) { - return new Line(null, lineStr, lineStyle(lineStr), comment); + return new Line(null, lineStr, lineStyle(null, lineStr), comment); } else { final Set attrSet = new HashSet(); for (final Line.Attr attr : attrs) attrSet.add(attr); - return new Line(null, lineStr, lineStyle(lineStr), attrSet, comment); + return new Line(null, lineStr, lineStyle(null, lineStr), attrSet, comment); } } diff --git a/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java b/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java index 4bdeacd9..1f79aa58 100644 --- a/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java @@ -54,13 +54,36 @@ public abstract class AbstractNetworkProvider implements NetworkProvider this.styles = styles; } - public Style lineStyle(final String line) + private static final char STYLES_SEP = '|'; + + public Style lineStyle(final String network, final String line) { if (line == null || line.length() == 0) return null; if (styles != null) { + if (network != null) + { + // check for line match + final Style lineStyle = styles.get(network + STYLES_SEP + line); + if (lineStyle != null) + return lineStyle; + + // check for product match + final Style productStyle = styles.get(network + STYLES_SEP + line.charAt(0)); + if (productStyle != null) + return productStyle; + + // check for night bus, as that's a common special case + if (line.startsWith("BN")) + { + final Style nightStyle = styles.get(network + STYLES_SEP + "BN"); + if (nightStyle != null) + return nightStyle; + } + } + // check for line match final Style lineStyle = styles.get(line); if (lineStyle != null) diff --git a/enabler/src/de/schildbach/pte/InvgProvider.java b/enabler/src/de/schildbach/pte/InvgProvider.java index ab662d44..bd2879f3 100644 --- a/enabler/src/de/schildbach/pte/InvgProvider.java +++ b/enabler/src/de/schildbach/pte/InvgProvider.java @@ -290,28 +290,28 @@ public class InvgProvider extends AbstractHafasProvider if (mBus.matches()) { final String lineStr = "B" + mBus.group(1); - return new Line(null, lineStr, lineStyle(lineStr)); + return new Line(null, lineStr, lineStyle(null, lineStr)); } final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line); if (mNachtbus.matches()) { final String lineStr = "BN" + mNachtbus.group(1); - return new Line(null, lineStr, lineStyle(lineStr)); + return new Line(null, lineStr, lineStyle(null, lineStr)); } final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line); if (mBusS.matches()) { final String lineStr = "BS" + mBusS.group(1); - return new Line(null, lineStr, lineStyle(lineStr)); + return new Line(null, lineStr, lineStyle(null, lineStr)); } final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line); if (mBusX.matches()) { final String lineStr = "BX" + mBusX.group(1); - return new Line(null, lineStr, lineStyle(lineStr)); + return new Line(null, lineStr, lineStyle(null, lineStr)); } } diff --git a/enabler/src/de/schildbach/pte/NetworkProvider.java b/enabler/src/de/schildbach/pte/NetworkProvider.java index be99d788..ce96f86e 100644 --- a/enabler/src/de/schildbach/pte/NetworkProvider.java +++ b/enabler/src/de/schildbach/pte/NetworkProvider.java @@ -161,11 +161,13 @@ public interface NetworkProvider /** * Get style of line * + * @param network + * network to disambiguate line * @param line * line to get style of - * @return object containing background, foreground and border (optional) colors + * @return object containing background, foreground and optional border colors */ - Style lineStyle(String line); + Style lineStyle(String network, String line); /** * Gets the primary covered area of the network diff --git a/enabler/src/de/schildbach/pte/TflProvider.java b/enabler/src/de/schildbach/pte/TflProvider.java index 98f566d1..74b57980 100644 --- a/enabler/src/de/schildbach/pte/TflProvider.java +++ b/enabler/src/de/schildbach/pte/TflProvider.java @@ -154,11 +154,11 @@ public class TflProvider extends AbstractEfaProvider } @Override - public Style lineStyle(final String line) + public Style lineStyle(final String network, final String line) { if (line.startsWith("SLO")) - return super.lineStyle("SLO"); + return super.lineStyle(network, "SLO"); - return super.lineStyle(line); + return super.lineStyle(network, line); } } diff --git a/enabler/src/de/schildbach/pte/VrrProvider.java b/enabler/src/de/schildbach/pte/VrrProvider.java index c49f936e..6404a4ae 100644 --- a/enabler/src/de/schildbach/pte/VrrProvider.java +++ b/enabler/src/de/schildbach/pte/VrrProvider.java @@ -67,58 +67,58 @@ public class VrrProvider extends AbstractEfaProvider static { // Busse Bonn - STYLES.put("B63", new Style(Style.parseColor("#0065ae"), Style.WHITE)); - STYLES.put("B16", new Style(Style.parseColor("#0065ae"), Style.WHITE)); - STYLES.put("B66", new Style(Style.parseColor("#0065ae"), Style.WHITE)); - STYLES.put("B67", new Style(Style.parseColor("#0065ae"), Style.WHITE)); - STYLES.put("B68", new Style(Style.parseColor("#0065ae"), Style.WHITE)); - STYLES.put("B18", new Style(Style.parseColor("#0065ae"), Style.WHITE)); - STYLES.put("B61", new Style(Style.parseColor("#e4000b"), Style.WHITE)); - STYLES.put("B62", new Style(Style.parseColor("#e4000b"), Style.WHITE)); - STYLES.put("B65", new Style(Style.parseColor("#e4000b"), Style.WHITE)); - STYLES.put("BSB55", new Style(Style.parseColor("#00919e"), Style.WHITE)); - STYLES.put("BSB60", new Style(Style.parseColor("#8f9867"), Style.WHITE)); - STYLES.put("BSB69", new Style(Style.parseColor("#db5f1f"), Style.WHITE)); - STYLES.put("B529", new Style(Style.parseColor("#2e2383"), Style.WHITE)); - STYLES.put("B537", new Style(Style.parseColor("#2e2383"), Style.WHITE)); - STYLES.put("B541", new Style(Style.parseColor("#2e2383"), Style.WHITE)); - STYLES.put("B550", new Style(Style.parseColor("#2e2383"), Style.WHITE)); - STYLES.put("B163", new Style(Style.parseColor("#2e2383"), Style.WHITE)); - STYLES.put("B551", new Style(Style.parseColor("#2e2383"), Style.WHITE)); - STYLES.put("B600", new Style(Style.parseColor("#817db7"), Style.WHITE)); - STYLES.put("B601", new Style(Style.parseColor("#831b82"), Style.WHITE)); - STYLES.put("B602", new Style(Style.parseColor("#dd6ba6"), Style.WHITE)); - STYLES.put("B603", new Style(Style.parseColor("#e6007d"), Style.WHITE)); - STYLES.put("B604", new Style(Style.parseColor("#009f5d"), Style.WHITE)); - STYLES.put("B605", new Style(Style.parseColor("#007b3b"), Style.WHITE)); - STYLES.put("B606", new Style(Style.parseColor("#9cbf11"), Style.WHITE)); - STYLES.put("B607", new Style(Style.parseColor("#60ad2a"), Style.WHITE)); - STYLES.put("B608", new Style(Style.parseColor("#f8a600"), Style.WHITE)); - STYLES.put("B609", new Style(Style.parseColor("#ef7100"), Style.WHITE)); - STYLES.put("B610", new Style(Style.parseColor("#3ec1f1"), Style.WHITE)); - STYLES.put("B611", new Style(Style.parseColor("#0099db"), Style.WHITE)); - STYLES.put("B612", new Style(Style.parseColor("#ce9d53"), Style.WHITE)); - STYLES.put("B613", new Style(Style.parseColor("#7b3600"), Style.WHITE)); - STYLES.put("B614", new Style(Style.parseColor("#806839"), Style.WHITE)); - STYLES.put("B615", new Style(Style.parseColor("#532700"), Style.WHITE)); - STYLES.put("B630", new Style(Style.parseColor("#c41950"), Style.WHITE)); - STYLES.put("B631", new Style(Style.parseColor("#9b1c44"), Style.WHITE)); - STYLES.put("B633", new Style(Style.parseColor("#88cdc7"), Style.WHITE)); - STYLES.put("B635", new Style(Style.parseColor("#cec800"), Style.WHITE)); - STYLES.put("B636", new Style(Style.parseColor("#af0223"), Style.WHITE)); - STYLES.put("B637", new Style(Style.parseColor("#e3572a"), Style.WHITE)); - STYLES.put("B638", new Style(Style.parseColor("#af5836"), Style.WHITE)); - STYLES.put("B640", new Style(Style.parseColor("#004f81"), Style.WHITE)); - STYLES.put("BT650", new Style(Style.parseColor("#54baa2"), Style.WHITE)); - STYLES.put("BT651", new Style(Style.parseColor("#005738"), Style.WHITE)); - STYLES.put("BT680", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B800", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B812", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B843", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B845", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B852", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B855", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B856", new Style(Style.parseColor("#4e6578"), Style.WHITE)); - STYLES.put("B857", new Style(Style.parseColor("#4e6578"), 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|B66", new Style(Style.parseColor("#0065ae"), Style.WHITE)); + STYLES.put("vrs|B67", new Style(Style.parseColor("#0065ae"), Style.WHITE)); + STYLES.put("vrs|B68", new Style(Style.parseColor("#0065ae"), Style.WHITE)); + STYLES.put("vrs|B18", new Style(Style.parseColor("#0065ae"), Style.WHITE)); + STYLES.put("vrs|B61", new Style(Style.parseColor("#e4000b"), Style.WHITE)); + STYLES.put("vrs|B62", new Style(Style.parseColor("#e4000b"), Style.WHITE)); + STYLES.put("vrs|B65", new Style(Style.parseColor("#e4000b"), Style.WHITE)); + STYLES.put("vrs|BSB55", new Style(Style.parseColor("#00919e"), Style.WHITE)); + STYLES.put("vrs|BSB60", new Style(Style.parseColor("#8f9867"), Style.WHITE)); + STYLES.put("vrs|BSB69", new Style(Style.parseColor("#db5f1f"), Style.WHITE)); + STYLES.put("vrs|B529", new Style(Style.parseColor("#2e2383"), Style.WHITE)); + STYLES.put("vrs|B537", new Style(Style.parseColor("#2e2383"), Style.WHITE)); + STYLES.put("vrs|B541", new Style(Style.parseColor("#2e2383"), Style.WHITE)); + STYLES.put("vrs|B550", new Style(Style.parseColor("#2e2383"), Style.WHITE)); + STYLES.put("vrs|B163", new Style(Style.parseColor("#2e2383"), Style.WHITE)); + STYLES.put("vrs|B551", new Style(Style.parseColor("#2e2383"), Style.WHITE)); + STYLES.put("vrs|B600", new Style(Style.parseColor("#817db7"), Style.WHITE)); + STYLES.put("vrs|B601", new Style(Style.parseColor("#831b82"), Style.WHITE)); + STYLES.put("vrs|B602", new Style(Style.parseColor("#dd6ba6"), Style.WHITE)); + STYLES.put("vrs|B603", new Style(Style.parseColor("#e6007d"), Style.WHITE)); + STYLES.put("vrs|B604", new Style(Style.parseColor("#009f5d"), Style.WHITE)); + STYLES.put("vrs|B605", new Style(Style.parseColor("#007b3b"), Style.WHITE)); + STYLES.put("vrs|B606", new Style(Style.parseColor("#9cbf11"), Style.WHITE)); + STYLES.put("vrs|B607", new Style(Style.parseColor("#60ad2a"), Style.WHITE)); + STYLES.put("vrs|B608", new Style(Style.parseColor("#f8a600"), Style.WHITE)); + STYLES.put("vrs|B609", new Style(Style.parseColor("#ef7100"), Style.WHITE)); + STYLES.put("vrs|B610", new Style(Style.parseColor("#3ec1f1"), Style.WHITE)); + STYLES.put("vrs|B611", new Style(Style.parseColor("#0099db"), Style.WHITE)); + STYLES.put("vrs|B612", new Style(Style.parseColor("#ce9d53"), Style.WHITE)); + STYLES.put("vrs|B613", new Style(Style.parseColor("#7b3600"), Style.WHITE)); + STYLES.put("vrs|B614", new Style(Style.parseColor("#806839"), Style.WHITE)); + STYLES.put("vrs|B615", new Style(Style.parseColor("#532700"), Style.WHITE)); + STYLES.put("vrs|B630", new Style(Style.parseColor("#c41950"), Style.WHITE)); + STYLES.put("vrs|B631", new Style(Style.parseColor("#9b1c44"), Style.WHITE)); + STYLES.put("vrs|B633", new Style(Style.parseColor("#88cdc7"), Style.WHITE)); + STYLES.put("vrs|B635", new Style(Style.parseColor("#cec800"), Style.WHITE)); + STYLES.put("vrs|B636", new Style(Style.parseColor("#af0223"), Style.WHITE)); + STYLES.put("vrs|B637", new Style(Style.parseColor("#e3572a"), Style.WHITE)); + STYLES.put("vrs|B638", new Style(Style.parseColor("#af5836"), Style.WHITE)); + STYLES.put("vrs|B640", new Style(Style.parseColor("#004f81"), Style.WHITE)); + STYLES.put("vrs|BT650", new Style(Style.parseColor("#54baa2"), Style.WHITE)); + STYLES.put("vrs|BT651", new Style(Style.parseColor("#005738"), Style.WHITE)); + STYLES.put("vrs|BT680", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B800", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B812", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B843", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B845", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B852", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B855", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B856", new Style(Style.parseColor("#4e6578"), Style.WHITE)); + STYLES.put("vrs|B857", new Style(Style.parseColor("#4e6578"), Style.WHITE)); } } diff --git a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java index 5aa423d7..92de7350 100644 --- a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java @@ -75,6 +75,10 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest final QueryDeparturesResult result2 = provider.queryDepartures(20019904, 0, false); print(result2); + + // Bonn + provider.queryDepartures(22000687, 0, false); // Hauptbahnhof + provider.queryDepartures(22001374, 0, false); // Suedwache } @Test