diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java
index 75d040db..03b63f67 100644
--- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java
+++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java
@@ -3201,7 +3201,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
}
private static final Pattern P_POSITION = Pattern.compile(
- "(?:Gleis|Gl\\.|Bahnsteig|Bstg\\.|Bussteig|Busstg\\.|Steig|Hp\\.|Stop|Pos\\.|Zone|Platform)?\\s*(.+)", Pattern.CASE_INSENSITIVE);
+ "(?:Gleis|Gl\\.|Bahnsteig|Bstg\\.|Bussteig|Busstg\\.|Steig|Hp\\.|Stop|Pos\\.|Zone|Platform|Stand|Bay|Stance)?\\s*(.+)",
+ Pattern.CASE_INSENSITIVE);
@Override
protected Position parsePosition(final String position)
diff --git a/enabler/src/de/schildbach/pte/MerseyProvider.java b/enabler/src/de/schildbach/pte/MerseyProvider.java
new file mode 100644
index 00000000..895984ad
--- /dev/null
+++ b/enabler/src/de/schildbach/pte/MerseyProvider.java
@@ -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 .
+ */
+
+package de.schildbach.pte;
+
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import de.schildbach.pte.dto.Position;
+import de.schildbach.pte.dto.Product;
+
+/**
+ * @author Andreas Schildbach
+ */
+public class MerseyProvider extends AbstractEfaProvider
+{
+ public static final NetworkId NETWORK_ID = NetworkId.MERSEY;
+ private final static String API_BASE = "http://jp.merseytravel.gov.uk/nwm/";
+
+ public MerseyProvider()
+ {
+ super(API_BASE);
+
+ setLanguage("en");
+ setTimeZone("Europe/London");
+ }
+
+ public NetworkId id()
+ {
+ return NETWORK_ID;
+ }
+
+ @Override
+ public Set defaultProducts()
+ {
+ return Product.ALL;
+ }
+
+ private static final Pattern P_POSITION_BOUND = Pattern.compile("([NESW]+)-bound", Pattern.CASE_INSENSITIVE);
+
+ @Override
+ protected Position parsePosition(final String position)
+ {
+ if (position == null)
+ return null;
+
+ final Matcher m = P_POSITION_BOUND.matcher(position);
+ if (m.matches())
+ return new Position(m.group(1));
+
+ return super.parsePosition(position);
+ }
+}
diff --git a/enabler/src/de/schildbach/pte/NetworkId.java b/enabler/src/de/schildbach/pte/NetworkId.java
index 4c1ea39c..8ffdd754 100644
--- a/enabler/src/de/schildbach/pte/NetworkId.java
+++ b/enabler/src/de/schildbach/pte/NetworkId.java
@@ -56,7 +56,7 @@ public enum NetworkId
LU,
// United Kingdom
- TLEM,
+ TLEM, MERSEY,
// Ireland
TFI, EIREANN,
diff --git a/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java
new file mode 100644
index 00000000..60d8702a
--- /dev/null
+++ b/enabler/test/de/schildbach/pte/live/MerseyProviderLiveTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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 .
+ */
+
+package de.schildbach.pte.live;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.EnumSet;
+
+import org.junit.Test;
+
+import de.schildbach.pte.MerseyProvider;
+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 MerseyProviderLiveTest extends AbstractProviderLiveTest
+{
+ public MerseyProviderLiveTest()
+ {
+ super(new MerseyProvider());
+ }
+
+ @Test
+ public void nearbyStations() throws Exception
+ {
+ final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "4017846"));
+ print(result);
+ }
+
+ @Test
+ public void nearbyStationsByCoordinate() throws Exception
+ {
+ final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.ADDRESS, 53401112, -2958903));
+ print(result);
+ }
+
+ @Test
+ public void nearbyLocationsByCoordinate() throws Exception
+ {
+ final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION, LocationType.POI), new Location(
+ LocationType.ADDRESS, 53401112, -2958903));
+ print(result);
+ }
+
+ @Test
+ public void queryDepartures() throws Exception
+ {
+ final QueryDeparturesResult result = queryDepartures("4017846", false);
+ print(result);
+ }
+
+ @Test
+ public void queryDeparturesInvalidStation() throws Exception
+ {
+ final QueryDeparturesResult resultLive = queryDepartures("999999", false);
+ assertEquals(QueryDeparturesResult.Status.INVALID_STATION, resultLive.status);
+ }
+
+ @Test
+ public void suggestLocations() throws Exception
+ {
+ final SuggestLocationsResult result = suggestLocations("Liverpool");
+ print(result);
+ }
+
+ @Test
+ public void shortTrip() throws Exception
+ {
+ final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "4017846", 53401672, -2958720, "Liverpool", "Orphan Street"),
+ null, new Location(LocationType.STATION, "4027286", 53397324, -2961676, "Liverpool", "Womens Hospital"), 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);
+ }
+}