query more connections for Switzerland and Belgium

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@318 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-10-23 13:28:36 +00:00
parent 039168e55f
commit 6811870b0e
13 changed files with 49 additions and 49 deletions

View file

@ -993,8 +993,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
XmlPullUtil.skipRestOfTree(pp);
}
return new QueryConnectionsResult(uri, from, via, to, commandLink(sessionId, "tripPrev"), commandLink(sessionId, "tripNext"),
connections);
return new QueryConnectionsResult(uri, from, via, to, commandLink(sessionId, "tripNext"), connections);
}
else
{

View file

@ -233,9 +233,26 @@ public abstract class AbstractHafasProvider implements NetworkProvider
+ "<RFlags b=\"0\" chExtension=\"0\" f=\"4\" sMode=\"N\"/>" //
+ "</ConReq>";
return queryConnections(request, from, via, to);
}
public QueryConnectionsResult queryMoreConnections(final String context) throws IOException
{
final String request = "<ConScrReq scr=\"F\" nrCons=\"4\">" //
+ "<ConResCtxt>" + context + "</ConResCtxt>" //
+ "</ConScrReq>";
return queryConnections(request, null, null, null);
}
private QueryConnectionsResult queryConnections(final String request, final Location from, final Location via, final Location to)
throws IOException
{
// System.out.println(request);
// System.out.println(ParserUtils.scrape(apiUri, true, wrap(request), null, false));
final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
InputStream is = null;
try
{
@ -263,7 +280,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
}
XmlPullUtil.require(pp, "ConResCtxt");
final String sessionId = XmlPullUtil.text(pp);
final String context = XmlPullUtil.text(pp);
XmlPullUtil.require(pp, "ConnectionList");
XmlPullUtil.enter(pp);
@ -456,7 +473,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
XmlPullUtil.exit(pp);
return new QueryConnectionsResult(null, from, via, to, null, null, connections);
return new QueryConnectionsResult(null, from, via, to, context, connections);
}
catch (final XmlPullParserException x)
{
@ -663,11 +680,6 @@ public abstract class AbstractHafasProvider implements NetworkProvider
return P_WHITESPACE.matcher(str).replaceAll("");
}
public QueryConnectionsResult queryMoreConnections(String uri) throws IOException
{
throw new UnsupportedOperationException();
}
public GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException
{
throw new UnsupportedOperationException();

View file

@ -294,7 +294,7 @@ public final class BahnProvider implements NetworkProvider
}
}
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
return new QueryConnectionsResult(uri, from, null, to, linkLater, connections);
}
else
{

View file

@ -287,7 +287,7 @@ public final class BvgProvider implements NetworkProvider
}
}
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
return new QueryConnectionsResult(uri, from, null, to, linkLater, connections);
}
else
{

View file

@ -102,12 +102,12 @@ public interface NetworkProvider
/**
* Query more connections (e.g. earlier or later)
*
* @param uri
* uri to query more connections from
* @param context
* context to query more connections from
* @return result object that contains possible connections
* @throws IOException
*/
QueryConnectionsResult queryMoreConnections(String uri) throws IOException;
QueryConnectionsResult queryMoreConnections(String context) throws IOException;
/**
* Get details about a connection

View file

@ -477,7 +477,7 @@ public class OebbProvider extends AbstractHafasProvider
}
return new QueryConnectionsResult(allDetailsUri, from, null, to, linkEarlier, linkLater, connections);
return new QueryConnectionsResult(allDetailsUri, from, null, to, linkLater, connections);
}
else
{

View file

@ -304,7 +304,7 @@ public class RmvProvider extends AbstractHafasProvider
}
}
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
return new QueryConnectionsResult(uri, from, null, to, linkLater, connections);
}
else
{

View file

@ -44,20 +44,18 @@ public final class QueryConnectionsResult implements Serializable
public final Location from;
public final Location via;
public final Location to;
public final String linkEarlier;
public final String linkLater;
public final String context;
public final List<Connection> connections;
public QueryConnectionsResult(final String queryUri, final Location from, final Location via, final Location to, final String linkEarlier,
final String linkLater, final List<Connection> connections)
public QueryConnectionsResult(final String queryUri, final Location from, final Location via, final Location to, final String context,
final List<Connection> connections)
{
this.status = Status.OK;
this.queryUri = queryUri;
this.from = from;
this.via = via;
this.to = to;
this.linkEarlier = linkEarlier;
this.linkLater = linkLater;
this.context = context;
this.connections = connections;
this.ambiguousFrom = null;
@ -76,8 +74,7 @@ public final class QueryConnectionsResult implements Serializable
this.from = null;
this.via = null;
this.to = null;
this.linkEarlier = null;
this.linkLater = null;
this.context = null;
this.connections = null;
}
@ -92,8 +89,7 @@ public final class QueryConnectionsResult implements Serializable
this.from = null;
this.via = null;
this.to = null;
this.linkEarlier = null;
this.linkLater = null;
this.context = null;
this.connections = null;
}

View file

@ -50,7 +50,7 @@ public class BahnProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Berlin"), null, new Location(
LocationType.ANY, 0, 0, 0, "Leipzig"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
for (final Connection connection : result.connections)
provider.getConnectionDetails(connection.link);
System.out.println(moreResult);
@ -62,7 +62,7 @@ public class BahnProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Marienburger Str., Berlin"), null,
new Location(LocationType.ANY, 0, 0, 0, "Tutzinger-Hof-Platz, Starnberg"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
for (final Connection connection : result.connections)
provider.getConnectionDetails(connection.link);
System.out.println(moreResult);
@ -76,7 +76,7 @@ public class BahnProviderLiveTest
new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
for (final Connection connection : result.connections)
provider.getConnectionDetails(connection.link);
System.out.println(moreResult);

View file

@ -90,7 +90,7 @@ public class LinzProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 0, 0, 0, "Linz Hauptbahnhof"), null,
new Location(LocationType.STATION, 0, 0, 0, "Linz Auwiesen"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -100,7 +100,7 @@ public class LinzProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 0, 0, 0, "Linz Auwiesen"), null,
new Location(LocationType.STATION, 0, 0, 0, "Linz Hafen"), new Date(), true, ALL_PRODUCTS, WalkSpeed.SLOW);
System.out.println(result);
// final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
// final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
// System.out.println(moreResult);
}
}

View file

@ -41,7 +41,7 @@ public class MvvProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Marienplatz"), null, new Location(
LocationType.ANY, 0, 0, 0, "Pasing"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -60,7 +60,7 @@ public class MvvProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48165238, 11577473, null), null,
new Location(LocationType.ADDRESS, 0, 47987199, 11326532, null), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -70,7 +70,7 @@ public class MvvProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48238341, 11478230, null), null,
new Location(LocationType.ANY, 0, 0, 0, "Ostbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -80,7 +80,7 @@ public class MvvProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 0, 0, "München, Maximilianstr. 1"),
null, new Location(LocationType.ADDRESS, 0, 0, 0, "Starnberg, Jahnstraße 50"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
}

View file

@ -50,7 +50,7 @@ public class OebbProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Linz"), null, new Location(
LocationType.ANY, 0, 0, 0, "Berlin"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -60,7 +60,7 @@ public class OebbProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Ramsen, Zoll"), null, new Location(
LocationType.ANY, 0, 0, 0, "Azuga"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -70,7 +70,7 @@ public class OebbProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Graz, Haselweg"), null,
new Location(LocationType.ADDRESS, 0, 0, 0, "Innsbruck, Gumppstraße 69"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@ -81,7 +81,7 @@ public class OebbProviderLiveTest
.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Wien, Krottenbachstraße 110!"), null, new Location(LocationType.ADDRESS,
0, 0, 0, "Wien, Meidlinger Hauptstraße 1"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
}

View file

@ -24,7 +24,6 @@ import org.junit.Test;
import de.schildbach.pte.SbbProvider;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
@ -77,10 +76,8 @@ public class SbbProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8503000, 0, 0, "Zürich HB"), null,
new Location(LocationType.STATION, 8507785, 0, 0, "Bern, Hauptbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
for (final Connection connection : moreResult.connections)
System.out.println(provider.getConnectionDetails(connection.link));
}
@Test
@ -89,10 +86,8 @@ public class SbbProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, 0, 0, "Schocherswil, Alte Post!"), null,
new Location(LocationType.ANY, 0, 0, 0, "Laconnex, Mollach"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
for (final Connection connection : moreResult.connections)
System.out.println(provider.getConnectionDetails(connection.link));
}
@Test
@ -101,9 +96,7 @@ public class SbbProviderLiveTest
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 0, 0, "Spiez, Seestraße 62"), null,
new Location(LocationType.ADDRESS, 0, 0, 0, "Einsiedeln, Erlenmoosweg 24"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
for (final Connection connection : moreResult.connections)
System.out.println(provider.getConnectionDetails(connection.link));
}
}