EFA: Fix parsing of itdOdv and handling of location IDs.

This commit is contained in:
Andreas Schildbach 2015-01-12 12:47:46 +01:00
parent 64df076576
commit bb03f45f53
14 changed files with 406 additions and 436 deletions

View file

@ -33,6 +33,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -87,7 +88,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
private String additionalQueryParameter = null; private String additionalQueryParameter = null;
private boolean useRealtime = true; private boolean useRealtime = true;
private boolean canAcceptPoiId = false;
private boolean needsSpEncId = false; private boolean needsSpEncId = false;
private boolean includeRegionId = true; private boolean includeRegionId = true;
private boolean useProxFootSearch = true; private boolean useProxFootSearch = true;
@ -216,11 +216,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
this.useStringCoordListOutputFormat = useStringCoordListOutputFormat; this.useStringCoordListOutputFormat = useStringCoordListOutputFormat;
} }
protected void setCanAcceptPoiId(final boolean canAcceptPoiId)
{
this.canAcceptPoiId = canAcceptPoiId;
}
protected void setNeedsSpEncId(final boolean needsSpEncId) protected void setNeedsSpEncId(final boolean needsSpEncId)
{ {
this.needsSpEncId = needsSpEncId; this.needsSpEncId = needsSpEncId;
@ -240,6 +235,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
private final void appendCommonRequestParams(final StringBuilder uri, final String outputFormat) private final void appendCommonRequestParams(final StringBuilder uri, final String outputFormat)
{ {
uri.append("?outputFormat=").append(outputFormat); uri.append("?outputFormat=").append(outputFormat);
uri.append("&stateless=1");
uri.append("&coordOutputFormat=WGS84"); uri.append("&coordOutputFormat=WGS84");
if (additionalQueryParameter != null) if (additionalQueryParameter != null)
uri.append('&').append(additionalQueryParameter); uri.append('&').append(additionalQueryParameter);
@ -306,8 +302,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
String type = stop.getString("type"); String type = stop.getString("type");
if ("any".equals(type)) if ("any".equals(type))
type = stop.getString("anyType"); type = stop.getString("anyType");
final String id = stop.getString("stateless");
final String name = normalizeLocationName(stop.optString("name")); final String name = normalizeLocationName(stop.optString("name"));
final String object = normalizeLocationName(stop.optString("object")); final String object = normalizeLocationName(stop.optString("object"));
final String postcode = stop.optString("postcode");
final int quality = stop.getInt("quality"); final int quality = stop.getInt("quality");
final JSONObject ref = stop.getJSONObject("ref"); final JSONObject ref = stop.getJSONObject("ref");
String place = ref.getString("place"); String place = ref.getString("place");
@ -330,13 +328,15 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Location location; final Location location;
if ("stop".equals(type)) if ("stop".equals(type))
location = new Location(LocationType.STATION, stop.getString("stateless"), lat, lon, place, object); location = new Location(LocationType.STATION, id, lat, lon, place, object);
else if ("poi".equals(type)) else if ("poi".equals(type))
location = new Location(LocationType.POI, null, lat, lon, place, object); location = new Location(LocationType.POI, id, lat, lon, place, object);
else if ("crossing".equals(type)) else if ("crossing".equals(type))
location = new Location(LocationType.ADDRESS, null, lat, lon, place, object); location = new Location(LocationType.ADDRESS, id, lat, lon, place, object);
else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type) || "buildingname".equals(type)) else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type) || "buildingname".equals(type))
location = new Location(LocationType.ADDRESS, null, lat, lon, place, name); location = new Location(LocationType.ADDRESS, id, lat, lon, place, name);
else if ("postcode".equals(type))
location = new Location(LocationType.ADDRESS, id, lat, lon, place, postcode);
else else
throw new JSONException("unknown type: " + type); throw new JSONException("unknown type: " + type);
@ -392,42 +392,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "itdStopFinderRequest"); XmlPullUtil.enter(pp, "itdStopFinderRequest");
XmlPullUtil.require(pp, "itdOdv"); processItdOdv(pp, "sf", new ProcessItdOdvCallback()
if (!"sf".equals(pp.getAttributeValue(null, "usage")))
throw new IllegalStateException("cannot find <itdOdv usage=\"sf\" />");
XmlPullUtil.enter(pp, "itdOdv");
XmlPullUtil.require(pp, "itdOdvPlace");
XmlPullUtil.next(pp);
XmlPullUtil.require(pp, "itdOdvName");
final String nameState = pp.getAttributeValue(null, "state");
XmlPullUtil.enter(pp, "itdOdvName");
if (XmlPullUtil.test(pp, "itdMessage"))
XmlPullUtil.next(pp);
if ("identified".equals(nameState) || "list".equals(nameState))
{ {
while (XmlPullUtil.test(pp, "odvNameElem")) public void location(final String nameState, final Location location, final int matchQuality)
{ {
final int matchQuality = XmlPullUtil.intAttr(pp, "matchQuality");
final Location location = processOdvNameElem(pp, null);
locations.add(new SuggestedLocation(location, matchQuality)); locations.add(new SuggestedLocation(location, matchQuality));
} }
} });
else if ("notidentified".equals(nameState))
{
// do nothing
}
else
{
throw new RuntimeException("unknown nameState '" + nameState + "' on " + uri);
}
XmlPullUtil.skipExit(pp, "itdOdvName");
XmlPullUtil.skipExit(pp, "itdOdv");
XmlPullUtil.skipExit(pp, "itdStopFinderRequest"); XmlPullUtil.skipExit(pp, "itdStopFinderRequest");
@ -705,6 +676,93 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
return jsonStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString())); return jsonStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString()));
} }
private interface ProcessItdOdvCallback
{
void location(String nameState, Location location, int matchQuality);
}
private String processItdOdv(final XmlPullParser pp, final String expectedUsage, final ProcessItdOdvCallback callback)
throws XmlPullParserException, IOException
{
if (!XmlPullUtil.test(pp, "itdOdv"))
throw new IllegalStateException("expecting <itdOdv />");
final String usage = XmlPullUtil.attr(pp, "usage");
if (expectedUsage != null && !usage.equals(expectedUsage))
throw new IllegalStateException("expecting <itdOdv usage=\"" + expectedUsage + "\" />");
final String type = XmlPullUtil.attr(pp, "type");
XmlPullUtil.enter(pp, "itdOdv");
final String place = processItdOdvPlace(pp);
XmlPullUtil.require(pp, "itdOdvName");
final String nameState = XmlPullUtil.attr(pp, "state");
XmlPullUtil.enter(pp, "itdOdvName");
XmlPullUtil.optSkip(pp, "itdMessage");
if ("identified".equals(nameState))
{
final Location location = processOdvNameElem(pp, type, place);
if (location != null)
callback.location(nameState, location, Integer.MAX_VALUE);
}
else if ("list".equals(nameState))
{
while (XmlPullUtil.test(pp, "odvNameElem"))
{
final int matchQuality = XmlPullUtil.intAttr(pp, "matchQuality");
final Location location = processOdvNameElem(pp, type, place);
if (location != null)
callback.location(nameState, location, matchQuality);
}
}
else if ("notidentified".equals(nameState) || "empty".equals(nameState))
{
XmlPullUtil.optSkip(pp, "odvNameElem");
}
else
{
throw new RuntimeException("cannot handle nameState '" + nameState + "'");
}
while (XmlPullUtil.test(pp, "infoLink"))
XmlPullUtil.requireSkip(pp, "infoLink");
XmlPullUtil.optSkip(pp, "odvNameInput");
XmlPullUtil.exit(pp, "itdOdvName");
XmlPullUtil.optSkip(pp, "odvInfoList");
XmlPullUtil.optSkip(pp, "itdPoiHierarchyRoot");
if (XmlPullUtil.test(pp, "itdOdvAssignedStops"))
{
XmlPullUtil.enter(pp, "itdOdvAssignedStops");
while (XmlPullUtil.test(pp, "itdOdvAssignedStop"))
{
final Location stop = processItdOdvAssignedStop(pp);
if (stop != null)
callback.location("assigned", stop, 0);
}
XmlPullUtil.exit(pp, "itdOdvAssignedStops");
}
XmlPullUtil.optSkip(pp, "itdServingModes");
XmlPullUtil.optSkip(pp, "genAttrList");
XmlPullUtil.exit(pp, "itdOdv");
return nameState;
}
private String processItdOdvPlace(final XmlPullParser pp) throws XmlPullParserException, IOException private String processItdOdvPlace(final XmlPullParser pp) throws XmlPullParserException, IOException
{ {
if (!XmlPullUtil.test(pp, "itdOdvPlace")) if (!XmlPullUtil.test(pp, "itdOdvPlace"))
@ -724,25 +782,24 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
return place; return place;
} }
private Location processOdvNameElem(final XmlPullParser pp, final String defaultPlace) throws XmlPullParserException, IOException private Location processOdvNameElem(final XmlPullParser pp, String type, final String defaultPlace) throws XmlPullParserException, IOException
{ {
if (!XmlPullUtil.test(pp, "odvNameElem")) if (!XmlPullUtil.test(pp, "odvNameElem"))
throw new IllegalStateException("expecting <odvNameElem />"); throw new IllegalStateException("expecting <odvNameElem />");
final String anyType = pp.getAttributeValue(null, "anyType"); if ("any".equals(type))
final String idStr = pp.getAttributeValue(null, "id"); type = XmlPullUtil.attr(pp, "anyType");
final String stopIdStr = pp.getAttributeValue(null, "stopID"); final String id = XmlPullUtil.attr(pp, "stateless");
final String poiIdStr = pp.getAttributeValue(null, "poiID");
final String streetIdStr = pp.getAttributeValue(null, "streetID");
final String locality = normalizeLocationName(pp.getAttributeValue(null, "locality")); final String locality = normalizeLocationName(pp.getAttributeValue(null, "locality"));
final String objectName = normalizeLocationName(pp.getAttributeValue(null, "objectName")); final String objectName = normalizeLocationName(pp.getAttributeValue(null, "objectName"));
final String buildingName = XmlPullUtil.optAttr(pp, "buildingName", null);
final String buildingNumber = XmlPullUtil.optAttr(pp, "buildingNumber", null);
final String postCode = XmlPullUtil.optAttr(pp, "postCode", null);
final String mapName = XmlPullUtil.optAttr(pp, "mapName", null); final String mapName = XmlPullUtil.optAttr(pp, "mapName", null);
final float x = XmlPullUtil.optFloatAttr(pp, "x", 0); final float x = XmlPullUtil.optFloatAttr(pp, "x", 0);
final float y = XmlPullUtil.optFloatAttr(pp, "y", 0); final float y = XmlPullUtil.optFloatAttr(pp, "y", 0);
final String elemName = normalizeLocationName(XmlPullUtil.valueTag(pp, "odvNameElem"));
final int lat; final int lat;
final int lon; final int lon;
@ -761,83 +818,64 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y); throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y);
} }
final LocationType type; final String nameElem = normalizeLocationName(XmlPullUtil.valueTag(pp, "odvNameElem"));
final String id;
final LocationType locationType;
final String place; final String place;
final String name; final String name;
if ("stop".equals(anyType)) if ("stop".equals(type))
{ {
type = LocationType.STATION; locationType = LocationType.STATION;
id = idStr;
place = locality; place = locality;
name = objectName; name = objectName;
} }
else if ("poi".equals(anyType) || "poiHierarchy".equals(anyType)) else if ("poi".equals(type))
{ {
type = LocationType.POI; locationType = LocationType.POI;
id = idStr;
place = locality; place = locality;
name = objectName; name = objectName;
} }
else if ("loc".equals(anyType)) else if ("loc".equals(type))
{ {
type = LocationType.ANY; return null;
id = null;
place = locality;
name = locality;
} }
else if ("address".equals(anyType)) else if ("address".equals(type) || "singlehouse".equals(type))
{ {
type = LocationType.ADDRESS; locationType = LocationType.ADDRESS;
id = null; place = locality;
name = objectName + (buildingNumber != null ? " " + buildingNumber : "");
}
else if ("street".equals(type) || "crossing".equals(type))
{
locationType = LocationType.ADDRESS;
place = locality; place = locality;
name = objectName; name = objectName;
} }
else if ("postcode".equals(anyType) || "street".equals(anyType) || "crossing".equals(anyType) || "singlehouse".equals(anyType) else if ("postcode".equals(type))
|| "buildingname".equals(anyType))
{ {
type = LocationType.ADDRESS; locationType = LocationType.ADDRESS;
id = null;
place = locality; place = locality;
name = objectName; name = postCode;
} }
else if (anyType == null || "unknown".equals(anyType)) else if ("buildingname".equals(type))
{ {
if (stopIdStr != null) locationType = LocationType.ADDRESS;
{
type = LocationType.STATION;
id = stopIdStr;
}
else if (poiIdStr != null)
{
type = LocationType.POI;
id = poiIdStr;
}
else if (streetIdStr != null)
{
type = LocationType.ADDRESS;
id = streetIdStr;
}
else if (lat != 0 || lon != 0)
{
type = LocationType.ADDRESS;
id = null;
}
else
{
throw new IllegalArgumentException("cannot substitute type");
}
place = locality; place = locality;
name = objectName; name = buildingName;
}
else if ("coord".equals(type))
{
locationType = LocationType.ADDRESS;
place = defaultPlace;
name = nameElem;
} }
else else
{ {
throw new IllegalArgumentException("unknown type: " + anyType); throw new IllegalArgumentException("unknown type/anyType: " + type);
} }
return new Location(type, id, lat, lon, place != null ? place : defaultPlace, name != null ? name : elemName); return new Location(locationType, id, lat, lon, place != null ? place : defaultPlace, name != null ? name : nameElem);
} }
private Location processItdOdvAssignedStop(final XmlPullParser pp) throws XmlPullParserException, IOException private Location processItdOdvAssignedStop(final XmlPullParser pp) throws XmlPullParserException, IOException
@ -923,71 +961,33 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest"); XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
if (!XmlPullUtil.test(pp, "itdOdv") || !"dm".equals(pp.getAttributeValue(null, "usage"))) final AtomicReference<Location> ownStation = new AtomicReference<Location>();
throw new IllegalStateException("cannot find <itdOdv usage=\"dm\" />"); final List<Location> stations = new ArrayList<Location>();
XmlPullUtil.enter(pp, "itdOdv");
final String place = processItdOdvPlace(pp); final String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback()
XmlPullUtil.require(pp, "itdOdvName");
final String nameState = pp.getAttributeValue(null, "state");
XmlPullUtil.enter(pp, "itdOdvName");
if ("identified".equals(nameState))
{ {
final Location ownLocation = processOdvNameElem(pp, place); public void location(final String nameState, final Location location, final int matchQuality)
final Location ownStation = ownLocation.type == LocationType.STATION ? ownLocation : null;
XmlPullUtil.skipExit(pp, "itdOdvName");
final List<Location> stations = new ArrayList<Location>();
if (XmlPullUtil.test(pp, "itdOdvAssignedStops"))
{ {
XmlPullUtil.enter(pp, "itdOdvAssignedStops"); if (location.type == LocationType.STATION)
while (XmlPullUtil.test(pp, "itdOdvAssignedStop"))
{ {
final Location newStation = processItdOdvAssignedStop(pp); if ("identified".equals(nameState))
ownStation.set(location);
if (newStation != null && !stations.contains(newStation)) else if ("assigned".equals(nameState))
stations.add(newStation); stations.add(location);
} }
XmlPullUtil.skipExit(pp, "itdOdvAssignedStops");
} }
});
XmlPullUtil.skipExit(pp, "itdOdv"); if ("notidentified".equals(nameState))
if (ownStation != null && !stations.contains(ownStation))
stations.add(ownStation);
if (maxStations == 0 || maxStations >= stations.size())
return new NearbyStationsResult(header, stations);
else
return new NearbyStationsResult(header, stations.subList(0, maxStations));
}
else if ("list".equals(nameState))
{
final List<Location> stations = new ArrayList<Location>();
if (XmlPullUtil.test(pp, "itdMessage"))
XmlPullUtil.next(pp);
while (XmlPullUtil.test(pp, "odvNameElem"))
{
final Location newLocation = processOdvNameElem(pp, place);
if (newLocation.type == LocationType.STATION && !stations.contains(newLocation))
stations.add(newLocation);
}
return new NearbyStationsResult(header, stations);
}
else if ("notidentified".equals(nameState))
{
return new NearbyStationsResult(header, NearbyStationsResult.Status.INVALID_STATION); return new NearbyStationsResult(header, NearbyStationsResult.Status.INVALID_STATION);
}
if (ownStation.get() != null && !stations.contains(ownStation))
stations.add(ownStation.get());
if (maxStations == 0 || maxStations >= stations.size())
return new NearbyStationsResult(header, stations);
else else
{ return new NearbyStationsResult(header, stations.subList(0, maxStations));
throw new RuntimeException("unknown nameState '" + nameState + "' on " + uri);
}
// XmlPullUtil.exit(pp, "itdOdvName");
} }
catch (final XmlPullParserException x) catch (final XmlPullParserException x)
{ {
@ -1507,186 +1507,153 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
pp.setInput(is, null); pp.setInput(is, null);
final ResultHeader header = enterItdRequest(pp); final ResultHeader header = enterItdRequest(pp);
final QueryDeparturesResult result = new QueryDeparturesResult(header);
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest"); XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
if (XmlPullUtil.test(pp, "itdMessage")) XmlPullUtil.optSkip(pp, "itdMessage");
XmlPullUtil.next(pp);
if (!XmlPullUtil.test(pp, "itdOdv") || !"dm".equals(XmlPullUtil.attr(pp, "usage"))) final String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback()
throw new IllegalStateException("cannot find <itdOdv usage=\"dm\" />, first chars: " + firstChars);
XmlPullUtil.enter(pp, "itdOdv");
final String place = processItdOdvPlace(pp);
XmlPullUtil.require(pp, "itdOdvName");
final String nameState = pp.getAttributeValue(null, "state");
XmlPullUtil.enter(pp, "itdOdvName");
if ("identified".equals(nameState))
{ {
final QueryDeparturesResult result = new QueryDeparturesResult(header); public void location(final String nameState, final Location location, final int matchQuality)
final Location location = processOdvNameElem(pp, place);
result.stationDepartures.add(new StationDepartures(location, new LinkedList<Departure>(), new LinkedList<LineDestination>()));
XmlPullUtil.skipExit(pp, "itdOdvName");
if (XmlPullUtil.test(pp, "itdOdvAssignedStops"))
{ {
XmlPullUtil.enter(pp, "itdOdvAssignedStops"); if (location.type == LocationType.STATION)
while (XmlPullUtil.test(pp, "itdOdvAssignedStop")) if (findStationDepartures(result.stationDepartures, location.id) == null)
{ result.stationDepartures.add(new StationDepartures(location, new LinkedList<Departure>(),
final Location assignedLocation = processItdOdvAssignedStop(pp); new LinkedList<LineDestination>()));
if (assignedLocation != null)
if (findStationDepartures(result.stationDepartures, assignedLocation.id) == null)
result.stationDepartures.add(new StationDepartures(assignedLocation, new LinkedList<Departure>(),
new LinkedList<LineDestination>()));
}
XmlPullUtil.skipExit(pp, "itdOdvAssignedStops");
} }
});
XmlPullUtil.skipExit(pp, "itdOdv"); if ("notidentified".equals(nameState) || "list".equals(nameState))
if (XmlPullUtil.test(pp, "itdDateTime"))
XmlPullUtil.next(pp);
if (XmlPullUtil.test(pp, "itdDMDateTime"))
XmlPullUtil.next(pp);
if (XmlPullUtil.test(pp, "itdDateRange"))
XmlPullUtil.next(pp);
if (XmlPullUtil.test(pp, "itdTripOptions"))
XmlPullUtil.next(pp);
if (XmlPullUtil.test(pp, "itdMessage"))
XmlPullUtil.next(pp);
final Calendar plannedDepartureTime = new GregorianCalendar(timeZone);
final Calendar predictedDepartureTime = new GregorianCalendar(timeZone);
XmlPullUtil.require(pp, "itdServingLines");
if (!pp.isEmptyElementTag())
{
XmlPullUtil.enter(pp, "itdServingLines");
while (XmlPullUtil.test(pp, "itdServingLine"))
{
final String assignedStopId = pp.getAttributeValue(null, "assignedStopID");
final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final String destinationId = XmlPullUtil.optAttr(pp, "destID", null);
final Location destination = new Location(destinationId != null ? LocationType.STATION : LocationType.ANY, destinationId,
null, destinationName);
final LineDestination line = new LineDestination(processItdServingLine(pp), destination);
StationDepartures assignedStationDepartures;
if (assignedStopId == null)
assignedStationDepartures = result.stationDepartures.get(0);
else
assignedStationDepartures = findStationDepartures(result.stationDepartures, assignedStopId);
if (assignedStationDepartures == null)
assignedStationDepartures = new StationDepartures(new Location(LocationType.STATION, assignedStopId),
new LinkedList<Departure>(), new LinkedList<LineDestination>());
if (!assignedStationDepartures.lines.contains(line))
assignedStationDepartures.lines.add(line);
}
XmlPullUtil.skipExit(pp, "itdServingLines");
}
else
{
XmlPullUtil.next(pp);
}
XmlPullUtil.require(pp, "itdDepartureList");
if (!pp.isEmptyElementTag())
{
XmlPullUtil.enter(pp, "itdDepartureList");
while (XmlPullUtil.test(pp, "itdDeparture"))
{
final String assignedStopId = XmlPullUtil.attr(pp, "stopID");
StationDepartures assignedStationDepartures = findStationDepartures(result.stationDepartures, assignedStopId);
if (assignedStationDepartures == null)
{
final String mapName = XmlPullUtil.optAttr(pp, "mapName", null);
final float x = XmlPullUtil.optFloatAttr(pp, "x", 0);
final float y = XmlPullUtil.optFloatAttr(pp, "y", 0);
final int lat;
final int lon;
if (mapName == null || (x == 0 && y == 0))
{
lat = 0;
lon = 0;
}
else if ("WGS84".equals(mapName))
{
lat = Math.round(y);
lon = Math.round(x);
}
else
{
throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y);
}
// final String name = normalizeLocationName(XmlPullUtil.attr(pp, "nameWO"));
assignedStationDepartures = new StationDepartures(new Location(LocationType.STATION, assignedStopId, lat, lon),
new LinkedList<Departure>(), new LinkedList<LineDestination>());
}
final Position position = normalizePlatformName(XmlPullUtil.optAttr(pp, "platformName", null));
XmlPullUtil.enter(pp, "itdDeparture");
XmlPullUtil.require(pp, "itdDateTime");
plannedDepartureTime.clear();
processItdDateTime(pp, plannedDepartureTime);
predictedDepartureTime.clear();
if (XmlPullUtil.test(pp, "itdRTDateTime"))
processItdDateTime(pp, predictedDepartureTime);
if (XmlPullUtil.test(pp, "itdFrequencyInfo"))
XmlPullUtil.next(pp);
XmlPullUtil.require(pp, "itdServingLine");
final boolean isRealtime = pp.getAttributeValue(null, "realtime").equals("1");
final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final String destinationIdStr = XmlPullUtil.optAttr(pp, "destID", null);
final String destinationId = !"-1".equals(destinationIdStr) ? destinationIdStr : null;
final Location destination = new Location(destinationId != null ? LocationType.STATION : LocationType.ANY, destinationId,
null, destinationName);
final Line line = processItdServingLine(pp);
if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY))
predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis());
XmlPullUtil.skipExit(pp, "itdDeparture");
final Departure departure = new Departure(plannedDepartureTime.getTime(),
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position,
destination, null, null);
assignedStationDepartures.departures.add(departure);
}
XmlPullUtil.skipExit(pp, "itdDepartureList");
}
else
{
XmlPullUtil.next(pp);
}
return result;
}
else if ("notidentified".equals(nameState) || "list".equals(nameState))
{
return new QueryDeparturesResult(header, QueryDeparturesResult.Status.INVALID_STATION); return new QueryDeparturesResult(header, QueryDeparturesResult.Status.INVALID_STATION);
XmlPullUtil.optSkip(pp, "itdDateTime");
XmlPullUtil.optSkip(pp, "itdDMDateTime");
XmlPullUtil.optSkip(pp, "itdDateRange");
XmlPullUtil.optSkip(pp, "itdTripOptions");
XmlPullUtil.optSkip(pp, "itdMessage");
final Calendar plannedDepartureTime = new GregorianCalendar(timeZone);
final Calendar predictedDepartureTime = new GregorianCalendar(timeZone);
XmlPullUtil.require(pp, "itdServingLines");
if (!pp.isEmptyElementTag())
{
XmlPullUtil.enter(pp, "itdServingLines");
while (XmlPullUtil.test(pp, "itdServingLine"))
{
final String assignedStopId = pp.getAttributeValue(null, "assignedStopID");
final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final String destinationId = XmlPullUtil.optAttr(pp, "destID", null);
final Location destination = new Location(destinationId != null ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final LineDestination line = new LineDestination(processItdServingLine(pp), destination);
StationDepartures assignedStationDepartures;
if (assignedStopId == null)
assignedStationDepartures = result.stationDepartures.get(0);
else
assignedStationDepartures = findStationDepartures(result.stationDepartures, assignedStopId);
if (assignedStationDepartures == null)
assignedStationDepartures = new StationDepartures(new Location(LocationType.STATION, assignedStopId),
new LinkedList<Departure>(), new LinkedList<LineDestination>());
if (!assignedStationDepartures.lines.contains(line))
assignedStationDepartures.lines.add(line);
}
XmlPullUtil.skipExit(pp, "itdServingLines");
} }
else else
{ {
throw new RuntimeException("unknown nameState '" + nameState + "' on " + uri); XmlPullUtil.next(pp);
} }
XmlPullUtil.require(pp, "itdDepartureList");
if (!pp.isEmptyElementTag())
{
XmlPullUtil.enter(pp, "itdDepartureList");
while (XmlPullUtil.test(pp, "itdDeparture"))
{
final String assignedStopId = XmlPullUtil.attr(pp, "stopID");
StationDepartures assignedStationDepartures = findStationDepartures(result.stationDepartures, assignedStopId);
if (assignedStationDepartures == null)
{
final String mapName = XmlPullUtil.optAttr(pp, "mapName", null);
final float x = XmlPullUtil.optFloatAttr(pp, "x", 0);
final float y = XmlPullUtil.optFloatAttr(pp, "y", 0);
final int lat;
final int lon;
if (mapName == null || (x == 0 && y == 0))
{
lat = 0;
lon = 0;
}
else if ("WGS84".equals(mapName))
{
lat = Math.round(y);
lon = Math.round(x);
}
else
{
throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y);
}
// final String name = normalizeLocationName(XmlPullUtil.attr(pp, "nameWO"));
assignedStationDepartures = new StationDepartures(new Location(LocationType.STATION, assignedStopId, lat, lon),
new LinkedList<Departure>(), new LinkedList<LineDestination>());
}
final Position position = normalizePlatformName(XmlPullUtil.optAttr(pp, "platformName", null));
XmlPullUtil.enter(pp, "itdDeparture");
XmlPullUtil.require(pp, "itdDateTime");
plannedDepartureTime.clear();
processItdDateTime(pp, plannedDepartureTime);
predictedDepartureTime.clear();
if (XmlPullUtil.test(pp, "itdRTDateTime"))
processItdDateTime(pp, predictedDepartureTime);
if (XmlPullUtil.test(pp, "itdFrequencyInfo"))
XmlPullUtil.next(pp);
XmlPullUtil.require(pp, "itdServingLine");
final boolean isRealtime = pp.getAttributeValue(null, "realtime").equals("1");
final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final String destinationIdStr = XmlPullUtil.optAttr(pp, "destID", null);
final String destinationId = !"-1".equals(destinationIdStr) ? destinationIdStr : null;
final Location destination = new Location(destinationId != null ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final Line line = processItdServingLine(pp);
if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY))
predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis());
XmlPullUtil.skipExit(pp, "itdDeparture");
final Departure departure = new Departure(plannedDepartureTime.getTime(),
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position,
destination, null, null);
assignedStationDepartures.departures.add(departure);
}
XmlPullUtil.skipExit(pp, "itdDepartureList");
}
else
{
XmlPullUtil.next(pp);
}
return result;
} }
catch (final XmlPullParserException x) catch (final XmlPullParserException x)
{ {
@ -2337,60 +2304,41 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (XmlPullUtil.test(pp, "itdAddress")) if (XmlPullUtil.test(pp, "itdAddress"))
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
// parse odv name elements
List<Location> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null; List<Location> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
Location from = null, via = null, to = null; Location from = null, via = null, to = null;
while (XmlPullUtil.test(pp, "itdOdv")) while (XmlPullUtil.test(pp, "itdOdv"))
{ {
final String usage = XmlPullUtil.attr(pp, "usage"); final String usage = pp.getAttributeValue(null, "usage");
XmlPullUtil.enter(pp, "itdOdv");
final String place = processItdOdvPlace(pp); final List<Location> locations = new ArrayList<Location>();
final String nameState = processItdOdv(pp, usage, new ProcessItdOdvCallback()
if (!XmlPullUtil.test(pp, "itdOdvName")) {
throw new IllegalStateException("cannot find <itdOdvName /> inside " + usage); public void location(final String nameState, final Location location, final int matchQuality)
final String nameState = XmlPullUtil.attr(pp, "state"); {
XmlPullUtil.enter(pp, "itdOdvName"); locations.add(location);
if (XmlPullUtil.test(pp, "itdMessage")) }
XmlPullUtil.next(pp); });
if ("list".equals(nameState)) if ("list".equals(nameState))
{ {
if ("origin".equals(usage)) if ("origin".equals(usage))
{ ambiguousFrom = locations;
ambiguousFrom = new ArrayList<Location>();
while (XmlPullUtil.test(pp, "odvNameElem"))
ambiguousFrom.add(processOdvNameElem(pp, place));
}
else if ("via".equals(usage)) else if ("via".equals(usage))
{ ambiguousVia = locations;
ambiguousVia = new ArrayList<Location>();
while (XmlPullUtil.test(pp, "odvNameElem"))
ambiguousVia.add(processOdvNameElem(pp, place));
}
else if ("destination".equals(usage)) else if ("destination".equals(usage))
{ ambiguousTo = locations;
ambiguousTo = new ArrayList<Location>();
while (XmlPullUtil.test(pp, "odvNameElem"))
ambiguousTo.add(processOdvNameElem(pp, place));
}
else else
{
throw new IllegalStateException("unknown usage: " + usage); throw new IllegalStateException("unknown usage: " + usage);
}
} }
else if ("identified".equals(nameState)) else if ("identified".equals(nameState))
{ {
if (!XmlPullUtil.test(pp, "odvNameElem"))
throw new IllegalStateException("cannot find <odvNameElem /> inside " + usage);
if ("origin".equals(usage)) if ("origin".equals(usage))
from = processOdvNameElem(pp, place); from = locations.get(0);
else if ("via".equals(usage)) else if ("via".equals(usage))
via = processOdvNameElem(pp, place); via = locations.get(0);
else if ("destination".equals(usage)) else if ("destination".equals(usage))
to = processOdvNameElem(pp, place); to = locations.get(0);
else else
throw new IllegalStateException("unknown usage: " + usage); throw new IllegalStateException("unknown usage: " + usage);
} }
@ -2405,8 +2353,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
else else
throw new IllegalStateException("unknown usage: " + usage); throw new IllegalStateException("unknown usage: " + usage);
} }
XmlPullUtil.skipExit(pp, "itdOdvName");
XmlPullUtil.skipExit(pp, "itdOdv");
} }
if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null) if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null)
@ -3285,12 +3231,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
private void appendLocation(final StringBuilder uri, final Location location, final String paramSuffix) private void appendLocation(final StringBuilder uri, final Location location, final String paramSuffix)
{ {
if (canAcceptPoiId && location.type == LocationType.POI && location.hasId()) if (location.type == LocationType.ADDRESS && location.hasLocation())
{
uri.append("&type_").append(paramSuffix).append("=poiID");
uri.append("&name_").append(paramSuffix).append("=").append(normalizeStationId(location.id));
}
else if ((location.type == LocationType.POI || location.type == LocationType.ADDRESS) && location.hasLocation())
{ {
uri.append("&type_").append(paramSuffix).append("=coord"); uri.append("&type_").append(paramSuffix).append("=coord");
uri.append("&name_").append(paramSuffix).append("=") uri.append("&name_").append(paramSuffix).append("=")
@ -3319,7 +3260,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
protected static final String locationValue(final Location location) protected static final String locationValue(final Location location)
{ {
if ((location.type == LocationType.STATION || location.type == LocationType.POI) && location.hasId()) if (location.type == LocationType.STATION && location.hasId())
return normalizeStationId(location.id);
else if (location.type == LocationType.POI && location.hasId())
return location.id; return location.id;
else else
return location.name; return location.name;

View file

@ -39,6 +39,7 @@ public class VrrProvider extends AbstractEfaProvider
setNeedsSpEncId(true); setNeedsSpEncId(true);
setUseRouteIndexAsTripId(false); setUseRouteIndexAsTripId(false);
setStyles(STYLES); setStyles(STYLES);
setRequestUrlEncoding(UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -35,8 +35,6 @@ public class VvsProvider extends AbstractEfaProvider
public VvsProvider(final String apiBase) public VvsProvider(final String apiBase)
{ {
super(apiBase); super(apiBase);
setCanAcceptPoiId(true);
} }
public NetworkId id() public NetworkId id()

View file

@ -49,7 +49,6 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "90001611")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "90001611"));
print(result); print(result);
} }
@ -57,7 +56,6 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48401092, 9992037)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48401092, 9992037));
print(result); print(result);
} }
@ -65,7 +63,13 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("90001611", false); final QueryDeparturesResult result = queryDepartures("90001611", false);
print(result);
}
@Test
public void suggestLocationsIdentified() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Ulm, Justizgebäude");
print(result); print(result);
} }
@ -73,7 +77,6 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }
@ -81,15 +84,14 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@Test @Test
public void shortTrip() throws Exception public void shortTrip() throws Exception
{ {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "9001011", null, "Justizgebäude"), null, new Location( final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "9001011", "Ulm", "Justizgebäude"), null, new Location(
LocationType.STATION, "2504524", null, "Theater"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL); LocationType.STATION, "9001010", "Ulm", "Theater"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0); assertTrue(result.trips.size() > 0);

View file

@ -49,7 +49,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10001167")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10001167"));
print(result); print(result);
} }
@ -57,7 +56,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, -37800941, 144966545)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, -37800941, 144966545));
print(result); print(result);
} }
@ -65,7 +63,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("10001167", false); final QueryDeparturesResult result = queryDepartures("10001167", false);
print(result); print(result);
} }
@ -73,7 +70,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void queryDeparturesInvalidStation() throws Exception public void queryDeparturesInvalidStation() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("999999", false); final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status); assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
} }
@ -81,7 +77,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }
@ -113,4 +108,13 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult); print(earlierResult);
} }
@Test
public void tripToAny() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, -37903445, 145102109, null,
"16 Burlington St, Oakleigh Victoria 3166, Australien"), null, new Location(LocationType.ANY, null, 0, 0, null,
"elizabeth st kensingtin"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
}
} }

View file

@ -50,7 +50,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "350")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "350"));
print(result); print(result);
} }
@ -58,7 +57,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48135232, 11560650)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48135232, 11560650));
print(result); print(result);
} }
@ -66,7 +64,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("2", false); final QueryDeparturesResult result = queryDepartures("2", false);
assertEquals(QueryDeparturesResult.Status.OK, result.status); assertEquals(QueryDeparturesResult.Status.OK, result.status);
print(result); print(result);
} }
@ -75,15 +72,20 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void queryDeparturesInvalidStation() throws Exception public void queryDeparturesInvalidStation() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("999999", false); final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status); assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
} }
@Test
public void suggestLocationsIdentified() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Starnberg, Agentur für Arbeit");
print(result);
}
@Test @Test
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Marien"); final SuggestLocationsResult result = suggestLocations("Marien");
print(result); print(result);
} }
@ -91,7 +93,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@ -126,10 +127,10 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
@Test @Test
public void longTrip() throws Exception public void longTrip() throws Exception
{ {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Starnberg, Arbeitsamt"), null, new Location( final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1005530", 48002924, 11340144, "Starnberg",
LocationType.STATION, null, null, "Ackermannstraße"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL); "Agentur für Arbeit"), null, new Location(LocationType.STATION, null, null, "Ackermannstraße"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result); print(result);
// seems like there are no more trips all the time
} }
@Test @Test

View file

@ -49,7 +49,6 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10101101")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10101101"));
print(result); print(result);
} }
@ -57,7 +56,6 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, -32823911, 151462824)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, -32823911, 151462824));
print(result); print(result);
} }
@ -65,15 +63,13 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("10101101", false); final QueryDeparturesResult result = queryDepartures("10101101", false);
print(result); print(result);
} }
@Test @Test
public void suggestLocations() throws Exception public void suggestLocationsIdentified() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Town Hall Station"); final SuggestLocationsResult result = suggestLocations("Sydney, Town Hall Station");
print(result); print(result);
} }
@ -81,7 +77,6 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }

View file

@ -49,7 +49,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "51013670")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "51013670"));
print(result); print(result);
} }
@ -57,7 +56,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 53348656, -6262221)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 53348656, -6262221));
print(result); print(result);
} }
@ -65,7 +63,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("51013670", false); final QueryDeparturesResult result = queryDepartures("51013670", false);
print(result); print(result);
} }
@ -73,7 +70,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Lower O'Connell Street"); final SuggestLocationsResult result = suggestLocations("Lower O'Connell Street");
print(result); print(result);
} }
@ -81,7 +77,7 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void shortTrip() throws Exception public void shortTrip() throws Exception
{ {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "51013670", "Dublin City South", final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "51013670", "Dublin City South",
"O'Connell Bridge (on Lower O'Connell Street)"), null, new Location(LocationType.STATION, "52003679", "Dublin City South", "O'Connell Bridge (on Lower O'Connell Street)"), null, new Location(LocationType.STATION, "51005661", "Dublin City South",
"Dublin (Baggot Street)"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL); "Dublin (Baggot Street)"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);

View file

@ -90,7 +90,6 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocations() throws Exception public void suggestLocations() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Lower Arncott The Plough"); final SuggestLocationsResult result = suggestLocations("Lower Arncott The Plough");
print(result); print(result);
} }
@ -98,7 +97,6 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Birming"); final SuggestLocationsResult result = suggestLocations("Birming");
print(result); print(result);
} }
@ -187,4 +185,22 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult); print(earlierResult);
} }
@Test
public void tripFromPOI() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.POI,
"poiID:48863:31117134:-1:Statue:Ham (London):Statue:ANY:POI:517246:826916:TFLV:uk", 51444620, -314316, "Ham (London)", "Statue"),
null, new Location(LocationType.ADDRESS, "streetID:106269::31117001:-1", "London", "Cannon Street, London"), new Date(), true,
Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
}
@Test
public void tripPostcode() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "se7 7tr"), null, new Location(LocationType.ANY, null,
null, "n9 0nx"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
}
} }

View file

@ -49,7 +49,6 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "119")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "119"));
print(result); print(result);
} }
@ -57,7 +56,6 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 47049107, 8312502)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 47049107, 8312502));
print(result); print(result);
} }
@ -65,7 +63,13 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("717", false); final QueryDeparturesResult result = queryDepartures("717", false);
print(result);
}
@Test
public void suggestLocationsIdentified() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Luzern, Kantonalbank");
print(result); print(result);
} }
@ -73,7 +77,6 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }
@ -81,15 +84,14 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@Test @Test
public void shortTrip() throws Exception public void shortTrip() throws Exception
{ {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "119", 47050760, 8310252, "Luzern", "Luzern, Bahnhof"), null, final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "53020041", 47050164, 8310352, "Luzern", "Bahnhof"), null,
new Location(LocationType.STATION, "118", 47048844, 8306433, "Luzern", "Kantonalbank"), new Date(), true, Product.ALL, new Location(LocationType.STATION, "53028841", 47048564, 8306016, "Luzern", "Kantonalbank"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL); WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);

View file

@ -46,7 +46,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3000510")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3000510"));
print(result); print(result);
} }
@ -54,7 +53,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 49455472, 11079655)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 49455472, 11079655));
print(result); print(result);
} }
@ -62,7 +60,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("3000510", false); final QueryDeparturesResult result = queryDepartures("3000510", false);
print(result); print(result);
} }
@ -70,7 +67,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }
@ -78,7 +74,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@ -92,6 +87,17 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
print(laterResult); print(laterResult);
} }
@Test
public void tripToPOI() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 49527298, 10836204), null, new Location(LocationType.POI,
"poiID:246:9564000:1:Grundschule Grimmstr.:Nürnberg:Grundschule Grimmstr.:ANY:POI:4436708:678322:NAV4:VGN", 49468692, 11125334,
"Nürnberg", "Grundschule Grimmstr."), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test @Test
public void tripToAddress() throws Exception public void tripToAddress() throws Exception
{ {

View file

@ -49,7 +49,6 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60001296")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60001296"));
print(result); print(result);
} }
@ -57,7 +56,6 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 47271228, 11402063)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 47271228, 11402063));
print(result); print(result);
} }
@ -65,7 +63,13 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("60001296", false); final QueryDeparturesResult result = queryDepartures("60001296", false);
print(result);
}
@Test
public void suggestLocationsIdentified() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Katzenturm");
print(result); print(result);
} }
@ -73,7 +77,6 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }
@ -81,15 +84,14 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@Test @Test
public void shortTrip() throws Exception public void shortTrip() throws Exception
{ {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "60000822", 47238428, 9596940, "Feldkirch", "Katzenturm"), final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "66200822", 47238428, 9596940, "Feldkirch", "Katzenturm"),
null, new Location(LocationType.STATION, "60000305", 47240744, 9589368, "Tosters", "Vorarlberghalle"), new Date(), true, Product.ALL, null, new Location(LocationType.STATION, "66200305", 47240744, 9589368, "Tosters", "Vorarlberghalle"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL); WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);

View file

@ -51,7 +51,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60203090")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60203090"));
print(result); print(result);
} }
@ -59,7 +58,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48207355, 16370602)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48207355, 16370602));
print(result); print(result);
} }
@ -67,7 +65,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("60203090", false); final QueryDeparturesResult result = queryDepartures("60203090", false);
print(result); print(result);
} }
@ -75,7 +72,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
} }
@ -83,7 +79,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@ -128,6 +123,17 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
print(earlierResult); print(earlierResult);
} }
@Test
public void tripToPOI() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 48221088, 16342658, "Wien", "Antonigasse 4"), null,
new Location(LocationType.POI, "poiID:1005:49000000:-1", 48199844, 16365834, "Wien", "Naschmarkt"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test @Test
public void tripBetweenCoordinates() throws Exception public void tripBetweenCoordinates() throws Exception
{ {

View file

@ -51,7 +51,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception public void nearbyStations() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "20019904")); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "20019904"));
print(result); print(result);
} }
@ -59,11 +58,9 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception public void nearbyStationsByCoordinate() throws Exception
{ {
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 51218693, 6777785)); final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 51218693, 6777785));
print(result); print(result);
final NearbyStationsResult result2 = queryNearbyStations(new Location(LocationType.ADDRESS, 51719648, 8754330)); final NearbyStationsResult result2 = queryNearbyStations(new Location(LocationType.ADDRESS, 51719648, 8754330));
print(result2); print(result2);
} }
@ -71,11 +68,9 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception public void queryDepartures() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("1007258", false); final QueryDeparturesResult result = queryDepartures("1007258", false);
print(result); print(result);
final QueryDeparturesResult result2 = queryDepartures("20019904", false); final QueryDeparturesResult result2 = queryDepartures("20019904", false);
print(result2); print(result2);
// Bonn // Bonn
@ -87,7 +82,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void queryManyDeparturesWithEquivs() throws Exception public void queryManyDeparturesWithEquivs() throws Exception
{ {
final QueryDeparturesResult result = queryDepartures("20018235", true); final QueryDeparturesResult result = queryDepartures("20018235", true);
print(result); print(result);
} }
@ -95,11 +89,9 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception public void suggestLocationsIncomplete() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
final SuggestLocationsResult paderbornResult = suggestLocations("Paderborn Hbf"); final SuggestLocationsResult paderbornResult = suggestLocations("Paderborn Hbf");
print(paderbornResult); print(paderbornResult);
} }
@ -107,7 +99,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception public void suggestLocationsWithUmlaut() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("grün"); final SuggestLocationsResult result = suggestLocations("grün");
print(result); print(result);
} }
@ -115,7 +106,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIdentified() throws Exception public void suggestLocationsIdentified() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Düsseldorf, Am Frohnhof"); final SuggestLocationsResult result = suggestLocations("Düsseldorf, Am Frohnhof");
print(result); print(result);
} }
@ -147,10 +137,18 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsCity() throws Exception public void suggestLocationsCity() throws Exception
{ {
final SuggestLocationsResult result = suggestLocations("Düsseldorf"); final SuggestLocationsResult result = suggestLocations("Düsseldorf");
print(result); print(result);
} }
@Test
public void anyTrip() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Köln"), null, new Location(LocationType.ANY, null,
null, "Bonn"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
}
@Test @Test
public void shortTrip() throws Exception public void shortTrip() throws Exception
{ {