AbstractEfaProvider: Support poiIDs in mobile API.

This commit is contained in:
Andreas Schildbach 2018-12-17 19:02:38 +01:00
parent de4a94014a
commit fa98ef4bbd
2 changed files with 20 additions and 13 deletions

View file

@ -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");

View file

@ -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);
}