diff --git a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java index 5a0f962d..73553698 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java @@ -89,6 +89,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider private String accessId; private String clientType; private Charset jsonGetStopsEncoding; + private boolean jsonGetStopsUseWeight = true; private Charset jsonNearbyStationsEncoding; private boolean dominantPlanStopTime = false; private boolean useIso8601 = false; @@ -183,6 +184,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider this.jsonGetStopsEncoding = jsonGetStopsEncoding; } + protected void setJsonGetStopsUseWeight(final boolean jsonGetStopsUseWeight) + { + this.jsonGetStopsUseWeight = jsonGetStopsUseWeight; + } + protected void setJsonNearbyStationsEncoding(final Charset jsonNearbyStationsEncoding) { this.jsonNearbyStationsEncoding = jsonNearbyStationsEncoding; @@ -372,7 +378,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider final String value = suggestion.getString("value"); final int lat = suggestion.optInt("ycoord"); final int lon = suggestion.optInt("xcoord"); - final int weight = suggestion.getInt("weight"); + final int weight = jsonGetStopsUseWeight ? suggestion.getInt("weight") : -i; String localId = null; final Matcher m = P_AJAX_GET_STOPS_ID.matcher(suggestion.getString("id")); if (m.matches()) diff --git a/enabler/src/de/schildbach/pte/BvgProvider.java b/enabler/src/de/schildbach/pte/BvgProvider.java index 14ee7206..d62fd7ac 100644 --- a/enabler/src/de/schildbach/pte/BvgProvider.java +++ b/enabler/src/de/schildbach/pte/BvgProvider.java @@ -63,6 +63,7 @@ public final class BvgProvider extends AbstractHafasProvider super(API_BASE + "stboard.bin/dn", API_BASE + "ajax-getstop.bin/dny", API_BASE + "query.bin/dn", 8, UTF_8); setStyles(STYLES); + setJsonGetStopsUseWeight(false); this.additionalQueryParameter = additionalQueryParameter; } diff --git a/enabler/src/de/schildbach/pte/dto/Location.java b/enabler/src/de/schildbach/pte/dto/Location.java index 31c0f1fa..6a7642d4 100644 --- a/enabler/src/de/schildbach/pte/dto/Location.java +++ b/enabler/src/de/schildbach/pte/dto/Location.java @@ -155,7 +155,11 @@ public final class Location implements Serializable return this.id.equals(other.id); if (this.lat != 0 && this.lon != 0) return this.lat == other.lat && this.lon == other.lon; - if (!nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given + + // only discriminate by name/place if no ids are given + if (!nullSafeEquals(this.name, other.name)) + return false; + if (!nullSafeEquals(this.place, other.place)) return false; return true; } diff --git a/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java index 8cb855a5..dbf70f14 100644 --- a/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java @@ -100,6 +100,16 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest Assert.assertEquals("Güntzelstr. (U)", result.getLocations().get(0).name); } + @Test + public void suggestLocationsLocality() throws Exception + { + final SuggestLocationsResult result = provider.suggestLocations("seeling"); + + print(result); + + Assert.assertEquals(new Location(LocationType.STATION, null, "Berlin", "Seelingstr."), result.getLocations().get(0)); + } + @Test public void suggestLocationsAddress() throws Exception {