AbstractEfaProvider: For stations use ref.id as a station ID when suggesting locations, because stateless has grown a weird appendix in some cases.

This commit is contained in:
Andreas Schildbach 2018-12-06 12:51:53 +01:00
parent 22d552f07f
commit 5b662a0ba9

View file

@ -314,31 +314,35 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
String type = stop.getString("type");
if ("any".equals(type))
type = stop.getString("anyType");
final String id = stop.getString("stateless");
final String stateless = stop.getString("stateless");
final String name = normalizeLocationName(stop.optString("name"));
final String object = normalizeLocationName(stop.optString("object"));
final String postcode = stop.optString("postcode");
final int quality = stop.getInt("quality");
final JSONObject ref = stop.getJSONObject("ref");
final String id = ref.getString("id");
String place = ref.getString("place");
if (place != null && place.length() == 0)
place = null;
final Point coord = parseCoord(ref.optString("coords", null));
final Location location;
if ("stop".equals(type))
if ("stop".equals(type)) {
if (!stateless.startsWith(id))
throw new RuntimeException("id mismatch: '" + id + "' vs '" + stateless + "'");
location = new Location(LocationType.STATION, id, coord, place, object);
else if ("poi".equals(type))
location = new Location(LocationType.POI, id, coord, place, object);
else if ("crossing".equals(type))
location = new Location(LocationType.ADDRESS, id, coord, place, object);
else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type)
|| "buildingname".equals(type) || "loc".equals(type))
location = new Location(LocationType.ADDRESS, id, coord, place, name);
else if ("postcode".equals(type))
location = new Location(LocationType.ADDRESS, id, coord, place, postcode);
else
} else if ("poi".equals(type)) {
location = new Location(LocationType.POI, stateless, coord, place, object);
} else if ("crossing".equals(type)) {
location = new Location(LocationType.ADDRESS, stateless, coord, place, object);
} else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type)
|| "buildingname".equals(type) || "loc".equals(type)) {
location = new Location(LocationType.ADDRESS, stateless, coord, place, name);
} else if ("postcode".equals(type)) {
location = new Location(LocationType.ADDRESS, stateless, coord, place, postcode);
} else {
throw new JSONException("unknown type: " + type);
}
return new SuggestedLocation(location, quality);
}