DSB: Normalize a bus name. Also fix a test in DsbProviderLiveTest.

This commit is contained in:
Tomas Groth 2017-10-21 22:24:45 +02:00 committed by Andreas Schildbach
parent 1c7a208817
commit 3b38a48bff
2 changed files with 16 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 the original author or authors.
* Copyright 2010-2017 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,7 @@ package de.schildbach.pte;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import de.schildbach.pte.dto.Product;
@ -99,4 +100,17 @@ public class DsbProvider extends AbstractHafasLegacyProvider {
return super.normalizeType(type);
}
// Busses line name is formatted as "42#Bus 42" but we just want "42"
private static final Pattern P_NORMALIZE_LINE_NAME_BUS_DSB = Pattern.compile(".*?#Bus (.*)",
Pattern.CASE_INSENSITIVE);
@Override
protected String normalizeLineName(final String lineName) {
final Matcher mBus = P_NORMALIZE_LINE_NAME_BUS_DSB.matcher(lineName);
if (mBus.matches())
return mBus.group(1);
return super.normalizeLineName(lineName);
}
}

View file

@ -76,7 +76,7 @@ public class DsbProviderLiveTest extends AbstractProviderLiveTest {
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "900000011", null, "Copenhagen Airport"), null,
new Location(LocationType.STATION, "551922500", null, "Billund Airport"), new Date(), true, Product.ALL,
new Location(LocationType.POI, "551922500", null, "Billund Airport"), new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);