fixed geocoding of POIs

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@278 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-10-11 09:35:44 +00:00
parent ad1ff4c7f7
commit 7e33f3eb1d

View file

@ -86,28 +86,24 @@ public class OebbProvider extends AbstractHafasProvider
{ {
final int type = suggestion.getInt("type"); final int type = suggestion.getInt("type");
final String value = suggestion.getString("value"); final String value = suggestion.getString("value");
final int lat = suggestion.getInt("ycoord");
final int lon = suggestion.getInt("xcoord");
int localId = 0;
final Matcher m = P_AUTOCOMPLETE_ID.matcher(suggestion.getString("id"));
if (m.matches())
localId = Integer.parseInt(m.group(1));
if (type == 1) // station if (type == 1) // station
{ {
final String id = suggestion.getString("id"); results.add(new Location(LocationType.STATION, localId, lat, lon, value));
final Matcher m = P_AUTOCOMPLETE_ID.matcher(id);
if (m.matches())
{
final int localId = Integer.parseInt(m.group(1));
results.add(new Location(LocationType.STATION, localId, 0, 0, value));
}
else
{
throw new IllegalStateException("id does not match: " + id);
}
} }
else if (type == 2) // address else if (type == 2) // address
{ {
results.add(new Location(LocationType.ADDRESS, 0, 0, 0, value)); results.add(new Location(LocationType.ADDRESS, 0, lat, lon, value));
} }
else if (type == 4) // poi else if (type == 4) // poi
{ {
results.add(new Location(LocationType.ANY, 0, 0, 0, value)); results.add(new Location(LocationType.POI, localId, lat, lon, value));
} }
else else
{ {
@ -207,6 +203,8 @@ public class OebbProvider extends AbstractHafasProvider
return 1; return 1;
if (type == LocationType.ADDRESS) if (type == LocationType.ADDRESS)
return 2; return 2;
if (type == LocationType.POI)
return 4;
if (type == LocationType.ANY) if (type == LocationType.ANY)
return 255; return 255;
throw new IllegalArgumentException(type.toString()); throw new IllegalArgumentException(type.toString());
@ -214,7 +212,7 @@ public class OebbProvider extends AbstractHafasProvider
private static String locationValue(final Location location) private static String locationValue(final Location location)
{ {
if (location.type == LocationType.STATION && location.id != 0) if ((location.type == LocationType.STATION || location.type == LocationType.POI) && location.id != 0)
return Integer.toString(location.id); return Integer.toString(location.id);
else else
return location.name; return location.name;