Hafas: Support POIs for JSON trips query.

This commit is contained in:
Andreas Schildbach 2016-10-12 12:56:21 +02:00
parent 879de41cf7
commit 459dd5743f
2 changed files with 12 additions and 1 deletions

View file

@ -1241,6 +1241,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
return "{\"type\":\"S\",\"extId\":" + JSONObject.quote(location.id) + "}";
else if (location.type == LocationType.ADDRESS && location.hasId())
return "{\"type\":\"A\",\"lid\":" + JSONObject.quote(location.id) + "}";
else if (location.type == LocationType.POI && location.hasId())
return "{\"type\":\"P\",\"lid\":" + JSONObject.quote(location.id) + "}";
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@ -1332,7 +1334,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider {
placeAndName[1], products));
} else if ("P".equals(type)) {
final String[] placeAndName = splitPOI(loc.getString("name"));
final String id = normalizeStationId(loc.getString("extId"));
final String id = loc.getString("lid");
locations.add(new Location(LocationType.POI, id, crd.getInt("y"), crd.getInt("x"), placeAndName[0],
placeAndName[1]));
} else if ("A".equals(type)) {

View file

@ -123,6 +123,15 @@ public class ShProviderLiveTest extends AbstractProviderLiveTest {
print(result);
}
@Test
public void tripKielPoi() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "3490015"), null,
new Location(LocationType.POI,
"A=4@O=Kiel, Hiroshimapark@X=10131697@Y=54324466@U=104@L=970001375@B=1@V=14.9,@p=1397713274@"),
new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
}
@Test
public void trip_errorTooClose() throws Exception {
final Location station = new Location(LocationType.STATION, "003665026");