mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 06:08:52 +00:00
AVV_AACHEN: handle inconsistent place "AC" and order for some stations in Aachen
This commit is contained in:
parent
5f0f872b67
commit
fffd2c9acb
2 changed files with 32 additions and 1 deletions
|
@ -46,11 +46,26 @@ public class AvvAachenProvider extends AbstractHafasClientInterfaceProvider {
|
|||
setApiAuthorization(apiAuthorization);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "AC", "Aachen" };
|
||||
|
||||
@Override
|
||||
protected String[] splitStationName(final String name) {
|
||||
// Some stations in Aachen city have 3 names: "Aachen, station name", "station name, AC" and "AC, station name".
|
||||
// Some (other) stations has 2 variants: "Aachen, station name" and "station name, Aachen"
|
||||
// If you type the station name first, you get the variant "station name, AC" resp. "station name, Aachen",
|
||||
// which would be parsed as a station AC resp. Aachen in "station name".
|
||||
for (final String place: PLACES) {
|
||||
if (name.endsWith(", " + place)) {
|
||||
return new String[] { "Aachen" , name.substring(0, name.length() - place.length() - 2) };
|
||||
}
|
||||
}
|
||||
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name);
|
||||
if (m.matches())
|
||||
if (m.matches()) {
|
||||
// also remove the abbreviating variant, just for consistency
|
||||
if (m.group(1).equals("AC"))
|
||||
return new String[] { "Aachen", m.group(2) };
|
||||
return new String[] { m.group(1), m.group(2) };
|
||||
}
|
||||
return super.splitStationName(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,10 @@ package de.schildbach.pte.live;
|
|||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -74,6 +76,20 @@ public class AvvAachenProviderLiveTest extends AbstractProviderLiveTest {
|
|||
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1576", "Aachen", "Gaßmühle")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationBadSuffix() throws Exception {
|
||||
final SuggestLocationsResult result = suggestLocations("Turmstraße");
|
||||
print(result);
|
||||
assertTrue(Objects.requireNonNull(result.getLocations().get(0).name).contains("Turmstr"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationSpecialPlaceStationOrder() throws Exception {
|
||||
final SuggestLocationsResult result = suggestLocations("Jupp-Müller");
|
||||
print(result);
|
||||
assertTrue(Objects.requireNonNull(result.getLocations().get(0).name).contains("Jupp-Müller"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationsPOI() throws Exception {
|
||||
final SuggestLocationsResult result = suggestLocations("Suermondt-Ludwig-Museum");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue