mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 17:08:49 +00:00
Add Finland provider based on Navitia.
This commit is contained in:
parent
3591f05aa3
commit
ae7146050a
3 changed files with 197 additions and 0 deletions
49
enabler/src/de/schildbach/pte/FinlandProvider.java
Normal file
49
enabler/src/de/schildbach/pte/FinlandProvider.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import de.schildbach.pte.util.WordUtils;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Adrian Perez de Castro <aperez@igalia.com>
|
||||
*/
|
||||
public class FinlandProvider extends AbstractNavitiaProvider {
|
||||
private static String API_REGION = "fi";
|
||||
|
||||
public FinlandProvider(final HttpUrl apiBase, final String authorization) {
|
||||
super(NetworkId.FINLAND, apiBase, authorization);
|
||||
setTimeZone("Europe/Helsinki");
|
||||
}
|
||||
|
||||
public FinlandProvider(final String authorization) {
|
||||
super(NetworkId.FINLAND, authorization);
|
||||
setTimeZone("Europe/Helsinki");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String region() {
|
||||
return API_REGION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLocationName(final String name) {
|
||||
return WordUtils.capitalizeFully(name);
|
||||
}
|
||||
}
|
|
@ -51,6 +51,9 @@ public enum NetworkId {
|
|||
// Sweden
|
||||
SE,
|
||||
|
||||
// Finland
|
||||
FINLAND,
|
||||
|
||||
// Luxembourg
|
||||
LU,
|
||||
|
||||
|
|
145
enabler/test/de/schildbach/pte/live/FinlandProviderLiveTest.java
Normal file
145
enabler/test/de/schildbach/pte/live/FinlandProviderLiveTest.java
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.schildbach.pte.FinlandProvider;
|
||||
import de.schildbach.pte.dto.Point;
|
||||
|
||||
/**
|
||||
* @author Adrian Perez de Castro <aperez@igalia.com>
|
||||
*/
|
||||
public class FinlandProviderLiveTest extends AbstractNavitiaProviderLiveTest {
|
||||
public FinlandProviderLiveTest() {
|
||||
super(new FinlandProvider(secretProperty("navitia.authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsAddress() throws Exception {
|
||||
nearbyStationsAddress(60160920, 24941870);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsStation() throws Exception {
|
||||
nearbyStationsStation("stop_point:OFI:SP:1050412");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsPoi() throws Exception {
|
||||
nearbyStationsPoi("poi:osm:way:29071686");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsAny() throws Exception {
|
||||
nearbyStationsAny(60160920, 24941870);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsInvalidStation() throws Exception {
|
||||
nearbyStationsInvalidStation("stop_point:9999999999");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesStopArea() throws Exception {
|
||||
queryDeparturesStopArea("stop_area:OFI:SA:1000201");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesEquivsFalse() throws Exception {
|
||||
queryDeparturesEquivsFalse("stop_point:OFI:SP:1050412");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesEquivsTrue() throws Exception {
|
||||
queryDeparturesEquivsTrue("stop_area:OFI:SA:1000201");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesInvalidStation() throws Exception {
|
||||
queryDeparturesInvalidStation("stop_point:OFI:SP:999999");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocations() throws Exception {
|
||||
suggestLocationsFromName("postitalo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationsFromAddress() throws Exception {
|
||||
suggestLocationsFromAddress("10 yrjönkatu");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationsNoLocation() throws Exception {
|
||||
suggestLocationsNoLocation("fontana di trevi blah blah");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripAddresses() throws Exception {
|
||||
queryTrip("Yrjönkatu, 10, Helsinki", "Kolmas Linja, 5, Helsinki");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripAddressStation() throws Exception {
|
||||
queryTrip("Viides Linja, 3, Helsinki", "Kapylän asema");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripStations() throws Exception {
|
||||
queryTrip("Kapylän asema", "Päärautatieasema");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripNoSolution() throws Exception {
|
||||
queryTripNoSolution("Steissi, Helsinki", "Keskuskatu 1, Kuopio");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripUnknownFrom() throws Exception {
|
||||
queryTripUnknownFrom("Rautatieasema");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripUnknownTo() throws Exception {
|
||||
queryTripUnknownTo("Rautatieasema");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripSlowWalk() throws Exception {
|
||||
queryTripSlowWalk("Rautatieasema", "Postitalo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryTripFastWalk() throws Exception {
|
||||
queryTripFastWalk("Rautatieasema", "Postitalo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryMoreTrips() throws Exception {
|
||||
queryMoreTrips("Steissi", "Töölöntori");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArea() throws Exception {
|
||||
final Point[] polygon = provider.getArea();
|
||||
assertTrue(polygon.length > 0);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue