diff --git a/src/de/schildbach/pte/OebbProvider.java b/src/de/schildbach/pte/OebbProvider.java index 58a0eb8b..79e25d6f 100644 --- a/src/de/schildbach/pte/OebbProvider.java +++ b/src/de/schildbach/pte/OebbProvider.java @@ -18,25 +18,16 @@ package de.schildbach.pte; import java.io.IOException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import de.schildbach.pte.dto.Connection; -import de.schildbach.pte.dto.GetConnectionDetailsResult; -import de.schildbach.pte.dto.Line; 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; -import de.schildbach.pte.exception.SessionExpiredException; import de.schildbach.pte.util.ParserUtils; /** @@ -51,7 +42,7 @@ public class OebbProvider extends AbstractHafasProvider public OebbProvider() { - super(null, 12, null); + super(API_BASE + "query.exe/dn", 12, null); } public NetworkId id() @@ -72,7 +63,48 @@ public class OebbProvider extends AbstractHafasProvider @Override protected void setProductBits(final StringBuilder productBits, final char product) { - throw new UnsupportedOperationException(); + if (product == 'I') + { + productBits.setCharAt(0, '1'); // railjet/ICE + productBits.setCharAt(1, '1'); // ÖBB EC/ÖBB IC + productBits.setCharAt(2, '1'); // EC/IC + } + else if (product == 'R') + { + productBits.setCharAt(3, '1'); // D/EN + productBits.setCharAt(4, '1'); // REX/R + } + else if (product == 'S') + { + productBits.setCharAt(5, '1'); // S-Bahnen + } + else if (product == 'U') + { + productBits.setCharAt(8, '1'); // U-Bahn + } + else if (product == 'T') + { + productBits.setCharAt(9, '1'); // Straßenbahn + } + else if (product == 'B') + { + productBits.setCharAt(6, '1'); // Busse + } + else if (product == 'P') + { + productBits.setCharAt(11, '1'); // Anrufpflichtige Verkehre + } + else if (product == 'F') + { + productBits.setCharAt(7, '1'); // Schiffe + } + 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 @@ -138,366 +170,6 @@ public class OebbProvider extends AbstractHafasProvider WALKSPEED_MAP.put(WalkSpeed.FAST, "85"); } - private String connectionsQuery(final Location from, final Location via, final Location to, final Date date, final boolean dep, - final String products, final WalkSpeed walkSpeed) throws IOException - { - final Calendar c = new GregorianCalendar(timeZone()); - c.setTime(date); - - final StringBuilder uri = new StringBuilder(); - - uri.append("queryPageDisplayed=yes"); - uri.append("&ignoreTypeCheck=yes"); - uri.append("&REQ0JourneyStopsS0ID=").append(ParserUtils.urlEncode(locationId(from), URL_ENCODING)); - if (via != null) - uri.append("&REQ0JourneyStops1.0ID=").append(ParserUtils.urlEncode(locationId(via), URL_ENCODING)); - uri.append("&REQ0JourneyStopsZ0ID=").append(ParserUtils.urlEncode(locationId(to), URL_ENCODING)); - uri.append("&REQ0JourneyDate=").append( - String.format("%02d.%02d.%02d", c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.MONTH) + 1, c.get(Calendar.YEAR) - 2000)); - uri.append("&wDayExt0=").append(ParserUtils.urlEncode("Mo|Di|Mi|Do|Fr|Sa|So")); - uri.append("&REQ0JourneyTime=").append(String.format("%02d:%02d", c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE))); - uri.append("&REQ0HafasSearchForw=").append(dep ? "1" : "0"); - uri.append("&existHafasDemo3=yes"); - uri.append("&REQ0JourneyDep_Foot_speed=").append(WALKSPEED_MAP.get(walkSpeed)); - uri.append("&existBikeEverywhere=yes"); - uri.append("&existHafasAttrInc=yes"); - uri.append("&start=Verbindungen+suchen"); - - if (products != null) - { - for (final char p : products.toCharArray()) - { - if (p == 'I') - { - uri.append("&REQ0JourneyProduct_prod_section_0_0=1&REQ0JourneyProduct_prod_section_0_1=1&REQ0JourneyProduct_prod_section_0_2=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_0=1&REQ0JourneyProduct_prod_section_1_1=1&REQ0JourneyProduct_prod_section_1_2=1"); - } - if (p == 'R') - { - uri.append("&REQ0JourneyProduct_prod_section_0_3=1&REQ0JourneyProduct_prod_section_0_4=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_3=1&REQ0JourneyProduct_prod_section_1_4=1"); - } - if (p == 'S') - { - uri.append("&REQ0JourneyProduct_prod_section_0_5=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_5=1"); - } - if (p == 'U') - { - uri.append("&REQ0JourneyProduct_prod_section_0_8=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_8=1"); - } - if (p == 'T') - { - uri.append("&REQ0JourneyProduct_prod_section_0_9=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_9=1"); - } - if (p == 'B') - { - uri.append("&REQ0JourneyProduct_prod_section_0_6=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_6=1"); - } - if (p == 'P') - { - uri.append("&REQ0JourneyProduct_prod_section_0_11=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_11=1"); - } - if (p == 'F') - { - uri.append("&REQ0JourneyProduct_prod_section_0_7=1"); - if (via != null) - uri.append("&REQ0JourneyProduct_prod_section_1_7=1"); - } - // FIXME if (p == 'C') - } - } - - return uri.toString(); - } - - private static final String QUERY_CONNECTIONS_FORM_URL = API_BASE + "query.exe/dn?"; - private static final Pattern P_QUERY_CONNECTIONS_FORM_ACTION = Pattern - .compile("