mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 19:09:52 +00:00
Hafas: Declare individual product map for each provider, rather than implementing intToProduct() and setProductBits().
This commit is contained in:
parent
5048e826dc
commit
fb6e71ee2b
27 changed files with 136 additions and 1676 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
|
@ -30,7 +31,6 @@ import java.io.Reader;
|
|||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
|
@ -95,7 +95,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
protected final String stationBoardEndpoint;
|
||||
protected final String getStopEndpoint;
|
||||
protected final String queryEndpoint;
|
||||
private final int numProductBits;
|
||||
private Product[] productsMap;
|
||||
private @Nullable String accessId = null;
|
||||
private @Nullable String clientType = "ANDROID";
|
||||
private Charset jsonGetStopsEncoding;
|
||||
|
@ -162,21 +162,21 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
public AbstractHafasProvider(final NetworkId network, final String stationBoardEndpoint, final String getStopEndpoint,
|
||||
final String queryEndpoint, final int numProductBits)
|
||||
public AbstractHafasProvider(final NetworkId network, final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint,
|
||||
final Product[] productsMap)
|
||||
{
|
||||
this(network, stationBoardEndpoint, getStopEndpoint, queryEndpoint, numProductBits, Charsets.ISO_8859_1);
|
||||
this(network, stationBoardEndpoint, getStopEndpoint, queryEndpoint, productsMap, Charsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
public AbstractHafasProvider(final NetworkId network, final String stationBoardEndpoint, final String getStopEndpoint,
|
||||
final String queryEndpoint, final int numProductBits, final Charset jsonEncoding)
|
||||
public AbstractHafasProvider(final NetworkId network, final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint,
|
||||
final Product[] productsMap, final Charset jsonEncoding)
|
||||
{
|
||||
super(network);
|
||||
|
||||
this.stationBoardEndpoint = stationBoardEndpoint;
|
||||
this.getStopEndpoint = getStopEndpoint;
|
||||
this.queryEndpoint = queryEndpoint;
|
||||
this.numProductBits = numProductBits;
|
||||
this.productsMap = productsMap;
|
||||
this.jsonGetStopsEncoding = jsonEncoding;
|
||||
this.jsonNearbyLocationsEncoding = jsonEncoding;
|
||||
}
|
||||
|
@ -242,25 +242,52 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return true;
|
||||
}
|
||||
|
||||
protected final String allProductsString()
|
||||
protected final CharSequence productsString(final Set<Product> products)
|
||||
{
|
||||
final StringBuilder allProducts = new StringBuilder(numProductBits);
|
||||
for (int i = 0; i < numProductBits; i++)
|
||||
allProducts.append('1');
|
||||
return allProducts.toString();
|
||||
final StringBuilder productsStr = new StringBuilder(productsMap.length);
|
||||
for (int i = 0; i < productsMap.length; i++)
|
||||
{
|
||||
if (productsMap[i] != null && products.contains(productsMap[i]))
|
||||
productsStr.append('1');
|
||||
else
|
||||
productsStr.append('0');
|
||||
}
|
||||
return productsStr;
|
||||
}
|
||||
|
||||
protected final CharSequence allProductsString()
|
||||
{
|
||||
final StringBuilder productsStr = new StringBuilder(productsMap.length);
|
||||
for (int i = 0; i < productsMap.length; i++)
|
||||
productsStr.append('1');
|
||||
return productsStr;
|
||||
}
|
||||
|
||||
protected final int allProductsInt()
|
||||
{
|
||||
return (1 << numProductBits) - 1;
|
||||
return (1 << productsMap.length) - 1;
|
||||
}
|
||||
|
||||
protected Product intToProduct(final int value)
|
||||
protected final Product intToProduct(int value)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final int allProductsInt = allProductsInt();
|
||||
checkArgument(value < allProductsInt, "value " + value + " must be smaller than " + allProductsInt);
|
||||
|
||||
protected abstract void setProductBits(StringBuilder productBits, Product product);
|
||||
Product product = null;
|
||||
for (int i = productsMap.length - 1; i >= 0; i--)
|
||||
{
|
||||
final int v = 1 << i;
|
||||
if (value >= v)
|
||||
{
|
||||
if (product != null)
|
||||
throw new IllegalArgumentException("ambigous value: " + value);
|
||||
product = productsMap[i];
|
||||
value -= v;
|
||||
}
|
||||
}
|
||||
checkState(value == 0);
|
||||
return product;
|
||||
}
|
||||
|
||||
protected static final Pattern P_SPLIT_NAME_FIRST_COMMA = Pattern.compile("([^,]*), (.*)");
|
||||
protected static final Pattern P_SPLIT_NAME_LAST_COMMA = Pattern.compile("(.*), ([^,]*)");
|
||||
|
@ -779,7 +806,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
protected final QueryTripsResult queryTripsXml(Location from, @Nullable Location via, Location to, final Date date, final boolean dep,
|
||||
final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||
|
@ -817,18 +844,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
final Calendar c = new GregorianCalendar(timeZone);
|
||||
c.setTime(date);
|
||||
|
||||
final StringBuilder productsStr = new StringBuilder(numProductBits);
|
||||
final CharSequence productsStr;
|
||||
if (products != null)
|
||||
{
|
||||
for (int i = 0; i < numProductBits; i++)
|
||||
productsStr.append('0');
|
||||
for (final Product p : products)
|
||||
setProductBits(productsStr, p);
|
||||
}
|
||||
productsStr = productsString(products);
|
||||
else
|
||||
{
|
||||
productsStr.append(allProductsString());
|
||||
}
|
||||
productsStr = allProductsString();
|
||||
|
||||
final char bikeChar = (options != null && options.contains(Option.BIKE)) ? '1' : '0';
|
||||
|
||||
|
@ -1373,7 +1393,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
protected void appendQueryTripsBinaryParameters(final StringBuilder uri, final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Collection<Product> products, final @Nullable Accessibility accessibility,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options)
|
||||
{
|
||||
uri.append("?start=Suchen");
|
||||
|
@ -1411,18 +1431,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
appendDateTimeParameters(uri, date, "REQ0JourneyDate", "REQ0JourneyTime");
|
||||
|
||||
final StringBuilder productsStr = new StringBuilder(numProductBits);
|
||||
final CharSequence productsStr;
|
||||
if (products != null)
|
||||
{
|
||||
for (int i = 0; i < numProductBits; i++)
|
||||
productsStr.append('0');
|
||||
for (final Product p : products)
|
||||
setProductBits(productsStr, p);
|
||||
}
|
||||
productsStr = productsString(products);
|
||||
else
|
||||
{
|
||||
productsStr.append(allProductsString());
|
||||
}
|
||||
productsStr = allProductsString();
|
||||
uri.append("&REQ0JourneyProduct_prod_list_1=").append(productsStr);
|
||||
|
||||
if (accessibility != null && accessibility != Accessibility.NEUTRAL)
|
||||
|
@ -1449,7 +1462,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
private final static int QUERY_TRIPS_BINARY_BUFFER_SIZE = 384 * 1024;
|
||||
|
||||
protected final QueryTripsResult queryTripsBinary(Location from, @Nullable Location via, Location to, final Date date, final boolean dep,
|
||||
final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||
|
|
|
@ -30,88 +30,18 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
{
|
||||
private static final String API_BASE = "http://reiseauskunft.bahn.de/bin/";
|
||||
private static final String API_BASE_STATION_BOARD = "http://mobile.bahn.de/bin/mobil/";
|
||||
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, null, null,
|
||||
null, null };
|
||||
|
||||
public BahnProvider()
|
||||
{
|
||||
super(NetworkId.DB, API_BASE_STATION_BOARD + "bhftafel.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 14);
|
||||
super(NetworkId.DB, API_BASE_STATION_BOARD + "bhftafel.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP);
|
||||
|
||||
setStationBoardHasStationTable(false);
|
||||
setJsonGetStopsUseWeight(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.SUBWAY;
|
||||
if (value == 256)
|
||||
return Product.TRAM;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1');
|
||||
productBits.setCharAt(1, '1');
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1');
|
||||
productBits.setCharAt(3, '1');
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1');
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1');
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1');
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1');
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1');
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1');
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -39,83 +39,18 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
{
|
||||
private static final String API_BASE = "https://fahrinfo.bvg.de/Fahrinfo/bin/";
|
||||
private static final String API_BASE_STATION_BOARD = "http://bvg.hafas.de/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY,
|
||||
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.ON_DEMAND };
|
||||
|
||||
public BvgProvider()
|
||||
{
|
||||
super(NetworkId.BVG, API_BASE_STATION_BOARD + "stboard.exe/dn", API_BASE + "ajax-getstop.bin/dny", API_BASE + "query.bin/dn", 8,
|
||||
super(NetworkId.BVG, API_BASE_STATION_BOARD + "stboard.exe/dn", API_BASE + "ajax-getstop.bin/dny", API_BASE + "query.bin/dn", PRODUCTS_MAP,
|
||||
Charsets.UTF_8);
|
||||
|
||||
setJsonGetStopsUseWeight(false);
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.SUBWAY;
|
||||
if (value == 4)
|
||||
return Product.TRAM;
|
||||
if (value == 8)
|
||||
return Product.BUS;
|
||||
if (value == 16)
|
||||
return Product.FERRY;
|
||||
if (value == 32)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 64)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 128)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(5, '1');
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(6, '1');
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1');
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(1, '1');
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(2, '1');
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(3, '1');
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(7, '1');
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(4, '1');
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?");
|
||||
private static final Pattern P_SPLIT_NAME_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
|
||||
|
||||
|
|
|
@ -28,93 +28,19 @@ import de.schildbach.pte.dto.Product;
|
|||
public class DsbProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://mobil.rejseplanen.dk/mobil-bin/";
|
||||
|
||||
// http://dk.hafas.de/bin/fat/
|
||||
// http://mobil.rejseplanen.dk/mobil-bin/
|
||||
// http://www.dsb.dk/Rejseplan/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.BUS, Product.BUS, Product.BUS, Product.FERRY, Product.SUBWAY };
|
||||
|
||||
public DsbProvider()
|
||||
{
|
||||
super(NetworkId.DSB, API_BASE + "stboard.exe/mn", API_BASE + "ajax-getstop.exe/mn", API_BASE + "query.exe/dn", 11);
|
||||
super(NetworkId.DSB, API_BASE + "stboard.exe/mn", API_BASE + "ajax-getstop.exe/mn", API_BASE + "query.exe/dn", PRODUCTS_MAP);
|
||||
|
||||
setStationBoardHasStationTable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128)
|
||||
return Product.BUS;
|
||||
if (value == 256)
|
||||
return Product.BUS;
|
||||
if (value == 512)
|
||||
return Product.FERRY;
|
||||
if (value == 1024)
|
||||
return Product.SUBWAY;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Intercity
|
||||
productBits.setCharAt(1, '1'); // InterCityExpress
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Regionalzug
|
||||
productBits.setCharAt(3, '1'); // sonstige Züge
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(10, '1'); // Metro
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
productBits.setCharAt(6, '1'); // ExpressBus
|
||||
productBits.setCharAt(7, '1'); // Nachtbus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Telebus/andere
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Fähre
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] splitStationName(final String name)
|
||||
{
|
||||
|
|
|
@ -39,51 +39,15 @@ import de.schildbach.pte.dto.QueryTripsResult;
|
|||
public class EireannProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://journeyplanner.buseireann.ie/jp/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { null, null, null, Product.BUS };
|
||||
|
||||
public EireannProvider()
|
||||
{
|
||||
super(NetworkId.EIREANN, API_BASE + "stboard.exe/en", API_BASE + "ajax-getstop.exe/en", API_BASE + "query.exe/en", 4);
|
||||
super(NetworkId.EIREANN, API_BASE + "stboard.exe/en", API_BASE + "ajax-getstop.exe/en", API_BASE + "query.exe/en", PRODUCTS_MAP);
|
||||
|
||||
setStationBoardHasStationTable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(3, '1');
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@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,
|
||||
|
|
|
@ -60,14 +60,13 @@ import de.schildbach.pte.util.ParserUtils;
|
|||
public class InvgProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://fpa.invg.de/bin/";
|
||||
|
||||
// http://invg.hafas.de/bin/
|
||||
|
||||
private static final Product[] PRODUCTS_MAP = { null, null, null, null, null, null, null, null, null, null };
|
||||
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
|
||||
|
||||
public InvgProvider()
|
||||
{
|
||||
super(NetworkId.INVG, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
super(NetworkId.INVG, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setStationBoardCanDoEquivs(false);
|
||||
setStyles(STYLES);
|
||||
|
@ -83,12 +82,6 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
return super.hasCapability(capability);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Ingolstadt", "München" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,59 +38,11 @@ import de.schildbach.pte.dto.Product;
|
|||
public class JetProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://planner.jet.org.il/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { null, null, Product.TRAM, Product.BUS };
|
||||
|
||||
public JetProvider()
|
||||
{
|
||||
super(NetworkId.JET, API_BASE + "stboard.bin/yn", API_BASE + "ajax-getstop.bin/yn", API_BASE + "query.bin/yn", 4, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 4)
|
||||
return Product.TRAM;
|
||||
if (value == 8)
|
||||
return Product.BUS;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
super(NetworkId.JET, API_BASE + "stboard.bin/yn", API_BASE + "ajax-getstop.bin/yn", API_BASE + "query.bin/yn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,80 +29,12 @@ import de.schildbach.pte.dto.Product;
|
|||
public class LuProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://mobiliteitszentral.hafas.de/hafas/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
|
||||
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.BUS, Product.BUS };
|
||||
|
||||
public LuProvider()
|
||||
{
|
||||
super(NetworkId.LU, API_BASE + "stboard.exe/fn", API_BASE + "ajax-getstop.exe/fn", API_BASE + "query.exe/fn", 9, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128)
|
||||
return Product.BUS;
|
||||
if (value == 256)
|
||||
return Product.BUS;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1');
|
||||
productBits.setCharAt(6, '1');
|
||||
productBits.setCharAt(7, '1');
|
||||
productBits.setCharAt(8, '1');
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
super(NetworkId.LU, API_BASE + "stboard.exe/fn", API_BASE + "ajax-getstop.exe/fn", API_BASE + "query.exe/fn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,72 +35,16 @@ import de.schildbach.pte.util.StringReplaceReader;
|
|||
public class NasaProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://reiseauskunft.insa.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.TRAM, Product.BUS, Product.ON_DEMAND };
|
||||
|
||||
public NasaProvider()
|
||||
{
|
||||
super(NetworkId.NASA, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 8, Charsets.UTF_8);
|
||||
super(NetworkId.NASA, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setStationBoardHasLocation(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.TRAM;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128) // Rufbus
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@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'); // IC/EC
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // RE/RB
|
||||
productBits.setCharAt(7, '1'); // Tourismus-Züge
|
||||
productBits.setCharAt(2, '1'); // undokumentiert
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN || product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S/U
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.FERRY || product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] splitStationName(final String name)
|
||||
{
|
||||
|
|
|
@ -36,77 +36,16 @@ import de.schildbach.pte.dto.QueryTripsResult;
|
|||
public class NriProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://hafas.websrv05.reiseinfo.no/bin/dev/nri/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.BUS, Product.TRAM, Product.SUBWAY,
|
||||
Product.FERRY, Product.FERRY, Product.FERRY };
|
||||
|
||||
public NriProvider()
|
||||
{
|
||||
super(NetworkId.NRI, API_BASE + "stboard.exe/on", API_BASE + "ajax-getstop.exe/ony", API_BASE + "query.exe/on", 8);
|
||||
super(NetworkId.NRI, API_BASE + "stboard.exe/on", API_BASE + "ajax-getstop.exe/ony", API_BASE + "query.exe/on", PRODUCTS_MAP);
|
||||
|
||||
setJsonGetStopsEncoding(Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1) // Air
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.BUS;
|
||||
if (value == 8)
|
||||
return Product.TRAM;
|
||||
if (value == 16)
|
||||
return Product.SUBWAY;
|
||||
if (value == 32)
|
||||
return Product.FERRY;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.FERRY;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Flugzeug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(1, '1'); // Regionalverkehrszug
|
||||
productBits.setCharAt(7, '1'); // Tourismus-Züge
|
||||
productBits.setCharAt(2, '1'); // undokumentiert
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN || product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Express-Boot
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
productBits.setCharAt(7, '1'); // Fähre
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Oslo", "Bergen" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,90 +33,18 @@ import de.schildbach.pte.dto.Product;
|
|||
public class NsProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://hafas.bene-system.com/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 };
|
||||
private static final Pattern HTML_NEARBY_STATIONS_PATTERN = Pattern.compile("<tr bgcolor=\"#(E7EEF9|99BAE4)\">(.*?)</tr>", Pattern.DOTALL);
|
||||
|
||||
public NsProvider()
|
||||
{
|
||||
super(NetworkId.NS, API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 10);
|
||||
super(NetworkId.NS, API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", PRODUCTS_MAP);
|
||||
|
||||
setHtmlNearbyStationsPattern(HTML_NEARBY_STATIONS_PATTERN);
|
||||
setStationBoardHasLocation(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.SUBWAY;
|
||||
if (value == 256)
|
||||
return Product.TRAM;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // HST
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // IR/D
|
||||
productBits.setCharAt(3, '1');
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1');
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1');
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1');
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1');
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1');
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // boat
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
|
||||
final int maxLocations) throws IOException
|
||||
|
|
|
@ -35,89 +35,13 @@ import de.schildbach.pte.util.StringReplaceReader;
|
|||
public class NvvProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://auskunft.nvv.de/auskunft/bin/jp/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
|
||||
Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.BUS, Product.FERRY, Product.ON_DEMAND, Product.REGIONAL_TRAIN,
|
||||
Product.REGIONAL_TRAIN };
|
||||
|
||||
public NvvProvider()
|
||||
{
|
||||
super(NetworkId.NVV, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 12, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@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'); // IC/EC
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Regionalzug
|
||||
productBits.setCharAt(10, '1'); // Zug
|
||||
productBits.setCharAt(11, '1'); // RegioTram
|
||||
}
|
||||
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 Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBWAY;
|
||||
if (value == 32)
|
||||
return Product.TRAM;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128)
|
||||
return Product.BUS;
|
||||
if (value == 256)
|
||||
return Product.FERRY;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
if (value == 1024)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 2048)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
super(NetworkId.NVV, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen",
|
||||
|
|
|
@ -35,97 +35,18 @@ import de.schildbach.pte.dto.Product;
|
|||
public class OebbProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://fahrplan.oebb.at/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, 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.HIGH_SPEED_TRAIN, Product.ON_DEMAND, Product.HIGH_SPEED_TRAIN };
|
||||
|
||||
public OebbProvider()
|
||||
{
|
||||
super(NetworkId.OEBB, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/dn", 13);
|
||||
super(NetworkId.OEBB, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/dn", PRODUCTS_MAP);
|
||||
|
||||
setDominantPlanStopTime(true);
|
||||
setJsonGetStopsEncoding(Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128)
|
||||
return Product.FERRY;
|
||||
if (value == 256)
|
||||
return Product.SUBWAY;
|
||||
if (value == 512)
|
||||
return Product.TRAM;
|
||||
if (value == 1024) // Autoreisezug
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2048)
|
||||
return Product.ON_DEMAND;
|
||||
if (value == 4096)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // railjet/ICE
|
||||
productBits.setCharAt(1, '1'); // ÖBB EC/ÖBB IC
|
||||
productBits.setCharAt(2, '1'); // EC/IC
|
||||
productBits.setCharAt(10, '1'); // Autoreisezug
|
||||
productBits.setCharAt(12, '1'); // westbahn
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // D/EN
|
||||
productBits.setCharAt(4, '1'); // REX/R
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // S-Bahnen
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Busse
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(11, '1'); // Anrufpflichtige Verkehre
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Schiffe
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
|
||||
final int maxLocations) throws IOException
|
||||
|
|
|
@ -30,68 +30,12 @@ import de.schildbach.pte.util.StringReplaceReader;
|
|||
public class PlProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://rozklad.bilkom.pl/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
|
||||
Product.SUBURBAN_TRAIN, Product.BUS, Product.BUS, Product.FERRY };
|
||||
|
||||
public PlProvider()
|
||||
{
|
||||
super(NetworkId.PL, API_BASE + "stboard.exe/pn", API_BASE + "ajax-getstop.exe/pn", API_BASE + "query.exe/pn", 7, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 16) // Bus
|
||||
return Product.BUS;
|
||||
if (value == 32) // AST, SEV
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Kolej dużych prędkości
|
||||
productBits.setCharAt(1, '1'); // EC/IC/EIC/Ex
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // TLK/IR/RE/D/Posp.
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regio/Osobowe
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Metro
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Tramwaj
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // Autobus
|
||||
}
|
||||
else if (product == Product.FERRY || product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
super(NetworkId.PL, API_BASE + "stboard.exe/pn", API_BASE + "ajax-getstop.exe/pn", API_BASE + "query.exe/pn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Warszawa", "Kraków" };
|
||||
|
|
|
@ -34,89 +34,17 @@ import de.schildbach.pte.dto.Style.Shape;
|
|||
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 + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
super(NetworkId.RSAG, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.SUBWAY;
|
||||
if (value == 256)
|
||||
return Product.TRAM;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE, TGV, Thalys, etc.
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // sonstiger Schnellzug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalzug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anrufverkehre
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Fähre
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Rostock", "Warnemünde" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,61 +30,17 @@ import de.schildbach.pte.dto.Product;
|
|||
public class RtProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://railteam.hafas.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 RtProvider()
|
||||
{
|
||||
super(NetworkId.RT, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
super(NetworkId.RT, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setJsonNearbyLocationsEncoding(Charsets.ISO_8859_1);
|
||||
setStationBoardHasStationTable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -28,81 +28,16 @@ import de.schildbach.pte.dto.Product;
|
|||
public class SbbProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://fahrplan.sbb.ch/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
|
||||
Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS, Product.CABLECAR, Product.REGIONAL_TRAIN, Product.TRAM };
|
||||
|
||||
public SbbProvider()
|
||||
{
|
||||
super(NetworkId.SBB, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10);
|
||||
super(NetworkId.SBB, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP);
|
||||
|
||||
setStationBoardHasStationTable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.FERRY;
|
||||
if (value == 32)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128)
|
||||
return Product.CABLECAR;
|
||||
if (value == 256)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 512)
|
||||
return Product.TRAM;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE/TGV/IRJ
|
||||
productBits.setCharAt(1, '1'); // EC/IC
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // IR
|
||||
productBits.setCharAt(3, '1'); // RE/D
|
||||
productBits.setCharAt(8, '1'); // ARZ/EXT
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // S/SN/R
|
||||
}
|
||||
else if (product == Product.SUBWAY || product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Tram/Metro
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Seilbahn
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -32,93 +32,21 @@ import de.schildbach.pte.dto.Product;
|
|||
public class SeProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://samtrafiken.hafas.de/bin/";
|
||||
|
||||
// http://reseplanerare.resrobot.se/bin/
|
||||
// http://api.vasttrafik.se/bin/
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN, Product.BUS,
|
||||
Product.REGIONAL_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY, Product.FERRY, Product.REGIONAL_TRAIN, null, null,
|
||||
null };
|
||||
|
||||
public SeProvider()
|
||||
{
|
||||
super(NetworkId.SE, API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 14, Charsets.UTF_8);
|
||||
super(NetworkId.SE, API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setUseIso8601(true);
|
||||
setStationBoardHasStationTable(false);
|
||||
setStationBoardCanDoEquivs(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1) // Flyg
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2) // X2000
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8) // Expressbus
|
||||
return Product.BUS;
|
||||
if (value == 16)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 32) // Tunnelbana
|
||||
return Product.SUBWAY;
|
||||
if (value == 64) // Spårvagn
|
||||
return Product.TRAM;
|
||||
if (value == 128)
|
||||
return Product.BUS;
|
||||
if (value == 256)
|
||||
return Product.FERRY;
|
||||
if (value == 512) // Länstaxi
|
||||
return Product.FERRY;
|
||||
if (value == 1024) // Future
|
||||
return Product.REGIONAL_TRAIN;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Flyg
|
||||
productBits.setCharAt(1, '1'); // Snabbtåg
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Tåg
|
||||
productBits.setCharAt(4, '1'); // Lokaltåg
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Tunnelbana
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Spårvagn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Expressbuss
|
||||
productBits.setCharAt(7, '1'); // Buss
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Båt
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_NAME_PAREN = Pattern.compile("(.*) \\((.{3,}?) kn\\)");
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,48 +57,17 @@ import de.schildbach.pte.util.ParserUtils;
|
|||
public class SeptaProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://airs1.septa.org/bin/";
|
||||
|
||||
private static final Product[] PRODUCTS_MAP = { Product.SUBWAY, Product.TRAM, Product.BUS, Product.SUBURBAN_TRAIN };
|
||||
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
|
||||
|
||||
public SeptaProvider()
|
||||
{
|
||||
super(NetworkId.SEPTA, API_BASE + "stboard.exe/en", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/en", 4);
|
||||
super(NetworkId.SEPTA, API_BASE + "stboard.exe/en", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/en", PRODUCTS_MAP);
|
||||
|
||||
setStationBoardCanDoEquivs(false);
|
||||
setTimeZone("EST");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN || product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regional Rail
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Subway
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(1, '1'); // Trolley
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND || product == Product.FERRY || product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance,
|
||||
final int maxLocations) throws IOException
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -34,83 +31,12 @@ import de.schildbach.pte.dto.Product;
|
|||
public class ShProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://nah.sh.hafas.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 ShProvider()
|
||||
{
|
||||
super(NetworkId.SH, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.SUBWAY;
|
||||
if (value == 256)
|
||||
return Product.TRAM;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
super(NetworkId.SH, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Hamburg", "Kiel", "Lübeck", "Flensburg", "Neumünster" };
|
||||
|
|
|
@ -35,73 +35,19 @@ import de.schildbach.pte.dto.Product;
|
|||
public class SncbProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://www.belgianrail.be/jp/sncb-nmbs-routeplanner/";
|
||||
|
||||
// http://hari.b-rail.be/hafas/bin/
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, null, Product.HIGH_SPEED_TRAIN, null, null, Product.BUS,
|
||||
Product.REGIONAL_TRAIN, null, Product.SUBWAY, Product.BUS, Product.TRAM, null, null, null, null, null };
|
||||
|
||||
public SncbProvider()
|
||||
{
|
||||
super(NetworkId.SNCB, API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 16);
|
||||
super(NetworkId.SNCB, API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", PRODUCTS_MAP);
|
||||
|
||||
setJsonGetStopsEncoding(Charsets.UTF_8);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
setStationBoardHasLocation(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 256)
|
||||
return Product.SUBWAY;
|
||||
if (value == 512)
|
||||
return Product.BUS;
|
||||
if (value == 1024)
|
||||
return Product.TRAM;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(2, '1'); // IC/IR/P/ICT
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN || product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Zug
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Metro
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(10, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
productBits.setCharAt(9, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.FERRY || product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Antwerpen", "Gent", "Charleroi", "Liege", "Liège", "Brussel" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,79 +32,18 @@ import de.schildbach.pte.dto.Style.Shape;
|
|||
public class StockholmProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://reseplanerare.trafiken.nu/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS,
|
||||
Product.FERRY, Product.FERRY };
|
||||
|
||||
public StockholmProvider()
|
||||
{
|
||||
super(NetworkId.STOCKHOLM, API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 7);
|
||||
super(NetworkId.STOCKHOLM, API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", PRODUCTS_MAP);
|
||||
|
||||
setStyles(STYLES);
|
||||
setStationBoardHasStationTable(false);
|
||||
setStationBoardCanDoEquivs(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1) // Pendeltåg
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 2) // Tunnelbana
|
||||
return Product.SUBWAY;
|
||||
if (value == 4) // Lokalbanor
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8) // Bussar
|
||||
return Product.BUS;
|
||||
if (value == 16) // Flygbussar
|
||||
return Product.BUS;
|
||||
if (value == 32)
|
||||
return Product.FERRY;
|
||||
if (value == 64) // Waxholmsbåtar
|
||||
return Product.FERRY;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Lokalbanor
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Pendeltåg
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(1, '1'); // Tunnelbana
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Bussar
|
||||
productBits.setCharAt(4, '1'); // Flygbussar
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Waxholmsbåtar
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] splitStationName(final String name)
|
||||
{
|
||||
|
|
|
@ -33,77 +33,18 @@ import de.schildbach.pte.dto.Product;
|
|||
public class VbbProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://fahrinfo.vbb.de/bin/";
|
||||
private static final Set<Product> ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND = EnumSet.complementOf(EnumSet
|
||||
.of(Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND));
|
||||
private static final Product[] PRODUCTS_MAP = { Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM, Product.BUS, Product.FERRY,
|
||||
Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN };
|
||||
private static final Set<Product> ALL_EXCEPT_HIGHSPEED_AND_ONDEMAND = EnumSet
|
||||
.complementOf(EnumSet.of(Product.HIGH_SPEED_TRAIN, Product.ON_DEMAND));
|
||||
|
||||
public VbbProvider()
|
||||
{
|
||||
super(NetworkId.VBB, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 7, Charsets.UTF_8);
|
||||
super(NetworkId.VBB, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setJsonGetStopsUseWeight(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.SUBWAY;
|
||||
if (value == 4)
|
||||
return Product.TRAM;
|
||||
if (value == 8)
|
||||
return Product.BUS;
|
||||
if (value == 16)
|
||||
return Product.FERRY;
|
||||
if (value == 32)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 64)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(5, '1');
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(6, '1');
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1');
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(1, '1');
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(2, '1');
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(3, '1');
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(4, '1');
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_NAME_SU = Pattern.compile("(.*?)(?:\\s+\\((S|U|S\\+U)\\))?");
|
||||
private static final Pattern P_SPLIT_NAME_BUS = Pattern.compile("(.*?)(\\s+\\[[^\\]]+\\])?");
|
||||
|
||||
|
|
|
@ -27,83 +27,12 @@ import de.schildbach.pte.dto.Product;
|
|||
public class VbnProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "https://fahrplaner.vbn.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 VbnProvider()
|
||||
{
|
||||
super(NetworkId.VBN, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.SUBWAY;
|
||||
if (value == 256)
|
||||
return Product.TRAM;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
super(NetworkId.VBN, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Osnabrück", "Göttingen" };
|
||||
|
|
|
@ -32,61 +32,17 @@ import de.schildbach.pte.dto.Product;
|
|||
public class VgsProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://www.saarfahrplan.de/cgi-bin/"; // http://www.vgs-online.de/cgi-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.SUBWAY, Product.TRAM, Product.BUS, Product.CABLECAR, Product.ON_DEMAND,
|
||||
Product.BUS };
|
||||
|
||||
public VgsProvider()
|
||||
{
|
||||
super(NetworkId.VGS, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 11);
|
||||
super(NetworkId.VGS, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP);
|
||||
|
||||
setStationBoardHasStationTable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Bus
|
||||
productBits.setCharAt(10, '1'); // Schulbus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] splitStationName(final String name)
|
||||
{
|
||||
|
|
|
@ -33,83 +33,12 @@ import de.schildbach.pte.dto.Product;
|
|||
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 + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 32)
|
||||
return Product.BUS;
|
||||
if (value == 64)
|
||||
return Product.FERRY;
|
||||
if (value == 128)
|
||||
return Product.SUBWAY;
|
||||
if (value == 256)
|
||||
return Product.TRAM;
|
||||
if (value == 512)
|
||||
return Product.ON_DEMAND;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // sonstiger Schnellzug
|
||||
productBits.setCharAt(3, '1'); // Regionalzug
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == Product.BUS)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anrufverkehre
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
super(NetworkId.VSN, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Göttingen" };
|
||||
|
|
|
@ -34,83 +34,16 @@ import de.schildbach.pte.dto.Style.Shape;
|
|||
public class ZvvProvider extends AbstractHafasProvider
|
||||
{
|
||||
private static final String API_BASE = "http://online.fahrplan.zvv.ch/bin/";
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN, Product.REGIONAL_TRAIN,
|
||||
Product.REGIONAL_TRAIN, Product.FERRY, Product.SUBURBAN_TRAIN, Product.BUS, Product.CABLECAR, Product.SUBWAY, Product.TRAM };
|
||||
|
||||
public ZvvProvider()
|
||||
{
|
||||
super(NetworkId.ZVV, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, Charsets.UTF_8);
|
||||
super(NetworkId.ZVV, API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", PRODUCTS_MAP, Charsets.UTF_8);
|
||||
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Product intToProduct(final int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 2)
|
||||
return Product.HIGH_SPEED_TRAIN;
|
||||
if (value == 4)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 8)
|
||||
return Product.REGIONAL_TRAIN;
|
||||
if (value == 16)
|
||||
return Product.FERRY;
|
||||
if (value == 32)
|
||||
return Product.SUBURBAN_TRAIN;
|
||||
if (value == 64)
|
||||
return Product.BUS;
|
||||
if (value == 128)
|
||||
return Product.CABLECAR;
|
||||
if (value == 256)
|
||||
return Product.SUBWAY;
|
||||
if (value == 512)
|
||||
return Product.TRAM;
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final Product product)
|
||||
{
|
||||
if (product == Product.HIGH_SPEED_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE/EN/CNL/CIS/ES/MET/NZ/PEN/TGV/THA/X2
|
||||
productBits.setCharAt(1, '1'); // EuroCity/InterCity/InterCityNight/SuperCity
|
||||
}
|
||||
else if (product == Product.REGIONAL_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // InterRegio
|
||||
productBits.setCharAt(3, '1'); // Schnellzug/RegioExpress
|
||||
}
|
||||
else if (product == Product.SUBURBAN_TRAIN)
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // S-Bahn/StadtExpress/Eilzug/Regionalzug
|
||||
}
|
||||
else if (product == Product.SUBWAY)
|
||||
{
|
||||
}
|
||||
else if (product == Product.TRAM)
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Tram
|
||||
}
|
||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Postauto/Bus
|
||||
}
|
||||
else if (product == Product.FERRY)
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // Schiff/Fähre/Dampfschiff
|
||||
}
|
||||
else if (product == Product.CABLECAR)
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Luftseilbahn/Standseilbahn/Bergbahn
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] OPERATORS = { "SBB", "SZU" };
|
||||
private static final String[] PLACES = { "Zürich", "Winterthur" };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue