mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 16:20:34 +00:00
Migrate Bremen, Bremerhaven and Oldenburg to binary connections query
This commit is contained in:
parent
5b098e1268
commit
40871c35b7
2 changed files with 51 additions and 1 deletions
|
@ -18,13 +18,18 @@
|
|||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
|
@ -47,7 +52,8 @@ public class VbnProvider extends AbstractHafasProvider
|
|||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.AUTOCOMPLETE_ONE_LINE || capability == Capability.DEPARTURES)
|
||||
if (capability == Capability.NEARBY_STATIONS || capability == Capability.DEPARTURES || capability == Capability.AUTOCOMPLETE_ONE_LINE
|
||||
|| capability == Capability.TRIPS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -99,6 +105,20 @@ public class VbnProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Göttingen" };
|
||||
|
||||
@Override
|
||||
protected String[] splitPlaceAndName(final String name)
|
||||
{
|
||||
for (final String place : PLACES)
|
||||
{
|
||||
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
|
||||
return new String[] { place, name.substring(place.length() + 1) };
|
||||
}
|
||||
|
||||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
@ -143,6 +163,26 @@ public class VbnProvider extends AbstractHafasProvider
|
|||
return jsonGetStops(uri.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendCustomTripsQueryBinaryUri(final StringBuilder uri)
|
||||
{
|
||||
uri.append("&h2g-direct=11");
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final int numTrips, final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility,
|
||||
final Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsBinary(from, via, to, date, dep, numTrips, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later, final int numTrips) throws IOException
|
||||
{
|
||||
return queryMoreTripsBinary(contextObj, later, numTrips);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char normalizeType(final String type)
|
||||
{
|
||||
|
|
|
@ -76,6 +76,16 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest
|
|||
print(autocompletes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autocompleteUmlaut() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Göttingen Hauptbahnhof");
|
||||
|
||||
print(autocompletes);
|
||||
|
||||
assertEquals("Göttingen", autocompletes.get(0).place);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortTrip() throws Exception
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue