mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 00:39:58 +00:00
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:
parent
22d552f07f
commit
5b662a0ba9
1 changed files with 16 additions and 12 deletions
|
@ -314,31 +314,35 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
String type = stop.getString("type");
|
String type = stop.getString("type");
|
||||||
if ("any".equals(type))
|
if ("any".equals(type))
|
||||||
type = stop.getString("anyType");
|
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 name = normalizeLocationName(stop.optString("name"));
|
||||||
final String object = normalizeLocationName(stop.optString("object"));
|
final String object = normalizeLocationName(stop.optString("object"));
|
||||||
final String postcode = stop.optString("postcode");
|
final String postcode = stop.optString("postcode");
|
||||||
final int quality = stop.getInt("quality");
|
final int quality = stop.getInt("quality");
|
||||||
final JSONObject ref = stop.getJSONObject("ref");
|
final JSONObject ref = stop.getJSONObject("ref");
|
||||||
|
final String id = ref.getString("id");
|
||||||
String place = ref.getString("place");
|
String place = ref.getString("place");
|
||||||
if (place != null && place.length() == 0)
|
if (place != null && place.length() == 0)
|
||||||
place = null;
|
place = null;
|
||||||
final Point coord = parseCoord(ref.optString("coords", null));
|
final Point coord = parseCoord(ref.optString("coords", null));
|
||||||
|
|
||||||
final Location location;
|
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);
|
location = new Location(LocationType.STATION, id, coord, place, object);
|
||||||
else if ("poi".equals(type))
|
} else if ("poi".equals(type)) {
|
||||||
location = new Location(LocationType.POI, id, coord, place, object);
|
location = new Location(LocationType.POI, stateless, coord, place, object);
|
||||||
else if ("crossing".equals(type))
|
} else if ("crossing".equals(type)) {
|
||||||
location = new Location(LocationType.ADDRESS, id, coord, place, object);
|
location = new Location(LocationType.ADDRESS, stateless, coord, place, object);
|
||||||
else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type)
|
} else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type)
|
||||||
|| "buildingname".equals(type) || "loc".equals(type))
|
|| "buildingname".equals(type) || "loc".equals(type)) {
|
||||||
location = new Location(LocationType.ADDRESS, id, coord, place, name);
|
location = new Location(LocationType.ADDRESS, stateless, coord, place, name);
|
||||||
else if ("postcode".equals(type))
|
} else if ("postcode".equals(type)) {
|
||||||
location = new Location(LocationType.ADDRESS, id, coord, place, postcode);
|
location = new Location(LocationType.ADDRESS, stateless, coord, place, postcode);
|
||||||
else
|
} else {
|
||||||
throw new JSONException("unknown type: " + type);
|
throw new JSONException("unknown type: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
return new SuggestedLocation(location, quality);
|
return new SuggestedLocation(location, quality);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue