mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 08:40:29 +00:00
AbstractHafasClientInterfaceProvider: When resolving locations when querying trips, only request 1 location.
This commit is contained in:
parent
601572ebde
commit
2843b9f33d
1 changed files with 8 additions and 5 deletions
|
@ -144,7 +144,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||||
return jsonLocMatch(constraint);
|
return jsonLocMatch(constraint, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -348,10 +348,13 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final SuggestLocationsResult jsonLocMatch(final CharSequence constraint) throws IOException {
|
protected final SuggestLocationsResult jsonLocMatch(final CharSequence constraint, int maxLocations)
|
||||||
|
throws IOException {
|
||||||
|
if (maxLocations == 0)
|
||||||
|
maxLocations = DEFAULT_MAX_LOCATIONS;
|
||||||
final String request = wrapJsonApiRequest("LocMatch",
|
final String request = wrapJsonApiRequest("LocMatch",
|
||||||
"{\"input\":{\"field\":\"S\",\"loc\":{\"name\":" + JSONObject.quote(checkNotNull(constraint).toString())
|
"{\"input\":{\"field\":\"S\",\"loc\":{\"name\":" + JSONObject.quote(checkNotNull(constraint).toString())
|
||||||
+ ",\"meta\":false},\"maxLoc\":" + DEFAULT_MAX_LOCATIONS + "}}",
|
+ ",\"meta\":false},\"maxLoc\":" + maxLocations + "}}",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final HttpUrl url = requestUrl(request);
|
final HttpUrl url = requestUrl(request);
|
||||||
|
@ -401,13 +404,13 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
||||||
|
|
||||||
private Location jsonTripSearchIdentify(final Location location) throws IOException {
|
private Location jsonTripSearchIdentify(final Location location) throws IOException {
|
||||||
if (location.hasName()) {
|
if (location.hasName()) {
|
||||||
final List<Location> locations = jsonLocMatch(JOINER.join(location.place, location.name)).getLocations();
|
final List<Location> locations = jsonLocMatch(JOINER.join(location.place, location.name), 1).getLocations();
|
||||||
if (!locations.isEmpty())
|
if (!locations.isEmpty())
|
||||||
return locations.get(0);
|
return locations.get(0);
|
||||||
}
|
}
|
||||||
if (location.hasLocation()) {
|
if (location.hasLocation()) {
|
||||||
final List<Location> locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.lat,
|
final List<Location> locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.lat,
|
||||||
location.lon, 0, 0).locations;
|
location.lon, 0, 1).locations;
|
||||||
if (!locations.isEmpty())
|
if (!locations.isEmpty())
|
||||||
return locations.get(0);
|
return locations.get(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue