special parsing for some places

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@440 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-01-09 13:36:28 +00:00
parent 7ca487c632
commit f5f5be44e8

View file

@ -146,7 +146,7 @@ public final class BvgProvider extends AbstractHafasProvider
final int parsedLon = (int) (Float.parseFloat(mOwn.group(2)) * 1E6); final int parsedLon = (int) (Float.parseFloat(mOwn.group(2)) * 1E6);
final int parsedLat = (int) (Float.parseFloat(mOwn.group(3)) * 1E6); final int parsedLat = (int) (Float.parseFloat(mOwn.group(3)) * 1E6);
final String parsedName = ParserUtils.urlDecode(mOwn.group(4), "ISO-8859-1"); final String parsedName = ParserUtils.urlDecode(mOwn.group(4), "ISO-8859-1");
stations.add(new Station(parsedId, null, parsedName, null, parsedLat, parsedLon, 0, null, null)); stations.add(newStation(parsedId, parsedName, parsedLat, parsedLon));
} }
final Matcher mPage = P_NEARBY_PAGE.matcher(page); final Matcher mPage = P_NEARBY_PAGE.matcher(page);
@ -162,7 +162,9 @@ public final class BvgProvider extends AbstractHafasProvider
{ {
final int parsedId = Integer.parseInt(mFineLocation.group(1)); final int parsedId = Integer.parseInt(mFineLocation.group(1));
final String parsedName = ParserUtils.resolveEntities(mFineLocation.group(2)); final String parsedName = ParserUtils.resolveEntities(mFineLocation.group(2));
stations.add(new Station(parsedId, null, parsedName, null, 0, 0, 0, null, null)); final Station station = newStation(parsedId, parsedName, 0, 0);
if (!stations.contains(station))
stations.add(station);
} }
else else
{ {
@ -181,6 +183,28 @@ public final class BvgProvider extends AbstractHafasProvider
} }
} }
private Station newStation(final int id, final String parsedName, final int lat, final int lon)
{
String place = null, name = null, longName = null;
if (parsedName.endsWith(" (Berlin)"))
{
place = "Berlin";
name = parsedName.substring(0, parsedName.length() - 9);
}
else if (parsedName.startsWith("Potsdam, "))
{
place = "Potsdam";
name = parsedName.substring(9);
}
else
{
longName = parsedName;
}
return new Station(id, place, name, longName, lat, lon, 0, null, null);
}
public static final String STATION_URL_CONNECTION = "http://mobil.bvg.de/Fahrinfo/bin/query.bin/dox"; public static final String STATION_URL_CONNECTION = "http://mobil.bvg.de/Fahrinfo/bin/query.bin/dox";
private String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep, private String connectionsQueryUri(final Location from, final Location via, final Location to, final Date date, final boolean dep,