\n
\n(.+?)\\s*(?:- Aktuell)?\\n.*?" // location
+ "Abfahrt (\\d+:\\d+)\\n?Uhr, (\\d+\\.\\d+\\.\\d+).*?" // currentTime
, Pattern.DOTALL);
- private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("
(.+?)
", Pattern.DOTALL);
+ private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("
\n(.+?)
", Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
+ "
(.*?).*?" // line
- + ">>\\n?\\s*(.+?)\\s*\\n?
\\n?" // destination
- + "
(\\d+:\\d+).*?" // time
+ + ">>\n\\s*(.+?)\\s*\n
\n" // destination
+ + "
(\\d{1,2}:\\d{2})" // time
+ + "(?:
ca. ([+-]?\\d+))?" // 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);
}
diff --git a/src/de/schildbach/pte/Departure.java b/src/de/schildbach/pte/Departure.java
index a7ce0e07..0b5f133b 100644
--- a/src/de/schildbach/pte/Departure.java
+++ b/src/de/schildbach/pte/Departure.java
@@ -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");
diff --git a/src/de/schildbach/pte/MvvProvider.java b/src/de/schildbach/pte/MvvProvider.java
index d97742b6..02a05de0 100644
--- a/src/de/schildbach/pte/MvvProvider.java
+++ b/src/de/schildbach/pte/MvvProvider.java
@@ -278,8 +278,9 @@ public class MvvProvider implements NetworkProvider
+ "(?:
(\\d+)\\.(\\d+)\\. .*?)?" // date
+ "
" // 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("(.+?)
", Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
+ "(?:[\\xa0\\s]*[\\xa0\\s]*(\\d+)\\.(\\d+)\\.[\\xa0\\s]*)?" // date
- + "(\\d+):(\\d+).*?" // time
+ + "(\\d{1,2}):(\\d{2}).*?" // time
+ "(?:
.*?)?" // product
+ "\\s*([^<]*?)[\\xa0\\s]*(?:.*?)?" // line
+ " \\s*(.*?)\\s* .*?" // 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
diff --git a/src/de/schildbach/pte/OebbProvider.java b/src/de/schildbach/pte/OebbProvider.java
index 4d380afc..52f3e587 100644
--- a/src/de/schildbach/pte/OebbProvider.java
+++ b/src/de/schildbach/pte/OebbProvider.java
@@ -395,12 +395,13 @@ public class OebbProvider implements NetworkProvider
, Pattern.DOTALL);
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("(.*?) ", Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
- + " | (\\d+:\\d+) | .*?" // time
+ + "
(\\d{1,2}:\\d{2}) | .*?" // time
+ "
_pic\\.gif\"\\s+alt=\".*?\")
\\s*(.*?)\\s*\n" //
+ "
" // destinationId
+ "\\s*(.*?)\\s*\n" // destination
+ ".*?" //
+ + "(?:
\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);
diff --git a/src/de/schildbach/pte/ParserUtils.java b/src/de/schildbach/pte/ParserUtils.java
index 8139feb0..2e44535b 100644
--- a/src/de/schildbach/pte/ParserUtils.java
+++ b/src/de/schildbach/pte/ParserUtils.java
@@ -245,4 +245,6 @@ public final class ParserUtils
{
return link.substring(link.length() - 10);
}
+
+ public static final String P_PLATFORM = "[\\wÄÖÜäöüßáàâéèêíìîóòôúùû\\. -/]+";
}
diff --git a/src/de/schildbach/pte/RmvProvider.java b/src/de/schildbach/pte/RmvProvider.java
index e9ec75b1..43d3c42d 100644
--- a/src/de/schildbach/pte/RmvProvider.java
+++ b/src/de/schildbach/pte/RmvProvider.java
@@ -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(" (.+?) ", Pattern.DOTALL);
- private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?\\s*(.*?)\\s*.*?" // line
+ private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("\n(.+?) ", Pattern.DOTALL);
+ private static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
+ + "\\s*(.*?)\\s*.*?" // line
+ ">>\n" //
- + "(.*?)\n?" // destination
- + " .*?" //
- + "(\\d{1,2}:\\d{2}).*?" // planTime
- + "(?:ca\\. (\\d{1,2}:\\d{2}).*?)?" // liveTime
- + "(?:Gl\\. (\\d+) .*?)?", Pattern.DOTALL);
+ + "(.*?)\n" // destination
+ + " \n" //
+ + "(\\d{1,2}:\\d{2})\n" // plannedTime
+ + "(?:ca\\. (\\d{1,2}:\\d{2})\n)?" // predictedTime
+ + "(?:heute Gl\\. " + ParserUtils.P_PLATFORM + " \n)?" // predictedPosition
+ + "(?:(Gl\\. " + ParserUtils.P_PLATFORM + ") \n)?" // position
+ + "(?: \n.+?\n \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);
diff --git a/src/de/schildbach/pte/SbbProvider.java b/src/de/schildbach/pte/SbbProvider.java
index 3de1351b..a9cb985f 100644
--- a/src/de/schildbach/pte/SbbProvider.java
+++ b/src/de/schildbach/pte/SbbProvider.java
@@ -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("\n(.+?)\n ", Pattern.DOTALL);
+ private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("\n(.+?) ", Pattern.DOTALL);
private static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
+ "(.*?)\n" // line
+ ">>\n" //
+ "(.*?)\n" // destination
+ " \n" //
- + "(\\d+:\\d+).*?" // time
+ + "(\\d+:\\d+)\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);
diff --git a/src/de/schildbach/pte/SncbProvider.java b/src/de/schildbach/pte/SncbProvider.java
index abc268f4..d6d0fca9 100644
--- a/src/de/schildbach/pte/SncbProvider.java
+++ b/src/de/schildbach/pte/SncbProvider.java
@@ -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);
diff --git a/src/de/schildbach/pte/VbbProvider.java b/src/de/schildbach/pte/VbbProvider.java
index 79c1bfa7..876b0ac0 100644
--- a/src/de/schildbach/pte/VbbProvider.java
+++ b/src/de/schildbach/pte/VbbProvider.java
@@ -507,15 +507,24 @@ public final class VbbProvider implements NetworkProvider
return uri.toString();
}
- private static final Pattern P_DEPARTURES_HEAD = Pattern.compile(".*?(.*?).*?Datum:(.*?) .*", Pattern.DOTALL);
- private static final Pattern P_DEPARTURES_COARSE = Pattern.compile(
- " | \\s*((?:| | ).+?)\\s* |
", Pattern.DOTALL);
- private static final Pattern P_DEPARTURES_LIVE_FINE = Pattern.compile("
\\s*(.*?)[\\s\\*]* | \\s*" //
+ private static final Pattern P_DEPARTURES_HEAD = Pattern.compile(".*?" //
+ + "
(.*?).*?Datum:(.*?)
.*" //
+ , Pattern.DOTALL);
+ private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("" //
+ + "
\\s*((?:| | ).+?)\\s* |
" //
+ , Pattern.DOTALL);
+ private static final Pattern P_DEPARTURES_LIVE_FINE = Pattern.compile("" //
+ + "
\\s*(.*?)[\\s\\*]* | \\s*" //
+ "
\\s*(.*?)\\s* | \\s*" //
- + "
.*?\\s*(.*?)\\s*.*? | ", Pattern.DOTALL);
- private static final Pattern P_DEPARTURES_PLAN_FINE = Pattern.compile("
(\\d{2}:\\d{2}) | .*?" //
- + "
\\s*(.*?)[\\s\\*]*.*?" //
- + "
\\s*(.*?)\\s*.*?", Pattern.DOTALL);
+ + "
.*?\\s*(.*?)\\s*.*? | " //
+ , Pattern.DOTALL);
+ private static final Pattern P_DEPARTURES_PLAN_FINE = Pattern.compile("" //
+ + "
(\\d{1,2}:\\d{2}) | .*?" // time
+ + "
\\s*(.*?)[\\s\\*]*.*?" // line
+ + "(?:\\((Gl\\. " + ParserUtils.P_PLATFORM + ")\\).*?)?" // position
+ + "
" // destinationId
+ + "\\s*(.*?)\\s*.*?" // 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