diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java
index 9a4ee5d6..be9bc0b8 100644
--- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java
+++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -87,7 +88,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
private String additionalQueryParameter = null;
private boolean useRealtime = true;
- private boolean canAcceptPoiId = false;
private boolean needsSpEncId = false;
private boolean includeRegionId = true;
private boolean useProxFootSearch = true;
@@ -216,11 +216,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
this.useStringCoordListOutputFormat = useStringCoordListOutputFormat;
}
- protected void setCanAcceptPoiId(final boolean canAcceptPoiId)
- {
- this.canAcceptPoiId = canAcceptPoiId;
- }
-
protected void setNeedsSpEncId(final boolean needsSpEncId)
{
this.needsSpEncId = needsSpEncId;
@@ -240,6 +235,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
private final void appendCommonRequestParams(final StringBuilder uri, final String outputFormat)
{
uri.append("?outputFormat=").append(outputFormat);
+ uri.append("&stateless=1");
uri.append("&coordOutputFormat=WGS84");
if (additionalQueryParameter != null)
uri.append('&').append(additionalQueryParameter);
@@ -306,8 +302,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
String type = stop.getString("type");
if ("any".equals(type))
type = stop.getString("anyType");
+ final String id = stop.getString("stateless");
final String name = normalizeLocationName(stop.optString("name"));
final String object = normalizeLocationName(stop.optString("object"));
+ final String postcode = stop.optString("postcode");
final int quality = stop.getInt("quality");
final JSONObject ref = stop.getJSONObject("ref");
String place = ref.getString("place");
@@ -330,13 +328,15 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Location location;
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))
- 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))
- 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))
- 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
throw new JSONException("unknown type: " + type);
@@ -392,42 +392,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "itdStopFinderRequest");
- XmlPullUtil.require(pp, "itdOdv");
- if (!"sf".equals(pp.getAttributeValue(null, "usage")))
- throw new IllegalStateException("cannot find ");
- 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))
+ processItdOdv(pp, "sf", new ProcessItdOdvCallback()
{
- 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));
}
- }
- 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");
@@ -705,6 +676,93 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
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 ");
+
+ final String usage = XmlPullUtil.attr(pp, "usage");
+ if (expectedUsage != null && !usage.equals(expectedUsage))
+ throw new IllegalStateException("expecting ");
+
+ 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
{
if (!XmlPullUtil.test(pp, "itdOdvPlace"))
@@ -724,25 +782,24 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
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"))
throw new IllegalStateException("expecting ");
- final String anyType = pp.getAttributeValue(null, "anyType");
- final String idStr = pp.getAttributeValue(null, "id");
- final String stopIdStr = pp.getAttributeValue(null, "stopID");
- final String poiIdStr = pp.getAttributeValue(null, "poiID");
- final String streetIdStr = pp.getAttributeValue(null, "streetID");
+ if ("any".equals(type))
+ type = XmlPullUtil.attr(pp, "anyType");
+ final String id = XmlPullUtil.attr(pp, "stateless");
final String locality = normalizeLocationName(pp.getAttributeValue(null, "locality"));
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 float x = XmlPullUtil.optFloatAttr(pp, "x", 0);
final float y = XmlPullUtil.optFloatAttr(pp, "y", 0);
- final String elemName = normalizeLocationName(XmlPullUtil.valueTag(pp, "odvNameElem"));
-
final int lat;
final int lon;
@@ -761,83 +818,64 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y);
}
- final LocationType type;
- final String id;
+ final String nameElem = normalizeLocationName(XmlPullUtil.valueTag(pp, "odvNameElem"));
+
+ final LocationType locationType;
final String place;
final String name;
- if ("stop".equals(anyType))
+ if ("stop".equals(type))
{
- type = LocationType.STATION;
- id = idStr;
+ locationType = LocationType.STATION;
place = locality;
name = objectName;
}
- else if ("poi".equals(anyType) || "poiHierarchy".equals(anyType))
+ else if ("poi".equals(type))
{
- type = LocationType.POI;
- id = idStr;
+ locationType = LocationType.POI;
place = locality;
name = objectName;
}
- else if ("loc".equals(anyType))
+ else if ("loc".equals(type))
{
- type = LocationType.ANY;
- id = null;
- place = locality;
- name = locality;
+ return null;
}
- else if ("address".equals(anyType))
+ else if ("address".equals(type) || "singlehouse".equals(type))
{
- type = LocationType.ADDRESS;
- id = null;
+ locationType = LocationType.ADDRESS;
+ place = locality;
+ name = objectName + (buildingNumber != null ? " " + buildingNumber : "");
+ }
+ else if ("street".equals(type) || "crossing".equals(type))
+ {
+ locationType = LocationType.ADDRESS;
place = locality;
name = objectName;
}
- else if ("postcode".equals(anyType) || "street".equals(anyType) || "crossing".equals(anyType) || "singlehouse".equals(anyType)
- || "buildingname".equals(anyType))
+ else if ("postcode".equals(type))
{
- type = LocationType.ADDRESS;
- id = null;
+ locationType = LocationType.ADDRESS;
place = locality;
- name = objectName;
+ name = postCode;
}
- else if (anyType == null || "unknown".equals(anyType))
+ else if ("buildingname".equals(type))
{
- if (stopIdStr != null)
- {
- 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");
- }
-
+ locationType = LocationType.ADDRESS;
place = locality;
- name = objectName;
+ name = buildingName;
+ }
+ else if ("coord".equals(type))
+ {
+ locationType = LocationType.ADDRESS;
+ place = defaultPlace;
+ name = nameElem;
}
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
@@ -923,71 +961,33 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
- if (!XmlPullUtil.test(pp, "itdOdv") || !"dm".equals(pp.getAttributeValue(null, "usage")))
- throw new IllegalStateException("cannot find ");
- XmlPullUtil.enter(pp, "itdOdv");
+ final AtomicReference ownStation = new AtomicReference();
+ final List stations = new ArrayList();
- 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 String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback()
{
- final Location ownLocation = processOdvNameElem(pp, place);
- final Location ownStation = ownLocation.type == LocationType.STATION ? ownLocation : null;
-
- XmlPullUtil.skipExit(pp, "itdOdvName");
-
- final List stations = new ArrayList();
-
- if (XmlPullUtil.test(pp, "itdOdvAssignedStops"))
+ public void location(final String nameState, final Location location, final int matchQuality)
{
- XmlPullUtil.enter(pp, "itdOdvAssignedStops");
- while (XmlPullUtil.test(pp, "itdOdvAssignedStop"))
+ if (location.type == LocationType.STATION)
{
- final Location newStation = processItdOdvAssignedStop(pp);
-
- if (newStation != null && !stations.contains(newStation))
- stations.add(newStation);
+ if ("identified".equals(nameState))
+ ownStation.set(location);
+ else if ("assigned".equals(nameState))
+ stations.add(location);
}
- XmlPullUtil.skipExit(pp, "itdOdvAssignedStops");
}
+ });
- XmlPullUtil.skipExit(pp, "itdOdv");
-
- 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 stations = new ArrayList();
-
- 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))
- {
+ if ("notidentified".equals(nameState))
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
- {
- throw new RuntimeException("unknown nameState '" + nameState + "' on " + uri);
- }
- // XmlPullUtil.exit(pp, "itdOdvName");
+ return new NearbyStationsResult(header, stations.subList(0, maxStations));
}
catch (final XmlPullParserException x)
{
@@ -1507,186 +1507,153 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
pp.setInput(is, null);
final ResultHeader header = enterItdRequest(pp);
+ final QueryDeparturesResult result = new QueryDeparturesResult(header);
+
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
- if (XmlPullUtil.test(pp, "itdMessage"))
- XmlPullUtil.next(pp);
+ XmlPullUtil.optSkip(pp, "itdMessage");
- if (!XmlPullUtil.test(pp, "itdOdv") || !"dm".equals(XmlPullUtil.attr(pp, "usage")))
- throw new IllegalStateException("cannot find , 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 String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback()
{
- final QueryDeparturesResult result = new QueryDeparturesResult(header);
-
- final Location location = processOdvNameElem(pp, place);
- result.stationDepartures.add(new StationDepartures(location, new LinkedList(), new LinkedList()));
-
- XmlPullUtil.skipExit(pp, "itdOdvName");
-
- if (XmlPullUtil.test(pp, "itdOdvAssignedStops"))
+ public void location(final String nameState, final Location location, final int matchQuality)
{
- XmlPullUtil.enter(pp, "itdOdvAssignedStops");
- while (XmlPullUtil.test(pp, "itdOdvAssignedStop"))
- {
- final Location assignedLocation = processItdOdvAssignedStop(pp);
- if (assignedLocation != null)
- if (findStationDepartures(result.stationDepartures, assignedLocation.id) == null)
- result.stationDepartures.add(new StationDepartures(assignedLocation, new LinkedList(),
- new LinkedList()));
- }
- XmlPullUtil.skipExit(pp, "itdOdvAssignedStops");
+ if (location.type == LocationType.STATION)
+ if (findStationDepartures(result.stationDepartures, location.id) == null)
+ result.stationDepartures.add(new StationDepartures(location, new LinkedList(),
+ new LinkedList()));
}
+ });
- XmlPullUtil.skipExit(pp, "itdOdv");
-
- 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(), new LinkedList());
-
- 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(), new LinkedList());
- }
-
- 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))
- {
+ if ("notidentified".equals(nameState) || "list".equals(nameState))
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(), new LinkedList());
+
+ if (!assignedStationDepartures.lines.contains(line))
+ assignedStationDepartures.lines.add(line);
+ }
+ XmlPullUtil.skipExit(pp, "itdServingLines");
}
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(), new LinkedList());
+ }
+
+ 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)
{
@@ -2337,60 +2304,41 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (XmlPullUtil.test(pp, "itdAddress"))
XmlPullUtil.next(pp);
- // parse odv name elements
List ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
Location from = null, via = null, to = null;
while (XmlPullUtil.test(pp, "itdOdv"))
{
- final String usage = XmlPullUtil.attr(pp, "usage");
- XmlPullUtil.enter(pp, "itdOdv");
+ final String usage = pp.getAttributeValue(null, "usage");
- final String place = processItdOdvPlace(pp);
-
- if (!XmlPullUtil.test(pp, "itdOdvName"))
- throw new IllegalStateException("cannot find inside " + usage);
- final String nameState = XmlPullUtil.attr(pp, "state");
- XmlPullUtil.enter(pp, "itdOdvName");
- if (XmlPullUtil.test(pp, "itdMessage"))
- XmlPullUtil.next(pp);
+ final List locations = new ArrayList();
+ final String nameState = processItdOdv(pp, usage, new ProcessItdOdvCallback()
+ {
+ public void location(final String nameState, final Location location, final int matchQuality)
+ {
+ locations.add(location);
+ }
+ });
if ("list".equals(nameState))
{
if ("origin".equals(usage))
- {
- ambiguousFrom = new ArrayList();
- while (XmlPullUtil.test(pp, "odvNameElem"))
- ambiguousFrom.add(processOdvNameElem(pp, place));
- }
+ ambiguousFrom = locations;
else if ("via".equals(usage))
- {
- ambiguousVia = new ArrayList();
- while (XmlPullUtil.test(pp, "odvNameElem"))
- ambiguousVia.add(processOdvNameElem(pp, place));
- }
+ ambiguousVia = locations;
else if ("destination".equals(usage))
- {
- ambiguousTo = new ArrayList();
- while (XmlPullUtil.test(pp, "odvNameElem"))
- ambiguousTo.add(processOdvNameElem(pp, place));
- }
+ ambiguousTo = locations;
else
- {
throw new IllegalStateException("unknown usage: " + usage);
- }
}
else if ("identified".equals(nameState))
{
- if (!XmlPullUtil.test(pp, "odvNameElem"))
- throw new IllegalStateException("cannot find inside " + usage);
-
if ("origin".equals(usage))
- from = processOdvNameElem(pp, place);
+ from = locations.get(0);
else if ("via".equals(usage))
- via = processOdvNameElem(pp, place);
+ via = locations.get(0);
else if ("destination".equals(usage))
- to = processOdvNameElem(pp, place);
+ to = locations.get(0);
else
throw new IllegalStateException("unknown usage: " + usage);
}
@@ -2405,8 +2353,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
else
throw new IllegalStateException("unknown usage: " + usage);
}
- XmlPullUtil.skipExit(pp, "itdOdvName");
- XmlPullUtil.skipExit(pp, "itdOdv");
}
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)
{
- if (canAcceptPoiId && location.type == LocationType.POI && location.hasId())
- {
- 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())
+ if (location.type == LocationType.ADDRESS && location.hasLocation())
{
uri.append("&type_").append(paramSuffix).append("=coord");
uri.append("&name_").append(paramSuffix).append("=")
@@ -3319,7 +3260,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
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;
else
return location.name;
diff --git a/enabler/src/de/schildbach/pte/VrrProvider.java b/enabler/src/de/schildbach/pte/VrrProvider.java
index 3daa3169..2d038182 100644
--- a/enabler/src/de/schildbach/pte/VrrProvider.java
+++ b/enabler/src/de/schildbach/pte/VrrProvider.java
@@ -39,6 +39,7 @@ public class VrrProvider extends AbstractEfaProvider
setNeedsSpEncId(true);
setUseRouteIndexAsTripId(false);
setStyles(STYLES);
+ setRequestUrlEncoding(UTF_8);
}
public NetworkId id()
diff --git a/enabler/src/de/schildbach/pte/VvsProvider.java b/enabler/src/de/schildbach/pte/VvsProvider.java
index 511afa20..3d3a287d 100644
--- a/enabler/src/de/schildbach/pte/VvsProvider.java
+++ b/enabler/src/de/schildbach/pte/VvsProvider.java
@@ -35,8 +35,6 @@ public class VvsProvider extends AbstractEfaProvider
public VvsProvider(final String apiBase)
{
super(apiBase);
-
- setCanAcceptPoiId(true);
}
public NetworkId id()
diff --git a/enabler/test/de/schildbach/pte/live/DingProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/DingProviderLiveTest.java
index cd347bc9..5531d4eb 100644
--- a/enabler/test/de/schildbach/pte/live/DingProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/DingProviderLiveTest.java
@@ -49,7 +49,6 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "90001611"));
-
print(result);
}
@@ -57,7 +56,6 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48401092, 9992037));
-
print(result);
}
@@ -65,7 +63,13 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("90001611", false);
+ print(result);
+ }
+ @Test
+ public void suggestLocationsIdentified() throws Exception
+ {
+ final SuggestLocationsResult result = suggestLocations("Ulm, Justizgebäude");
print(result);
}
@@ -73,7 +77,6 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
@@ -81,15 +84,14 @@ public class DingProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@Test
public void shortTrip() throws Exception
{
- final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "9001011", null, "Justizgebäude"), null, new Location(
- LocationType.STATION, "2504524", null, "Theater"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
+ final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "9001011", "Ulm", "Justizgebäude"), null, new Location(
+ LocationType.STATION, "9001010", "Ulm", "Theater"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
diff --git a/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java
index 41570149..5af05faa 100644
--- a/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java
@@ -49,7 +49,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10001167"));
-
print(result);
}
@@ -57,7 +56,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, -37800941, 144966545));
-
print(result);
}
@@ -65,7 +63,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("10001167", false);
-
print(result);
}
@@ -73,7 +70,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void queryDeparturesInvalidStation() throws Exception
{
final QueryDeparturesResult result = queryDepartures("999999", false);
-
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@@ -81,7 +77,6 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
@@ -113,4 +108,13 @@ public class MetProviderLiveTest extends AbstractProviderLiveTest
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
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);
+ }
}
diff --git a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java
index d4f214d6..0dcbb6b1 100644
--- a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java
@@ -50,7 +50,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "350"));
-
print(result);
}
@@ -58,7 +57,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48135232, 11560650));
-
print(result);
}
@@ -66,7 +64,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("2", false);
-
assertEquals(QueryDeparturesResult.Status.OK, result.status);
print(result);
}
@@ -75,15 +72,20 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void queryDeparturesInvalidStation() throws Exception
{
final QueryDeparturesResult result = queryDepartures("999999", false);
-
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
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Marien");
-
print(result);
}
@@ -91,7 +93,6 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@@ -126,10 +127,10 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
@Test
public void longTrip() throws Exception
{
- final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Starnberg, Arbeitsamt"), null, new Location(
- LocationType.STATION, null, null, "Ackermannstraße"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
+ final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1005530", 48002924, 11340144, "Starnberg",
+ "Agentur für Arbeit"), null, new Location(LocationType.STATION, null, null, "Ackermannstraße"), new Date(), true, Product.ALL,
+ WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
- // seems like there are no more trips all the time
}
@Test
diff --git a/enabler/test/de/schildbach/pte/live/SydneyProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/SydneyProviderLiveTest.java
index c0fad912..749abccc 100644
--- a/enabler/test/de/schildbach/pte/live/SydneyProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/SydneyProviderLiveTest.java
@@ -49,7 +49,6 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10101101"));
-
print(result);
}
@@ -57,7 +56,6 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, -32823911, 151462824));
-
print(result);
}
@@ -65,15 +63,13 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("10101101", false);
-
print(result);
}
@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);
}
@@ -81,7 +77,6 @@ public class SydneyProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
diff --git a/enabler/test/de/schildbach/pte/live/TfiProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/TfiProviderLiveTest.java
index a6f2eaf3..b7377da9 100644
--- a/enabler/test/de/schildbach/pte/live/TfiProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/TfiProviderLiveTest.java
@@ -49,7 +49,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "51013670"));
-
print(result);
}
@@ -57,7 +56,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 53348656, -6262221));
-
print(result);
}
@@ -65,7 +63,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("51013670", false);
-
print(result);
}
@@ -73,7 +70,6 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Lower O'Connell Street");
-
print(result);
}
@@ -81,7 +77,7 @@ public class TfiProviderLiveTest extends AbstractProviderLiveTest
public void shortTrip() throws Exception
{
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);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
diff --git a/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java
index 90df7f53..734f2d70 100644
--- a/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java
@@ -90,7 +90,6 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocations() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Lower Arncott The Plough");
-
print(result);
}
@@ -98,7 +97,6 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Birming");
-
print(result);
}
@@ -187,4 +185,22 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
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);
+ }
}
diff --git a/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java
index 2a472d82..7ac9331e 100644
--- a/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java
@@ -49,7 +49,6 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "119"));
-
print(result);
}
@@ -57,7 +56,6 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 47049107, 8312502));
-
print(result);
}
@@ -65,7 +63,13 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("717", false);
+ print(result);
+ }
+ @Test
+ public void suggestLocationsIdentified() throws Exception
+ {
+ final SuggestLocationsResult result = suggestLocations("Luzern, Kantonalbank");
print(result);
}
@@ -73,7 +77,6 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
@@ -81,15 +84,14 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@Test
public void shortTrip() throws Exception
{
- final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "119", 47050760, 8310252, "Luzern", "Luzern, Bahnhof"), null,
- new Location(LocationType.STATION, "118", 47048844, 8306433, "Luzern", "Kantonalbank"), new Date(), true, Product.ALL,
+ final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "53020041", 47050164, 8310352, "Luzern", "Bahnhof"), null,
+ new Location(LocationType.STATION, "53028841", 47048564, 8306016, "Luzern", "Kantonalbank"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
diff --git a/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java
index 72fa24ce..72b80026 100644
--- a/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java
@@ -46,7 +46,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3000510"));
-
print(result);
}
@@ -54,7 +53,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 49455472, 11079655));
-
print(result);
}
@@ -62,7 +60,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("3000510", false);
-
print(result);
}
@@ -70,7 +67,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
@@ -78,7 +74,6 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@@ -92,6 +87,17 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest
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
public void tripToAddress() throws Exception
{
diff --git a/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java
index 1367368b..8b9adc31 100644
--- a/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java
@@ -49,7 +49,6 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60001296"));
-
print(result);
}
@@ -57,7 +56,6 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 47271228, 11402063));
-
print(result);
}
@@ -65,7 +63,13 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("60001296", false);
+ print(result);
+ }
+ @Test
+ public void suggestLocationsIdentified() throws Exception
+ {
+ final SuggestLocationsResult result = suggestLocations("Katzenturm");
print(result);
}
@@ -73,7 +77,6 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
@@ -81,15 +84,14 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@Test
public void shortTrip() throws Exception
{
- final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "60000822", 47238428, 9596940, "Feldkirch", "Katzenturm"),
- null, new Location(LocationType.STATION, "60000305", 47240744, 9589368, "Tosters", "Vorarlberghalle"), new Date(), true, Product.ALL,
+ final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "66200822", 47238428, 9596940, "Feldkirch", "Katzenturm"),
+ null, new Location(LocationType.STATION, "66200305", 47240744, 9589368, "Tosters", "Vorarlberghalle"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
diff --git a/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java
index 1a3dbf41..5af938bd 100644
--- a/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java
@@ -51,7 +51,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60203090"));
-
print(result);
}
@@ -59,7 +58,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 48207355, 16370602));
-
print(result);
}
@@ -67,7 +65,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("60203090", false);
-
print(result);
}
@@ -75,7 +72,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
}
@@ -83,7 +79,6 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@@ -128,6 +123,17 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
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
public void tripBetweenCoordinates() throws Exception
{
diff --git a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java
index 87e548fb..7e8b3929 100644
--- a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java
+++ b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java
@@ -51,7 +51,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.STATION, "20019904"));
-
print(result);
}
@@ -59,11 +58,9 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 51218693, 6777785));
-
print(result);
final NearbyStationsResult result2 = queryNearbyStations(new Location(LocationType.ADDRESS, 51719648, 8754330));
-
print(result2);
}
@@ -71,11 +68,9 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("1007258", false);
-
print(result);
final QueryDeparturesResult result2 = queryDepartures("20019904", false);
-
print(result2);
// Bonn
@@ -87,7 +82,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void queryManyDeparturesWithEquivs() throws Exception
{
final QueryDeparturesResult result = queryDepartures("20018235", true);
-
print(result);
}
@@ -95,11 +89,9 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIncomplete() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Kur");
-
print(result);
final SuggestLocationsResult paderbornResult = suggestLocations("Paderborn Hbf");
-
print(paderbornResult);
}
@@ -107,7 +99,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsWithUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("grün");
-
print(result);
}
@@ -115,7 +106,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsIdentified() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Düsseldorf, Am Frohnhof");
-
print(result);
}
@@ -147,10 +137,18 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
public void suggestLocationsCity() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Düsseldorf");
-
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
public void shortTrip() throws Exception
{