From 7e33f3eb1dc5edb72e9e9a7c41753f75d4d6f096 Mon Sep 17 00:00:00 2001 From: "andreas.schildbach" Date: Mon, 11 Oct 2010 09:35:44 +0000 Subject: [PATCH] fixed geocoding of POIs git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@278 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/OebbProvider.java | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/de/schildbach/pte/OebbProvider.java b/src/de/schildbach/pte/OebbProvider.java index a433635e..f9536398 100644 --- a/src/de/schildbach/pte/OebbProvider.java +++ b/src/de/schildbach/pte/OebbProvider.java @@ -86,28 +86,24 @@ public class OebbProvider extends AbstractHafasProvider { final int type = suggestion.getInt("type"); 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 { - final String id = suggestion.getString("id"); - 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); - } + results.add(new Location(LocationType.STATION, localId, lat, lon, value)); } 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 { - results.add(new Location(LocationType.ANY, 0, 0, 0, value)); + results.add(new Location(LocationType.POI, localId, lat, lon, value)); } else { @@ -207,6 +203,8 @@ public class OebbProvider extends AbstractHafasProvider return 1; if (type == LocationType.ADDRESS) return 2; + if (type == LocationType.POI) + return 4; if (type == LocationType.ANY) return 255; throw new IllegalArgumentException(type.toString()); @@ -214,7 +212,7 @@ public class OebbProvider extends AbstractHafasProvider 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); else return location.name;