From fa98ef4bbd78752b75bdba033a58ec4af70f37e3 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Mon, 17 Dec 2018 19:02:38 +0100 Subject: [PATCH] AbstractEfaProvider: Support poiIDs in mobile API. --- .../schildbach/pte/AbstractEfaProvider.java | 11 +++++----- .../pte/live/BayernProviderLiveTest.java | 22 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 102957e3..bbf84197 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -407,7 +407,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { final String id = XmlPullUtil.valueTag(pp, "id"); XmlPullUtil.optValueTag(pp, "gid", null); - XmlPullUtil.valueTag(pp, "stateless"); + final String stateless = XmlPullUtil.valueTag(pp, "stateless"); XmlPullUtil.valueTag(pp, "omc"); final String place = normalizeLocationName(XmlPullUtil.optValueTag(pp, "pc", null)); XmlPullUtil.valueTag(pp, "pid"); @@ -420,7 +420,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { XmlPullUtil.skipExit(pp, "p"); - final Location location = new Location(type, type == LocationType.STATION ? id : null, + final Location location = new Location(type, type == LocationType.STATION ? id : stateless, coord, place, name); final SuggestedLocation locationAndQuality = new SuggestedLocation(location, quality); locations.add(locationAndQuality); @@ -572,14 +572,15 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { XmlPullUtil.valueTag(pp, "layer"); XmlPullUtil.valueTag(pp, "gisID"); XmlPullUtil.valueTag(pp, "ds"); - XmlPullUtil.valueTag(pp, "stateless"); + final String stateless = XmlPullUtil.valueTag(pp, "stateless"); + final String locationId = locationType == LocationType.STATION ? id : stateless; final Point coord = parseCoord(XmlPullUtil.valueTag(pp, "c")); final Location location; if (name != null) - location = new Location(locationType, id, coord, place, name); + location = new Location(locationType, locationId, coord, place, name); else - location = new Location(locationType, id, coord, null, place); + location = new Location(locationType, locationId, coord, null, place); stations.add(location); XmlPullUtil.skipExit(pp, "pi"); diff --git a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java index 9a0f8bfd..54e36bec 100644 --- a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java @@ -96,6 +96,14 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1000921"))); } + @Test + public void suggestLocationsPOI() throws Exception { + final SuggestLocationsResult result = suggestLocations("Ruhpolding, Seehaus"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.POI, + "poiID:40499046:9189140:-1:Seehaus:Ruhpolding:Seehaus:ANY:POI:1405062:5941100:MRCV:BAY"))); + } + @Test public void suggestLocationsAddress() throws Exception { final SuggestLocationsResult result = suggestLocations("München, Friedenstraße 2"); @@ -195,16 +203,14 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenPOIs() throws Exception { - final Location from = new Location(LocationType.POI, null, Point.from1E6(47710568, 12621970), null, - "Ruhpolding, Seehaus"); - final Location to = new Location(LocationType.POI, null, Point.from1E6(47738372, 12630996), null, - "Ruhpolding, Unternberg-Bahn"); + final Location from = new Location(LocationType.POI, + "poiID:40499046:9189140:-1:Seehaus:Ruhpolding:Seehaus:ANY:POI:1405062:5941100:MRCV:BAY", "Ruhpolding", + "Seehaus"); + final Location to = new Location(LocationType.POI, + "poiID:40215904:9189140:-1:Alpengasthof Laubau:Ruhpolding:Alpengasthof Laubau:ANY:POI:1409082:5938642:MRCV:BAY", + "Ruhpolding", "Alpengasthof Laubau"); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - - if (!result.context.canQueryLater()) - return; - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); }