mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 19:18:53 +00:00
fixed öbb changed ld=web25 to web05
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@173 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
699a6bb320
commit
3bca82d3c3
2 changed files with 69 additions and 9 deletions
|
@ -115,7 +115,7 @@ public class OebbProvider implements NetworkProvider
|
||||||
final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm");
|
final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm");
|
||||||
final StringBuilder uri = new StringBuilder();
|
final StringBuilder uri = new StringBuilder();
|
||||||
|
|
||||||
uri.append("http://fahrplan.oebb.at/bin/query.exe/dn?ld=web25&OK");
|
uri.append("http://fahrplan.oebb.at/bin/query.exe/dn?ld=web05&OK");
|
||||||
uri.append("&REQ0HafasSearchForw=").append(dep ? "1" : "0");
|
uri.append("&REQ0HafasSearchForw=").append(dep ? "1" : "0");
|
||||||
uri.append("&REQ0JourneyDate=").append(ParserUtils.urlEncode(DATE_FORMAT.format(date)));
|
uri.append("&REQ0JourneyDate=").append(ParserUtils.urlEncode(DATE_FORMAT.format(date)));
|
||||||
uri.append("&REQ0JourneyStopsS0G=").append(ParserUtils.urlEncode(from));
|
uri.append("&REQ0JourneyStopsS0G=").append(ParserUtils.urlEncode(from));
|
||||||
|
@ -449,15 +449,15 @@ public class OebbProvider implements NetworkProvider
|
||||||
+ "Abfahrt (\\d+:\\d+).*?" // time
|
+ "Abfahrt (\\d+:\\d+).*?" // time
|
||||||
+ "%23(\\d+)&.*?" // locationId
|
+ "%23(\\d+)&.*?" // locationId
|
||||||
, Pattern.DOTALL);
|
, Pattern.DOTALL);
|
||||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"depboard-\\w*\">(.*?)</tr>", Pattern.DOTALL);
|
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<tr class=\"depboard-(\\w*)\">\n(.*?)</tr>", Pattern.DOTALL);
|
||||||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
|
static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
|
||||||
+ "<td class=\"[\\w ]*\">(\\d{1,2}:\\d{2})</td>\n" // plannedTime
|
+ "<td class=\"[\\w ]*\">(\\d{1,2}:\\d{2})</td>\n.*?" // plannedTime
|
||||||
+ "(?:<td class=\"[\\w ]*prognosis[\\w ]*\">\n" //
|
+ "(?:<td class=\"[\\w ]*?prognosis[\\w ]*?\">\n" //
|
||||||
+ "(?: |<span class=\"rtLimit\\d\">(pünktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
|
+ "(?: |<span class=\"rtLimit\\d\">(pünktlich|\\d{1,2}:\\d{2})</span>)\n</td>\n" // predictedTime
|
||||||
+ ")?.*?" //
|
+ ")?.*?" //
|
||||||
+ "<img src=\"/img/vs_oebb/(\\w+)_pic\\.gif\"\\s+alt=\".*?\">\\s*(.*?)\\s*</.*?" // type, line
|
+ "<img src=\"/img/vs_oebb/(\\w+)_pic\\.gif\"\\s+alt=\"[^\"]*\">\\s*(.*?)\\s*</.*?" // type, line
|
||||||
+ "<span class=\"bold\">\n" //
|
+ "<span class=\"bold\">\n" //
|
||||||
+ "<a href=\"http://fahrplan\\.oebb\\.at/bin/stboard\\.exe/dn\\?ld=web25&input=[^%]*?(?:%23(\\d+))?&.*?\">" // destinationId
|
+ "<a href=\"http://fahrplan\\.oebb\\.at/bin/stboard\\.exe/dn\\?ld=web\\d+&input=[^%]*?(?:%23(\\d+))?&.*?\">" // destinationId
|
||||||
+ "\\s*(.*?)\\s*</a>\n" // destination
|
+ "\\s*(.*?)\\s*</a>\n" // destination
|
||||||
+ "</span>.*?" //
|
+ "</span>.*?" //
|
||||||
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
|
+ "(?:<td class=\"center sepline top\">\n(" + ParserUtils.P_PLATFORM + ").*?)?" // position
|
||||||
|
@ -488,11 +488,18 @@ public class OebbProvider implements NetworkProvider
|
||||||
.parseTime(mHeadFine.group(3)));
|
.parseTime(mHeadFine.group(3)));
|
||||||
final int stationId = Integer.parseInt(mHeadFine.group(4));
|
final int stationId = Integer.parseInt(mHeadFine.group(4));
|
||||||
final List<Departure> departures = new ArrayList<Departure>(8);
|
final List<Departure> departures = new ArrayList<Departure>(8);
|
||||||
|
String oldZebra = null;
|
||||||
|
|
||||||
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(2));
|
final Matcher mDepCoarse = P_DEPARTURES_COARSE.matcher(mHeadCoarse.group(2));
|
||||||
while (mDepCoarse.find())
|
while (mDepCoarse.find())
|
||||||
{
|
{
|
||||||
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(1));
|
final String zebra = mDepCoarse.group(1);
|
||||||
|
if (oldZebra != null && zebra.equals(oldZebra))
|
||||||
|
throw new IllegalArgumentException("missed row? last:" + zebra);
|
||||||
|
else
|
||||||
|
oldZebra = zebra;
|
||||||
|
|
||||||
|
final Matcher mDepFine = P_DEPARTURES_FINE.matcher(mDepCoarse.group(2));
|
||||||
if (mDepFine.matches())
|
if (mDepFine.matches())
|
||||||
{
|
{
|
||||||
final Calendar current = new GregorianCalendar();
|
final Calendar current = new GregorianCalendar();
|
||||||
|
@ -535,7 +542,7 @@ public class OebbProvider implements NetworkProvider
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(1) + "' on " + uri);
|
throw new IllegalArgumentException("cannot parse '" + mDepCoarse.group(2) + "' on " + uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
53
test/de/schildbach/pte/OebbProviderTest.java
Normal file
53
test/de/schildbach/pte/OebbProviderTest.java
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
package de.schildbach.pte;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class OebbProviderTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testDepartures()
|
||||||
|
{
|
||||||
|
assertFineDepartures("" //
|
||||||
|
+ "<td class=\"bold center sepline top\">09:12</td>\n" //
|
||||||
|
+ "<td class=\"bold top nowrap sepline\">\n" //
|
||||||
|
+ "<a href=\"http://fahrplan.oebb.at/bin/traininfo.exe/dn/152499/163408/534164/216252/81?ld=web05&date=21.09.10&station_evaId=912101&station_type=dep\"><img src=\"/img/vs_oebb/bus_pic.gif\" alt=\"Bus 16A\"> Bus 16A</a>\n" //
|
||||||
|
+ "</td>\n" //
|
||||||
|
+ "<td class=\"sepline top\">\n" //
|
||||||
|
+ "<span class=\"bold\">\n" //
|
||||||
|
+ "<a href=\"http://fahrplan.oebb.at/bin/stboard.exe/dn?ld=web05&input=Wien Hetzendorf Bahnhst&boardType=dep&time=09:13&maxJourneys=10&productsFilter=111111111111&\">\n" //
|
||||||
|
+ "Wien Hetzendorf Bahnhst\n" //
|
||||||
|
+ "</a>\n" //
|
||||||
|
+ "</span>\n" //
|
||||||
|
+ "<br />\n" //
|
||||||
|
+ "<a href=\"http://fahrplan.oebb.at/bin/stboard.exe/dn?ld=web05&input=Wien Breitenfurter Straße/Hetzendorfer Straße%23912101&boardType=dep&time=09:12&maxJourneys=10&productsFilter=111111111111&\">\n" //
|
||||||
|
+ "Wien Breitenfurter Straße/Hetzendorfer Straße\n" //
|
||||||
|
+ "</a>\n" //
|
||||||
|
+ "09:12\n" //
|
||||||
|
+ "-\n" //
|
||||||
|
+ "<a href=\"http://fahrplan.oebb.at/bin/stboard.exe/dn?ld=web05&input=Wien Hetzendorf Bahnhst (Eckartsaugasse)%23912018&boardType=dep&time=09:13&maxJourneys=10&productsFilter=111111111111&\">\n" //
|
||||||
|
+ "Wien Hetzendorf Bahnhst (Eckartsaugasse)\n" //
|
||||||
|
+ "</a>\n" //
|
||||||
|
+ "09:13\n" //
|
||||||
|
+ "</td>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Matcher assertFineDepartures(String s)
|
||||||
|
{
|
||||||
|
Matcher m = OebbProvider.P_DEPARTURES_FINE.matcher(s);
|
||||||
|
assertTrue(m.matches());
|
||||||
|
|
||||||
|
// ParserUtils.printGroups(m);
|
||||||
|
|
||||||
|
assertNotNull(m.group(1)); // time
|
||||||
|
assertNotNull(m.group(3)); // lineType
|
||||||
|
assertNotNull(m.group(4)); // line
|
||||||
|
assertNotNull(m.group(6)); // destination
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue