diff --git a/src/de/schildbach/pte/AbstractEfaProvider.java b/src/de/schildbach/pte/AbstractEfaProvider.java index 2fc036c8..d79049d3 100644 --- a/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/src/de/schildbach/pte/AbstractEfaProvider.java @@ -833,18 +833,16 @@ public abstract class AbstractEfaProvider implements NetworkProvider if (!XmlPullUtil.jumpToStartTag(pp, null, "itdOdv") || !"dm".equals(pp.getAttributeValue(null, "usage"))) throw new IllegalStateException("cannot find "); - if (!XmlPullUtil.nextStartTagInsideTree(pp, null, "itdOdvName")) - throw new IllegalStateException("cannot find "); + XmlPullUtil.enter(pp, "itdOdv"); + + final String place = processItdOdvPlace(pp); + + XmlPullUtil.require(pp, "itdOdvName"); final String nameState = pp.getAttributeValue(null, "state"); + XmlPullUtil.enter(pp, "itdOdvName"); if ("identified".equals(nameState)) { - XmlPullUtil.jumpToStartTag(pp, null, "odvNameElem"); - String locationIdStr = pp.getAttributeValue(null, "stopID"); - if (locationIdStr == null) - locationIdStr = pp.getAttributeValue(null, "id"); - final int locationId = Integer.parseInt(locationIdStr); - - final String location = normalizeLocationName(pp.nextText()); + final Location location = processOdvNameElem(pp, place); final Calendar plannedDepartureTime = new GregorianCalendar(); plannedDepartureTime.setTimeZone(timeZone()); @@ -883,7 +881,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider XmlPullUtil.enter(pp, "itdDepartureList"); while (XmlPullUtil.test(pp, "itdDeparture")) { - if (Integer.parseInt(pp.getAttributeValue(null, "stopID")) == locationId) + if (Integer.parseInt(pp.getAttributeValue(null, "stopID")) == location.id) { final String position = normalizePlatform(pp.getAttributeValue(null, "platform"), pp.getAttributeValue(null, "platformName")); @@ -926,7 +924,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider XmlPullUtil.exit(pp, "itdDepartureList"); } - return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, location), departures, lines); + return new QueryDeparturesResult(location, departures, lines); } else if ("notidentified".equals(nameState)) { @@ -1239,7 +1237,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider final String destinationIdStr = pp.getAttributeValue(null, "destID"); final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "destination")); final Location destination = destinationIdStr.length() > 0 ? new Location(LocationType.STATION, - Integer.parseInt(destinationIdStr), destinationName) : new Location(LocationType.ANY, 0, destinationName); + Integer.parseInt(destinationIdStr), null, destinationName) : new Location(LocationType.ANY, 0, null, + destinationName); String line; if ("AST".equals(pp.getAttributeValue(null, "symbol"))) line = "BAST"; @@ -1274,7 +1273,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider XmlPullUtil.require(pp, "itdDateTime"); processItdDateTime(pp, stopTime); XmlPullUtil.exit(pp, "itdPoint"); - intermediateStops.add(new Stop(new Location(LocationType.STATION, stopId, stopName), stopPosition, stopTime + intermediateStops.add(new Stop(new Location(LocationType.STATION, stopId, null, stopName), stopPosition, stopTime .getTime())); } XmlPullUtil.exit(pp, "itdStopSeq"); diff --git a/src/de/schildbach/pte/AbstractHafasProvider.java b/src/de/schildbach/pte/AbstractHafasProvider.java index 9fca2afc..9dc02c3d 100644 --- a/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/src/de/schildbach/pte/AbstractHafasProvider.java @@ -123,7 +123,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider { XmlPullUtil.requireAttr(pp, "type", "ADR"); final String name = pp.getAttributeValue(null, "output").trim(); - return new Location(LocationType.ADDRESS, 0, name); + return new Location(LocationType.ADDRESS, 0, null, name); } throw new IllegalStateException("cannot handle: " + type); } @@ -377,7 +377,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider } else if ("DIRECTION".equals(attrName)) { - destination = new Location(LocationType.ANY, 0, attributeVariants.get("NORMAL")); + destination = new Location(LocationType.ANY, 0, null, attributeVariants.get("NORMAL")); } } XmlPullUtil.exit(pp); diff --git a/src/de/schildbach/pte/BahnProvider.java b/src/de/schildbach/pte/BahnProvider.java index 70bf0551..69429018 100644 --- a/src/de/schildbach/pte/BahnProvider.java +++ b/src/de/schildbach/pte/BahnProvider.java @@ -82,13 +82,13 @@ public final class BahnProvider extends AbstractHafasProvider final Matcher mSingle = P_SINGLE_NAME.matcher(page); if (mSingle.matches()) { - results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1)))); + results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), null, ParserUtils.resolveEntities(mSingle.group(1)))); } else { final Matcher mMulti = P_MULTI_NAME.matcher(page); while (mMulti.find()) - results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2)))); + results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), null, ParserUtils.resolveEntities(mMulti.group(2)))); } return results; @@ -190,7 +190,7 @@ public final class BahnProvider extends AbstractHafasProvider { final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim(); if (!addresses.contains(address)) - addresses.add(new Location(LocationType.ANY, 0, address + "!")); + addresses.add(new Location(LocationType.ANY, 0, null, address + "!")); } if (type.equals("REQ0JourneyStopsS0K")) @@ -250,8 +250,8 @@ public final class BahnProvider extends AbstractHafasProvider final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page); if (mHead.matches()) { - final Location from = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(1))); - final Location to = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(2))); + final Location from = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(1))); + final Location to = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(2))); final Date currentDate = ParserUtils.parseDate(mHead.group(3)); final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null; final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null; @@ -479,7 +479,7 @@ public final class BahnProvider extends AbstractHafasProvider if (code.equals("H730")) // Your input is not valid return new QueryDeparturesResult(QueryDeparturesResult.Status.INVALID_STATION, Integer.parseInt(stationId)); if (code.equals("H890")) // No trains in result - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null), + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId)), Collections. emptyList(), null); throw new IllegalArgumentException("unknown error " + code + ", " + text); } @@ -524,7 +524,7 @@ public final class BahnProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId)), departures, null); } @Override diff --git a/src/de/schildbach/pte/BvgProvider.java b/src/de/schildbach/pte/BvgProvider.java index fe572832..4f40f41f 100644 --- a/src/de/schildbach/pte/BvgProvider.java +++ b/src/de/schildbach/pte/BvgProvider.java @@ -94,13 +94,13 @@ public final class BvgProvider extends AbstractHafasProvider final Matcher mSingle = P_SINGLE_NAME.matcher(page); if (mSingle.matches()) { - results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1)))); + results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), null, ParserUtils.resolveEntities(mSingle.group(1)))); } else { final Matcher mMulti = P_MULTI_NAME.matcher(page); while (mMulti.find()) - results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2)))); + results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), null, ParserUtils.resolveEntities(mMulti.group(2)))); } return results; @@ -304,7 +304,7 @@ public final class BvgProvider extends AbstractHafasProvider { final String address = ParserUtils.resolveEntities(mAddress.group(1)); if (!addresses.contains(address)) - addresses.add(new Location(LocationType.ANY, 0, address + "!")); + addresses.add(new Location(LocationType.ANY, 0, null, address + "!")); } if (addresses.isEmpty()) @@ -364,8 +364,8 @@ public final class BvgProvider extends AbstractHafasProvider final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page); if (mHead.matches()) { - final Location from = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(1))); - final Location to = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(2))); + final Location from = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(1))); + final Location to = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(2))); final Date currentDate = ParserUtils.parseDate(mHead.group(3)); final String linkEarlier = mHead.group(4) != null ? BVG_BASE_URL + ParserUtils.resolveEntities(mHead.group(4)) : null; final String linkLater = mHead.group(5) != null ? BVG_BASE_URL + ParserUtils.resolveEntities(mHead.group(5)) : null; @@ -483,7 +483,7 @@ public final class BvgProvider extends AbstractHafasProvider final String line = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(5))); - final Location destination = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mDetFine.group(6))); + final Location destination = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mDetFine.group(6))); Date arrivalTime = ParserUtils.joinDateTime(currentDate, ParserUtils.parseTime(mDetFine.group(7))); if (departureTime.after(arrivalTime)) @@ -662,7 +662,7 @@ public final class BvgProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null, location), departures, null); } else { @@ -729,7 +729,7 @@ public final class BvgProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/NasaProvider.java b/src/de/schildbach/pte/NasaProvider.java index 7a83e557..132de1de 100644 --- a/src/de/schildbach/pte/NasaProvider.java +++ b/src/de/schildbach/pte/NasaProvider.java @@ -143,7 +143,7 @@ public class NasaProvider extends AbstractHafasProvider { // messages if (mHeadCoarse.group(3) != null) - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null), + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId)), Collections. emptyList(), null); else if (mHeadCoarse.group(4) != null) return new QueryDeparturesResult(Status.INVALID_STATION, Integer.parseInt(stationId)); @@ -215,7 +215,7 @@ public class NasaProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/NsProvider.java b/src/de/schildbach/pte/NsProvider.java index 7c755a6b..f28e04a0 100644 --- a/src/de/schildbach/pte/NsProvider.java +++ b/src/de/schildbach/pte/NsProvider.java @@ -161,7 +161,7 @@ public class NsProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/OebbProvider.java b/src/de/schildbach/pte/OebbProvider.java index f3a9f5b0..89d805f4 100644 --- a/src/de/schildbach/pte/OebbProvider.java +++ b/src/de/schildbach/pte/OebbProvider.java @@ -281,7 +281,7 @@ public class OebbProvider extends AbstractHafasProvider { final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim(); if (!addresses.contains(address)) - addresses.add(new Location(LocationType.ANY, 0, address + "!")); + addresses.add(new Location(LocationType.ANY, 0, null, address + "!")); } if (type.equals("REQ0JourneyStopsS0K")) @@ -383,8 +383,8 @@ public class OebbProvider extends AbstractHafasProvider final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page); if (mHead.matches()) { - final Location from = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(1))); - final Location to = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(2))); + final Location from = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(1))); + final Location to = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(2))); final Date currentDate = ParserUtils.parseDate(mHead.group(3)); final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null; final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null; @@ -459,7 +459,7 @@ public class OebbProvider extends AbstractHafasProvider final String arrivalPosition = mDetFine.group(12) != null ? ParserUtils.resolveEntities(mDetFine.group(12)) : null; - final Location destination = mDetFine.group(13) != null ? new Location(LocationType.ANY, 0, + final Location destination = mDetFine.group(13) != null ? new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mDetFine.group(13))) : null; final Connection.Trip trip = new Connection.Trip(line, lineColors(line), destination, detailsDepartureDateTime, @@ -575,7 +575,7 @@ public class OebbProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, null, location), departures, null); } catch (final JSONException x) { diff --git a/src/de/schildbach/pte/RmvProvider.java b/src/de/schildbach/pte/RmvProvider.java index 2351e6e6..c53c8f98 100644 --- a/src/de/schildbach/pte/RmvProvider.java +++ b/src/de/schildbach/pte/RmvProvider.java @@ -86,13 +86,13 @@ public class RmvProvider extends AbstractHafasProvider final Matcher mSingle = P_SINGLE_NAME.matcher(page); if (mSingle.matches()) { - results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1)))); + results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), null, ParserUtils.resolveEntities(mSingle.group(1)))); } else { final Matcher mMulti = P_MULTI_NAME.matcher(page); while (mMulti.find()) - results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2)))); + results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), null, ParserUtils.resolveEntities(mMulti.group(2)))); } return results; @@ -199,7 +199,7 @@ public class RmvProvider extends AbstractHafasProvider { final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim(); if (!addresses.contains(address)) - addresses.add(new Location(LocationType.ANY, 0, address + "!")); + addresses.add(new Location(LocationType.ANY, 0, null, address + "!")); } if (type == null) @@ -245,8 +245,8 @@ public class RmvProvider extends AbstractHafasProvider final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page); if (mHead.matches()) { - final Location from = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(1))); - final Location to = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mHead.group(2))); + final Location from = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(1))); + final Location to = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(2))); final Date currentDate = ParserUtils.parseDate(mHead.group(3)); final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null; final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null; @@ -352,7 +352,7 @@ public class RmvProvider extends AbstractHafasProvider { final String line = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(1))); - final Location destination = new Location(LocationType.ANY, 0, ParserUtils.resolveEntities(mDetFine.group(2))); + final Location destination = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mDetFine.group(2))); final Date departureTime = upTime(lastTime, ParserUtils.joinDateTime(currentDate, ParserUtils.parseTime(mDetFine.group(3)))); @@ -527,7 +527,7 @@ public class RmvProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/SbbProvider.java b/src/de/schildbach/pte/SbbProvider.java index 6e1c69f0..235d1058 100644 --- a/src/de/schildbach/pte/SbbProvider.java +++ b/src/de/schildbach/pte/SbbProvider.java @@ -124,7 +124,7 @@ public class SbbProvider extends AbstractHafasProvider { // messages if (mHeadCoarse.group(3) != null) - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null), + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId)), Collections. emptyList(), null); else if (mHeadCoarse.group(5) != null) return new QueryDeparturesResult(Status.INVALID_STATION, Integer.parseInt(stationId)); @@ -182,7 +182,7 @@ public class SbbProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/SncbProvider.java b/src/de/schildbach/pte/SncbProvider.java index 4bd6007b..973ee112 100644 --- a/src/de/schildbach/pte/SncbProvider.java +++ b/src/de/schildbach/pte/SncbProvider.java @@ -161,7 +161,7 @@ public class SncbProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/VgsProvider.java b/src/de/schildbach/pte/VgsProvider.java index c77d9af3..991fc420 100644 --- a/src/de/schildbach/pte/VgsProvider.java +++ b/src/de/schildbach/pte/VgsProvider.java @@ -142,7 +142,7 @@ public class VgsProvider extends AbstractHafasProvider { // messages if (mHeadCoarse.group(3) != null) - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null), + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId)), Collections. emptyList(), null); else if (mHeadCoarse.group(4) != null) return new QueryDeparturesResult(Status.INVALID_STATION, Integer.parseInt(stationId)); @@ -214,7 +214,7 @@ public class VgsProvider extends AbstractHafasProvider } } - return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), location), departures, null); + return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), null, location), departures, null); } else { diff --git a/src/de/schildbach/pte/dto/Location.java b/src/de/schildbach/pte/dto/Location.java index ce58629e..10c057f3 100644 --- a/src/de/schildbach/pte/dto/Location.java +++ b/src/de/schildbach/pte/dto/Location.java @@ -40,14 +40,34 @@ public final class Location implements Serializable this.name = name; } - public Location(final LocationType type, final int id, final String name) + public Location(final LocationType type, final int id, final String place, final String name) + { + this.type = type; + this.id = id; + this.lat = 0; + this.lon = 0; + this.place = place; + this.name = name; + } + + public Location(final LocationType type, final int id, final int lat, final int lon) + { + this.type = type; + this.id = id; + this.lat = lat; + this.lon = lon; + this.place = null; + this.name = null; + } + + public Location(final LocationType type, final int id) { this.type = type; this.id = id; this.lat = 0; this.lon = 0; this.place = null; - this.name = name; + this.name = null; } @Override diff --git a/src/de/schildbach/pte/dto/QueryDeparturesResult.java b/src/de/schildbach/pte/dto/QueryDeparturesResult.java index e8dbe8f6..e81b543b 100644 --- a/src/de/schildbach/pte/dto/QueryDeparturesResult.java +++ b/src/de/schildbach/pte/dto/QueryDeparturesResult.java @@ -45,7 +45,7 @@ public final class QueryDeparturesResult public QueryDeparturesResult(final Status status, final int locationId) { this.status = status; - this.location = new Location(LocationType.STATION, locationId, null); + this.location = new Location(LocationType.STATION, locationId); this.departures = null; this.lines = null; } diff --git a/test/de/schildbach/pte/live/BahnProviderLiveTest.java b/test/de/schildbach/pte/live/BahnProviderLiveTest.java index 8316102a..9d678f51 100644 --- a/test/de/schildbach/pte/live/BahnProviderLiveTest.java +++ b/test/de/schildbach/pte/live/BahnProviderLiveTest.java @@ -47,8 +47,8 @@ public class BahnProviderLiveTest @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Berlin"), null, new Location( - LocationType.ANY, 0, "Leipzig"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Berlin"), null, new Location( + LocationType.ANY, 0, null, "Leipzig"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); for (final Connection connection : result.connections) @@ -59,8 +59,8 @@ public class BahnProviderLiveTest @Test public void slowConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Marienburger Str., Berlin"), null, - new Location(LocationType.ANY, 0, "Tutzinger-Hof-Platz, Starnberg"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Marienburger Str., Berlin"), null, + new Location(LocationType.ANY, 0, null, "Tutzinger-Hof-Platz, Starnberg"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); for (final Connection connection : result.connections) @@ -71,8 +71,9 @@ public class BahnProviderLiveTest @Test public void connectionWithFootway() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, "Berlin - Mitte, Unter den Linden 24"), - null, new Location(LocationType.ADDRESS, 0, "Starnberg, Possenhofener Straße 13"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, null, + "Berlin - Mitte, Unter den Linden 24"), null, new Location(LocationType.ADDRESS, 0, null, "Starnberg, Possenhofener Straße 13"), + new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); diff --git a/test/de/schildbach/pte/live/GvhProviderLiveTest.java b/test/de/schildbach/pte/live/GvhProviderLiveTest.java index 4f82a90f..7dd649d5 100644 --- a/test/de/schildbach/pte/live/GvhProviderLiveTest.java +++ b/test/de/schildbach/pte/live/GvhProviderLiveTest.java @@ -88,17 +88,16 @@ public class GvhProviderLiveTest @Test public void incompleteConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "hann"), null, new Location( - LocationType.ANY, 0, "laat"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "hann"), null, new Location( + LocationType.ANY, 0, null, "laat"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); System.out.println(result); } @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 25000031, 0, 0, null, - "Hannover Hauptbahnhof"), null, new Location(LocationType.STATION, 25001141, "Hannover Bismarckstraße"), new Date(), true, - ALL_PRODUCTS, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 25000031, null, "Hannover Hauptbahnhof"), + null, new Location(LocationType.STATION, 25001141, null, "Hannover Bismarckstraße"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); System.out.println(result); } diff --git a/test/de/schildbach/pte/live/LinzProviderLiveTest.java b/test/de/schildbach/pte/live/LinzProviderLiveTest.java index c944e838..c03c03f7 100644 --- a/test/de/schildbach/pte/live/LinzProviderLiveTest.java +++ b/test/de/schildbach/pte/live/LinzProviderLiveTest.java @@ -79,16 +79,16 @@ public class LinzProviderLiveTest @Test public void incompleteConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "linz"), null, new Location( - LocationType.ANY, 0, "gel"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "linz"), null, new Location( + LocationType.ANY, 0, null, "gel"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); System.out.println(result); } @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 0, "Linz Hauptbahnhof"), null, - new Location(LocationType.STATION, 0, "Linz Auwiesen"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 0, null, "Linz Hauptbahnhof"), null, + new Location(LocationType.STATION, 0, null, "Linz Auwiesen"), new Date(), true, ALL_PRODUCTS, WalkSpeed.FAST); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -97,8 +97,8 @@ public class LinzProviderLiveTest @Test public void longConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 0, "Linz Auwiesen"), null, new Location( - LocationType.STATION, 0, "Linz Hafen"), new Date(), true, ALL_PRODUCTS, WalkSpeed.SLOW); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 0, null, "Linz Auwiesen"), null, + new Location(LocationType.STATION, 0, null, "Linz Hafen"), new Date(), true, ALL_PRODUCTS, WalkSpeed.SLOW); System.out.println(result); // final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); // System.out.println(moreResult); diff --git a/test/de/schildbach/pte/live/MvvProviderLiveTest.java b/test/de/schildbach/pte/live/MvvProviderLiveTest.java index 754eb671..e1dca7e6 100644 --- a/test/de/schildbach/pte/live/MvvProviderLiveTest.java +++ b/test/de/schildbach/pte/live/MvvProviderLiveTest.java @@ -25,6 +25,7 @@ import de.schildbach.pte.MvvProvider; import de.schildbach.pte.NetworkProvider.WalkSpeed; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; +import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.QueryConnectionsResult; /** @@ -35,11 +36,19 @@ public class MvvProviderLiveTest private MvvProvider provider = new MvvProvider(); private static final String ALL_PRODUCTS = "IRSUTBFC"; + @Test + public void nearbyStation() throws Exception + { + final NearbyStationsResult result = provider.nearbyStations("350", 0, 0, 0, 0); + + System.out.println(result.stations.size() + " " + result.stations); + } + @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Marienplatz"), null, new Location( - LocationType.ANY, 0, "Pasing"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Marienplatz"), null, new Location( + LocationType.ANY, 0, null, "Pasing"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -48,8 +57,8 @@ public class MvvProviderLiveTest @Test public void longConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Starnberg, Arbeitsamt"), null, - new Location(LocationType.STATION, 0, "Ackermannstraße"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Starnberg, Arbeitsamt"), null, + new Location(LocationType.STATION, 0, null, "Ackermannstraße"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); // seems like there are no more connections all the time } @@ -57,8 +66,8 @@ public class MvvProviderLiveTest @Test public void connectionBetweenCoordinates() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48165238, 11577473, null, null), null, - new Location(LocationType.ADDRESS, 0, 47987199, 11326532, null, null), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48165238, 11577473), null, + new Location(LocationType.ADDRESS, 0, 47987199, 11326532), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -67,8 +76,8 @@ public class MvvProviderLiveTest @Test public void connectionBetweenCoordinateAndStation() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48238341, 11478230, null, null), null, - new Location(LocationType.ANY, 0, "Ostbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48238341, 11478230), null, + new Location(LocationType.ANY, 0, null, "Ostbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -77,8 +86,8 @@ public class MvvProviderLiveTest @Test public void connectionBetweenAddresses() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, "München, Maximilianstr. 1"), null, - new Location(LocationType.ADDRESS, 0, "Starnberg, Jahnstraße 50"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, null, "München, Maximilianstr. 1"), + null, new Location(LocationType.ADDRESS, 0, null, "Starnberg, Jahnstraße 50"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -87,7 +96,7 @@ public class MvvProviderLiveTest @Test public void connectionBetweenStationAndAddress() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 1220, "Josephsburg"), null, new Location( + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 1220, null, "Josephsburg"), null, new Location( LocationType.ADDRESS, 0, 48188018, 11574239, null, "München Frankfurter Ring 35"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); diff --git a/test/de/schildbach/pte/live/NaldoProviderLiveTest.java b/test/de/schildbach/pte/live/NaldoProviderLiveTest.java index 033527a1..daaa450e 100644 --- a/test/de/schildbach/pte/live/NaldoProviderLiveTest.java +++ b/test/de/schildbach/pte/live/NaldoProviderLiveTest.java @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package de.schildbach.pte.live; import org.junit.Test; @@ -42,6 +43,6 @@ public class NaldoProviderLiveTest { final QueryDeparturesResult result = provider.queryDepartures("53019174", 0); - System.out.println(result.departures.size() + " " + result.departures); + System.out.println(result.location.toDebugString() + " " + result.departures.size() + " " + result.departures); } } diff --git a/test/de/schildbach/pte/live/NsProviderLiveTest.java b/test/de/schildbach/pte/live/NsProviderLiveTest.java index 5117e2c9..425278a8 100644 --- a/test/de/schildbach/pte/live/NsProviderLiveTest.java +++ b/test/de/schildbach/pte/live/NsProviderLiveTest.java @@ -64,8 +64,8 @@ public class NsProviderLiveTest @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024, null), null, new Location( - LocationType.STATION, 100066, null), new Date(), true, null, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024), null, new Location( + LocationType.STATION, 100066), new Date(), true, null, WalkSpeed.FAST); System.out.println(result.status + " " + result.connections); } @@ -73,8 +73,8 @@ public class NsProviderLiveTest @Test public void longConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024, null), null, new Location( - LocationType.STATION, 103624, null), new Date(), true, null, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024), null, new Location( + LocationType.STATION, 103624), new Date(), true, null, WalkSpeed.FAST); System.out.println(result.status + " " + result.connections); } diff --git a/test/de/schildbach/pte/live/OebbProviderLiveTest.java b/test/de/schildbach/pte/live/OebbProviderLiveTest.java index 0a4c9e40..d2c63e02 100644 --- a/test/de/schildbach/pte/live/OebbProviderLiveTest.java +++ b/test/de/schildbach/pte/live/OebbProviderLiveTest.java @@ -47,8 +47,8 @@ public class OebbProviderLiveTest @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Linz"), null, new Location( - LocationType.ANY, 0, "Berlin"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Linz"), null, new Location( + LocationType.ANY, 0, null, "Berlin"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -57,8 +57,8 @@ public class OebbProviderLiveTest @Test public void slowConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Ramsen, Zoll"), null, new Location( - LocationType.ANY, 0, "Azuga"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Ramsen, Zoll"), null, new Location( + LocationType.ANY, 0, null, "Azuga"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -67,8 +67,8 @@ public class OebbProviderLiveTest @Test public void connectionWithFootway() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Graz, Haselweg"), null, new Location( - LocationType.ADDRESS, 0, "Innsbruck, Gumppstraße 69"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Graz, Haselweg"), null, + new Location(LocationType.ADDRESS, 0, null, "Innsbruck, Gumppstraße 69"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -77,8 +77,9 @@ public class OebbProviderLiveTest @Test public void connectionWithFootway2() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Wien, Krottenbachstraße 110!"), null, - new Location(LocationType.ADDRESS, 0, "Wien, Meidlinger Hauptstraße 1"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider + .queryConnections(new Location(LocationType.ANY, 0, null, "Wien, Krottenbachstraße 110!"), null, new Location(LocationType.ADDRESS, + 0, null, "Wien, Meidlinger Hauptstraße 1"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); diff --git a/test/de/schildbach/pte/live/SbbProviderLiveTest.java b/test/de/schildbach/pte/live/SbbProviderLiveTest.java index 9ec9ff74..1981196c 100644 --- a/test/de/schildbach/pte/live/SbbProviderLiveTest.java +++ b/test/de/schildbach/pte/live/SbbProviderLiveTest.java @@ -73,8 +73,8 @@ public class SbbProviderLiveTest @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8503000, "Zürich HB"), null, new Location( - LocationType.STATION, 8507785, "Bern, Hauptbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8503000, null, "Zürich HB"), null, + new Location(LocationType.STATION, 8507785, null, "Bern, Hauptbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -83,8 +83,8 @@ public class SbbProviderLiveTest @Test public void slowConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "Schocherswil, Alte Post!"), null, - new Location(LocationType.ANY, 0, "Laconnex, Mollach"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "Schocherswil, Alte Post!"), null, + new Location(LocationType.ANY, 0, null, "Laconnex, Mollach"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); @@ -93,8 +93,8 @@ public class SbbProviderLiveTest @Test public void connectionWithFootway() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, "Spiez, Seestraße 62"), null, - new Location(LocationType.ADDRESS, 0, "Einsiedeln, Erlenmoosweg 24"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, null, "Spiez, Seestraße 62"), null, + new Location(LocationType.ADDRESS, 0, null, "Einsiedeln, Erlenmoosweg 24"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); System.out.println(moreResult); diff --git a/test/de/schildbach/pte/live/SncbProviderLiveTest.java b/test/de/schildbach/pte/live/SncbProviderLiveTest.java index 176c184a..8ff44f2f 100644 --- a/test/de/schildbach/pte/live/SncbProviderLiveTest.java +++ b/test/de/schildbach/pte/live/SncbProviderLiveTest.java @@ -64,8 +64,8 @@ public class SncbProviderLiveTest @Test public void shortConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024, null), null, new Location( - LocationType.STATION, 100066, null), new Date(), true, null, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024), null, new Location( + LocationType.STATION, 100066), new Date(), true, null, WalkSpeed.FAST); System.out.println(result.status + " " + result.connections); } @@ -73,8 +73,8 @@ public class SncbProviderLiveTest @Test public void longConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024, null), null, new Location( - LocationType.STATION, 103624, null), new Date(), true, null, WalkSpeed.FAST); + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 100024), null, new Location( + LocationType.STATION, 103624), new Date(), true, null, WalkSpeed.FAST); System.out.println(result.status + " " + result.connections); } diff --git a/test/de/schildbach/pte/live/TflProviderLiveTest.java b/test/de/schildbach/pte/live/TflProviderLiveTest.java index d0abf80f..90a8c73b 100644 --- a/test/de/schildbach/pte/live/TflProviderLiveTest.java +++ b/test/de/schildbach/pte/live/TflProviderLiveTest.java @@ -56,7 +56,7 @@ public class TflProviderLiveTest @Test public void postcodeConnection() throws Exception { - final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, "sw19 8ta"), null, new Location( + final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ANY, 0, null, "sw19 8ta"), null, new Location( LocationType.STATION, 1016019, 51655903, -397249, null, "Watford (Herts), Watford Town Centre"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); System.out.println(result);