Point: Store coordinate as pair of double, rather than 1E6 ints.

This makes the lat/lon member variables private and adds 1E6 variants for getters and the static constructor.
Also, Location now stores a Point for its coordinate, rather than 1E6 ints. The 1E6-based constructors have been removed.
This commit is contained in:
Andreas Schildbach 2018-11-15 21:59:38 +01:00
parent a7f6abc4b9
commit e6474db222
49 changed files with 514 additions and 462 deletions

View file

@ -477,12 +477,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
private void appendXmlCoordRequestParameters(final HttpUrl.Builder url, final EnumSet<LocationType> types, private void appendXmlCoordRequestParameters(final HttpUrl.Builder url, final EnumSet<LocationType> types,
final int lat, final int lon, final int maxDistance, final int maxLocations) { final Point coord, final int maxDistance, final int maxLocations) {
appendCommonRequestParams(url, "XML"); appendCommonRequestParams(url, "XML");
url.addEncodedQueryParameter("coord", url.addEncodedQueryParameter("coord", ParserUtils.urlEncode(
ParserUtils.urlEncode( String.format(Locale.ENGLISH, "%2.6f:%2.6f:WGS84", coord.getLonAsDouble(), coord.getLatAsDouble()),
String.format(Locale.ENGLISH, "%2.6f:%2.6f:WGS84", latLonToDouble(lon), latLonToDouble(lat)), requestUrlEncoding));
requestUrlEncoding));
if (useStringCoordListOutputFormat) if (useStringCoordListOutputFormat)
url.addEncodedQueryParameter("coordListOutputFormat", "STRING"); url.addEncodedQueryParameter("coordListOutputFormat", "STRING");
url.addEncodedQueryParameter("max", Integer.toString(maxLocations != 0 ? maxLocations : 50)); url.addEncodedQueryParameter("max", Integer.toString(maxLocations != 0 ? maxLocations : 50));
@ -500,10 +499,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
} }
protected NearbyLocationsResult xmlCoordRequest(final EnumSet<LocationType> types, final int lat, final int lon, protected NearbyLocationsResult xmlCoordRequest(final EnumSet<LocationType> types, final Point coord,
final int maxDistance, final int maxStations) throws IOException { final int maxDistance, final int maxStations) throws IOException {
final HttpUrl.Builder url = coordEndpoint.newBuilder(); final HttpUrl.Builder url = coordEndpoint.newBuilder();
appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations); appendXmlCoordRequestParameters(url, types, coord, maxDistance, maxStations);
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>(); final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() { final HttpClient.Callback callback = new HttpClient.Callback() {
@ -572,10 +571,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
return result.get(); return result.get();
} }
protected NearbyLocationsResult mobileCoordRequest(final EnumSet<LocationType> types, final int lat, final int lon, protected NearbyLocationsResult mobileCoordRequest(final EnumSet<LocationType> types, final Point coord,
final int maxDistance, final int maxStations) throws IOException { final int maxDistance, final int maxStations) throws IOException {
final HttpUrl.Builder url = coordEndpoint.newBuilder(); final HttpUrl.Builder url = coordEndpoint.newBuilder();
appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations); appendXmlCoordRequestParameters(url, types, coord, maxDistance, maxStations);
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>(); final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() { final HttpClient.Callback callback = new HttpClient.Callback() {
@ -836,8 +835,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException { final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) if (location.hasCoord())
return xmlCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); return xmlCoordRequest(types, location.coord, maxDistance, maxLocations);
if (location.type != LocationType.STATION) if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type); throw new IllegalArgumentException("cannot handle: " + location.type);
@ -1964,10 +1963,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
return P_STATION_NAME_WHITESPACE.matcher(name).replaceAll(" "); return P_STATION_NAME_WHITESPACE.matcher(name).replaceAll(" ");
} }
protected static double latLonToDouble(final int value) {
return (double) value / 1000000;
}
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from, protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
final @Nullable Location via, final Location to, final Date time, final boolean dep, final @Nullable Location via, final Location to, final Date time, final boolean dep,
@Nullable TripOptions options) { @Nullable TripOptions options) {
@ -2810,7 +2805,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
if ("WGS84".equals(coordParts[2])) { if ("WGS84".equals(coordParts[2])) {
final int lat = (int) Math.round(Double.parseDouble(coordParts[1])); final int lat = (int) Math.round(Double.parseDouble(coordParts[1]));
final int lon = (int) Math.round(Double.parseDouble(coordParts[0])); final int lon = (int) Math.round(Double.parseDouble(coordParts[0]));
coords = new Point(lat, lon); coords = Point.from1E6(lat, lon);
} else { } else {
coords = null; coords = null;
} }
@ -2934,7 +2929,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
while (XmlPullUtil.optEnter(pp, "itdCoordinateBaseElem")) { while (XmlPullUtil.optEnter(pp, "itdCoordinateBaseElem")) {
final int lon = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "x"))); final int lon = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "x")));
final int lat = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "y"))); final int lat = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "y")));
path.add(new Point(lat, lon)); path.add(Point.from1E6(lat, lon));
XmlPullUtil.skipExit(pp, "itdCoordinateBaseElem"); XmlPullUtil.skipExit(pp, "itdCoordinateBaseElem");
} }
@ -2951,7 +2946,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final String[] parts = coordStr.split(","); final String[] parts = coordStr.split(",");
final int lat = (int) Math.round(Double.parseDouble(parts[1])); final int lat = (int) Math.round(Double.parseDouble(parts[1]));
final int lon = (int) Math.round(Double.parseDouble(parts[0])); final int lon = (int) Math.round(Double.parseDouble(parts[0]));
return new Point(lat, lon); return Point.from1E6(lat, lon);
} }
private Point processCoordAttr(final XmlPullParser pp) { private Point processCoordAttr(final XmlPullParser pp) {
@ -2965,7 +2960,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
if (!"WGS84".equals(mapName)) if (!"WGS84".equals(mapName))
return null; return null;
return new Point(y, x); return Point.from1E6(y, x);
} }
private Fare processItdGenericTicketGroup(final XmlPullParser pp, final String net, final Currency currency) private Fare processItdGenericTicketGroup(final XmlPullParser pp, final String net, final Currency currency)
@ -3029,10 +3024,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
private void appendLocationParams(final HttpUrl.Builder url, final Location location, final String paramSuffix) { private void appendLocationParams(final HttpUrl.Builder url, final Location location, final String paramSuffix) {
final String name = locationValue(location); final String name = locationValue(location);
if ((location.type == LocationType.ADDRESS || location.type == LocationType.COORD) && location.hasLocation()) { if ((location.type == LocationType.ADDRESS || location.type == LocationType.COORD) && location.hasCoord()) {
url.addEncodedQueryParameter("type_" + paramSuffix, "coord"); url.addEncodedQueryParameter("type_" + paramSuffix, "coord");
url.addEncodedQueryParameter("name_" + paramSuffix, ParserUtils.urlEncode( url.addEncodedQueryParameter("name_" + paramSuffix, ParserUtils.urlEncode(
String.format(Locale.ENGLISH, "%.6f:%.6f", location.lon / 1E6, location.lat / 1E6) + ":WGS84", String.format(Locale.ENGLISH, "%.6f:%.6f", location.getLonAsDouble(), location.getLatAsDouble())
+ ":WGS84",
requestUrlEncoding)); requestUrlEncoding));
} else if (name != null) { } else if (name != null) {
url.addEncodedQueryParameter("type_" + paramSuffix, locationTypeValue(location)); url.addEncodedQueryParameter("type_" + paramSuffix, locationTypeValue(location));

View file

@ -57,6 +57,7 @@ import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Position; import de.schildbach.pte.dto.Position;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
@ -131,8 +132,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException { final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) if (location.hasCoord())
return jsonLocGeoPos(types, location.lat, location.lon, maxDistance, maxLocations); return jsonLocGeoPos(types, location.coord, maxDistance, maxLocations);
else else
throw new IllegalArgumentException("cannot handle: " + location); throw new IllegalArgumentException("cannot handle: " + location);
} }
@ -162,7 +163,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
jsonContext.products, jsonContext.walkSpeed, later ? jsonContext.laterContext : jsonContext.earlierContext); jsonContext.products, jsonContext.walkSpeed, later ? jsonContext.laterContext : jsonContext.earlierContext);
} }
protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet<LocationType> types, final int lat, final int lon, protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet<LocationType> types, final Point coord,
int maxDistance, int maxLocations) throws IOException { int maxDistance, int maxLocations) throws IOException {
if (maxDistance == 0) if (maxDistance == 0)
maxDistance = DEFAULT_MAX_DISTANCE; maxDistance = DEFAULT_MAX_DISTANCE;
@ -171,7 +172,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
final boolean getStations = types.contains(LocationType.STATION); final boolean getStations = types.contains(LocationType.STATION);
final boolean getPOIs = types.contains(LocationType.POI); final boolean getPOIs = types.contains(LocationType.POI);
final String request = wrapJsonApiRequest("LocGeoPos", "{\"ring\":" // final String request = wrapJsonApiRequest("LocGeoPos", "{\"ring\":" //
+ "{\"cCrd\":{\"x\":" + lon + ",\"y\":" + lat + "},\"maxDist\":" + maxDistance + "}," // + "{\"cCrd\":{\"x\":" + coord.getLonAs1E6() + ",\"y\":" + coord.getLatAs1E6() + "}," //
+ "\"maxDist\":" + maxDistance + "}," //
+ "\"getStops\":" + getStations + "," // + "\"getStops\":" + getStations + "," //
+ "\"getPOIs\":" + getPOIs + "," // + "\"getPOIs\":" + getPOIs + "," //
+ "\"maxLoc\":" + maxLocations + "}", // + "\"maxLoc\":" + maxLocations + "}", //
@ -411,9 +413,9 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
if (!locations.isEmpty()) if (!locations.isEmpty())
return locations.get(0); return locations.get(0);
} }
if (location.hasLocation()) { if (location.hasCoord()) {
final List<Location> locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.lat, final List<Location> locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.coord, 0,
location.lon, 0, 1).locations; 1).locations;
if (!locations.isEmpty()) if (!locations.isEmpty())
return locations.get(0); return locations.get(0);
} }
@ -805,8 +807,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
final JSONObject crd = loc.optJSONObject("crd"); final JSONObject crd = loc.optJSONObject("crd");
if (crd != null) if (crd != null)
return new Location(locationType, id, crd.getInt("y"), crd.getInt("x"), placeAndName[0], placeAndName[1], return new Location(locationType, id, Point.from1E6(crd.getInt("y"), crd.getInt("x")), placeAndName[0],
products); placeAndName[1], products);
else else
return new Location(LocationType.STATION, id, null, placeAndName[0], placeAndName[1], products); return new Location(LocationType.STATION, id, null, placeAndName[0], placeAndName[1], products);
} }

View file

@ -248,9 +248,9 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final String id = XmlPullUtil.attr(pp, "externalStationNr"); final String id = XmlPullUtil.attr(pp, "externalStationNr");
final int x = XmlPullUtil.intAttr(pp, "x"); final int x = XmlPullUtil.intAttr(pp, "x");
final int y = XmlPullUtil.intAttr(pp, "y"); final int y = XmlPullUtil.intAttr(pp, "y");
final Point coord = Point.from1E6(y, x);
final String[] placeAndName = splitStationName(name); final String[] placeAndName = splitStationName(name);
return new Location(LocationType.STATION, id, y, x, placeAndName[0], placeAndName[1]); return new Location(LocationType.STATION, id, coord, placeAndName[0], placeAndName[1]);
} }
throw new IllegalStateException("cannot handle: " + type); throw new IllegalStateException("cannot handle: " + type);
} }
@ -263,7 +263,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
name = null; name = null;
final int x = XmlPullUtil.intAttr(pp, "x"); final int x = XmlPullUtil.intAttr(pp, "x");
final int y = XmlPullUtil.intAttr(pp, "y"); final int y = XmlPullUtil.intAttr(pp, "y");
return new Location(LocationType.POI, null, y, x, null, name); final Point coord = Point.from1E6(y, x);
return new Location(LocationType.POI, null, coord, null, name);
} }
throw new IllegalStateException("cannot handle: " + type); throw new IllegalStateException("cannot handle: " + type);
} }
@ -276,9 +277,9 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
name = null; name = null;
final int x = XmlPullUtil.intAttr(pp, "x"); final int x = XmlPullUtil.intAttr(pp, "x");
final int y = XmlPullUtil.intAttr(pp, "y"); final int y = XmlPullUtil.intAttr(pp, "y");
final Point coord = Point.from1E6(y, x);
final String[] placeAndName = splitAddress(name); final String[] placeAndName = splitAddress(name);
return new Location(LocationType.ADDRESS, null, y, x, placeAndName[0], placeAndName[1]); return new Location(LocationType.ADDRESS, null, coord, placeAndName[0], placeAndName[1]);
} }
throw new IllegalStateException("cannot handle: " + type); throw new IllegalStateException("cannot handle: " + type);
} }
@ -346,23 +347,23 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
if (type == 1) // station if (type == 1) // station
{ {
final String[] placeAndName = splitStationName(value); final String[] placeAndName = splitStationName(value);
location = new Location(LocationType.STATION, localId, lat, lon, placeAndName[0], location = new Location(LocationType.STATION, localId, Point.from1E6(lat, lon),
placeAndName[1]); placeAndName[0], placeAndName[1]);
} else if (type == 2) // address } else if (type == 2) // address
{ {
final String[] placeAndName = splitAddress(value); final String[] placeAndName = splitAddress(value);
location = new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], location = new Location(LocationType.ADDRESS, null, Point.from1E6(lat, lon),
placeAndName[1]); placeAndName[0], placeAndName[1]);
} else if (type == 4) // poi } else if (type == 4) // poi
{ {
final String[] placeAndName = splitPOI(value); final String[] placeAndName = splitPOI(value);
location = new Location(LocationType.POI, localId, lat, lon, placeAndName[0], location = new Location(LocationType.POI, localId, Point.from1E6(lat, lon), placeAndName[0],
placeAndName[1]); placeAndName[1]);
} else if (type == 128) // crossing } else if (type == 128) // crossing
{ {
final String[] placeAndName = splitAddress(value); final String[] placeAndName = splitAddress(value);
location = new Location(LocationType.ADDRESS, localId, lat, lon, placeAndName[0], location = new Location(LocationType.ADDRESS, localId, Point.from1E6(lat, lon),
placeAndName[1]); placeAndName[0], placeAndName[1]);
} else if (type == 87) { } else if (type == 87) {
location = null; location = null;
// don't know what to do // don't know what to do
@ -1115,7 +1116,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
while (XmlPullUtil.test(pp, "Point")) { while (XmlPullUtil.test(pp, "Point")) {
final int x = XmlPullUtil.intAttr(pp, "x"); final int x = XmlPullUtil.intAttr(pp, "x");
final int y = XmlPullUtil.intAttr(pp, "y"); final int y = XmlPullUtil.intAttr(pp, "y");
path.add(new Point(y, x)); path.add(Point.from1E6(y, x));
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
} }
XmlPullUtil.skipExit(pp, "Polyline"); XmlPullUtil.skipExit(pp, "Polyline");
@ -1248,13 +1249,13 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
private static final String locationXml(final Location location) { private static final String locationXml(final Location location) {
if (location.type == LocationType.STATION && location.hasId()) if (location.type == LocationType.STATION && location.hasId())
return "<Station externalId=\"" + normalizeStationId(location.id) + "\" />"; return "<Station externalId=\"" + normalizeStationId(location.id) + "\" />";
else if (location.type == LocationType.POI && location.hasLocation()) else if (location.type == LocationType.POI && location.hasCoord())
return "<Poi type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />"; return "<Poi type=\"WGS84\" x=\"" + location.getLonAs1E6() + "\" y=\"" + location.getLatAs1E6() + "\" />";
else if (location.type == LocationType.ADDRESS && location.hasLocation()) else if (location.type == LocationType.ADDRESS && location.hasCoord())
return "<Address type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" name=\"" return "<Address type=\"WGS84\" x=\"" + location.getLonAs1E6() + "\" y=\"" + location.getLatAs1E6()
+ (location.place != null ? location.place + ", " : "") + location.name + "\" />"; + "\" name=\"" + (location.place != null ? location.place + ", " : "") + location.name + "\" />";
else if (location.type == LocationType.COORD && location.hasLocation()) else if (location.type == LocationType.COORD && location.hasCoord())
return "<Coord type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />"; return "<Coord type=\"WGS84\" x=\"" + location.getLonAs1E6() + "\" y=\"" + location.getLatAs1E6() + "\" />";
else else
throw new IllegalArgumentException("cannot handle: " + location); throw new IllegalArgumentException("cannot handle: " + location);
} }
@ -1266,11 +1267,11 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
if (location.type == LocationType.STATION && location.hasId()) { if (location.type == LocationType.STATION && location.hasId()) {
id.append("@L=").append(normalizeStationId(location.id)); id.append("@L=").append(normalizeStationId(location.id));
} else if (location.hasLocation()) { } else if (location.hasCoord()) {
id.append("@X=").append(location.lon); id.append("@X=").append(location.getLonAs1E6());
id.append("@Y=").append(location.lat); id.append("@Y=").append(location.getLatAs1E6());
id.append("@O=").append(location.name != null ? location.name id.append("@O=").append(location.name != null ? location.name : String.format(Locale.ENGLISH, "%.6f, %.6f",
: String.format(Locale.ENGLISH, "%.6f, %.6f", location.lat / 1E6, location.lon / 1E6)); location.getLatAsDouble(), location.getLonAsDouble()));
} else if (location.name != null) { } else if (location.name != null) {
id.append("@G=").append(location.name); id.append("@G=").append(location.name);
if (location.type != LocationType.ANY) if (location.type != LocationType.ANY)
@ -1286,7 +1287,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
return 1; return 1;
if (type == LocationType.POI) if (type == LocationType.POI)
return 4; return 4;
if (type == LocationType.COORD || (type == LocationType.ADDRESS && location.hasLocation())) if (type == LocationType.COORD || (type == LocationType.ADDRESS && location.hasCoord()))
return 16; return 16;
if (type == LocationType.ADDRESS && location.name != null) if (type == LocationType.ADDRESS && location.name != null)
return 2; return 2;
@ -1310,12 +1311,12 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
if (via.type == LocationType.STATION && via.hasId()) { if (via.type == LocationType.STATION && via.hasId()) {
url.addQueryParameter("REQ0JourneyStops1.0L", via.id); url.addQueryParameter("REQ0JourneyStops1.0L", via.id);
} else if (via.hasLocation()) { } else if (via.hasCoord()) {
url.addQueryParameter("REQ0JourneyStops1.0X", Integer.toString(via.lon)); url.addQueryParameter("REQ0JourneyStops1.0X", Integer.toString(via.getLonAs1E6()));
url.addQueryParameter("REQ0JourneyStops1.0Y", Integer.toString(via.lat)); url.addQueryParameter("REQ0JourneyStops1.0Y", Integer.toString(via.getLatAs1E6()));
if (via.name == null) if (via.name == null)
url.addQueryParameter("REQ0JourneyStops1.0O", url.addQueryParameter("REQ0JourneyStops1.0O",
String.format(Locale.ENGLISH, "%.6f, %.6f", via.lat / 1E6, via.lon / 1E6)); String.format(Locale.ENGLISH, "%.6f, %.6f", via.getLatAsDouble(), via.getLonAsDouble()));
} else if (via.name != null) { } else if (via.name != null) {
url.addEncodedQueryParameter("REQ0JourneyStops1.0G", ParserUtils url.addEncodedQueryParameter("REQ0JourneyStops1.0G", ParserUtils
.urlEncode(via.name + (via.type != LocationType.ANY ? "!" : ""), requestUrlEncoding)); .urlEncode(via.name + (via.type != LocationType.ANY ? "!" : ""), requestUrlEncoding));
@ -2029,13 +2030,13 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
if (type == 1) { if (type == 1) {
final String[] placeAndName = splitStationName(name); final String[] placeAndName = splitStationName(name);
return new Location(LocationType.STATION, null, lat, lon, placeAndName[0], placeAndName[1]); return new Location(LocationType.STATION, null, Point.from1E6(lat, lon), placeAndName[0], placeAndName[1]);
} else if (type == 2) { } else if (type == 2) {
final String[] placeAndName = splitAddress(name); final String[] placeAndName = splitAddress(name);
return new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], placeAndName[1]); return new Location(LocationType.ADDRESS, null, Point.from1E6(lat, lon), placeAndName[0], placeAndName[1]);
} else if (type == 3) { } else if (type == 3) {
final String[] placeAndName = splitPOI(name); final String[] placeAndName = splitPOI(name);
return new Location(LocationType.POI, null, lat, lon, placeAndName[0], placeAndName[1]); return new Location(LocationType.POI, null, Point.from1E6(lat, lon), placeAndName[0], placeAndName[1]);
} else { } else {
throw new IllegalStateException("unknown type: " + type + " " + name); throw new IllegalStateException("unknown type: " + type + " " + name);
} }
@ -2185,8 +2186,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final int lon = stationInputStream.readIntReverse(); final int lon = stationInputStream.readIntReverse();
final int lat = stationInputStream.readIntReverse(); final int lat = stationInputStream.readIntReverse();
return new Location(LocationType.STATION, id != 0 ? Integer.toString(id) : null, lat, lon, return new Location(LocationType.STATION, id != 0 ? Integer.toString(id) : null,
placeAndName[0], placeAndName[1]); Point.from1E6(lat, lon), placeAndName[0], placeAndName[1]);
} finally { } finally {
stationInputStream.close(); stationInputStream.close();
} }
@ -2196,23 +2197,23 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException { final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) if (location.hasCoord())
return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations); return nearbyLocationsByCoordinate(types, location.coord, maxDistance, maxLocations);
else if (location.type == LocationType.STATION && location.hasId()) else if (location.type == LocationType.STATION && location.hasId())
return nearbyStationsById(location.id, maxDistance); return nearbyStationsById(location.id, maxDistance);
else else
throw new IllegalArgumentException("cannot handle: " + location); throw new IllegalArgumentException("cannot handle: " + location);
} }
protected final NearbyLocationsResult nearbyLocationsByCoordinate(final EnumSet<LocationType> types, final int lat, protected final NearbyLocationsResult nearbyLocationsByCoordinate(final EnumSet<LocationType> types,
final int lon, final int maxDistance, final int maxLocations) throws IOException { final Point coord, final int maxDistance, final int maxLocations) throws IOException {
if (types.contains(LocationType.STATION)) { if (types.contains(LocationType.STATION)) {
final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage + "y"); final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage + "y");
appendJsonNearbyStationsParameters(url, lat, lon, maxDistance, maxLocations); appendJsonNearbyStationsParameters(url, coord, maxDistance, maxLocations);
return jsonNearbyLocations(url.build()); return jsonNearbyLocations(url.build());
} else if (types.contains(LocationType.POI)) { } else if (types.contains(LocationType.POI)) {
final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage + "y"); final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage + "y");
appendJsonNearbyPOIsParameters(url, lat, lon, maxDistance, maxLocations); appendJsonNearbyPOIsParameters(url, coord, maxDistance, maxLocations);
return jsonNearbyLocations(url.build()); return jsonNearbyLocations(url.build());
} else { } else {
return new NearbyLocationsResult(null, Collections.<Location> emptyList()); return new NearbyLocationsResult(null, Collections.<Location> emptyList());
@ -2239,12 +2240,11 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
private static final Pattern P_XML_NEARBY_STATIONS_COARSE = Pattern.compile("\\G<\\s*St\\s*(.*?)/?>(?:\n|\\z)", private static final Pattern P_XML_NEARBY_STATIONS_COARSE = Pattern.compile("\\G<\\s*St\\s*(.*?)/?>(?:\n|\\z)",
Pattern.DOTALL); Pattern.DOTALL);
private static final Pattern P_XML_NEARBY_STATIONS_FINE = Pattern.compile( private static final Pattern P_XML_NEARBY_STATIONS_FINE = Pattern.compile("" //
"" // + "evaId=\"(\\d+)\"\\s*" // id
+ "evaId=\"(\\d+)\"\\s*" // id + "name=\"([^\"]+)\".*?" // name
+ "name=\"([^\"]+)\".*?" // name + "(?:x=\"(\\d+)\"\\s*)?" // x
+ "(?:x=\"(\\d+)\"\\s*)?" // x + "(?:y=\"(\\d+)\"\\s*)?" // y
+ "(?:y=\"(\\d+)\"\\s*)?" // y
, Pattern.DOTALL); , Pattern.DOTALL);
private static final Pattern P_XML_NEARBY_STATIONS_MESSAGES = Pattern private static final Pattern P_XML_NEARBY_STATIONS_MESSAGES = Pattern
.compile("<Err code=\"([^\"]*)\" text=\"([^\"]*)\""); .compile("<Err code=\"([^\"]*)\" text=\"([^\"]*)\"");
@ -2276,19 +2276,15 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final String parsedName = ParserUtils.resolveEntities(mFine.group(2)).trim(); final String parsedName = ParserUtils.resolveEntities(mFine.group(2)).trim();
final int parsedLon; final Point parsedCoord;
final int parsedLat; if (mFine.group(3) != null && mFine.group(4) != null)
if (mFine.group(3) != null && mFine.group(4) != null) { parsedCoord = Point.from1E6(Integer.parseInt(mFine.group(4)), Integer.parseInt(mFine.group(3)));
parsedLon = Integer.parseInt(mFine.group(3)); else
parsedLat = Integer.parseInt(mFine.group(4)); parsedCoord = null;
} else {
parsedLon = 0;
parsedLat = 0;
}
final String[] placeAndName = splitStationName(parsedName); final String[] placeAndName = splitStationName(parsedName);
stations.add(new Location(LocationType.STATION, parsedId, parsedLat, parsedLon, placeAndName[0], stations.add(
placeAndName[1])); new Location(LocationType.STATION, parsedId, parsedCoord, placeAndName[0], placeAndName[1]));
} else { } else {
throw new IllegalArgumentException("cannot parse '" + mCoarse.group(1) + "' on " + url); throw new IllegalArgumentException("cannot parse '" + mCoarse.group(1) + "' on " + url);
} }
@ -2297,7 +2293,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
return new NearbyLocationsResult(null, stations); return new NearbyLocationsResult(null, stations);
} }
protected void appendJsonNearbyStationsParameters(final HttpUrl.Builder url, final int lat, final int lon, protected void appendJsonNearbyStationsParameters(final HttpUrl.Builder url, final Point coord,
final int maxDistance, final int maxStations) { final int maxDistance, final int maxStations) {
url.addQueryParameter("performLocating", "2"); url.addQueryParameter("performLocating", "2");
url.addQueryParameter("tpl", "stop2json"); url.addQueryParameter("tpl", "stop2json");
@ -2309,19 +2305,19 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
// density|80 // density|80
// get_stopweight|yes // get_stopweight|yes
// get_infotext|yes // get_infotext|yes
url.addQueryParameter("look_x", Integer.toString(lon)); url.addQueryParameter("look_x", Integer.toString(coord.getLonAs1E6()));
url.addQueryParameter("look_y", Integer.toString(lat)); url.addQueryParameter("look_y", Integer.toString(coord.getLatAs1E6()));
url.addQueryParameter("look_maxno", Integer.toString(maxStations != 0 ? maxStations : 200)); url.addQueryParameter("look_maxno", Integer.toString(maxStations != 0 ? maxStations : 200));
url.addQueryParameter("look_maxdist", Integer.toString(maxDistance != 0 ? maxDistance : 5000)); url.addQueryParameter("look_maxdist", Integer.toString(maxDistance != 0 ? maxDistance : 5000));
} }
protected void appendJsonNearbyPOIsParameters(final HttpUrl.Builder url, final int lat, final int lon, protected void appendJsonNearbyPOIsParameters(final HttpUrl.Builder url, final Point coord, final int maxDistance,
final int maxDistance, final int maxStations) { final int maxStations) {
url.addQueryParameter("performLocating", "4"); url.addQueryParameter("performLocating", "4");
url.addQueryParameter("tpl", "poi2json"); url.addQueryParameter("tpl", "poi2json");
url.addQueryParameter("look_pois", ""); // all categories url.addQueryParameter("look_pois", ""); // all categories
url.addQueryParameter("look_x", Integer.toString(lon)); url.addQueryParameter("look_x", Integer.toString(coord.getLonAs1E6()));
url.addQueryParameter("look_y", Integer.toString(lat)); url.addQueryParameter("look_y", Integer.toString(coord.getLatAs1E6()));
url.addQueryParameter("look_maxno", Integer.toString(maxStations != 0 ? maxStations : 200)); url.addQueryParameter("look_maxno", Integer.toString(maxStations != 0 ? maxStations : 200));
url.addQueryParameter("look_maxdist", Integer.toString(maxDistance != 0 ? maxDistance : 5000)); url.addQueryParameter("look_maxdist", Integer.toString(maxDistance != 0 ? maxDistance : 5000));
} }
@ -2353,8 +2349,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
if (stopWeight != 0) { if (stopWeight != 0) {
final String[] placeAndName = splitStationName(urlname); final String[] placeAndName = splitStationName(urlname);
final Set<Product> products = prodclass != -1 ? intToProducts(prodclass) : null; final Set<Product> products = prodclass != -1 ? intToProducts(prodclass) : null;
locations.add(new Location(LocationType.STATION, id, lat, lon, placeAndName[0], locations.add(new Location(LocationType.STATION, id, Point.from1E6(lat, lon),
placeAndName[1], products)); placeAndName[0], placeAndName[1], products));
} }
} }
} }
@ -2373,7 +2369,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final int lon = poi.getInt("x"); final int lon = poi.getInt("x");
final String[] placeAndName = splitPOI(urlname); final String[] placeAndName = splitPOI(urlname);
locations.add(new Location(LocationType.POI, id, lat, lon, placeAndName[0], placeAndName[1])); locations.add(new Location(LocationType.POI, id, Point.from1E6(lat, lon), placeAndName[0],
placeAndName[1]));
} }
} }

View file

@ -310,8 +310,8 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
private String printLocation(final Location location) { private String printLocation(final Location location) {
if (location.hasId()) if (location.hasId())
return location.id; return location.id;
else if (location.hasLocation()) else if (location.hasCoord())
return (double) (location.lon) / 1E6 + ";" + (double) (location.lat) / 1E6; return location.getLonAsDouble() + ";" + location.getLatAsDouble();
else else
return ""; return "";
} }
@ -695,9 +695,9 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
// Build url depending of location type. // Build url depending of location type.
final HttpUrl.Builder url = url(); final HttpUrl.Builder url = url();
if (location.hasLocation()) { if (location.hasCoord()) {
final double lon = location.lon / 1E6; final double lon = location.getLonAsDouble();
final double lat = location.lat / 1E6; final double lat = location.getLatAsDouble();
url.addPathSegment("coords").addPathSegment(lon + ";" + lat); url.addPathSegment("coords").addPathSegment(lon + ";" + lat);
} else if (location.type == LocationType.STATION) { } else if (location.type == LocationType.STATION) {
if (!location.isIdentified()) if (!location.isIdentified())

View file

@ -112,8 +112,8 @@ public class BayernProvider extends AbstractEfaProvider {
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException { final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) if (location.hasCoord())
return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); return mobileCoordRequest(types, location.coord, maxDistance, maxLocations);
if (location.type != LocationType.STATION) if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type); throw new IllegalArgumentException("cannot handle: " + location.type);

View file

@ -157,7 +157,7 @@ public class HslProvider extends AbstractNetworkProvider {
final String id = xmlValueTag(pp, "code"); final String id = xmlValueTag(pp, "code");
final String name = xmlValueTag(pp, "name_fi"); final String name = xmlValueTag(pp, "name_fi");
final Point pt = coordStrToPoint(xmlValueTag(pp, "coords")); final Point pt = coordStrToPoint(xmlValueTag(pp, "coords"));
result.set(new Location(LocationType.STATION, id, pt.lat, pt.lon, null, name)); result.set(new Location(LocationType.STATION, id, pt, null, name));
} catch (final XmlPullParserException x) { } catch (final XmlPullParserException x) {
throw new ParserException("cannot parse xml: " + bodyPeek, x); throw new ParserException("cannot parse xml: " + bodyPeek, x);
} }
@ -175,7 +175,7 @@ public class HslProvider extends AbstractNetworkProvider {
public NearbyLocationsResult queryNearbyLocations(EnumSet<LocationType> types, Location location, int maxDistance, public NearbyLocationsResult queryNearbyLocations(EnumSet<LocationType> types, Location location, int maxDistance,
int maxStations) throws IOException { int maxStations) throws IOException {
final HttpUrl.Builder url = apiUrl("stops_area"); final HttpUrl.Builder url = apiUrl("stops_area");
if (!location.hasLocation()) { if (!location.hasCoord()) {
if (location.type != LocationType.STATION) if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type); throw new IllegalArgumentException("cannot handle: " + location.type);
if (!location.hasId()) if (!location.hasId())
@ -209,7 +209,7 @@ public class HslProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "node"); XmlPullUtil.skipExit(pp, "node");
stations.add(new Location(LocationType.STATION, id, pt.lat, pt.lon, place, name)); stations.add(new Location(LocationType.STATION, id, pt, place, name));
} }
result.set(new NearbyLocationsResult(header, stations)); result.set(new NearbyLocationsResult(header, stations));
@ -384,8 +384,7 @@ public class HslProvider extends AbstractNetworkProvider {
if (shortCode != null) if (shortCode != null)
name = name + " (" + shortCode + ")"; name = name + " (" + shortCode + ")";
locations locations.add(new SuggestedLocation(new Location(type, id, pt, null, name), weight));
.add(new SuggestedLocation(new Location(type, id, pt.lat, pt.lon, null, name), weight));
weight -= 1; weight -= 1;
} }
@ -628,7 +627,7 @@ public class HslProvider extends AbstractNetworkProvider {
LocationType type = LocationType.ANY; LocationType type = LocationType.ANY;
if (code != null) if (code != null)
type = LocationType.STATION; type = LocationType.STATION;
Location loc = new Location(type, code, pt.lat, pt.lon, stopAddress, name); Location loc = new Location(type, code, pt, stopAddress, name);
if (path.size() == 0) { if (path.size() == 0) {
departure = loc; departure = loc;
@ -653,8 +652,8 @@ public class HslProvider extends AbstractNetworkProvider {
if (legType.equals("walk")) { if (legType.equals("walk")) {
// ugly hack to set the name of the last arrival // ugly hack to set the name of the last arrival
if (arrival != null && arrival.name == null) { if (arrival != null && arrival.name == null) {
arrival = new Location(arrival.type, arrival.id, arrival.lat, arrival.lon, arrival = new Location(arrival.type, arrival.id, arrival.coord, arrival.place,
arrival.place, to.name); to.name);
} }
legs.add(new Trip.Individual(Trip.Individual.Type.WALK, departure, departureTime, legs.add(new Trip.Individual(Trip.Individual.Type.WALK, departure, departureTime,

View file

@ -232,10 +232,6 @@ public class NegentweeProvider extends AbstractNetworkProvider {
} }
} }
private Point pointFromLocation(Location location) throws JSONException {
return new Point(location.lat, location.lon);
}
private LocationType locationTypeFromTypeString(String type) throws JSONException { private LocationType locationTypeFromTypeString(String type) throws JSONException {
switch (type) { switch (type) {
case "station": case "station":
@ -322,7 +318,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
private String locationToQueryParameterString(Location loc) { private String locationToQueryParameterString(Location loc) {
if (loc.hasId()) { if (loc.hasId()) {
return loc.id; return loc.id;
} else if (loc.hasLocation()) { } else if (loc.hasCoord()) {
return loc.getLatAsDouble() + "," + loc.getLonAsDouble(); return loc.getLatAsDouble() + "," + loc.getLonAsDouble();
} else { } else {
return null; return null;
@ -408,18 +404,18 @@ public class NegentweeProvider extends AbstractNetworkProvider {
// First stop // First stop
Stop firstStop = stopFromJSONObject(stops.getJSONObject(0)); Stop firstStop = stopFromJSONObject(stops.getJSONObject(0));
foundPoints.add(pointFromLocation(firstStop.location)); foundPoints.add(firstStop.location.coord);
// Intermediate stops // Intermediate stops
LinkedList<Stop> foundStops = new LinkedList<>(); LinkedList<Stop> foundStops = new LinkedList<>();
for (int j = 1; j < stops.length() - 1; j++) { for (int j = 1; j < stops.length() - 1; j++) {
foundStops.add(stopFromJSONObject(stops.getJSONObject(j))); foundStops.add(stopFromJSONObject(stops.getJSONObject(j)));
foundPoints.add(pointFromLocation(foundStops.getLast().location)); foundPoints.add(foundStops.getLast().location.coord);
} }
// Last stop // Last stop
Stop lastStop = stopFromJSONObject(stops.getJSONObject(stops.length() - 1)); Stop lastStop = stopFromJSONObject(stops.getJSONObject(stops.length() - 1));
foundPoints.add(pointFromLocation(lastStop.location)); foundPoints.add(lastStop.location.coord);
switch (leg.getString("type").toLowerCase()) { switch (leg.getString("type").toLowerCase()) {
case "scheduled": case "scheduled":
@ -578,14 +574,14 @@ public class NegentweeProvider extends AbstractNetworkProvider {
Point locationPoint = Point.fromDouble(latlon.getDouble("lat"), latlon.getDouble("long")); Point locationPoint = Point.fromDouble(latlon.getDouble("lat"), latlon.getDouble("long"));
return new Location(locationTypeFromTypeString(locationType), location.getString("id"), locationPoint.lat, return new Location(locationTypeFromTypeString(locationType), location.getString("id"), locationPoint,
locationPoint.lon, !(place == null) ? place.optString("name", null) : null, locationName, null); !(place == null) ? place.optString("name", null) : null, locationName, null);
} }
private List<Location> solveAmbiguousLocation(Location location) throws IOException { private List<Location> solveAmbiguousLocation(Location location) throws IOException {
if (location.hasId()) { if (location.hasId()) {
return Arrays.asList(location); return Arrays.asList(location);
} else if (location.hasLocation()) { } else if (location.hasCoord()) {
return queryNearbyLocations(EnumSet.of(location.type), location, -1, -1).locations; return queryNearbyLocations(EnumSet.of(location.type), location, -1, -1).locations;
} else if (location.hasName()) { } else if (location.hasName()) {
return queryLocationsByName(location.name, EnumSet.of(location.type)); return queryLocationsByName(location.name, EnumSet.of(location.type));
@ -715,7 +711,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
public NearbyLocationsResult queryNearbyLocations(EnumSet<LocationType> types, Location location, int maxDistance, public NearbyLocationsResult queryNearbyLocations(EnumSet<LocationType> types, Location location, int maxDistance,
int maxLocations) throws IOException { int maxLocations) throws IOException {
// Coordinates are required // Coordinates are required
if (!location.hasLocation()) { if (!location.hasCoord()) {
try { try {
if (location.hasId()) { if (location.hasId()) {
location = queryLocationById(location.id); location = queryLocationById(location.id);
@ -728,7 +724,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
return new NearbyLocationsResult(this.resultHeader, NearbyLocationsResult.Status.SERVICE_DOWN); return new NearbyLocationsResult(this.resultHeader, NearbyLocationsResult.Status.SERVICE_DOWN);
} }
if (location == null || !location.hasLocation()) { if (location == null || !location.hasCoord()) {
return new NearbyLocationsResult(this.resultHeader, NearbyLocationsResult.Status.INVALID_ID); return new NearbyLocationsResult(this.resultHeader, NearbyLocationsResult.Status.INVALID_ID);
} }
} }
@ -814,7 +810,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
lineDestinationResult.add(new LineDestination( lineDestinationResult.add(new LineDestination(
new Line(null, departure.getString("operatorName"), lineProduct, mode.getString("name"), new Line(null, departure.getString("operatorName"), lineProduct, mode.getString("name"),
null, Standard.STYLES.get(lineProduct), null, null), null, Standard.STYLES.get(lineProduct), null, null),
new Location(LocationType.STATION, null, 0, 0, null, new Location(LocationType.STATION, null, null, null,
departure.getString("destinationName"), EnumSet.of(lineProduct)))); departure.getString("destinationName"), EnumSet.of(lineProduct))));
} }
@ -864,10 +860,10 @@ public class NegentweeProvider extends AbstractNetworkProvider {
@Override @Override
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep, public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
@Nullable TripOptions options) throws IOException { @Nullable TripOptions options) throws IOException {
if (!(from.hasId() || from.hasLocation())) if (!(from.hasId() || from.hasCoord()))
return ambiguousQueryTrips(from, via, to); return ambiguousQueryTrips(from, via, to);
if (!(to.hasId() || to.hasLocation())) if (!(to.hasId() || to.hasCoord()))
return ambiguousQueryTrips(from, via, to); return ambiguousQueryTrips(from, via, to);
// Default query options // Default query options
@ -880,7 +876,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
new QueryParameter("before", "1"), new QueryParameter("after", "5"))); new QueryParameter("before", "1"), new QueryParameter("after", "5")));
if (via != null) { if (via != null) {
if (!(via.hasId() || via.hasLocation())) if (!(via.hasId() || via.hasCoord()))
return ambiguousQueryTrips(from, via, to); return ambiguousQueryTrips(from, via, to);
queryParameters.add(new QueryParameter("via", locationToQueryParameterString(via))); queryParameters.add(new QueryParameter("via", locationToQueryParameterString(via)));

View file

@ -53,8 +53,8 @@ public class StvProvider extends AbstractEfaProvider {
@Override @Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException { final int maxDistance, final int maxLocations) throws IOException {
if (location.hasLocation()) if (location.hasCoord())
return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); return mobileCoordRequest(types, location.coord, maxDistance, maxLocations);
if (location.type != LocationType.STATION) if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type); throw new IllegalArgumentException("cannot handle: " + location.type);

View file

@ -363,9 +363,9 @@ public class VrsProvider extends AbstractNetworkProvider {
// g=p means group by product; not used here // g=p means group by product; not used here
final HttpUrl.Builder url = API_BASE.newBuilder(); final HttpUrl.Builder url = API_BASE.newBuilder();
url.addQueryParameter("eID", "tx_vrsinfo_ass2_timetable"); url.addQueryParameter("eID", "tx_vrsinfo_ass2_timetable");
if (location.hasLocation()) { if (location.hasCoord()) {
url.addQueryParameter("r", url.addQueryParameter("r",
String.format(Locale.ENGLISH, "%.6f,%.6f", location.lat / 1E6, location.lon / 1E6)); String.format(Locale.ENGLISH, "%.6f,%.6f", location.getLatAsDouble(), location.getLonAsDouble()));
} else if (location.type == LocationType.STATION && location.hasId()) { } else if (location.type == LocationType.STATION && location.hasId()) {
url.addQueryParameter("i", location.id); url.addQueryParameter("i", location.id);
} else { } else {
@ -857,15 +857,15 @@ public class VrsProvider extends AbstractNetworkProvider {
} }
List<Point> points = new ArrayList<>(); List<Point> points = new ArrayList<>();
points.add(new Point(segmentOrigin.lat, segmentOrigin.lon)); points.add(segmentOrigin.coord);
if (EXACT_POINTS && segment.has("polygon")) { if (EXACT_POINTS && segment.has("polygon")) {
parsePolygon(segment.getString("polygon"), points); parsePolygon(segment.getString("polygon"), points);
} else { } else {
for (Stop intermediateStop : intermediateStops) { for (Stop intermediateStop : intermediateStops) {
points.add(new Point(intermediateStop.location.lat, intermediateStop.location.lon)); points.add(intermediateStop.location.coord);
} }
} }
points.add(new Point(segmentDestination.lat, segmentDestination.lon)); points.add(segmentDestination.coord);
if (type.equals("walk")) { if (type.equals("walk")) {
if (departurePlanned == null) if (departurePlanned == null)
departurePlanned = legs.get(legs.size() - 1).getArrivalTime(); departurePlanned = legs.get(legs.size() - 1).getArrivalTime();
@ -941,8 +941,7 @@ public class VrsProvider extends AbstractNetworkProvider {
String pointsArr[] = polygonStr.split("\\s"); String pointsArr[] = polygonStr.split("\\s");
for (String point : pointsArr) { for (String point : pointsArr) {
String latlon[] = point.split(","); String latlon[] = point.split(",");
polygonArr.add(new Point((int) Math.round(Double.parseDouble(latlon[0]) * 1E6), polygonArr.add(Point.fromDouble(Double.parseDouble(latlon[0]), Double.parseDouble(latlon[1])));
(int) Math.round(Double.parseDouble(latlon[1]) * 1E6)));
} }
} }
} }
@ -970,7 +969,7 @@ public class VrsProvider extends AbstractNetworkProvider {
@Override @Override
public Point[] getArea() throws IOException { public Point[] getArea() throws IOException {
return new Point[] { new Point(50937531, 6960279) }; return new Point[] { Point.from1E6(50937531, 6960279) };
} }
private static Product productFromLineNumber(String number) { private static Product productFromLineNumber(String number) {
@ -1113,9 +1112,10 @@ public class VrsProvider extends AbstractNetworkProvider {
place += "-" + location.getString("district"); place += "-" + location.getString("district");
} }
} }
final int lat = (int) Math.round(location.optDouble("x", 0) * 1E6); final double lat = location.optDouble("x", 0);
final int lon = (int) Math.round(location.optDouble("y", 0) * 1E6); final double lon = location.optDouble("y", 0);
return new LocationWithPosition(new Location(locationType, id, lat, lon, place, name), final Point coord = Point.fromDouble(lat, lon);
return new LocationWithPosition(new Location(locationType, id, coord, place, name),
position != null ? new Position(position.substring(position.lastIndexOf(" ") + 1)) : null); position != null ? new Position(position.substring(position.lastIndexOf(" ") + 1)) : null);
} }
@ -1124,8 +1124,8 @@ public class VrsProvider extends AbstractNetworkProvider {
return null; return null;
} else if (loc.id != null) { } else if (loc.id != null) {
return loc.id; return loc.id;
} else if (loc.lat != 0 && loc.lon != 0) { } else if (loc.coord != null) {
return String.format(Locale.ENGLISH, "%f,%f", loc.lat / 1E6, loc.lon / 1E6); return String.format(Locale.ENGLISH, "%f,%f", loc.getLatAsDouble(), loc.getLonAsDouble());
} else { } else {
SuggestLocationsResult suggestLocationsResult = suggestLocations(loc.name); SuggestLocationsResult suggestLocationsResult = suggestLocations(loc.name);
final List<Location> suggestedLocations = suggestLocationsResult.getLocations(); final List<Location> suggestedLocations = suggestLocationsResult.getLocations();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 the original author or authors. * Copyright the original author or authors.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -39,17 +39,16 @@ public final class Location implements Serializable {
public final LocationType type; public final LocationType type;
public final @Nullable String id; public final @Nullable String id;
public final int lat, lon; public final @Nullable Point coord;
public final @Nullable String place; public final @Nullable String place;
public final @Nullable String name; public final @Nullable String name;
public final @Nullable Set<Product> products; public final @Nullable Set<Product> products;
public Location(final LocationType type, final String id, final int lat, final int lon, final String place, public Location(final LocationType type, final String id, final Point coord, final String place, final String name,
final String name, final Set<Product> products) { final Set<Product> products) {
this.type = checkNotNull(type); this.type = checkNotNull(type);
this.id = id; this.id = id;
this.lat = lat; this.coord = coord;
this.lon = lon;
this.place = place; this.place = place;
this.name = name; this.name = name;
this.products = products; this.products = products;
@ -59,36 +58,22 @@ public final class Location implements Serializable {
if (type == LocationType.ANY) { if (type == LocationType.ANY) {
checkArgument(id == null, "type ANY cannot have ID"); checkArgument(id == null, "type ANY cannot have ID");
} else if (type == LocationType.COORD) { } else if (type == LocationType.COORD) {
checkArgument(hasLocation(), "coordinates missing"); checkArgument(hasCoord(), "coordinates missing");
checkArgument(place == null && name == null, "coordinates cannot have place or name"); checkArgument(place == null && name == null, "coordinates cannot have place or name");
} }
} }
public Location(final LocationType type, final String id, final int lat, final int lon, final String place,
final String name) {
this(type, id, lat, lon, place, name, null);
}
public Location(final LocationType type, final String id, final Point coord, final String place, final String name,
final Set<Product> products) {
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name, products);
}
public Location(final LocationType type, final String id, final Point coord, final String place, public Location(final LocationType type, final String id, final Point coord, final String place,
final String name) { final String name) {
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, place, name); this(type, id, coord, place, name, null);
} }
public Location(final LocationType type, final String id, final String place, final String name) { public Location(final LocationType type, final String id, final String place, final String name) {
this(type, id, 0, 0, place, name); this(type, id, null, place, name);
}
public Location(final LocationType type, final String id, final int lat, final int lon) {
this(type, id, lat, lon, null, null);
} }
public Location(final LocationType type, final String id, final Point coord) { public Location(final LocationType type, final String id, final Point coord) {
this(type, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0); this(type, id, coord, null, null);
} }
public Location(final LocationType type, final String id) { public Location(final LocationType type, final String id) {
@ -96,27 +81,35 @@ public final class Location implements Serializable {
} }
public static Location coord(final int lat, final int lon) { public static Location coord(final int lat, final int lon) {
return new Location(LocationType.COORD, null, lat, lon); return new Location(LocationType.COORD, null, Point.from1E6(lat, lon));
} }
public static Location coord(final Point coord) { public static Location coord(final Point coord) {
return new Location(LocationType.COORD, null, coord.lat, coord.lon); return new Location(LocationType.COORD, null, coord);
} }
public final boolean hasId() { public final boolean hasId() {
return !Strings.isNullOrEmpty(id); return !Strings.isNullOrEmpty(id);
} }
public final boolean hasLocation() { public final boolean hasCoord() {
return lat != 0 || lon != 0; return coord != null;
} }
public double getLatAsDouble() { public double getLatAsDouble() {
return lat / 1E6; return coord.getLatAsDouble();
} }
public double getLonAsDouble() { public double getLonAsDouble() {
return lon / 1E6; return coord.getLonAsDouble();
}
public int getLatAs1E6() {
return coord.getLatAs1E6();
}
public int getLonAs1E6() {
return coord.getLonAs1E6();
} }
public final boolean hasName() { public final boolean hasName() {
@ -131,7 +124,7 @@ public final class Location implements Serializable {
return true; return true;
if (type == LocationType.ADDRESS || type == LocationType.COORD) if (type == LocationType.ADDRESS || type == LocationType.COORD)
return hasLocation(); return hasCoord();
return false; return false;
} }
@ -165,8 +158,8 @@ public final class Location implements Serializable {
return false; return false;
if (this.id != null) if (this.id != null)
return Objects.equal(this.id, other.id); return Objects.equal(this.id, other.id);
if (this.lat != 0 && this.lon != 0) if (this.coord != null)
return this.lat == other.lat && this.lon == other.lon; return Objects.equal(this.coord, other.coord);
// only discriminate by name/place if no ids are given // only discriminate by name/place if no ids are given
if (!Objects.equal(this.place, other.place)) if (!Objects.equal(this.place, other.place))
@ -185,7 +178,7 @@ public final class Location implements Serializable {
return false; return false;
if (!Objects.equal(this.id, other.id)) if (!Objects.equal(this.id, other.id))
return false; return false;
if (this.lat != other.lat && this.lon != other.lon) if (!Objects.equal(this.coord, other.coord))
return false; return false;
if (!Objects.equal(this.place, other.place)) if (!Objects.equal(this.place, other.place))
return false; return false;
@ -201,14 +194,14 @@ public final class Location implements Serializable {
if (id != null) if (id != null)
return Objects.hashCode(type, id); return Objects.hashCode(type, id);
else else
return Objects.hashCode(type, lat, lon); return Objects.hashCode(type, coord);
} }
@Override @Override
public String toString() { public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(type).addValue(id); final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(type).addValue(id);
if (hasLocation()) if (hasCoord())
helper.addValue(lat + "/" + lon); helper.addValue(coord);
return helper.add("place", place).add("name", name).add("products", products).omitNullValues().toString(); return helper.add("place", place).add("name", name).add("products", products).omitNullValues().toString();
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 the original author or authors. * Copyright the original author or authors.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,6 +18,7 @@
package de.schildbach.pte.dto; package de.schildbach.pte.dto;
import java.io.Serializable; import java.io.Serializable;
import java.util.Locale;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -27,23 +28,35 @@ import com.google.common.base.Objects;
public final class Point implements Serializable { public final class Point implements Serializable {
private static final long serialVersionUID = -256077054671402897L; private static final long serialVersionUID = -256077054671402897L;
public final int lat, lon; private final double lat, lon;
public Point(final int lat, final int lon) { private Point(final double lat, final double lon) {
this.lat = lat; this.lat = lat;
this.lon = lon; this.lon = lon;
} }
public static Point fromDouble(final double lat, final double lon) { public static Point fromDouble(final double lat, final double lon) {
return new Point((int) Math.round(lat * 1E6), (int) Math.round(lon * 1E6)); return new Point(lat, lon);
}
public static Point from1E6(final int lat, final int lon) {
return new Point(lat / 1E6, lon / 1E6);
} }
public double getLatAsDouble() { public double getLatAsDouble() {
return lat / 1E6; return lat;
} }
public double getLonAsDouble() { public double getLonAsDouble() {
return lon / 1E6; return lon;
}
public int getLatAs1E6() {
return (int) Math.round(lat * 1E6);
}
public int getLonAs1E6() {
return (int) Math.round(lon * 1E6);
} }
@Override @Override
@ -67,6 +80,6 @@ public final class Point implements Serializable {
@Override @Override
public String toString() { public String toString() {
return lat + "/" + lon; return String.format(Locale.ENGLISH, "%.7f/%.7f", lat, lon);
} }
} }

View file

@ -240,9 +240,8 @@ public final class Trip implements Serializable {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
for (final Leg leg : legs) { for (final Leg leg : legs) {
builder.append(leg.departure.hasId() ? leg.departure.id : leg.departure.lat + '/' + leg.departure.lon) builder.append(leg.departure.hasId() ? leg.departure.id : leg.departure.coord).append('-');
.append('-'); builder.append(leg.arrival.hasId() ? leg.arrival.id : leg.arrival.coord).append('-');
builder.append(leg.arrival.hasId() ? leg.arrival.id : leg.arrival.lat + '/' + leg.arrival.lon).append('-');
if (leg instanceof Individual) { if (leg instanceof Individual) {
builder.append("individual"); builder.append("individual");

View file

@ -32,6 +32,7 @@ import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
@ -124,11 +125,11 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void slowTrip() throws Exception { public void slowTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "732655", Point.from1E6(52535576, 13422171), null,
new Location(LocationType.STATION, "732655", 52535576, 13422171, null, "Marienburger Str., Berlin"), "Marienburger Str., Berlin");
null, new Location(LocationType.STATION, "623234", 48000221, 11342490, null, final Location to = new Location(LocationType.STATION, "623234", Point.from1E6(48000221, 11342490), null,
"Tutzinger-Hof-Platz, Starnberg"), "Tutzinger-Hof-Platz, Starnberg");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())
@ -148,12 +149,11 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripWithFootway() throws Exception { public void tripWithFootway() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52517139, 13388749), null,
new Location(LocationType.ADDRESS, null, 52517139, 13388749, null, "Berlin - Mitte, Unter den Linden 24");
"Berlin - Mitte, Unter den Linden 24"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(47994243, 11338543), null,
null, new Location(LocationType.ADDRESS, null, 47994243, 11338543, null, "Starnberg, Possenhofener Straße 13");
"Starnberg, Possenhofener Straße 13"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -31,6 +31,7 @@ import de.schildbach.pte.BayernProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -145,8 +146,9 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenCoordinateAndStation() throws Exception { public void tripBetweenCoordinateAndStation() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 48238341, 11478230), null, final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48238341, 11478230));
new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"), new Date(), true, null); final Location to = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())
@ -172,9 +174,10 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenStationAndAddress() throws Exception { public void tripBetweenStationAndAddress() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1001220", null, "Josephsburg"), final Location from = new Location(LocationType.STATION, "1001220", null, "Josephsburg");
null, new Location(LocationType.ADDRESS, null, 48188018, 11574239, null, "München Frankfurter Ring 35"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(48188018, 11574239), null,
new Date(), true, null); "München Frankfurter Ring 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())
@ -186,10 +189,11 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenPOIs() throws Exception { public void tripBetweenPOIs() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.POI, null, Point.from1E6(47710568, 12621970), null,
new Location(LocationType.POI, null, 47710568, 12621970, null, "Ruhpolding, Seehaus"), null, "Ruhpolding, Seehaus");
new Location(LocationType.POI, null, 47738372, 12630996, null, "Ruhpolding, Unternberg-Bahn"), final Location to = new Location(LocationType.POI, null, Point.from1E6(47738372, 12630996), null,
new Date(), true, null); "Ruhpolding, Unternberg-Bahn");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -29,6 +29,7 @@ import de.schildbach.pte.BvgProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -131,10 +132,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenStations() throws Exception { public void tripBetweenStations() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "900055101", Point.from1E6(52496176, 13343273), null,
new Location(LocationType.STATION, "900055101", 52496176, 13343273, null, "U Viktoria-Luise-Platz"), "U Viktoria-Luise-Platz");
null, new Location(LocationType.STATION, "900089303", 52588810, 13288699, null, "S Tegel"), new Date(), final Location to = new Location(LocationType.STATION, "900089303", Point.from1E6(52588810, 13288699), null,
true, null); "S Tegel");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
} }
@ -160,12 +162,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenCoordinatesAndAddresses() throws Exception { public void tripBetweenCoordinatesAndAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52536099, 13426309), null,
new Location(LocationType.ADDRESS, null, 52536099, 13426309, null, "Christburger Straße 1, 10405 Berlin, Deutschland");
"Christburger Straße 1, 10405 Berlin, Deutschland"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52486400, 13350744), null,
null, new Location(LocationType.ADDRESS, null, 52486400, 13350744, null, "Eisenacher Straße 70, 10823 Berlin, Deutschland");
"Eisenacher Straße 70, 10823 Berlin, Deutschland"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -182,12 +183,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", "10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
"Weimarische Str. 7"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52541536, 13421290),
null, new Location(LocationType.ADDRESS, null, 52541536, 13421290, "10437 Berlin-Prenzlauer Berg", "10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5");
"Göhrener Str. 5"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -195,13 +195,13 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void viaTripBetweenAddresses() throws Exception { public void viaTripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", "10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
"Weimarische Str. 7"), final Location via = new Location(LocationType.ADDRESS, null, Point.from1E6(52527872, 13381657),
new Location(LocationType.ADDRESS, null, 52527872, 13381657, "10115 Berlin-Mitte", "10115 Berlin-Mitte", "Hannoversche Str. 20");
"Hannoversche Str. 20"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52526029, 13399878),
new Location(LocationType.ADDRESS, null, 52526029, 13399878, "10178 Berlin-Mitte", "Sophienstr. 24"), "10178 Berlin-Mitte", "Sophienstr. 24");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -209,12 +209,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripAddressWithoutId() throws Exception { public void tripAddressWithoutId() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52481922, 13388383), null,
new Location(LocationType.ADDRESS, null, 52481922, 13388383, null, "Bayernring, 12101 Berlin, Deutschland");
"Bayernring, 12101 Berlin, Deutschland"), final Location to = new Location(LocationType.STATION, "900064301", Point.from1E6(52429099, 13328081), null,
null, "S Lichterfelde Ost Bhf");
new Location(LocationType.STATION, "900064301", 52429099, 13328081, null, "S Lichterfelde Ost Bhf"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
} }
} }

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.CmtaProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -62,8 +63,8 @@ public class CmtaProviderLiveTest extends AbstractProviderLiveTest {
print(result); print(result);
assertThat(result.locations, assertThat(result.locations,
hasItem(new Location(LocationType.POI, hasItem(new Location(LocationType.POI,
"A=4@O=Texas State Capitol@X=-97740215@Y=30275103@u=0@U=130@L=9819105@", 30275103, -97740215, "A=4@O=Texas State Capitol@X=-97740215@Y=30275103@u=0@U=130@L=9819105@",
null, "Texas State Capitol"))); Point.from1E6(30275103, -97740215), null, "Texas State Capitol")));
} }
@Test @Test

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.GvhProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -136,10 +137,11 @@ public class GvhProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenAnyAndAddress() throws Exception { public void tripBetweenAnyAndAddress() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ANY, null, Point.from1E6(53069619, 8799202), null,
new Location(LocationType.ANY, null, 53069619, 8799202, null, "bremen, neustadtswall 12"), null, "bremen, neustadtswall 12");
new Location(LocationType.ADDRESS, null, 53104124, 8788575, null, "Bremen Glücksburger Straße 37"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(53104124, 8788575), null,
new Date(), true, null); "Bremen Glücksburger Straße 37");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -147,12 +149,11 @@ public class GvhProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(53622859, 10133545), null,
new Location(LocationType.ADDRESS, null, 53622859, 10133545, null, "Zamenhofweg 14, 22159 Hamburg, Deutschland");
"Zamenhofweg 14, 22159 Hamburg, Deutschland"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(53734260, 9674990), null,
null, new Location(LocationType.ADDRESS, null, 53734260, 9674990, null, "Lehmkuhlen 5, 25337 Elmshorn, Deutschland");
"Lehmkuhlen 5, 25337 Elmshorn, Deutschland"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.KvvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -81,11 +82,11 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "7000001", Point.from1E6(49009526, 8404914),
new Location(LocationType.STATION, "7000001", 49009526, 8404914, "Karlsruhe", "Marktplatz"), null, "Karlsruhe", "Marktplatz");
new Location(LocationType.STATION, "7000002", 49009393, 8408866, "Karlsruhe", final Location to = new Location(LocationType.STATION, "7000002", Point.from1E6(49009393, 8408866), "Karlsruhe",
"Kronenplatz (Kaiserstr.)"), "Kronenplatz (Kaiserstr.)");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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);
@ -111,12 +112,11 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48985089, 8402709), null,
new Location(LocationType.ADDRESS, null, 48985089, 8402709, null, "Konstanzer Straße 17, 76199 Karlsruhe, Deutschland");
"Konstanzer Straße 17, 76199 Karlsruhe, Deutschland"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(49007706, 8356358), null,
null, new Location(LocationType.ADDRESS, null, 49007706, 8356358, null, "Durmersheimer Straße 6, 76185 Karlsruhe, Deutschland");
"Durmersheimer Straße 6, 76185 Karlsruhe, Deutschland"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -27,6 +27,7 @@ import de.schildbach.pte.LuProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -81,9 +82,10 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void addressTrip() throws Exception { public void addressTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(49611610, 6130265), null,
new Location(LocationType.ADDRESS, null, 49611610, 6130265, null, "Luxembourg, Rue Génistre 2"), null, "Luxembourg, Rue Génistre 2");
new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale"), new Date(), true, null); final Location to = new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);

View file

@ -29,6 +29,7 @@ import de.schildbach.pte.MerseyProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -81,10 +82,11 @@ public class MerseyProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "4017846", Point.from1E6(53401672, -2958720),
new Location(LocationType.STATION, "4017846", 53401672, -2958720, "Liverpool", "Orphan Street"), null, "Liverpool", "Orphan Street");
new Location(LocationType.STATION, "4027286", 53397324, -2961676, "Liverpool", "Womens Hospital"), final Location to = new Location(LocationType.STATION, "4027286", Point.from1E6(53397324, -2961676),
new Date(), true, null); "Liverpool", "Womens Hospital");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -31,6 +31,7 @@ import de.schildbach.pte.MvvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -124,9 +125,10 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void longTrip() throws Exception { public void longTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "1005530", Point.from1E6(48002924, 11340144),
new Location(LocationType.STATION, "1005530", 48002924, 11340144, "Starnberg", "Agentur für Arbeit"), "Starnberg", "Agentur für Arbeit");
null, new Location(LocationType.STATION, null, null, "Ackermannstraße"), new Date(), true, null); final Location to = new Location(LocationType.STATION, null, null, "Ackermannstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
} }
@ -141,8 +143,9 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenCoordinateAndStation() throws Exception { public void tripBetweenCoordinateAndStation() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 48238341, 11478230), null, final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48238341, 11478230));
new Location(LocationType.ANY, null, null, "Ostbahnhof"), new Date(), true, null); final Location to = new Location(LocationType.ANY, null, null, "Ostbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -160,9 +163,10 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenStationAndAddress() throws Exception { public void tripBetweenStationAndAddress() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1220", null, "Josephsburg"), final Location from = new Location(LocationType.STATION, "1220", null, "Josephsburg");
null, new Location(LocationType.ADDRESS, null, 48188018, 11574239, null, "München Frankfurter Ring 35"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(48188018, 11574239), null,
new Date(), true, null); "München Frankfurter Ring 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -171,11 +175,11 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void queryTripInvalidStation() throws Exception { public void queryTripInvalidStation() throws Exception {
final QueryTripsResult result1 = queryTrips(new Location(LocationType.STATION, "2", "München", "Marienplatz"), final QueryTripsResult result1 = queryTrips(new Location(LocationType.STATION, "2", "München", "Marienplatz"),
null, new Location(LocationType.STATION, "99999", 0, 0, null, null), new Date(), true, null); null, new Location(LocationType.STATION, "99999", null, null), new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result1.status); assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result1.status);
final QueryTripsResult result2 = queryTrips(new Location(LocationType.STATION, "99999", 0, 0, null, null), null, final QueryTripsResult result2 = queryTrips(new Location(LocationType.STATION, "99999", null, null), null,
new Location(LocationType.STATION, "2", "München", "Marienplatz"), new Date(), true, null); new Location(LocationType.STATION, "2", "München", "Marienplatz"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result2.status); assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result2.status);

View file

@ -28,6 +28,7 @@ import de.schildbach.pte.NasaProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -103,10 +104,11 @@ public class NasaProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void anotherShortTrip() throws Exception { public void anotherShortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "8010205", Point.from1E6(51346546, 12383333), null,
new Location(LocationType.STATION, "8010205", 51346546, 12383333, null, "Leipzig Hbf"), null, "Leipzig Hbf");
new Location(LocationType.STATION, "8012183", 51423340, 12223423, null, "Leipzig/Halle Flughafen"), final Location to = new Location(LocationType.STATION, "8012183", Point.from1E6(51423340, 12223423), null,
new Date(), true, null); "Leipzig/Halle Flughafen");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
print(result); print(result);
@ -143,10 +145,10 @@ public class NasaProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void addressTrip() throws Exception { public void addressTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51334078, 12478331),
new Location(LocationType.ADDRESS, null, 51334078, 12478331, "04319 Leipzig-Engelsdorf", "04319 Leipzig-Engelsdorf", "August-Bebel-Platz");
"August-Bebel-Platz"), final Location to = new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf");
null, new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
print(result); print(result);

View file

@ -177,9 +177,10 @@ public class NegentweeProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void coordinatesTrip() throws Exception { public void coordinatesTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.COORD, null, new Point(51677273, 4437548)), final Location from = new Location(LocationType.COORD, null, Point.from1E6(51677273, 4437548));
new Location(LocationType.COORD, null, new Point(52162772, 4583171)), final Location via = new Location(LocationType.COORD, null, Point.from1E6(52162772, 4583171));
new Location(LocationType.COORD, null, new Point(53347140, 6720583)), new Date(), true, null); final Location to = new Location(LocationType.COORD, null, Point.from1E6(53347140, 6720583));
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
} }

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.NvbwProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -137,10 +138,11 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTripReutlingen() throws Exception { public void shortTripReutlingen() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "8029333", Point.from1E6(48492484, 9207456),
new Location(LocationType.STATION, "8029333", 48492484, 9207456, "Reutlingen", "ZOB"), null, "Reutlingen", "ZOB");
new Location(LocationType.STATION, "8029109", 48496968, 9213320, "Reutlingen", "Bismarckstr."), final Location to = new Location(LocationType.STATION, "8029109", Point.from1E6(48496968, 9213320),
new Date(), true, null); "Reutlingen", "Bismarckstr.");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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);
@ -166,11 +168,11 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void trip() throws Exception { public void trip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "6900037", Point.from1E6(48063184, 7779532),
new Location(LocationType.STATION, "6900037", 48063184, 7779532, "Buchheim (Breisgau)", "Fortuna"), "Buchheim (Breisgau)", "Fortuna");
null, new Location(LocationType.STATION, "6906508", 47996616, 7840450, "Freiburg im Breisgau", final Location to = new Location(LocationType.STATION, "6906508", Point.from1E6(47996616, 7840450),
"Freiburg im Breisgau, Hauptbahnhof"), "Freiburg im Breisgau", "Freiburg im Breisgau, Hauptbahnhof");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
} }

View file

@ -31,6 +31,7 @@ import de.schildbach.pte.NvvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
@ -193,10 +194,11 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest {
public void slowTrip() throws Exception { public void slowTrip() throws Exception {
final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.NORMAL, Accessibility.BARRIER_FREE, final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.NORMAL, Accessibility.BARRIER_FREE,
null); null);
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "3029079", Point.from1E6(50017679, 8229480), "Mainz",
new Location(LocationType.STATION, "3029079", 50017679, 8229480, "Mainz", "An den Dünen"), null, "An den Dünen");
new Location(LocationType.STATION, "3013508", 50142890, 8895203, "Hanau", "Beethovenplatz"), new Date(), final Location to = new Location(LocationType.STATION, "3013508", Point.from1E6(50142890, 8895203), "Hanau",
true, options); "Beethovenplatz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, options);
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);
@ -218,12 +220,11 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripUsingMuchBuffer() throws IOException { public void tripUsingMuchBuffer() throws IOException {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(50119563, 8697044), null,
new Location(LocationType.ADDRESS, null, 50119563, 8697044, null, "Hegelstrasse, 60316 Frankfurt am Main");
"Hegelstrasse, 60316 Frankfurt am Main"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(50100364, 8615193), null,
null, "Mainzer Landstrasse, Frankfurt");
new Location(LocationType.ADDRESS, null, 50100364, 8615193, null, "Mainzer Landstrasse, Frankfurt"), final QueryTripsResult result = queryTrips(from, null, to, new Date(1378368840000l), true, null);
new Date(1378368840000l), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())
@ -235,10 +236,11 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripUsingEvenMoreBuffer() throws IOException { public void tripUsingEvenMoreBuffer() throws IOException {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "3000909", Point.from1E6(50094052, 8690923), null,
new Location(LocationType.STATION, "3000909", 50094052, 8690923, null, "F Brauerei"), null, "F Brauerei");
new Location(LocationType.STATION, "3001201", 50119950, 8653924, null, "F Bockenheimer Warte"), final Location to = new Location(LocationType.STATION, "3001201", Point.from1E6(50119950, 8653924), null,
new Date(1378368840000l), true, null); "F Bockenheimer Warte");
final QueryTripsResult result = queryTrips(from, null, to, new Date(1378368840000l), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.OoevvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -141,10 +142,11 @@ public class OoevvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTripSalzburg() throws Exception { public void shortTripSalzburg() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409),
new Location(LocationType.STATION, "455000900", 47808976, 13056409, "Salzburg", "Vogelweiderstraße"), "Salzburg", "Vogelweiderstraße");
null, new Location(LocationType.STATION, "455084400", 47811556, 13050278, "Salzburg", "Merianstraße"), final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278),
new Date(), true, null); "Salzburg", "Merianstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -27,6 +27,7 @@ import de.schildbach.pte.RtProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -114,11 +115,11 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripFromAddress() throws Exception { public void tripFromAddress() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51521886, -51447), null,
new Location(LocationType.ADDRESS, null, 51521886, -51447, null, "26 Coopers Close, Poplar, Greater London E1 4, Vereinigtes Königreich");
"26 Coopers Close, Poplar, Greater London E1 4, Vereinigtes Königreich"), final Location to = new Location(LocationType.STATION, "8096022", Point.from1E6(50941312, 6967206), null,
null, new Location(LocationType.STATION, "8096022", 50941312, 6967206, null, "COLOGNE"), new Date(), "COLOGNE");
true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);

View file

@ -27,6 +27,7 @@ import de.schildbach.pte.SbbProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -103,10 +104,11 @@ public class SbbProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripWithFootway() throws Exception { public void tripWithFootway() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(46689354, 7683444), null,
new Location(LocationType.ADDRESS, null, 46689354, 7683444, null, "Spiez, Seestraße 62"), null, "Spiez, Seestraße 62");
new Location(LocationType.ADDRESS, null, 47133169, 8767425, null, "Einsiedeln, Erlenmoosweg 24"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(47133169, 8767425), null,
new Date(), true, null); "Einsiedeln, Erlenmoosweg 24");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -114,9 +116,10 @@ public class SbbProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripFromAddress() throws Exception { public void tripFromAddress() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(47438595, 8437369), null,
new Location(LocationType.ADDRESS, null, 47438595, 8437369, null, "Dorfstrasse 10, Dällikon, Schweiz"), "Dorfstrasse 10, Dällikon, Schweiz");
null, new Location(LocationType.STATION, "8500010", null, "Basel"), new Date(), true, null); final Location to = new Location(LocationType.STATION, "8500010", null, "Basel");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);

View file

@ -29,6 +29,7 @@ import de.schildbach.pte.SeProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -114,9 +115,10 @@ public class SeProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void longTrip() throws Exception { public void longTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "740098086", Point.from1E6(67859847, 20212802), null,
new Location(LocationType.STATION, "740098086", 67859847, 20212802, null, "KIRUNA"), null, "KIRUNA");
new Location(LocationType.STATION, "740098000", null, "STOCKHOLM"), new Date(), true, null); final Location to = new Location(LocationType.STATION, "740098000", null, "STOCKHOLM");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.SvvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -101,10 +102,11 @@ public class SvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "455002100", Point.from1E6(47797110, 13053632),
new Location(LocationType.STATION, "455002100", 47797110, 13053632, "Salzburg", "Justizgebäude"), null, "Salzburg", "Justizgebäude");
new Location(LocationType.STATION, "455002200", 47794000, 13059223, "Salzburg", "Akademiestraße"), final Location to = new Location(LocationType.STATION, "455002200", Point.from1E6(47794000, 13059223),
new Date(), true, null); "Salzburg", "Akademiestraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -28,6 +28,7 @@ import de.schildbach.pte.TlemProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -118,12 +119,11 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip2() throws Exception { public void shortTrip2() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "2099014", Point.from1E6(52478184, -1898364),
new Location(LocationType.STATION, "2099014", 52478184, -1898364, "Birmingham", "Birmingham", "Birmingham New Street Rail Station");
"Birmingham New Street Rail Station"), final Location to = new Location(LocationType.STATION, "2099150", Point.from1E6(52585468, -2122962),
null, new Location(LocationType.STATION, "2099150", 52585468, -2122962, "Wolverhampton", "Wolverhampton", "Wolverhampton Rail Station");
"Wolverhampton Rail Station"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
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);
@ -149,12 +149,11 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripArncott() throws Exception { public void tripArncott() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "60011202", Point.from1E6(51850168, -1094302),
new Location(LocationType.STATION, "60011202", 51850168, -1094302, "Upper Arncott", "Upper Arncott", "Bullingdon Prison");
"Bullingdon Prison"), final Location to = new Location(LocationType.STATION, "60006013", Point.from1E6(51856612, -1112904),
null, "Lower Arncott", "The Plough E");
new Location(LocationType.STATION, "60006013", 51856612, -1112904, "Lower Arncott", "The Plough E"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
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);
@ -180,22 +179,22 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripFromPOI() throws Exception { public void tripFromPOI() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.POI,
new Location(LocationType.POI, "poiID:48863:31117134:-1:Statue:Ham (London):Statue:ANY:POI:517246:826916:TFLV:uk",
"poiID:48863:31117134:-1:Statue:Ham (London):Statue:ANY:POI:517246:826916:TFLV:uk", 51444620, Point.from1E6(51444620, -314316), "Ham (London)", "Statue");
-314316, "Ham (London)", "Statue"), final Location to = new Location(LocationType.ADDRESS, "streetID:106269::31117001:-1", "London",
null, "Cannon Street, London");
new Location(LocationType.ADDRESS, "streetID:106269::31117001:-1", "London", "Cannon Street, London"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
} }
@Test @Test
public void tripFromAddress() throws Exception { public void tripFromAddress() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, "streetID:203417::31117006:-1", "London",
new Location(LocationType.ADDRESS, "streetID:203417::31117006:-1", "London", "Kings Cross, London"), "Kings Cross, London");
null, new Location(LocationType.STATION, "1002070", 51508530, 46706, "Royal Albert", "Royal Albert"), final Location to = new Location(LocationType.STATION, "1002070", Point.from1E6(51508530, 46706),
new Date(), true, null); "Royal Albert", "Royal Albert");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
} }

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.VaoProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -153,10 +154,11 @@ public class VaoProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTripSalzburg() throws Exception { public void shortTripSalzburg() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409),
new Location(LocationType.STATION, "455000900", 47808976, 13056409, "Salzburg", "Vogelweiderstraße"), "Salzburg", "Vogelweiderstraße");
null, new Location(LocationType.STATION, "455084400", 47811556, 13050278, "Salzburg", "Merianstraße"), final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278),
new Date(), true, null); "Salzburg", "Merianstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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);
@ -193,7 +195,6 @@ public class VaoProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripCoordinateToStation() throws Exception { public void tripCoordinateToStation() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(47238096, 9585581), null, final QueryTripsResult result = queryTrips(Location.coord(47238096, 9585581), null,
new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof"), new Date(), true, null); new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof"), new Date(), true, null);
print(result); print(result);

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.VbbProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -126,11 +127,11 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortFootwayTrip() throws Exception { public void shortFootwayTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52435193, 13473409),
new Location(LocationType.ADDRESS, null, 52435193, 13473409, "12357 Berlin-Buckow", "Kernbeisserweg 4"), "12357 Berlin-Buckow", "Kernbeisserweg 4");
null, final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52433989, 13474353),
new Location(LocationType.ADDRESS, null, 52433989, 13474353, "12357 Berlin-Buckow", "Distelfinkweg 35"), "12357 Berlin-Buckow", "Distelfinkweg 35");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())
@ -183,12 +184,11 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", "10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
"Weimarische Str. 7"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52541536, 13421290),
null, new Location(LocationType.ADDRESS, null, 52541536, 13421290, "10437 Berlin-Prenzlauer Berg", "10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5");
"Göhrener Str. 5"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())
@ -200,13 +200,13 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void viaTripBetweenAddresses() throws Exception { public void viaTripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", "10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
"Weimarische Str. 7"), final Location via = new Location(LocationType.ADDRESS, null, Point.from1E6(52527872, 13381657),
new Location(LocationType.ADDRESS, null, 52527872, 13381657, "10115 Berlin-Mitte", "10115 Berlin-Mitte", "Hannoversche Str. 20");
"Hannoversche Str. 20"), final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52526029, 13399878),
new Location(LocationType.ADDRESS, null, 52526029, 13399878, "10178 Berlin-Mitte", "Sophienstr. 24"), "10178 Berlin-Mitte", "Sophienstr. 24");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -28,6 +28,7 @@ import de.schildbach.pte.VblProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -78,10 +79,11 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "53020041", Point.from1E6(47050164, 8310352), "Luzern",
new Location(LocationType.STATION, "53020041", 47050164, 8310352, "Luzern", "Bahnhof"), null, "Bahnhof");
new Location(LocationType.STATION, "53028841", 47048564, 8306016, "Luzern", "Kantonalbank"), new Date(), final Location to = new Location(LocationType.STATION, "53028841", Point.from1E6(47048564, 8306016), "Luzern",
true, null); "Kantonalbank");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -28,6 +28,7 @@ import de.schildbach.pte.VgnProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -86,11 +87,11 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripToPOI() throws Exception { public void tripToPOI() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 49527298, 10836204), null, final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(49527298, 10836204));
new Location(LocationType.POI, final Location to = new Location(LocationType.POI,
"poiID:246:9564000:1:Grundschule Grimmstr.:Nürnberg:Grundschule Grimmstr.:ANY:POI:4436708:678322:NAV4:VGN", "poiID:246:9564000:1:Grundschule Grimmstr.:Nürnberg:Grundschule Grimmstr.:ANY:POI:4436708:678322:NAV4:VGN",
49468692, 11125334, "Nürnberg", "Grundschule Grimmstr."), Point.from1E6(49468692, 11125334), "Nürnberg", "Grundschule Grimmstr.");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
@ -99,10 +100,10 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripToAddress() throws Exception { public void tripToAddress() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "1756", "Nürnberg", "Saarbrückener Str.");
new Location(LocationType.STATION, "1756", "Nürnberg", "Saarbrückener Str."), null, final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(49437392, 11094524), "Nürnberg",
new Location(LocationType.ADDRESS, null, 49437392, 11094524, "Nürnberg", "Wodanstraße 25"), new Date(), "Wodanstraße 25");
false, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.VmobilProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -153,10 +154,11 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTripSalzburg() throws Exception { public void shortTripSalzburg() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409),
new Location(LocationType.STATION, "455000900", 47808976, 13056409, "Salzburg", "Vogelweiderstraße"), "Salzburg", "Vogelweiderstraße");
null, new Location(LocationType.STATION, "455084400", 47811556, 13050278, "Salzburg", "Merianstraße"), final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278),
new Date(), true, null); "Salzburg", "Merianstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -28,6 +28,7 @@ import de.schildbach.pte.VmsProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -66,10 +67,11 @@ public class VmsProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "36030131", Point.from1E6(50831380, 12922278),
new Location(LocationType.STATION, "36030131", 50831380, 12922278, "Chemnitz", "Zentralhaltestelle"), "Chemnitz", "Zentralhaltestelle");
null, new Location(LocationType.STATION, "36030522", 50836056, 12922042, "Chemnitz", "Stadthalle"), final Location to = new Location(LocationType.STATION, "36030522", Point.from1E6(50836056, 12922042),
new Date(), true, null); "Chemnitz", "Stadthalle");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -27,6 +27,7 @@ import de.schildbach.pte.VmtProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -80,10 +81,11 @@ public class VmtProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "153166", Point.from1E6(50926947, 11586987), null,
new Location(LocationType.STATION, "153166", 50926947, 11586987, null, "Jena, Stadtzentrum"), null, "Jena, Stadtzentrum");
new Location(LocationType.STATION, "153014", 50933887, 11590592, null, "Jena, Spittelpl."), new Date(), final Location to = new Location(LocationType.STATION, "153014", Point.from1E6(50933887, 11590592), null,
true, null); "Jena, Spittelpl.");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
System.out.println(result); System.out.println(result);
if (!result.context.canQueryLater()) if (!result.context.canQueryLater())

View file

@ -28,6 +28,7 @@ import de.schildbach.pte.VmvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -74,10 +75,10 @@ public class VmvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "44402006", null, "Schwerin Marienplatz");
new Location(LocationType.STATION, "44402006", null, "Schwerin Marienplatz"), null, final Location to = new Location(LocationType.STATION, "44402007", Point.from1E6(53625272, 11409350), null,
new Location(LocationType.STATION, "44402007", 53625272, 11409350, null, "Schlossblick"), new Date(), "Schlossblick");
true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -30,6 +30,7 @@ import de.schildbach.pte.VorProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -98,10 +99,11 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "490065700", Point.from1E6(48200852, 16368880), "Wien",
new Location(LocationType.STATION, "490065700", 48200852, 16368880, "Wien", "Karlsplatz"), null, "Karlsplatz");
new Location(LocationType.STATION, "490109400", 48198362, 16367667, "Wien", "Resselgasse"), new Date(), final Location to = new Location(LocationType.STATION, "490109400", Point.from1E6(48198362, 16367667), "Wien",
true, null); "Resselgasse");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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);
@ -127,12 +129,11 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripToPOI() throws Exception { public void tripToPOI() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "490134900", 48185184, 16376413), final Location from = new Location(LocationType.STATION, "490134900", Point.from1E6(48185184, 16376413));
null, final Location to = new Location(LocationType.POI,
new Location(LocationType.POI, "A=4@O=Naschmarkt, Wien@X=16362903@Y=48198290@U=130@L=960068499@B=1@p=1476842541@",
"A=4@O=Naschmarkt, Wien@X=16362903@Y=48198290@U=130@L=960068499@B=1@p=1476842541@", 48198290, Point.from1E6(48198290, 16362903), "Wien", "Naschmarkt");
16362903, "Wien", "Naschmarkt"), final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.VrnProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -102,10 +103,11 @@ public class VrnProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "6002417", Point.from1E6(49479748, 8469938),
new Location(LocationType.STATION, "6002417", 49479748, 8469938, "Mannheim", "Mannheim, Hauptbahnhof"), "Mannheim", "Mannheim, Hauptbahnhof");
null, new Location(LocationType.STATION, "6005542", 49482892, 8473050, "Mannheim", "Kunsthalle"), final Location to = new Location(LocationType.STATION, "6005542", Point.from1E6(49482892, 8473050), "Mannheim",
new Date(), true, null); "Kunsthalle");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -45,6 +45,7 @@ import de.schildbach.pte.dto.LineDestination;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
@ -415,10 +416,12 @@ public class VrsProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void testTripByAddressAndEmptyPolygon() throws Exception { public void testTripByAddressAndEmptyPolygon() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null /* id */, Point.from1E6(50909350, 6676310),
new Location(LocationType.ADDRESS, null /* id */, 50909350, 6676310, "Kerpen-Sindorf", "Erftstraße 43"), "Kerpen-Sindorf", "Erftstraße 43");
null, new Location(LocationType.ADDRESS, null /* id */, 50923000, 6818440, "Frechen", "Zedernweg 1"), final Location to = new Location(LocationType.ADDRESS, null /* id */, Point.from1E6(50923000, 6818440),
Iso8601Format.parseDateTime("2015-03-17 21:11:18"), true, null); "Frechen", "Zedernweg 1");
final QueryTripsResult result = queryTrips(from, null, to, Iso8601Format.parseDateTime("2015-03-17 21:11:18"),
true, null);
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

@ -30,6 +30,7 @@ import de.schildbach.pte.VvmProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -75,10 +76,11 @@ public class VvmProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "3700075", Point.from1E6(49801076, 9934302),
new Location(LocationType.STATION, "3700075", 49801076, 9934302, "Würzburg", "Busbahnhof"), null, "Würzburg", "Busbahnhof");
new Location(LocationType.STATION, "3700403", 49797772, 9934986, "Würzburg", "Stift Haug"), new Date(), final Location to = new Location(LocationType.STATION, "3700403", Point.from1E6(49797772, 9934986), "Würzburg",
true, null); "Stift Haug");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -30,6 +30,7 @@ import de.schildbach.pte.VvoProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -116,11 +117,11 @@ public class VvoProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripFromAddressToAddress() throws Exception { public void tripFromAddressToAddress() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51052260, 13740998), "Dresden",
new Location(LocationType.ADDRESS, null, 51052260, 13740998, "Dresden", "Dresden, Töpferstraße 10"), "Dresden, Töpferstraße 10");
null, new Location(LocationType.ADDRESS, null, 51029752, 13700666, "Dresden", final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(51029752, 13700666), "Dresden",
"Dresden, Tharandter Straße 88"), "Dresden, Tharandter Straße 88");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -30,6 +30,7 @@ import de.schildbach.pte.VvsProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -82,11 +83,11 @@ public class VvsProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "5006118", Point.from1E6(48782984, 9179846),
new Location(LocationType.STATION, "5006118", 48782984, 9179846, "Stuttgart", "Stuttgart", "Stuttgart, Hauptbahnhof");
"Stuttgart, Hauptbahnhof"), final Location to = new Location(LocationType.STATION, "5006024", Point.from1E6(48782584, 9187098), "Stuttgart",
null, new Location(LocationType.STATION, "5006024", 48782584, 9187098, "Stuttgart", "Staatsgalerie"), "Staatsgalerie");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -30,6 +30,7 @@ import de.schildbach.pte.VvtProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -87,10 +88,11 @@ public class VvtProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "476151200", Point.from1E6(47268248, 11355560),
new Location(LocationType.STATION, "476151200", 47268248, 11355560, "Innsbruck", "Allerheiligen"), null, "Innsbruck", "Allerheiligen");
new Location(LocationType.STATION, "476151000", 47267241, 11351003, "Innsbruck", "Tschiggfreystraße"), final Location to = new Location(LocationType.STATION, "476151000", Point.from1E6(47267241, 11351003),
new Date(), true, null); "Innsbruck", "Tschiggfreystraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -28,6 +28,7 @@ import de.schildbach.pte.VvvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -72,11 +73,11 @@ public class VvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "30202006", Point.from1E6(50484564, 12140028),
new Location(LocationType.STATION, "30202006", 50484564, 12140028, "Plauen (Vogtl)", "Bickelstraße"), "Plauen (Vogtl)", "Bickelstraße");
null, final Location to = new Location(LocationType.STATION, "30202012", Point.from1E6(50487332, 12139050),
new Location(LocationType.STATION, "30202012", 50487332, 12139050, "Plauen (Vogtl)", "Hofer Straße"), "Plauen (Vogtl)", "Hofer Straße");
new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -31,6 +31,7 @@ import de.schildbach.pte.WienProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -95,10 +96,11 @@ public class WienProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "60200657", Point.from1E6(48200756, 16369001), "Wien",
new Location(LocationType.STATION, "60200657", 48200756, 16369001, "Wien", "Karlsplatz"), null, "Karlsplatz");
new Location(LocationType.STATION, "60201094", 48198612, 16367719, "Wien", "Resselgasse"), new Date(), final Location to = new Location(LocationType.STATION, "60201094", Point.from1E6(48198612, 16367719), "Wien",
true, null); "Resselgasse");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
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

@ -27,6 +27,7 @@ import de.schildbach.pte.ZvvProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -81,10 +82,11 @@ public class ZvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void trip() throws Exception { public void trip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "8503000", Point.from1E6(47378491, 8537945), "Zürich",
new Location(LocationType.STATION, "8503000", 47378491, 8537945, "Zürich", "Zürich, Hauptbahnhof"), "Zürich, Hauptbahnhof");
null, new Location(LocationType.STATION, "8530812", 47361762, 8560715, "Zürich", "Hegibachplatz"), final Location to = new Location(LocationType.STATION, "8530812", Point.from1E6(47361762, 8560715), "Zürich",
new Date(), true, null); "Hegibachplatz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);