diff --git a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index c5ac51dc..290422cb 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -129,7 +129,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, final int maxLocations) throws IOException { if (location.hasLocation()) - return jsonLocGeoPos(types, location.lat, location.lon); + return jsonLocGeoPos(types, location.lat, location.lon, maxDistance); else throw new IllegalArgumentException("cannot handle: " + location); } @@ -160,13 +160,14 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas jsonContext.products, jsonContext.walkSpeed, later ? jsonContext.laterContext : jsonContext.earlierContext); } - protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet types, final int lat, final int lon) - throws IOException { + protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet types, final int lat, final int lon, + int maxDistance) throws IOException { + if (maxDistance == 0) + maxDistance = DEFAULT_MAX_DISTANCE; final boolean getPOIs = types.contains(LocationType.POI); - final String request = wrapJsonApiRequest("LocGeoPos", - "{\"ring\":" // - + "{\"cCrd\":{\"x\":" + lon + ",\"y\":" + lat + "}}," // - + "\"getPOIs\":" + getPOIs + "}", // + final String request = wrapJsonApiRequest("LocGeoPos", "{\"ring\":" // + + "{\"cCrd\":{\"x\":" + lon + ",\"y\":" + lat + "},\"maxDist\":" + maxDistance + "}," // + + "\"getPOIs\":" + getPOIs + "}", // false); final HttpUrl url = requestUrl(request); @@ -401,7 +402,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas } if (location.hasLocation()) { final List locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.lat, - location.lon).locations; + location.lon, 0).locations; if (!locations.isEmpty()) return locations.get(0); } diff --git a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java index d4478f22..041e45b3 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java @@ -41,6 +41,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider { protected static final String SERVER_PRODUCT = "hafas"; protected static final int DEFAULT_MAX_DEPARTURES = 100; protected static final int DEFAULT_MAX_LOCATIONS = 50; + protected static final int DEFAULT_MAX_DISTANCE = 20000; protected static final Logger log = LoggerFactory.getLogger(AbstractHafasProvider.class);