AbstractEfaProvider: Support for address location IDs.

This commit is contained in:
Andreas Schildbach 2018-12-31 19:20:05 +01:00
parent c2d77e8c8e
commit 586c071946
7 changed files with 303 additions and 155 deletions

View file

@ -2963,6 +2963,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} else if (location.type == LocationType.POI && location.hasId()) { } else if (location.type == LocationType.POI && location.hasId()) {
url.addEncodedQueryParameter("type_" + paramSuffix, "poi"); url.addEncodedQueryParameter("type_" + paramSuffix, "poi");
url.addEncodedQueryParameter("name_" + paramSuffix, ParserUtils.urlEncode(location.id, requestUrlEncoding)); 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) } else if ((location.type == LocationType.ADDRESS || location.type == LocationType.COORD)
&& location.hasCoord()) { && location.hasCoord()) {
url.addEncodedQueryParameter("type_" + paramSuffix, "coord"); url.addEncodedQueryParameter("type_" + paramSuffix, "coord");

View file

@ -98,65 +98,74 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
} }
@Test @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"); final SuggestLocationsResult result = suggestLocations("Ruhpolding, Seehaus");
print(result); print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.POI, 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 @Test
public void suggestLocationsAddress() throws Exception { public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("München, Friedenstraße 2"); final SuggestLocationsResult result = suggestLocations("München, Friedenstraße 2");
print(result); 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 @Test
public void suggestLocationsLocal() throws Exception { public void suggestStreet() throws Exception {
final SuggestLocationsResult regensburgResult = suggestLocations("Regensburg"); final SuggestLocationsResult result = suggestLocations("München, Friedenstraße");
assertEquals("80001083", regensburgResult.getLocations().iterator().next().id); print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
final SuggestLocationsResult munichResult = suggestLocations("München"); "streetID:1500002757::9162000:-1:Friedenstraße:München:Friedenstraße::Friedenstraße: 81671:ANY:DIVA_STREET:1292298:5871791:MRCV:BAY")));
assertEquals("80000689", munichResult.getLocations().iterator().next().id);
final SuggestLocationsResult nurembergResult = suggestLocations("Nürnberg");
assertEquals("80001020", nurembergResult.getLocations().iterator().next().id);
} }
@Test @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof");
new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"), null, final Location to = new Location(LocationType.STATION, "80000799", "München", "Pasing");
new Location(LocationType.STATION, "80000799", "München", "Pasing"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
} }
@Test @Test
public void longTrip() throws Exception { public void longTrip() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "1005530", "Starnberg", "Arbeitsamt");
new Location(LocationType.STATION, "1005530", "Starnberg", "Arbeitsamt"), null, final Location to = new Location(LocationType.STATION, "3001459", "Nürnberg", "Fallrohrstraße");
new Location(LocationType.STATION, "3001459", "Nürnberg", "Fallrohrstraße"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
// seems like there are no more trips all the time
} }
@Test @Test
public void tripBetweenCoordinates() throws Exception { public void tripBetweenCoordinates() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(48165238, 11577473), null, final Location from = Location.coord(48165238, 11577473);
Location.coord(47987199, 11326532), new Date(), true, null); final Location to = Location.coord(47987199, 11326532);
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
} }
@Test @Test
@ -165,26 +174,14 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
final Location to = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof"); final Location to = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
} }
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1");
new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1"), null, final Location to = new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50");
new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
} }
@Test @Test
@ -194,12 +191,6 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
"München Frankfurter Ring 35"); "München Frankfurter Ring 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
} }
@Test @Test
@ -212,17 +203,13 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest {
"Ruhpolding", "Alpengasthof Laubau"); "Ruhpolding", "Alpengasthof Laubau");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
} }
@Test @Test
public void tripRegensburg() throws Exception { public void tripRegensburg() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "4014051", "Regensburg", "Klenzestraße");
new Location(LocationType.STATION, "4014051", "Regensburg", "Klenzestraße"), null, final Location to = new Location(LocationType.STATION, "4014080", "Regensburg", "Universität");
new Location(LocationType.STATION, "4014080", "Regensburg", "Universität"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
} }
} }

View file

@ -86,6 +86,22 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest {
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "7000044"))); 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 @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "7000001", Point.from1E6(49009526, 8404914), final Location from = new Location(LocationType.STATION, "7000001", Point.from1E6(49009526, 8404914),
@ -96,39 +112,35 @@ public class KvvProviderLiveTest extends AbstractProviderLiveTest {
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0); assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result); print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult); print(earlierResult);
} }
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48985089, 8402709), null, final Location from = new Location(LocationType.ADDRESS,
"Konstanzer Straße 17, 76199 Karlsruhe, Deutschland"); "streetID:1500000173:2:8212000:15:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz:76137:ANY:DIVA_SINGLEHOUSE:935315:5725973:MRCV:b_w",
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(49007706, 8356358), null, null, "Bahnhofsplatz 2");
"Durmersheimer Straße 6, 76185 Karlsruhe, Deutschland"); 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); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
}
if (!result.context.canQueryLater()) @Test
return; public void tripBetweenStreets() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); "streetID:1500000173::8212000:-1:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz: 76137:ANY:DIVA_STREET:935120:5726009:MRCV:b_w",
print(laterResult); 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);
} }
} }

View file

@ -130,6 +130,22 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest {
assertEquals("München", result.getLocations().get(0).place); 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 @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "2", "München", "Marienplatz"); final Location from = new Location(LocationType.STATION, "2", "München", "Marienplatz");
@ -173,8 +189,26 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest {
@Test @Test
public void tripBetweenAddresses() throws Exception { public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1"); final Location from = new Location(LocationType.ADDRESS,
final Location to = new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50"); "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); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);

View file

@ -142,6 +142,22 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest {
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "8706554"))); 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 @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "17002402", null, "Bahnhof"); final Location from = new Location(LocationType.STATION, "17002402", null, "Bahnhof");
@ -211,4 +227,28 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest {
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); 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);
}
} }

View file

@ -73,20 +73,40 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest {
} }
@Test @Test
public void suggestLocationsWithUmlaut() throws Exception { public void suggestLocationsWithUmlautDuerrenhof() throws Exception {
final SuggestLocationsResult result1 = suggestLocations("Dürrenhof"); final SuggestLocationsResult result = suggestLocations("Dürrenhof");
print(result1); print(result);
assertThat(result1.getLocations(), hasItem(new Location(LocationType.STATION, "3000427"))); assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "3000427")));
}
final SuggestLocationsResult result2 = suggestLocations("Röthenbach"); @Test
print(result2); public void suggestLocationsWithUmlautRoethenbach() throws Exception {
assertThat(result2.getLocations(), hasItem(new Location(LocationType.STATION, "3001970"))); 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 @Test
public void shortTrip() throws Exception { public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "451", "Nürnberg", "Ostring"), final Location from = new Location(LocationType.STATION, "451", "Nürnberg", "Ostring");
null, new Location(LocationType.STATION, "510", "Nürnberg", "Hauptbahnhof"), new Date(), true, null); final Location to = new Location(LocationType.STATION, "510", "Nürnberg", "Hauptbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
@ -106,14 +126,26 @@ public class VgnProviderLiveTest extends AbstractProviderLiveTest {
} }
@Test @Test
public void tripToAddress() throws Exception { public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.STATION, "1756", "Nürnberg", "Saarbrückener Str."); final Location from = new Location(LocationType.ADDRESS,
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(49437392, 11094524), "Nürnberg", "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",
"Wodanstraße 25"); 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); final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null);
print(result); print(result);
}
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); @Test
print(laterResult); 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);
} }
} }

View file

@ -30,6 +30,7 @@ import de.schildbach.pte.VrrProvider;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.SuggestLocationsResult;
@ -49,12 +50,19 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest {
} }
@Test @Test
public void nearbyStationsByCoordinate() throws Exception { public void nearbyStationsByCoordinateDuesseldorf() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51218693, 6777785)); final NearbyLocationsResult result = queryNearbyStations(
Location.coord(Point.fromDouble(51.2190163, 6.7757496)));
print(result); print(result);
assertThat(result.locations, hasItem(new Location(LocationType.STATION, "20018243"))); // Graf-Adolf-Platz
}
final NearbyLocationsResult result2 = queryNearbyStations(Location.coord(51719648, 8754330)); @Test
print(result2); 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 @Test
@ -86,9 +94,6 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest {
public void suggestLocationsIncomplete() throws Exception { public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur"); final SuggestLocationsResult result = suggestLocations("Kur");
print(result); print(result);
final SuggestLocationsResult paderbornResult = suggestLocations("Paderborn Hbf");
print(paderbornResult);
} }
@Test @Test
@ -105,26 +110,45 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest {
} }
@Test @Test
public void suggestLocationsCoverage() throws Exception { public void suggestLocationsCologne() throws Exception {
final SuggestLocationsResult cologneResult = suggestLocations("Köln Ebertplatz"); final SuggestLocationsResult result = suggestLocations("Köln Ebertplatz");
print(cologneResult); print(result);
assertThat(cologneResult.getLocations(), hasItem(new Location(LocationType.STATION, "22000035"))); assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "22000035")));
}
final SuggestLocationsResult dortmundResult = suggestLocations("Dortmund Zugstraße"); @Test
print(dortmundResult); public void suggestLocationsDortmund() throws Exception {
assertThat(dortmundResult.getLocations(), hasItem(new Location(LocationType.STATION, "20000524"))); 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"); @Test
print(duesseldorfResult); public void suggestLocationsDuesseldorf() throws Exception {
assertThat(duesseldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "20018017"))); 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"); @Test
print(muensterResult); public void suggestLocationsMuenster() throws Exception {
assertThat(muensterResult.getLocations(), hasItem(new Location(LocationType.STATION, "24047291"))); final SuggestLocationsResult result = suggestLocations("Münster Vennheideweg");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "24047291")));
}
final SuggestLocationsResult aachenResult = suggestLocations("Aachen Elisenbrunnen"); @Test
print(aachenResult); public void suggestLocationsAachen() throws Exception {
assertThat(aachenResult.getLocations(), hasItem(new Location(LocationType.STATION, "21001029"))); 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 @Test
@ -133,76 +157,92 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest {
print(result); 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 @Test
public void anyTrip() throws Exception { public void anyTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Köln"), null, final Location from = new Location(LocationType.ANY, null, null, "Köln");
new Location(LocationType.ANY, null, null, "Bonn"), new Date(), true, null); final Location to = new Location(LocationType.ANY, null, null, "Bonn");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status); assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
} }
@Test @Test
public void shortTrip() throws Exception { public void shortTripEssen() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "20009289", "Essen", "Hauptbahnhof");
new Location(LocationType.STATION, "20009289", "Essen", "Hauptbahnhof"), null, final Location to = new Location(LocationType.STATION, "20009161", "Essen", "Bismarckplatz");
new Location(LocationType.STATION, "20009161", "Essen", "Bismarckplatz"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0); assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result); print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult); print(earlierResult);
} }
@Test @Test
public void shortTripPaderborn() throws Exception { public void shortTripPaderborn() throws Exception {
final QueryTripsResult result = queryTrips( final Location from = new Location(LocationType.STATION, "23207000"); // Paderborn Hbf
new Location(LocationType.STATION, "23007000", "Paderborn", "Paderborn Hbf"), null, final Location to = new Location(LocationType.STATION, "23207700"); // Höxter, Bahnhof / Rathaus
new Location(LocationType.STATION, "23007700", "Höxter", "Bahnhof / Rathaus"), new Date(), true, null); final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0); assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true); final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult); print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result); print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult); print(earlierResult);
} }
@Test @Test
public void shortTripDorsten() throws Exception { public void shortTripDorsten() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "20009643", "Bottrop", "West S"), final Location from = new Location(LocationType.STATION, "20009643", "Bottrop", "West S");
null, new Location(LocationType.STATION, "20003214", "Dorsten", "ZOB Dorsten"), new Date(), true, null); final Location to = new Location(LocationType.STATION, "20003214", "Dorsten", "ZOB Dorsten");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result); print(result);
assertEquals(QueryTripsResult.Status.OK, result.status); assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0); assertTrue(result.trips.size() > 0);
} }
@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);
}
} }