nearby stations by coordinate for Austria

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@611 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-05-07 12:27:26 +00:00
parent 1a3548f831
commit 19cb46decc
2 changed files with 43 additions and 1 deletions

View file

@ -38,6 +38,7 @@ import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
import de.schildbach.pte.dto.QueryConnectionsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
@ -92,6 +93,30 @@ public class OebbProvider extends AbstractHafasProvider
return String.format(NEARBY_URI, ParserUtils.urlEncode(stationId));
}
@Override
public NearbyStationsResult nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
throws IOException
{
final StringBuilder uri = new StringBuilder(API_BASE);
if (lat != 0 || lon != 0)
{
uri.append("query.exe/dny");
uri.append("?performLocating=2&tpl=stop2json");
uri.append("&look_maxno=").append(maxStations != 0 ? maxStations : 200);
uri.append("&look_maxdist=").append(maxDistance != 0 ? maxDistance : 5000);
uri.append("&look_stopclass=2047");
uri.append("&look_x=").append(lon);
uri.append("&look_y=").append(lat);
return jsonNearbyStations(uri.toString());
}
else
{
return super.nearbyStations(stationId, lat, lon, maxDistance, maxStations);
}
}
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
static
{

View file

@ -27,6 +27,7 @@ import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
import de.schildbach.pte.dto.QueryConnectionsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
/**
* @author Andreas Schildbach
@ -37,13 +38,29 @@ public class OebbProviderLiveTest
private static final String ALL_PRODUCTS = "IRSUTBFC";
@Test
public void nearbyStation() throws Exception
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = provider.nearbyStations("902006", 0, 0, 0, 0);
System.out.println(result.stations.size() + " " + result.stations);
}
@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = provider.nearbyStations(null, 48200239, 16370773, 0, 0);
System.out.println(result.stations.size() + " " + result.stations);
}
@Test
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = provider.queryDepartures("902006", 0, false);
System.out.println(result.stationDepartures);
}
@Test
public void shortConnection() throws Exception
{