mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 22:28:51 +00:00
uniform method order
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@663 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
56465ede5e
commit
c9fac86b2a
58 changed files with 967 additions and 968 deletions
|
@ -50,12 +50,6 @@ public class AtcProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class AtcProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class AvvProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class AvvProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,16 +68,6 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Pattern P_NEARBY_STATIONS_BY_STATION = Pattern
|
private final static Pattern P_NEARBY_STATIONS_BY_STATION = Pattern
|
||||||
.compile("<a href=\"http://mobile\\.bahn\\.de/bin/mobil/bhftafel.exe/dn[^\"]*?evaId=(\\d*)&[^\"]*?\">([^<]*)</a>");
|
.compile("<a href=\"http://mobile\\.bahn\\.de/bin/mobil/bhftafel.exe/dn[^\"]*?evaId=(\\d*)&[^\"]*?\">([^<]*)</a>");
|
||||||
|
|
||||||
|
@ -130,6 +120,16 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
private String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
private String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||||
final String products)
|
final String products)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class BsagProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class BsagProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class BsvagProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class BsvagProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class BvbProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class BvbProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,21 @@ public final class BvgProvider extends AbstractHafasProvider
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
@Override
|
||||||
|
protected String[] splitNameAndPlace(final String name)
|
||||||
{
|
{
|
||||||
return xmlMLcReq(constraint);
|
if (name.endsWith(" (Berlin)"))
|
||||||
|
return new String[] { "Berlin", name.substring(0, name.length() - 9) };
|
||||||
|
else if (name.startsWith("Potsdam, "))
|
||||||
|
return new String[] { "Potsdam", name.substring(9) };
|
||||||
|
else if (name.startsWith("Cottbus, "))
|
||||||
|
return new String[] { "Cottbus", name.substring(9) };
|
||||||
|
else if (name.startsWith("Brandenburg, "))
|
||||||
|
return new String[] { "Brandenburg", name.substring(13) };
|
||||||
|
else if (name.startsWith("Frankfurt (Oder), "))
|
||||||
|
return new String[] { "Frankfurt (Oder)", name.substring(18) };
|
||||||
|
|
||||||
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Pattern P_NEARBY_OWN = Pattern
|
private final static Pattern P_NEARBY_OWN = Pattern
|
||||||
|
@ -165,21 +177,245 @@ public final class BvgProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static final String DEPARTURE_URL_LIVE = BASE_URL + "/IstAbfahrtzeiten/index/mobil?";
|
||||||
protected String[] splitNameAndPlace(final String name)
|
|
||||||
{
|
|
||||||
if (name.endsWith(" (Berlin)"))
|
|
||||||
return new String[] { "Berlin", name.substring(0, name.length() - 9) };
|
|
||||||
else if (name.startsWith("Potsdam, "))
|
|
||||||
return new String[] { "Potsdam", name.substring(9) };
|
|
||||||
else if (name.startsWith("Cottbus, "))
|
|
||||||
return new String[] { "Cottbus", name.substring(9) };
|
|
||||||
else if (name.startsWith("Brandenburg, "))
|
|
||||||
return new String[] { "Brandenburg", name.substring(13) };
|
|
||||||
else if (name.startsWith("Frankfurt (Oder), "))
|
|
||||||
return new String[] { "Frankfurt (Oder)", name.substring(18) };
|
|
||||||
|
|
||||||
return super.splitNameAndPlace(name);
|
private String departuresQueryLiveUri(final int stationId)
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(DEPARTURE_URL_LIVE);
|
||||||
|
uri.append("input=").append(stationId);
|
||||||
|
if (additionalQueryParameter != null)
|
||||||
|
uri.append('&').append(additionalQueryParameter);
|
||||||
|
return uri.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String DEPARTURE_URL_PLAN = API_BASE + "stboard.bin/dox/dox?boardType=dep&disableEquivs=yes&start=yes&";
|
||||||
|
|
||||||
|
private String departuresQueryPlanUri(final int stationId, final int maxDepartures)
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(DEPARTURE_URL_PLAN);
|
||||||
|
uri.append("input=").append(stationId);
|
||||||
|
uri.append("&maxJourneys=").append(maxDepartures != 0 ? maxDepartures : 50);
|
||||||
|
if (additionalQueryParameter != null)
|
||||||
|
uri.append('&').append(additionalQueryParameter);
|
||||||
|
return uri.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Pattern P_DEPARTURES_PLAN_HEAD = Pattern.compile(".*?" //
|
||||||
|
+ "<strong>(.*?)</strong>.*?Datum:\\s*([^<\n]+)[<\n].*?" //
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_PLAN_COARSE = Pattern.compile("" //
|
||||||
|
+ "<tr class=\"ivu_table_bg\\d\">\\s*((?:<td class=\"ivu_table_c_dep\">|<td>).+?)\\s*</tr>" //
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_PLAN_FINE = Pattern.compile("" //
|
||||||
|
+ "<td><strong>(\\d{1,2}:\\d{2})</strong></td>.*?" // time
|
||||||
|
+ "<strong>\\s*(.*?)[\\s\\*]*</strong>.*?" // line
|
||||||
|
+ "(?:\\((Gl\\. " + ParserUtils.P_PLATFORM + ")\\).*?)?" // position
|
||||||
|
+ "<a href=\"/Fahrinfo/bin/stboard\\.bin/dox/dox.*?evaId=(\\d+)&[^>]*>" // destinationId
|
||||||
|
+ "\\s*(.*?)\\s*</a>.*?" // destination
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_PLAN_ERRORS = Pattern.compile("(derzeit leider nicht bearbeitet werden)|(Wartungsarbeiten)|"
|
||||||
|
+ "(http-equiv=\"refresh\")", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
private static final Pattern P_DEPARTURES_LIVE_HEAD = Pattern.compile(".*?" //
|
||||||
|
+ "<strong>(.*?)</strong>.*?Datum:\\s*([^<\n]+)[<\n].*?" //
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_LIVE_COARSE = Pattern.compile("" //
|
||||||
|
+ "<tr class=\"ivu_table_bg\\d\">\\s*((?:<td class=\"ivu_table_c_dep\">|<td>).+?)\\s*</tr>" //
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_LIVE_FINE = Pattern.compile("" //
|
||||||
|
+ "<td class=\"ivu_table_c_dep\">\\s*(\\d{1,2}:\\d{2})\\s*" // time
|
||||||
|
+ "(\\*)?\\s*</td>\\s*" // planned
|
||||||
|
+ "<td class=\"ivu_table_c_line\">\\s*(.*?)\\s*</td>\\s*" // line
|
||||||
|
+ "<td>.*?<a.*?[^-]>\\s*(.*?)\\s*</a>.*?</td>" // destination
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_LIVE_MSGS_COARSE = Pattern.compile("" //
|
||||||
|
+ "<tr class=\"ivu_table_bg\\d\">\\s*(<td class=\"ivu_table_c_line\">.+?)\\s*</tr>" //
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_LIVE_MSGS_FINE = Pattern.compile("" //
|
||||||
|
+ "<td class=\"ivu_table_c_line\">\\s*(.*?)\\s*</td>\\s*" // line
|
||||||
|
+ "<td class=\"ivu_table_c_dep\">\\s*(\\d{2}\\.\\d{2}\\.\\d{4})\\s*</td>\\s*" // date
|
||||||
|
+ "<td>([^<]*)</td>" // message
|
||||||
|
, Pattern.DOTALL);
|
||||||
|
private static final Pattern P_DEPARTURES_LIVE_ERRORS = Pattern.compile("(Haltestelle:)|(Wartungsgründen)|(http-equiv=\"refresh\")",
|
||||||
|
Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final QueryDeparturesResult result = new QueryDeparturesResult();
|
||||||
|
|
||||||
|
if (stationId < 1000000) // live
|
||||||
|
{
|
||||||
|
// scrape page
|
||||||
|
final String uri = departuresQueryLiveUri(stationId);
|
||||||
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
|
|
||||||
|
final Matcher mError = P_DEPARTURES_LIVE_ERRORS.matcher(page);
|
||||||
|
if (mError.find())
|
||||||
|
{
|
||||||
|
if (mError.group(1) != null)
|
||||||
|
return new QueryDeparturesResult(Status.INVALID_STATION);
|
||||||
|
if (mError.group(2) != null)
|
||||||
|
return new QueryDeparturesResult(Status.SERVICE_DOWN);
|
||||||
|
if (mError.group(3) != null)
|
||||||
|
throw new IOException("connected to private wlan");
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse page
|
||||||
|
final Matcher mHead = P_DEPARTURES_LIVE_HEAD.matcher(page);
|
||||||
|
if (mHead.matches())
|
||||||
|
{
|
||||||
|
final String[] placeAndName = splitNameAndPlace(ParserUtils.resolveEntities(mHead.group(1)));
|
||||||
|
final Calendar currentTime = new GregorianCalendar(timeZone());
|
||||||
|
currentTime.clear();
|
||||||
|
parseDateTime(currentTime, mHead.group(2));
|
||||||
|
|
||||||
|
final Map<String, String> messages = new HashMap<String, String>();
|
||||||
|
|
||||||
|
final Matcher mMsgsCoarse = P_DEPARTURES_LIVE_MSGS_COARSE.matcher(page);
|
||||||
|
while (mMsgsCoarse.find())
|
||||||
|
{
|
||||||
|
final Matcher mMsgsFine = P_DEPARTURES_LIVE_MSGS_FINE.matcher(mMsgsCoarse.group(1));
|
||||||
|
if (mMsgsFine.matches())
|
||||||
|
{
|
||||||
|
final String line = normalizeLine(ParserUtils.resolveEntities(mMsgsFine.group(1)));
|
||||||
|
final String message = ParserUtils.resolveEntities(mMsgsFine.group(3)).replace('\n', ' ');
|
||||||
|
messages.put(line, message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("cannot parse '" + mMsgsCoarse.group(1) + "' on " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Departure> departures = new ArrayList<Departure>(8);
|
||||||
|
|
||||||
|
final Matcher mDepCoarse = P_DEPARTURES_LIVE_COARSE.matcher(page);
|
||||||
|
while (mDepCoarse.find())
|
||||||
|
{
|
||||||
|
final Matcher mDepFine = P_DEPARTURES_LIVE_FINE.matcher(mDepCoarse.group(1));
|
||||||
|
if (mDepFine.matches())
|
||||||
|
{
|
||||||
|
final Calendar parsedTime = new GregorianCalendar(timeZone());
|
||||||
|
parsedTime.setTimeInMillis(currentTime.getTimeInMillis());
|
||||||
|
ParserUtils.parseEuropeanTime(parsedTime, mDepFine.group(1));
|
||||||
|
|
||||||
|
if (parsedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
||||||
|
parsedTime.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
boolean isPlanned = mDepFine.group(2) != null;
|
||||||
|
|
||||||
|
Date plannedTime = null;
|
||||||
|
Date predictedTime = null;
|
||||||
|
if (!isPlanned)
|
||||||
|
predictedTime = parsedTime.getTime();
|
||||||
|
else
|
||||||
|
plannedTime = parsedTime.getTime();
|
||||||
|
|
||||||
|
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(3)));
|
||||||
|
|
||||||
|
final String position = null;
|
||||||
|
|
||||||
|
final int destinationId = 0;
|
||||||
|
|
||||||
|
final String destination = ParserUtils.resolveEntities(mDepFine.group(4));
|
||||||
|
|
||||||
|
final Departure dep = new Departure(plannedTime, predictedTime, line, line != null ? lineColors(line) : null, null, position,
|
||||||
|
destinationId, destination, messages.get(line));
|
||||||
|
if (!departures.contains(dep))
|
||||||
|
departures.add(dep);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(1) + "' on " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]),
|
||||||
|
departures, null));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("cannot parse '" + page + "' on " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// scrape page
|
||||||
|
final String uri = departuresQueryPlanUri(stationId, maxDepartures);
|
||||||
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
|
|
||||||
|
final Matcher mError = P_DEPARTURES_PLAN_ERRORS.matcher(page);
|
||||||
|
if (mError.find())
|
||||||
|
{
|
||||||
|
if (mError.group(1) != null)
|
||||||
|
return new QueryDeparturesResult(Status.INVALID_STATION);
|
||||||
|
if (mError.group(2) != null)
|
||||||
|
return new QueryDeparturesResult(Status.SERVICE_DOWN);
|
||||||
|
if (mError.group(3) != null)
|
||||||
|
throw new IOException("connected to private wlan");
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse page
|
||||||
|
final Matcher mHead = P_DEPARTURES_PLAN_HEAD.matcher(page);
|
||||||
|
if (mHead.matches())
|
||||||
|
{
|
||||||
|
final String[] placeAndName = splitNameAndPlace(ParserUtils.resolveEntities(mHead.group(1)));
|
||||||
|
final Calendar currentTime = new GregorianCalendar(timeZone());
|
||||||
|
currentTime.clear();
|
||||||
|
ParserUtils.parseGermanDate(currentTime, mHead.group(2));
|
||||||
|
final List<Departure> departures = new ArrayList<Departure>(8);
|
||||||
|
|
||||||
|
final Matcher mDepCoarse = P_DEPARTURES_PLAN_COARSE.matcher(page);
|
||||||
|
while (mDepCoarse.find())
|
||||||
|
{
|
||||||
|
final Matcher mDepFine = P_DEPARTURES_PLAN_FINE.matcher(mDepCoarse.group(1));
|
||||||
|
if (mDepFine.matches())
|
||||||
|
{
|
||||||
|
final Calendar parsedTime = new GregorianCalendar(timeZone());
|
||||||
|
parsedTime.setTimeInMillis(currentTime.getTimeInMillis());
|
||||||
|
ParserUtils.parseEuropeanTime(parsedTime, mDepFine.group(1));
|
||||||
|
|
||||||
|
if (parsedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
||||||
|
parsedTime.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
final Date plannedTime = parsedTime.getTime();
|
||||||
|
|
||||||
|
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(2)));
|
||||||
|
|
||||||
|
final String position = ParserUtils.resolveEntities(mDepFine.group(3));
|
||||||
|
|
||||||
|
final int destinationId = Integer.parseInt(mDepFine.group(4));
|
||||||
|
|
||||||
|
final String destination = ParserUtils.resolveEntities(mDepFine.group(5));
|
||||||
|
|
||||||
|
final Departure dep = new Departure(plannedTime, null, line, line != null ? lineColors(line) : null, null, position,
|
||||||
|
destinationId, destination, null);
|
||||||
|
if (!departures.contains(dep))
|
||||||
|
departures.add(dep);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(1) + "' on " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]),
|
||||||
|
departures, null));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("cannot parse '" + page + "' on " + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
private String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||||
|
@ -636,242 +872,6 @@ public final class BvgProvider extends AbstractHafasProvider
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String DEPARTURE_URL_LIVE = BASE_URL + "/IstAbfahrtzeiten/index/mobil?";
|
|
||||||
|
|
||||||
private String departuresQueryLiveUri(final int stationId)
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(DEPARTURE_URL_LIVE);
|
|
||||||
uri.append("input=").append(stationId);
|
|
||||||
if (additionalQueryParameter != null)
|
|
||||||
uri.append('&').append(additionalQueryParameter);
|
|
||||||
return uri.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String DEPARTURE_URL_PLAN = API_BASE + "stboard.bin/dox/dox?boardType=dep&disableEquivs=yes&start=yes&";
|
|
||||||
|
|
||||||
private String departuresQueryPlanUri(final int stationId, final int maxDepartures)
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(DEPARTURE_URL_PLAN);
|
|
||||||
uri.append("input=").append(stationId);
|
|
||||||
uri.append("&maxJourneys=").append(maxDepartures != 0 ? maxDepartures : 50);
|
|
||||||
if (additionalQueryParameter != null)
|
|
||||||
uri.append('&').append(additionalQueryParameter);
|
|
||||||
return uri.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Pattern P_DEPARTURES_PLAN_HEAD = Pattern.compile(".*?" //
|
|
||||||
+ "<strong>(.*?)</strong>.*?Datum:\\s*([^<\n]+)[<\n].*?" //
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_PLAN_COARSE = Pattern.compile("" //
|
|
||||||
+ "<tr class=\"ivu_table_bg\\d\">\\s*((?:<td class=\"ivu_table_c_dep\">|<td>).+?)\\s*</tr>" //
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_PLAN_FINE = Pattern.compile("" //
|
|
||||||
+ "<td><strong>(\\d{1,2}:\\d{2})</strong></td>.*?" // time
|
|
||||||
+ "<strong>\\s*(.*?)[\\s\\*]*</strong>.*?" // line
|
|
||||||
+ "(?:\\((Gl\\. " + ParserUtils.P_PLATFORM + ")\\).*?)?" // position
|
|
||||||
+ "<a href=\"/Fahrinfo/bin/stboard\\.bin/dox/dox.*?evaId=(\\d+)&[^>]*>" // destinationId
|
|
||||||
+ "\\s*(.*?)\\s*</a>.*?" // destination
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_PLAN_ERRORS = Pattern.compile("(derzeit leider nicht bearbeitet werden)|(Wartungsarbeiten)|"
|
|
||||||
+ "(http-equiv=\"refresh\")", Pattern.CASE_INSENSITIVE);
|
|
||||||
|
|
||||||
private static final Pattern P_DEPARTURES_LIVE_HEAD = Pattern.compile(".*?" //
|
|
||||||
+ "<strong>(.*?)</strong>.*?Datum:\\s*([^<\n]+)[<\n].*?" //
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_LIVE_COARSE = Pattern.compile("" //
|
|
||||||
+ "<tr class=\"ivu_table_bg\\d\">\\s*((?:<td class=\"ivu_table_c_dep\">|<td>).+?)\\s*</tr>" //
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_LIVE_FINE = Pattern.compile("" //
|
|
||||||
+ "<td class=\"ivu_table_c_dep\">\\s*(\\d{1,2}:\\d{2})\\s*" // time
|
|
||||||
+ "(\\*)?\\s*</td>\\s*" // planned
|
|
||||||
+ "<td class=\"ivu_table_c_line\">\\s*(.*?)\\s*</td>\\s*" // line
|
|
||||||
+ "<td>.*?<a.*?[^-]>\\s*(.*?)\\s*</a>.*?</td>" // destination
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_LIVE_MSGS_COARSE = Pattern.compile("" //
|
|
||||||
+ "<tr class=\"ivu_table_bg\\d\">\\s*(<td class=\"ivu_table_c_line\">.+?)\\s*</tr>" //
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_LIVE_MSGS_FINE = Pattern.compile("" //
|
|
||||||
+ "<td class=\"ivu_table_c_line\">\\s*(.*?)\\s*</td>\\s*" // line
|
|
||||||
+ "<td class=\"ivu_table_c_dep\">\\s*(\\d{2}\\.\\d{2}\\.\\d{4})\\s*</td>\\s*" // date
|
|
||||||
+ "<td>([^<]*)</td>" // message
|
|
||||||
, Pattern.DOTALL);
|
|
||||||
private static final Pattern P_DEPARTURES_LIVE_ERRORS = Pattern.compile("(Haltestelle:)|(Wartungsgründen)|(http-equiv=\"refresh\")",
|
|
||||||
Pattern.CASE_INSENSITIVE);
|
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final QueryDeparturesResult result = new QueryDeparturesResult();
|
|
||||||
|
|
||||||
if (stationId < 1000000) // live
|
|
||||||
{
|
|
||||||
// scrape page
|
|
||||||
final String uri = departuresQueryLiveUri(stationId);
|
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
|
||||||
|
|
||||||
final Matcher mError = P_DEPARTURES_LIVE_ERRORS.matcher(page);
|
|
||||||
if (mError.find())
|
|
||||||
{
|
|
||||||
if (mError.group(1) != null)
|
|
||||||
return new QueryDeparturesResult(Status.INVALID_STATION);
|
|
||||||
if (mError.group(2) != null)
|
|
||||||
return new QueryDeparturesResult(Status.SERVICE_DOWN);
|
|
||||||
if (mError.group(3) != null)
|
|
||||||
throw new IOException("connected to private wlan");
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse page
|
|
||||||
final Matcher mHead = P_DEPARTURES_LIVE_HEAD.matcher(page);
|
|
||||||
if (mHead.matches())
|
|
||||||
{
|
|
||||||
final String[] placeAndName = splitNameAndPlace(ParserUtils.resolveEntities(mHead.group(1)));
|
|
||||||
final Calendar currentTime = new GregorianCalendar(timeZone());
|
|
||||||
currentTime.clear();
|
|
||||||
parseDateTime(currentTime, mHead.group(2));
|
|
||||||
|
|
||||||
final Map<String, String> messages = new HashMap<String, String>();
|
|
||||||
|
|
||||||
final Matcher mMsgsCoarse = P_DEPARTURES_LIVE_MSGS_COARSE.matcher(page);
|
|
||||||
while (mMsgsCoarse.find())
|
|
||||||
{
|
|
||||||
final Matcher mMsgsFine = P_DEPARTURES_LIVE_MSGS_FINE.matcher(mMsgsCoarse.group(1));
|
|
||||||
if (mMsgsFine.matches())
|
|
||||||
{
|
|
||||||
final String line = normalizeLine(ParserUtils.resolveEntities(mMsgsFine.group(1)));
|
|
||||||
final String message = ParserUtils.resolveEntities(mMsgsFine.group(3)).replace('\n', ' ');
|
|
||||||
messages.put(line, message);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("cannot parse '" + mMsgsCoarse.group(1) + "' on " + uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Departure> departures = new ArrayList<Departure>(8);
|
|
||||||
|
|
||||||
final Matcher mDepCoarse = P_DEPARTURES_LIVE_COARSE.matcher(page);
|
|
||||||
while (mDepCoarse.find())
|
|
||||||
{
|
|
||||||
final Matcher mDepFine = P_DEPARTURES_LIVE_FINE.matcher(mDepCoarse.group(1));
|
|
||||||
if (mDepFine.matches())
|
|
||||||
{
|
|
||||||
final Calendar parsedTime = new GregorianCalendar(timeZone());
|
|
||||||
parsedTime.setTimeInMillis(currentTime.getTimeInMillis());
|
|
||||||
ParserUtils.parseEuropeanTime(parsedTime, mDepFine.group(1));
|
|
||||||
|
|
||||||
if (parsedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
|
||||||
parsedTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
|
|
||||||
boolean isPlanned = mDepFine.group(2) != null;
|
|
||||||
|
|
||||||
Date plannedTime = null;
|
|
||||||
Date predictedTime = null;
|
|
||||||
if (!isPlanned)
|
|
||||||
predictedTime = parsedTime.getTime();
|
|
||||||
else
|
|
||||||
plannedTime = parsedTime.getTime();
|
|
||||||
|
|
||||||
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(3)));
|
|
||||||
|
|
||||||
final String position = null;
|
|
||||||
|
|
||||||
final int destinationId = 0;
|
|
||||||
|
|
||||||
final String destination = ParserUtils.resolveEntities(mDepFine.group(4));
|
|
||||||
|
|
||||||
final Departure dep = new Departure(plannedTime, predictedTime, line, line != null ? lineColors(line) : null, null, position,
|
|
||||||
destinationId, destination, messages.get(line));
|
|
||||||
if (!departures.contains(dep))
|
|
||||||
departures.add(dep);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(1) + "' on " + uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]),
|
|
||||||
departures, null));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("cannot parse '" + page + "' on " + uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// scrape page
|
|
||||||
final String uri = departuresQueryPlanUri(stationId, maxDepartures);
|
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
|
||||||
|
|
||||||
final Matcher mError = P_DEPARTURES_PLAN_ERRORS.matcher(page);
|
|
||||||
if (mError.find())
|
|
||||||
{
|
|
||||||
if (mError.group(1) != null)
|
|
||||||
return new QueryDeparturesResult(Status.INVALID_STATION);
|
|
||||||
if (mError.group(2) != null)
|
|
||||||
return new QueryDeparturesResult(Status.SERVICE_DOWN);
|
|
||||||
if (mError.group(3) != null)
|
|
||||||
throw new IOException("connected to private wlan");
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse page
|
|
||||||
final Matcher mHead = P_DEPARTURES_PLAN_HEAD.matcher(page);
|
|
||||||
if (mHead.matches())
|
|
||||||
{
|
|
||||||
final String[] placeAndName = splitNameAndPlace(ParserUtils.resolveEntities(mHead.group(1)));
|
|
||||||
final Calendar currentTime = new GregorianCalendar(timeZone());
|
|
||||||
currentTime.clear();
|
|
||||||
ParserUtils.parseGermanDate(currentTime, mHead.group(2));
|
|
||||||
final List<Departure> departures = new ArrayList<Departure>(8);
|
|
||||||
|
|
||||||
final Matcher mDepCoarse = P_DEPARTURES_PLAN_COARSE.matcher(page);
|
|
||||||
while (mDepCoarse.find())
|
|
||||||
{
|
|
||||||
final Matcher mDepFine = P_DEPARTURES_PLAN_FINE.matcher(mDepCoarse.group(1));
|
|
||||||
if (mDepFine.matches())
|
|
||||||
{
|
|
||||||
final Calendar parsedTime = new GregorianCalendar(timeZone());
|
|
||||||
parsedTime.setTimeInMillis(currentTime.getTimeInMillis());
|
|
||||||
ParserUtils.parseEuropeanTime(parsedTime, mDepFine.group(1));
|
|
||||||
|
|
||||||
if (parsedTime.getTimeInMillis() - currentTime.getTimeInMillis() < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
|
||||||
parsedTime.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
|
|
||||||
final Date plannedTime = parsedTime.getTime();
|
|
||||||
|
|
||||||
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(2)));
|
|
||||||
|
|
||||||
final String position = ParserUtils.resolveEntities(mDepFine.group(3));
|
|
||||||
|
|
||||||
final int destinationId = Integer.parseInt(mDepFine.group(4));
|
|
||||||
|
|
||||||
final String destination = ParserUtils.resolveEntities(mDepFine.group(5));
|
|
||||||
|
|
||||||
final Departure dep = new Departure(plannedTime, null, line, line != null ? lineColors(line) : null, null, position,
|
|
||||||
destinationId, destination, null);
|
|
||||||
if (!departures.contains(dep))
|
|
||||||
departures.add(dep);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(1) + "' on " + uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, stationId, placeAndName[0], placeAndName[1]),
|
|
||||||
departures, null));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("cannot parse '" + page + "' on " + uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Pattern P_DATE_TIME = Pattern.compile("([^,]*), (.*?)");
|
private static final Pattern P_DATE_TIME = Pattern.compile("([^,]*), (.*?)");
|
||||||
|
|
||||||
private static final void parseDateTime(final Calendar calendar, final CharSequence str)
|
private static final void parseDateTime(final Calendar calendar, final CharSequence str)
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class DingProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class DingProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,18 +55,7 @@ public class DsbProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations)
|
|
||||||
throws IOException
|
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
|
||||||
|
@ -99,6 +88,31 @@ public class DsbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/mn");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -163,19 +177,4 @@ public class DsbProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/mn");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,6 @@ public class DubProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -73,4 +67,10 @@ public class DubProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,6 @@ public class GvhProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "XSLT_DM_REQUEST?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
|
||||||
|
@ -69,6 +63,12 @@ public class GvhProvider extends AbstractEfaProvider
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -66,12 +66,6 @@ public class InvgProvider extends AbstractHafasProvider
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlMLcReq(constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] PLACES = { "Ingolstadt", "München" };
|
private static final String[] PLACES = { "Ingolstadt", "München" };
|
||||||
|
@ -108,45 +102,6 @@ public class InvgProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Bus\\s*(\\d+)");
|
|
||||||
protected static final Pattern P_NORMALIZE_LINE_NACHTBUS = Pattern.compile("Bus\\s*N\\s*(\\d+)");
|
|
||||||
protected static final Pattern P_NORMALIZE_LINE_BUS_S = Pattern.compile("Bus\\s*S\\s*(\\d+)");
|
|
||||||
protected static final Pattern P_NORMALIZE_LINE_BUS_X = Pattern.compile("Bus\\s*X\\s*(\\d+)");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String normalizeLine(final String type, final String line)
|
|
||||||
{
|
|
||||||
if ("1".equals(type))
|
|
||||||
{
|
|
||||||
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
|
|
||||||
if (mBus.matches())
|
|
||||||
return "B" + mBus.group(1);
|
|
||||||
|
|
||||||
final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line);
|
|
||||||
if (mNachtbus.matches())
|
|
||||||
return "BN" + mNachtbus.group(1);
|
|
||||||
|
|
||||||
final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line);
|
|
||||||
if (mBusS.matches())
|
|
||||||
return "BS" + mBusS.group(1);
|
|
||||||
|
|
||||||
final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line);
|
|
||||||
if (mBusX.matches())
|
|
||||||
return "BX" + mBusX.group(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.normalizeLine(type, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected char normalizeType(final String type)
|
|
||||||
{
|
|
||||||
if ("1".equals(type))
|
|
||||||
return 'B';
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String departuresQueryUri(final int stationId, final int maxDepartures)
|
private String departuresQueryUri(final int stationId, final int maxDepartures)
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder();
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
@ -307,6 +262,50 @@ public class InvgProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static final Pattern P_NORMALIZE_LINE_BUS = Pattern.compile("Bus\\s*(\\d+)");
|
||||||
|
protected static final Pattern P_NORMALIZE_LINE_NACHTBUS = Pattern.compile("Bus\\s*N\\s*(\\d+)");
|
||||||
|
protected static final Pattern P_NORMALIZE_LINE_BUS_S = Pattern.compile("Bus\\s*S\\s*(\\d+)");
|
||||||
|
protected static final Pattern P_NORMALIZE_LINE_BUS_X = Pattern.compile("Bus\\s*X\\s*(\\d+)");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String normalizeLine(final String type, final String line)
|
||||||
|
{
|
||||||
|
if ("1".equals(type))
|
||||||
|
{
|
||||||
|
final Matcher mBus = P_NORMALIZE_LINE_BUS.matcher(line);
|
||||||
|
if (mBus.matches())
|
||||||
|
return "B" + mBus.group(1);
|
||||||
|
|
||||||
|
final Matcher mNachtbus = P_NORMALIZE_LINE_NACHTBUS.matcher(line);
|
||||||
|
if (mNachtbus.matches())
|
||||||
|
return "BN" + mNachtbus.group(1);
|
||||||
|
|
||||||
|
final Matcher mBusS = P_NORMALIZE_LINE_BUS_S.matcher(line);
|
||||||
|
if (mBusS.matches())
|
||||||
|
return "BS" + mBusS.group(1);
|
||||||
|
|
||||||
|
final Matcher mBusX = P_NORMALIZE_LINE_BUS_X.matcher(line);
|
||||||
|
if (mBusX.matches())
|
||||||
|
return "BX" + mBusX.group(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.normalizeLine(type, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected char normalizeType(final String type)
|
||||||
|
{
|
||||||
|
if ("1".equals(type))
|
||||||
|
return 'B';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class IvbProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class IvbProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class KvvProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class KvvProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class LinzProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&mode=direct&coordOutputFormat=WGS84&mergeDep=1&useAllStops=1&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&excludedMeans=checkbox";
|
+ "?outputFormat=XML&mode=direct&coordOutputFormat=WGS84&mergeDep=1&useAllStops=1&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&excludedMeans=checkbox";
|
||||||
|
@ -66,4 +60,10 @@ public class LinzProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,11 +54,6 @@ public class LuProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlMLcReq(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
if (location.type == LocationType.STATION && location.hasId())
|
if (location.type == LocationType.STATION && location.hasId())
|
||||||
|
@ -78,6 +73,26 @@ public class LuProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/dn");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,19 +128,4 @@ public class LuProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/dn");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class MariborProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class MariborProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,12 +60,6 @@ public class MetProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -76,6 +70,12 @@ public class MetProvider extends AbstractEfaProvider
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<Character, int[]> LINES = new HashMap<Character, int[]>();
|
private static final Map<Character, int[]> LINES = new HashMap<Character, int[]>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class MvgProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
||||||
|
@ -65,4 +59,10 @@ public class MvgProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,6 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -70,6 +64,12 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class NaldoProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class NaldoProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,6 @@ public class NasaProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlMLcReq(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -242,6 +237,11 @@ public class NasaProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected char normalizeType(String type)
|
protected char normalizeType(String type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,16 +48,6 @@ public interface NetworkProvider
|
||||||
|
|
||||||
boolean hasCapabilities(Capability... capabilities);
|
boolean hasCapabilities(Capability... capabilities);
|
||||||
|
|
||||||
/**
|
|
||||||
* Meant for auto-completion of station names, like in an {@link android.widget.AutoCompleteTextView}
|
|
||||||
*
|
|
||||||
* @param constraint
|
|
||||||
* input by user so far
|
|
||||||
* @return auto-complete suggestions
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
List<Location> autocompleteStations(CharSequence constraint) throws IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine stations near to given location. At least one of stationId or lat/lon pair must be present.
|
* Determine stations near to given location. At least one of stationId or lat/lon pair must be present.
|
||||||
*
|
*
|
||||||
|
@ -72,6 +62,30 @@ public interface NetworkProvider
|
||||||
*/
|
*/
|
||||||
NearbyStationsResult queryNearbyStations(Location location, int maxDistance, int maxStations) throws IOException;
|
NearbyStationsResult queryNearbyStations(Location location, int maxDistance, int maxStations) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get departures at a given station, probably live
|
||||||
|
*
|
||||||
|
* @param stationId
|
||||||
|
* id of the station
|
||||||
|
* @param maxDepartures
|
||||||
|
* maximum number of departures to get or {@code 0}
|
||||||
|
* @param equivs
|
||||||
|
* also query equivalent stations?
|
||||||
|
* @return result object containing the departures
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
QueryDeparturesResult queryDepartures(int stationId, int maxDepartures, boolean equivs) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meant for auto-completion of station names, like in an {@link android.widget.AutoCompleteTextView}
|
||||||
|
*
|
||||||
|
* @param constraint
|
||||||
|
* input by user so far
|
||||||
|
* @return auto-complete suggestions
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
List<Location> autocompleteStations(CharSequence constraint) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query connections, asking for any ambiguousnesses
|
* Query connections, asking for any ambiguousnesses
|
||||||
*
|
*
|
||||||
|
@ -117,20 +131,6 @@ public interface NetworkProvider
|
||||||
*/
|
*/
|
||||||
GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException;
|
GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get departures at a given station, probably live
|
|
||||||
*
|
|
||||||
* @param stationId
|
|
||||||
* id of the station
|
|
||||||
* @param maxDepartures
|
|
||||||
* maximum number of departures to get or {@code 0}
|
|
||||||
* @param equivs
|
|
||||||
* also query equivalent stations?
|
|
||||||
* @return result object containing the departures
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
QueryDeparturesResult queryDepartures(int stationId, int maxDepartures, boolean equivs) throws IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get colors of line
|
* Get colors of line
|
||||||
*
|
*
|
||||||
|
|
|
@ -65,17 +65,6 @@ public class NriProvider extends AbstractHafasProvider
|
||||||
return super.splitNameAndPlace(name);
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/ony?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsS0B=5&REQ0JourneyStopsB=12&getstop=1&noSession=yes&REQ0JourneyStopsS0G=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -109,6 +98,32 @@ public class NriProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/on");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/ony?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsS0B=5&REQ0JourneyStopsB=12&getstop=1&noSession=yes&REQ0JourneyStopsS0G=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected char normalizeType(final String type)
|
protected char normalizeType(final String type)
|
||||||
{
|
{
|
||||||
|
@ -144,19 +159,4 @@ public class NriProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/on");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,6 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
if (location.type == LocationType.STATION && location.hasId())
|
if (location.type == LocationType.STATION && location.hasId())
|
||||||
|
@ -194,6 +189,11 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected char normalizeType(final String type)
|
protected char normalizeType(final String type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class NvbwProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class NvbwProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,16 +76,6 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), URL_ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -116,6 +106,100 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String departuresQueryUri(final int stationId, final int maxDepartures)
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
|
||||||
|
uri.append(API_BASE);
|
||||||
|
uri.append("stboard.exe/dn?L=vs_scotty.vs_stb");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&additionalTime=0");
|
||||||
|
uri.append("&maxJourneys=").append(maxDepartures != 0 ? maxDepartures : 20);
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&monitor=1");
|
||||||
|
uri.append("&requestType=0");
|
||||||
|
uri.append("&view=preview");
|
||||||
|
uri.append("&disableEquivs=yes"); // don't use nearby stations
|
||||||
|
|
||||||
|
return uri.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Pattern P_DEPARTURES_ERROR = Pattern.compile("(Verbindung zum Server konnte leider nicht hergestellt werden)");
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final QueryDeparturesResult result = new QueryDeparturesResult();
|
||||||
|
|
||||||
|
// scrape page
|
||||||
|
final String uri = departuresQueryUri(stationId, maxDepartures);
|
||||||
|
final String page = ParserUtils.scrape(uri).toString().substring(14);
|
||||||
|
|
||||||
|
// parse page
|
||||||
|
final Matcher mError = P_DEPARTURES_ERROR.matcher(page);
|
||||||
|
if (mError.find())
|
||||||
|
{
|
||||||
|
if (mError.group(1) != null)
|
||||||
|
return new QueryDeparturesResult(Status.SERVICE_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final JSONObject head = new JSONObject(page);
|
||||||
|
final String location = ParserUtils.resolveEntities(head.getString("stationName"));
|
||||||
|
final int locationId = head.optInt("stationEvaId", -1);
|
||||||
|
// final boolean rt = head.optBoolean("rtInfo");
|
||||||
|
if (locationId == -1)
|
||||||
|
return new QueryDeparturesResult(Status.INVALID_STATION);
|
||||||
|
|
||||||
|
final List<Departure> departures = new ArrayList<Departure>(8);
|
||||||
|
|
||||||
|
final JSONArray aDeparture = head.optJSONArray("journey");
|
||||||
|
if (aDeparture != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < aDeparture.length(); i++)
|
||||||
|
{
|
||||||
|
final JSONObject departure = aDeparture.optJSONObject(i);
|
||||||
|
if (departure != null)
|
||||||
|
{
|
||||||
|
final Calendar parsedTime = new GregorianCalendar(timeZone());
|
||||||
|
parsedTime.clear();
|
||||||
|
ParserUtils.parseGermanDate(parsedTime, departure.getString("da"));
|
||||||
|
ParserUtils.parseEuropeanTime(parsedTime, departure.getString("ti"));
|
||||||
|
final String line = normalizeLine(ParserUtils.resolveEntities(departure.getString("pr")));
|
||||||
|
final String destination = ParserUtils.resolveEntities(departure.getString("st"));
|
||||||
|
String position = departure.optString("tr");
|
||||||
|
if (position != null)
|
||||||
|
position = "Gl. " + position;
|
||||||
|
final boolean rt = head.optBoolean("rt", false);
|
||||||
|
final String lineLink = departure.optString("tinfoline");
|
||||||
|
|
||||||
|
departures.add(new Departure(!rt ? parsedTime.getTime() : null, rt ? parsedTime.getTime() : null, line,
|
||||||
|
line != null ? lineColors(line) : null, lineLink, position, 0, destination, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, locationId, null, location), departures, null));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (final JSONException x)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("cannot parse: '" + page + "' on " + stationId, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), URL_ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
|
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
|
@ -481,90 +565,6 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String departuresQueryUri(final int stationId, final int maxDepartures)
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
|
|
||||||
uri.append(API_BASE);
|
|
||||||
uri.append("stboard.exe/dn?L=vs_scotty.vs_stb");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&additionalTime=0");
|
|
||||||
uri.append("&maxJourneys=").append(maxDepartures != 0 ? maxDepartures : 20);
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&monitor=1");
|
|
||||||
uri.append("&requestType=0");
|
|
||||||
uri.append("&view=preview");
|
|
||||||
uri.append("&disableEquivs=yes"); // don't use nearby stations
|
|
||||||
|
|
||||||
return uri.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Pattern P_DEPARTURES_ERROR = Pattern.compile("(Verbindung zum Server konnte leider nicht hergestellt werden)");
|
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final QueryDeparturesResult result = new QueryDeparturesResult();
|
|
||||||
|
|
||||||
// scrape page
|
|
||||||
final String uri = departuresQueryUri(stationId, maxDepartures);
|
|
||||||
final String page = ParserUtils.scrape(uri).toString().substring(14);
|
|
||||||
|
|
||||||
// parse page
|
|
||||||
final Matcher mError = P_DEPARTURES_ERROR.matcher(page);
|
|
||||||
if (mError.find())
|
|
||||||
{
|
|
||||||
if (mError.group(1) != null)
|
|
||||||
return new QueryDeparturesResult(Status.SERVICE_DOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final JSONObject head = new JSONObject(page);
|
|
||||||
final String location = ParserUtils.resolveEntities(head.getString("stationName"));
|
|
||||||
final int locationId = head.optInt("stationEvaId", -1);
|
|
||||||
// final boolean rt = head.optBoolean("rtInfo");
|
|
||||||
if (locationId == -1)
|
|
||||||
return new QueryDeparturesResult(Status.INVALID_STATION);
|
|
||||||
|
|
||||||
final List<Departure> departures = new ArrayList<Departure>(8);
|
|
||||||
|
|
||||||
final JSONArray aDeparture = head.optJSONArray("journey");
|
|
||||||
if (aDeparture != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < aDeparture.length(); i++)
|
|
||||||
{
|
|
||||||
final JSONObject departure = aDeparture.optJSONObject(i);
|
|
||||||
if (departure != null)
|
|
||||||
{
|
|
||||||
final Calendar parsedTime = new GregorianCalendar(timeZone());
|
|
||||||
parsedTime.clear();
|
|
||||||
ParserUtils.parseGermanDate(parsedTime, departure.getString("da"));
|
|
||||||
ParserUtils.parseEuropeanTime(parsedTime, departure.getString("ti"));
|
|
||||||
final String line = normalizeLine(ParserUtils.resolveEntities(departure.getString("pr")));
|
|
||||||
final String destination = ParserUtils.resolveEntities(departure.getString("st"));
|
|
||||||
String position = departure.optString("tr");
|
|
||||||
if (position != null)
|
|
||||||
position = "Gl. " + position;
|
|
||||||
final boolean rt = head.optBoolean("rt", false);
|
|
||||||
final String lineLink = departure.optString("tinfoline");
|
|
||||||
|
|
||||||
departures.add(new Departure(!rt ? parsedTime.getTime() : null, rt ? parsedTime.getTime() : null, line,
|
|
||||||
line != null ? lineColors(line) : null, lineLink, position, 0, destination, null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result.stationDepartures.add(new StationDepartures(new Location(LocationType.STATION, locationId, null, location), departures, null));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (final JSONException x)
|
|
||||||
{
|
|
||||||
throw new RuntimeException("cannot parse: '" + page + "' on " + stationId, x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}");
|
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}");
|
||||||
private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("\\d{1,3}[A-Z]{2}");
|
private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("\\d{1,3}[A-Z]{2}");
|
||||||
private static final Pattern P_NORMALIZE_LINE_RUSSIA_INT = Pattern.compile("\\d{3}Y");
|
private static final Pattern P_NORMALIZE_LINE_RUSSIA_INT = Pattern.compile("\\d{3}Y");
|
||||||
|
|
|
@ -70,11 +70,6 @@ public class PlProvider extends AbstractHafasProvider
|
||||||
return super.splitNameAndPlace(name);
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlMLcReq(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
if (location.type == LocationType.STATION && location.hasId())
|
if (location.type == LocationType.STATION && location.hasId())
|
||||||
|
@ -97,6 +92,26 @@ public class PlProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/pn");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("(?:D\\s*)?(\\d{1,3}(?:[A-Z]{2}|Y))");
|
private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("(?:D\\s*)?(\\d{1,3}(?:[A-Z]{2}|Y))");
|
||||||
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}");
|
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}");
|
||||||
|
|
||||||
|
@ -179,19 +194,4 @@ public class PlProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/pn");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,16 +77,6 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
return super.splitNameAndPlace(name);
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -257,6 +247,16 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalizeLine(final String line)
|
protected String normalizeLine(final String line)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,16 +57,6 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -115,6 +105,16 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -96,17 +96,6 @@ public class SeProvider extends AbstractHafasProvider
|
||||||
return super.splitNameAndPlace(name);
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/sny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=7&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=&S=%s";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -139,12 +128,6 @@ public class SeProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected char normalizeType(final String type)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder();
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
@ -159,4 +142,21 @@ public class SeProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/sny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=7&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=&S=%s";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected char normalizeType(final String type)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,62 +71,6 @@ public class SeptaProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected char normalizeType(final String type)
|
|
||||||
{
|
|
||||||
final String ucType = type.toUpperCase();
|
|
||||||
|
|
||||||
// skip parsing of "common" lines, because this is America
|
|
||||||
|
|
||||||
// Regional
|
|
||||||
if (ucType.equals("RAI"))
|
|
||||||
return 'R';
|
|
||||||
|
|
||||||
// Subway
|
|
||||||
if (ucType.equals("BSS"))
|
|
||||||
return 'U';
|
|
||||||
if (ucType.equals("BSL"))
|
|
||||||
return 'U';
|
|
||||||
if (ucType.equals("MFL"))
|
|
||||||
return 'U';
|
|
||||||
|
|
||||||
// Tram
|
|
||||||
if (ucType.equals("TRM"))
|
|
||||||
return 'T';
|
|
||||||
if (ucType.equals("NHS")) // Tro NHSL
|
|
||||||
return 'T';
|
|
||||||
|
|
||||||
// Bus
|
|
||||||
if (ucType.equals("BUS"))
|
|
||||||
return 'B';
|
|
||||||
if (ucType.equals("TRO"))
|
|
||||||
return 'B';
|
|
||||||
|
|
||||||
// from Connections:
|
|
||||||
|
|
||||||
if (ucType.equals("RAIL"))
|
|
||||||
return 'R';
|
|
||||||
|
|
||||||
if (ucType.equals("SUBWAY"))
|
|
||||||
return 'U';
|
|
||||||
|
|
||||||
if (ucType.equals("TROLLEY"))
|
|
||||||
return 'B';
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -295,4 +239,60 @@ public class SeptaProvider extends AbstractHafasProvider
|
||||||
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
|
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected char normalizeType(final String type)
|
||||||
|
{
|
||||||
|
final String ucType = type.toUpperCase();
|
||||||
|
|
||||||
|
// skip parsing of "common" lines, because this is America
|
||||||
|
|
||||||
|
// Regional
|
||||||
|
if (ucType.equals("RAI"))
|
||||||
|
return 'R';
|
||||||
|
|
||||||
|
// Subway
|
||||||
|
if (ucType.equals("BSS"))
|
||||||
|
return 'U';
|
||||||
|
if (ucType.equals("BSL"))
|
||||||
|
return 'U';
|
||||||
|
if (ucType.equals("MFL"))
|
||||||
|
return 'U';
|
||||||
|
|
||||||
|
// Tram
|
||||||
|
if (ucType.equals("TRM"))
|
||||||
|
return 'T';
|
||||||
|
if (ucType.equals("NHS")) // Tro NHSL
|
||||||
|
return 'T';
|
||||||
|
|
||||||
|
// Bus
|
||||||
|
if (ucType.equals("BUS"))
|
||||||
|
return 'B';
|
||||||
|
if (ucType.equals("TRO"))
|
||||||
|
return 'B';
|
||||||
|
|
||||||
|
// from Connections:
|
||||||
|
|
||||||
|
if (ucType.equals("RAIL"))
|
||||||
|
return 'R';
|
||||||
|
|
||||||
|
if (ucType.equals("SUBWAY"))
|
||||||
|
return 'U';
|
||||||
|
|
||||||
|
if (ucType.equals("TROLLEY"))
|
||||||
|
return 'B';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,22 @@ public class SfProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
|
+ "XSLT_DM_REQUEST"
|
||||||
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String nearbyStationUri(final int stationId)
|
||||||
|
{
|
||||||
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalizeLocationName(final String name)
|
protected String normalizeLocationName(final String name)
|
||||||
{
|
{
|
||||||
|
@ -80,20 +96,4 @@ public class SfProvider extends AbstractEfaProvider
|
||||||
else
|
else
|
||||||
return super.parseLine(mot, name, longName, noTrainName);
|
return super.parseLine(mot, name, longName, noTrainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
|
||||||
+ "XSLT_DM_REQUEST"
|
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String nearbyStationUri(final int stationId)
|
|
||||||
{
|
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,6 @@ public class ShProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlMLcReq(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -87,23 +82,6 @@ public class ShProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected char normalizeType(final String type)
|
|
||||||
{
|
|
||||||
final String ucType = type.toUpperCase();
|
|
||||||
|
|
||||||
if ("KBS".equals(ucType))
|
|
||||||
return 'B';
|
|
||||||
if ("KB1".equals(ucType))
|
|
||||||
return 'B';
|
|
||||||
|
|
||||||
final char t = super.normalizeType(type);
|
|
||||||
if (t != 0)
|
|
||||||
return t;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String departuresQueryUri(final int stationId, final int maxDepartures)
|
private String departuresQueryUri(final int stationId, final int maxDepartures)
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder();
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
@ -257,4 +235,26 @@ public class ShProvider extends AbstractHafasProvider
|
||||||
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
|
throw new IllegalArgumentException("cannot parse '" + page + "' on " + stationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected char normalizeType(final String type)
|
||||||
|
{
|
||||||
|
final String ucType = type.toUpperCase();
|
||||||
|
|
||||||
|
if ("KBS".equals(ucType))
|
||||||
|
return 'B';
|
||||||
|
if ("KB1".equals(ucType))
|
||||||
|
return 'B';
|
||||||
|
|
||||||
|
final char t = super.normalizeType(type);
|
||||||
|
if (t != 0)
|
||||||
|
return t;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,17 +65,6 @@ public class SncbProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -201,6 +190,17 @@ public class SncbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected char normalizeType(final String type)
|
protected char normalizeType(final String type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class StvProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class StvProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class SvvProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class SvvProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,12 +61,6 @@ public class TflProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "XSLT_DM_REQUEST?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
|
||||||
|
@ -76,6 +70,12 @@ public class TflProvider extends AbstractEfaProvider
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -58,12 +58,6 @@ public class TleaProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -73,4 +67,10 @@ public class TleaProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,6 @@ public class TlemProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -73,4 +67,10 @@ public class TlemProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,6 @@ public class TlseProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -73,4 +67,10 @@ public class TlseProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,12 +57,6 @@ public class TlswProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&name_dm=90000591&type_dm=stop&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&name_dm=90000591&type_dm=stop&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -72,4 +66,10 @@ public class TlswProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class VagfrProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class VagfrProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,16 +75,6 @@ public class VbbProvider extends AbstractHafasProvider
|
||||||
return super.splitNameAndPlace(name);
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -118,6 +108,31 @@ public class VbbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/dn");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -138,19 +153,4 @@ public class VbbProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
throw new IllegalStateException("cannot normalize line " + line);
|
throw new IllegalStateException("cannot normalize line " + line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/dn");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class VblProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class VblProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,17 +53,6 @@ public class VbnProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsS0B=5&REQ0JourneyStopsB=12&getstop=1&noSession=yes&REQ0JourneyStopsS0G=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -97,6 +86,32 @@ public class VbnProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/dn");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsS0B=5&REQ0JourneyStopsB=12&getstop=1&noSession=yes&REQ0JourneyStopsS0G=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected char normalizeType(final String type)
|
protected char normalizeType(final String type)
|
||||||
{
|
{
|
||||||
|
@ -124,19 +139,4 @@ public class VbnProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/dn");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,17 +64,6 @@ public class VgsProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/eny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=1&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=%s?&js=true&";
|
|
||||||
private static final String ENCODING = "ISO-8859-1";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -259,6 +248,17 @@ public class VgsProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||||
|
+ "ajax-getstop.exe/eny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=1&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=%s?&js=true&";
|
||||||
|
private static final String ENCODING = "ISO-8859-1";
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
|
|
||||||
|
return jsonGetStops(uri);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected char normalizeType(final String type)
|
protected char normalizeType(final String type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ import de.schildbach.pte.dto.LocationType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verkehrsverbund Vorarlberg
|
* Verkehrsverbund Vorarlberg
|
||||||
|
*
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
*/
|
*/
|
||||||
public class VmobilProvider extends AbstractEfaProvider
|
public class VmobilProvider extends AbstractEfaProvider
|
||||||
|
@ -51,12 +52,6 @@ public class VmobilProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +61,10 @@ public class VmobilProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class VmsProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
||||||
|
@ -66,4 +60,10 @@ public class VmsProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class VmvProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
||||||
|
@ -66,4 +60,10 @@ public class VmvProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class VorProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class VorProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class VrnProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
||||||
|
@ -66,4 +60,10 @@ public class VrnProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,6 @@ public class VrrProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
||||||
|
@ -70,6 +64,12 @@ public class VrrProvider extends AbstractEfaProvider
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
private static final Map<String, int[]> LINES = new HashMap<String, int[]>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class VrtProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class VrtProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class VvmProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -65,4 +59,10 @@ public class VvmProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class VvoProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
|
||||||
|
@ -66,4 +60,10 @@ public class VvoProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.STATION, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ public class VvsProvider extends AbstractEfaProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String NEARBY_STATION_URI = API_BASE
|
private static final String NEARBY_STATION_URI = API_BASE
|
||||||
+ "XSLT_DM_REQUEST"
|
+ "XSLT_DM_REQUEST"
|
||||||
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
|
||||||
|
@ -66,4 +60,10 @@ public class VvsProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
return String.format(NEARBY_STATION_URI, stationId);
|
return String.format(NEARBY_STATION_URI, stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,11 +68,6 @@ public class ZvvProvider extends AbstractHafasProvider
|
||||||
return super.splitNameAndPlace(name);
|
return super.splitNameAndPlace(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
|
||||||
{
|
|
||||||
return xmlMLcReq(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||||
{
|
{
|
||||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
@ -106,6 +101,26 @@ public class ZvvProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
uri.append(API_BASE).append("stboard.exe/dn");
|
||||||
|
uri.append("?productsFilter=").append(allProductsString());
|
||||||
|
uri.append("&boardType=dep");
|
||||||
|
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
||||||
|
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||||
|
uri.append("&start=yes");
|
||||||
|
uri.append("&L=vs_java3");
|
||||||
|
uri.append("&input=").append(stationId);
|
||||||
|
|
||||||
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
|
{
|
||||||
|
return xmlMLcReq(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
private static final Pattern P_NORMALIZE_LINE_AND_TYPE = Pattern.compile("([^#]*)#(.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -165,19 +180,4 @@ public class ZvvProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
final StringBuilder uri = new StringBuilder();
|
|
||||||
uri.append(API_BASE).append("stboard.exe/dn");
|
|
||||||
uri.append("?productsFilter=").append(allProductsString());
|
|
||||||
uri.append("&boardType=dep");
|
|
||||||
uri.append("&disableEquivs=").append(equivs ? "no" : "yes"); // don't use nearby stations
|
|
||||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
|
||||||
uri.append("&start=yes");
|
|
||||||
uri.append("&L=vs_java3");
|
|
||||||
uri.append("&input=").append(stationId);
|
|
||||||
|
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue