mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 17:39:49 +00:00
Poland
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@608 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
bafa81b8f5
commit
bb548b6adb
10 changed files with 460 additions and 48 deletions
|
@ -63,11 +63,23 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
private final String apiUri;
|
||||
private static final String prod = "hafas";
|
||||
private final String accessId;
|
||||
private final String ajaxGetStopsEncoding;
|
||||
private final String mlcResEncoding;
|
||||
|
||||
public AbstractHafasProvider(final String apiUri, final String accessId, final String ajaxGetStopsEncoding, final String mlcResEncoding)
|
||||
{
|
||||
this.apiUri = apiUri;
|
||||
this.accessId = accessId;
|
||||
this.ajaxGetStopsEncoding = ajaxGetStopsEncoding;
|
||||
this.mlcResEncoding = mlcResEncoding;
|
||||
}
|
||||
|
||||
public AbstractHafasProvider(final String apiUri, final String accessId)
|
||||
{
|
||||
this.apiUri = apiUri;
|
||||
this.accessId = accessId;
|
||||
this.ajaxGetStopsEncoding = DEFAULT_ENCODING;
|
||||
this.mlcResEncoding = DEFAULT_ENCODING;
|
||||
}
|
||||
|
||||
protected TimeZone timeZone()
|
||||
|
@ -205,7 +217,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
|
||||
protected final List<Location> ajaxGetStops(final String uri) throws IOException
|
||||
{
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
final CharSequence page = ParserUtils.scrape(uri, false, null, ajaxGetStopsEncoding, false);
|
||||
|
||||
final Matcher mJson = P_AJAX_GET_STOPS_JSON.matcher(page);
|
||||
if (mJson.matches())
|
||||
|
@ -234,7 +246,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
|
||||
if (type == 1) // station
|
||||
{
|
||||
results.add(new Location(LocationType.STATION, localId, lat, lon, null, value));
|
||||
final String[] nameAndPlace = splitNameAndPlace(value);
|
||||
results.add(new Location(LocationType.STATION, localId, lat, lon, nameAndPlace[0], nameAndPlace[1]));
|
||||
}
|
||||
else if (type == 2) // address
|
||||
{
|
||||
|
@ -276,7 +289,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
{
|
||||
final String request = "<MLcReq><MLc n=\"" + constraint + "?\" t=\"ALLTYPE\" /></MLcReq>";
|
||||
|
||||
// ParserUtils.printXml(ParserUtils.scrape(apiUri, true, wrap(request), null, false));
|
||||
// ParserUtils.printXml(ParserUtils.scrape(apiUri, true, wrap(request), mlcResEncoding, false));
|
||||
|
||||
InputStream is = null;
|
||||
|
||||
|
@ -286,7 +299,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
|
||||
final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
|
||||
final XmlPullParser pp = factory.newPullParser();
|
||||
pp.setInput(is, DEFAULT_ENCODING);
|
||||
pp.setInput(is, mlcResEncoding);
|
||||
|
||||
final List<Location> results = new ArrayList<Location>();
|
||||
|
||||
|
@ -330,7 +343,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
final int lon = Integer.parseInt(iMatcherLonLat.group(1));
|
||||
final int lat = Integer.parseInt(iMatcherLonLat.group(2));
|
||||
|
||||
results.add(new Location(type, id, lat, lon, null, name));
|
||||
final String[] nameAndPlace = splitNameAndPlace(name);
|
||||
results.add(new Location(type, id, lat, lon, nameAndPlace[0], nameAndPlace[1]));
|
||||
|
||||
XmlPullUtil.next(pp);
|
||||
}
|
||||
|
@ -661,6 +675,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
XmlPullUtil.enter(pp, "JourneyAttributeList");
|
||||
String name = null;
|
||||
String category = null;
|
||||
String shortCategory = null;
|
||||
String longCategory = null;
|
||||
while (XmlPullUtil.test(pp, "JourneyAttribute"))
|
||||
{
|
||||
|
@ -678,6 +693,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
}
|
||||
else if ("CATEGORY".equals(attrName))
|
||||
{
|
||||
shortCategory = attributeVariants.get("SHORT");
|
||||
category = attributeVariants.get("NORMAL");
|
||||
longCategory = attributeVariants.get("LONG");
|
||||
}
|
||||
|
@ -689,6 +705,9 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
XmlPullUtil.exit(pp);
|
||||
XmlPullUtil.exit(pp);
|
||||
|
||||
if (category == null)
|
||||
category = shortCategory;
|
||||
|
||||
final char type = normalizeType(category);
|
||||
final String lineStr;
|
||||
if (type != 0)
|
||||
|
@ -960,7 +979,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
parsedLat = 0;
|
||||
}
|
||||
|
||||
stations.add(new Location(LocationType.STATION, parsedId, parsedLat, parsedLon, null, parsedName));
|
||||
final String[] nameAndPlace = splitNameAndPlace(parsedName);
|
||||
stations.add(new Location(LocationType.STATION, parsedId, parsedLat, parsedLon, nameAndPlace[0], nameAndPlace[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1073,6 +1093,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 'I';
|
||||
if (ucType.equals("ICT")) // InterCity
|
||||
return 'I';
|
||||
if ("ICN".equals(ucType)) // Intercity-Neigezug, Schweiz
|
||||
return 'I';
|
||||
if (ucType.equals("CNL")) // CityNightLine
|
||||
return 'I';
|
||||
if (ucType.equals("OEC")) // ÖBB-EuroCity
|
||||
|
@ -1085,7 +1107,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 'I';
|
||||
if (ucType.equals("TGV")) // Train à Grande Vitesse
|
||||
return 'I';
|
||||
if (ucType.equals("DNZ")) // Berlin-Saratov, Berlin-Moskva, Connections only?
|
||||
if (ucType.equals("DNZ")) // Nachtzug Basel-Moskau
|
||||
return 'I';
|
||||
if (ucType.equals("AIR")) // Generic Flight
|
||||
return 'I';
|
||||
|
@ -1101,6 +1123,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 'I';
|
||||
if (ucType.equals("IRX")) // IC
|
||||
return 'I';
|
||||
if ("FLUG".equals(ucType))
|
||||
return 'I';
|
||||
|
||||
// Regional
|
||||
if (ucType.equals("ZUG")) // Generic Train
|
||||
|
@ -1129,6 +1153,10 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 'R';
|
||||
if (ucType.equals("SP")) // Spěšný vlak, Czech Republic
|
||||
return 'R';
|
||||
if ("EZ".equals(ucType)) // ÖBB ErlebnisBahn
|
||||
return 'R';
|
||||
if ("ARZ".equals(ucType)) // Auto-Reisezug Brig - Iselle di Trasquera
|
||||
return 'R';
|
||||
|
||||
// Suburban Trains
|
||||
if (ucType.equals("S")) // Generic S-Bahn
|
||||
|
@ -1141,6 +1169,10 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
// Tram
|
||||
if (ucType.equals("STR")) // Generic Tram
|
||||
return 'T';
|
||||
if ("TRAM".equals(ucType))
|
||||
return 'T';
|
||||
if ("TRA".equals(ucType))
|
||||
return 'T';
|
||||
|
||||
// Bus
|
||||
if (ucType.equals("BUS")) // Generic Bus
|
||||
|
@ -1165,6 +1197,16 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 'F';
|
||||
if (ucType.equals("AS")) // SyltShuttle, eigentlich Autoreisezug
|
||||
return 'F';
|
||||
if ("SCHIFF".equals(ucType))
|
||||
return 'F';
|
||||
if ("KAT".equals(ucType)) // Katamaran
|
||||
return 'F';
|
||||
|
||||
// Cable Car
|
||||
if ("SB".equals(ucType)) // Seilbahn
|
||||
return 'C';
|
||||
if ("ZAHNR".equals(ucType)) // Zahnradbahn, u.a. Zugspitzbahn
|
||||
return 'C';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -520,13 +520,6 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
@Override
|
||||
protected final String normalizeLine(final String line)
|
||||
{
|
||||
// TODO ARZ Simplon Tunnel: Brig - Iselle di Trasquera
|
||||
// ARZ29171
|
||||
// ARZ29172
|
||||
// ARZ29173
|
||||
// ARZ29177
|
||||
// ARZ29178
|
||||
|
||||
if (line == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ public enum NetworkId
|
|||
// Slovenia
|
||||
MARIBOR,
|
||||
|
||||
// Poland
|
||||
PL,
|
||||
|
||||
// Italy
|
||||
ATC,
|
||||
|
||||
|
|
|
@ -212,9 +212,6 @@ public class NsProvider extends AbstractHafasProvider
|
|||
if (ucType.equals("MÉT"))
|
||||
return 'U';
|
||||
|
||||
if (ucType.equals("TRA"))
|
||||
return 'T';
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -622,17 +622,11 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
return 'I';
|
||||
if (ucType.equals("LYN")) // Dänemark
|
||||
return 'I';
|
||||
if (ucType.equals("ARZ")) // Frankreich, Nacht
|
||||
return 'I';
|
||||
if (ucType.equals("ES")) // Eurostar Italia
|
||||
return 'I';
|
||||
if (ucType.equals("ICN")) // Italien, Nacht
|
||||
return 'I';
|
||||
if (ucType.equals("UUU")) // Italien, Nacht, Connections only?
|
||||
return 'I';
|
||||
|
||||
if (ucType.equals("EZ")) // Erlebniszug
|
||||
return 'R';
|
||||
if (ucType.equals("S2")) // Helsinki-Turku, Connections only?
|
||||
return 'R';
|
||||
if (ucType.equals("RE")) // RegionalExpress Deutschland
|
||||
|
@ -810,7 +804,7 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
return 'B';
|
||||
if (ucType.equals("BUSTN/TW")) // via JSON API
|
||||
return 'B';
|
||||
if (ucType.equals("BUSMKK")) // via JSON API
|
||||
if (ucType.equals("BUSMKK")) // Main-Kinz-Kreis, via JSON API
|
||||
return 'B';
|
||||
if (ucType.equals("BUSG")) // via JSON API
|
||||
return 'B';
|
||||
|
@ -821,15 +815,11 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
|
||||
if (ucType.equals("SCH")) // Connections only?
|
||||
return 'F';
|
||||
if (ucType.equals("SCHIFF")) // via JSON API
|
||||
return 'F';
|
||||
if (ucType.equals("F")) // Fähre
|
||||
return 'F';
|
||||
if (ucType.equals("FÄHRE")) // via JSON API
|
||||
return 'F';
|
||||
|
||||
if (ucType.equals("SB")) // Connections only?
|
||||
return 'C';
|
||||
if (ucType.equals("LIF"))
|
||||
return 'C';
|
||||
if (ucType.equals("SEILBAHN")) // via JSON API
|
||||
|
@ -839,9 +829,6 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
if (ucType.equals("HBB")) // Innsbruck Hungerburgbahn, via JSON API
|
||||
return 'C';
|
||||
|
||||
if (ucType.equals("FLUG")) // via JSON API
|
||||
return 'I';
|
||||
|
||||
if (ucType.equals("U70")) // U.K., Connections only?
|
||||
return '?';
|
||||
if (ucType.equals("R84")) // U.K., Connections only?
|
||||
|
|
324
src/de/schildbach/pte/PlProvider.java
Normal file
324
src/de/schildbach/pte/PlProvider.java
Normal file
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* Copyright 2010, 2011 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.util.ParserUtils;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class PlProvider extends AbstractHafasProvider
|
||||
{
|
||||
public static final NetworkId NETWORK_ID = NetworkId.PL;
|
||||
private static final String API_BASE = "http://rozklad.sitkol.pl/bin/";
|
||||
|
||||
public PlProvider()
|
||||
{
|
||||
super(API_BASE + "query.exe/pn", null, null, "UTF-8");
|
||||
}
|
||||
|
||||
public NetworkId id()
|
||||
{
|
||||
return NETWORK_ID;
|
||||
}
|
||||
|
||||
public boolean hasCapabilities(Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.AUTOCOMPLETE_ONE_LINE || capability == Capability.DEPARTURES || capability == Capability.CONNECTIONS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String[] PLACES = { "Warszawa", "Kraków" };
|
||||
|
||||
@Override
|
||||
protected String[] splitNameAndPlace(final String name)
|
||||
{
|
||||
for (final String place : PLACES)
|
||||
{
|
||||
if (name.endsWith(", " + place))
|
||||
return new String[] { place, name.substring(0, name.length() - place.length() - 2) };
|
||||
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
|
||||
return new String[] { place, name.substring(place.length() + 1) };
|
||||
}
|
||||
|
||||
return super.splitNameAndPlace(name);
|
||||
}
|
||||
|
||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
return xmlMLcReq(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String nearbyStationUri(String stationId)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||
uri.append("stboard.exe/pn");
|
||||
uri.append("?productsFilter=1111111");
|
||||
uri.append("&boardType=dep");
|
||||
uri.append("&input=").append(ParserUtils.urlEncode(stationId));
|
||||
uri.append("&sTI=1&start=yes&hcount=0");
|
||||
uri.append("&L=vs_java3");
|
||||
|
||||
// &inputTripelId=A%3d1%40O%3dCopenhagen%20Airport%40X%3d12646941%40Y%3d55629753%40U%3d86%40L%3d900000011%40B%3d1
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
|
||||
private static final Pattern P_NORMALIZE_LINE_RUSSIA = Pattern.compile("(?:D\\s*)?(\\d{1,3}(?:[A-Z]{2}|Y))");
|
||||
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{2,5}");
|
||||
|
||||
@Override
|
||||
protected String normalizeLine(String line)
|
||||
{
|
||||
final Matcher mRussia = P_NORMALIZE_LINE_RUSSIA.matcher(line);
|
||||
if (mRussia.matches())
|
||||
return 'R' + mRussia.group(1);
|
||||
|
||||
if (P_NORMALIZE_LINE_NUMBER.matcher(line).matches())
|
||||
return 'R' + line;
|
||||
|
||||
return super.normalizeLine(line);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char normalizeType(final String type)
|
||||
{
|
||||
final String ucType = type.toUpperCase();
|
||||
|
||||
if ("TLK".equals(ucType)) // Tanie Linie Kolejowe, Polen
|
||||
return 'I';
|
||||
if ("X".equals(ucType)) // Schweden
|
||||
return 'I';
|
||||
if ("NZ".equals(ucType)) // Schweden, Nacht
|
||||
return 'I';
|
||||
if ("LYN".equals(ucType)) // Dänemark
|
||||
return 'I';
|
||||
if ("HOT".equals(ucType)) // Spanien, Nacht
|
||||
return 'I';
|
||||
if ("AVE".equals(ucType)) // Alta Velocidad Española, Spanien
|
||||
return 'I';
|
||||
if ("TLG".equals(ucType)) // Spanien, Madrid
|
||||
return 'I';
|
||||
if ("ALS".equals(ucType)) // Spanien
|
||||
return 'I';
|
||||
if ("ARC".equals(ucType)) // Spanien
|
||||
return 'I';
|
||||
if ("EM".equals(ucType)) // EuroMed, Barcelona-Alicante, Spanien
|
||||
return 'I';
|
||||
if ("ES".equals(ucType)) // Eurostar Italia
|
||||
return 'I';
|
||||
if ("SC".equals(ucType)) // SuperCity, Tschechien
|
||||
return 'I';
|
||||
if ("EST".equals(ucType)) // Eurostar Frankreich
|
||||
return 'I';
|
||||
if ("FYR".equals(ucType)) // Fyra, Amsterdam-Schiphol-Rotterdam
|
||||
return 'I';
|
||||
|
||||
if ("D".equals(ucType))
|
||||
return 'R';
|
||||
if ("KM".equals(ucType)) // Koleje Mazowieckie
|
||||
return 'R';
|
||||
if ("KD".equals(ucType)) // Koleje Dolnoslaskie
|
||||
return 'R';
|
||||
if ("AR".equals(ucType)) // Arriva Polaczen
|
||||
return 'R';
|
||||
if ("NEB".equals(ucType)) // Niederbarnimer Eisenbahn
|
||||
return 'R';
|
||||
if ("NWB".equals(ucType)) // NordWestBahn
|
||||
return 'R';
|
||||
if ("OE".equals(ucType)) // Ostdeutsche Eisenbahn
|
||||
return 'R';
|
||||
if ("MR".equals(ucType)) // Märkische Regionalbahn
|
||||
return 'R';
|
||||
if ("MRB".equals(ucType)) // Mitteldeutsche Regiobahn
|
||||
return 'R';
|
||||
if ("HZL".equals(ucType)) // Hohenzollerische Landesbahn
|
||||
return 'R';
|
||||
if ("PEG".equals(ucType)) // Prignitzer Eisenbahn
|
||||
return 'R';
|
||||
if ("HLB".equals(ucType)) // Hessische Landesbahn
|
||||
return 'R';
|
||||
if ("VBG".equals(ucType)) // Vogtlandbahn
|
||||
return 'R';
|
||||
if ("CAN".equals(ucType)) // cantus Verkehrsgesellschaft
|
||||
return 'R';
|
||||
if ("TLX".equals(ucType)) // Trilex (Vogtlandbahn)
|
||||
return 'R';
|
||||
if ("SBB".equals(ucType)) // Schweizerische Bundesbahnen
|
||||
return 'R';
|
||||
if ("HSB".equals(ucType)) // Harzer Schmalspurbahnen
|
||||
return 'R';
|
||||
if ("OLA".equals(ucType)) // Ostseeland Verkehr
|
||||
return 'R';
|
||||
if ("ÖBA".equals(ucType)) // Öchsle-Bahn Betriebsgesellschaft
|
||||
return 'R';
|
||||
if ("BOB".equals(ucType)) // Bayerische Oberlandbahn
|
||||
return 'R';
|
||||
if ("VEC".equals(ucType)) // vectus Verkehrsgesellschaft
|
||||
return 'R';
|
||||
if ("OSB".equals(ucType)) // Ortenau-S-Bahn
|
||||
return 'R';
|
||||
if ("FEG".equals(ucType)) // Freiberger Eisenbahngesellschaft
|
||||
return 'R';
|
||||
if ("BRB".equals(ucType)) // ABELLIO Rail
|
||||
return 'R';
|
||||
if ("EB".equals(ucType)) // Erfurter Bahn
|
||||
return 'R';
|
||||
if ("SBS".equals(ucType)) // Städtebahn Sachsen
|
||||
return 'R';
|
||||
if ("WEG".equals(ucType)) // Württembergische Eisenbahn-Gesellschaft
|
||||
return 'R';
|
||||
if ("EX".equals(ucType)) // Polen
|
||||
return 'R';
|
||||
if ("ERB".equals(ucType)) // eurobahn (Keolis Deutschland)
|
||||
return 'R';
|
||||
if ("UBB".equals(ucType)) // Usedomer Bäderbahn
|
||||
return 'R';
|
||||
if ("RTB".equals(ucType)) // Rurtalbahn
|
||||
return 'R';
|
||||
if ("EVB".equals(ucType)) // Eisenbahnen und Verkehrsbetriebe Elbe-Weser
|
||||
return 'R';
|
||||
if ("RNV".equals(ucType)) // Rhein-Neckar-Verkehr GmbH
|
||||
return 'R';
|
||||
if ("VIA".equals(ucType))
|
||||
return 'R';
|
||||
if ("ME".equals(ucType)) // metronom Eisenbahngesellschaft
|
||||
return 'R';
|
||||
if ("MER".equals(ucType)) // metronom regional
|
||||
return 'R';
|
||||
if ("ALX".equals(ucType)) // Arriva-Länderbahn-Express
|
||||
return 'R';
|
||||
if ("STB".equals(ucType)) // Süd-Thüringen-Bahn
|
||||
return 'R';
|
||||
if ("CB".equals(ucType)) // City Bahn Chemnitz
|
||||
return 'R';
|
||||
if ("HTB".equals(ucType)) // Hörseltalbahn
|
||||
return 'R';
|
||||
if ("NOB".equals(ucType)) // Nord-Ostsee-Bahn
|
||||
return 'R';
|
||||
if ("ARR".equals(ucType)) // Ostfriesland
|
||||
return 'R';
|
||||
if ("ABR".equals(ucType)) // Bayerische Regiobahn
|
||||
return 'R';
|
||||
if ("AG".equals(ucType)) // Ingolstadt-Landshut
|
||||
return 'R';
|
||||
if ("PRE".equals(ucType)) // Pressnitztalbahn
|
||||
return 'R';
|
||||
if ("ZR".equals(ucType)) // Bratislava, Slovakai
|
||||
return 'R';
|
||||
if ("AKN".equals(ucType)) // AKN Eisenbahn AG
|
||||
return 'R';
|
||||
if ("SHB".equals(ucType)) // Schleswig-Holstein-Bahn
|
||||
return 'R';
|
||||
if ("P".equals(ucType)) // Kasbachtalbahn
|
||||
return 'R';
|
||||
if ("NBE".equals(ucType)) // nordbahn
|
||||
return 'R';
|
||||
if ("SDG".equals(ucType)) // Sächsische Dampfeisenbahngesellschaft
|
||||
return 'R';
|
||||
if ("MBB".equals(ucType)) // Mecklenburgische Bäderbahn Molli
|
||||
return 'R';
|
||||
if ("VE".equals(ucType)) // Lutherstadt Wittenberg
|
||||
return 'R';
|
||||
if ("SOE".equals(ucType)) // Sächsisch-Oberlausitzer Eisenbahngesellschaft
|
||||
return 'R';
|
||||
if ("BLB".equals(ucType)) // Berchtesgadener Land Bahn
|
||||
return 'R';
|
||||
if ("DAB".equals(ucType)) // Daadetalbahn
|
||||
return 'R';
|
||||
if ("VEN".equals(ucType)) // Rhenus Veniro
|
||||
return 'R';
|
||||
if ("NEG".equals(ucType)) // Norddeutsche Eisenbahngesellschaft Niebüll
|
||||
return 'R';
|
||||
if ("WTB".equals(ucType)) // Wutachtalbahn e.V.
|
||||
return 'R';
|
||||
if ("KTB".equals(ucType)) // Kandertalbahn
|
||||
return 'R';
|
||||
if ("BE".equals(ucType)) // Grensland-Express
|
||||
return 'R';
|
||||
if ("CAT".equals(ucType)) // City Airport Train
|
||||
return 'R';
|
||||
if ("ATR".equals(ucType)) // Spanien
|
||||
return 'R';
|
||||
if ("N".equals(ucType)) // St. Pierre des Corps - Tours
|
||||
return 'R';
|
||||
// if ("INT".equals(ucType)) // Rußland
|
||||
// return 'R';
|
||||
|
||||
if ("SKM".equals(ucType)) // Szybka Kolej Miejska Tricity
|
||||
return 'S';
|
||||
if ("SKW".equals(ucType)) // Szybka Kolej Miejska Warschau
|
||||
return 'S';
|
||||
if ("WKD".equals(ucType)) // Warszawska Kolej Dojazdowa
|
||||
return 'S';
|
||||
if ("RER".equals(ucType)) // Réseau Express Régional, Frankreich
|
||||
return 'S';
|
||||
if ("SWE".equals(ucType)) // Südwestdeutsche Verkehrs-AG, Ortenau-S-Bahn
|
||||
return 'S';
|
||||
if ("BSB".equals(ucType)) // Breisgau S-Bahn
|
||||
return 'S';
|
||||
|
||||
if ("METRO".equals(ucType))
|
||||
return 'U';
|
||||
|
||||
if ("BUSMKK".equals(ucType)) // Main-Kinz-Kreis
|
||||
return 'B';
|
||||
|
||||
final char t = normalizeCommonTypes(ucType);
|
||||
if (t != 0)
|
||||
return t;
|
||||
|
||||
if ("E".equals(ucType))
|
||||
return '?';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final int maxDepartures, final boolean equivs) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder();
|
||||
uri.append(API_BASE).append("stboard.exe/pn");
|
||||
uri.append("?productsFilter=1111111");
|
||||
uri.append("&boardType=dep");
|
||||
uri.append("&maxJourneys=50"); // ignore maxDepartures because result contains other stations
|
||||
uri.append("&start=yes");
|
||||
uri.append("&L=vs_java3");
|
||||
uri.append("&input=").append(stationId);
|
||||
|
||||
return xmlQueryDepartures(uri.toString(), Integer.parseInt(stationId));
|
||||
}
|
||||
}
|
|
@ -219,8 +219,6 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
if (t != 0)
|
||||
return t;
|
||||
|
||||
if (ucType.equals("ICN")) // Intercity-Neigezug, Schweiz
|
||||
return 'I';
|
||||
if (ucType.equals("X")) // InterConnex
|
||||
return 'I';
|
||||
if (ucType.equals("ES")) // Eurostar Italia
|
||||
|
@ -235,12 +233,10 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
return 'I';
|
||||
if (ucType.equals("TAL")) // Talgo, Spanien
|
||||
return 'I';
|
||||
if (ucType.equals("EM")) // Barcelona-Alicante, Spanien
|
||||
if (ucType.equals("EM")) // EuroMed, Barcelona-Alicante, Spanien
|
||||
return 'I';
|
||||
if (ucType.equals("FYR")) // Fyra, Amsterdam-Schiphol-Rotterdam
|
||||
return 'I';
|
||||
if (ucType.equals("ARZ")) // Frankreich, Nacht
|
||||
return 'I';
|
||||
|
||||
if (ucType.equals("D"))
|
||||
return 'R';
|
||||
|
@ -269,10 +265,6 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
if (ucType.equals("MET")) // Lausanne
|
||||
return 'U';
|
||||
|
||||
if (ucType.equals("TRAM"))
|
||||
return 'T';
|
||||
if (ucType.equals("TRA"))
|
||||
return 'T';
|
||||
if (ucType.equals("M")) // Lausanne
|
||||
return 'T';
|
||||
if (ucType.equals("T"))
|
||||
|
|
|
@ -219,9 +219,6 @@ public class SncbProvider extends AbstractHafasProvider
|
|||
if (ucType.equals("MÉT"))
|
||||
return 'U';
|
||||
|
||||
if (ucType.equals("TRA"))
|
||||
return 'T';
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,9 +113,6 @@ public class ZvvProvider extends AbstractHafasProvider
|
|||
// E-Bus: Bus, Tram oder Zug?
|
||||
// TX: Ruftaxi?
|
||||
|
||||
if ("ICN".equals(ucType))
|
||||
return 'I';
|
||||
|
||||
if ("D".equals(ucType))
|
||||
return 'R';
|
||||
if ("EXT".equals(ucType))
|
||||
|
@ -140,8 +137,6 @@ public class ZvvProvider extends AbstractHafasProvider
|
|||
if ("TRO".equals(ucType))
|
||||
return 'B';
|
||||
|
||||
if ("SCHIFF".equals(ucType))
|
||||
return 'F';
|
||||
if ("D-SCHIFF".equals(ucType))
|
||||
return 'F';
|
||||
if ("FAE".equals(ucType))
|
||||
|
|
82
test/de/schildbach/pte/live/PlProviderLiveTest.java
Normal file
82
test/de/schildbach/pte/live/PlProviderLiveTest.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright 2010, 2011 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||
import de.schildbach.pte.PlProvider;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class PlProviderLiveTest
|
||||
{
|
||||
private final PlProvider provider = new PlProvider();
|
||||
private static final String ALL_PRODUCTS = "IRSUTBFC";
|
||||
|
||||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Warszawa");
|
||||
|
||||
list(autocompletes);
|
||||
}
|
||||
|
||||
private void list(final List<Location> autocompletes)
|
||||
{
|
||||
System.out.print(autocompletes.size() + " ");
|
||||
for (final Location autocomplete : autocompletes)
|
||||
System.out.print(autocomplete.toDebugString() + " ");
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStation() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.nearbyStations("5100065", 0, 0, 0, 0);
|
||||
|
||||
System.out.println(result.stations.size() + " " + result.stations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDepartures() throws Exception
|
||||
{
|
||||
final QueryDeparturesResult result = provider.queryDepartures("5100065", 0, false);
|
||||
|
||||
System.out.println(result.stationDepartures);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortConnection() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 5196001, null, "KRAKÓW"), null,
|
||||
new Location(LocationType.STATION, 5196003, null, "WARSZAWA"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
|
||||
System.out.println(moreResult);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue