mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 17:39:49 +00:00
support product selection for XML API based connection queries
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@706 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
f442cd5ead
commit
e10e60cb41
22 changed files with 630 additions and 5 deletions
|
@ -115,6 +115,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected abstract void setProductBits(StringBuilder productBits, char product);
|
||||
|
||||
private static final Pattern P_SPLIT_ADDRESS = Pattern.compile("(\\d{4,5}\\s+[^,]+),\\s+(.*)");
|
||||
|
||||
protected String[] splitPlaceAndName(final String name)
|
||||
|
@ -636,10 +638,19 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
final Calendar c = new GregorianCalendar(timeZone());
|
||||
c.setTime(date);
|
||||
|
||||
final StringBuilder productsStr = new StringBuilder(numProductBits);
|
||||
for (int i = 0; i < numProductBits; i++)
|
||||
productsStr.append('0');
|
||||
for (final char p : products.toCharArray())
|
||||
setProductBits(productsStr, p);
|
||||
|
||||
final String request = "<ConReq>" //
|
||||
+ "<Start>"
|
||||
+ location(from)
|
||||
+ "<Prod bike=\"0\" couchette=\"0\" direct=\"0\" sleeper=\"0\"/></Start>" //
|
||||
+ "<Prod prod=\""
|
||||
+ productsStr
|
||||
+ "\" bike=\"0\" couchette=\"0\" direct=\"0\" sleeper=\"0\"/>" //
|
||||
+ "</Start>" //
|
||||
+ (via != null ? "<Via>" + location(via) + "</Via>" : "") //
|
||||
+ "<Dest>"
|
||||
+ location(to)
|
||||
|
@ -667,7 +678,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
private QueryConnectionsResult queryConnections(final String request, final Location from, final Location via, final Location to)
|
||||
throws IOException
|
||||
{
|
||||
// System.out.println(request);
|
||||
System.out.println(request);
|
||||
// ParserUtils.printXml(ParserUtils.scrape(apiUri, true, wrap(request), null, null));
|
||||
|
||||
InputStream is = null;
|
||||
|
|
|
@ -68,6 +68,12 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private final static Pattern P_NEARBY_STATIONS_BY_STATION = Pattern
|
||||
.compile("<a href=\"http://mobile\\.bahn\\.de/bin/mobil/bhftafel.exe/dn[^\"]*?evaId=(\\d*)&[^\"]*?\">([^<]*)</a>");
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.GregorianCalendar;
|
|||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -83,6 +82,12 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] splitPlaceAndName(final String name)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,12 @@ public class DsbProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -69,6 +69,12 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Ingolstadt", "München" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,6 +54,52 @@ public class LuProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // AST/Rufbus
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -66,6 +66,41 @@ public class NasaProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // RE/RB
|
||||
productBits.setCharAt(7, '1'); // Tourismus-Züge
|
||||
productBits.setCharAt(2, '1'); // undokumentiert
|
||||
}
|
||||
else if (product == 'S' || product == 'U')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S/U
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Bus
|
||||
}
|
||||
else if (product == 'F' || product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -53,6 +53,46 @@ public class NriProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Flugzeug
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(1, '1'); // Regionalverkehrszug
|
||||
productBits.setCharAt(7, '1'); // Tourismus-Züge
|
||||
productBits.setCharAt(2, '1'); // undokumentiert
|
||||
}
|
||||
else if (product == 'S' || product == 'T')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Bus
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Express-Boot
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
productBits.setCharAt(7, '1'); // Fähre
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Oslo", "Bergen" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,6 +66,12 @@ public class NsProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -69,6 +69,12 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -54,6 +54,40 @@ public class PlProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // EC/IC/EIC/Ex
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // TLK/IR/D
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == 'S' || product == 'T')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // Bus
|
||||
}
|
||||
else if (product == 'F' || product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Warszawa", "Kraków" };
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,6 +65,53 @@ public class RmvProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(1, '1'); // Zug
|
||||
productBits.setCharAt(2, '1'); // Zug
|
||||
productBits.setCharAt(10, '1'); // Zug
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Straßenbahn
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Niederflurbus
|
||||
productBits.setCharAt(7, '1'); // Bus
|
||||
}
|
||||
else if (product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // AST/Rufbus
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Fähre/Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Frankfurt (Main)", "Offenbach (Main)", "Mainz", "Wiesbaden", "Marburg", "Kassel", "Hanau", "Göttingen",
|
||||
"Darmstadt", "Aschaffenburg", "Berlin", "Fulda" };
|
||||
|
||||
|
|
|
@ -55,6 +55,52 @@ public class RtProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -57,6 +57,46 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // ICE/TGV/IRJ
|
||||
productBits.setCharAt(1, '1'); // EC/IC
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // IR
|
||||
productBits.setCharAt(3, '1'); // RE/D
|
||||
productBits.setCharAt(8, '1'); // ARZ/EXT
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // S/SN/R
|
||||
}
|
||||
else if (product == 'U' || product == 'T')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Tram/Metro
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Bus
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Seilbahn
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -84,6 +84,12 @@ public class SeProvider extends AbstractHafasProvider
|
|||
throw new IllegalArgumentException("cannot handle: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_NAME_KN = Pattern.compile("(.*?) \\((.*?) kn\\)");
|
||||
|
||||
@Override
|
||||
|
|
|
@ -72,6 +72,37 @@ public class SeptaProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
}
|
||||
else if (product == 'R' || product == 'S')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regional Rail
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Subway
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(1, '1'); // Trolley
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // Bus
|
||||
}
|
||||
else if (product == 'P' || product == 'F' || product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_ADDRESS = Pattern.compile("(.*),\\s+([^,]+\\s+\\d{4,5})");
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ShProvider extends AbstractHafasProvider
|
|||
|
||||
public ShProvider()
|
||||
{
|
||||
super(API_BASE + "query.exe/dn", 16, null);
|
||||
super(API_BASE + "query.exe/dn", 10, null);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
@ -65,6 +65,52 @@ public class ShProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -66,6 +66,39 @@ public class SncbProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(2, '1'); // IC/IR/P/ICT
|
||||
}
|
||||
else if (product == 'R'||product == 'S')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Zug
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Metro
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(10, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Bus
|
||||
}
|
||||
else if (product == 'F' || product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -55,6 +55,43 @@ public class VbbProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(5, '1');
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(6, '1');
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(0, '1');
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(1, '1');
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(2, '1');
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(3, '1');
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(4, '1');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern P_SPLIT_NAME_PAREN = Pattern.compile("(.*?) \\((.{4,}?)\\)(?: \\((U|S|S\\+U)\\))?");
|
||||
private static final Pattern P_SPLIT_NAME_COMMA = Pattern.compile("([^,]*), ([^,]*)");
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class VbnProvider extends AbstractHafasProvider
|
|||
|
||||
public VbnProvider()
|
||||
{
|
||||
super(API_BASE + "query.exe/dn", 11, null);
|
||||
super(API_BASE + "query.exe/dn", 10, null);
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
|
@ -53,6 +53,52 @@ public class VbnProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // Bus
|
||||
}
|
||||
else if (product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
|
|
|
@ -64,6 +64,54 @@ public class VgsProvider extends AbstractHafasProvider
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
||||
productBits.setCharAt(1, '1'); // IC/EC
|
||||
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
||||
}
|
||||
else if (product == 'R')
|
||||
{
|
||||
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // S-Bahn
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // U-Bahn
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Stadtbahn
|
||||
}
|
||||
else if (product == 'B')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Bus
|
||||
productBits.setCharAt(10, '1'); // Schulbus
|
||||
}
|
||||
else if (product == 'P')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(8, '1'); // Schiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
|
|
|
@ -54,6 +54,48 @@ public class ZvvProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setProductBits(final StringBuilder productBits, final char product)
|
||||
{
|
||||
if (product == 'I')
|
||||
{
|
||||
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 == 'R')
|
||||
{
|
||||
productBits.setCharAt(2, '1'); // InterRegio
|
||||
productBits.setCharAt(3, '1'); // Schnellzug/RegioExpress
|
||||
}
|
||||
else if (product == 'S')
|
||||
{
|
||||
productBits.setCharAt(5, '1'); // S-Bahn/StadtExpress/Eilzug/Regionalzug
|
||||
}
|
||||
else if (product == 'U')
|
||||
{
|
||||
}
|
||||
else if (product == 'T')
|
||||
{
|
||||
productBits.setCharAt(9, '1'); // Tram
|
||||
}
|
||||
else if (product == 'B' || product == 'P')
|
||||
{
|
||||
productBits.setCharAt(6, '1'); // Postauto/Bus
|
||||
}
|
||||
else if (product == 'F')
|
||||
{
|
||||
productBits.setCharAt(4, '1'); // Schiff/Fähre/Dampfschiff
|
||||
}
|
||||
else if (product == 'C')
|
||||
{
|
||||
productBits.setCharAt(7, '1'); // Luftseilbahn/Standseilbahn/Bergbahn
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + product);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Zürich" };
|
||||
|
||||
@Override
|
||||
|
@ -163,6 +205,8 @@ public class ZvvProvider extends AbstractHafasProvider
|
|||
return 'B';
|
||||
if ("TRO-NF".equals(ucType)) // Niederflur
|
||||
return 'B';
|
||||
if ("N".equals(ucType)) // Nachtbus
|
||||
return 'B';
|
||||
if ("BUXI".equals(ucType))
|
||||
return 'B';
|
||||
if ("TX".equals(ucType))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue