From 7c6b3d2539bd6c5ae54ed6db75763d6e44d61deb Mon Sep 17 00:00:00 2001
From: "andreas.schildbach@gmail.com"
\n" //
- + "- (.*?) -.*?" // firstDeparture
- + "Abfahrt: (\\d{2}\\.\\d{2}\\.\\d{2}) \n(.+?)
\n"// date
- + "(?:Ankunft: \\d{2}\\.\\d{2}\\.\\d{2}
\n)?" //
- + "Dauer: (\\d{1,2}:\\d{2})
.*?" // duration
- , Pattern.DOTALL);
- private static final Pattern P_CONNECTION_DETAILS_COARSE = Pattern.compile("/b> -\n(.*?- [^<]*)<", Pattern.DOTALL);
- private static final Pattern P_CONNECTION_DETAILS_FINE = Pattern.compile("
\n" //
- + "(?:(.*?) nach ([^\n]*)\n" // line, destination
- + "
\n" //
- + "ab (\\d{1,2}:\\d{2})\n" // plannedDepartureTime
- + "(?:\nca\\.(\\d{1,2}:\\d{2})\n\n)?" // predictedDepartureTime
- + "(?:Gl\\. (.+?)\\s*\n)?" // departurePosition
- + "
\n" //
- + "an (\\d{1,2}:\\d{2})\n" // plannedArrivalTime
- + "(?:ca\\.(\\d{1,2}:\\d{2})\n)?" // predictedArrivalTime
- + "(?:Gl\\. (.+?)\\s*\n)?" // arrivalPosition
- + "
\n|" //
- + "]*>\n" //
- + "Fussweg\\s*\n" //
- + "\n" //
- + "(\\d+) Min.
\n)" // footway
- + "- (.*?)" // arrival
- , Pattern.DOTALL);
-
- @Override
- public GetConnectionDetailsResult getConnectionDetails(final String uri) throws IOException
- {
- final CharSequence page = ParserUtils.scrape(uri);
-
- final Matcher mHead = P_CONNECTION_DETAILS_HEAD.matcher(page);
- if (mHead.matches())
- {
- final Location firstDeparture = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mHead.group(1)));
- final Calendar currentDate = new GregorianCalendar(timeZone());
- currentDate.clear();
- ParserUtils.parseGermanDate(currentDate, mHead.group(2));
-
- final Calendar time = new GregorianCalendar(timeZone());
- time.setTimeInMillis(currentDate.getTimeInMillis());
-
- Date lastTime = time.getTime();
-
- Date firstDepartureTime = null;
- Date lastArrivalTime = null;
- Location lastArrival = null;
- Connection.Trip lastTrip = null;
-
- final List
\n" //
+ "(\\d{1,2}:\\d{2})\n" // plannedTime
+ "(?:keine Prognose verfügbar\n)?" //
@@ -519,7 +163,7 @@ public class RmvProvider extends AbstractHafasProvider
+ "(?:(Gl\\. " + ParserUtils.P_PLATFORM + ")
\n)?" // position
+ "(?:([^>]*)\n)?" // message
+ "(?:\n[^<]*\n
\n)*" // (messages)
- , Pattern.DOTALL);
+ + ".*?", Pattern.DOTALL);
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
{
@@ -659,6 +303,10 @@ public class RmvProvider extends AbstractHafasProvider
return "TRT" + number;
if (type.startsWith("Bus"))
return "B" + type.substring(3) + number;
+ if (type.equals("AS")) // Anruf-Sammel-Taxi
+ return "BAS" + number;
+ if (type.equals("ASOF-")) // Anruf-Sammel-Taxi
+ return "BASOF" + number;
if (type.startsWith("AST")) // Anruf-Sammel-Taxi
return "BAST" + type.substring(3) + number;
if (type.startsWith("ALT")) // Anruf-Linien-Taxi
@@ -684,6 +332,15 @@ public class RmvProvider extends AbstractHafasProvider
@Override
protected char normalizeType(final String type)
{
- throw new UnsupportedOperationException();
+ final String ucType = type.toUpperCase();
+
+ if ("U-BAHN".equals(ucType))
+ return 'U';
+
+ final char t = super.normalizeType(type);
+ if (t != 0)
+ return t;
+
+ return 0;
}
}
diff --git a/test/de/schildbach/pte/RmvProviderTest.java b/test/de/schildbach/pte/RmvProviderTest.java
deleted file mode 100644
index c4662e30..00000000
--- a/test/de/schildbach/pte/RmvProviderTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2010, 2011 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
\n" //
- + "20:21\n" //
- + "keine Prognose verfügbar\n" //
- + "heute Gl. Enkheim
\n");
-
- assertNotNull(m.group(5)); // predictedPosition
- }
-
- @Test
- public void departureWithMessage()
- {
- final Matcher m = assertFineDepartures("Bus 274 \n" //
- + ">>\n" //
- + "Bad Schwalbach Kurhaus\n" //
- + "
\n" //
- + "15:47\n" //
- + "Zug fällt aus\n");
-
- assertNotNull(m.group(7)); // message
- }
-
- private Matcher assertFineDepartures(String s)
- {
- Matcher m = RmvProvider.P_DEPARTURES_FINE.matcher(s);
- assertTrue(m.matches());
-
- // ParserUtils.printGroups(m);
-
- assertNotNull(m.group(1)); // line
- assertNotNull(m.group(2)); // destination
- assertNotNull(m.group(3)); // time
-
- return m;
- }
-}
diff --git a/test/de/schildbach/pte/live/RmvProviderLiveTest.java b/test/de/schildbach/pte/live/RmvProviderLiveTest.java
index 231d598e..d535e5cf 100644
--- a/test/de/schildbach/pte/live/RmvProviderLiveTest.java
+++ b/test/de/schildbach/pte/live/RmvProviderLiveTest.java
@@ -24,7 +24,6 @@ import org.junit.Test;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.RmvProvider;
-import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
@@ -39,6 +38,30 @@ public class RmvProviderLiveTest
private final RmvProvider provider = new RmvProvider();
protected static final String ALL_PRODUCTS = "IRSUTBFC";
+ @Test
+ public void nearbyStations() throws Exception
+ {
+ final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3000001), 0, 0);
+
+ System.out.println(result.stations.size() + " " + result.stations);
+ }
+
+ @Test
+ public void nearbyStationsByCoordinate() throws Exception
+ {
+ final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 50108625, 8669604), 0, 0);
+
+ System.out.println(result.stations.size() + " " + result.stations);
+ }
+
+ @Test
+ public void queryDepartures() throws Exception
+ {
+ final QueryDeparturesResult result = provider.queryDepartures(3000408, 0, false);
+
+ System.out.println(result.stationDepartures);
+ }
+
@Test
public void autocomplete() throws Exception
{
@@ -55,22 +78,6 @@ public class RmvProviderLiveTest
System.out.println();
}
- @Test
- public void nearbyStations() throws Exception
- {
- final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3000001), 0, 0);
-
- System.out.println(result.stations.size() + " " + result.stations);
- }
-
- @Test
- public void queryDepartures() throws Exception
- {
- final QueryDeparturesResult result = provider.queryDepartures(3000001, 0, false);
-
- System.out.println(result.stationDepartures);
- }
-
@Test
public void shortConnection() throws Exception
{
@@ -78,11 +85,9 @@ public class RmvProviderLiveTest
new Location(LocationType.ANY, 0, null, "Frankfurt Hauptbahnhof!"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
- for (final Connection connection : result.connections)
- provider.getConnectionDetails(connection.link);
System.out.println(moreResult);
}
-
+
@Test
public void shortConnectionByName() throws Exception
{