mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 08:29:50 +00:00
handle stations by id if possible
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@124 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
197202e275
commit
e3b8e3e02e
7 changed files with 63 additions and 34 deletions
|
@ -89,8 +89,8 @@ public class SbbProvider implements NetworkProvider
|
|||
// final String uri = "http://fahrplan.sbb.ch/bin/extxml.exe/dn";
|
||||
}
|
||||
|
||||
private String connectionsQueryUri(final LocationType fromType, final String from, final String via, final LocationType toType, final String to,
|
||||
final Date date, final boolean dep)
|
||||
private String connectionsQueryUri(final LocationType fromType, final String from, final LocationType viaType, final String via,
|
||||
final LocationType toType, final String to, final Date date, final boolean dep)
|
||||
{
|
||||
final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yy");
|
||||
final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm");
|
||||
|
@ -109,7 +109,7 @@ public class SbbProvider implements NetworkProvider
|
|||
if (via != null)
|
||||
{
|
||||
uri.append("&REQ0JourneyStops1.0G=").append(ParserUtils.urlEncode(via));
|
||||
uri.append("&REQ0JourneyStops1.0A=7"); // any
|
||||
uri.append("&REQ0JourneyStops1.0A=").append(locationType(viaType));
|
||||
uri.append("&REQ0JourneyStops1.0ID=");
|
||||
}
|
||||
uri.append("&REQ0JourneyStopsZ0G=").append(ParserUtils.urlEncode(to));
|
||||
|
@ -124,6 +124,8 @@ public class SbbProvider implements NetworkProvider
|
|||
|
||||
private static int locationType(final LocationType locationType)
|
||||
{
|
||||
if (locationType == LocationType.STATION)
|
||||
return 1;
|
||||
if (locationType == LocationType.ADDRESS)
|
||||
return 2;
|
||||
if (locationType == LocationType.ANY)
|
||||
|
@ -139,7 +141,7 @@ public class SbbProvider implements NetworkProvider
|
|||
public QueryConnectionsResult queryConnections(final LocationType fromType, final String from, final LocationType viaType, final String via,
|
||||
final LocationType toType, final String to, final Date date, final boolean dep) throws IOException
|
||||
{
|
||||
final String uri = connectionsQueryUri(fromType, from, via, toType, to, date, dep);
|
||||
final String uri = connectionsQueryUri(fromType, from, viaType, via, toType, to, date, dep);
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
||||
final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue