From c6cb7bcfefd53832ec4bf427554229b5f3f74ec5 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Thu, 15 Sep 2016 11:33:11 +0200 Subject: [PATCH] Navitia: Add support for fr-nw region (North-West of France). --- .../pte/FranceNorthWestProvider.java | 42 +++++++++++ enabler/src/de/schildbach/pte/NetworkId.java | 2 +- .../live/FranceNorthWestProviderLiveTest.java | 70 +++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 enabler/src/de/schildbach/pte/FranceNorthWestProvider.java create mode 100644 enabler/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java diff --git a/enabler/src/de/schildbach/pte/FranceNorthWestProvider.java b/enabler/src/de/schildbach/pte/FranceNorthWestProvider.java new file mode 100644 index 00000000..1c841717 --- /dev/null +++ b/enabler/src/de/schildbach/pte/FranceNorthWestProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 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 . + */ + +package de.schildbach.pte; + +/** + * @author Patrick Kanzler + */ +public class FranceNorthWestProvider extends AbstractNavitiaProvider { + private static String API_REGION = "fr-nw"; + + public FranceNorthWestProvider(final String apiBase, final String authorization) { + super(NetworkId.FRANCENORTHWEST, apiBase, authorization); + + setTimeZone("Europe/Paris"); + } + + public FranceNorthWestProvider(final String authorization) { + super(NetworkId.FRANCENORTHWEST, authorization); + + setTimeZone("Europe/Paris"); + } + + @Override + public String region() { + return API_REGION; + } +} diff --git a/enabler/src/de/schildbach/pte/NetworkId.java b/enabler/src/de/schildbach/pte/NetworkId.java index 5007d4ad..5b72ec7e 100644 --- a/enabler/src/de/schildbach/pte/NetworkId.java +++ b/enabler/src/de/schildbach/pte/NetworkId.java @@ -34,7 +34,7 @@ public enum NetworkId { SBB, BVB, VBL, ZVV, // France - PACA, PARIS, FRENCHSOUTHWEST, FRANCESOUTHEAST, FRANCENORTHEAST, + PACA, PARIS, FRENCHSOUTHWEST, FRANCESOUTHEAST, FRANCENORTHWEST, FRANCENORTHEAST, // Belgium SNCB, diff --git a/enabler/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java new file mode 100644 index 00000000..0aa12247 --- /dev/null +++ b/enabler/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2016 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 . + */ + +package de.schildbach.pte.live; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import de.schildbach.pte.FranceNorthWestProvider; +import de.schildbach.pte.dto.Location; +import de.schildbach.pte.dto.LocationType; +import de.schildbach.pte.dto.NearbyLocationsResult; +import de.schildbach.pte.dto.Point; +import de.schildbach.pte.dto.QueryDeparturesResult; +import de.schildbach.pte.dto.SuggestLocationsResult; + +/** + * @author Patrick Kanzler + */ +public class FranceNorthWestProviderLiveTest extends AbstractNavitiaProviderLiveTest { + public FranceNorthWestProviderLiveTest() { + super(new FranceNorthWestProvider(secretProperty("navitia.authorization"))); + } + + @Test + public void nearbyStations() throws Exception { + final NearbyLocationsResult result = queryNearbyStations( + new Location(LocationType.STATION, "stop_point:ORE:SP:1016")); + print(result); + } + + @Test + public void nearbyStationsByCoordinate() throws Exception { + final NearbyLocationsResult result = queryNearbyStations(Location.coord(48109710, -16793391)); + print(result); + } + + @Test + public void queryDepartures() throws Exception { + final QueryDeparturesResult result = queryDepartures("stop_point:ORE:SP:1016", 10, false); + print(result); + } + + @Test + public void suggestLocations() throws Exception { + final SuggestLocationsResult result = suggestLocations("Anne"); + print(result); + } + + @Test + public void getArea() throws Exception { + final Point[] polygon = provider.getArea(); + assertTrue(polygon.length > 0); + } +}