From 9b34b91ad43041ab441af69f6034c6978033cd21 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Tue, 8 Jan 2019 00:57:36 +0100 Subject: [PATCH] AbstractHafasClientInterfaceProvider: Parse 'lineId' of 'prodCtx' and use it. --- .../AbstractHafasClientInterfaceProvider.java | 10 ++++++---- enabler/src/de/schildbach/pte/BvgProvider.java | 18 +++++++++--------- enabler/src/de/schildbach/pte/VbnProvider.java | 8 ++++---- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index 603ea5ba..49435b77 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -1015,14 +1015,16 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas final int oprIndex = prod.optInt("oprX", -1); final String operator = oprIndex != -1 ? operators.get(oprIndex) : null; final int cls = prod.optInt("cls", -1); + final JSONObject prodCtx = prod.optJSONObject("prodCtx"); + final String id = prodCtx != null ? prodCtx.optString("lineId", null) : null; final Product product = cls != -1 ? intToProduct(cls) : null; - lines.add(newLine(operator, product, name, nameS, number, style)); + lines.add(newLine(id, operator, product, name, nameS, number, style)); } return lines; } - protected Line newLine(final String operator, final Product product, final @Nullable String name, + protected Line newLine(final String id, final String operator, final Product product, final @Nullable String name, final @Nullable String shortName, final @Nullable String number, final Style style) { final String longName; if (name != null) @@ -1041,10 +1043,10 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas label = number; else label = name; - return new Line(null, operator, product, label, longName, lineStyle(operator, product, label)); + return new Line(id, operator, product, label, longName, lineStyle(operator, product, label)); } else { // Otherwise the longer label is fine - return new Line(null, operator, product, name, longName, lineStyle(operator, product, name)); + return new Line(id, operator, product, name, longName, lineStyle(operator, product, name)); } } diff --git a/enabler/src/de/schildbach/pte/BvgProvider.java b/enabler/src/de/schildbach/pte/BvgProvider.java index b5b1b73c..9c8aac7b 100644 --- a/enabler/src/de/schildbach/pte/BvgProvider.java +++ b/enabler/src/de/schildbach/pte/BvgProvider.java @@ -109,32 +109,32 @@ public final class BvgProvider extends AbstractHafasClientInterfaceProvider { } @Override - protected Line newLine(final String operator, final Product product, final @Nullable String name, + protected Line newLine(final String id, final String operator, final Product product, final @Nullable String name, final @Nullable String shortName, final @Nullable String number, final Style style) { - final Line line = super.newLine(operator, product, name, shortName, number, style); + final Line line = super.newLine(id, operator, product, name, shortName, number, style); if (line.product == Product.SUBURBAN_TRAIN) { if ("S41".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.CIRCLE_CLOCKWISE), line.message); if ("S42".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.CIRCLE_ANTICLOCKWISE), line.message); if ("S9".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.LINE_AIRPORT), line.message); if ("S45".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.LINE_AIRPORT), line.message); } else if (line.product == Product.BUS) { if ("S41".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE), line.message); if ("S42".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE), line.message); if ("TXL".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.LINE_AIRPORT), line.message); } diff --git a/enabler/src/de/schildbach/pte/VbnProvider.java b/enabler/src/de/schildbach/pte/VbnProvider.java index 4ff0a90d..5754c173 100644 --- a/enabler/src/de/schildbach/pte/VbnProvider.java +++ b/enabler/src/de/schildbach/pte/VbnProvider.java @@ -90,16 +90,16 @@ public class VbnProvider extends AbstractHafasClientInterfaceProvider { } @Override - protected Line newLine(final String operator, final Product product, final @Nullable String name, + protected Line newLine(final String id, final String operator, final Product product, final @Nullable String name, final @Nullable String shortName, final @Nullable String number, final Style style) { - final Line line = super.newLine(operator, product, name, shortName, number, style); + final Line line = super.newLine(id, operator, product, name, shortName, number, style); if (line.product == Product.BUS) { if ("57".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_CLOCKWISE), line.message); if ("58".equals(line.label)) - return new Line(null, line.network, line.product, line.label, line.name, line.style, + return new Line(id, line.network, line.product, line.label, line.name, line.style, Sets.newHashSet(Attr.SERVICE_REPLACEMENT, Attr.CIRCLE_ANTICLOCKWISE), line.message); }