'no connections' error

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@63 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-08-10 16:32:30 +00:00
parent ea85db9851
commit 57a67412b9

View file

@ -120,6 +120,7 @@ public class SbbProvider implements NetworkProvider
private static final Pattern P_PRE_ADDRESS = Pattern.compile( private static final Pattern P_PRE_ADDRESS = Pattern.compile(
"<select name=\"(REQ0JourneyStopsS0K|REQ0JourneyStopsZ0K|REQ0JourneyStops1\\.0K)\" accesskey=\"f\".*?>(.*?)</select>", Pattern.DOTALL); "<select name=\"(REQ0JourneyStopsS0K|REQ0JourneyStopsZ0K|REQ0JourneyStops1\\.0K)\" accesskey=\"f\".*?>(.*?)</select>", Pattern.DOTALL);
private static final Pattern P_ADDRESSES = Pattern.compile("<option.*?>\\s*(.*?)\\s*</option>", Pattern.DOTALL); private static final Pattern P_ADDRESSES = Pattern.compile("<option.*?>\\s*(.*?)\\s*</option>", 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) public QueryConnectionsResult queryConnections(final String from, final String via, final String to, final Date date, final boolean dep)
throws IOException throws IOException
@ -127,7 +128,12 @@ public class SbbProvider implements NetworkProvider
final String uri = connectionsQueryUri(from, via, to, date, dep); final String uri = connectionsQueryUri(from, via, to, date, dep);
final CharSequence page = ParserUtils.scrape(uri); 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<String> fromAddresses = null; List<String> fromAddresses = null;
List<String> viaAddresses = null; List<String> viaAddresses = null;
@ -439,12 +445,16 @@ public class SbbProvider implements NetworkProvider
if (type.equals("ec")) // EuroCity if (type.equals("ec")) // EuroCity
return "I" + strippedLine; return "I" + strippedLine;
if (type.equals("en")) // EuroNight
return "I" + strippedLine;
if (type.equals("ice")) // InterCityExpress if (type.equals("ice")) // InterCityExpress
return "I" + strippedLine; return "I" + strippedLine;
if (type.equals("ic")) // InterCity if (type.equals("ic")) // InterCity
return "I" + strippedLine; return "I" + strippedLine;
if (type.equals("icn")) // Intercity-Neigezug, Schweiz if (type.equals("icn")) // Intercity-Neigezug, Schweiz
return "I" + strippedLine; return "I" + strippedLine;
if (type.equals("cnl")) // CityNightLine
return "I" + strippedLine;
if (type.equals("tha")) // Thalys if (type.equals("tha")) // Thalys
return "I" + strippedLine; return "I" + strippedLine;
if (type.equals("r")) if (type.equals("r"))
@ -461,6 +471,12 @@ public class SbbProvider implements NetworkProvider
return "B" + strippedLine; return "B" + strippedLine;
if (type.equals("tro")) if (type.equals("tro"))
return "B" + strippedLine; 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); throw new IllegalStateException("cannot normalize type " + type + " line " + line);
} }