mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 08:49:58 +00:00
rudimentary connections for all efa based providers
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@246 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
b4bf75d875
commit
875bd1d651
15 changed files with 725 additions and 193 deletions
|
@ -16,11 +16,10 @@
|
|||
*/
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||
import de.schildbach.pte.util.ParserUtils;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +33,8 @@ public class VrrProvider extends AbstractEfaProvider
|
|||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.DEPARTURES)
|
||||
if (capability == Capability.DEPARTURES || capability == Capability.CONNECTIONS || capability == Capability.LOCATION_STATION_ID
|
||||
|| capability == Capability.LOCATION_WGS84)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -76,19 +76,87 @@ public class VrrProvider extends AbstractEfaProvider
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryConnections(LocationType fromType, String from, LocationType viaType, String via, LocationType toType,
|
||||
String to, Date date, boolean dep, String products, WalkSpeed walkSpeed) throws IOException
|
||||
@Override
|
||||
protected 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 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");
|
||||
uri.append("&outputFormat=XML");
|
||||
uri.append("&coordOutputFormat=WGS84");
|
||||
|
||||
if (fromType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = from.split(",\\s*", 2);
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&nameInfo_origin=").append(String.format("%2.6f:%2.6f", lon / 1E6, lat / 1E6)).append(":WGS84[DD.dddddd]");
|
||||
uri.append("&typeInfo_origin=coord");
|
||||
}
|
||||
else
|
||||
{
|
||||
uri.append("&type_origin=").append(locationTypeValue(fromType));
|
||||
uri.append("&name_origin=").append(ParserUtils.urlEncode(from, "ISO-8859-1")); // fine-grained location
|
||||
}
|
||||
|
||||
if (toType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = to.split(",\\s*", 2);
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&nameInfo_destination=").append(String.format("%2.6f:%2.6f", lon / 1E6, lat / 1E6)).append(":WGS84[DD.dddddd]");
|
||||
uri.append("&typeInfo_destination=coord");
|
||||
}
|
||||
else
|
||||
{
|
||||
uri.append("&type_destination=").append(locationTypeValue(toType));
|
||||
uri.append("&name_destination=").append(ParserUtils.urlEncode(to, "ISO-8859-1")); // fine-grained location
|
||||
}
|
||||
|
||||
if (via != null)
|
||||
{
|
||||
if (viaType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = via.split(",\\s*", 2);
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&nameInfo_via=").append(String.format("%2.6f:%2.6f", lon / 1E6, lat / 1E6)).append(":WGS84[DD.dddddd]");
|
||||
uri.append("&typeInfo_via=coord");
|
||||
}
|
||||
else
|
||||
{
|
||||
uri.append("&type_via=").append(locationTypeValue(viaType));
|
||||
uri.append("&name_via=").append(ParserUtils.urlEncode(via, "ISO-8859-1"));
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
// TODO products
|
||||
|
||||
uri.append("&changeSpeed=").append(WALKSPEED_MAP.get(walkSpeed));
|
||||
|
||||
uri.append("&locationServerActive=1");
|
||||
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryMoreConnections(String uri) throws IOException
|
||||
@Override
|
||||
protected String commandLink(final String sessionId, final String command)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
final StringBuilder uri = new StringBuilder();
|
||||
uri.append(API_BASE);
|
||||
uri.append("XSLT_TRIP_REQUEST2");
|
||||
uri.append("?sessionID=").append(sessionId);
|
||||
uri.append("&command=").append(command);
|
||||
return uri.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue