mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-20 09:19:57 +00:00
parameter for number of connections to query
This commit is contained in:
parent
0b40edff29
commit
d254923b77
73 changed files with 278 additions and 252 deletions
|
@ -1564,7 +1564,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
protected String xsltTripRequest2Uri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final String products, final WalkSpeed walkSpeed, final Accessibility accessibility)
|
||||
final int numConnections, final String products, final WalkSpeed walkSpeed, final Accessibility accessibility)
|
||||
{
|
||||
final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
||||
final DateFormat TIME_FORMAT = new SimpleDateFormat("HHmm");
|
||||
|
@ -1588,6 +1588,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
uri.append("&itdTime=").append(ParserUtils.urlEncode(TIME_FORMAT.format(date)));
|
||||
uri.append("&itdTripDateTimeDepArr=").append(dep ? "dep" : "arr");
|
||||
|
||||
uri.append("&calcNumberOfTrips=").append(numConnections);
|
||||
|
||||
uri.append("&ptOptionsActive=1"); // enable public transport options
|
||||
uri.append("&itOptionsActive=1"); // enable individual transport options
|
||||
uri.append("&changeSpeed=").append(WALKSPEED_MAP.get(walkSpeed));
|
||||
|
@ -1666,9 +1668,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
public QueryConnectionsResult queryConnections(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
final int numConnections, final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
{
|
||||
final String uri = xsltTripRequest2Uri(from, via, to, date, dep, products, walkSpeed, accessibility);
|
||||
final String uri = xsltTripRequest2Uri(from, via, to, date, dep, numConnections, products, walkSpeed, accessibility);
|
||||
|
||||
InputStream is = null;
|
||||
try
|
||||
|
@ -1687,7 +1689,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later, final int numConnections)
|
||||
throws IOException
|
||||
{
|
||||
final Context context = (Context) contextObj;
|
||||
final String commandUri = context.context;
|
||||
|
|
|
@ -70,7 +70,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
private static final String DEFAULT_ENCODING = "ISO-8859-1";
|
||||
private static final String PROD = "hafas";
|
||||
private static final int NUM_CONNECTIONS = 6;
|
||||
|
||||
private final String apiUri;
|
||||
private final int numProductBits;
|
||||
|
@ -727,7 +726,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
public QueryConnectionsResult queryConnections(Location from, Location via, Location to, final Date date, final boolean dep,
|
||||
final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
final int numConnections, final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(SERVER_PRODUCT);
|
||||
|
||||
|
@ -795,7 +794,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
// number of connections backwards
|
||||
request.append(" b=\"").append(0).append("\"");
|
||||
// number of connection forwards
|
||||
request.append(" f=\"").append(NUM_CONNECTIONS).append("\"");
|
||||
request.append(" f=\"").append(numConnections).append("\"");
|
||||
// percentual extension of change time
|
||||
request.append(" chExtension=\"").append(walkSpeed == WalkSpeed.SLOW ? 50 : 0).append("\"");
|
||||
// TODO nrChanges: max number of changes
|
||||
|
@ -805,12 +804,13 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return queryConnections(null, true, request.toString(), from, via, to);
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later, final int numConnections)
|
||||
throws IOException
|
||||
{
|
||||
final Context context = (Context) contextObj;
|
||||
|
||||
final StringBuilder request = new StringBuilder("<ConScrReq scrDir=\"").append(later ? 'F' : 'B').append("\" nrCons=\"")
|
||||
.append(NUM_CONNECTIONS).append("\">");
|
||||
.append(numConnections).append("\">");
|
||||
request.append("<ConResCtxt>").append(later ? context.laterContext : context.earlierContext).append("</ConResCtxt>");
|
||||
request.append("</ConScrReq>");
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
|
||||
@Override
|
||||
public QueryConnectionsResult queryConnections(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
final int numConnections, final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
{
|
||||
final String uri = connectionsQueryUri(from, via, to, date, dep, products);
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
@ -317,7 +317,8 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later, final int numConnections)
|
||||
throws IOException
|
||||
{
|
||||
final Context context = (Context) contextObj;
|
||||
|
||||
|
|
|
@ -572,7 +572,7 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
|
||||
@Override
|
||||
public QueryConnectionsResult queryConnections(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
final int numConnections, final String products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
{
|
||||
final String uri = connectionsQueryUri(from, via, to, date, dep, products);
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
@ -627,7 +627,8 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later, final int numConnections)
|
||||
throws IOException
|
||||
{
|
||||
final Context context = (Context) contextObj;
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ import de.schildbach.pte.dto.QueryDeparturesResult;
|
|||
import de.schildbach.pte.dto.Style;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by providers of transportation networks
|
||||
*
|
||||
* Interface to be implemented by providers of transportation networks.
|
||||
*
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public interface NetworkProvider
|
||||
|
@ -107,6 +107,8 @@ public interface NetworkProvider
|
|||
* desired date for departing, mandatory
|
||||
* @param dep
|
||||
* date is departure date? {@code true} for departure, {@code false} for arrival
|
||||
* @param numConnections
|
||||
* number of connections to query
|
||||
* @param products
|
||||
* products to take into account
|
||||
* @param walkSpeed
|
||||
|
@ -116,8 +118,8 @@ public interface NetworkProvider
|
|||
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible connections
|
||||
* @throws IOException
|
||||
*/
|
||||
QueryConnectionsResult queryConnections(Location from, Location via, Location to, Date date, boolean dep, String products, WalkSpeed walkSpeed,
|
||||
Accessibility accessibility) throws IOException;
|
||||
QueryConnectionsResult queryConnections(Location from, Location via, Location to, Date date, boolean dep, int numConnections, String products,
|
||||
WalkSpeed walkSpeed, Accessibility accessibility) throws IOException;
|
||||
|
||||
/**
|
||||
* Query more connections (e.g. earlier or later)
|
||||
|
@ -126,10 +128,12 @@ public interface NetworkProvider
|
|||
* context to query more connections from
|
||||
* @param next
|
||||
* {@code true} for get next connections, {@code false} for get previous connections
|
||||
* @param numConnections
|
||||
* number of connections to query
|
||||
* @return result object that contains possible connections
|
||||
* @throws IOException
|
||||
*/
|
||||
QueryConnectionsResult queryMoreConnections(QueryConnectionsContext context, boolean later) throws IOException;
|
||||
QueryConnectionsResult queryMoreConnections(QueryConnectionsContext context, boolean later, int numConnections) throws IOException;
|
||||
|
||||
/**
|
||||
* Get details about a connection
|
||||
|
|
|
@ -51,8 +51,8 @@ public class VgnProvider extends AbstractEfaProvider
|
|||
|
||||
@Override
|
||||
protected String xsltTripRequest2Uri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final String products, final WalkSpeed walkSpeed, final Accessibility accessibility)
|
||||
final int numConnections, final String products, final WalkSpeed walkSpeed, final Accessibility accessibility)
|
||||
{
|
||||
return super.xsltTripRequest2Uri(from, via, to, date, dep, products, walkSpeed, accessibility) + "&itdLPxx_showTariffLevel=1";
|
||||
return super.xsltTripRequest2Uri(from, via, to, date, dep, numConnections, products, walkSpeed, accessibility) + "&itdLPxx_showTariffLevel=1";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue