AbstractHafasClientInterfaceProvider: Handle when jsonTripSearchIdentify() is called with an already identified location.

This commit is contained in:
Andreas Schildbach 2018-10-31 00:55:31 +01:00
parent 97513c23f5
commit b025ca004e

View file

@ -403,6 +403,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
private static final Joiner JOINER = Joiner.on(' ').skipNulls(); private static final Joiner JOINER = Joiner.on(' ').skipNulls();
private Location jsonTripSearchIdentify(final Location location) throws IOException { private Location jsonTripSearchIdentify(final Location location) throws IOException {
if (location.hasId())
return location;
if (location.hasName()) { if (location.hasName()) {
final List<Location> locations = jsonLocMatch(JOINER.join(location.place, location.name), 1).getLocations(); final List<Location> locations = jsonLocMatch(JOINER.join(location.place, location.name), 1).getLocations();
if (!locations.isEmpty()) if (!locations.isEmpty())
@ -420,26 +422,19 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
protected final QueryTripsResult jsonTripSearch(Location from, @Nullable Location via, Location to, final Date time, protected final QueryTripsResult jsonTripSearch(Location from, @Nullable Location via, Location to, final Date time,
final boolean dep, final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final boolean dep, final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed,
final @Nullable String moreContext) throws IOException { final @Nullable String moreContext) throws IOException {
if (!from.hasId()) { from = jsonTripSearchIdentify(from);
from = jsonTripSearchIdentify(from); if (from == null)
if (from == null) return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT),
return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT), QueryTripsResult.Status.UNKNOWN_FROM);
QueryTripsResult.Status.UNKNOWN_FROM); if (via != null) {
}
if (via != null && !via.hasId()) {
via = jsonTripSearchIdentify(via); via = jsonTripSearchIdentify(via);
if (via == null) if (via == null)
return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT), return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT),
QueryTripsResult.Status.UNKNOWN_VIA); QueryTripsResult.Status.UNKNOWN_VIA);
} }
to = jsonTripSearchIdentify(to);
if (!to.hasId()) { if (to == null)
to = jsonTripSearchIdentify(to); return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT), QueryTripsResult.Status.UNKNOWN_TO);
if (to == null)
return new QueryTripsResult(new ResultHeader(network, SERVER_PRODUCT),
QueryTripsResult.Status.UNKNOWN_TO);
}
final Calendar c = new GregorianCalendar(timeZone); final Calendar c = new GregorianCalendar(timeZone);
c.setTime(time); c.setTime(time);