Migrate Göttingen & South Lower Saxony and Rostock into Bremen, Bremerhaven & Osnabrück. Also switch to JSON API and adapt Rostock styles.

This commit is contained in:
Andreas Schildbach 2015-10-03 20:43:02 +02:00
parent b70a3c5258
commit 6e03763192
9 changed files with 320 additions and 591 deletions

View file

@ -989,6 +989,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
else
throw new RuntimeException(err + ": " + errTxt);
}
else if ("1.10".equals(jsonApiVersion) && svcRes.toString().length() == 170)
{
// horrible hack, because API version 1.10 doesn't signal invalid stations via error
return new QueryDeparturesResult(header, QueryDeparturesResult.Status.INVALID_STATION);
}
final JSONObject res = svcRes.getJSONObject("res");
final JSONObject common = res.getJSONObject("common");
@ -1139,6 +1144,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
c.setTime(time);
final CharSequence outDate = jsonDate(c);
final CharSequence outTime = jsonTime(c);
final CharSequence outFrwdKey = "1.11".equals(jsonApiVersion) ? "outFrwd" : "frwd";
final CharSequence outFrwd = Boolean.toString(dep);
final CharSequence jnyFltr = productsString(products);
final CharSequence jsonContext = moreContext != null ? "\"ctxScr\":" + JSONObject.quote(moreContext) + "," : "";
@ -1148,10 +1154,10 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
+ "\"arrLocL\":[" + jsonLocation(to) + "]," //
+ "\"outDate\":\"" + outDate + "\"," //
+ "\"outTime\":\"" + outTime + "\"," //
+ "\"outFrwd\":" + outFrwd + "," //
+ "\"" + outFrwdKey + "\":" + outFrwd + "," //
+ "\"jnyFltrL\":[{\"value\":\"" + jnyFltr + "\",\"mode\":\"BIT\",\"type\":\"PROD\"}]," //
+ "\"gisFltrL\":[{\"mode\":\"FB\",\"profile\":{\"type\":\"F\",\"linDistRouting\":false,\"maxdist\":2000},\"type\":\"P\"}]," //
+ "\"getPolyline\":false,\"getPasslist\":true,\"liveSearch\":false,\"getIST\":false,\"getEco\":false,\"extChgTime\":-1,\"economic\":false}", //
+ "\"getPolyline\":false,\"getPasslist\":true,\"getIST\":false,\"getEco\":false,\"extChgTime\":-1}", //
false);
final String uri = checkNotNull(mgateEndpoint);

View file

@ -26,7 +26,7 @@ public enum NetworkId
RT,
// Germany
DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV, VGN, VVM, VMV, RSAG, HVV, SH, GVH, VSN, BSVAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VVS, DING, KVV, VAGFR, NVBW, VVV,
DB, BVG, VBB, NVV, BAYERN, MVV, INVG, AVV, VGN, VVM, VMV, HVV, SH, GVH, BSVAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VVS, DING, KVV, VAGFR, NVBW, VVV,
// Austria
OEBB, VAO, VOR, WIEN, LINZ, SVV, VVT, IVB, STV,

View file

@ -1,226 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package de.schildbach.pte;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import com.google.common.base.Charsets;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.Style.Shape;
/**
* @author Andreas Schildbach
*/
public class RsagProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://fahrplan.rsag-online.de/hafas/";
// http://fahrplanauskunft.verkehrsverbund-warnow.de/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public RsagProvider()
{
super(NetworkId.RSAG, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
private static final String[] PLACES = { "Rostock", "Warnemünde" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
{
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
return super.splitStationName(name);
}
@Override
protected String[] splitAddress(final String address)
{
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
return super.splitStationName(address);
}
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
protected void appendJsonGetStopsParameters(final StringBuilder uri, final CharSequence constraint, final int maxStops)
{
super.appendJsonGetStopsParameters(uri, constraint, maxStops);
uri.append("&REQ0JourneyStopsS0B=5");
uri.append("&REQ0JourneyStopsS0F=distinguishPerimeterFilter;12140548;54126457;50");
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Rostock
STYLES.put("SS1", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("SS2", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("SS3", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("T1", new Style(Shape.RECT, Style.parseColor("#712090"), Style.WHITE));
STYLES.put("TTram1", new Style(Shape.RECT, Style.parseColor("#712090"), Style.WHITE));
STYLES.put("T2", new Style(Shape.RECT, Style.parseColor("#d136a3"), Style.WHITE));
STYLES.put("TTram2", new Style(Shape.RECT, Style.parseColor("#d136a3"), Style.WHITE));
STYLES.put("T3", new Style(Shape.RECT, Style.parseColor("#870e12"), Style.WHITE));
STYLES.put("TTram3", new Style(Shape.RECT, Style.parseColor("#870e12"), Style.WHITE));
STYLES.put("T4", new Style(Shape.RECT, Style.parseColor("#f47216"), Style.WHITE));
STYLES.put("TTram4", new Style(Shape.RECT, Style.parseColor("#f47216"), Style.WHITE));
STYLES.put("T5", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("TTram5", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("T6", new Style(Shape.RECT, Style.parseColor("#fab20b"), Style.WHITE));
STYLES.put("TTram6", new Style(Shape.RECT, Style.parseColor("#fab20b"), Style.WHITE));
STYLES.put("B15", new Style(Style.parseColor("#008dc6"), Style.WHITE));
STYLES.put("B16", new Style(Style.parseColor("#1d3c85"), Style.WHITE));
STYLES.put("B17", new Style(Style.parseColor("#5784cc"), Style.WHITE));
STYLES.put("B18", new Style(Style.parseColor("#0887c9"), Style.WHITE));
STYLES.put("B19", new Style(Style.parseColor("#202267"), Style.WHITE));
STYLES.put("PALT19A", new Style(Style.WHITE, Style.parseColor("#202267")));
STYLES.put("PALT20A", new Style(Style.WHITE, Style.parseColor("#1959a6")));
STYLES.put("B22", new Style(Style.parseColor("#3871c1"), Style.WHITE));
STYLES.put("B23", new Style(Style.parseColor("#009ddb"), Style.WHITE));
STYLES.put("B25", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("B26", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("B27", new Style(Style.parseColor("#6e87cd"), Style.WHITE));
STYLES.put("B28", new Style(Style.parseColor("#4fc6f4"), Style.WHITE));
STYLES.put("PALT30A", new Style(Style.WHITE, Style.parseColor("#1082ce")));
STYLES.put("B31", new Style(Style.parseColor("#3a9fdf"), Style.WHITE));
STYLES.put("B33", new Style(Style.parseColor("#21518d"), Style.WHITE));
STYLES.put("B35", new Style(Style.parseColor("#1969bc"), Style.WHITE));
STYLES.put("PALT35A", new Style(Style.WHITE, Style.parseColor("#1969bc")));
STYLES.put("B36", new Style(Style.parseColor("#2c6d8b"), Style.WHITE));
STYLES.put("B37", new Style(Style.parseColor("#36aee8"), Style.WHITE));
STYLES.put("B38", new Style(Style.parseColor("#173e7d"), Style.WHITE));
STYLES.put("B45", new Style(Style.parseColor("#66cef5"), Style.WHITE));
STYLES.put("PALT45A", new Style(Style.WHITE, Style.parseColor("#66cef5")));
STYLES.put("B49", new Style(Style.parseColor("#166ab8"), Style.WHITE));
STYLES.put("BF1", new Style(Style.parseColor("#656263"), Style.WHITE));
STYLES.put("PALTF1A", new Style(Style.WHITE, Style.parseColor("#656263")));
STYLES.put("BF2", new Style(Style.parseColor("#9c9a9b"), Style.WHITE));
STYLES.put("B101", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B102", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("B103", new Style(Style.parseColor("#d18e00"), Style.WHITE));
STYLES.put("B104", new Style(Style.parseColor("#006f9d"), Style.WHITE));
STYLES.put("B105", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("B106", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B107", new Style(Style.parseColor("#a52240"), Style.WHITE));
STYLES.put("B108", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("B109", new Style(Style.parseColor("#a97ea6"), Style.WHITE));
STYLES.put("B110", new Style(Style.parseColor("#95c11e"), Style.WHITE));
STYLES.put("B111", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B112", new Style(Style.parseColor("#e50068"), Style.WHITE));
STYLES.put("B113", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B114", new Style(Style.parseColor("#925b00"), Style.WHITE));
STYLES.put("B115", new Style(Style.parseColor("#74b958"), Style.WHITE));
STYLES.put("B116", new Style(Style.parseColor("#0084ab"), Style.WHITE));
STYLES.put("B118", new Style(Style.parseColor("#4a96d1"), Style.WHITE));
STYLES.put("B119", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("B120", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("B121", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B123", new Style(Style.parseColor("#f39200"), Style.WHITE));
STYLES.put("B124", new Style(Style.parseColor("#004f9e"), Style.WHITE));
STYLES.put("B125", new Style(Style.parseColor("#e7ac00"), Style.WHITE));
STYLES.put("B128", new Style(Style.parseColor("#e50068"), Style.WHITE));
STYLES.put("B129", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B131", new Style(Style.parseColor("#12a537"), Style.WHITE));
STYLES.put("B132", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("B134", new Style(Style.parseColor("#008e5c"), Style.WHITE));
STYLES.put("B135", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B136", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B137", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("B138", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B139", new Style(Style.parseColor("#f8ac00"), Style.WHITE));
STYLES.put("B140", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("B200", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B201", new Style(Style.parseColor("#009440"), Style.WHITE));
STYLES.put("B203", new Style(Style.parseColor("#f49a00"), Style.WHITE));
STYLES.put("B204", new Style(Style.parseColor("#9fc41c"), Style.WHITE));
STYLES.put("B205", new Style(Style.parseColor("#dc6ba5"), Style.WHITE));
STYLES.put("B208", new Style(Style.parseColor("#004f94"), Style.WHITE));
STYLES.put("B210", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B211", new Style(Style.parseColor("#95c11e"), Style.WHITE));
STYLES.put("B213", new Style(Style.parseColor("#a777b2"), Style.WHITE));
STYLES.put("B215", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("B216", new Style(Style.parseColor("#fabd5d"), Style.WHITE));
STYLES.put("B220", new Style(Style.parseColor("#0090d6"), Style.WHITE));
STYLES.put("B221", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B222", new Style(Style.parseColor("#ef87b5"), Style.WHITE));
STYLES.put("B223", new Style(Style.parseColor("#f7a600"), Style.WHITE));
STYLES.put("B224", new Style(Style.parseColor("#004f9e"), Style.WHITE));
STYLES.put("B228", new Style(Style.parseColor("#003d7c"), Style.WHITE));
STYLES.put("B229", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B230", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("B231", new Style(Style.parseColor("#00843d"), Style.WHITE));
STYLES.put("B232", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B233", new Style(Style.parseColor("#113274"), Style.WHITE));
STYLES.put("B234", new Style(Style.parseColor("#ea5197"), Style.WHITE));
STYLES.put("B235", new Style(Style.parseColor("#ba0066"), Style.WHITE));
STYLES.put("B240", new Style(Style.parseColor("#942642"), Style.WHITE));
STYLES.put("B241", new Style(Style.parseColor("#ea5197"), Style.WHITE));
STYLES.put("B242", new Style(Style.parseColor("#f39200"), Style.WHITE));
STYLES.put("B243", new Style(Style.parseColor("#fbb900"), Style.WHITE));
STYLES.put("B244", new Style(Style.parseColor("#f7aa59"), Style.WHITE));
STYLES.put("B245", new Style(Style.parseColor("#76b72a"), Style.WHITE));
STYLES.put("B246", new Style(Style.parseColor("#f39a8b"), Style.WHITE));
STYLES.put("B247", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("B250", new Style(Style.parseColor("#0080c8"), Style.WHITE));
STYLES.put("B251", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("B252", new Style(Style.parseColor("#e41a18"), Style.WHITE));
STYLES.put("B260", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B270", new Style(Style.parseColor("#fabd5d"), Style.WHITE));
STYLES.put("B271", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("B272", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("B273", new Style(Style.parseColor("#004899"), Style.WHITE));
STYLES.put("B280", new Style(Style.parseColor("#e41a18"), Style.WHITE));
STYLES.put("B281", new Style(Style.parseColor("#f8ac00"), Style.WHITE));
STYLES.put("B282", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("B283", new Style(Style.parseColor("#eb609f"), Style.WHITE));
STYLES.put("B284", new Style(Style.parseColor("#951b81"), Style.WHITE));
STYLES.put("B285", new Style(Style.parseColor("#a42422"), Style.WHITE));
STYLES.put("B286", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("B290", new Style(Style.parseColor("#302683"), Style.WHITE));
STYLES.put("B291", new Style(Style.parseColor("#a61680"), Style.WHITE));
STYLES.put("B292", new Style(Style.parseColor("#c9be46"), Style.WHITE));
STYLES.put("F", new Style(Shape.CIRCLE, Style.parseColor("#17a4da"), Style.WHITE));
}
}

View file

@ -17,9 +17,28 @@
package de.schildbach.pte;
import java.io.IOException;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import javax.annotation.Nullable;
import com.google.common.base.Charsets;
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.QueryTripsContext;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.Style.Shape;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
@ -27,18 +46,25 @@ import de.schildbach.pte.dto.Product;
public class VbnProvider extends AbstractHafasProvider
{
private static final String API_BASE = "https://fahrplaner.vbn.de/hafas/";
// http://fahrplaner.vsninfo.de/hafas/
// http://fahrplan.rsag-online.de/hafas/
// http://fahrplanauskunft.verkehrsverbund-warnow.de/bin/
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public VbnProvider()
public VbnProvider(final String jsonApiAuthorization)
{
super(NetworkId.VBN, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonApiVersion("1.10");
setJsonApiClient("{\"id\":\"VBN\"}");
setJsonApiAuthorization(jsonApiAuthorization);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
setStyles(STYLES);
}
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Osnabrück", "Göttingen" };
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Osnabrück", "Göttingen", "Rostock", "Warnemünde" };
@Override
protected String[] splitStationName(final String name)
@ -53,13 +79,189 @@ public class VbnProvider extends AbstractHafasProvider
}
@Override
protected Product normalizeType(final String type)
protected String[] splitAddress(final String address)
{
final String ucType = type.toUpperCase();
final Matcher m = P_SPLIT_NAME_FIRST_COMMA.matcher(address);
if (m.matches())
return new String[] { m.group(1), m.group(2) };
if ("SEILB".equals(ucType))
return Product.CABLECAR;
return super.splitAddress(address);
}
return super.normalizeType(type);
@Override
public Set<Product> defaultProducts()
{
return Product.ALL;
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.hasLocation())
return jsonLocGeoPos(types, location.lat, location.lon);
else
throw new IllegalArgumentException("cannot handle: " + location);
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
throws IOException
{
return jsonStationBoard(stationId, time, maxDepartures, equivs);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException
{
return jsonLocMatch(constraint);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
final @Nullable Set<Product> products, final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
{
return jsonTripSearch(from, to, date, dep, products, null);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException
{
final JsonContext jsonContext = (JsonContext) context;
return jsonTripSearch(jsonContext.from, jsonContext.to, jsonContext.date, jsonContext.dep, jsonContext.products,
later ? jsonContext.laterContext : jsonContext.earlierContext);
}
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
static
{
// Rostock
STYLES.put("DB Regio AG|SS1", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("DB Regio AG|SS2", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("DB Regio AG|SS3", new Style(Shape.CIRCLE, Style.parseColor("#009037"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T1", new Style(Shape.RECT, Style.parseColor("#712090"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T2", new Style(Shape.RECT, Style.parseColor("#d136a3"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T3", new Style(Shape.RECT, Style.parseColor("#870e12"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T4", new Style(Shape.RECT, Style.parseColor("#f47216"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T5", new Style(Shape.RECT, Style.parseColor("#ed1c24"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|T6", new Style(Shape.RECT, Style.parseColor("#fab20b"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B15", new Style(Style.parseColor("#008dc6"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B16", new Style(Style.parseColor("#1d3c85"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B17", new Style(Style.parseColor("#5784cc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B18", new Style(Style.parseColor("#0887c9"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B19", new Style(Style.parseColor("#202267"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 19A", new Style(Style.WHITE, Style.parseColor("#202267")));
STYLES.put("Rostocker Straßenbahn AG|PRFT 20A", new Style(Style.WHITE, Style.parseColor("#1959a6")));
STYLES.put("Rostocker Straßenbahn AG|B22", new Style(Style.parseColor("#3871c1"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B23", new Style(Style.parseColor("#009ddb"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B25", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B26", new Style(Style.parseColor("#0994dc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B27", new Style(Style.parseColor("#6e87cd"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B28", new Style(Style.parseColor("#4fc6f4"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 30A", new Style(Style.WHITE, Style.parseColor("#1082ce")));
STYLES.put("Rostocker Straßenbahn AG|B31", new Style(Style.parseColor("#3a9fdf"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B33", new Style(Style.parseColor("#21518d"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B35", new Style(Style.parseColor("#1969bc"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 35A", new Style(Style.WHITE, Style.parseColor("#1969bc")));
STYLES.put("Rostocker Straßenbahn AG|B36", new Style(Style.parseColor("#2c6d8b"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B37", new Style(Style.parseColor("#36aee8"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B38", new Style(Style.parseColor("#173e7d"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|B45", new Style(Style.parseColor("#66cef5"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT 45A", new Style(Style.WHITE, Style.parseColor("#66cef5")));
STYLES.put("Rostocker Straßenbahn AG|B49", new Style(Style.parseColor("#166ab8"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|BF1", new Style(Style.parseColor("#656263"), Style.WHITE));
STYLES.put("Rostocker Straßenbahn AG|PRFT F1A", new Style(Style.WHITE, Style.parseColor("#656263")));
STYLES.put("Rostocker Straßenbahn AG|BF2", new Style(Style.parseColor("#9c9a9b"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B101", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B102", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B103", new Style(Style.parseColor("#d18e00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B104", new Style(Style.parseColor("#006f9d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B105", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B106", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B107", new Style(Style.parseColor("#a52240"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B108", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B109", new Style(Style.parseColor("#a97ea6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B110", new Style(Style.parseColor("#95c11e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B111", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B112", new Style(Style.parseColor("#e50068"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B113", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B114", new Style(Style.parseColor("#925b00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B115", new Style(Style.parseColor("#74b958"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B116", new Style(Style.parseColor("#0084ab"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B118", new Style(Style.parseColor("#4a96d1"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B119", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B120", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B121", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B123", new Style(Style.parseColor("#f39200"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B124", new Style(Style.parseColor("#004f9e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B125", new Style(Style.parseColor("#e7ac00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B128", new Style(Style.parseColor("#e50068"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B129", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B131", new Style(Style.parseColor("#12a537"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B132", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B134", new Style(Style.parseColor("#008e5c"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B135", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B136", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B137", new Style(Style.parseColor("#ef7c00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B138", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B139", new Style(Style.parseColor("#f8ac00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B140", new Style(Style.parseColor("#c2a712"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B200", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B201", new Style(Style.parseColor("#009440"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B203", new Style(Style.parseColor("#f49a00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B204", new Style(Style.parseColor("#9fc41c"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B205", new Style(Style.parseColor("#dc6ba5"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B208", new Style(Style.parseColor("#004f94"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B210", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B211", new Style(Style.parseColor("#95c11e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B213", new Style(Style.parseColor("#a777b2"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B215", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B216", new Style(Style.parseColor("#fabd5d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B220", new Style(Style.parseColor("#0090d6"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B221", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B222", new Style(Style.parseColor("#ef87b5"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B223", new Style(Style.parseColor("#f7a600"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B224", new Style(Style.parseColor("#004f9e"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B228", new Style(Style.parseColor("#003d7c"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B229", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B230", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B231", new Style(Style.parseColor("#00843d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B232", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B233", new Style(Style.parseColor("#113274"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B234", new Style(Style.parseColor("#ea5197"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B235", new Style(Style.parseColor("#ba0066"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B240", new Style(Style.parseColor("#942642"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B241", new Style(Style.parseColor("#ea5197"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B242", new Style(Style.parseColor("#f39200"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B243", new Style(Style.parseColor("#fbb900"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B244", new Style(Style.parseColor("#f7aa59"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B245", new Style(Style.parseColor("#76b72a"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B246", new Style(Style.parseColor("#f39a8b"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B247", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B250", new Style(Style.parseColor("#0080c8"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B251", new Style(Style.parseColor("#009640"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B252", new Style(Style.parseColor("#e41a18"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B260", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B270", new Style(Style.parseColor("#fabd5d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B271", new Style(Style.parseColor("#e30513"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B272", new Style(Style.parseColor("#009ee3"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B273", new Style(Style.parseColor("#004899"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B280", new Style(Style.parseColor("#e41a18"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B281", new Style(Style.parseColor("#f8ac00"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B282", new Style(Style.parseColor("#005ca9"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B283", new Style(Style.parseColor("#eb609f"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B284", new Style(Style.parseColor("#951b81"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B285", new Style(Style.parseColor("#a42422"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B286", new Style(Style.parseColor("#e5007d"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B290", new Style(Style.parseColor("#302683"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B291", new Style(Style.parseColor("#a61680"), Style.WHITE));
STYLES.put("rebus Regionalbus Rostock GmbH|B292", new Style(Style.parseColor("#c9be46"), Style.WHITE));
STYLES.put("Rostocker Fähren|F", new Style(Shape.CIRCLE, Style.parseColor("#17a4da"), Style.WHITE));
}
}

View file

@ -1,96 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package de.schildbach.pte;
import java.io.IOException;
import java.util.EnumSet;
import com.google.common.base.Charsets;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Product;
/**
* @author Andreas Schildbach
*/
public class VsnProvider extends AbstractHafasProvider
{
private static final String API_BASE = "http://fahrplaner.vsninfo.de/hafas/";
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY, Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
public VsnProvider()
{
super(NetworkId.VSN, API_BASE, "dn", PRODUCTS_MAP);
setJsonGetStopsEncoding(Charsets.UTF_8);
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
}
private static final String[] PLACES = { "Göttingen" };
@Override
protected String[] splitStationName(final String name)
{
for (final String place : PLACES)
{
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
return new String[] { place, name.substring(place.length() + 1) };
}
return super.splitStationName(name);
}
@Override
protected String[] splitAddress(final String address)
{
return super.splitStationName(address);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
final int maxLocations) throws IOException
{
if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Anzeigen");
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
uri.append("&input=").append(normalizeStationId(location.id));
return htmlNearbyStations(uri.toString());
}
else
{
throw new IllegalArgumentException("cannot handle: " + location);
}
}
@Override
protected Product normalizeType(final String type)
{
final String ucType = type.toUpperCase();
if ("T84".equals(ucType))
return null;
return super.normalizeType(type);
}
}

View file

@ -1,131 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.RsagProvider;
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 RsagProviderLiveTest extends AbstractProviderLiveTest
{
public RsagProviderLiveTest()
{
super(new RsagProvider());
}
@Test
public void nearbyStations() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8010304"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(Location.coord(54078314, 12131715));
print(result);
}
@Test
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("8010304", 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 suggestLocations() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Rostock");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Lütten Klein");
print(result);
assertEquals("Lütten Klein", result.getLocations().get(0).name);
}
@Test
public void suggestLocationsCoverage() throws Exception
{
final SuggestLocationsResult rostockResult = suggestLocations("Rostock");
print(rostockResult);
assertThat(rostockResult.getLocations(), hasItem(new Location(LocationType.STATION, "8010304")));
final SuggestLocationsResult warnemuendeResult = suggestLocations("Warnemünde");
print(warnemuendeResult);
assertThat(warnemuendeResult.getLocations(), hasItem(new Location(LocationType.STATION, "8013236")));
}
@Test
public void suggestLocationsLocality() throws Exception
{
final SuggestLocationsResult result = suggestLocations("lange");
assertEquals("Rostock", result.getLocations().get(0).place);
assertEquals("Lange Straße", result.getLocations().get(0).name);
}
@Test
public void shortTrip() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"), null, new Location(
LocationType.STATION, "625398", null, "Bremerhaven"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripDateOutsideTimetablePeriod() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"), null, new Location(
LocationType.STATION, "625398", null, "Bremerhaven"), new Date(1155822689759l), true, Product.ALL, WalkSpeed.NORMAL,
Accessibility.NEUTRAL);
assertEquals(QueryTripsResult.Status.INVALID_DATE, result.status);
}
}

View file

@ -24,5 +24,6 @@ public final class Secrets
{
public static final String VGN_API_BASE = "insert vgn base here";
public static final String NAVITIA_AUTHORIZATION = "insert navitia authorization here";
public static final String VBN_JSON_API_AUTHORIZATION = "insert vao authorization here";
public static final String VAO_JSON_API_AUTHORIZATION = "insert vao authorization here";
}

View file

@ -17,7 +17,10 @@
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;
@ -41,28 +44,33 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest
{
public VbnProviderLiveTest()
{
super(new VbnProvider());
}
@Test
public void nearbyStations() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8000110"));
print(result);
super(new VbnProvider(Secrets.VBN_JSON_API_AUTHORIZATION));
}
@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51318447, 9496250));
print(result);
final NearbyLocationsResult result1 = queryNearbyStations(Location.coord(53086421, 8806388));
print(result1);
final NearbyLocationsResult result2 = queryNearbyStations(Location.coord(51536614, 9925673));
print(result2);
final NearbyLocationsResult result3 = queryNearbyStations(Location.coord(54078314, 12131715));
print(result3);
}
@Test
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("8000110", false);
print(result);
final QueryDeparturesResult result1 = queryDepartures("8000110", false);
print(result1);
final QueryDeparturesResult result2 = queryDepartures("8000128", false);
print(result2);
final QueryDeparturesResult result3 = queryDepartures("8010304", false);
print(result3);
}
@Test
@ -75,25 +83,97 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest
@Test
public void suggestLocations() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Coppengrave");
print(result);
final SuggestLocationsResult result1 = suggestLocations("Bremen");
print(result1);
final SuggestLocationsResult result2 = suggestLocations("Hannover");
print(result2);
final SuggestLocationsResult result3 = suggestLocations("Rostock");
print(result3);
}
@Test
public void suggestLocationsUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Göttingen Hauptbahnhof");
final SuggestLocationsResult result1 = suggestLocations("Göttingen Hauptbahnhof");
print(result1);
assertEquals("Göttingen", result1.getLocations().get(0).name);
final SuggestLocationsResult result2 = suggestLocations("Lütten Klein");
print(result2);
assertEquals("Lütten Klein", result2.getLocations().get(0).name);
}
@Test
public void suggestLocationsCoverage() throws Exception
{
final SuggestLocationsResult rostockResult = suggestLocations("Rostock");
print(rostockResult);
assertThat(rostockResult.getLocations(), hasItem(new Location(LocationType.STATION, "8010304")));
final SuggestLocationsResult warnemuendeResult = suggestLocations("Warnemünde");
print(warnemuendeResult);
assertThat(warnemuendeResult.getLocations(), hasItem(new Location(LocationType.STATION, "8013236")));
}
@Test
public void suggestLocationsLocality() throws Exception
{
final SuggestLocationsResult result = suggestLocations("lange straße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "708425", "Rostock", "Lange Straße")));
}
@Test
public void suggestLocationsWithoutCoordinatesInResult() throws Exception
{
final SuggestLocationsResult result = suggestLocations("aachen");
print(result);
assertEquals("Göttingen", result.getLocations().get(0).place);
}
@Test
public void shortTrip() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"), null, new Location(
LocationType.STATION, "625398", null, "Bremerhaven"), new Date(), true, Product.ALL, WalkSpeed.NORMAL, Accessibility.NEUTRAL);
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"), null,
new Location(LocationType.STATION, "625398", null, "Bremerhaven"), new Date(), true, Product.ALL, WalkSpeed.NORMAL,
Accessibility.NEUTRAL);
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);
if (!earlierResult.context.canQueryEarlier())
return;
final QueryTripsResult earlier2Result = queryMoreTrips(earlierResult.context, false);
print(earlier2Result);
}
@Test
public void shortTripGoettingen() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8000128", null, "Göttingen"), null,
new Location(LocationType.STATION, "1140061", null, "Göttingen Nikolausberger Weg"), new Date(), true, Product.ALL, WalkSpeed.NORMAL,
Accessibility.NEUTRAL);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@ -101,8 +181,8 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest
@Test
public void tripDateOutsideTimetablePeriod() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"), null, new Location(
LocationType.STATION, "625398", null, "Bremerhaven"), new Date(1155822689759l), true, Product.ALL, WalkSpeed.NORMAL,
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"), null,
new Location(LocationType.STATION, "625398", null, "Bremerhaven"), new Date(1155822689759l), true, Product.ALL, WalkSpeed.NORMAL,
Accessibility.NEUTRAL);
assertEquals(QueryTripsResult.Status.INVALID_DATE, result.status);
}

View file

@ -1,107 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.VsnProvider;
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 VsnProviderLiveTest extends AbstractProviderLiveTest
{
public VsnProviderLiveTest()
{
super(new VsnProvider());
}
@Test
public void nearbyStations() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8000128"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51536614, 9925673));
print(result);
}
@Test
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("8000128", 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 suggestLocations() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Hannover");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Göttingen");
print(result);
}
@Test
public void suggestLocationsWithoutCoordinatesInResult() throws Exception
{
final SuggestLocationsResult result = suggestLocations("aachen");
print(result);
}
@Test
public void shortTrip() throws Exception
{
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8000128", null, "Göttingen"), null, new Location(
LocationType.STATION, "1140061", null, "Göttingen Nikolausberger Weg"), new Date(), true, Product.ALL, WalkSpeed.NORMAL,
Accessibility.NEUTRAL);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}