From af0bcdc17c194f77dd96560bbfb8568106b144f1 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Sat, 27 May 2017 08:17:21 +1000 Subject: [PATCH] AbstractNavitiaProvider: Pass network to getLineStyle(). This allows coverages with multiple distinct transport agencies (e.g. Australia) to meaninfully distinguish between different lines with similar names. For example, there is often buses which are labelled by numbers. "Bus 12" needs to be two different colours, based on which transport network it belongs to. In the case of Australia, it will use this to delegate to the lineStyles() method. --- .../de/schildbach/pte/AbstractNavitiaProvider.java | 12 ++++++------ .../de/schildbach/pte/FranceNorthEastProvider.java | 2 +- .../de/schildbach/pte/FranceSouthEastProvider.java | 4 ++-- .../de/schildbach/pte/FranceSouthWestProvider.java | 4 ++-- enabler/src/de/schildbach/pte/ParisProvider.java | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java b/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java index 0196eb27..594624da 100644 --- a/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java @@ -145,12 +145,12 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider { return Style.deriveForegroundColor(bgColor); } - protected Style getLineStyle(final Product product, final String code, final String color) { - return getLineStyle(product, code, color, null); + protected Style getLineStyle(final String network, final Product product, final String code, final String color) { + return getLineStyle(network, product, code, color, null); } - protected Style getLineStyle(final Product product, final String code, final String backgroundColor, - final String foregroundColor) { + protected Style getLineStyle(final String network, final Product product, final String code, + final String backgroundColor, final String foregroundColor) { if (backgroundColor != null) { if (foregroundColor == null) return new Style(Shape.RECT, Style.parseColor(backgroundColor), @@ -417,7 +417,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider { final String code = displayInfo.getString("code"); final String color = Strings.emptyToNull(displayInfo.getString("color")); final String name = Strings.emptyToNull(displayInfo.optString("headsign")); - final Style lineStyle = getLineStyle(product, code, color != null ? "#" + color : null); + final Style lineStyle = getLineStyle(network, product, code, color != null ? "#" + color : null); return new Line(lineId, network, product, code, name, lineStyle); } catch (final JSONException jsonExc) { @@ -586,7 +586,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider { final String name = Strings.emptyToNull(jsonLine.optString("name")); final String color = Strings.emptyToNull(jsonLine.getString("color")); final String textColor = Strings.emptyToNull(jsonLine.optString("text_color")); - final Style lineStyle = getLineStyle(product, code, color != null ? "#" + color : null, + final Style lineStyle = getLineStyle(network, product, code, color != null ? "#" + color : null, textColor != null ? "#" + textColor : null); return new Line(lineId, network, product, code, name, lineStyle); diff --git a/enabler/src/de/schildbach/pte/FranceNorthEastProvider.java b/enabler/src/de/schildbach/pte/FranceNorthEastProvider.java index cecbade9..891a3a56 100644 --- a/enabler/src/de/schildbach/pte/FranceNorthEastProvider.java +++ b/enabler/src/de/schildbach/pte/FranceNorthEastProvider.java @@ -49,7 +49,7 @@ public class FranceNorthEastProvider extends AbstractNavitiaProvider { } @Override - protected Style getLineStyle(final Product product, final String code, final String color) { + protected Style getLineStyle(final String network, final Product product, final String code, final String color) { switch (product) { case REGIONAL_TRAIN: { // Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF) diff --git a/enabler/src/de/schildbach/pte/FranceSouthEastProvider.java b/enabler/src/de/schildbach/pte/FranceSouthEastProvider.java index 7290f59f..394db041 100644 --- a/enabler/src/de/schildbach/pte/FranceSouthEastProvider.java +++ b/enabler/src/de/schildbach/pte/FranceSouthEastProvider.java @@ -47,7 +47,7 @@ public class FranceSouthEastProvider extends AbstractNavitiaProvider { } @Override - protected Style getLineStyle(final Product product, final String code, final String color) { + protected Style getLineStyle(final String network, final Product product, final String code, final String color) { switch (product) { case REGIONAL_TRAIN: { // TER + Intercités @@ -73,7 +73,7 @@ public class FranceSouthEastProvider extends AbstractNavitiaProvider { return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); } default: - return super.getLineStyle(product, code, color); + return super.getLineStyle(network, product, code, color); } } } diff --git a/enabler/src/de/schildbach/pte/FranceSouthWestProvider.java b/enabler/src/de/schildbach/pte/FranceSouthWestProvider.java index bcf240a3..46f600bd 100644 --- a/enabler/src/de/schildbach/pte/FranceSouthWestProvider.java +++ b/enabler/src/de/schildbach/pte/FranceSouthWestProvider.java @@ -47,7 +47,7 @@ public class FranceSouthWestProvider extends AbstractNavitiaProvider { } @Override - protected Style getLineStyle(final Product product, final String code, final String color) { + protected Style getLineStyle(final String network, final Product product, final String code, final String color) { switch (product) { case REGIONAL_TRAIN: { // TER + Intercités @@ -73,7 +73,7 @@ public class FranceSouthWestProvider extends AbstractNavitiaProvider { return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); } default: - return super.getLineStyle(product, code, color); + return super.getLineStyle(network, product, code, color); } } } diff --git a/enabler/src/de/schildbach/pte/ParisProvider.java b/enabler/src/de/schildbach/pte/ParisProvider.java index 9e5cc2e5..efc7bf74 100644 --- a/enabler/src/de/schildbach/pte/ParisProvider.java +++ b/enabler/src/de/schildbach/pte/ParisProvider.java @@ -48,7 +48,7 @@ public class ParisProvider extends AbstractNavitiaProvider { } @Override - protected Style getLineStyle(final Product product, final String code, final String color) { + protected Style getLineStyle(final String network, final Product product, final String code, final String color) { switch (product) { case SUBURBAN_TRAIN: { // RER @@ -81,7 +81,7 @@ public class ParisProvider extends AbstractNavitiaProvider { return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); } default: - return super.getLineStyle(product, code, color); + return super.getLineStyle(network, product, code, color); } }