mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-09 17:48:49 +00:00
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:
parent
8a69715ba0
commit
af0bcdc17c
5 changed files with 13 additions and 13 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue