mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 08:19:51 +00:00
overhauled Luxembourg
This commit is contained in:
parent
b61ebf3a7d
commit
15050b91ba
2 changed files with 42 additions and 12 deletions
|
@ -19,6 +19,7 @@ package de.schildbach.pte;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
|
@ -35,7 +36,7 @@ public class LuProvider extends AbstractHafasProvider
|
|||
|
||||
public LuProvider()
|
||||
{
|
||||
super(API_BASE + "query.exe/dn", 10, null);
|
||||
super(API_BASE + "query.exe/fn", 10, null, UTF_8, UTF_8);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
@ -98,12 +99,41 @@ public class LuProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Luxembourg", "Luxembourg/Centre" };
|
||||
|
||||
@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) };
|
||||
else if (name.startsWith(place + ", "))
|
||||
return new String[] { place, name.substring(place.length() + 2) };
|
||||
}
|
||||
|
||||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
uri.append("stboard.exe/dn");
|
||||
|
||||
if (location.hasLocation())
|
||||
{
|
||||
uri.append("query.exe/fny");
|
||||
uri.append("?performLocating=2&tpl=stop2json");
|
||||
uri.append("&look_maxno=").append(maxStations != 0 ? maxStations : 200);
|
||||
uri.append("&look_maxdist=").append(maxDistance != 0 ? maxDistance : 5000);
|
||||
uri.append("&look_stopclass=").append(allProductsInt());
|
||||
uri.append("&look_x=").append(location.lon);
|
||||
uri.append("&look_y=").append(location.lat);
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
uri.append("stboard.exe/fn");
|
||||
uri.append("?productsFilter=").append(allProductsString());
|
||||
uri.append("&boardType=dep");
|
||||
uri.append("&input=").append(location.id);
|
||||
|
@ -120,7 +150,7 @@ public class LuProvider extends AbstractHafasProvider
|
|||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder();
|
||||
uri.append(API_BASE).append("stboard.exe/dn");
|
||||
uri.append(API_BASE).append("stboard.exe/fn");
|
||||
uri.append("?productsFilter=").append(allProductsString());
|
||||
uri.append("&boardType=dep");
|
||||
uri.append("&disableEquivs=yes"); // don't use nearby stations
|
||||
|
|
|
@ -44,7 +44,7 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void nearbyStations() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 9865836), 0, 0);
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 120405001), 0, 0);
|
||||
|
||||
print(result);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void queryDepartures() throws Exception
|
||||
{
|
||||
final QueryDeparturesResult result = provider.queryDepartures(9865836, 0, false);
|
||||
final QueryDeparturesResult result = provider.queryDepartures(120405001, 0, false);
|
||||
|
||||
print(result);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Flughafen");
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Aéroport");
|
||||
|
||||
print(autocompletes);
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void shortConnection() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = queryConnections(new Location(LocationType.STATION, 9409001, null, "Echternach, Bel Air"), null,
|
||||
new Location(LocationType.STATION, 9440001, null, "Echternach, Gare"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL,
|
||||
final QueryConnectionsResult result = queryConnections(new Location(LocationType.STATION, 200416001, null, "Cité Aéroport"), null,
|
||||
new Location(LocationType.STATION, 200405035, "Luxembourg", "Gare Centrale"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL,
|
||||
Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true);
|
||||
|
@ -88,8 +88,8 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest
|
|||
public void addressConnection() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = queryConnections(new Location(LocationType.ADDRESS, 0, 49611610, 6130265, null,
|
||||
"Luxembourg, Rue Génistre 2"), null, new Location(LocationType.STATION, 9217081, null, "Luxembourg, Gare Centrale"), new Date(),
|
||||
true, ALL_PRODUCTS, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||
"Luxembourg, Rue Génistre 2"), null, new Location(LocationType.STATION, 200405035, "Luxembourg", "Gare Centrale"), new Date(), true,
|
||||
ALL_PRODUCTS, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue