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.
This commit is contained in:
Peter Serwylo 2017-05-27 08:17:21 +10:00 committed by Andreas Schildbach
parent 8a69715ba0
commit af0bcdc17c
5 changed files with 13 additions and 13 deletions

View file

@ -145,12 +145,12 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
return Style.deriveForegroundColor(bgColor); return Style.deriveForegroundColor(bgColor);
} }
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) {
return getLineStyle(product, code, color, null); return getLineStyle(network, product, code, color, null);
} }
protected Style getLineStyle(final Product product, final String code, final String backgroundColor, protected Style getLineStyle(final String network, final Product product, final String code,
final String foregroundColor) { final String backgroundColor, final String foregroundColor) {
if (backgroundColor != null) { if (backgroundColor != null) {
if (foregroundColor == null) if (foregroundColor == null)
return new Style(Shape.RECT, Style.parseColor(backgroundColor), 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 code = displayInfo.getString("code");
final String color = Strings.emptyToNull(displayInfo.getString("color")); final String color = Strings.emptyToNull(displayInfo.getString("color"));
final String name = Strings.emptyToNull(displayInfo.optString("headsign")); 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); return new Line(lineId, network, product, code, name, lineStyle);
} catch (final JSONException jsonExc) { } catch (final JSONException jsonExc) {
@ -586,7 +586,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
final String name = Strings.emptyToNull(jsonLine.optString("name")); final String name = Strings.emptyToNull(jsonLine.optString("name"));
final String color = Strings.emptyToNull(jsonLine.getString("color")); final String color = Strings.emptyToNull(jsonLine.getString("color"));
final String textColor = Strings.emptyToNull(jsonLine.optString("text_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); textColor != null ? "#" + textColor : null);
return new Line(lineId, network, product, code, name, lineStyle); return new Line(lineId, network, product, code, name, lineStyle);

View file

@ -49,7 +49,7 @@ public class FranceNorthEastProvider extends AbstractNavitiaProvider {
} }
@Override @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) { switch (product) {
case REGIONAL_TRAIN: { case REGIONAL_TRAIN: {
// Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF) // Rail (route_type = 2) for TER and Corail Intercité/Lunéa (all SNCF)

View file

@ -47,7 +47,7 @@ public class FranceSouthEastProvider extends AbstractNavitiaProvider {
} }
@Override @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) { switch (product) {
case REGIONAL_TRAIN: { case REGIONAL_TRAIN: {
// TER + Intercités // TER + Intercités
@ -73,7 +73,7 @@ public class FranceSouthEastProvider extends AbstractNavitiaProvider {
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
} }
default: default:
return super.getLineStyle(product, code, color); return super.getLineStyle(network, product, code, color);
} }
} }
} }

View file

@ -47,7 +47,7 @@ public class FranceSouthWestProvider extends AbstractNavitiaProvider {
} }
@Override @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) { switch (product) {
case REGIONAL_TRAIN: { case REGIONAL_TRAIN: {
// TER + Intercités // TER + Intercités
@ -73,7 +73,7 @@ public class FranceSouthWestProvider extends AbstractNavitiaProvider {
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
} }
default: default:
return super.getLineStyle(product, code, color); return super.getLineStyle(network, product, code, color);
} }
} }
} }

View file

@ -48,7 +48,7 @@ public class ParisProvider extends AbstractNavitiaProvider {
} }
@Override @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) { switch (product) {
case SUBURBAN_TRAIN: { case SUBURBAN_TRAIN: {
// RER // RER
@ -81,7 +81,7 @@ public class ParisProvider extends AbstractNavitiaProvider {
return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
} }
default: default:
return super.getLineStyle(product, code, color); return super.getLineStyle(network, product, code, color);
} }
} }