diff --git a/enabler/src/de/schildbach/pte/LuProvider.java b/enabler/src/de/schildbach/pte/LuProvider.java index 5d9dc254..c362bcc1 100644 --- a/enabler/src/de/schildbach/pte/LuProvider.java +++ b/enabler/src/de/schildbach/pte/LuProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 the original author or authors. + * Copyright 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,8 +19,6 @@ package de.schildbach.pte; import java.util.regex.Matcher; -import com.google.common.base.Charsets; - import de.schildbach.pte.dto.Product; import okhttp3.HttpUrl; @@ -28,18 +26,17 @@ import okhttp3.HttpUrl; /** * @author Andreas Schildbach */ -public class LuProvider extends AbstractHafasLegacyProvider { +public class LuProvider extends AbstractHafasClientInterfaceProvider { private static final HttpUrl API_BASE = HttpUrl.parse("https://travelplanner.mobiliteit.lu/hafas/"); - // https://mobiliteitszentral.hafas.de/hafas/ private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.BUS, Product.BUS }; - public LuProvider() { - super(NetworkId.LU, API_BASE, "fn", PRODUCTS_MAP); - - setRequestUrlEncoding(Charsets.UTF_8); - setJsonNearbyLocationsEncoding(Charsets.UTF_8); + public LuProvider(final String apiAuthorization) { + super(NetworkId.LU, API_BASE, PRODUCTS_MAP); + setApiVersion("1.16"); + setApiClient("{\"id\":\"CDT\",\"type\":\"AND\"}"); + setApiAuthorization(apiAuthorization); } @Override @@ -47,7 +44,6 @@ public class LuProvider extends AbstractHafasLegacyProvider { final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(name); if (m.matches()) return new String[] { m.group(1), m.group(2) }; - return super.splitStationName(name); } @@ -56,26 +52,6 @@ public class LuProvider extends AbstractHafasLegacyProvider { final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address); if (m.matches()) return new String[] { m.group(1), m.group(2) }; - return super.splitStationName(address); } - - @Override - protected Product normalizeType(final String type) { - final String ucType = type.toUpperCase(); - - if ("CRE".equals(ucType)) - return Product.REGIONAL_TRAIN; - - if ("CITYBUS".equals(ucType)) - return Product.BUS; - if ("NIGHTBUS".equals(ucType)) - return Product.BUS; - if ("DIFFBUS".equals(ucType)) - return Product.BUS; - if ("NAVETTE".equals(ucType)) - return Product.BUS; - - return super.normalizeType(type); - } } diff --git a/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java index a1c508ff..8144b0c8 100644 --- a/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/LuProviderLiveTest.java @@ -37,13 +37,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult; */ public class LuProviderLiveTest extends AbstractProviderLiveTest { public LuProviderLiveTest() { - super(new LuProvider()); - } - - @Test - public void nearbyStations() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "200501001")); - print(result); + super(new LuProvider(secretProperty("lu.api_authorization"))); } @Test @@ -72,9 +66,9 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest { @Test public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "200416001", null, "Cité Aéroport"), null, - new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale"), new Date(), true, null); + final Location from = new Location(LocationType.STATION, "200416001", null, "Cité Aéroport"); + final Location to = new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale"); + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); print(result); final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); @@ -90,4 +84,13 @@ public class LuProviderLiveTest extends AbstractProviderLiveTest { final QueryTripsResult laterResult = queryMoreTrips(result.context, true); print(laterResult); } + + @Test + public void tripBetweenCoordinates() throws Exception { + final Location from = Location.coord(Point.fromDouble(49.5999681, 6.1342493)); // Luxembourg Central + // Station + final Location to = Location.coord(Point.fromDouble(49.5956369, 6.1200199)); // Hollerich + final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null); + print(result); + } } diff --git a/enabler/test/de/schildbach/pte/live/secrets.properties.template b/enabler/test/de/schildbach/pte/live/secrets.properties.template index 9a8f073b..b59c5809 100644 --- a/enabler/test/de/schildbach/pte/live/secrets.properties.template +++ b/enabler/test/de/schildbach/pte/live/secrets.properties.template @@ -17,5 +17,6 @@ vao.api_authorization = zvv.api_authorization = dsb.api_authorization = se.api_authorization = +lu.api_authorization = hsl.usertoken = hsl.passphrase =