mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 09:29:49 +00:00
parse updated position
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@145 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
c9b139b653
commit
568b829744
3 changed files with 29 additions and 3 deletions
|
@ -452,7 +452,7 @@ public final class BahnProvider implements NetworkProvider
|
|||
+ "(?: <span class=\"[\\w ]*\">(?:(pünktl\\.)|ca. \\+(\\d+))</span>)?" // ontime, delay
|
||||
+ "(?: k\\.A\\.)?" //
|
||||
+ "(?:, <span class=\"red\">([^<]*)</span>)?" // message
|
||||
+ "(?:(?:, )?(Gl\\. " + ParserUtils.P_PLATFORM + "))?" // position
|
||||
+ "(?:(?:, )?(?:<span class=\"red\">heute )?(Gl\\. " + ParserUtils.P_PLATFORM + ")(?:\\s*</span>)?)?" // position
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_URI_STATION_ID = Pattern.compile("input=(\\d+)");
|
||||
|
||||
|
|
|
@ -246,5 +246,5 @@ public final class ParserUtils
|
|||
return link.substring(link.length() - 10);
|
||||
}
|
||||
|
||||
public static final String P_PLATFORM = "[\\wÄÖÜäöüßáàâéèêíìîóòôúùû\\. -/&#;]+";
|
||||
public static final String P_PLATFORM = "[\\wÄÖÜäöüßáàâéèêíìîóòôúùû\\. -/&#;]+?";
|
||||
}
|
||||
|
|
|
@ -78,6 +78,32 @@ public class BahnProviderTest
|
|||
+ "<span class=\"bold\">07:02</span> <span class=\"red\">ca. +5</span>, <span class=\"red\">Fährt heute nur bis Düsseldorf Hbf</span>, Gl. 10");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void departureUpdatedPosition()
|
||||
{
|
||||
assertFineDepartures("" //
|
||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/492282/296365/292060/18065/80/si=8000320&bt=dep&ti=17:08&pt=17:08&p=1111111111&date=07.09.10&max=10&rt=1&&\">\n" //
|
||||
+ "<span class=\"bold\">RB 30240</span>\n" //
|
||||
+ "</a>\n" //
|
||||
+ ">>\n" //
|
||||
+ "Holzkirchen\n" //
|
||||
+ "<br />\n" //
|
||||
+ "<span class=\"bold\">17:10</span> <span class=\"green bold\">pünktl.</span>, <span class=\"red\">heute Gl. 7 </span>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void departureMessageAndUpdatedPosition()
|
||||
{
|
||||
assertFineDepartures("" //
|
||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/220206/221797/157782/5489/80/si=727269&bt=dep&ti=19:56&pt=19:56&p=1111111111&date=06.09.10&max=10&rt=1&&\">\n" //
|
||||
+ "<span class=\"bold\">CNL 450</span>\n" //
|
||||
+ "</a>\n" //
|
||||
+ ">>\n" //
|
||||
+ "Paris Est\n" //
|
||||
+ "<br />\n" //
|
||||
+ "<span class=\"bold\">19:57</span> <span class=\"green bold\">pünktl.</span>, <span class=\"red\">Änderung im Zuglauf!</span>, <span class=\"red\">heute Gl. 7 </span>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void departureWithWeirdMessage()
|
||||
{
|
||||
|
@ -104,7 +130,7 @@ public class BahnProviderTest
|
|||
Matcher m = BahnProvider.P_DEPARTURES_FINE.matcher(s);
|
||||
assertTrue(m.matches());
|
||||
|
||||
ParserUtils.printGroups(m);
|
||||
// ParserUtils.printGroups(m);
|
||||
|
||||
assertNotNull(m.group(1)); // line
|
||||
assertNotNull(m.group(2)); // destination
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue