diff --git a/src/de/schildbach/pte/AbstractHafasProvider.java b/src/de/schildbach/pte/AbstractHafasProvider.java index 5fd9d11b..b35dc1fb 100644 --- a/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/src/de/schildbach/pte/AbstractHafasProvider.java @@ -26,10 +26,12 @@ import java.util.Collections; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1757,17 +1759,27 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider throw new IllegalStateException("cannot normalize line " + line); } - protected final Line newLine(final String lineStr) + protected final Line newLine(final String lineStr, final Line.Attr... attrs) { - return new Line(null, lineStr, lineColors(lineStr)); + if (attrs.length == 0) + { + return new Line(null, lineStr, lineColors(lineStr)); + } + else + { + final Set attrSet = new HashSet(); + for (final Line.Attr attr : attrs) + attrSet.add(attr); + return new Line(null, lineStr, lineColors(lineStr), attrSet); + } } - private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)"); + protected static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)"); private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}"); // saved from RtProvider private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("(\\d{3}(BJ|FJ|IJ|MJ|NJ|OJ|TJ|SZ))"); - protected final Line parseLineAndType(final String lineAndType) + protected Line parseLineAndType(final String lineAndType) { final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType); if (m.matches()) diff --git a/src/de/schildbach/pte/ZvvProvider.java b/src/de/schildbach/pte/ZvvProvider.java index 6bf4ed03..83c89ae9 100644 --- a/src/de/schildbach/pte/ZvvProvider.java +++ b/src/de/schildbach/pte/ZvvProvider.java @@ -19,6 +19,7 @@ package de.schildbach.pte; import java.io.IOException; import java.util.List; +import java.util.regex.Matcher; import de.schildbach.pte.dto.Line; import de.schildbach.pte.dto.Location; @@ -168,6 +169,35 @@ public class ZvvProvider extends AbstractHafasProvider return parseLineAndType(line); } + @Override + protected Line parseLineAndType(final String lineAndType) + { + final Matcher m = P_NORMALIZE_LINE_AND_TYPE.matcher(lineAndType); + if (m.matches()) + { + final String number = m.group(1).replaceAll("\\s+", " "); + final String type = m.group(2); + + if ("Bus-NF".equals(type)) + return newLine('B' + number, Line.Attr.WHEEL_CHAIR_ACCESS); + if ("Tro-NF".equals(type)) + return newLine('B' + number, Line.Attr.WHEEL_CHAIR_ACCESS); + if ("Trm-NF".equals(type)) + return newLine('T' + number, Line.Attr.WHEEL_CHAIR_ACCESS); + + if (type.length() > 0) + { + final char normalizedType = normalizeType(type); + if (normalizedType != 0) + return newLine(normalizedType + number); + } + + throw new IllegalStateException("cannot normalize type " + type + " number " + number + " line#type " + lineAndType); + } + + throw new IllegalStateException("cannot normalize line#type " + lineAndType); + } + @Override protected char normalizeType(final String type) {