Skip to content

Commit

Permalink
Navitia: Add provider for the Czech Republic, currently covering Prague.
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-hejsek authored and schildbach committed Oct 16, 2019
1 parent 48e25e0 commit 170d7ee
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/de/schildbach/pte/CzechRepublicProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2019 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 okhttp3.HttpUrl;

/**
* @author Filip Hejsek
*/
public class CzechRepublicProvider extends AbstractNavitiaProvider {
private static final String API_REGION = "cz";

public CzechRepublicProvider(final HttpUrl apiBase, final String authorization) {
super(NetworkId.CZECH_REPUBLIC, apiBase, authorization);
setTimeZone("Europe/Prague");
}

public CzechRepublicProvider(final String authorization) {
super(NetworkId.CZECH_REPUBLIC, authorization);
setTimeZone("Europe/Prague");
}

@Override
public String region() {
return API_REGION;
}
}
3 changes: 3 additions & 0 deletions src/de/schildbach/pte/NetworkId.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public enum NetworkId {
// Austria
OEBB, VAO, VOR, WIEN, OOEVV, LINZ, SVV, VVT, STV, VMOBIL,

// Czech Republic
CZECH_REPUBLIC,

// Switzerland
SBB, VBL, ZVV,

Expand Down
175 changes: 175 additions & 0 deletions test/de/schildbach/pte/live/CzechRepublicProviderLiveTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*
* Copyright 2019 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.CzechRepublicProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.Point;

/**
* @author Filip Hejsek
*/
public class CzechRepublicProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public CzechRepublicProviderLiveTest() {
super(new CzechRepublicProvider(secretProperty("navitia.authorization")));
}

@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(50062956, 14430641);
}

@Test
public void nearbyStationsAddress2() throws Exception {
nearbyStationsAddress(50083373, 14423001);
}

@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:OCZPRA:U527Z102P");
}

@Test
public void nearbyStationsPoi() throws Exception {
nearbyStationsPoi("poi:osm:way:141756627");
}

@Test
public void nearbyStationsAny() throws Exception {
nearbyStationsAny(50062956, 14430641);
}

@Test
public void nearbyStationsDistance() throws Exception {
nearbyStationsStationDistance("stop_point:OCZPRA:U527Z102P");
}

@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:RTP:SP:392");
}

@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:OCZPRA:U1072Z121P");
}

@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:OCZPRA:U527S1");
}

@Test
public void queryDeparturesEquivsTrue() throws Exception {
queryDeparturesEquivsTrue("stop_point:OCZPRA:U527Z101P");
}

@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:RTP:SP:999999");
}

@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("Vyšehr");
}

@Test
public void suggestLocationsFromAddress() throws Exception {
suggestLocationsFromAddress("This doesn't work");
// Address search doesn't work for Czech Republic in Navitia
}

@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("bellevilleadasdjkaskd");
}

@Test
public void queryTripAddresses() throws Exception {
queryTrip("This doesn't work", "This doesn't work");
// Address search doesn't work for Czech Republic in Navitia
}

@Test
public void queryTripAddressStation() throws Exception {
queryTrip("This doesn't work", "Muzeum");
// Address search doesn't work for Czech Republic in Navitia
}

@Test
public void queryTripStations() throws Exception {
queryTrip("Vyšehrad", "Muzeum");
}

@Test
public void queryTripStations2() throws Exception {
queryTrip("Sídliště Písnice", "Modřanská rokle");
}

@Test
public void queryTripStations3() throws Exception {
queryTrip("Modřanská rokle", "Českomoravská");
}

@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("Muzeum");
}

@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("Vyšehrad");
}

@Test
public void queryTripAmbiguousFrom() throws Exception {
queryTripAmbiguousFrom(new Location(LocationType.ANY, null, null, "Sídliště"), "Muzeum");
}

@Test
public void queryTripAmbiguousTo() throws Exception {
queryTripAmbiguousTo("Vyšehrad", new Location(LocationType.ANY, null, null, "Sídliště"));
}

@Test
public void queryTripSlowWalk() throws Exception {
queryTripSlowWalk("Nemocnice Krč", "Budějovická");
}

@Test
public void queryTripFastWalk() throws Exception {
queryTripFastWalk("Nemocnice Krč", "Budějovická");
}

@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("Nemocnice Krč", "Budějovická");
}

@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

0 comments on commit 170d7ee

Please sign in to comment.