adapt to API changes of BVG

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@727 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-07-11 10:23:37 +00:00
parent afb23ab99e
commit 678b4eb3d0

View file

@ -607,18 +607,18 @@ public final class BvgProvider extends AbstractHafasProvider
private Location location(final String typeStr, final String idStr, final String latStr, final String lonStr, final String nameStr) private Location location(final String typeStr, final String idStr, final String latStr, final String lonStr, final String nameStr)
{ {
final int id = idStr != null ? Integer.parseInt(idStr) : 0; final int id = idStr != null ? Integer.parseInt(idStr) : 0;
final int lat = latStr != null ? (int) (Float.parseFloat(latStr) * 1E6) : 0; final int lat = latStr != null ? Integer.parseInt(latStr) : 0;
final int lon = lonStr != null ? (int) (Float.parseFloat(lonStr) * 1E6) : 0; final int lon = lonStr != null ? Integer.parseInt(lonStr) : 0;
final String[] placeAndName = splitPlaceAndName(nameStr); final String[] placeAndName = splitPlaceAndName(nameStr);
final LocationType type; final LocationType type;
if (typeStr == null) if (typeStr == null)
type = LocationType.ANY; type = LocationType.ANY;
else if ("HST".equals(typeStr)) else if ("STATION".equals(typeStr))
type = LocationType.STATION; type = LocationType.STATION;
else if ("POI".equals(typeStr)) else if ("POI".equals(typeStr))
type = LocationType.POI; type = LocationType.POI;
else if ("ADR".equals(typeStr)) else if ("ADDRESS".equals(typeStr))
type = LocationType.ADDRESS; type = LocationType.ADDRESS;
else else
throw new IllegalArgumentException("cannot handle: " + typeStr); throw new IllegalArgumentException("cannot handle: " + typeStr);
@ -649,12 +649,14 @@ public final class BvgProvider extends AbstractHafasProvider
private static final Pattern P_CONNECTIONS_HEAD = Pattern.compile(".*?" // private static final Pattern P_CONNECTIONS_HEAD = Pattern.compile(".*?" //
+ "<td headers=\"ivuAnfFrom\"[^>]*>\n" // + "<td headers=\"ivuAnfFrom\"[^>]*>\n" //
+ "(?:([^\n]*)\n)?" // from name + "(?:([^\n]*)\n)?" // from name
+ "<a href=\"[^\"]*location=(?:(\\d+)|),(?:(\\w+)|),WGS84,(\\d+\\.\\d+),(\\d+\\.\\d+)&.*?" // fr id,lat,lon + "<a href=\"/Fahrinfo/[^\"]*?MapLocation\\.X=(\\d+)&MapLocation\\.Y=(\\d+)&[^\"]*?" // from lat, lon
+ "MapLocation\\.type=(\\w+)&(?:MapLocation.extId=(\\d+)&)?.*?" // from type, id
+ "(?:<td headers=\"ivuAnfVia1\"[^>]*>\n" // + "(?:<td headers=\"ivuAnfVia1\"[^>]*>\n" //
+ "([^\n]*)<.*?)?" // via name + "([^\n]*)<.*?)?" // via name
+ "<td headers=\"ivuAnfTo\"[^>]*>\n" // + "<td headers=\"ivuAnfTo\"[^>]*>\n" //
+ "(?:([^\n]*)\n)?" // to name + "(?:([^\n]*)\n)?" // to name
+ "<a href=\"[^\"]*location=(?:(\\d+)|),(?:(\\w+)|),WGS84,(\\d+\\.\\d+),(\\d+\\.\\d+)&.*?" // to id,lat,lon + "<a href=\"/Fahrinfo/[^\"]*?MapLocation\\.X=(\\d+)&MapLocation\\.Y=(\\d+)&[^\"]*?" // to lat, lon
+ "MapLocation\\.type=(\\w+)&(?:MapLocation.extId=(\\d+)&)?.*?" // to type, id
+ "<td headers=\"ivuAnfTime\"[^>]*>.., (\\d{2}\\.\\d{2}\\.\\d{2}) \\d{1,2}:\\d{2}</td>.*?" // date + "<td headers=\"ivuAnfTime\"[^>]*>.., (\\d{2}\\.\\d{2}\\.\\d{2}) \\d{1,2}:\\d{2}</td>.*?" // date
+ "(?:<a href=\"([^\"]*)\" title=\"fr&uuml;here Verbindungen\"[^>]*?>.*?)?" // linkEarlier + "(?:<a href=\"([^\"]*)\" title=\"fr&uuml;here Verbindungen\"[^>]*?>.*?)?" // linkEarlier
+ "(?:<a href=\"([^\"]*)\" title=\"sp&auml;tere Verbindungen\"[^>]*?>.*?)?" // linkLater + "(?:<a href=\"([^\"]*)\" title=\"sp&auml;tere Verbindungen\"[^>]*?>.*?)?" // linkLater
@ -706,10 +708,10 @@ public final class BvgProvider extends AbstractHafasProvider
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page); final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
if (mHead.matches()) if (mHead.matches())
{ {
final Location from = mHead.group(1) != null ? location(mHead.group(3), mHead.group(2), mHead.group(5), mHead.group(4), final Location from = mHead.group(1) != null ? location(mHead.group(4), mHead.group(5), mHead.group(2), mHead.group(3),
ParserUtils.resolveEntities(mHead.group(1))) : null; ParserUtils.resolveEntities(mHead.group(1))) : null;
final Location via = mHead.group(6) != null ? location(null, null, null, null, ParserUtils.resolveEntities(mHead.group(6))) : null; final Location via = mHead.group(6) != null ? location(null, null, null, null, ParserUtils.resolveEntities(mHead.group(6))) : null;
final Location to = mHead.group(7) != null ? location(mHead.group(9), mHead.group(8), mHead.group(11), mHead.group(10), final Location to = mHead.group(7) != null ? location(mHead.group(10), mHead.group(11), mHead.group(8), mHead.group(9),
ParserUtils.resolveEntities(mHead.group(7))) : null; ParserUtils.resolveEntities(mHead.group(7))) : null;
final Calendar currentDate = new GregorianCalendar(timeZone()); final Calendar currentDate = new GregorianCalendar(timeZone());
currentDate.clear(); currentDate.clear();