Add support for Navitia fr-sw region (which covers South-West of France) #55

Closed
wants to merge 4 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+262 −1
Diff settings

Always

Just for now

@@ -0,0 +1,68 @@
+/*
+ * Copyright 2014-2015 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 <http://www.gnu.org/licenses/>.
+ */
+
+package de.schildbach.pte;
+
+import de.schildbach.pte.dto.Product;
+import de.schildbach.pte.dto.Style;
+import de.schildbach.pte.dto.Style.Shape;
+
+/**
+ * @author Nicolas Derive
+ */
+public class FrenchSouthWestProvider extends AbstractNavitiaProvider
+{
+ private static String API_REGION = "fr-sw";
+
+ public FrenchSouthWestProvider(final String authorization)
+ {
+ super(NetworkId.FRENCHSOUTHWEST, authorization);
+
+ setTimeZone("Europe/Paris");
+ }
+
+ @Override
+ public String region()
+ {
+ return API_REGION;
+ }
+
+ @Override
+ protected Style getLineStyle(final Product product, final String code, final String color)
+ {
+ switch (product)
+ {
+ case TRAM:
+ {
+ // Tram
+ return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color));
+ }
+ case BUS:
+ {
+ // Bus + Transgironde
+ return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
+ }
+ case FERRY:
+ {
+ // Batcub
+ return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color));
+ }
+ default:
+ throw new IllegalArgumentException("Unhandled product: " + product);
+ }
+ }
+}
@@ -35,7 +35,7 @@
SBB, BVB, VBL, ZVV,
// France
- PACA, PARIS,
+ PACA, PARIS, FRENCHSOUTHWEST,
// Belgium
SNCB,
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2014-2015 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 <http://www.gnu.org/licenses/>.
+ */
+
+package de.schildbach.pte.live;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import de.schildbach.pte.FrenchSouthWestProvider;
+import de.schildbach.pte.dto.Point;
+
+/**
+ * @author Nicolas Derive
+ */
+public class FrenchSouthWestProviderLiveTest extends AbstractNavitiaProviderLiveTest
+{
+ public FrenchSouthWestProviderLiveTest()
+ {
+ super(new FrenchSouthWestProvider(Secrets.NAVITIA_AUTHORIZATION));
+ }
+
+ @Test
+ public void nearbyStationsAddress() throws Exception
+ {
+ nearbyStationsAddress(44826434, -557312);
+ }
+
+ @Test
+ public void nearbyStationsAddress2() throws Exception
+ {
+ nearbyStationsAddress(44841225, -580036);
+ }
+
+ @Test
+ public void nearbyStationsStation() throws Exception
+ {
+ nearbyStationsStation("stop_point:STE:SP:OCETrainTER-87581538");
+ }
+
+ @Test
+ public void nearbyStationsPoi() throws Exception
+ {
+ nearbyStationsPoi("poi:n849494949");
+ }
+
+ @Test
+ public void nearbyStationsAny() throws Exception
+ {
+ nearbyStationsAny(44826434, -557312);
+ }
+
+ @Test
+ public void nearbyStationsInvalidStation() throws Exception
+ {
+ nearbyStationsInvalidStation("stop_point:OBO:SP:7");
+ }
+
+ @Test
+ public void queryDeparturesEquivsFalse() throws Exception
+ {
+ queryDeparturesEquivsFalse("stop_point:OBO:SP:732");
+ }
+
+ @Test
+ public void queryDeparturesStopArea() throws Exception
+ {
+ queryDeparturesStopArea("stop_area:OBO:SA:AEROG");
+ }
+
+ @Test
+ public void queryDeparturesEquivsTrue() throws Exception
+ {
+ queryDeparturesEquivsTrue("stop_point:OBO:SP:732");
+ }
+
+ @Test
+ public void queryDeparturesInvalidStation() throws Exception
+ {
+ queryDeparturesInvalidStation("stop_point:OBO:SP:999999");
+ }
+
+ @Test
+ public void suggestLocations() throws Exception
+ {
+ suggestLocationsFromName("quinco");
+ }
+
+ @Test
+ public void suggestLocationsFromAddress() throws Exception
+ {
+ suggestLocationsFromAddress("78 rue cam");
+ }
+
+ @Test
+ public void suggestLocationsNoLocation() throws Exception
+ {
+ suggestLocationsNoLocation("quinconcesadasdjkaskd");
+ }
+
+ @Test
+ public void queryTripAddresses() throws Exception
+ {
+ queryTrip("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
+ }
+
+ @Test
+ public void queryTripAddressStation() throws Exception
+ {
+ queryTrip("98, rue Jean-Renaud Dandicolle Bordeaux", "Saint-Augustin");
+ }
+
+ @Test
+ public void queryTripStations() throws Exception
+ {
+ queryTrip("Hôpital Pellegrin", "Avenue de l'Université");
+ }
+
+ @Test
+ public void queryTripStations2() throws Exception
+ {
+ queryTrip("Pelletan", "Barrière de Pessac");
+ }
+
+ @Test
+ public void queryTripStations3() throws Exception
+ {
+ queryTrip("Barrière de Pessac", "Hôpital Pellegrin");
+ }
+
+ @Test
+ public void queryTripStationsRapidTransit() throws Exception
+ {
+ queryTrip("Gaviniès Bordeaux", "Saint-Augustin Bordeaux");
+ }
+
+ @Test
+ public void queryTripNoSolution() throws Exception
+ {
+ queryTripNoSolution("Patinoire Mériadeck Bordeaux", "Mérignac Centre");
+ }
+
+ @Test
+ public void queryTripUnknownFrom() throws Exception
+ {
+ queryTripUnknownFrom("Patinoire Mériadeck Bordeaux");
+ }
+
+ @Test
+ public void queryTripUnknownTo() throws Exception
+ {
+ queryTripUnknownTo("Patinoire Mériadeck Bordeaux");
+ }
+
+ @Test
+ public void queryTripSlowWalk() throws Exception
+ {
+ queryTripSlowWalk("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
+ }
+
+ @Test
+ public void queryTripFastWalk() throws Exception
+ {
+ queryTripFastWalk("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
+ }
+
+ @Test
+ public void queryMoreTrips() throws Exception
+ {
+ queryMoreTrips("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
+ }
+
+ @Test
+ public void getArea() throws Exception
+ {
+ final Point[] polygon = provider.getArea();
+ assertTrue(polygon.length > 0);
+ }
+}