queryNearbyStations now takes Location object

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@619 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-05-07 16:29:02 +00:00
parent c0f0be81bf
commit 653d590e1b
112 changed files with 605 additions and 501 deletions

View file

@ -431,20 +431,21 @@ public abstract class AbstractEfaProvider implements NetworkProvider
return new Location(LocationType.STATION, id, lat, lon, place, name);
}
protected abstract String nearbyStationUri(String stationId);
protected abstract String nearbyStationUri(int stationId);
public NearbyStationsResult nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
throws IOException
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
{
if (lat != 0 || lon != 0)
return new NearbyStationsResult(xmlCoordRequest(lat, lon, maxDistance, maxStations));
if (location.hasLocation())
return new NearbyStationsResult(xmlCoordRequest(location.lat, location.lon, maxDistance, maxStations));
String uri = null;
if (uri == null && stationId != null)
uri = nearbyStationUri(stationId);
if (uri == null)
if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type);
if (!location.hasId())
throw new IllegalArgumentException("at least one of stationId or lat/lon must be given");
final String uri = nearbyStationUri(location.id);
InputStream is = null;
try
{
@ -644,6 +645,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider
return 'I' + str;
if (type.equals("HKX")) // Hamburg-Koeln-Express
return 'I' + str;
if (type.equals("DNZ")) // Nachtzug Basel-Moskau
return 'I' + str;
if (type.equals("IR")) // Interregio
return 'R' + str;