AbstractHafasClientInterfaceProvider: Follow path to main mast only in jsonLocGeoPos(), jsonLocMatch() and jsonTripSearch().

This commit is contained in:
Andreas Schildbach 2019-01-21 12:36:43 +01:00
parent 6c78edea09
commit 9ae8081f96

View file

@ -628,9 +628,10 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
final List<Trip> trips = new ArrayList<>(outConList.length()); final List<Trip> trips = new ArrayList<>(outConList.length());
for (int iOutCon = 0; iOutCon < outConList.length(); iOutCon++) { for (int iOutCon = 0; iOutCon < outConList.length(); iOutCon++) {
final JSONObject outCon = outConList.getJSONObject(iOutCon); final JSONObject outCon = outConList.getJSONObject(iOutCon);
final Location tripFrom = parseLoc(locList, outCon.getJSONObject("dep").getInt("locX"), null, final Location tripFrom = parseLoc(locList, outCon.getJSONObject("dep").getInt("locX"),
crdSysList); new HashSet<Integer>(), crdSysList);
final Location tripTo = parseLoc(locList, outCon.getJSONObject("arr").getInt("locX"), null, crdSysList); final Location tripTo = parseLoc(locList, outCon.getJSONObject("arr").getInt("locX"),
new HashSet<Integer>(), crdSysList);
c.clear(); c.clear();
ParserUtils.parseIsoDate(c, outCon.getString("date")); ParserUtils.parseIsoDate(c, outCon.getString("date"));
@ -906,7 +907,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
private Stop parseJsonStop(final JSONObject json, final JSONArray locList, final JSONArray crdSysList, private Stop parseJsonStop(final JSONObject json, final JSONArray locList, final JSONArray crdSysList,
final Calendar c, final Date baseDate) throws JSONException { final Calendar c, final Date baseDate) throws JSONException {
final Location location = parseLoc(locList, json.getInt("locX"), null, crdSysList); final Location location = parseLoc(locList, json.getInt("locX"), new HashSet<Integer>(), crdSysList);
final boolean arrivalCancelled = json.optBoolean("aCncl", false); final boolean arrivalCancelled = json.optBoolean("aCncl", false);
final Date plannedArrivalTime = parseJsonTime(c, baseDate, json.optString("aTimeS", null)); final Date plannedArrivalTime = parseJsonTime(c, baseDate, json.optString("aTimeS", null));
@ -981,7 +982,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
private List<Location> parseLocList(final JSONArray locList, final JSONArray crdSysList) throws JSONException { private List<Location> parseLocList(final JSONArray locList, final JSONArray crdSysList) throws JSONException {
final List<Location> locations = new ArrayList<>(locList.length()); final List<Location> locations = new ArrayList<>(locList.length());
for (int iLoc = 0; iLoc < locList.length(); iLoc++) for (int iLoc = 0; iLoc < locList.length(); iLoc++)
locations.add(parseLoc(locList, iLoc, null, crdSysList)); locations.add(parseLoc(locList, iLoc, new HashSet<Integer>(), crdSysList));
return locations; return locations;
} }
@ -996,14 +997,10 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
final Set<Product> products; final Set<Product> products;
if ("S".equals(type)) { if ("S".equals(type)) {
final int mMastLocX = loc.optInt("mMastLocX", -1); final int mMastLocX = loc.optInt("mMastLocX", -1);
if (mMastLocX != -1) { if (previousLocListIndexes != null && mMastLocX != -1 && !previousLocListIndexes.contains(mMastLocX)) {
if (previousLocListIndexes == null)
previousLocListIndexes = new HashSet<>();
if (!previousLocListIndexes.contains(mMastLocX)) {
previousLocListIndexes.add(locListIndex); previousLocListIndexes.add(locListIndex);
return parseLoc(locList, mMastLocX, previousLocListIndexes, crdSysList); return parseLoc(locList, mMastLocX, previousLocListIndexes, crdSysList);
} }
}
locationType = LocationType.STATION; locationType = LocationType.STATION;
id = normalizeStationId(loc.getString("extId")); id = normalizeStationId(loc.getString("extId"));
placeAndName = splitStationName(loc.getString("name")); placeAndName = splitStationName(loc.getString("name"));