mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 16:29:51 +00:00
London is more
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@297 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
ff93409f9a
commit
5e98011fbb
1 changed files with 45 additions and 6 deletions
|
@ -17,10 +17,13 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -39,16 +42,19 @@ public class TflProvider extends AbstractEfaProvider
|
||||||
public boolean hasCapabilities(final Capability... capabilities)
|
public boolean hasCapabilities(final Capability... capabilities)
|
||||||
{
|
{
|
||||||
for (final Capability capability : capabilities)
|
for (final Capability capability : capabilities)
|
||||||
if (capability == Capability.DEPARTURES)
|
if (capability == Capability.DEPARTURES || capability == Capability.CONNECTIONS)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "XSLT_TRIP_REQUEST2?outputFormat=XML&coordOutputFormat=WGS84&locationServerActive=1&type_origin=any&name_origin=%s";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String autocompleteUri(CharSequence constraint)
|
protected String autocompleteUri(CharSequence constraint)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
return String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), "ISO-8859-1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
|
@ -80,14 +86,47 @@ public class TflProvider extends AbstractEfaProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String connectionsQueryUri(Location from, Location via, Location to, Date date, boolean dep, String products, WalkSpeed walkSpeed)
|
protected String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||||
|
final String products, final WalkSpeed walkSpeed)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
||||||
|
final DateFormat TIME_FORMAT = new SimpleDateFormat("HHmm");
|
||||||
|
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE);
|
||||||
|
uri.append("XSLT_TRIP_REQUEST2");
|
||||||
|
|
||||||
|
uri.append("?language=de");
|
||||||
|
appendCommonConnectionParams(uri);
|
||||||
|
|
||||||
|
appendLocation(uri, from, "origin");
|
||||||
|
appendLocation(uri, to, "destination");
|
||||||
|
if (via != null)
|
||||||
|
appendLocation(uri, via, "via");
|
||||||
|
|
||||||
|
uri.append("&itdDate=").append(ParserUtils.urlEncode(DATE_FORMAT.format(date)));
|
||||||
|
uri.append("&itdTime=").append(ParserUtils.urlEncode(TIME_FORMAT.format(date)));
|
||||||
|
uri.append("&itdTripDateTimeDepArr=").append(dep ? "dep" : "arr");
|
||||||
|
|
||||||
|
uri.append("&ptOptionsActive=1");
|
||||||
|
uri.append("&changeSpeed=").append(WALKSPEED_MAP.get(walkSpeed));
|
||||||
|
uri.append(productParams(products));
|
||||||
|
|
||||||
|
uri.append("&locationServerActive=1");
|
||||||
|
uri.append("&useRealtime=1");
|
||||||
|
|
||||||
|
return uri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String commandLink(String sessionId, String command)
|
protected String commandLink(final String sessionId, final String command)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE);
|
||||||
|
uri.append("XSLT_TRIP_REQUEST2");
|
||||||
|
uri.append("?sessionID=").append(sessionId);
|
||||||
|
appendCommonConnectionParams(uri);
|
||||||
|
uri.append("&command=").append(command);
|
||||||
|
return uri.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue