From dee663ea54d818b2d58d22cf4d16c54746e4aa5b Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 13 Jan 2017 12:29:38 +0100 Subject: [PATCH] Remove Melbourne. PTV has shut or locked down their EFA. --- .../src/de/schildbach/pte/MetProvider.java | 82 ------------ enabler/src/de/schildbach/pte/NetworkId.java | 2 +- .../pte/live/MetProviderLiveTest.java | 117 ------------------ 3 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 enabler/src/de/schildbach/pte/MetProvider.java delete mode 100644 enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java diff --git a/enabler/src/de/schildbach/pte/MetProvider.java b/enabler/src/de/schildbach/pte/MetProvider.java deleted file mode 100644 index a843d38b..00000000 --- a/enabler/src/de/schildbach/pte/MetProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2010-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 . - */ - -package de.schildbach.pte; - -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Nullable; - -import com.google.common.base.Strings; - -import de.schildbach.pte.dto.Line; -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; - -import okhttp3.HttpUrl; - -/** - * Has been renamed to PTV (Public Transport Vicoria). - * - * @author Andreas Schildbach - */ -public class MetProvider extends AbstractEfaProvider { - private static final HttpUrl API_BASE = HttpUrl.parse("http://jp.ptv.vic.gov.au/ptv/"); - - public MetProvider() { - super(NetworkId.MET, API_BASE); - - setLanguage("en"); - setTimeZone("Australia/Melbourne"); - setUseRouteIndexAsTripId(false); - setStyles(STYLES); - setSessionCookieName("BIGipServerpl_ptv_jp_lbvsvr"); - } - - @Override - protected Line parseLine(final @Nullable String id, final @Nullable String network, final @Nullable String mot, - final @Nullable String symbol, final @Nullable String name, final @Nullable String longName, - final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName) { - if ("0".equals(mot)) { - if ("Regional Train :".equals(longName)) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - if ("Regional Train".equals(trainName)) - return new Line(id, network, Product.REGIONAL_TRAIN, null); - if ("vPK".equals(symbol) && "Regional Train Pakenham".equals(longName)) - return new Line(id, network, Product.REGIONAL_TRAIN, "V/Line"); - } else if ("1".equals(mot)) { - if (trainType == null && trainNum != null) - return new Line(id, network, Product.SUBURBAN_TRAIN, trainNum); - if ("Metropolitan Train".equals(trainName) && trainNum == null) - return new Line(id, network, Product.SUBURBAN_TRAIN, Strings.nullToEmpty(name)); - } - - return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName); - } - - private static final Map STYLES = new HashMap(); - - static { - STYLES.put("R", new Style(Style.parseColor("#a24ba3"), Style.WHITE)); - STYLES.put("S", new Style(Style.parseColor("#3a75c4"), Style.WHITE)); - STYLES.put("T", new Style(Style.parseColor("#5bbf21"), Style.WHITE)); - STYLES.put("B", new Style(Style.parseColor("#f77f00"), Style.WHITE)); - - // TODO NightRider buses (buses with numbers > 940): #f26522 - } -} diff --git a/enabler/src/de/schildbach/pte/NetworkId.java b/enabler/src/de/schildbach/pte/NetworkId.java index c327f09f..0975db84 100644 --- a/enabler/src/de/schildbach/pte/NetworkId.java +++ b/enabler/src/de/schildbach/pte/NetworkId.java @@ -79,5 +79,5 @@ public enum NetworkId { ONTARIO, QUEBEC, // Australia - SYDNEY, MET + SYDNEY } diff --git a/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java deleted file mode 100644 index afe071f5..00000000 --- a/enabler/test/de/schildbach/pte/live/MetProviderLiveTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2010-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 . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Date; - -import org.junit.Test; - -import de.schildbach.pte.MetProvider; -import de.schildbach.pte.NetworkProvider.Accessibility; -import de.schildbach.pte.NetworkProvider.WalkSpeed; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.QueryTripsResult; -import de.schildbach.pte.dto.SuggestLocationsResult; - -/** - * @author Andreas Schildbach - */ -public class MetProviderLiveTest extends AbstractProviderLiveTest { - public MetProviderLiveTest() { - super(new MetProvider()); - } - - @Test - public void nearbyStations() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10001167")); - print(result); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(Location.coord(-37800941, 144966545)); - print(result); - } - - @Test - public void queryDepartures() throws Exception { - final QueryDeparturesResult result = queryDepartures("10001167", false); - print(result); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - final QueryDeparturesResult result = queryDepartures("999999", false); - assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status); - } - - @Test - public void suggestLocationsIncomplete() throws Exception { - final SuggestLocationsResult result = suggestLocations("Kur"); - print(result); - } - - @Test - public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.STATION, "10001181", -37818664, 144952784, "Melbourne City", - "Southern Cross Railway Station (Melbourne City)"), - null, - new Location(LocationType.STATION, "10002204", -37818248, 144967824, "Melbourne City", - "13-Federation Square/Swanston St"), - new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL); - print(result); - assertEquals(QueryTripsResult.Status.OK, result.status); - assertTrue(result.trips.size() > 0); - - if (!result.context.canQueryLater()) - return; - - final QueryTripsResult laterResult = queryMoreTrips(result.context, true); - print(laterResult); - - if (!laterResult.context.canQueryLater()) - return; - - final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true); - print(later2Result); - - if (!later2Result.context.canQueryEarlier()) - return; - - final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false); - print(earlierResult); - } - - @Test - public void tripToAny() throws Exception { - final QueryTripsResult result = queryTrips( - new Location(LocationType.ADDRESS, null, -37903445, 145102109, null, - "16 Burlington St, Oakleigh Victoria 3166, Australien"), - null, new Location(LocationType.ANY, null, 0, 0, null, "elizabeth st kensingtin"), new Date(), true, - Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL); - print(result); - } -}