mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 15:29:49 +00:00
show position in departures
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@118 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
ce9a890986
commit
bb64514145
9 changed files with 98 additions and 41 deletions
|
@ -309,7 +309,8 @@ public final class BahnProvider implements NetworkProvider
|
|||
+ "(\\d+) Min\\..*?" // footway
|
||||
+ "<span class=\"bold\">\\s*(.+?)\\s*</span><br />" // arrival
|
||||
+ "|" //
|
||||
+ "Übergang.*?" + "<span class=\"bold\">\\s*(.+?)\\s*</span><br />" // arrival
|
||||
+ "Übergang.*?" //
|
||||
+ "<span class=\"bold\">\\s*(.+?)\\s*</span><br />" // arrival
|
||||
+ ")", Pattern.DOTALL);
|
||||
private static final Pattern P_CONNECTION_DETAILS_MESSAGES = Pattern
|
||||
.compile("Dauer: \\d+:\\d+|(Anschlusszug nicht mehr rechtzeitig)|(Anschlusszug jedoch erreicht werden)|(nur teilweise dargestellt)|(Längerer Aufenthalt)|(äquivalentem Bahnhof)|(Bahnhof wird mehrfach durchfahren)");
|
||||
|
@ -437,14 +438,16 @@ public final class BahnProvider implements NetworkProvider
|
|||
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(
|
||||
".*?<title>Deutsche Bahn - Abfahrt</title>.*?<body >(.*?Abfahrt.*?)</body>.*?", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(".*?" //
|
||||
+ "<div class=\"haupt rline\">\n?<span class=\"bold\">\\n?(.+?)\\s*(?:- Aktuell)?\\n</span>.*?" // location
|
||||
+ "<div class=\"haupt rline\">\n<span class=\"bold\">\n(.+?)\\s*(?:- Aktuell)?\\n</span>.*?" // location
|
||||
+ "Abfahrt (\\d+:\\d+)\\n?Uhr, (\\d+\\.\\d+\\.\\d+).*?" // currentTime
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<div class=\"sqdetailsDep trow\">(.+?)</div>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<div class=\"sqdetailsDep trow\">\n(.+?)</div>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
|
||||
+ "<span class=\"bold\">(.*?)</span>.*?" // line
|
||||
+ ">>\\n?\\s*(.+?)\\s*\\n?<br />\\n?" // destination
|
||||
+ "<span class=\"bold\">(\\d+:\\d+)</span>.*?" // time
|
||||
+ ">>\n\\s*(.+?)\\s*\n<br />\n" // destination
|
||||
+ "<span class=\"bold\">(\\d{1,2}:\\d{2})</span>" // time
|
||||
+ "(?: <span class=\"red\">ca. ([+-]?\\d+)</span>)?" // delay
|
||||
+ "(?:, (Gl\\. " + ParserUtils.P_PLATFORM + "))?" // position
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_URI_STATION_ID = Pattern.compile("input=(\\d+)");
|
||||
|
||||
|
@ -492,7 +495,14 @@ public final class BahnProvider implements NetworkProvider
|
|||
if (ParserUtils.timeDiff(parsed.getTime(), currentTime) < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
||||
parsed.add(Calendar.DAY_OF_MONTH, 1);
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, 0, destination);
|
||||
// delay
|
||||
final int delay = mDepFine.group(4) != null ? Integer.parseInt(mDepFine.group(4)) : 0;
|
||||
|
||||
// position
|
||||
final String position = ParserUtils.resolveEntities(mDepFine.group(5));
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, position, 0,
|
||||
destination);
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
}
|
||||
|
|
|
@ -27,14 +27,17 @@ public final class Departure
|
|||
final public Date time;
|
||||
final public String line;
|
||||
final public int[] lineColors;
|
||||
final public String position;
|
||||
final public int destinationId;
|
||||
final public String destination;
|
||||
|
||||
public Departure(final Date time, final String line, final int[] lineColors, final int destinationId, final String destination)
|
||||
public Departure(final Date time, final String line, final int[] lineColors, final String position, final int destinationId,
|
||||
final String destination)
|
||||
{
|
||||
this.time = time;
|
||||
this.line = line;
|
||||
this.lineColors = lineColors;
|
||||
this.position = position;
|
||||
this.destinationId = destinationId;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
@ -47,6 +50,8 @@ public final class Departure
|
|||
builder.append(",");
|
||||
builder.append(line != null ? line : "null");
|
||||
builder.append(",");
|
||||
builder.append(position != null ? position : "null");
|
||||
builder.append(",");
|
||||
builder.append(destinationId);
|
||||
builder.append(",");
|
||||
builder.append(destination != null ? destination : "null");
|
||||
|
|
|
@ -278,8 +278,9 @@ public class MvvProvider implements NetworkProvider
|
|||
+ "(?:<font color=\"red\">(\\d+)\\.(\\d+)\\. </font>.*?)?" // date
|
||||
+ "<a href=\"(XSLT_TRIP_REQUEST2.*?itdLPxx_view=detail_\\d+)\">" // url
|
||||
+ "(?:" //
|
||||
+ "(\\d+:\\d+)[\\xa0\\s]+-[\\xa0\\s]+(\\d+:\\d+)" // departureTime, arrivalTime
|
||||
+ "|" + "Fußweg.*?Dauer:[\\xa0\\s]+(\\d+):(\\d+)" //
|
||||
+ "(\\d{1,2}:\\d{2})[\\xa0\\s]+-[\\xa0\\s]+(\\d{1,2}:\\d{2})" // departureTime, arrivalTime
|
||||
+ "|" //
|
||||
+ "Fußweg.*?Dauer:[\\xa0\\s]+(\\d{1,2}):(\\d{2})" // min
|
||||
+ ").*?", Pattern.DOTALL);
|
||||
|
||||
private QueryConnectionsResult queryConnections(final String uri, final CharSequence page) throws IOException
|
||||
|
@ -503,7 +504,7 @@ public class MvvProvider implements NetworkProvider
|
|||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr valign=\"top\" bgcolor=\"#\\w{6}\">(.+?)</tr>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
|
||||
+ "(?:[\\xa0\\s]*<font color=\"red\">[\\xa0\\s]*(\\d+)\\.(\\d+)\\.[\\xa0\\s]*</font>)?" // date
|
||||
+ "(\\d+):(\\d+)</td>.*?" // time
|
||||
+ "(\\d{1,2}):(\\d{2})</td>.*?" // time
|
||||
+ "(?:<img src=\"images/means.*?\" alt=\"(.*?)\" />.*?)?" // product
|
||||
+ "<td width=\"100\">\\s*([^<]*?)[\\xa0\\s]*(?:<a .*?</a>.*?)?" // line
|
||||
+ "<br />\\s*(.*?)\\s*<br />.*?" // destination
|
||||
|
@ -546,9 +547,16 @@ public class MvvProvider implements NetworkProvider
|
|||
calendar.set(Calendar.MONTH, Integer.parseInt(month) - 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(mDepFine.group(3)));
|
||||
calendar.set(Calendar.MINUTE, Integer.parseInt(mDepFine.group(4)));
|
||||
|
||||
final String normalizedLine = normalizeLine(mDepFine.group(5), mDepFine.group(6));
|
||||
|
||||
final String destination = normalizeStationName(mDepFine.group(7));
|
||||
final Departure departure = new Departure(calendar.getTime(), normalizedLine, LINES.get(normalizedLine), 0, destination);
|
||||
|
||||
final String position = null; // TODO
|
||||
|
||||
final Departure departure = new Departure(calendar.getTime(), normalizedLine, LINES.get(normalizedLine), position, 0,
|
||||
destination);
|
||||
|
||||
departures.add(departure);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -395,12 +395,13 @@ public class OebbProvider implements NetworkProvider
|
|||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"depboard-\\w*\">(.*?)</tr>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
|
||||
+ "<td class=\"[\\w ]*\">(\\d+:\\d+)</td>.*?" // time
|
||||
+ "<td class=\"[\\w ]*\">(\\d{1,2}:\\d{2})</td>.*?" // time
|
||||
+ "<img src=\"/img/vs_oebb/(\\w+)_pic\\.gif\"\\s+alt=\".*?\">\\s*(.*?)\\s*</.*?" // type, line
|
||||
+ "<span class=\"bold\">\n" //
|
||||
+ "<a href=\"http://fahrplan\\.oebb\\.at/bin/stboard\\.exe/dn\\?ld=web25&input=[^%]*?(?:%23(\\d+))?&.*?\">" // destinationId
|
||||
+ "\\s*(.*?)\\s*</a>\n" // destination
|
||||
+ "</span>.*?" //
|
||||
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
|
||||
, Pattern.DOTALL);
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String uri) throws IOException
|
||||
|
@ -453,8 +454,10 @@ public class OebbProvider implements NetworkProvider
|
|||
|
||||
final String destination = ParserUtils.resolveEntities(mDepFine.group(5));
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, destinationId,
|
||||
destination);
|
||||
final String position = mDepFine.group(6) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(6)) : null;
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, position,
|
||||
destinationId, destination);
|
||||
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
|
|
|
@ -245,4 +245,6 @@ public final class ParserUtils
|
|||
{
|
||||
return link.substring(link.length() - 10);
|
||||
}
|
||||
|
||||
public static final String P_PLATFORM = "[\\wÄÖÜäöüßáàâéèêíìîóòôúùû\\. -/&#;]+";
|
||||
}
|
||||
|
|
|
@ -438,14 +438,18 @@ public class RmvProvider implements NetworkProvider
|
|||
+ "Abfahrt (\\d+:\\d+).*?" //
|
||||
+ "Uhr, (\\d+\\.\\d+\\.\\d+).*?" //
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<p class=\"sq\">(.+?)</p>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?<b>\\s*(.*?)\\s*</b>.*?" // line
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<p class=\"sq\">\n(.+?)</p>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
|
||||
+ "<b>\\s*(.*?)\\s*</b>.*?" // line
|
||||
+ ">>\n" //
|
||||
+ "(.*?)\n?" // destination
|
||||
+ "<br />.*?" //
|
||||
+ "<b>(\\d{1,2}:\\d{2})</b>.*?" // planTime
|
||||
+ "(?:<span class=\"red\">ca\\. (\\d{1,2}:\\d{2})</span>.*?)?" // liveTime
|
||||
+ "(?:Gl\\. (\\d+)<br />.*?)?", Pattern.DOTALL);
|
||||
+ "(.*?)\n" // destination
|
||||
+ "<br />\n" //
|
||||
+ "<b>(\\d{1,2}:\\d{2})</b>\n" // plannedTime
|
||||
+ "(?:<span class=\"red\">ca\\. (\\d{1,2}:\\d{2})</span>\n)?" // predictedTime
|
||||
+ "(?:<span class=\"red\">heute Gl\\. " + ParserUtils.P_PLATFORM + "</span><br />\n)?" // predictedPosition
|
||||
+ "(?:(Gl\\. " + ParserUtils.P_PLATFORM + ")<br />\n)?" // position
|
||||
+ "(?:<img src=\".+?\" alt=\"\" />\n<b>.+?</b>\n<br />\n)*" // (messages)
|
||||
, Pattern.DOTALL);
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String uri) throws IOException
|
||||
{
|
||||
|
@ -488,16 +492,16 @@ public class RmvProvider implements NetworkProvider
|
|||
current.setTime(currentTime);
|
||||
final Calendar parsed = new GregorianCalendar();
|
||||
|
||||
// planTime
|
||||
// plannedTime
|
||||
parsed.setTime(ParserUtils.parseTime(mDepFine.group(3)));
|
||||
parsed.set(Calendar.YEAR, current.get(Calendar.YEAR));
|
||||
parsed.set(Calendar.MONTH, current.get(Calendar.MONTH));
|
||||
parsed.set(Calendar.DAY_OF_MONTH, current.get(Calendar.DAY_OF_MONTH));
|
||||
if (ParserUtils.timeDiff(parsed.getTime(), currentTime) < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
||||
parsed.add(Calendar.DAY_OF_MONTH, 1);
|
||||
final Date planTime = parsed.getTime();
|
||||
final Date plannedTime = parsed.getTime();
|
||||
|
||||
// liveTime
|
||||
// predictedTime
|
||||
if (mDepFine.group(4) != null)
|
||||
{
|
||||
parsed.setTime(ParserUtils.parseTime(mDepFine.group(4)));
|
||||
|
@ -506,10 +510,14 @@ public class RmvProvider implements NetworkProvider
|
|||
parsed.set(Calendar.DAY_OF_MONTH, current.get(Calendar.DAY_OF_MONTH));
|
||||
if (ParserUtils.timeDiff(parsed.getTime(), currentTime) < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
||||
parsed.add(Calendar.DAY_OF_MONTH, 1);
|
||||
final Date liveTime = parsed.getTime();
|
||||
final Date predictedTime = parsed.getTime();
|
||||
}
|
||||
|
||||
final Departure dep = new Departure(planTime, line, line != null ? LINES.get(line.charAt(0)) : null, 0, destination);
|
||||
// position
|
||||
final String position = ParserUtils.resolveEntities(mDepFine.group(5));
|
||||
|
||||
final Departure dep = new Departure(plannedTime, line, line != null ? LINES.get(line.charAt(0)) : null, position, 0,
|
||||
destination);
|
||||
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
|
|
|
@ -387,13 +387,15 @@ public class SbbProvider implements NetworkProvider
|
|||
+ "Uhr, (\\d{2}\\.\\d{2}\\.\\d{2}).*?" // date
|
||||
+ "input=(\\d+).*?" // locationId
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<p class=\"sq\">\n(.+?)\n</p>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<p class=\"sq\">\n(.+?)</p>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
|
||||
+ "<b>(.*?)</b>\n" // line
|
||||
+ ">>\n" //
|
||||
+ "(.*?)\n" // destination
|
||||
+ "<br />\n" //
|
||||
+ "<b>(\\d+:\\d+)</b>.*?" // time
|
||||
+ "<b>(\\d+:\\d+)</b>\n" // time
|
||||
+ "(?:Gl\\. (" + ParserUtils.P_PLATFORM + ")\n)?" // position
|
||||
+ ".*?" //
|
||||
, Pattern.DOTALL);
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String uri) throws IOException
|
||||
|
@ -442,7 +444,10 @@ public class SbbProvider implements NetworkProvider
|
|||
if (ParserUtils.timeDiff(parsed.getTime(), currentTime) < -PARSER_DAY_ROLLOVER_THRESHOLD_MS)
|
||||
parsed.add(Calendar.DAY_OF_MONTH, 1);
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, 0, destination);
|
||||
final String position = ParserUtils.resolveEntities(mDepFine.group(4));
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, position, 0,
|
||||
destination);
|
||||
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
|
|
|
@ -132,7 +132,8 @@ public class SncbProvider implements NetworkProvider
|
|||
|
||||
mDepFine.group(4); // TODO delay
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, 0, destination);
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line.charAt(0)) : null, null, 0,
|
||||
destination);
|
||||
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
|
|
|
@ -507,15 +507,24 @@ public final class VbbProvider implements NetworkProvider
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
private static final Pattern P_DEPARTURES_HEAD = Pattern.compile(".*?<strong>(.*?)</strong>.*?Datum:(.*?)<br />.*", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_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*(.*?)[\\s\\*]*</td>\\s*" //
|
||||
private static final Pattern P_DEPARTURES_HEAD = Pattern.compile(".*?" //
|
||||
+ "<strong>(.*?)</strong>.*?Datum:(.*?)<br />.*" //
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_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*(.*?)[\\s\\*]*</td>\\s*" //
|
||||
+ "<td class=\"ivu_table_c_line\">\\s*(.*?)\\s*</td>\\s*" //
|
||||
+ "<td>.*?<a.*?[^-]>\\s*(.*?)\\s*</a>.*?</td>", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_PLAN_FINE = Pattern.compile("<td><strong>(\\d{2}:\\d{2})</strong></td>.*?" //
|
||||
+ "<strong>\\s*(.*?)[\\s\\*]*</strong>.*?" //
|
||||
+ "<a href=\"/Fahrinfo/bin/stboard\\.bin/dox/dox.*?evaId=(\\d+)&.*?>\\s*(.*?)\\s*</a>.*?", Pattern.DOTALL);
|
||||
+ "<td>.*?<a.*?[^-]>\\s*(.*?)\\s*</a>.*?</td>" //
|
||||
, 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_SERVICE_DOWN = Pattern.compile("Wartungsarbeiten");
|
||||
private static final Pattern P_DEPARTURES_URI_STATION_ID = Pattern.compile("input=(\\d+)");
|
||||
|
||||
|
@ -561,13 +570,17 @@ public final class VbbProvider implements NetworkProvider
|
|||
// line
|
||||
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(2)));
|
||||
|
||||
// position
|
||||
final String position = !live ? ParserUtils.resolveEntities(mDepFine.group(3)) : null;
|
||||
|
||||
// destinationId
|
||||
final int destinationId = !live ? Integer.parseInt(mDepFine.group(3)) : 0;
|
||||
final int destinationId = !live ? Integer.parseInt(mDepFine.group(4)) : 0;
|
||||
|
||||
// destination
|
||||
final String destination = ParserUtils.resolveEntities(mDepFine.group(live ? 3 : 4));
|
||||
final String destination = ParserUtils.resolveEntities(mDepFine.group(live ? 3 : 5));
|
||||
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line) : null, destinationId, destination);
|
||||
final Departure dep = new Departure(parsed.getTime(), line, line != null ? LINES.get(line) : null, position, destinationId,
|
||||
destination);
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
}
|
||||
|
@ -639,6 +652,8 @@ public final class VbbProvider implements NetworkProvider
|
|||
return "ICNL" + number;
|
||||
if (type.equals("Zug"))
|
||||
return "R" + number;
|
||||
if (type.equals("ZUG"))
|
||||
return "R" + number;
|
||||
if (type.equals("D")) // D-Zug?
|
||||
return "RD" + number;
|
||||
if (type.equals("DNZ")) // unklar, aber vermutlich Russland
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue