mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 16:59:51 +00:00
Allow specifying time when querying for departures.
This commit is contained in:
parent
110f48ac81
commit
6e2aa29eca
76 changed files with 224 additions and 206 deletions
|
@ -61,6 +61,7 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
|
||||
|
||||
setStationBoardCanDoEquivs(false);
|
||||
setStyles(STYLES);
|
||||
setExtXmlEndpoint(API_BASE + "extxml.exe");
|
||||
}
|
||||
|
@ -119,19 +120,6 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
private String departuresQueryUri(final String stationId, final int maxDepartures)
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append("?input=").append(normalizeStationId(stationId));
|
||||
uri.append("&boardType=dep");
|
||||
uri.append("&productsFilter=").append(allProductsString());
|
||||
uri.append("&maxJourneys=").append(maxDepartures != 0 ? maxDepartures : DEFAULT_MAX_DEPARTURES);
|
||||
uri.append("&disableEquivs=yes"); // don't use nearby stations
|
||||
uri.append("&start=yes");
|
||||
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern
|
||||
.compile(
|
||||
".*?" //
|
||||
|
@ -163,14 +151,19 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
, Pattern.DOTALL);
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(SERVER_PRODUCT);
|
||||
final QueryDeparturesResult result = new QueryDeparturesResult(header);
|
||||
|
||||
// scrape page
|
||||
final String uri = departuresQueryUri(stationId, maxDepartures);
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
appendXmlStationBoardParameters(uri, time, stationId, maxDepartures, null);
|
||||
final CharSequence page = ParserUtils.scrape(uri.toString());
|
||||
|
||||
// System.out.println(uri);
|
||||
// System.out.println(page);
|
||||
|
||||
// parse page
|
||||
final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue