diff --git a/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java b/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java index 87b6d5ea..7ec124fd 100644 --- a/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java @@ -760,7 +760,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider return false; } - public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, + public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, int maxDistance, final int maxLocations) throws IOException { final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, 0, null); @@ -799,6 +799,9 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider throw new IllegalArgumentException("Unhandled location type: " + location.type); } + if (maxDistance == 0) + maxDistance = 50000; + final String queryUri = uri() + queryUriType + "places_nearby?type[]=stop_point" + "&distance=" + maxDistance + "&count=" + maxLocations + "&depth=0"; final CharSequence page = httpClient.get(queryUri); diff --git a/enabler/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java index 2b571752..aebc8975 100644 --- a/enabler/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java @@ -79,6 +79,15 @@ public abstract class AbstractNavitiaProviderLiveTest extends AbstractProviderLi print(result); } + protected final void nearbyStationsStationDistance(final String stationId) throws IOException + { + final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.STATION, stationId), 0, + 10); + assertEquals(NearbyLocationsResult.Status.OK, result.status); + assertTrue(result.locations.size() > 1); + print(result); + } + protected final void nearbyStationsInvalidStation(final String stationId) throws IOException { final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), new Location(LocationType.STATION, stationId), diff --git a/enabler/test/de/schildbach/pte/live/ParisProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/ParisProviderLiveTest.java index 5b30044e..98106022 100644 --- a/enabler/test/de/schildbach/pte/live/ParisProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/ParisProviderLiveTest.java @@ -64,6 +64,12 @@ public class ParisProviderLiveTest extends AbstractNavitiaProviderLiveTest nearbyStationsAny(48877523, 2378353); } + @Test + public void nearbyStationsDistance() throws Exception + { + nearbyStationsStationDistance("stop_point:OIF:SP:80:137"); + } + @Test public void nearbyStationsInvalidStation() throws Exception {