mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-15 17:10:30 +00:00
AbstractHafasClientInterfaceProvider: Support maxDistance when querying for nearby locations.
This commit is contained in:
parent
59e6438882
commit
06cec0c183
2 changed files with 10 additions and 8 deletions
|
@ -129,7 +129,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
|||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> 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,12 +160,13 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
|||
jsonContext.products, jsonContext.walkSpeed, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet<LocationType> types, final int lat, final int lon)
|
||||
throws IOException {
|
||||
protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet<LocationType> 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 + "}}," //
|
||||
final String request = wrapJsonApiRequest("LocGeoPos", "{\"ring\":" //
|
||||
+ "{\"cCrd\":{\"x\":" + lon + ",\"y\":" + lat + "},\"maxDist\":" + maxDistance + "}," //
|
||||
+ "\"getPOIs\":" + getPOIs + "}", //
|
||||
false);
|
||||
|
||||
|
@ -401,7 +402,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
|||
}
|
||||
if (location.hasLocation()) {
|
||||
final List<Location> locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.lat,
|
||||
location.lon).locations;
|
||||
location.lon, 0).locations;
|
||||
if (!locations.isEmpty())
|
||||
return locations.get(0);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue