From 874198b621bde0f9e168b3b631136628b49020a8 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Sat, 17 Nov 2018 10:51:06 +0100 Subject: [PATCH] AbstractHafasClientInterfaceProvider: Split unidentified destination as if it were a station. --- .../AbstractHafasClientInterfaceProvider.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index 682bad10..af6f3283 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -311,17 +311,19 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas final Position position = normalizePosition(stbStopPlatformS); final String jnyDirTxt = jny.getString("dirTxt"); + Location destination = null; + // if last entry in stopL happens to be our destination, use it final JSONArray stopList = jny.optJSONArray("stopL"); - final Location destination; if (stopList != null) { final int lastStopIdx = stopList.getJSONObject(stopList.length() - 1).getInt("locX"); final String lastStopName = locList.getJSONObject(lastStopIdx).getString("name"); if (jnyDirTxt.equals(lastStopName)) destination = parseLoc(locList, lastStopIdx, null); - else - destination = new Location(LocationType.ANY, null, null, jnyDirTxt); - } else { - destination = new Location(LocationType.ANY, null, null, jnyDirTxt); + } + // otherwise split unidentified destination as if it was a station and use it + if (destination == null) { + final String[] splitJnyDirTxt = splitStationName(jnyDirTxt); + destination = new Location(LocationType.ANY, null, splitJnyDirTxt[0], splitJnyDirTxt[1]); } final JSONArray remList = jny.optJSONArray("remL"); @@ -547,8 +549,14 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas final JSONObject jny = sec.getJSONObject("jny"); final Line line = lines.get(jny.getInt("prodX")); final String dirTxt = jny.optString("dirTxt", null); - final Location destination = dirTxt != null ? new Location(LocationType.ANY, null, null, dirTxt) - : null; + + final Location destination; + if (dirTxt != null) { + final String[] splitDirTxt = splitStationName(dirTxt); + destination = new Location(LocationType.ANY, null, splitDirTxt[0], splitDirTxt[1]); + } else { + destination = null; + } final JSONArray stopList = jny.optJSONArray("stopL"); final List intermediateStops;