SH: Handle querying for nearby stations by coordinate.

This commit is contained in:
Andreas Schildbach 2015-08-26 13:30:42 +02:00
parent 26199d7ec3
commit f8e1674ab6
2 changed files with 16 additions and 10 deletions

View file

@ -145,16 +145,6 @@ public class ShProvider extends AbstractHafasProvider
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.type == LocationType.STATION && location.hasId())
return nearbyStationsById(location.id, maxDistance);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
protected NearbyLocationsResult nearbyStationsById(final String id, final int maxDistance) throws IOException
{

View file

@ -18,6 +18,7 @@
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
@ -51,6 +52,21 @@ public class ShProviderLiveTest extends AbstractProviderLiveTest
print(result);
}
@Test
public void nearbyStationsInvalidStation() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "999999"));
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
}
@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(Location.coord(54325845, 10122920));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception
{