mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 08:10:46 +00:00
Consolidate Frankfurt into Hesse
This commit is contained in:
parent
008c0f6eb5
commit
0b17a9eb47
5 changed files with 240 additions and 475 deletions
|
@ -26,7 +26,7 @@ public enum NetworkId
|
|||
RT,
|
||||
|
||||
// Germany
|
||||
DB, BVG, VBB, RMV, NVV, BAYERN, MVV, INVG, AVV, VGN, VVM, VMV, HVV, SH, GVH, BSVAG, BSAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VRT, VVS, NALDO, DING, KVV, VAGFR, NVBW, VVV,
|
||||
DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV, VGN, VVM, VMV, HVV, SH, GVH, BSVAG, BSAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VRT, VVS, NALDO, DING, KVV, VAGFR, NVBW, VVV,
|
||||
|
||||
// Austria
|
||||
OEBB, VOR, LINZ, SVV, VVT, VMOBIL, IVB, STV,
|
||||
|
|
|
@ -18,13 +18,19 @@
|
|||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.util.StringReplaceReader;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
|
@ -32,11 +38,11 @@ import de.schildbach.pte.dto.QueryDeparturesResult;
|
|||
public class NvvProvider extends AbstractHafasProvider
|
||||
{
|
||||
public static final NetworkId NETWORK_ID = NetworkId.NVV;
|
||||
private static final String API_BASE = "http://auskunft.nvv.de/nvv/bin/jp/";
|
||||
private static final String API_BASE = "http://auskunft.nvv.de/auskunft/bin/jp/";
|
||||
|
||||
public NvvProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", null, API_BASE + "query.exe/dn", 17, null, UTF_8, UTF_8);
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 16, null, UTF_8, null);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
@ -47,7 +53,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.AUTOCOMPLETE_ONE_LINE || capability == Capability.TRIPS)
|
||||
if (capability == Capability.AUTOCOMPLETE_ONE_LINE || capability == Capability.DEPARTURES || capability == Capability.TRIPS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -58,13 +64,13 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Zug ICE
|
||||
productBits.setCharAt(1, '1'); // Zug
|
||||
productBits.setCharAt(0, '1'); // ICE
|
||||
productBits.setCharAt(1, '1'); // Zug, scheinbar IC?
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Zug Nahverkehr
|
||||
productBits.setCharAt(10, '1'); // RegioTram
|
||||
productBits.setCharAt(2, '1'); // Zug
|
||||
productBits.setCharAt(10, '1'); // Zug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
|
@ -76,7 +82,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Tram
|
||||
productBits.setCharAt(5, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
|
@ -85,11 +91,11 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
productBits.setCharAt(9, '1'); // AST/Rufbus
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Schiff
|
||||
productBits.setCharAt(8, '1'); // Fähre/Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
|
@ -100,14 +106,48 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Kassel" };
|
||||
@Override
|
||||
protected char intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return 'I';
|
||||
if (value == 2)
|
||||
return 'I';
|
||||
if (value == 4)
|
||||
return 'R';
|
||||
if (value == 8)
|
||||
return 'S';
|
||||
if (value == 16)
|
||||
return 'U';
|
||||
if (value == 32)
|
||||
return 'T';
|
||||
if (value == 64)
|
||||
return 'B';
|
||||
if (value == 128)
|
||||
return 'B';
|
||||
if (value == 256)
|
||||
return 'F';
|
||||
if (value == 512)
|
||||
return 'P';
|
||||
if (value == 1024)
|
||||
return 'R';
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen",
|
||||
"Darmstadt", "Aschaffenburg", "Berlin", "Fulda" };
|
||||
|
||||
@Override
|
||||
protected String[] splitPlaceAndName(final String name)
|
||||
{
|
||||
for (final String place : PLACES)
|
||||
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
|
||||
{
|
||||
if (name.startsWith(place + " - "))
|
||||
return new String[] { place, name.substring(place.length() + 3) };
|
||||
else if (name.startsWith(place + " ") || name.startsWith(place + "-"))
|
||||
return new String[] { place, name.substring(place.length() + 1) };
|
||||
}
|
||||
|
||||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
@ -122,6 +162,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
uri.append("&look_maxno=").append(maxStations != 0 ? maxStations : 200);
|
||||
uri.append("&look_maxdist=").append(maxDistance != 0 ? maxDistance : 5000);
|
||||
uri.append("&look_stopclass=").append(allProductsInt());
|
||||
uri.append("&look_nv=get_stopweight|yes");
|
||||
uri.append("&look_x=").append(location.lon);
|
||||
uri.append("&look_y=").append(location.lat);
|
||||
|
||||
|
@ -130,7 +171,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append("?near=Anzeigen");
|
||||
uri.append("?L=vs_rmv&near=Anzeigen");
|
||||
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
|
||||
uri.append("&input=").append(location.id);
|
||||
|
||||
|
@ -142,7 +183,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, boolean equivs) throws IOException
|
||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlQueryDeparturesParameters(stationId));
|
||||
|
@ -150,9 +191,44 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
return xmlQueryDepartures(uri.toString(), stationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCustomReplaces(final StringReplaceReader reader)
|
||||
{
|
||||
reader.replace("<br />", " ");
|
||||
reader.replace("<ul>", " ");
|
||||
reader.replace("</ul>", " ");
|
||||
reader.replace("<li>", " ");
|
||||
reader.replace("</li>", " ");
|
||||
reader.replace("<b>", " ");
|
||||
reader.replace("</b>", " ");
|
||||
}
|
||||
|
||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
return xmlMLcReq(constraint);
|
||||
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||
uri.append(jsonGetStopsParameters(constraint));
|
||||
|
||||
return jsonGetStops(uri.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendCustomTripsQueryBinaryUri(final StringBuilder uri)
|
||||
{
|
||||
uri.append("&h2g-direct=11");
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final int numTrips, final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility,
|
||||
final Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsBinary(from, via, to, date, dep, numTrips, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later, final int numTrips) throws IOException
|
||||
{
|
||||
return queryMoreTripsBinary(contextObj, later, numTrips);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,8 +239,23 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
if ("U-BAHN".equals(ucType))
|
||||
return 'U';
|
||||
|
||||
if ("B".equals(ucType))
|
||||
return 'B';
|
||||
if ("BUFB".equals(ucType)) // BuFB
|
||||
return 'B';
|
||||
if ("BUVB".equals(ucType)) // BuVB
|
||||
return 'B';
|
||||
if ("LTAXI".equals(ucType))
|
||||
return 'B';
|
||||
if ("BN".equals(ucType)) // BN Venus
|
||||
return 'B';
|
||||
if ("ASOF".equals(ucType))
|
||||
return 'B';
|
||||
if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich
|
||||
return 'B';
|
||||
|
||||
if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt
|
||||
return 'P';
|
||||
|
||||
final char t = super.normalizeType(type);
|
||||
if (t != 0)
|
||||
|
|
|
@ -1,266 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2013 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.util.StringReplaceReader;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class RmvProvider extends AbstractHafasProvider
|
||||
{
|
||||
public static final NetworkId NETWORK_ID = NetworkId.RMV;
|
||||
private static final String API_BASE = "http://auskunft.nvv.de/auskunft/bin/jp/";
|
||||
|
||||
public RmvProvider()
|
||||
{
|
||||
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 16, null, UTF_8, null);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
{
|
||||
return NETWORK_ID;
|
||||
}
|
||||
|
||||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.AUTOCOMPLETE_ONE_LINE || capability == Capability.DEPARTURES || capability == Capability.TRIPS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE
|
||||
productBits.setCharAt(1, '1'); // Zug, scheinbar IC?
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Zug
|
||||
productBits.setCharAt(10, '1'); // Zug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Niederflurbus
|
||||
productBits.setCharAt(7, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // AST/Rufbus
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Fähre/Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return 'I';
|
||||
if (value == 2)
|
||||
return 'I';
|
||||
if (value == 4)
|
||||
return 'R';
|
||||
if (value == 8)
|
||||
return 'S';
|
||||
if (value == 16)
|
||||
return 'U';
|
||||
if (value == 32)
|
||||
return 'T';
|
||||
if (value == 64)
|
||||
return 'B';
|
||||
if (value == 128)
|
||||
return 'B';
|
||||
if (value == 256)
|
||||
return 'F';
|
||||
if (value == 512)
|
||||
return 'P';
|
||||
if (value == 1024)
|
||||
return 'R';
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen",
|
||||
"Darmstadt", "Aschaffenburg", "Berlin", "Fulda" };
|
||||
|
||||
@Override
|
||||
protected String[] splitPlaceAndName(final String name)
|
||||
{
|
||||
for (final String place : PLACES)
|
||||
{
|
||||
if (name.startsWith(place + " - "))
|
||||
return new String[] { place, name.substring(place.length() + 3) };
|
||||
else if (name.startsWith(place + " ") || name.startsWith(place + "-"))
|
||||
return new String[] { place, name.substring(place.length() + 1) };
|
||||
}
|
||||
|
||||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append('y');
|
||||
uri.append("?performLocating=2&tpl=stop2json");
|
||||
uri.append("&look_maxno=").append(maxStations != 0 ? maxStations : 200);
|
||||
uri.append("&look_maxdist=").append(maxDistance != 0 ? maxDistance : 5000);
|
||||
uri.append("&look_stopclass=").append(allProductsInt());
|
||||
uri.append("&look_nv=get_stopweight|yes");
|
||||
uri.append("&look_x=").append(location.lon);
|
||||
uri.append("&look_y=").append(location.lat);
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append("?L=vs_rmv&near=Anzeigen");
|
||||
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
|
||||
uri.append("&input=").append(location.id);
|
||||
|
||||
return htmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location.toDebugString());
|
||||
}
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final int stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlQueryDeparturesParameters(stationId));
|
||||
|
||||
return xmlQueryDepartures(uri.toString(), stationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCustomReplaces(final StringReplaceReader reader)
|
||||
{
|
||||
reader.replace("<br />", " ");
|
||||
reader.replace("<ul>", " ");
|
||||
reader.replace("</ul>", " ");
|
||||
reader.replace("<li>", " ");
|
||||
reader.replace("</li>", " ");
|
||||
reader.replace("<b>", " ");
|
||||
reader.replace("</b>", " ");
|
||||
}
|
||||
|
||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||
uri.append(jsonGetStopsParameters(constraint));
|
||||
|
||||
return jsonGetStops(uri.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendCustomTripsQueryBinaryUri(final StringBuilder uri)
|
||||
{
|
||||
uri.append("&h2g-direct=11");
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final int numTrips, final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility,
|
||||
final Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsBinary(from, via, to, date, dep, numTrips, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later, final int numTrips) throws IOException
|
||||
{
|
||||
return queryMoreTripsBinary(contextObj, later, numTrips);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char normalizeType(final String type)
|
||||
{
|
||||
final String ucType = type.toUpperCase();
|
||||
|
||||
if ("U-BAHN".equals(ucType))
|
||||
return 'U';
|
||||
|
||||
if ("B".equals(ucType))
|
||||
return 'B';
|
||||
if ("BUFB".equals(ucType)) // BuFB
|
||||
return 'B';
|
||||
if ("BUVB".equals(ucType)) // BuVB
|
||||
return 'B';
|
||||
if ("LTAXI".equals(ucType))
|
||||
return 'B';
|
||||
if ("BN".equals(ucType)) // BN Venus
|
||||
return 'B';
|
||||
if ("ASOF".equals(ucType))
|
||||
return 'B';
|
||||
if ("AT".equals(ucType)) // Anschluß Sammel Taxi, Anmeldung nicht erforderlich
|
||||
return 'B';
|
||||
|
||||
if ("MOFA".equals(ucType)) // Mobilfalt-Fahrt
|
||||
return 'P';
|
||||
|
||||
final char t = super.normalizeType(type);
|
||||
if (t != 0)
|
||||
return t;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -45,13 +48,21 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void nearbyStations() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3011245), 0, 0);
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3000001), 0, 0);
|
||||
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsByCoordinate() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 50108625, 8669604), 0, 0);
|
||||
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsByCoordinateKassel() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 51318447, 9496250), 0, 0);
|
||||
|
||||
|
@ -61,9 +72,25 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void queryDepartures() throws Exception
|
||||
{
|
||||
final QueryDeparturesResult result = provider.queryDepartures(3011245, 0, false);
|
||||
|
||||
final QueryDeparturesResult result = provider.queryDepartures(3000408, 0, false);
|
||||
print(result);
|
||||
|
||||
final QueryDeparturesResult result2 = provider.queryDepartures(3000010, 0, false);
|
||||
print(result2);
|
||||
|
||||
final QueryDeparturesResult result3 = provider.queryDepartures(3015989, 0, false);
|
||||
print(result3);
|
||||
|
||||
final QueryDeparturesResult result4 = provider.queryDepartures(3000139, 0, false);
|
||||
print(result4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Flughafen");
|
||||
|
||||
print(autocompletes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,8 +101,86 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
print(autocompletes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autocompleteUmlaut() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("könig");
|
||||
|
||||
print(autocompletes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortTrip() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, 3000001, null, "Hauptwache"), null, new Location(
|
||||
LocationType.STATION, 3000912, null, "Südbahnhof"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||
assertTrue(result.trips.size() > 0);
|
||||
|
||||
if (!result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
|
||||
if (!laterResult.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
|
||||
System.out.println(later2Result);
|
||||
|
||||
if (!later2Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later3Result = queryMoreTrips(later2Result.context, true);
|
||||
System.out.println(later3Result);
|
||||
|
||||
if (!later3Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later4Result = queryMoreTrips(later3Result.context, true);
|
||||
System.out.println(later4Result);
|
||||
|
||||
if (!later4Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later5Result = queryMoreTrips(later4Result.context, true);
|
||||
System.out.println(later5Result);
|
||||
|
||||
if (!later5Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later6Result = queryMoreTrips(later5Result.context, true);
|
||||
System.out.println(later6Result);
|
||||
|
||||
if (!result.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
|
||||
System.out.println(earlierResult);
|
||||
|
||||
if (!earlierResult.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlier2Result = queryMoreTrips(earlierResult.context, false);
|
||||
System.out.println(earlier2Result);
|
||||
|
||||
if (!earlier2Result.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlier3Result = queryMoreTrips(earlier2Result.context, false);
|
||||
System.out.println(earlier3Result);
|
||||
|
||||
if (!earlier3Result.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlier4Result = queryMoreTrips(earlier3Result.context, false);
|
||||
System.out.println(earlier4Result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortTripKassel() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, 2200007, null, "Kassel Wilhelmshöhe"), null, new Location(
|
||||
LocationType.STATION, 2200278, null, "Kassel Wilhelmshöher Weg"), new Date(), true, Product.ALL, WalkSpeed.NORMAL,
|
||||
|
@ -84,4 +189,29 @@ public class NvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slowTrip() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, 3029079, 50017679, 8229480, "Mainz", "An den Dünen"), null,
|
||||
new Location(LocationType.STATION, 3013508, 50142890, 8895203, "Hanau", "Beethovenplatz"), new Date(), true, Product.ALL,
|
||||
WalkSpeed.NORMAL, Accessibility.BARRIER_FREE);
|
||||
System.out.println(result);
|
||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||
assertTrue(result.trips.size() > 0);
|
||||
|
||||
if (!result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortTripByName() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, 0, null, "Frankfurt Bockenheimer Warte!"), null, new Location(
|
||||
LocationType.ANY, 0, null, "Frankfurt Hauptbahnhof!"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010-2013 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.schildbach.pte.NetworkProvider.Accessibility;
|
||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||
import de.schildbach.pte.RmvProvider;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class RmvProviderLiveTest extends AbstractProviderLiveTest
|
||||
{
|
||||
public RmvProviderLiveTest()
|
||||
{
|
||||
super(new RmvProvider());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStations() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3000001), 0, 0);
|
||||
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsByCoordinate() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 50108625, 8669604), 0, 0);
|
||||
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDepartures() throws Exception
|
||||
{
|
||||
final QueryDeparturesResult result = provider.queryDepartures(3000408, 0, false);
|
||||
print(result);
|
||||
|
||||
final QueryDeparturesResult result2 = provider.queryDepartures(3000010, 0, false);
|
||||
print(result2);
|
||||
|
||||
final QueryDeparturesResult result3 = provider.queryDepartures(3015989, 0, false);
|
||||
print(result3);
|
||||
|
||||
final QueryDeparturesResult result4 = provider.queryDepartures(3000139, 0, false);
|
||||
print(result4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Flughafen");
|
||||
|
||||
print(autocompletes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autocompleteUmlaut() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("könig");
|
||||
|
||||
print(autocompletes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortTrip() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, 3000001, null, "Hauptwache"), null, new Location(
|
||||
LocationType.STATION, 3000912, null, "Südbahnhof"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||
assertTrue(result.trips.size() > 0);
|
||||
|
||||
if (!result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
|
||||
if (!laterResult.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
|
||||
System.out.println(later2Result);
|
||||
|
||||
if (!later2Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later3Result = queryMoreTrips(later2Result.context, true);
|
||||
System.out.println(later3Result);
|
||||
|
||||
if (!later3Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later4Result = queryMoreTrips(later3Result.context, true);
|
||||
System.out.println(later4Result);
|
||||
|
||||
if (!later4Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later5Result = queryMoreTrips(later4Result.context, true);
|
||||
System.out.println(later5Result);
|
||||
|
||||
if (!later5Result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult later6Result = queryMoreTrips(later5Result.context, true);
|
||||
System.out.println(later6Result);
|
||||
|
||||
if (!result.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
|
||||
System.out.println(earlierResult);
|
||||
|
||||
if (!earlierResult.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlier2Result = queryMoreTrips(earlierResult.context, false);
|
||||
System.out.println(earlier2Result);
|
||||
|
||||
if (!earlier2Result.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlier3Result = queryMoreTrips(earlier2Result.context, false);
|
||||
System.out.println(earlier3Result);
|
||||
|
||||
if (!earlier3Result.context.canQueryEarlier())
|
||||
return;
|
||||
|
||||
final QueryTripsResult earlier4Result = queryMoreTrips(earlier3Result.context, false);
|
||||
System.out.println(earlier4Result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slowTrip() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, 3029079, 50017679, 8229480, "Mainz", "An den Dünen"), null,
|
||||
new Location(LocationType.STATION, 3013508, 50142890, 8895203, "Hanau", "Beethovenplatz"), new Date(), true, Product.ALL,
|
||||
WalkSpeed.NORMAL, Accessibility.BARRIER_FREE);
|
||||
System.out.println(result);
|
||||
assertEquals(QueryTripsResult.Status.OK, result.status);
|
||||
assertTrue(result.trips.size() > 0);
|
||||
|
||||
if (!result.context.canQueryLater())
|
||||
return;
|
||||
|
||||
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortTripByName() throws Exception
|
||||
{
|
||||
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, 0, null, "Frankfurt Bockenheimer Warte!"), null, new Location(
|
||||
LocationType.ANY, 0, null, "Frankfurt Hauptbahnhof!"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue