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:
andreas.schildbach 2010-09-07 18:14:28 +00:00
parent c9b139b653
commit 568b829744
3 changed files with 29 additions and 3 deletions

View file

@ -452,7 +452,7 @@ public final class BahnProvider implements NetworkProvider
+ "(?:&nbsp;<span class=\"[\\w ]*\">(?:(p&#252;nktl\\.)|ca. \\+(\\d+))</span>)?" // ontime, delay
+ "(?:&nbsp;k\\.A\\.)?" //
+ "(?:, <span class=\"red\">([^<]*)</span>)?" // message
+ "(?:(?:,&nbsp;)?(Gl\\. " + ParserUtils.P_PLATFORM + "))?" // position
+ "(?:(?:,&nbsp;)?(?:<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+)");

View file

@ -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ÄÖÜäöüßáàâéèêíìîóòôúùû\\. -/&#;]+?";
}

View file

@ -78,6 +78,32 @@ public class BahnProviderTest
+ "<span class=\"bold\">07:02</span>&nbsp;<span class=\"red\">ca. +5</span>, <span class=\"red\">F&#228;hrt heute nur bis&nbsp;D&#252;sseldorf Hbf</span>,&nbsp;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&amp;bt=dep&amp;ti=17:08&amp;pt=17:08&amp;p=1111111111&amp;date=07.09.10&amp;max=10&amp;rt=1&amp;&amp;\">\n" //
+ "<span class=\"bold\">RB 30240</span>\n" //
+ "</a>\n" //
+ "&gt;&gt;\n" //
+ "Holzkirchen\n" //
+ "<br />\n" //
+ "<span class=\"bold\">17:10</span>&nbsp;<span class=\"green bold\">p&#252;nktl.</span>,&nbsp;<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&amp;bt=dep&amp;ti=19:56&amp;pt=19:56&amp;p=1111111111&amp;date=06.09.10&amp;max=10&amp;rt=1&amp;&amp;\">\n" //
+ "<span class=\"bold\">CNL 450</span>\n" //
+ "</a>\n" //
+ "&gt;&gt;\n" //
+ "Paris Est\n" //
+ "<br />\n" //
+ "<span class=\"bold\">19:57</span>&nbsp;<span class=\"green bold\">p&#252;nktl.</span>, <span class=\"red\">&#196;nderung im Zuglauf!</span>,&nbsp;<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