diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 90029df0..c94b135b 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -477,12 +477,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { } private void appendXmlCoordRequestParameters(final HttpUrl.Builder url, final EnumSet 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"); - url.addEncodedQueryParameter("coord", - ParserUtils.urlEncode( - String.format(Locale.ENGLISH, "%2.6f:%2.6f:WGS84", latLonToDouble(lon), latLonToDouble(lat)), - requestUrlEncoding)); + url.addEncodedQueryParameter("coord", ParserUtils.urlEncode( + String.format(Locale.ENGLISH, "%2.6f:%2.6f:WGS84", coord.getLonAsDouble(), coord.getLatAsDouble()), + requestUrlEncoding)); if (useStringCoordListOutputFormat) url.addEncodedQueryParameter("coordListOutputFormat", "STRING"); url.addEncodedQueryParameter("max", Integer.toString(maxLocations != 0 ? maxLocations : 50)); @@ -500,10 +499,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { } } - protected NearbyLocationsResult xmlCoordRequest(final EnumSet types, final int lat, final int lon, + protected NearbyLocationsResult xmlCoordRequest(final EnumSet types, final Point coord, final int maxDistance, final int maxStations) throws IOException { final HttpUrl.Builder url = coordEndpoint.newBuilder(); - appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations); + appendXmlCoordRequestParameters(url, types, coord, maxDistance, maxStations); final AtomicReference result = new AtomicReference<>(); final HttpClient.Callback callback = new HttpClient.Callback() { @@ -572,10 +571,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { return result.get(); } - protected NearbyLocationsResult mobileCoordRequest(final EnumSet types, final int lat, final int lon, + protected NearbyLocationsResult mobileCoordRequest(final EnumSet types, final Point coord, final int maxDistance, final int maxStations) throws IOException { final HttpUrl.Builder url = coordEndpoint.newBuilder(); - appendXmlCoordRequestParameters(url, types, lat, lon, maxDistance, maxStations); + appendXmlCoordRequestParameters(url, types, coord, maxDistance, maxStations); final AtomicReference result = new AtomicReference<>(); final HttpClient.Callback callback = new HttpClient.Callback() { @@ -836,8 +835,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { @Override public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, final int maxLocations) throws IOException { - if (location.hasLocation()) - return xmlCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); + if (location.hasCoord()) + return xmlCoordRequest(types, location.coord, maxDistance, maxLocations); if (location.type != LocationType.STATION) 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(" "); } - protected static double latLonToDouble(final int value) { - return (double) value / 1000000; - } - protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from, final @Nullable Location via, final Location to, final Date time, final boolean dep, @Nullable TripOptions options) { @@ -2810,7 +2805,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { if ("WGS84".equals(coordParts[2])) { final int lat = (int) Math.round(Double.parseDouble(coordParts[1])); final int lon = (int) Math.round(Double.parseDouble(coordParts[0])); - coords = new Point(lat, lon); + coords = Point.from1E6(lat, lon); } else { coords = null; } @@ -2934,7 +2929,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { while (XmlPullUtil.optEnter(pp, "itdCoordinateBaseElem")) { final int lon = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "x"))); 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"); } @@ -2951,7 +2946,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { final String[] parts = coordStr.split(","); final int lat = (int) Math.round(Double.parseDouble(parts[1])); 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) { @@ -2965,7 +2960,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { if (!"WGS84".equals(mapName)) return null; - return new Point(y, x); + return Point.from1E6(y, x); } 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) { 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("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)); } else if (name != null) { url.addEncodedQueryParameter("type_" + paramSuffix, locationTypeValue(location)); diff --git a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index 03f18b19..e2760705 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -57,6 +57,7 @@ import de.schildbach.pte.dto.Line; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Position; import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.QueryDeparturesResult; @@ -131,8 +132,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas @Override public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, final int maxLocations) throws IOException { - if (location.hasLocation()) - return jsonLocGeoPos(types, location.lat, location.lon, maxDistance, maxLocations); + if (location.hasCoord()) + return jsonLocGeoPos(types, location.coord, maxDistance, maxLocations); else 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); } - protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet types, final int lat, final int lon, + protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet types, final Point coord, int maxDistance, int maxLocations) throws IOException { if (maxDistance == 0) maxDistance = DEFAULT_MAX_DISTANCE; @@ -171,7 +172,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas final boolean getStations = types.contains(LocationType.STATION); final boolean getPOIs = types.contains(LocationType.POI); final String request = wrapJsonApiRequest("LocGeoPos", "{\"ring\":" // - + "{\"cCrd\":{\"x\":" + lon + ",\"y\":" + lat + "},\"maxDist\":" + maxDistance + "}," // + + "{\"cCrd\":{\"x\":" + coord.getLonAs1E6() + ",\"y\":" + coord.getLatAs1E6() + "}," // + + "\"maxDist\":" + maxDistance + "}," // + "\"getStops\":" + getStations + "," // + "\"getPOIs\":" + getPOIs + "," // + "\"maxLoc\":" + maxLocations + "}", // @@ -411,9 +413,9 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas if (!locations.isEmpty()) return locations.get(0); } - if (location.hasLocation()) { - final List locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.lat, - location.lon, 0, 1).locations; + if (location.hasCoord()) { + final List locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.coord, 0, + 1).locations; if (!locations.isEmpty()) return locations.get(0); } @@ -805,8 +807,8 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas final JSONObject crd = loc.optJSONObject("crd"); if (crd != null) - return new Location(locationType, id, crd.getInt("y"), crd.getInt("x"), placeAndName[0], placeAndName[1], - products); + return new Location(locationType, id, Point.from1E6(crd.getInt("y"), crd.getInt("x")), placeAndName[0], + placeAndName[1], products); else return new Location(LocationType.STATION, id, null, placeAndName[0], placeAndName[1], products); } diff --git a/enabler/src/de/schildbach/pte/AbstractHafasLegacyProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasLegacyProvider.java index 93632120..763bf1ad 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasLegacyProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasLegacyProvider.java @@ -248,9 +248,9 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider final String id = XmlPullUtil.attr(pp, "externalStationNr"); final int x = XmlPullUtil.intAttr(pp, "x"); final int y = XmlPullUtil.intAttr(pp, "y"); - + final Point coord = Point.from1E6(y, x); 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); } @@ -263,7 +263,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider name = null; final int x = XmlPullUtil.intAttr(pp, "x"); 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); } @@ -276,9 +277,9 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider name = null; final int x = XmlPullUtil.intAttr(pp, "x"); final int y = XmlPullUtil.intAttr(pp, "y"); - + final Point coord = Point.from1E6(y, x); 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); } @@ -346,23 +347,23 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider if (type == 1) // station { final String[] placeAndName = splitStationName(value); - location = new Location(LocationType.STATION, localId, lat, lon, placeAndName[0], - placeAndName[1]); + location = new Location(LocationType.STATION, localId, Point.from1E6(lat, lon), + placeAndName[0], placeAndName[1]); } else if (type == 2) // address { final String[] placeAndName = splitAddress(value); - location = new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], - placeAndName[1]); + location = new Location(LocationType.ADDRESS, null, Point.from1E6(lat, lon), + placeAndName[0], placeAndName[1]); } else if (type == 4) // poi { 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]); } else if (type == 128) // crossing { final String[] placeAndName = splitAddress(value); - location = new Location(LocationType.ADDRESS, localId, lat, lon, placeAndName[0], - placeAndName[1]); + location = new Location(LocationType.ADDRESS, localId, Point.from1E6(lat, lon), + placeAndName[0], placeAndName[1]); } else if (type == 87) { location = null; // don't know what to do @@ -1115,7 +1116,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider while (XmlPullUtil.test(pp, "Point")) { final int x = XmlPullUtil.intAttr(pp, "x"); final int y = XmlPullUtil.intAttr(pp, "y"); - path.add(new Point(y, x)); + path.add(Point.from1E6(y, x)); XmlPullUtil.next(pp); } XmlPullUtil.skipExit(pp, "Polyline"); @@ -1248,13 +1249,13 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider private static final String locationXml(final Location location) { if (location.type == LocationType.STATION && location.hasId()) return ""; - else if (location.type == LocationType.POI && location.hasLocation()) - return ""; - else if (location.type == LocationType.ADDRESS && location.hasLocation()) - return "
"; - else if (location.type == LocationType.COORD && location.hasLocation()) - return ""; + else if (location.type == LocationType.POI && location.hasCoord()) + return ""; + else if (location.type == LocationType.ADDRESS && location.hasCoord()) + return "
"; + else if (location.type == LocationType.COORD && location.hasCoord()) + return ""; else throw new IllegalArgumentException("cannot handle: " + location); } @@ -1266,11 +1267,11 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider if (location.type == LocationType.STATION && location.hasId()) { id.append("@L=").append(normalizeStationId(location.id)); - } else if (location.hasLocation()) { - id.append("@X=").append(location.lon); - id.append("@Y=").append(location.lat); - id.append("@O=").append(location.name != null ? location.name - : String.format(Locale.ENGLISH, "%.6f, %.6f", location.lat / 1E6, location.lon / 1E6)); + } else if (location.hasCoord()) { + id.append("@X=").append(location.getLonAs1E6()); + id.append("@Y=").append(location.getLatAs1E6()); + id.append("@O=").append(location.name != null ? location.name : String.format(Locale.ENGLISH, "%.6f, %.6f", + location.getLatAsDouble(), location.getLonAsDouble())); } else if (location.name != null) { id.append("@G=").append(location.name); if (location.type != LocationType.ANY) @@ -1286,7 +1287,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider return 1; if (type == LocationType.POI) return 4; - if (type == LocationType.COORD || (type == LocationType.ADDRESS && location.hasLocation())) + if (type == LocationType.COORD || (type == LocationType.ADDRESS && location.hasCoord())) return 16; if (type == LocationType.ADDRESS && location.name != null) return 2; @@ -1310,12 +1311,12 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider if (via.type == LocationType.STATION && via.hasId()) { url.addQueryParameter("REQ0JourneyStops1.0L", via.id); - } else if (via.hasLocation()) { - url.addQueryParameter("REQ0JourneyStops1.0X", Integer.toString(via.lon)); - url.addQueryParameter("REQ0JourneyStops1.0Y", Integer.toString(via.lat)); + } else if (via.hasCoord()) { + url.addQueryParameter("REQ0JourneyStops1.0X", Integer.toString(via.getLonAs1E6())); + url.addQueryParameter("REQ0JourneyStops1.0Y", Integer.toString(via.getLatAs1E6())); if (via.name == null) 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) { url.addEncodedQueryParameter("REQ0JourneyStops1.0G", ParserUtils .urlEncode(via.name + (via.type != LocationType.ANY ? "!" : ""), requestUrlEncoding)); @@ -2029,13 +2030,13 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider if (type == 1) { 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) { 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) { 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 { throw new IllegalStateException("unknown type: " + type + " " + name); } @@ -2185,8 +2186,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider final int lon = stationInputStream.readIntReverse(); final int lat = stationInputStream.readIntReverse(); - return new Location(LocationType.STATION, id != 0 ? Integer.toString(id) : null, lat, lon, - placeAndName[0], placeAndName[1]); + return new Location(LocationType.STATION, id != 0 ? Integer.toString(id) : null, + Point.from1E6(lat, lon), placeAndName[0], placeAndName[1]); } finally { stationInputStream.close(); } @@ -2196,23 +2197,23 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider @Override public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, final int maxLocations) throws IOException { - if (location.hasLocation()) - return nearbyLocationsByCoordinate(types, location.lat, location.lon, maxDistance, maxLocations); + if (location.hasCoord()) + return nearbyLocationsByCoordinate(types, location.coord, maxDistance, maxLocations); else if (location.type == LocationType.STATION && location.hasId()) return nearbyStationsById(location.id, maxDistance); else throw new IllegalArgumentException("cannot handle: " + location); } - protected final NearbyLocationsResult nearbyLocationsByCoordinate(final EnumSet types, final int lat, - final int lon, final int maxDistance, final int maxLocations) throws IOException { + protected final NearbyLocationsResult nearbyLocationsByCoordinate(final EnumSet types, + final Point coord, final int maxDistance, final int maxLocations) throws IOException { if (types.contains(LocationType.STATION)) { final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage + "y"); - appendJsonNearbyStationsParameters(url, lat, lon, maxDistance, maxLocations); + appendJsonNearbyStationsParameters(url, coord, maxDistance, maxLocations); return jsonNearbyLocations(url.build()); } else if (types.contains(LocationType.POI)) { final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage + "y"); - appendJsonNearbyPOIsParameters(url, lat, lon, maxDistance, maxLocations); + appendJsonNearbyPOIsParameters(url, coord, maxDistance, maxLocations); return jsonNearbyLocations(url.build()); } else { return new NearbyLocationsResult(null, Collections. 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)", Pattern.DOTALL); - private static final Pattern P_XML_NEARBY_STATIONS_FINE = Pattern.compile( - "" // - + "evaId=\"(\\d+)\"\\s*" // id - + "name=\"([^\"]+)\".*?" // name - + "(?:x=\"(\\d+)\"\\s*)?" // x - + "(?:y=\"(\\d+)\"\\s*)?" // y + private static final Pattern P_XML_NEARBY_STATIONS_FINE = Pattern.compile("" // + + "evaId=\"(\\d+)\"\\s*" // id + + "name=\"([^\"]+)\".*?" // name + + "(?:x=\"(\\d+)\"\\s*)?" // x + + "(?:y=\"(\\d+)\"\\s*)?" // y , Pattern.DOTALL); private static final Pattern P_XML_NEARBY_STATIONS_MESSAGES = Pattern .compile(" products = prodclass != -1 ? intToProducts(prodclass) : null; - locations.add(new Location(LocationType.STATION, id, lat, lon, placeAndName[0], - placeAndName[1], products)); + locations.add(new Location(LocationType.STATION, id, Point.from1E6(lat, lon), + placeAndName[0], placeAndName[1], products)); } } } @@ -2373,7 +2369,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider final int lon = poi.getInt("x"); 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])); } } diff --git a/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java b/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java index 8e1dad70..b9d01e7f 100644 --- a/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractNavitiaProvider.java @@ -310,8 +310,8 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider { private String printLocation(final Location location) { if (location.hasId()) return location.id; - else if (location.hasLocation()) - return (double) (location.lon) / 1E6 + ";" + (double) (location.lat) / 1E6; + else if (location.hasCoord()) + return location.getLonAsDouble() + ";" + location.getLatAsDouble(); else return ""; } @@ -695,9 +695,9 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider { // Build url depending of location type. final HttpUrl.Builder url = url(); - if (location.hasLocation()) { - final double lon = location.lon / 1E6; - final double lat = location.lat / 1E6; + if (location.hasCoord()) { + final double lon = location.getLonAsDouble(); + final double lat = location.getLatAsDouble(); url.addPathSegment("coords").addPathSegment(lon + ";" + lat); } else if (location.type == LocationType.STATION) { if (!location.isIdentified()) diff --git a/enabler/src/de/schildbach/pte/BayernProvider.java b/enabler/src/de/schildbach/pte/BayernProvider.java index 6d18b889..93b89e32 100644 --- a/enabler/src/de/schildbach/pte/BayernProvider.java +++ b/enabler/src/de/schildbach/pte/BayernProvider.java @@ -112,8 +112,8 @@ public class BayernProvider extends AbstractEfaProvider { @Override public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, final int maxLocations) throws IOException { - if (location.hasLocation()) - return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); + if (location.hasCoord()) + return mobileCoordRequest(types, location.coord, maxDistance, maxLocations); if (location.type != LocationType.STATION) throw new IllegalArgumentException("cannot handle: " + location.type); diff --git a/enabler/src/de/schildbach/pte/HslProvider.java b/enabler/src/de/schildbach/pte/HslProvider.java index 95b4c147..4c7c6bdd 100644 --- a/enabler/src/de/schildbach/pte/HslProvider.java +++ b/enabler/src/de/schildbach/pte/HslProvider.java @@ -157,7 +157,7 @@ public class HslProvider extends AbstractNetworkProvider { final String id = xmlValueTag(pp, "code"); final String name = xmlValueTag(pp, "name_fi"); 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) { throw new ParserException("cannot parse xml: " + bodyPeek, x); } @@ -175,7 +175,7 @@ public class HslProvider extends AbstractNetworkProvider { public NearbyLocationsResult queryNearbyLocations(EnumSet types, Location location, int maxDistance, int maxStations) throws IOException { final HttpUrl.Builder url = apiUrl("stops_area"); - if (!location.hasLocation()) { + if (!location.hasCoord()) { if (location.type != LocationType.STATION) throw new IllegalArgumentException("cannot handle: " + location.type); if (!location.hasId()) @@ -209,7 +209,7 @@ public class HslProvider extends AbstractNetworkProvider { 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)); @@ -384,8 +384,7 @@ public class HslProvider extends AbstractNetworkProvider { if (shortCode != null) name = name + " (" + shortCode + ")"; - locations - .add(new SuggestedLocation(new Location(type, id, pt.lat, pt.lon, null, name), weight)); + locations.add(new SuggestedLocation(new Location(type, id, pt, null, name), weight)); weight -= 1; } @@ -628,7 +627,7 @@ public class HslProvider extends AbstractNetworkProvider { LocationType type = LocationType.ANY; if (code != null) 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) { departure = loc; @@ -653,8 +652,8 @@ public class HslProvider extends AbstractNetworkProvider { if (legType.equals("walk")) { // ugly hack to set the name of the last arrival if (arrival != null && arrival.name == null) { - arrival = new Location(arrival.type, arrival.id, arrival.lat, arrival.lon, - arrival.place, to.name); + arrival = new Location(arrival.type, arrival.id, arrival.coord, arrival.place, + to.name); } legs.add(new Trip.Individual(Trip.Individual.Type.WALK, departure, departureTime, diff --git a/enabler/src/de/schildbach/pte/NegentweeProvider.java b/enabler/src/de/schildbach/pte/NegentweeProvider.java index 6d36b55d..7eb53cb2 100644 --- a/enabler/src/de/schildbach/pte/NegentweeProvider.java +++ b/enabler/src/de/schildbach/pte/NegentweeProvider.java @@ -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 { switch (type) { case "station": @@ -322,7 +318,7 @@ public class NegentweeProvider extends AbstractNetworkProvider { private String locationToQueryParameterString(Location loc) { if (loc.hasId()) { return loc.id; - } else if (loc.hasLocation()) { + } else if (loc.hasCoord()) { return loc.getLatAsDouble() + "," + loc.getLonAsDouble(); } else { return null; @@ -408,18 +404,18 @@ public class NegentweeProvider extends AbstractNetworkProvider { // First stop Stop firstStop = stopFromJSONObject(stops.getJSONObject(0)); - foundPoints.add(pointFromLocation(firstStop.location)); + foundPoints.add(firstStop.location.coord); // Intermediate stops LinkedList foundStops = new LinkedList<>(); for (int j = 1; j < stops.length() - 1; j++) { foundStops.add(stopFromJSONObject(stops.getJSONObject(j))); - foundPoints.add(pointFromLocation(foundStops.getLast().location)); + foundPoints.add(foundStops.getLast().location.coord); } // Last stop Stop lastStop = stopFromJSONObject(stops.getJSONObject(stops.length() - 1)); - foundPoints.add(pointFromLocation(lastStop.location)); + foundPoints.add(lastStop.location.coord); switch (leg.getString("type").toLowerCase()) { case "scheduled": @@ -578,14 +574,14 @@ public class NegentweeProvider extends AbstractNetworkProvider { Point locationPoint = Point.fromDouble(latlon.getDouble("lat"), latlon.getDouble("long")); - return new Location(locationTypeFromTypeString(locationType), location.getString("id"), locationPoint.lat, - locationPoint.lon, !(place == null) ? place.optString("name", null) : null, locationName, null); + return new Location(locationTypeFromTypeString(locationType), location.getString("id"), locationPoint, + !(place == null) ? place.optString("name", null) : null, locationName, null); } private List solveAmbiguousLocation(Location location) throws IOException { if (location.hasId()) { return Arrays.asList(location); - } else if (location.hasLocation()) { + } else if (location.hasCoord()) { return queryNearbyLocations(EnumSet.of(location.type), location, -1, -1).locations; } else if (location.hasName()) { return queryLocationsByName(location.name, EnumSet.of(location.type)); @@ -715,7 +711,7 @@ public class NegentweeProvider extends AbstractNetworkProvider { public NearbyLocationsResult queryNearbyLocations(EnumSet types, Location location, int maxDistance, int maxLocations) throws IOException { // Coordinates are required - if (!location.hasLocation()) { + if (!location.hasCoord()) { try { if (location.hasId()) { location = queryLocationById(location.id); @@ -728,7 +724,7 @@ public class NegentweeProvider extends AbstractNetworkProvider { 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); } } @@ -814,7 +810,7 @@ public class NegentweeProvider extends AbstractNetworkProvider { lineDestinationResult.add(new LineDestination( new Line(null, departure.getString("operatorName"), lineProduct, mode.getString("name"), 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)))); } @@ -864,10 +860,10 @@ public class NegentweeProvider extends AbstractNetworkProvider { @Override public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep, @Nullable TripOptions options) throws IOException { - if (!(from.hasId() || from.hasLocation())) + if (!(from.hasId() || from.hasCoord())) return ambiguousQueryTrips(from, via, to); - if (!(to.hasId() || to.hasLocation())) + if (!(to.hasId() || to.hasCoord())) return ambiguousQueryTrips(from, via, to); // Default query options @@ -880,7 +876,7 @@ public class NegentweeProvider extends AbstractNetworkProvider { new QueryParameter("before", "1"), new QueryParameter("after", "5"))); if (via != null) { - if (!(via.hasId() || via.hasLocation())) + if (!(via.hasId() || via.hasCoord())) return ambiguousQueryTrips(from, via, to); queryParameters.add(new QueryParameter("via", locationToQueryParameterString(via))); diff --git a/enabler/src/de/schildbach/pte/StvProvider.java b/enabler/src/de/schildbach/pte/StvProvider.java index 37342628..f4dfcc3e 100644 --- a/enabler/src/de/schildbach/pte/StvProvider.java +++ b/enabler/src/de/schildbach/pte/StvProvider.java @@ -53,8 +53,8 @@ public class StvProvider extends AbstractEfaProvider { @Override public NearbyLocationsResult queryNearbyLocations(final EnumSet types, final Location location, final int maxDistance, final int maxLocations) throws IOException { - if (location.hasLocation()) - return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); + if (location.hasCoord()) + return mobileCoordRequest(types, location.coord, maxDistance, maxLocations); if (location.type != LocationType.STATION) throw new IllegalArgumentException("cannot handle: " + location.type); diff --git a/enabler/src/de/schildbach/pte/VrsProvider.java b/enabler/src/de/schildbach/pte/VrsProvider.java index 8983fa29..23a4f0f8 100644 --- a/enabler/src/de/schildbach/pte/VrsProvider.java +++ b/enabler/src/de/schildbach/pte/VrsProvider.java @@ -363,9 +363,9 @@ public class VrsProvider extends AbstractNetworkProvider { // g=p means group by product; not used here final HttpUrl.Builder url = API_BASE.newBuilder(); url.addQueryParameter("eID", "tx_vrsinfo_ass2_timetable"); - if (location.hasLocation()) { + if (location.hasCoord()) { 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()) { url.addQueryParameter("i", location.id); } else { @@ -857,15 +857,15 @@ public class VrsProvider extends AbstractNetworkProvider { } List points = new ArrayList<>(); - points.add(new Point(segmentOrigin.lat, segmentOrigin.lon)); + points.add(segmentOrigin.coord); if (EXACT_POINTS && segment.has("polygon")) { parsePolygon(segment.getString("polygon"), points); } else { 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 (departurePlanned == null) departurePlanned = legs.get(legs.size() - 1).getArrivalTime(); @@ -941,8 +941,7 @@ public class VrsProvider extends AbstractNetworkProvider { String pointsArr[] = polygonStr.split("\\s"); for (String point : pointsArr) { String latlon[] = point.split(","); - polygonArr.add(new Point((int) Math.round(Double.parseDouble(latlon[0]) * 1E6), - (int) Math.round(Double.parseDouble(latlon[1]) * 1E6))); + polygonArr.add(Point.fromDouble(Double.parseDouble(latlon[0]), Double.parseDouble(latlon[1]))); } } } @@ -970,7 +969,7 @@ public class VrsProvider extends AbstractNetworkProvider { @Override 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) { @@ -1113,9 +1112,10 @@ public class VrsProvider extends AbstractNetworkProvider { place += "-" + location.getString("district"); } } - final int lat = (int) Math.round(location.optDouble("x", 0) * 1E6); - final int lon = (int) Math.round(location.optDouble("y", 0) * 1E6); - return new LocationWithPosition(new Location(locationType, id, lat, lon, place, name), + final double lat = location.optDouble("x", 0); + final double lon = location.optDouble("y", 0); + 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); } @@ -1124,8 +1124,8 @@ public class VrsProvider extends AbstractNetworkProvider { return null; } else if (loc.id != null) { return loc.id; - } else if (loc.lat != 0 && loc.lon != 0) { - return String.format(Locale.ENGLISH, "%f,%f", loc.lat / 1E6, loc.lon / 1E6); + } else if (loc.coord != null) { + return String.format(Locale.ENGLISH, "%f,%f", loc.getLatAsDouble(), loc.getLonAsDouble()); } else { SuggestLocationsResult suggestLocationsResult = suggestLocations(loc.name); final List suggestedLocations = suggestLocationsResult.getLocations(); diff --git a/enabler/src/de/schildbach/pte/dto/Location.java b/enabler/src/de/schildbach/pte/dto/Location.java index 3e342960..3558987b 100644 --- a/enabler/src/de/schildbach/pte/dto/Location.java +++ b/enabler/src/de/schildbach/pte/dto/Location.java @@ -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 * 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 @Nullable String id; - public final int lat, lon; + public final @Nullable Point coord; public final @Nullable String place; public final @Nullable String name; public final @Nullable Set products; - public Location(final LocationType type, final String id, final int lat, final int lon, final String place, - final String name, final Set products) { + public Location(final LocationType type, final String id, final Point coord, final String place, final String name, + final Set products) { this.type = checkNotNull(type); this.id = id; - this.lat = lat; - this.lon = lon; + this.coord = coord; this.place = place; this.name = name; this.products = products; @@ -59,36 +58,22 @@ public final class Location implements Serializable { if (type == LocationType.ANY) { checkArgument(id == null, "type ANY cannot have ID"); } else if (type == LocationType.COORD) { - checkArgument(hasLocation(), "coordinates missing"); + checkArgument(hasCoord(), "coordinates missing"); 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 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, 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) { - this(type, id, 0, 0, place, name); - } - - public Location(final LocationType type, final String id, final int lat, final int lon) { - this(type, id, lat, lon, null, null); + this(type, id, null, place, name); } 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) { @@ -96,27 +81,35 @@ public final class Location implements Serializable { } 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) { - return new Location(LocationType.COORD, null, coord.lat, coord.lon); + return new Location(LocationType.COORD, null, coord); } public final boolean hasId() { return !Strings.isNullOrEmpty(id); } - public final boolean hasLocation() { - return lat != 0 || lon != 0; + public final boolean hasCoord() { + return coord != null; } public double getLatAsDouble() { - return lat / 1E6; + return coord.getLatAsDouble(); } 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() { @@ -131,7 +124,7 @@ public final class Location implements Serializable { return true; if (type == LocationType.ADDRESS || type == LocationType.COORD) - return hasLocation(); + return hasCoord(); return false; } @@ -165,8 +158,8 @@ public final class Location implements Serializable { return false; if (this.id != null) return Objects.equal(this.id, other.id); - if (this.lat != 0 && this.lon != 0) - return this.lat == other.lat && this.lon == other.lon; + if (this.coord != null) + return Objects.equal(this.coord, other.coord); // only discriminate by name/place if no ids are given if (!Objects.equal(this.place, other.place)) @@ -185,7 +178,7 @@ public final class Location implements Serializable { return false; if (!Objects.equal(this.id, other.id)) return false; - if (this.lat != other.lat && this.lon != other.lon) + if (!Objects.equal(this.coord, other.coord)) return false; if (!Objects.equal(this.place, other.place)) return false; @@ -201,14 +194,14 @@ public final class Location implements Serializable { if (id != null) return Objects.hashCode(type, id); else - return Objects.hashCode(type, lat, lon); + return Objects.hashCode(type, coord); } @Override public String toString() { final ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(type).addValue(id); - if (hasLocation()) - helper.addValue(lat + "/" + lon); + if (hasCoord()) + helper.addValue(coord); return helper.add("place", place).add("name", name).add("products", products).omitNullValues().toString(); } } diff --git a/enabler/src/de/schildbach/pte/dto/Point.java b/enabler/src/de/schildbach/pte/dto/Point.java index a9e3c9df..6719ba22 100644 --- a/enabler/src/de/schildbach/pte/dto/Point.java +++ b/enabler/src/de/schildbach/pte/dto/Point.java @@ -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 * it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ package de.schildbach.pte.dto; import java.io.Serializable; +import java.util.Locale; import com.google.common.base.Objects; @@ -27,23 +28,35 @@ import com.google.common.base.Objects; public final class Point implements Serializable { 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.lon = 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() { - return lat / 1E6; + return lat; } 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 @@ -67,6 +80,6 @@ public final class Point implements Serializable { @Override public String toString() { - return lat + "/" + lon; + return String.format(Locale.ENGLISH, "%.7f/%.7f", lat, lon); } } diff --git a/enabler/src/de/schildbach/pte/dto/Trip.java b/enabler/src/de/schildbach/pte/dto/Trip.java index ff824910..82af95c1 100644 --- a/enabler/src/de/schildbach/pte/dto/Trip.java +++ b/enabler/src/de/schildbach/pte/dto/Trip.java @@ -240,9 +240,8 @@ public final class Trip implements Serializable { final StringBuilder builder = new StringBuilder(); for (final Leg leg : legs) { - builder.append(leg.departure.hasId() ? leg.departure.id : leg.departure.lat + '/' + leg.departure.lon) - .append('-'); - builder.append(leg.arrival.hasId() ? leg.arrival.id : leg.arrival.lat + '/' + leg.arrival.lon).append('-'); + builder.append(leg.departure.hasId() ? leg.departure.id : leg.departure.coord).append('-'); + builder.append(leg.arrival.hasId() ? leg.arrival.id : leg.arrival.coord).append('-'); if (leg instanceof Individual) { builder.append("individual"); diff --git a/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java index 5480e4b2..0e399e26 100644 --- a/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java @@ -32,6 +32,7 @@ import de.schildbach.pte.NetworkProvider.WalkSpeed; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; @@ -124,11 +125,11 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest { @Test public void slowTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "732655", 52535576, 13422171, null, "Marienburger Str., Berlin"), - null, new Location(LocationType.STATION, "623234", 48000221, 11342490, null, - "Tutzinger-Hof-Platz, Starnberg"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "732655", Point.from1E6(52535576, 13422171), null, + "Marienburger Str., Berlin"); + final Location to = new Location(LocationType.STATION, "623234", Point.from1E6(48000221, 11342490), null, + "Tutzinger-Hof-Platz, Starnberg"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) @@ -148,12 +149,11 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripWithFootway() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52517139, 13388749, null, - "Berlin - Mitte, Unter den Linden 24"), - null, new Location(LocationType.ADDRESS, null, 47994243, 11338543, null, - "Starnberg, Possenhofener Straße 13"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52517139, 13388749), null, + "Berlin - Mitte, Unter den Linden 24"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(47994243, 11338543), null, + "Starnberg, Possenhofener Straße 13"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java index f7d6a3ef..34b8908a 100644 --- a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java @@ -31,6 +31,7 @@ import de.schildbach.pte.BayernProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -145,8 +146,9 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenCoordinateAndStation() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 48238341, 11478230), null, - new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"), new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48238341, 11478230)); + final Location to = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) @@ -172,9 +174,10 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenStationAndAddress() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1001220", null, "Josephsburg"), - null, new Location(LocationType.ADDRESS, null, 48188018, 11574239, null, "München Frankfurter Ring 35"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "1001220", null, "Josephsburg"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(48188018, 11574239), null, + "München Frankfurter Ring 35"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) @@ -186,10 +189,11 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenPOIs() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.POI, null, 47710568, 12621970, null, "Ruhpolding, Seehaus"), null, - new Location(LocationType.POI, null, 47738372, 12630996, null, "Ruhpolding, Unternberg-Bahn"), - new Date(), true, null); + final Location from = new Location(LocationType.POI, null, Point.from1E6(47710568, 12621970), null, + "Ruhpolding, Seehaus"); + final Location to = new Location(LocationType.POI, null, Point.from1E6(47738372, 12630996), null, + "Ruhpolding, Unternberg-Bahn"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java index 9acbb5af..9c092670 100644 --- a/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BvgProviderLiveTest.java @@ -29,6 +29,7 @@ import de.schildbach.pte.BvgProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -131,10 +132,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenStations() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "900055101", 52496176, 13343273, null, "U Viktoria-Luise-Platz"), - null, new Location(LocationType.STATION, "900089303", 52588810, 13288699, null, "S Tegel"), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "900055101", Point.from1E6(52496176, 13343273), null, + "U Viktoria-Luise-Platz"); + final Location to = new Location(LocationType.STATION, "900089303", Point.from1E6(52588810, 13288699), null, + "S Tegel"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); } @@ -160,12 +162,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenCoordinatesAndAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52536099, 13426309, null, - "Christburger Straße 1, 10405 Berlin, Deutschland"), - null, new Location(LocationType.ADDRESS, null, 52486400, 13350744, null, - "Eisenacher Straße 70, 10823 Berlin, Deutschland"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52536099, 13426309), null, + "Christburger Straße 1, 10405 Berlin, Deutschland"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52486400, 13350744), null, + "Eisenacher Straße 70, 10823 Berlin, Deutschland"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -182,12 +183,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", - "Weimarische Str. 7"), - null, new Location(LocationType.ADDRESS, null, 52541536, 13421290, "10437 Berlin-Prenzlauer Berg", - "Göhrener Str. 5"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278), + "10715 Berlin-Wilmersdorf", "Weimarische Str. 7"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52541536, 13421290), + "10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -195,13 +195,13 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest { @Test public void viaTripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", - "Weimarische Str. 7"), - new Location(LocationType.ADDRESS, null, 52527872, 13381657, "10115 Berlin-Mitte", - "Hannoversche Str. 20"), - new Location(LocationType.ADDRESS, null, 52526029, 13399878, "10178 Berlin-Mitte", "Sophienstr. 24"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278), + "10715 Berlin-Wilmersdorf", "Weimarische Str. 7"); + final Location via = new Location(LocationType.ADDRESS, null, Point.from1E6(52527872, 13381657), + "10115 Berlin-Mitte", "Hannoversche Str. 20"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52526029, 13399878), + "10178 Berlin-Mitte", "Sophienstr. 24"); + final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -209,12 +209,11 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripAddressWithoutId() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52481922, 13388383, null, - "Bayernring, 12101 Berlin, Deutschland"), - null, - new Location(LocationType.STATION, "900064301", 52429099, 13328081, null, "S Lichterfelde Ost Bhf"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52481922, 13388383), null, + "Bayernring, 12101 Berlin, Deutschland"); + final Location to = new Location(LocationType.STATION, "900064301", Point.from1E6(52429099, 13328081), null, + "S Lichterfelde Ost Bhf"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); } } diff --git a/enabler/test/de/schildbach/pte/live/CmtaProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/CmtaProviderLiveTest.java index 25c18812..399f4bc7 100644 --- a/enabler/test/de/schildbach/pte/live/CmtaProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/CmtaProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.CmtaProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -62,8 +63,8 @@ public class CmtaProviderLiveTest extends AbstractProviderLiveTest { print(result); assertThat(result.locations, hasItem(new Location(LocationType.POI, - "A=4@O=Texas State Capitol@X=-97740215@Y=30275103@u=0@U=130@L=9819105@", 30275103, -97740215, - null, "Texas State Capitol"))); + "A=4@O=Texas State Capitol@X=-97740215@Y=30275103@u=0@U=130@L=9819105@", + Point.from1E6(30275103, -97740215), null, "Texas State Capitol"))); } @Test diff --git a/enabler/test/de/schildbach/pte/live/GvhProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/GvhProviderLiveTest.java index 658f39af..c9959c2d 100644 --- a/enabler/test/de/schildbach/pte/live/GvhProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/GvhProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.GvhProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -136,10 +137,11 @@ public class GvhProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenAnyAndAddress() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ANY, null, 53069619, 8799202, null, "bremen, neustadtswall 12"), null, - new Location(LocationType.ADDRESS, null, 53104124, 8788575, null, "Bremen Glücksburger Straße 37"), - new Date(), true, null); + final Location from = new Location(LocationType.ANY, null, Point.from1E6(53069619, 8799202), null, + "bremen, neustadtswall 12"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(53104124, 8788575), null, + "Bremen Glücksburger Straße 37"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -147,12 +149,11 @@ public class GvhProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 53622859, 10133545, null, - "Zamenhofweg 14, 22159 Hamburg, Deutschland"), - null, new Location(LocationType.ADDRESS, null, 53734260, 9674990, null, - "Lehmkuhlen 5, 25337 Elmshorn, Deutschland"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(53622859, 10133545), null, + "Zamenhofweg 14, 22159 Hamburg, Deutschland"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(53734260, 9674990), null, + "Lehmkuhlen 5, 25337 Elmshorn, Deutschland"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); diff --git a/enabler/test/de/schildbach/pte/live/KvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/KvvProviderLiveTest.java index 06b09b22..d0bd5043 100644 --- a/enabler/test/de/schildbach/pte/live/KvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/KvvProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.KvvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -81,11 +82,11 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "7000001", 49009526, 8404914, "Karlsruhe", "Marktplatz"), null, - new Location(LocationType.STATION, "7000002", 49009393, 8408866, "Karlsruhe", - "Kronenplatz (Kaiserstr.)"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "7000001", Point.from1E6(49009526, 8404914), + "Karlsruhe", "Marktplatz"); + final Location to = new Location(LocationType.STATION, "7000002", Point.from1E6(49009393, 8408866), "Karlsruhe", + "Kronenplatz (Kaiserstr.)"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -111,12 +112,11 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 48985089, 8402709, null, - "Konstanzer Straße 17, 76199 Karlsruhe, Deutschland"), - null, new Location(LocationType.ADDRESS, null, 49007706, 8356358, null, - "Durmersheimer Straße 6, 76185 Karlsruhe, Deutschland"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48985089, 8402709), null, + "Konstanzer Straße 17, 76199 Karlsruhe, Deutschland"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(49007706, 8356358), null, + "Durmersheimer Straße 6, 76185 Karlsruhe, Deutschland"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java index a94275d2..a1c508ff 100644 --- a/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java @@ -27,6 +27,7 @@ import de.schildbach.pte.LuProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -81,9 +82,10 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest { @Test public void addressTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 49611610, 6130265, null, "Luxembourg, Rue Génistre 2"), null, - new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale"), new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(49611610, 6130265), null, + "Luxembourg, Rue Génistre 2"); + final Location to = new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); diff --git a/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java index bee69165..f297ccb1 100644 --- a/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java @@ -29,6 +29,7 @@ import de.schildbach.pte.MerseyProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -81,10 +82,11 @@ public class MerseyProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "4017846", 53401672, -2958720, "Liverpool", "Orphan Street"), null, - new Location(LocationType.STATION, "4027286", 53397324, -2961676, "Liverpool", "Womens Hospital"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "4017846", Point.from1E6(53401672, -2958720), + "Liverpool", "Orphan Street"); + final Location to = new Location(LocationType.STATION, "4027286", Point.from1E6(53397324, -2961676), + "Liverpool", "Womens Hospital"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java index 858baea9..758ef4e1 100644 --- a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java @@ -31,6 +31,7 @@ import de.schildbach.pte.MvvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -124,9 +125,10 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void longTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "1005530", 48002924, 11340144, "Starnberg", "Agentur für Arbeit"), - null, new Location(LocationType.STATION, null, null, "Ackermannstraße"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "1005530", Point.from1E6(48002924, 11340144), + "Starnberg", "Agentur für Arbeit"); + final Location to = new Location(LocationType.STATION, null, null, "Ackermannstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); } @@ -141,8 +143,9 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenCoordinateAndStation() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 48238341, 11478230), null, - new Location(LocationType.ANY, null, null, "Ostbahnhof"), new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48238341, 11478230)); + final Location to = new Location(LocationType.ANY, null, null, "Ostbahnhof"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -160,9 +163,10 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenStationAndAddress() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1220", null, "Josephsburg"), - null, new Location(LocationType.ADDRESS, null, 48188018, 11574239, null, "München Frankfurter Ring 35"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "1220", null, "Josephsburg"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(48188018, 11574239), null, + "München Frankfurter Ring 35"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -171,11 +175,11 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void queryTripInvalidStation() throws Exception { 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); - 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); assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result2.status); diff --git a/enabler/test/de/schildbach/pte/live/NasaProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NasaProviderLiveTest.java index a5c87a11..9694f542 100644 --- a/enabler/test/de/schildbach/pte/live/NasaProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/NasaProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.NasaProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -103,10 +104,11 @@ public class NasaProviderLiveTest extends AbstractProviderLiveTest { @Test public void anotherShortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "8010205", 51346546, 12383333, null, "Leipzig Hbf"), null, - new Location(LocationType.STATION, "8012183", 51423340, 12223423, null, "Leipzig/Halle Flughafen"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "8010205", Point.from1E6(51346546, 12383333), null, + "Leipzig Hbf"); + final Location to = new Location(LocationType.STATION, "8012183", Point.from1E6(51423340, 12223423), null, + "Leipzig/Halle Flughafen"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); assertEquals(QueryTripsResult.Status.OK, result.status); print(result); @@ -143,10 +145,10 @@ public class NasaProviderLiveTest extends AbstractProviderLiveTest { @Test public void addressTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 51334078, 12478331, "04319 Leipzig-Engelsdorf", - "August-Bebel-Platz"), - null, new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"), new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51334078, 12478331), + "04319 Leipzig-Engelsdorf", "August-Bebel-Platz"); + final Location to = new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); assertEquals(QueryTripsResult.Status.OK, result.status); print(result); diff --git a/enabler/test/de/schildbach/pte/live/NegentweeProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NegentweeProviderLiveTest.java index 7699c444..1e46b552 100644 --- a/enabler/test/de/schildbach/pte/live/NegentweeProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/NegentweeProviderLiveTest.java @@ -177,9 +177,10 @@ public class NegentweeProviderLiveTest extends AbstractProviderLiveTest { @Test public void coordinatesTrip() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.COORD, null, new Point(51677273, 4437548)), - new Location(LocationType.COORD, null, new Point(52162772, 4583171)), - new Location(LocationType.COORD, null, new Point(53347140, 6720583)), new Date(), true, null); + final Location from = new Location(LocationType.COORD, null, Point.from1E6(51677273, 4437548)); + final Location via = new Location(LocationType.COORD, null, Point.from1E6(52162772, 4583171)); + 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); assertEquals(QueryTripsResult.Status.OK, result.status); } diff --git a/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java index 241f296b..1b7a1c60 100644 --- a/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.NvbwProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -137,10 +138,11 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTripReutlingen() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "8029333", 48492484, 9207456, "Reutlingen", "ZOB"), null, - new Location(LocationType.STATION, "8029109", 48496968, 9213320, "Reutlingen", "Bismarckstr."), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "8029333", Point.from1E6(48492484, 9207456), + "Reutlingen", "ZOB"); + final Location to = new Location(LocationType.STATION, "8029109", Point.from1E6(48496968, 9213320), + "Reutlingen", "Bismarckstr."); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -166,11 +168,11 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest { @Test public void trip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "6900037", 48063184, 7779532, "Buchheim (Breisgau)", "Fortuna"), - null, new Location(LocationType.STATION, "6906508", 47996616, 7840450, "Freiburg im Breisgau", - "Freiburg im Breisgau, Hauptbahnhof"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "6900037", Point.from1E6(48063184, 7779532), + "Buchheim (Breisgau)", "Fortuna"); + final Location to = new Location(LocationType.STATION, "6906508", Point.from1E6(47996616, 7840450), + "Freiburg im Breisgau", "Freiburg im Breisgau, Hauptbahnhof"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); } diff --git a/enabler/test/de/schildbach/pte/live/NvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NvvProviderLiveTest.java index f11992d3..ccb86710 100644 --- a/enabler/test/de/schildbach/pte/live/NvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/NvvProviderLiveTest.java @@ -31,6 +31,7 @@ import de.schildbach.pte.NvvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; @@ -193,10 +194,11 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest { public void slowTrip() throws Exception { final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.NORMAL, Accessibility.BARRIER_FREE, null); - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "3029079", 50017679, 8229480, "Mainz", "An den Dünen"), null, - new Location(LocationType.STATION, "3013508", 50142890, 8895203, "Hanau", "Beethovenplatz"), new Date(), - true, options); + final Location from = new Location(LocationType.STATION, "3029079", Point.from1E6(50017679, 8229480), "Mainz", + "An den Dünen"); + final Location to = new Location(LocationType.STATION, "3013508", Point.from1E6(50142890, 8895203), "Hanau", + "Beethovenplatz"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, options); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -218,12 +220,11 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripUsingMuchBuffer() throws IOException { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 50119563, 8697044, null, - "Hegelstrasse, 60316 Frankfurt am Main"), - null, - new Location(LocationType.ADDRESS, null, 50100364, 8615193, null, "Mainzer Landstrasse, Frankfurt"), - new Date(1378368840000l), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(50119563, 8697044), null, + "Hegelstrasse, 60316 Frankfurt am Main"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(50100364, 8615193), null, + "Mainzer Landstrasse, Frankfurt"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(1378368840000l), true, null); print(result); if (!result.context.canQueryLater()) @@ -235,10 +236,11 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripUsingEvenMoreBuffer() throws IOException { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "3000909", 50094052, 8690923, null, "F Brauerei"), null, - new Location(LocationType.STATION, "3001201", 50119950, 8653924, null, "F Bockenheimer Warte"), - new Date(1378368840000l), true, null); + final Location from = new Location(LocationType.STATION, "3000909", Point.from1E6(50094052, 8690923), null, + "F Brauerei"); + final Location to = new Location(LocationType.STATION, "3001201", Point.from1E6(50119950, 8653924), null, + "F Bockenheimer Warte"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(1378368840000l), true, null); print(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/OoevvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/OoevvProviderLiveTest.java index 09c16819..26682be5 100644 --- a/enabler/test/de/schildbach/pte/live/OoevvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/OoevvProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.OoevvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -141,10 +142,11 @@ public class OoevvProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTripSalzburg() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "455000900", 47808976, 13056409, "Salzburg", "Vogelweiderstraße"), - null, new Location(LocationType.STATION, "455084400", 47811556, 13050278, "Salzburg", "Merianstraße"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409), + "Salzburg", "Vogelweiderstraße"); + final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278), + "Salzburg", "Merianstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java index 2dfcde7a..d87ccc72 100644 --- a/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/RtProviderLiveTest.java @@ -27,6 +27,7 @@ import de.schildbach.pte.RtProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -114,11 +115,11 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripFromAddress() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 51521886, -51447, null, - "26 Coopers Close, Poplar, Greater London E1 4, Vereinigtes Königreich"), - null, new Location(LocationType.STATION, "8096022", 50941312, 6967206, null, "COLOGNE"), new Date(), - true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51521886, -51447), null, + "26 Coopers Close, Poplar, Greater London E1 4, Vereinigtes Königreich"); + final Location to = new Location(LocationType.STATION, "8096022", Point.from1E6(50941312, 6967206), null, + "COLOGNE"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); diff --git a/enabler/test/de/schildbach/pte/live/SbbProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/SbbProviderLiveTest.java index 435d644a..dd7e38df 100644 --- a/enabler/test/de/schildbach/pte/live/SbbProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/SbbProviderLiveTest.java @@ -27,6 +27,7 @@ import de.schildbach.pte.SbbProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -103,10 +104,11 @@ public class SbbProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripWithFootway() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 46689354, 7683444, null, "Spiez, Seestraße 62"), null, - new Location(LocationType.ADDRESS, null, 47133169, 8767425, null, "Einsiedeln, Erlenmoosweg 24"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(46689354, 7683444), null, + "Spiez, Seestraße 62"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(47133169, 8767425), null, + "Einsiedeln, Erlenmoosweg 24"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -114,9 +116,10 @@ public class SbbProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripFromAddress() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 47438595, 8437369, null, "Dorfstrasse 10, Dällikon, Schweiz"), - null, new Location(LocationType.STATION, "8500010", null, "Basel"), new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(47438595, 8437369), null, + "Dorfstrasse 10, Dällikon, Schweiz"); + final Location to = new Location(LocationType.STATION, "8500010", null, "Basel"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); diff --git a/enabler/test/de/schildbach/pte/live/SeProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/SeProviderLiveTest.java index 1938f7af..5edf40d1 100644 --- a/enabler/test/de/schildbach/pte/live/SeProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/SeProviderLiveTest.java @@ -29,6 +29,7 @@ import de.schildbach.pte.SeProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -114,9 +115,10 @@ public class SeProviderLiveTest extends AbstractProviderLiveTest { @Test public void longTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "740098086", 67859847, 20212802, null, "KIRUNA"), null, - new Location(LocationType.STATION, "740098000", null, "STOCKHOLM"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "740098086", Point.from1E6(67859847, 20212802), null, + "KIRUNA"); + final Location to = new Location(LocationType.STATION, "740098000", null, "STOCKHOLM"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java index 98356530..04c67ee0 100644 --- a/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/SvvProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.SvvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -101,10 +102,11 @@ public class SvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "455002100", 47797110, 13053632, "Salzburg", "Justizgebäude"), null, - new Location(LocationType.STATION, "455002200", 47794000, 13059223, "Salzburg", "Akademiestraße"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "455002100", Point.from1E6(47797110, 13053632), + "Salzburg", "Justizgebäude"); + final Location to = new Location(LocationType.STATION, "455002200", Point.from1E6(47794000, 13059223), + "Salzburg", "Akademiestraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java index 03d28976..82178594 100644 --- a/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/TlemProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.TlemProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -118,12 +119,11 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip2() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "2099014", 52478184, -1898364, "Birmingham", - "Birmingham New Street Rail Station"), - null, new Location(LocationType.STATION, "2099150", 52585468, -2122962, "Wolverhampton", - "Wolverhampton Rail Station"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "2099014", Point.from1E6(52478184, -1898364), + "Birmingham", "Birmingham New Street Rail Station"); + final Location to = new Location(LocationType.STATION, "2099150", Point.from1E6(52585468, -2122962), + "Wolverhampton", "Wolverhampton Rail Station"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -149,12 +149,11 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripArncott() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "60011202", 51850168, -1094302, "Upper Arncott", - "Bullingdon Prison"), - null, - new Location(LocationType.STATION, "60006013", 51856612, -1112904, "Lower Arncott", "The Plough E"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "60011202", Point.from1E6(51850168, -1094302), + "Upper Arncott", "Bullingdon Prison"); + final Location to = new Location(LocationType.STATION, "60006013", Point.from1E6(51856612, -1112904), + "Lower Arncott", "The Plough E"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -180,22 +179,22 @@ public class TlemProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripFromPOI() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.POI, - "poiID:48863:31117134:-1:Statue:Ham (London):Statue:ANY:POI:517246:826916:TFLV:uk", 51444620, - -314316, "Ham (London)", "Statue"), - null, - new Location(LocationType.ADDRESS, "streetID:106269::31117001:-1", "London", "Cannon Street, London"), - new Date(), true, null); + final Location from = new Location(LocationType.POI, + "poiID:48863:31117134:-1:Statue:Ham (London):Statue:ANY:POI:517246:826916:TFLV:uk", + Point.from1E6(51444620, -314316), "Ham (London)", "Statue"); + final Location to = new Location(LocationType.ADDRESS, "streetID:106269::31117001:-1", "London", + "Cannon Street, London"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); } @Test public void tripFromAddress() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, "streetID:203417::31117006:-1", "London", "Kings Cross, London"), - null, new Location(LocationType.STATION, "1002070", 51508530, 46706, "Royal Albert", "Royal Albert"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, "streetID:203417::31117006:-1", "London", + "Kings Cross, London"); + final Location to = new Location(LocationType.STATION, "1002070", Point.from1E6(51508530, 46706), + "Royal Albert", "Royal Albert"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); } diff --git a/enabler/test/de/schildbach/pte/live/VaoProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VaoProviderLiveTest.java index cafcfec3..6b4288e6 100644 --- a/enabler/test/de/schildbach/pte/live/VaoProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VaoProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VaoProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -153,10 +154,11 @@ public class VaoProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTripSalzburg() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "455000900", 47808976, 13056409, "Salzburg", "Vogelweiderstraße"), - null, new Location(LocationType.STATION, "455084400", 47811556, 13050278, "Salzburg", "Merianstraße"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409), + "Salzburg", "Vogelweiderstraße"); + final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278), + "Salzburg", "Merianstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -193,7 +195,6 @@ public class VaoProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripCoordinateToStation() throws Exception { - final QueryTripsResult result = queryTrips(Location.coord(47238096, 9585581), null, new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof"), new Date(), true, null); print(result); diff --git a/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java index 55f823bf..b12ba5b4 100644 --- a/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VbbProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VbbProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -126,11 +127,11 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortFootwayTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52435193, 13473409, "12357 Berlin-Buckow", "Kernbeisserweg 4"), - null, - new Location(LocationType.ADDRESS, null, 52433989, 13474353, "12357 Berlin-Buckow", "Distelfinkweg 35"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52435193, 13473409), + "12357 Berlin-Buckow", "Kernbeisserweg 4"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52433989, 13474353), + "12357 Berlin-Buckow", "Distelfinkweg 35"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) @@ -183,12 +184,11 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", - "Weimarische Str. 7"), - null, new Location(LocationType.ADDRESS, null, 52541536, 13421290, "10437 Berlin-Prenzlauer Berg", - "Göhrener Str. 5"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278), + "10715 Berlin-Wilmersdorf", "Weimarische Str. 7"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52541536, 13421290), + "10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) @@ -200,13 +200,13 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest { @Test public void viaTripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 52479663, 13324278, "10715 Berlin-Wilmersdorf", - "Weimarische Str. 7"), - new Location(LocationType.ADDRESS, null, 52527872, 13381657, "10115 Berlin-Mitte", - "Hannoversche Str. 20"), - new Location(LocationType.ADDRESS, null, 52526029, 13399878, "10178 Berlin-Mitte", "Sophienstr. 24"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278), + "10715 Berlin-Wilmersdorf", "Weimarische Str. 7"); + final Location via = new Location(LocationType.ADDRESS, null, Point.from1E6(52527872, 13381657), + "10115 Berlin-Mitte", "Hannoversche Str. 20"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52526029, 13399878), + "10178 Berlin-Mitte", "Sophienstr. 24"); + final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null); print(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java index 5199de23..1c3d570a 100644 --- a/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VblProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.VblProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -78,10 +79,11 @@ public class VblProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "53020041", 47050164, 8310352, "Luzern", "Bahnhof"), null, - new Location(LocationType.STATION, "53028841", 47048564, 8306016, "Luzern", "Kantonalbank"), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "53020041", Point.from1E6(47050164, 8310352), "Luzern", + "Bahnhof"); + final Location to = new Location(LocationType.STATION, "53028841", Point.from1E6(47048564, 8306016), "Luzern", + "Kantonalbank"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java index dd1294a8..c5a1d2b2 100644 --- a/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.VgnProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -86,11 +87,11 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripToPOI() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, 49527298, 10836204), null, - new Location(LocationType.POI, - "poiID:246:9564000:1:Grundschule Grimmstr.:Nürnberg:Grundschule Grimmstr.:ANY:POI:4436708:678322:NAV4:VGN", - 49468692, 11125334, "Nürnberg", "Grundschule Grimmstr."), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(49527298, 10836204)); + final Location to = new Location(LocationType.POI, + "poiID:246:9564000:1:Grundschule Grimmstr.:Nürnberg:Grundschule Grimmstr.:ANY:POI:4436708:678322:NAV4:VGN", + Point.from1E6(49468692, 11125334), "Nürnberg", "Grundschule Grimmstr."); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); @@ -99,10 +100,10 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripToAddress() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "1756", "Nürnberg", "Saarbrückener Str."), null, - new Location(LocationType.ADDRESS, null, 49437392, 11094524, "Nürnberg", "Wodanstraße 25"), new Date(), - false, null); + final Location from = new Location(LocationType.STATION, "1756", "Nürnberg", "Saarbrückener Str."); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(49437392, 11094524), "Nürnberg", + "Wodanstraße 25"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); diff --git a/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java index b3d31398..46585953 100644 --- a/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VmobilProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VmobilProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -153,10 +154,11 @@ public class VmobilProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTripSalzburg() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "455000900", 47808976, 13056409, "Salzburg", "Vogelweiderstraße"), - null, new Location(LocationType.STATION, "455084400", 47811556, 13050278, "Salzburg", "Merianstraße"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409), + "Salzburg", "Vogelweiderstraße"); + final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278), + "Salzburg", "Merianstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VmsProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VmsProviderLiveTest.java index 83b94c41..271c0ff6 100644 --- a/enabler/test/de/schildbach/pte/live/VmsProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VmsProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.VmsProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -66,10 +67,11 @@ public class VmsProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "36030131", 50831380, 12922278, "Chemnitz", "Zentralhaltestelle"), - null, new Location(LocationType.STATION, "36030522", 50836056, 12922042, "Chemnitz", "Stadthalle"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "36030131", Point.from1E6(50831380, 12922278), + "Chemnitz", "Zentralhaltestelle"); + final Location to = new Location(LocationType.STATION, "36030522", Point.from1E6(50836056, 12922042), + "Chemnitz", "Stadthalle"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VmtProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VmtProviderLiveTest.java index f484b4cd..1848d5fe 100644 --- a/enabler/test/de/schildbach/pte/live/VmtProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VmtProviderLiveTest.java @@ -27,6 +27,7 @@ import de.schildbach.pte.VmtProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -80,10 +81,11 @@ public class VmtProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "153166", 50926947, 11586987, null, "Jena, Stadtzentrum"), null, - new Location(LocationType.STATION, "153014", 50933887, 11590592, null, "Jena, Spittelpl."), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "153166", Point.from1E6(50926947, 11586987), null, + "Jena, Stadtzentrum"); + final Location to = new Location(LocationType.STATION, "153014", Point.from1E6(50933887, 11590592), null, + "Jena, Spittelpl."); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); System.out.println(result); if (!result.context.canQueryLater()) diff --git a/enabler/test/de/schildbach/pte/live/VmvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VmvProviderLiveTest.java index db8a8601..074fb941 100644 --- a/enabler/test/de/schildbach/pte/live/VmvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VmvProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.VmvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -74,10 +75,10 @@ public class VmvProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "44402006", null, "Schwerin Marienplatz"), null, - new Location(LocationType.STATION, "44402007", 53625272, 11409350, null, "Schlossblick"), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "44402006", null, "Schwerin Marienplatz"); + final Location to = new Location(LocationType.STATION, "44402007", Point.from1E6(53625272, 11409350), null, + "Schlossblick"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java index 06ab19af..a9f7924c 100644 --- a/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VorProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VorProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -98,10 +99,11 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "490065700", 48200852, 16368880, "Wien", "Karlsplatz"), null, - new Location(LocationType.STATION, "490109400", 48198362, 16367667, "Wien", "Resselgasse"), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "490065700", Point.from1E6(48200852, 16368880), "Wien", + "Karlsplatz"); + final Location to = new Location(LocationType.STATION, "490109400", Point.from1E6(48198362, 16367667), "Wien", + "Resselgasse"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); @@ -127,12 +129,11 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripToPOI() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "490134900", 48185184, 16376413), - null, - new Location(LocationType.POI, - "A=4@O=Naschmarkt, Wien@X=16362903@Y=48198290@U=130@L=960068499@B=1@p=1476842541@", 48198290, - 16362903, "Wien", "Naschmarkt"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "490134900", Point.from1E6(48185184, 16376413)); + final Location to = new Location(LocationType.POI, + "A=4@O=Naschmarkt, Wien@X=16362903@Y=48198290@U=130@L=960068499@B=1@p=1476842541@", + Point.from1E6(48198290, 16362903), "Wien", "Naschmarkt"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); diff --git a/enabler/test/de/schildbach/pte/live/VrnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VrnProviderLiveTest.java index b522ebc7..a41fd288 100644 --- a/enabler/test/de/schildbach/pte/live/VrnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VrnProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VrnProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -102,10 +103,11 @@ public class VrnProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "6002417", 49479748, 8469938, "Mannheim", "Mannheim, Hauptbahnhof"), - null, new Location(LocationType.STATION, "6005542", 49482892, 8473050, "Mannheim", "Kunsthalle"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "6002417", Point.from1E6(49479748, 8469938), + "Mannheim", "Mannheim, Hauptbahnhof"); + final Location to = new Location(LocationType.STATION, "6005542", Point.from1E6(49482892, 8473050), "Mannheim", + "Kunsthalle"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VrsProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VrsProviderLiveTest.java index 514802f3..2e9e230d 100644 --- a/enabler/test/de/schildbach/pte/live/VrsProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VrsProviderLiveTest.java @@ -45,6 +45,7 @@ import de.schildbach.pte.dto.LineDestination; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; @@ -415,10 +416,12 @@ public class VrsProviderLiveTest extends AbstractProviderLiveTest { @Test public void testTripByAddressAndEmptyPolygon() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null /* id */, 50909350, 6676310, "Kerpen-Sindorf", "Erftstraße 43"), - null, new Location(LocationType.ADDRESS, null /* id */, 50923000, 6818440, "Frechen", "Zedernweg 1"), - Iso8601Format.parseDateTime("2015-03-17 21:11:18"), true, null); + final Location from = new Location(LocationType.ADDRESS, null /* id */, Point.from1E6(50909350, 6676310), + "Kerpen-Sindorf", "Erftstraße 43"); + final Location to = new Location(LocationType.ADDRESS, null /* id */, Point.from1E6(50923000, 6818440), + "Frechen", "Zedernweg 1"); + final QueryTripsResult result = queryTrips(from, null, to, Iso8601Format.parseDateTime("2015-03-17 21:11:18"), + true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VvmProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VvmProviderLiveTest.java index 5dcdf732..47296682 100644 --- a/enabler/test/de/schildbach/pte/live/VvmProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VvmProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VvmProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -75,10 +76,11 @@ public class VvmProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "3700075", 49801076, 9934302, "Würzburg", "Busbahnhof"), null, - new Location(LocationType.STATION, "3700403", 49797772, 9934986, "Würzburg", "Stift Haug"), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "3700075", Point.from1E6(49801076, 9934302), + "Würzburg", "Busbahnhof"); + final Location to = new Location(LocationType.STATION, "3700403", Point.from1E6(49797772, 9934986), "Würzburg", + "Stift Haug"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java index 7428cd4b..27f1f4fd 100644 --- a/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VvoProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VvoProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -116,11 +117,11 @@ public class VvoProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripFromAddressToAddress() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, 51052260, 13740998, "Dresden", "Dresden, Töpferstraße 10"), - null, new Location(LocationType.ADDRESS, null, 51029752, 13700666, "Dresden", - "Dresden, Tharandter Straße 88"), - new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51052260, 13740998), "Dresden", + "Dresden, Töpferstraße 10"); + final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(51029752, 13700666), "Dresden", + "Dresden, Tharandter Straße 88"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VvsProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VvsProviderLiveTest.java index 9d399b19..20c49be3 100644 --- a/enabler/test/de/schildbach/pte/live/VvsProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VvsProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VvsProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -82,11 +83,11 @@ public class VvsProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "5006118", 48782984, 9179846, "Stuttgart", - "Stuttgart, Hauptbahnhof"), - null, new Location(LocationType.STATION, "5006024", 48782584, 9187098, "Stuttgart", "Staatsgalerie"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "5006118", Point.from1E6(48782984, 9179846), + "Stuttgart", "Stuttgart, Hauptbahnhof"); + final Location to = new Location(LocationType.STATION, "5006024", Point.from1E6(48782584, 9187098), "Stuttgart", + "Staatsgalerie"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VvtProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VvtProviderLiveTest.java index 6811ff06..fb5d2181 100644 --- a/enabler/test/de/schildbach/pte/live/VvtProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VvtProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VvtProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -87,10 +88,11 @@ public class VvtProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "476151200", 47268248, 11355560, "Innsbruck", "Allerheiligen"), null, - new Location(LocationType.STATION, "476151000", 47267241, 11351003, "Innsbruck", "Tschiggfreystraße"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "476151200", Point.from1E6(47268248, 11355560), + "Innsbruck", "Allerheiligen"); + final Location to = new Location(LocationType.STATION, "476151000", Point.from1E6(47267241, 11351003), + "Innsbruck", "Tschiggfreystraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/VvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VvvProviderLiveTest.java index 555e691b..b4b5a552 100644 --- a/enabler/test/de/schildbach/pte/live/VvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VvvProviderLiveTest.java @@ -28,6 +28,7 @@ import de.schildbach.pte.VvvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -72,11 +73,11 @@ public class VvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "30202006", 50484564, 12140028, "Plauen (Vogtl)", "Bickelstraße"), - null, - new Location(LocationType.STATION, "30202012", 50487332, 12139050, "Plauen (Vogtl)", "Hofer Straße"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "30202006", Point.from1E6(50484564, 12140028), + "Plauen (Vogtl)", "Bickelstraße"); + final Location to = new Location(LocationType.STATION, "30202012", Point.from1E6(50487332, 12139050), + "Plauen (Vogtl)", "Hofer Straße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java index a566a40a..8b0242a7 100644 --- a/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/WienProviderLiveTest.java @@ -31,6 +31,7 @@ import de.schildbach.pte.WienProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -95,10 +96,11 @@ public class WienProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "60200657", 48200756, 16369001, "Wien", "Karlsplatz"), null, - new Location(LocationType.STATION, "60201094", 48198612, 16367719, "Wien", "Resselgasse"), new Date(), - true, null); + final Location from = new Location(LocationType.STATION, "60200657", Point.from1E6(48200756, 16369001), "Wien", + "Karlsplatz"); + final Location to = new Location(LocationType.STATION, "60201094", Point.from1E6(48198612, 16367719), "Wien", + "Resselgasse"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); diff --git a/enabler/test/de/schildbach/pte/live/ZvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/ZvvProviderLiveTest.java index 442eed57..6405e128 100644 --- a/enabler/test/de/schildbach/pte/live/ZvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/ZvvProviderLiveTest.java @@ -27,6 +27,7 @@ import de.schildbach.pte.ZvvProvider; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; @@ -81,10 +82,11 @@ public class ZvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void trip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "8503000", 47378491, 8537945, "Zürich", "Zürich, Hauptbahnhof"), - null, new Location(LocationType.STATION, "8530812", 47361762, 8560715, "Zürich", "Hegibachplatz"), - new Date(), true, null); + final Location from = new Location(LocationType.STATION, "8503000", Point.from1E6(47378491, 8537945), "Zürich", + "Zürich, Hauptbahnhof"); + final Location to = new Location(LocationType.STATION, "8530812", Point.from1E6(47361762, 8560715), "Zürich", + "Hegibachplatz"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult);