AbstractHafasClientInterfaceProvider: Fix handling of null products and walkSpeed in jsonTripSearch().

This commit is contained in:
Andreas Schildbach 2018-11-13 20:17:11 +01:00
parent 26d1b8efa6
commit 97513c23f5

View file

@ -418,8 +418,8 @@ 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 WalkSpeed walkSpeed, final boolean dep, final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed,
final String moreContext) throws IOException { final @Nullable String moreContext) throws IOException {
if (!from.hasId()) { if (!from.hasId()) {
from = jsonTripSearchIdentify(from); from = jsonTripSearchIdentify(from);
if (from == null) if (from == null)
@ -446,8 +446,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
final CharSequence outDate = jsonDate(c); final CharSequence outDate = jsonDate(c);
final CharSequence outTime = jsonTime(c); final CharSequence outTime = jsonTime(c);
final CharSequence outFrwd = Boolean.toString(dep); final CharSequence outFrwd = Boolean.toString(dep);
final CharSequence jnyFltr = productsString(products); final CharSequence jnyFltr = products != null ? productsString(products) : null;
final String meta = "foot_speed_" + walkSpeed.name().toLowerCase(); final String meta = "foot_speed_" + (walkSpeed != null ? walkSpeed : WalkSpeed.NORMAL).name().toLowerCase();
final CharSequence jsonContext = moreContext != null ? "\"ctxScr\":" + JSONObject.quote(moreContext) + "," : ""; final CharSequence jsonContext = moreContext != null ? "\"ctxScr\":" + JSONObject.quote(moreContext) + "," : "";
final String request = wrapJsonApiRequest("TripSearch", "{" // final String request = wrapJsonApiRequest("TripSearch", "{" //
+ jsonContext // + jsonContext //
@ -457,7 +457,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
+ "\"outDate\":\"" + outDate + "\"," // + "\"outDate\":\"" + outDate + "\"," //
+ "\"outTime\":\"" + outTime + "\"," // + "\"outTime\":\"" + outTime + "\"," //
+ "\"outFrwd\":" + outFrwd + "," // + "\"outFrwd\":" + outFrwd + "," //
+ "\"jnyFltrL\":[{\"value\":\"" + jnyFltr + "\",\"mode\":\"BIT\",\"type\":\"PROD\"}]," // + (jnyFltr != null
? "\"jnyFltrL\":[{\"value\":\"" + jnyFltr + "\",\"mode\":\"BIT\",\"type\":\"PROD\"}]," : "") //
+ "\"gisFltrL\":[{\"mode\":\"FB\",\"profile\":{\"type\":\"F\",\"linDistRouting\":false,\"maxdist\":2000},\"type\":\"M\",\"meta\":\"" + "\"gisFltrL\":[{\"mode\":\"FB\",\"profile\":{\"type\":\"F\",\"linDistRouting\":false,\"maxdist\":2000},\"type\":\"M\",\"meta\":\""
+ meta + "\"}]," // + meta + "\"}]," //
+ "\"getPolyline\":false,\"getPasslist\":true,\"getIST\":false,\"getEco\":false,\"extChgTime\":-1}", // + "\"getPolyline\":false,\"getPasslist\":true,\"getIST\":false,\"getEco\":false,\"extChgTime\":-1}", //