diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 02133a1c..fad195d4 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -2963,6 +2963,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { } else if (location.type == LocationType.POI && location.hasId()) { url.addEncodedQueryParameter("type_" + paramSuffix, "poi"); url.addEncodedQueryParameter("name_" + paramSuffix, ParserUtils.urlEncode(location.id, requestUrlEncoding)); + } else if (location.type == LocationType.ADDRESS && location.hasId()) { + url.addEncodedQueryParameter("type_" + paramSuffix, "address"); + url.addEncodedQueryParameter("name_" + paramSuffix, ParserUtils.urlEncode(location.id, requestUrlEncoding)); } else if ((location.type == LocationType.ADDRESS || location.type == LocationType.COORD) && location.hasCoord()) { url.addEncodedQueryParameter("type_" + paramSuffix, "coord"); diff --git a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java index eb882ce9..2447527a 100644 --- a/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BayernProviderLiveTest.java @@ -98,65 +98,74 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { } @Test - public void suggestLocationsPOI() throws Exception { + public void suggestLocationsRegensburg() throws Exception { + final SuggestLocationsResult result = suggestLocations("Regensburg"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "80001083"))); + } + + @Test + public void suggestLocationsMunich() throws Exception { + final SuggestLocationsResult result = suggestLocations("München"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "91000100"))); + } + + @Test + public void suggestLocationsNuernberg() throws Exception { + final SuggestLocationsResult result = suggestLocations("Nürnberg"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "80001020"))); + } + + @Test + public void suggestPOI() throws Exception { final SuggestLocationsResult result = suggestLocations("Ruhpolding, Seehaus"); print(result); assertThat(result.getLocations(), hasItem(new Location(LocationType.POI, - "poiID:40499046:9189140:-1:Seehaus:Ruhpolding:Seehaus:ANY:POI:1405062:5941100:MRCV:BAY"))); + "poiID:40502661:9189140:-1:Seehaus:Ruhpolding:Seehaus:ANY:POI:1405062:5941100:MRCV:BAY"))); } @Test - public void suggestLocationsAddress() throws Exception { + public void suggestAddress() throws Exception { final SuggestLocationsResult result = suggestLocations("München, Friedenstraße 2"); print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500002757:2:9162000:-1:Friedenstraße:München:Friedenstraße::Friedenstraße:81671:ANY:DIVA_SINGLEHOUSE:1291659:5872432:MRCV:BAY"))); } @Test - public void suggestLocationsLocal() throws Exception { - final SuggestLocationsResult regensburgResult = suggestLocations("Regensburg"); - assertEquals("80001083", regensburgResult.getLocations().iterator().next().id); - - final SuggestLocationsResult munichResult = suggestLocations("München"); - assertEquals("80000689", munichResult.getLocations().iterator().next().id); - - final SuggestLocationsResult nurembergResult = suggestLocations("Nürnberg"); - assertEquals("80001020", nurembergResult.getLocations().iterator().next().id); + public void suggestStreet() throws Exception { + final SuggestLocationsResult result = suggestLocations("München, Friedenstraße"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500002757::9162000:-1:Friedenstraße:München:Friedenstraße::Friedenstraße: 81671:ANY:DIVA_STREET:1292298:5871791:MRCV:BAY"))); } @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"), null, - new Location(LocationType.STATION, "80000799", "München", "Pasing"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"); + final Location to = new Location(LocationType.STATION, "80000799", "München", "Pasing"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - - if (!result.context.canQueryLater()) - return; - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); } @Test public void longTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "1005530", "Starnberg", "Arbeitsamt"), null, - new Location(LocationType.STATION, "3001459", "Nürnberg", "Fallrohrstraße"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "1005530", "Starnberg", "Arbeitsamt"); + final Location to = new Location(LocationType.STATION, "3001459", "Nürnberg", "Fallrohrstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - // seems like there are no more trips all the time } @Test public void tripBetweenCoordinates() throws Exception { - final QueryTripsResult result = queryTrips(Location.coord(48165238, 11577473), null, - Location.coord(47987199, 11326532), new Date(), true, null); + final Location from = Location.coord(48165238, 11577473); + final Location to = Location.coord(47987199, 11326532); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - - if (!result.context.canQueryLater()) - return; - - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); } @Test @@ -165,26 +174,14 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { 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()) - return; - - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); } @Test public void tripBetweenAddresses() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1"), null, - new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50"), new Date(), true, null); + final Location from = new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1"); + final Location to = new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - - if (!result.context.canQueryLater()) - return; - - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); } @Test @@ -194,12 +191,6 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { "München Frankfurter Ring 35"); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - - if (!result.context.canQueryLater()) - return; - - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); } @Test @@ -212,17 +203,13 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest { "Ruhpolding", "Alpengasthof Laubau"); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); } @Test public void tripRegensburg() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "4014051", "Regensburg", "Klenzestraße"), null, - new Location(LocationType.STATION, "4014080", "Regensburg", "Universität"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "4014051", "Regensburg", "Klenzestraße"); + final Location to = new Location(LocationType.STATION, "4014080", "Regensburg", "Universität"); + 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 17caf551..2d1cc8cc 100644 --- a/enabler/test/de/schildbach/pte/live/KvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/KvvProviderLiveTest.java @@ -86,6 +86,22 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest { assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "7000044"))); } + @Test + public void suggestAddress() throws Exception { + final SuggestLocationsResult result = suggestLocations("Karlsruhe, Bahnhofsplatz 2"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500000173:2:8212000:15:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz:76137:ANY:DIVA_SINGLEHOUSE:935315:5725973:MRCV:b_w"))); + } + + @Test + public void suggestStreet() throws Exception { + final SuggestLocationsResult result = suggestLocations("Karlsruhe, Bahnhofsplatz"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500000173::8212000:-1:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz: 76137:ANY:DIVA_STREET:935120:5726009:MRCV:b_w"))); + } + @Test public void shortTrip() throws Exception { final Location from = new Location(LocationType.STATION, "7000001", Point.from1E6(49009526, 8404914), @@ -96,39 +112,35 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest { print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); - - if (!result.context.canQueryLater()) - return; - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); - - if (!laterResult.context.canQueryLater()) - return; - final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); print(later2Result); - - if (!later2Result.context.canQueryEarlier()) - return; - final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); print(earlierResult); } @Test public void tripBetweenAddresses() throws Exception { - 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 Location from = new Location(LocationType.ADDRESS, + "streetID:1500000173:2:8212000:15:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz:76137:ANY:DIVA_SINGLEHOUSE:935315:5725973:MRCV:b_w", + null, "Bahnhofsplatz 2"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:1500001060:15:8212000:-1:Lorenzstraße:Karlsruhe:Lorenzstraße::Lorenzstraße:76135:ANY:DIVA_SINGLEHOUSE:933225:5724788:MRCV:b_w", + null, "Lorenzstraße 15"); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); + } - if (!result.context.canQueryLater()) - return; - - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); + @Test + public void tripBetweenStreets() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:1500000173::8212000:-1:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz: 76137:ANY:DIVA_STREET:935120:5726009:MRCV:b_w", + null, "Bahnhofsplatz"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:1500001060::8212000:-1:Lorenzstraße:Karlsruhe:Lorenzstraße::Lorenzstraße: 76135:ANY:DIVA_STREET:933225:5724788:MRCV:b_w", + null, "Lorenzstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); + print(result); } } diff --git a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java index 57bec338..ce53c10f 100644 --- a/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/MvvProviderLiveTest.java @@ -130,6 +130,22 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest { assertEquals("München", result.getLocations().get(0).place); } + @Test + public void suggestAddress() throws Exception { + final SuggestLocationsResult result = suggestLocations("München, Maximilianstr. 1"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:3239:1:9162000:9162000:Maximilianstraße:München:Maximilianstraße::Maximilianstraße:80539:ANY:DIVA_ADDRESS:4468763:826437:MVTT:MVV"))); + } + + @Test + public void suggestStreet() throws Exception { + final SuggestLocationsResult result = suggestLocations("München, Maximilianstr."); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:3239::9162000:-1:Maximilianstraße:München:Maximilianstraße::Maximilianstraße: 80539 80538:ANY:DIVA_STREET:4469138:826553:MVTT:MVV"))); + } + @Test public void shortTrip() throws Exception { final Location from = new Location(LocationType.STATION, "2", "München", "Marienplatz"); @@ -173,8 +189,26 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest { @Test public void tripBetweenAddresses() throws Exception { - final Location from = new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1"); - final Location to = new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50"); + final Location from = new Location(LocationType.ADDRESS, + "streetID:3239:1:9162000:9162000:Maximilianstraße:München:Maximilianstraße::Maximilianstraße:80539:ANY:DIVA_ADDRESS:4468763:826437:MVTT:MVV", + null, "Maximilianstraße 1"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:753:4:9162000:1:Burggrafenstraße:München:Burggrafenstraße::Burggrafenstraße:81671:ANY:DIVA_SINGLEHOUSE:4471134:827570:MVTT:MVV", + null, "Burggrafenstraße 4"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); + print(result); + final QueryTripsResult laterResult = queryMoreTrips(result.context, true); + print(laterResult); + } + + @Test + public void tripBetweenStreets() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:3239::9162000:-1:Maximilianstraße:München:Maximilianstraße::Maximilianstraße: 80539 80538:ANY:DIVA_STREET:4469138:826553:MVTT:MVV", + null, "Maximilianstraße"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:753::9162000:1:Burggrafenstraße:München:Burggrafenstraße::Burggrafenstraße: 81671:ANY:DIVA_STREET:4471150:827576:MVTT:MVV", + null, "Burggrafenstraße"); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); diff --git a/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java index 24f68f7f..554a17aa 100644 --- a/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/NvbwProviderLiveTest.java @@ -142,6 +142,22 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest { assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "8706554"))); } + @Test + public void suggestAddress() throws Exception { + final SuggestLocationsResult result = suggestLocations("Stuttgart, Kronenstraße 3"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500000599:3:8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße:70173:ANY:DIVA_SINGLEHOUSE:1021956:5762095:MRCV:B_W"))); + } + + @Test + public void suggestStreet() throws Exception { + final SuggestLocationsResult result = suggestLocations("Stuttgart, Kronenstraße"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500000599::8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße: 70174 70173:ANY:DIVA_STREET:1021539:5761790:MRCV:B_W"))); + } + @Test public void shortTrip() throws Exception { final Location from = new Location(LocationType.STATION, "17002402", null, "Bahnhof"); @@ -211,4 +227,28 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest { print(result); assertEquals(QueryTripsResult.Status.OK, result.status); } + + @Test + public void tripBetweenAddresses() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:1500000484:11:8111000:-1:Wilhelmsplatz (Stgt):Stuttgart:Wilhelmsplatz (Stgt)::Wilhelmsplatz (Stgt):70182:ANY:DIVA_SINGLEHOUSE:1021706:5763896:MRCV:B_W", + null, "Wilhelmsplatz 11"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:1500000599:3:8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße:70173:ANY:DIVA_SINGLEHOUSE:1021956:5762095:MRCV:B_W", + null, "Kronenstraße 3"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null); + print(result); + } + + @Test + public void tripBetweenStreets() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:1500000484::8111000:51:Wilhelmsplatz (Stgt):Stuttgart:Wilhelmsplatz (Stgt)::Wilhelmsplatz (Stgt): 70182:ANY:DIVA_STREET:1021828:5763870:MRCV:B_W", + null, "Wilhelmsplatz"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:1500000599::8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße: 70174 70173:ANY:DIVA_STREET:1021539:5761790:MRCV:B_W", + null, "Kronenstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null); + print(result); + } } diff --git a/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java index 2aca49e4..7fea9396 100644 --- a/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VgnProviderLiveTest.java @@ -73,20 +73,40 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest { } @Test - public void suggestLocationsWithUmlaut() throws Exception { - final SuggestLocationsResult result1 = suggestLocations("Dürrenhof"); - print(result1); - assertThat(result1.getLocations(), hasItem(new Location(LocationType.STATION, "3000427"))); + public void suggestLocationsWithUmlautDuerrenhof() throws Exception { + final SuggestLocationsResult result = suggestLocations("Dürrenhof"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "3000427"))); + } - final SuggestLocationsResult result2 = suggestLocations("Röthenbach"); - print(result2); - assertThat(result2.getLocations(), hasItem(new Location(LocationType.STATION, "3001970"))); + @Test + public void suggestLocationsWithUmlautRoethenbach() throws Exception { + final SuggestLocationsResult result = suggestLocations("Röthenbach"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "3001970"))); + } + + @Test + public void suggestAddress() throws Exception { + final SuggestLocationsResult result = suggestLocations("Nürnberg, Wodanstraße 25"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:2519:25:9564000:1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße:90461:ANY:DIVA_SINGLEHOUSE:4434433:681777:NAV4:VGN"))); + } + + @Test + public void suggestStreet() throws Exception { + final SuggestLocationsResult result = suggestLocations("Nürnberg, Wodanstraße"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:2519::9564000:-1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße: 90461:ANY:DIVA_STREET:4434565:681747:NAV4:VGN"))); } @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "451", "Nürnberg", "Ostring"), - null, new Location(LocationType.STATION, "510", "Nürnberg", "Hauptbahnhof"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "451", "Nürnberg", "Ostring"); + final Location to = new Location(LocationType.STATION, "510", "Nürnberg", "Hauptbahnhof"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -106,14 +126,26 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest { } @Test - public void tripToAddress() throws Exception { - 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"); + public void tripBetweenAddresses() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:832:2:9564000:1:Saarbrückener Straße:Nürnberg:Saarbrückener Straße::Saarbrückener Straße:90469:ANY:DIVA_SINGLEHOUSE:4433846:685282:NAV4:VGN", + null, "Saarbrückener Straße 2"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:2519:25:9564000:1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße:90461:ANY:DIVA_SINGLEHOUSE:4434433:681777:NAV4:VGN", + null, "Wodanstraße 25"); final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null); print(result); + } - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); + @Test + public void tripBetweenStreets() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:832::9564000:-1:Saarbrückener Straße:Nürnberg:Saarbrückener Straße::Saarbrückener Straße: 90469:ANY:DIVA_STREET:4433819:685855:NAV4:VGN", + null, "Saarbrückener Straße"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:2519::9564000:-1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße: 90461:ANY:DIVA_STREET:4434565:681747:NAV4:VGN", + null, "Wodanstraße"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null); + print(result); } } diff --git a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java index afd1c5ff..a15229ca 100644 --- a/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/VrrProviderLiveTest.java @@ -30,6 +30,7 @@ import de.schildbach.pte.VrrProvider; 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; @@ -49,12 +50,19 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest { } @Test - public void nearbyStationsByCoordinate() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(Location.coord(51218693, 6777785)); + public void nearbyStationsByCoordinateDuesseldorf() throws Exception { + final NearbyLocationsResult result = queryNearbyStations( + Location.coord(Point.fromDouble(51.2190163, 6.7757496))); print(result); + assertThat(result.locations, hasItem(new Location(LocationType.STATION, "20018243"))); // Graf-Adolf-Platz + } - final NearbyLocationsResult result2 = queryNearbyStations(Location.coord(51719648, 8754330)); - print(result2); + @Test + public void nearbyStationsByCoordinatePaderborn() throws Exception { + final NearbyLocationsResult result = queryNearbyStations( + Location.coord(Point.fromDouble(51.7169873, 8.7537501))); + print(result); + assertThat(result.locations, hasItem(new Location(LocationType.STATION, "23207100"))); // Rathausplatz } @Test @@ -86,9 +94,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest { public void suggestLocationsIncomplete() throws Exception { final SuggestLocationsResult result = suggestLocations("Kur"); print(result); - - final SuggestLocationsResult paderbornResult = suggestLocations("Paderborn Hbf"); - print(paderbornResult); } @Test @@ -105,26 +110,45 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest { } @Test - public void suggestLocationsCoverage() throws Exception { - final SuggestLocationsResult cologneResult = suggestLocations("Köln Ebertplatz"); - print(cologneResult); - assertThat(cologneResult.getLocations(), hasItem(new Location(LocationType.STATION, "22000035"))); + public void suggestLocationsCologne() throws Exception { + final SuggestLocationsResult result = suggestLocations("Köln Ebertplatz"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "22000035"))); + } - final SuggestLocationsResult dortmundResult = suggestLocations("Dortmund Zugstraße"); - print(dortmundResult); - assertThat(dortmundResult.getLocations(), hasItem(new Location(LocationType.STATION, "20000524"))); + @Test + public void suggestLocationsDortmund() throws Exception { + final SuggestLocationsResult result = suggestLocations("Dortmund Zugstraße"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "20000524"))); + } - final SuggestLocationsResult duesseldorfResult = suggestLocations("Düsseldorf Sternstraße"); - print(duesseldorfResult); - assertThat(duesseldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "20018017"))); + @Test + public void suggestLocationsDuesseldorf() throws Exception { + final SuggestLocationsResult result = suggestLocations("Düsseldorf Sternstraße"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "20018017"))); + } - final SuggestLocationsResult muensterResult = suggestLocations("Münster Vennheideweg"); - print(muensterResult); - assertThat(muensterResult.getLocations(), hasItem(new Location(LocationType.STATION, "24047291"))); + @Test + public void suggestLocationsMuenster() throws Exception { + final SuggestLocationsResult result = suggestLocations("Münster Vennheideweg"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "24047291"))); + } - final SuggestLocationsResult aachenResult = suggestLocations("Aachen Elisenbrunnen"); - print(aachenResult); - assertThat(aachenResult.getLocations(), hasItem(new Location(LocationType.STATION, "21001029"))); + @Test + public void suggestLocationsAachen() throws Exception { + final SuggestLocationsResult result = suggestLocations("Aachen Elisenbrunnen"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "21001029"))); + } + + @Test + public void suggestLocationsPaderborn() throws Exception { + final SuggestLocationsResult result = suggestLocations("Paderborn Hbf"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "23207000"))); } @Test @@ -133,76 +157,92 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest { print(result); } + @Test + public void suggestAddress() throws Exception { + final SuggestLocationsResult result = suggestLocations("Hagen, Siegstraße 30"); + print(result); + assertThat(result.getLocations(), + hasItem(new Location(LocationType.ADDRESS, "streetID:1500000683:30:5914000:-1"))); + } + + @Test + public void suggestStreet() throws Exception { + final SuggestLocationsResult result = suggestLocations("Hagen, Siegstraße"); + print(result); + assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS, + "streetID:1500000683::5914000:-1:Siegstraße:Hagen:Siegstraße::Siegstraße: 58097:ANY:DIVA_STREET:831366:5312904:MRCV:nrw"))); + } + @Test public void anyTrip() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Köln"), null, - new Location(LocationType.ANY, null, null, "Bonn"), new Date(), true, null); + final Location from = new Location(LocationType.ANY, null, null, "Köln"); + final Location to = new Location(LocationType.ANY, null, null, "Bonn"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status); } @Test - public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "20009289", "Essen", "Hauptbahnhof"), null, - new Location(LocationType.STATION, "20009161", "Essen", "Bismarckplatz"), new Date(), true, null); + public void shortTripEssen() throws Exception { + final Location from = new Location(LocationType.STATION, "20009289", "Essen", "Hauptbahnhof"); + final Location to = new Location(LocationType.STATION, "20009161", "Essen", "Bismarckplatz"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); - - if (!result.context.canQueryLater()) - return; - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); - - if (!laterResult.context.canQueryLater()) - return; - final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); print(later2Result); - - if (!later2Result.context.canQueryEarlier()) - return; - final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); print(earlierResult); } @Test public void shortTripPaderborn() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "23007000", "Paderborn", "Paderborn Hbf"), null, - new Location(LocationType.STATION, "23007700", "Höxter", "Bahnhof / Rathaus"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "23207000"); // Paderborn Hbf + final Location to = new Location(LocationType.STATION, "23207700"); // Höxter, Bahnhof / Rathaus + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); - - if (!result.context.canQueryLater()) - return; - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); - - if (!laterResult.context.canQueryLater()) - return; - final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); print(later2Result); - - if (!later2Result.context.canQueryEarlier()) - return; - final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); print(earlierResult); } @Test public void shortTripDorsten() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "20009643", "Bottrop", "West S"), - null, new Location(LocationType.STATION, "20003214", "Dorsten", "ZOB Dorsten"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "20009643", "Bottrop", "West S"); + final Location to = new Location(LocationType.STATION, "20003214", "Dorsten", "ZOB Dorsten"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); assertEquals(QueryTripsResult.Status.OK, result.status); assertTrue(result.trips.size() > 0); } + + @Test + public void tripBetweenAddresses() throws Exception { + final Location from = new Location(LocationType.ADDRESS, "streetID:1500000683:30:5914000:-1", null, + "Siegstraße 30"); + final Location to = new Location(LocationType.ADDRESS, "streetID:1500000146:1:5914000:-1", null, + "Berliner Platz 1"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); + print(result); + } + + @Test + public void tripBetweenStreets() throws Exception { + final Location from = new Location(LocationType.ADDRESS, + "streetID:1500000683::5914000:-1:Siegstraße:Hagen:Siegstraße::Siegstraße: 58097:ANY:DIVA_STREET:831366:5312904:MRCV:nrw", + null, "Siegstraße"); + final Location to = new Location(LocationType.ADDRESS, + "streetID:1500000146::5914000:29:Berliner Platz:Hagen:Berliner Platz::Berliner Platz: 58089:ANY:DIVA_STREET:830589:5314386:MRCV:nrw", + null, "Berliner Platz"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); + print(result); + } }