From 57a67412b900699fc7329bbb5120c5cac8c4aec9 Mon Sep 17 00:00:00 2001 From: "andreas.schildbach" Date: Tue, 10 Aug 2010 16:32:30 +0000 Subject: [PATCH] 'no connections' error git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@63 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/SbbProvider.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/de/schildbach/pte/SbbProvider.java b/src/de/schildbach/pte/SbbProvider.java index a70b41d6..ac71e669 100644 --- a/src/de/schildbach/pte/SbbProvider.java +++ b/src/de/schildbach/pte/SbbProvider.java @@ -120,6 +120,7 @@ public class SbbProvider implements NetworkProvider private static final Pattern P_PRE_ADDRESS = Pattern.compile( "", Pattern.DOTALL); private static final Pattern P_ADDRESSES = Pattern.compile("\\s*(.*?)\\s*", Pattern.DOTALL); + private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern.compile("(keine Verbindung gefunden werden)"); public QueryConnectionsResult queryConnections(final String from, final String via, final String to, final Date date, final boolean dep) throws IOException @@ -127,7 +128,12 @@ public class SbbProvider implements NetworkProvider final String uri = connectionsQueryUri(from, via, to, date, dep); final CharSequence page = ParserUtils.scrape(uri); - // TODO errors + final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page); + if (mError.find()) + { + if (mError.group(1) != null) + return QueryConnectionsResult.NO_CONNECTIONS; + } List fromAddresses = null; List viaAddresses = null; @@ -439,12 +445,16 @@ public class SbbProvider implements NetworkProvider if (type.equals("ec")) // EuroCity return "I" + strippedLine; + if (type.equals("en")) // EuroNight + return "I" + strippedLine; if (type.equals("ice")) // InterCityExpress return "I" + strippedLine; if (type.equals("ic")) // InterCity return "I" + strippedLine; if (type.equals("icn")) // Intercity-Neigezug, Schweiz return "I" + strippedLine; + if (type.equals("cnl")) // CityNightLine + return "I" + strippedLine; if (type.equals("tha")) // Thalys return "I" + strippedLine; if (type.equals("r")) @@ -461,6 +471,12 @@ public class SbbProvider implements NetworkProvider return "B" + strippedLine; if (type.equals("tro")) return "B" + strippedLine; + if (type.equals("bat")) + return "F" + strippedLine; + if (type.equals("lb")) + return "C" + strippedLine; + if (type.equals("gb")) // Gondelbahn + return "C" + strippedLine; throw new IllegalStateException("cannot normalize type " + type + " line " + line); }