From 30cf73eda6946dddf06822cedc89bda37f9f4cf1 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 16 Nov 2023 16:19:01 +0100 Subject: [PATCH] AVV: remove EFA-based provider for Augsburg The Hafas-based `AvvAugsburgProvider` takes its place. --- src/de/schildbach/pte/AvvProvider.java | 134 ------------------ src/de/schildbach/pte/NetworkId.java | 2 +- .../pte/live/AvvProviderLiveTest.java | 112 --------------- 3 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 src/de/schildbach/pte/AvvProvider.java delete mode 100644 test/de/schildbach/pte/live/AvvProviderLiveTest.java diff --git a/src/de/schildbach/pte/AvvProvider.java b/src/de/schildbach/pte/AvvProvider.java deleted file mode 100644 index 0170bd67..00000000 --- a/src/de/schildbach/pte/AvvProvider.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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 . - */ - -package de.schildbach.pte; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Nullable; - -import com.google.common.base.Charsets; - -import de.schildbach.pte.dto.Line; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.TripOptions; - -import okhttp3.HttpUrl; - -/** - * @author Andreas Schildbach - */ -public class AvvProvider extends AbstractEfaProvider { - private static final HttpUrl API_BASE = HttpUrl.parse("https://efa.avv-augsburg.de/avv2/"); - - public AvvProvider() { - super(NetworkId.AVV, API_BASE); - setUseRouteIndexAsTripId(false); - setRequestUrlEncoding(Charsets.UTF_8); - setStyles(STYLES); - } - - @Override - protected void appendTripRequestParameters(final HttpUrl.Builder url, final Location from, - final @Nullable Location via, final Location to, final Date time, final boolean dep, - final @Nullable TripOptions options) { - super.appendTripRequestParameters(url, from, via, to, time, dep, options); - url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus - url.addEncodedQueryParameter("inclMOT_17", "on"); - } - - @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 ("Regionalbahn".equals(trainName) && symbol != null) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - if ("Staudenbahn SVG".equals(trainNum) && trainType == null && trainName == null) - return new Line(id, network, Product.REGIONAL_TRAIN, "SVG"); - - // Streikfahrplan - if ("R1S".equals(symbol)) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - if ("R4S".equals(symbol)) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - if ("R6S".equals(symbol)) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - if ("R7S".equals(symbol)) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - if ("R8S".equals(symbol)) - return new Line(id, network, Product.REGIONAL_TRAIN, symbol); - } - - return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName); - } - - private static final Map STYLES = new HashMap<>(); - - static { - STYLES.put("B", new Style(Style.Shape.CIRCLE, Style.parseColor("#abb1b1"), Style.BLACK)); - STYLES.put("BB1", new Style(Style.Shape.CIRCLE, Style.parseColor("#93117e"), Style.WHITE)); - STYLES.put("BB3", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE)); - STYLES.put("B21", new Style(Style.Shape.CIRCLE, Style.parseColor("#00896b"), Style.WHITE)); - STYLES.put("B22", new Style(Style.Shape.CIRCLE, Style.parseColor("#eb6b59"), Style.WHITE)); - STYLES.put("B23", new Style(Style.Shape.CIRCLE, Style.parseColor("#97bf0d"), Style.parseColor("#d10019"))); - STYLES.put("B27", new Style(Style.Shape.CIRCLE, Style.parseColor("#74b57e"), Style.WHITE)); - STYLES.put("B29", new Style(Style.Shape.CIRCLE, Style.parseColor("#5f689f"), Style.WHITE)); - STYLES.put("B30", new Style(Style.Shape.CIRCLE, Style.parseColor("#829ac3"), Style.WHITE)); - STYLES.put("B31", new Style(Style.Shape.CIRCLE, Style.parseColor("#a3cdb0"), Style.parseColor("#006835"))); - STYLES.put("B32", new Style(Style.Shape.CIRCLE, Style.parseColor("#45a477"), Style.WHITE)); - STYLES.put("B33", new Style(Style.Shape.CIRCLE, Style.parseColor("#a0ca82"), Style.WHITE)); - STYLES.put("B35", new Style(Style.Shape.CIRCLE, Style.parseColor("#0085c5"), Style.WHITE)); - STYLES.put("B36", new Style(Style.Shape.CIRCLE, Style.parseColor("#b1c2e1"), Style.parseColor("#006ab3"))); - STYLES.put("B37", new Style(Style.Shape.CIRCLE, Style.parseColor("#eac26b"), Style.BLACK)); - STYLES.put("B38", new Style(Style.Shape.CIRCLE, Style.parseColor("#c3655a"), Style.WHITE)); - STYLES.put("B41", new Style(Style.Shape.CIRCLE, Style.parseColor("#d26110"), Style.WHITE)); - STYLES.put("B42", new Style(Style.Shape.CIRCLE, Style.parseColor("#d57642"), Style.WHITE)); - STYLES.put("B43", new Style(Style.Shape.CIRCLE, Style.parseColor("#e29241"), Style.WHITE)); - STYLES.put("B44", new Style(Style.Shape.CIRCLE, Style.parseColor("#d0aacc"), Style.parseColor("#6d1f80"))); - STYLES.put("B45", new Style(Style.Shape.CIRCLE, Style.parseColor("#a76da7"), Style.WHITE)); - STYLES.put("B46", new Style(Style.Shape.CIRCLE, Style.parseColor("#52bcc2"), Style.WHITE)); - STYLES.put("B48", new Style(Style.Shape.CIRCLE, Style.parseColor("#a6d7d2"), Style.parseColor("#079098"))); - STYLES.put("B51", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE)); - STYLES.put("B52", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE)); - STYLES.put("B54", new Style(Style.Shape.CIRCLE, Style.parseColor("#ee7f00"), Style.WHITE)); - STYLES.put("B56", new Style(Style.Shape.CIRCLE, Style.parseColor("#a86853"), Style.WHITE)); - STYLES.put("B57", new Style(Style.Shape.CIRCLE, Style.parseColor("#a76da7"), Style.WHITE)); - STYLES.put("B58", new Style(Style.Shape.CIRCLE, Style.parseColor("#d0aacc"), Style.parseColor("#6d1f80"))); - STYLES.put("B59", new Style(Style.Shape.CIRCLE, Style.parseColor("#b1c2e1"), Style.parseColor("#00519e"))); - STYLES.put("B70", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE)); - STYLES.put("B71", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE)); - STYLES.put("B72", new Style(Style.Shape.CIRCLE, Style.parseColor("#a99990"), Style.WHITE)); - STYLES.put("B76", new Style(Style.Shape.CIRCLE, Style.parseColor("#c3655a"), Style.WHITE)); - - STYLES.put("T2", new Style(Style.Shape.RECT, Style.parseColor("#006ab3"), Style.WHITE)); - STYLES.put("T13", new Style(Style.Shape.RECT, Style.parseColor("#e2001a"), Style.WHITE)); - STYLES.put("T64", new Style(Style.Shape.RECT, Style.parseColor("#97bf0d"), Style.WHITE)); - - STYLES.put("RR1", new Style(Style.Shape.ROUNDED, Style.parseColor("#1bbbea"), Style.WHITE)); - STYLES.put("RR2", new Style(Style.Shape.ROUNDED, Style.parseColor("#003a80"), Style.WHITE)); - STYLES.put("RR4", new Style(Style.Shape.ROUNDED, Style.parseColor("#bd5619"), Style.WHITE)); - STYLES.put("RR6", new Style(Style.Shape.ROUNDED, Style.parseColor("#0098a1"), Style.WHITE)); - STYLES.put("RR7", new Style(Style.Shape.ROUNDED, Style.parseColor("#80191c"), Style.WHITE)); - STYLES.put("RR8", new Style(Style.Shape.ROUNDED, Style.parseColor("#007d40"), Style.WHITE)); - STYLES.put("RR11", new Style(Style.Shape.ROUNDED, Style.parseColor("#e6a300"), Style.WHITE)); - } -} diff --git a/src/de/schildbach/pte/NetworkId.java b/src/de/schildbach/pte/NetworkId.java index b5cb2d1e..9fee2e87 100644 --- a/src/de/schildbach/pte/NetworkId.java +++ b/src/de/schildbach/pte/NetworkId.java @@ -25,7 +25,7 @@ public enum NetworkId { RT, // Germany - DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV, AVV_AUGSBURG, VGN, VVM, VMV, SH, GVH, BSVAG, VBN, NASA, VMT, VVO, VGS, VRR, VRS, AVV_AACHEN, MVG, VRN, VVS, DING, KVV, NVBW, VVV, + DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV_AUGSBURG, VGN, VVM, VMV, SH, GVH, BSVAG, VBN, NASA, VMT, VVO, VGS, VRR, VRS, AVV_AACHEN, MVG, VRN, VVS, DING, KVV, NVBW, VVV, // Austria OEBB, VAO, VOR, WIEN, OOEVV, LINZ, SVV, VVT, STV, VMOBIL, diff --git a/test/de/schildbach/pte/live/AvvProviderLiveTest.java b/test/de/schildbach/pte/live/AvvProviderLiveTest.java deleted file mode 100644 index a73d032a..00000000 --- a/test/de/schildbach/pte/live/AvvProviderLiveTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 . - */ - -package de.schildbach.pte.live; - -import static org.hamcrest.CoreMatchers.hasItem; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Date; - -import org.junit.Test; - -import de.schildbach.pte.AvvProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.QueryTripsResult; -import de.schildbach.pte.dto.SuggestLocationsResult; - -/** - * @author Andreas Schildbach - */ -public class AvvProviderLiveTest extends AbstractProviderLiveTest { - public AvvProviderLiveTest() { - super(new AvvProvider()); - } - - @Test - public void nearbyStations() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "100")); - print(result); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(Location.coord(48367233, 10894976)); - print(result); - } - - @Test - public void queryDepartures() throws Exception { - final QueryDeparturesResult result = queryDepartures("100", 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 suggestLocationsWithUmlaut() throws Exception { - final SuggestLocationsResult result1 = suggestLocations("Barfüßerbrücke"); - print(result1); - assertThat(result1.getLocations(), hasItem(new Location(LocationType.STATION, "2000131"))); - - final SuggestLocationsResult result2 = suggestLocations("Gärtnerstraße"); - print(result2); - assertThat(result2.getLocations(), hasItem(new Location(LocationType.STATION, "2000557"))); - } - - @Test - public void shortTrip() throws Exception { - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "101", null, "Königsplatz"), null, - new Location(LocationType.STATION, "100", null, "Hauptbahnhof"), new Date(), true, null); - 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); - } -}